test: PO advance paid on payment submission and cancellation

This commit is contained in:
ruthra kumar 2022-11-02 15:43:45 +05:30
parent 81d791eea0
commit 1a0a8ac7e2

View File

@ -732,6 +732,32 @@ class TestPurchaseOrder(FrappeTestCase):
pe_doc = frappe.get_doc("Payment Entry", pe.name)
pe_doc.cancel()
@change_settings("Accounts Settings", {"unlink_advance_payment_on_cancelation_of_order": 1})
def test_advance_paid_upon_payment_entry_cancellation(self):
from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
po_doc = create_purchase_order()
pe = get_payment_entry("Purchase Order", po_doc.name, bank_account="_Test Bank - _TC")
pe.reference_no = "1"
pe.reference_date = nowdate()
pe.paid_from_account_currency = po_doc.currency
pe.paid_to_account_currency = po_doc.currency
pe.source_exchange_rate = 1
pe.target_exchange_rate = 1
pe.paid_amount = po_doc.grand_total
pe.save(ignore_permissions=True)
pe.submit()
po_doc.reload()
self.assertEqual(po_doc.advance_paid, po_doc.base_grand_total)
pe_doc = frappe.get_doc("Payment Entry", pe.name)
pe_doc.cancel()
po_doc.reload()
self.assertEqual(po_doc.advance_paid, 0)
def test_schedule_date(self):
po = create_purchase_order(do_not_submit=True)
po.schedule_date = None