diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index e2386122522..192f9cc81d2 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -2639,6 +2639,36 @@ class TestPurchaseInvoice(FrappeTestCase, StockTestMixin): "Buying Settings", "bill_for_rejected_quantity_in_purchase_invoice", original_value ) + def test_trx_currency_debit_credit_for_high_precision(self): + exc_rate = 0.737517516 + pi = make_purchase_invoice( + currency="USD", conversion_rate=exc_rate, qty=1, rate=2000, do_not_save=True + ) + pi.supplier = "_Test Supplier USD" + pi.save().submit() + + expected = ( + ("_Test Account Cost for Goods Sold - _TC", 1475.04, 0.0, 2000.0, 0.0, "USD", exc_rate), + ("_Test Payable USD - _TC", 0.0, 1475.04, 0.0, 2000.0, "USD", exc_rate), + ) + + actual = frappe.db.get_all( + "GL Entry", + filters={"voucher_no": pi.name}, + fields=[ + "account", + "debit", + "credit", + "debit_in_transaction_currency", + "credit_in_transaction_currency", + "transaction_currency", + "transaction_exchange_rate", + ], + order_by="account", + as_list=1, + ) + self.assertEqual(actual, expected) + def set_advance_flag(company, flag, default_account): frappe.db.set_value(