From 72bc5b3a11528611db8a322d68c0ecc422b570c6 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 27 Jun 2023 16:11:03 +0530 Subject: [PATCH] refactor(test): difference amount no updated for exchange gain/loss --- erpnext/accounts/test/test_utils.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/test/test_utils.py b/erpnext/accounts/test/test_utils.py index 3aca60eae5..3cb5e42e7a 100644 --- a/erpnext/accounts/test/test_utils.py +++ b/erpnext/accounts/test/test_utils.py @@ -80,18 +80,27 @@ class TestUtils(unittest.TestCase): item = make_item().name purchase_invoice = make_purchase_invoice( - item=item, supplier="_Test Supplier USD", currency="USD", conversion_rate=82.32 + item=item, supplier="_Test Supplier USD", currency="USD", conversion_rate=82.32, do_not_submit=1 ) + purchase_invoice.credit_to = "_Test Payable USD - _TC" purchase_invoice.submit() payment_entry = get_payment_entry(purchase_invoice.doctype, purchase_invoice.name) - payment_entry.target_exchange_rate = 62.9 payment_entry.paid_amount = 15725 payment_entry.deductions = [] - payment_entry.insert() + payment_entry.save() + + # below is the difference between base_received_amount and base_paid_amount + self.assertEqual(payment_entry.difference_amount, -4855.0) + + payment_entry.target_exchange_rate = 62.9 + payment_entry.save() + + # below is due to change in exchange rate + self.assertEqual(payment_entry.references[0].exchange_gain_loss, -4855.0) - self.assertEqual(payment_entry.difference_amount, -4855.00) payment_entry.references = [] + self.assertEqual(payment_entry.difference_amount, 0.0) payment_entry.submit() payment_reconciliation = frappe.new_doc("Payment Reconciliation")