From f161e59cd7de888e6dc1975c736f480b0e4964ae Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 15 Jul 2024 11:33:46 +0530 Subject: [PATCH] fix(gross profit): incorrect valuation rate on different warehouses (cherry picked from commit f9d2dd0a62a42681871af874d8f6093ee6fdd715) --- erpnext/accounts/report/gross_profit/gross_profit.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py index fe2746660eb..a9039a9cada 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -713,7 +713,8 @@ class GrossProfitGenerator: def get_average_buying_rate(self, row, item_code): args = row - if item_code not in self.average_buying_rate: + key = (item_code, row.warehouse) + if key not in self.average_buying_rate: args.update( { "voucher_type": row.parenttype, @@ -727,9 +728,9 @@ class GrossProfitGenerator: args.update({"serial_and_batch_bundle": row.serial_and_batch_bundle}) average_buying_rate = get_incoming_rate(args) - self.average_buying_rate[item_code] = flt(average_buying_rate) + self.average_buying_rate[key] = flt(average_buying_rate) - return self.average_buying_rate[item_code] + return self.average_buying_rate[key] def get_last_purchase_rate(self, item_code, row): purchase_invoice = frappe.qb.DocType("Purchase Invoice")