From 068f1b5a6b15fdeed79d28a2e1db1c0d057afac9 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 4 Sep 2023 11:46:42 +0530 Subject: [PATCH] fix: invalid gain/loss JE created on base currency Expense Claim (cherry picked from commit 75d95acb23a9afcb53c188ceb9c2a71405b929ba) --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 1c6c99ed3e50..0e2de4ac3952 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -809,6 +809,11 @@ def calculate_base_allocated_amount_for_reference(self, d) -> float: flt(d.allocated_amount) * flt(exchange_rate), self.precision("base_paid_amount") ) + # on rare case, when `exchange_rate` is unset, gain/loss amount is incorrectly calculated + # for base currency transactions + if d.exchange_rate is None: + d.exchange_rate = 1 + allocated_amount_in_pe_exchange_rate = flt( flt(d.allocated_amount) * flt(d.exchange_rate), self.precision("base_paid_amount") )