From 4513d83f22fad18a9fcc9a3995f70be162a58566 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 28 Feb 2024 17:07:37 +0530 Subject: [PATCH] fix: don't override reference exchange rate (cherry picked from commit eaac02655b174cca9daa2d16ba85c335e70879c3) --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 7 ++++++- erpnext/accounts/utils.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 8af0713b0b49..d2ec699a6c3b 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -389,7 +389,10 @@ def set_missing_values(self): ) def set_missing_ref_details( - self, force: bool = False, update_ref_details_only_for: list | None = None + self, + force: bool = False, + update_ref_details_only_for: list | None = None, + ref_exchange_rate: float | None = None, ) -> None: for d in self.get("references"): if d.allocated_amount: @@ -401,6 +404,8 @@ def set_missing_ref_details( ref_details = get_reference_details( d.reference_doctype, d.reference_name, self.party_account_currency ) + if ref_exchange_rate: + ref_details.update({"exchange_rate": ref_exchange_rate}) for field, value in ref_details.items(): if d.exchange_gain_loss: diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index c06c9774c604..b1779e655dd6 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -714,7 +714,7 @@ def update_reference_in_payment_entry( payment_entry.setup_party_account_field() payment_entry.set_missing_values() if not skip_ref_details_update_for_pe: - payment_entry.set_missing_ref_details() + payment_entry.set_missing_ref_details(ref_exchange_rate=d.exchange_rate or None) payment_entry.set_amounts() payment_entry.make_exchange_gain_loss_journal( frappe._dict({"difference_posting_date": d.difference_posting_date}), dimensions_dict