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 <noreply@anthropic.com>
This commit is contained in:
Ali 2026-03-16 18:41:53 +04:00
parent 97b57c8572
commit 197257d044
1 changed files with 7 additions and 2 deletions

View File

@ -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 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) 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 # Use currency from: mapping row → bank transaction kb_currency → company currency
txn_currency = (mapping_currency or txn.get("currency") or company_currency).strip() 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 # Exchange rates: account_currency → company_currency
from_rate = 1 if from_currency == company_currency else get_exchange_rate(from_currency, company_currency, posting_date) from_rate = 1 if from_currency == company_currency else get_exchange_rate(from_currency, company_currency, posting_date)