mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-28 09:24:45 +00:00
refactor: handle Journal entries
(cherry picked from commit 9f3847c0f8)
This commit is contained in:
@@ -1060,14 +1060,15 @@ class JournalEntry(AccountsController):
|
|||||||
gl_map = []
|
gl_map = []
|
||||||
|
|
||||||
company_currency = erpnext.get_company_currency(self.company)
|
company_currency = erpnext.get_company_currency(self.company)
|
||||||
|
self.transaction_currency = company_currency
|
||||||
|
self.transaction_exchange_rate = 1
|
||||||
if self.multi_currency:
|
if self.multi_currency:
|
||||||
for row in self.get("accounts"):
|
for row in self.get("accounts"):
|
||||||
if row.account_currency != company_currency:
|
if row.account_currency != company_currency:
|
||||||
self.currency = row.account_currency
|
# Journal assumes the first foregin currency as transaction currency
|
||||||
self.conversion_rate = row.exchange_rate
|
self.transaction_currency = row.account_currency
|
||||||
|
self.transaction_exchange_rate = row.exchange_rate
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
self.currency = company_currency
|
|
||||||
|
|
||||||
for d in self.get("accounts"):
|
for d in self.get("accounts"):
|
||||||
if d.debit or d.credit or (self.voucher_type == "Exchange Gain Or Loss"):
|
if d.debit or d.credit or (self.voucher_type == "Exchange Gain Or Loss"):
|
||||||
@@ -1092,6 +1093,18 @@ class JournalEntry(AccountsController):
|
|||||||
"credit_in_account_currency": flt(
|
"credit_in_account_currency": flt(
|
||||||
d.credit_in_account_currency, d.precision("credit_in_account_currency")
|
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_type": d.reference_type,
|
||||||
"against_voucher": d.reference_name,
|
"against_voucher": d.reference_name,
|
||||||
"remarks": remarks,
|
"remarks": remarks,
|
||||||
|
|||||||
Reference in New Issue
Block a user