From 97f13049ee115198078859551e130f99ade2928f Mon Sep 17 00:00:00 2001 From: l0gesh29 Date: Tue, 17 Jun 2025 12:13:23 +0530 Subject: [PATCH] fix: add validation for exchange gain/loss entries (cherry picked from commit d992f67658bac579e48b8ea6725400ad426f64cd) --- erpnext/accounts/report/general_ledger/general_ledger.py | 3 ++- erpnext/accounts/report/utils.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py index 0bb14604991..7757bb37f6b 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.py +++ b/erpnext/accounts/report/general_ledger/general_ledger.py @@ -194,7 +194,8 @@ def get_gl_entries(filters, accounting_dimensions): voucher_type, voucher_subtype, voucher_no, {dimension_fields} cost_center, project, {transaction_currency_fields} against_voucher_type, against_voucher, account_currency, - against, is_opening, creation {select_fields} + against, is_opening, creation {select_fields}, + transaction_currency from `tabGL Entry` where company=%(company)s {get_conditions(filters)} {order_by_statement} diff --git a/erpnext/accounts/report/utils.py b/erpnext/accounts/report/utils.py index 2a72b10e4eb..5056b986187 100644 --- a/erpnext/accounts/report/utils.py +++ b/erpnext/accounts/report/utils.py @@ -101,13 +101,18 @@ def convert_to_presentation_currency(gl_entries, currency_info): account_currencies = list(set(entry["account_currency"] for entry in gl_entries)) for entry in gl_entries: + transaction_currency = entry.get("transaction_currency") debit = flt(entry["debit"]) credit = flt(entry["credit"]) debit_in_account_currency = flt(entry["debit_in_account_currency"]) credit_in_account_currency = flt(entry["credit_in_account_currency"]) account_currency = entry["account_currency"] - if len(account_currencies) == 1 and account_currency == presentation_currency: + if ( + len(account_currencies) == 1 + and account_currency == presentation_currency + and (transaction_currency is None or account_currency == transaction_currency) + ): entry["debit"] = debit_in_account_currency entry["credit"] = credit_in_account_currency else: