refactor(test): difference amount no updated for exchange gain/loss

This commit is contained in:
ruthra kumar 2023-06-27 16:11:03 +05:30
parent 5b06bd1af4
commit 72bc5b3a11

View File

@ -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")