From 646e9ca0dd484b65d4f3bbe674b63760f8e3d5ce Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 29 Feb 2024 17:31:08 +0530 Subject: [PATCH] test: advance pulling logic on Sales/Purchase Invoice --- .../sales_invoice/test_sales_invoice.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 8c3aedebcd..6da9244301 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -3577,6 +3577,33 @@ class TestSalesInvoice(FrappeTestCase): check_gl_entries(self, pe.name, expected_gle, nowdate(), voucher_type="Payment Entry") set_advance_flag(company="_Test Company", flag=0, default_account="") + def test_pulling_advance_based_on_debit_to(self): + from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_payment_entry + + debtors2 = create_account( + parent_account="Accounts Receivable - _TC", + account_name="Debtors 2", + company="_Test Company", + account_type="Receivable", + ) + si = create_sales_invoice(do_not_submit=True) + si.debit_to = debtors2 + si.save() + + pe = create_payment_entry( + company=si.company, + payment_type="Receive", + party_type="Customer", + party=si.customer, + paid_from=debtors2, + paid_to="Cash - _TC", + paid_amount=1000, + ) + pe.submit() + advances = si.get_advance_entries() + self.assertEqual(1, len(advances)) + self.assertEqual(advances[0].reference_name, pe.name) + def set_advance_flag(company, flag, default_account): frappe.db.set_value(