mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-08 15:42:52 +00:00
Merge pull request #28480 from frappe/mergify/bp/version-13-hotfix/pr-28402
fix: Gross Profit report totals (backport #28402)
This commit is contained in:
@@ -44,7 +44,7 @@ frappe.query_reports["Gross Profit"] = {
|
|||||||
"formatter": function(value, row, column, data, default_formatter) {
|
"formatter": function(value, row, column, data, default_formatter) {
|
||||||
value = default_formatter(value, row, column, data);
|
value = default_formatter(value, row, column, data);
|
||||||
|
|
||||||
if (data && data.indent == 0.0) {
|
if (data && (data.indent == 0.0 || row[1].content == "Total")) {
|
||||||
value = $(`<span>${value}</span>`);
|
value = $(`<span>${value}</span>`);
|
||||||
var $value = $(value).css("font-weight", "bold");
|
var $value = $(value).css("font-weight", "bold");
|
||||||
value = $value.wrap("<p></p>").parent().html();
|
value = $value.wrap("<p></p>").parent().html();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"filters": [],
|
"filters": [],
|
||||||
"idx": 3,
|
"idx": 3,
|
||||||
"is_standard": "Yes",
|
"is_standard": "Yes",
|
||||||
"modified": "2021-08-19 18:57:07.468202",
|
"modified": "2021-11-13 19:14:23.730198",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Gross Profit",
|
"name": "Gross Profit",
|
||||||
|
|||||||
@@ -78,7 +78,8 @@ def get_data_when_not_grouped_by_invoice(gross_profit_data, filters, group_wise_
|
|||||||
|
|
||||||
row.append(filters.currency)
|
row.append(filters.currency)
|
||||||
if idx == len(gross_profit_data.grouped_data)-1:
|
if idx == len(gross_profit_data.grouped_data)-1:
|
||||||
row[0] = frappe.bold("Total")
|
row[0] = "Total"
|
||||||
|
|
||||||
data.append(row)
|
data.append(row)
|
||||||
|
|
||||||
def get_columns(group_wise_columns, filters):
|
def get_columns(group_wise_columns, filters):
|
||||||
@@ -247,19 +248,28 @@ class GrossProfitGenerator(object):
|
|||||||
self.add_to_totals(new_row)
|
self.add_to_totals(new_row)
|
||||||
else:
|
else:
|
||||||
for i, row in enumerate(self.grouped[key]):
|
for i, row in enumerate(self.grouped[key]):
|
||||||
if row.parent in self.returned_invoices \
|
if row.indent == 1.0:
|
||||||
and row.item_code in self.returned_invoices[row.parent]:
|
if row.parent in self.returned_invoices \
|
||||||
returned_item_rows = self.returned_invoices[row.parent][row.item_code]
|
and row.item_code in self.returned_invoices[row.parent]:
|
||||||
for returned_item_row in returned_item_rows:
|
returned_item_rows = self.returned_invoices[row.parent][row.item_code]
|
||||||
row.qty += flt(returned_item_row.qty)
|
for returned_item_row in returned_item_rows:
|
||||||
row.base_amount += flt(returned_item_row.base_amount, self.currency_precision)
|
row.qty += flt(returned_item_row.qty)
|
||||||
row.buying_amount = flt(flt(row.qty) * flt(row.buying_rate), self.currency_precision)
|
row.base_amount += flt(returned_item_row.base_amount, self.currency_precision)
|
||||||
if (flt(row.qty) or row.base_amount) and self.is_not_invoice_row(row):
|
row.buying_amount = flt(flt(row.qty) * flt(row.buying_rate), self.currency_precision)
|
||||||
row = self.set_average_rate(row)
|
if (flt(row.qty) or row.base_amount):
|
||||||
self.grouped_data.append(row)
|
row = self.set_average_rate(row)
|
||||||
self.add_to_totals(row)
|
self.grouped_data.append(row)
|
||||||
|
self.add_to_totals(row)
|
||||||
|
|
||||||
self.set_average_gross_profit(self.totals)
|
self.set_average_gross_profit(self.totals)
|
||||||
self.grouped_data.append(self.totals)
|
|
||||||
|
if self.filters.get("group_by") == "Invoice":
|
||||||
|
self.totals.indent = 0.0
|
||||||
|
self.totals.parent_invoice = ""
|
||||||
|
self.totals.parent = "Total"
|
||||||
|
self.si_list.append(self.totals)
|
||||||
|
else:
|
||||||
|
self.grouped_data.append(self.totals)
|
||||||
|
|
||||||
def is_not_invoice_row(self, row):
|
def is_not_invoice_row(self, row):
|
||||||
return (self.filters.get("group_by") == "Invoice" and row.indent != 0.0) or self.filters.get("group_by") != "Invoice"
|
return (self.filters.get("group_by") == "Invoice" and row.indent != 0.0) or self.filters.get("group_by") != "Invoice"
|
||||||
|
|||||||
Reference in New Issue
Block a user