diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py index 09fa853d378c..d4a6b87d7fc0 100644 --- a/erpnext/selling/doctype/sales_order/test_sales_order.py +++ b/erpnext/selling/doctype/sales_order/test_sales_order.py @@ -1966,6 +1966,7 @@ def test_sales_order_advance_payment_status(self, mocked_get_payment_url): from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request + # Flow progressing to SI with payment entries "moved" from SO to SI so = make_sales_order(qty=1, rate=100, do_not_submit=True) # no-op; for optical consistency with how a webshop SO would look like so.order_type = "Shopping Cart" @@ -1997,6 +1998,28 @@ def test_sales_order_advance_payment_status(self, mocked_get_payment_url): frappe.db.get_value(so.doctype, so.name, "advance_payment_status"), "Not Requested" ) # TODO: this might be a bug; handover has happened + # Flow NOT progressing to SI with payment entries NOT "moved" + so = make_sales_order(qty=1, rate=100) + self.assertEqual(frappe.db.get_value(so.doctype, so.name, "advance_payment_status"), "Not Requested") + + pr = make_payment_request(dt=so.doctype, dn=so.name, submit_doc=True, return_doc=True) + self.assertEqual(frappe.db.get_value(so.doctype, so.name, "advance_payment_status"), "Requested") + + pe = get_payment_entry(so.doctype, so.name).save().submit() + self.assertEqual(frappe.db.get_value(so.doctype, so.name, "advance_payment_status"), "Fully Paid") + + pe.reload() + pe.cancel() + self.assertEqual( + frappe.db.get_value(so.doctype, so.name, "advance_payment_status"), "Requested" + ) # here: reset + + pr.reload() + pr.cancel() + self.assertEqual( + frappe.db.get_value(so.doctype, so.name, "advance_payment_status"), "Not Requested" + ) # here: reset + def test_pick_list_without_rejected_materials(self): serial_and_batch_item = make_item( "_Test Serial and Batch Item for Rejected Materials",