From 059f99e621fd3e5daf577f69661083319a502afa Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Thu, 27 Jul 2017 11:37:30 +0530 Subject: [PATCH] [Fix] Wrong avg. buying rate in the Gross Profit report (#10110) --- erpnext/accounts/report/gross_profit/gross_profit.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py index 20939bdf89..e2106e2d62 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -209,7 +209,10 @@ class GrossProfitGenerator(object): sle.voucher_detail_no == row.item_row: previous_stock_value = len(my_sle) > i+1 and \ flt(my_sle[i+1].stock_value) or 0.0 - return previous_stock_value - flt(sle.stock_value) + if previous_stock_value: + return previous_stock_value - flt(sle.stock_value) + else: + return flt(row.qty) * self.get_average_buying_rate(row, item_code) else: return flt(row.qty) * self.get_average_buying_rate(row, item_code)