From 51d8a7a0c1726130518e44b47cce387e90c2a6c7 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 5 Jan 2024 20:42:38 +0530 Subject: [PATCH] fix: incorrect outstanding amt validation on advance as liability (cherry picked from commit 4cc3c1b76529b99e1f0ed2594c0edc3152cc6534) --- erpnext/accounts/doctype/payment_entry/payment_entry.js | 4 ++++ erpnext/accounts/doctype/payment_entry/payment_entry.py | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index 26112409b7cb..81ffee3f6e86 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -747,6 +747,10 @@ frappe.ui.form.on('Payment Entry', { args["get_orders_to_be_billed"] = true; } + if (frm.doc.book_advance_payments_in_separate_party_account) { + args["book_advance_payments_in_separate_party_account"] = true; + } + frappe.flags.allocate_payment_amount = filters['allocate_payment_amount']; return frappe.call({ diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 1282ab60392e..e20da1d9d620 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -256,6 +256,7 @@ def validate_allocated_amount_with_latest_data(self): "get_outstanding_invoices": True, "get_orders_to_be_billed": True, "vouchers": vouchers, + "book_advance_payments_in_separate_party_account": self.book_advance_payments_in_separate_party_account, }, validate=True, ) @@ -1614,11 +1615,16 @@ def get_outstanding_reference_documents(args, validate=False): outstanding_invoices = [] negative_outstanding_invoices = [] + if args.get("book_advance_payments_in_separate_party_account"): + party_account = get_party_account(args.get("party_type"), args.get("party"), args.get("company")) + else: + party_account = args.get("party_account") + if args.get("get_outstanding_invoices"): outstanding_invoices = get_outstanding_invoices( args.get("party_type"), args.get("party"), - get_party_account(args.get("party_type"), args.get("party"), args.get("company")), + party_account, common_filter=common_filter, posting_date=posting_and_due_date, min_outstanding=args.get("outstanding_amt_greater_than"),