Merge pull request #17521 from rohitwaghchaure/fixed_get_invoiced_item_gross_margin

fix: get totals of gross profit amount on call of the method get_invoiced_item_gross_margin
This commit is contained in:
rohitwaghchaure
2019-05-08 16:17:11 +05:30
committed by GitHub

View File

@@ -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