fix: get totals of gross profit amount on call of the method get_invoiced_item_gross_margin
diff --git a/erpnext/accounts/report/utils.py b/erpnext/accounts/report/utils.py
index 0b17c8f..4a9af49 100644
--- a/erpnext/accounts/report/utils.py
+++ b/erpnext/accounts/report/utils.py
@@ -137,7 +137,7 @@
return company
@frappe.whitelist()
-def get_invoiced_item_gross_margin(sales_invoice=None, item_code=None, company=None):
+def get_invoiced_item_gross_margin(sales_invoice=None, item_code=None, company=None, with_item_data=False):
from erpnext.accounts.report.gross_profit.gross_profit import GrossProfitGenerator
sales_invoice = sales_invoice or frappe.form_dict.get('sales_invoice')
@@ -152,5 +152,8 @@
}
gross_profit_data = GrossProfitGenerator(filters)
+ result = gross_profit_data.grouped_data
+ if not with_item_data:
+ result = sum([d.gross_profit for d in result])
- return gross_profit_data.grouped_data
+ return result