fix: don't use mapping_currency as txn_currency in JE creation
mapping_currency is a filter field (which transactions the rule matches), not the denomination of the BT amount. Using it as txn_currency caused 700 AZN to be treated as 700 USD → 1190 AZN in the Journal Entry. Now txn_currency comes from bank_txn.currency (= GL account currency), which always matches the BT deposit/withdrawal amount. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d8cf942792
commit
f87db8e6de
|
|
@ -459,12 +459,11 @@ 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: mapping row → txn dict → bank transaction currency → company currency
|
# txn_currency = the currency the BT amount is denominated in.
|
||||||
# NOTE: use bank_txn.currency (= GL account currency, matches the BT amount),
|
# mapping_currency is a FILTER (which transactions this rule matches), NOT the amount's currency.
|
||||||
# NOT kb_currency (= the foreign currency from the bank API, may differ from BT amount).
|
# bank_txn.currency = GL account currency = currency of deposit/withdrawal = correct.
|
||||||
txn_currency = (
|
txn_currency = (
|
||||||
mapping_currency
|
txn.get("currency")
|
||||||
or txn.get("currency")
|
|
||||||
or (getattr(bank_txn, "currency", None) or "")
|
or (getattr(bank_txn, "currency", None) or "")
|
||||||
or company_currency
|
or company_currency
|
||||||
).strip()
|
).strip()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue