diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index ef2388a7eaa..725364c1590 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -1059,14 +1059,15 @@ class JournalEntry(AccountsController): gl_map = [] company_currency = erpnext.get_company_currency(self.company) + self.transaction_currency = company_currency + self.transaction_exchange_rate = 1 if self.multi_currency: for row in self.get("accounts"): if row.account_currency != company_currency: - self.currency = row.account_currency - self.conversion_rate = row.exchange_rate + # Journal assumes the first foregin currency as transaction currency + self.transaction_currency = row.account_currency + self.transaction_exchange_rate = row.exchange_rate break - else: - self.currency = company_currency for d in self.get("accounts"): if d.debit or d.credit or (self.voucher_type == "Exchange Gain Or Loss"): @@ -1091,6 +1092,18 @@ class JournalEntry(AccountsController): "credit_in_account_currency": flt( d.credit_in_account_currency, d.precision("credit_in_account_currency") ), + "transaction_currency": self.transaction_currency, + "transaction_exchange_rate": self.transaction_exchange_rate, + "debit_in_transaction_currency": flt( + d.debit_in_account_currency, d.precision("debit_in_account_currency") + ) + if self.transaction_currency == d.account_currency + else flt(d.debit, d.precision("debit")) / self.transaction_exchange_rate, + "credit_in_transaction_currency": flt( + d.credit_in_account_currency, d.precision("credit_in_account_currency") + ) + if self.transaction_currency == d.account_currency + else flt(d.credit, d.precision("credit")) / self.transaction_exchange_rate, "against_voucher_type": d.reference_type, "against_voucher": d.reference_name, "remarks": remarks,