From 197257d04429b63f64c3d7004009cf54e70aeca6 Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Mon, 16 Mar 2026 18:41:53 +0400 Subject: [PATCH] fix: use bank_txn.kb_currency as fallback for txn_currency in JE creation In "Both" mode, mapping_currency is empty and the frontend does not pass currency in the txn dict, causing txn_currency to default to AZN. Now falling back to bank_txn.kb_currency so the actual account currency is always used regardless of which mode triggered the JE creation. Co-Authored-By: Claude Sonnet 4.6 --- kapital_bank/mapping.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kapital_bank/mapping.py b/kapital_bank/mapping.py index cc4bd9f..553621d 100644 --- a/kapital_bank/mapping.py +++ b/kapital_bank/mapping.py @@ -459,8 +459,13 @@ def _create_journal_entry_for_brt(txn, paid_from, paid_to, bank_txn, multi_curre is_multi = from_currency != company_currency or to_currency != company_currency currency_precision = cint(frappe.db.get_single_value("System Settings", "currency_precision") or 2) - # Use currency from the selected mapping; fall back to company currency - txn_currency = (mapping_currency or txn.get("currency") or company_currency).strip() + # Use currency from: mapping row → bank transaction kb_currency → company currency + txn_currency = ( + mapping_currency + or txn.get("currency") + or (getattr(bank_txn, "kb_currency", None) or "") + or company_currency + ).strip() # Exchange rates: account_currency → company_currency from_rate = 1 if from_currency == company_currency else get_exchange_rate(from_currency, company_currency, posting_date)