From 1a7efbb65466518d25de853c71ca324ddf048ee5 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 5d656bb0a79..d6a0acce427 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -694,7 +694,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, @@ -705,9 +706,9 @@ class GrossProfitGenerator: ) 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")