From f55b561ff918268c178c7a51822c51cc3c7ed89f Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 13 Dec 2023 11:25:21 +0530 Subject: [PATCH] fix: fetch exc rate of multi currency journals (cherry picked from commit 1b3ba25220ca4ef96df5416331ee2f78376da64a) --- .../payment_reconciliation.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py index 06ad09259568..3ea25d16e6f4 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py @@ -592,6 +592,27 @@ def get_invoice_exchange_map(self, invoices, payments): invoice_exchange_map.update(purchase_invoice_map) + journals = [ + d.get("invoice_number") for d in invoices if d.get("invoice_type") == "Journal Entry" + ] + journals.extend( + [d.get("reference_name") for d in payments if d.get("reference_type") == "Journal Entry"] + ) + if journals: + journals = list(set(journals)) + journals_map = frappe._dict( + frappe.db.get_all( + "Journal Entry Account", + filters={"parent": ("in", journals), "account": ("in", [self.receivable_payable_account])}, + fields=[ + "parent as `name`", + "exchange_rate", + ], + as_list=1, + ) + ) + invoice_exchange_map.update(journals_map) + return invoice_exchange_map def validate_allocation(self):