diff --git a/erpnext/accounts/report/utils.py b/erpnext/accounts/report/utils.py index 0b17c8f964a..4a9af490cfc 100644 --- a/erpnext/accounts/report/utils.py +++ b/erpnext/accounts/report/utils.py @@ -137,7 +137,7 @@ def get_appropriate_company(filters): 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 @@ def get_invoiced_item_gross_margin(sales_invoice=None, item_code=None, company=N } 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