Merge pull request #43331 from ruthra-kumar/incorrect_transaction_currency_val_in_gl_entry

fix: transaction exchange rate on GL's for Multi currency Journals
This commit is contained in:
ruthra kumar
2024-09-23 17:32:00 +05:30
committed by GitHub
2 changed files with 20 additions and 1 deletions

View File

@@ -515,6 +515,23 @@ class TestJournalEntry(unittest.TestCase):
self.assertEqual(row.debit_in_account_currency, 100) self.assertEqual(row.debit_in_account_currency, 100)
self.assertEqual(row.credit_in_account_currency, 100) self.assertEqual(row.credit_in_account_currency, 100)
def test_transaction_exchange_rate_on_journals(self):
jv = make_journal_entry("_Test Bank - _TC", "_Test Receivable USD - _TC", 100, save=False)
jv.accounts[0].update({"debit_in_account_currency": 8500, "exchange_rate": 1})
jv.accounts[1].update({"party_type": "Customer", "party": "_Test Customer USD", "exchange_rate": 85})
jv.submit()
actual = frappe.db.get_all(
"GL Entry",
filters={"voucher_no": jv.name, "is_cancelled": 0},
fields=["account", "transaction_exchange_rate"],
order_by="account",
)
expected = [
{"account": "_Test Bank - _TC", "transaction_exchange_rate": 1.0},
{"account": "_Test Receivable USD - _TC", "transaction_exchange_rate": 85.0},
]
self.assertEqual(expected, actual)
def make_journal_entry( def make_journal_entry(
account1, account1,

View File

@@ -1039,7 +1039,9 @@ class AccountsController(TransactionBase):
gl_dict.update( gl_dict.update(
{ {
"transaction_currency": self.get("currency") or self.company_currency, "transaction_currency": self.get("currency") or self.company_currency,
"transaction_exchange_rate": self.get("conversion_rate", 1), "transaction_exchange_rate": item.get("exchange_rate", 1)
if self.doctype == "Journal Entry" and item
else self.get("conversion_rate", 1),
"debit_in_transaction_currency": self.get_value_in_transaction_currency( "debit_in_transaction_currency": self.get_value_in_transaction_currency(
account_currency, gl_dict, "debit" account_currency, gl_dict, "debit"
), ),