From 77c970549b267d5d32fe3f51bcef974d85791841 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 28 Mar 2017 12:20:31 +0530 Subject: [PATCH] In gross profit report, if incoming rate not found from last sle, consider average valuation rate --- erpnext/accounts/report/gross_profit/gross_profit.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py index df6cb3c33a..887d5f8c8d 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -5,6 +5,7 @@ from __future__ import unicode_literals import frappe from frappe import _, scrub from erpnext.stock.utils import get_incoming_rate +from erpnext.stock.stock_ledger import get_valuation_rate from frappe.utils import flt @@ -220,7 +221,10 @@ class GrossProfitGenerator(object): from `tabPurchase Invoice Item` where item_code = %s and docstatus=1""", item_code)[0][0]) else: - self.average_buying_rate[item_code] = get_incoming_rate(row) + average_buying_rate = get_incoming_rate(row) + if not average_buying_rate: + average_buying_rate = get_valuation_rate(item_code, row.warehouse, allow_zero_rate=True) + self.average_buying_rate[item_code] = average_buying_rate return self.average_buying_rate[item_code]