From df13a4cc2f3167ff322379227f5382fc8045a417 Mon Sep 17 00:00:00 2001 From: ljain112 Date: Thu, 19 Dec 2024 12:04:04 +0530 Subject: [PATCH] fix: correct args for get_advance_payment_entries_for_regional --- erpnext/controllers/accounts_controller.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index f1119f53236..75f163d287c 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1228,6 +1228,8 @@ class AccountsController(TransactionBase): def get_advance_entries(self, include_unallocated=True): party_account = [] + default_advance_account = None + if self.doctype == "Sales Invoice": party_type = "Customer" party = self.customer @@ -1243,10 +1245,14 @@ class AccountsController(TransactionBase): order_doctype = "Purchase Order" party_account.append(self.credit_to) - party_account.extend( - get_party_account(party_type, party=party, company=self.company, include_advance=True) + party_accounts = get_party_account( + party_type, party=party, company=self.company, include_advance=True ) + if party_accounts: + party_account.append(party_accounts[0]) + default_advance_account = party_accounts[1] if len(party_accounts) == 2 else None + order_list = list(set(d.get(order_field) for d in self.get("items") if d.get(order_field))) journal_entries = get_advance_journal_entries( @@ -1254,7 +1260,13 @@ class AccountsController(TransactionBase): ) payment_entries = get_advance_payment_entries_for_regional( - party_type, party, party_account, order_doctype, order_list, include_unallocated + party_type, + party, + party_account, + order_doctype, + order_list, + default_advance_account, + include_unallocated, ) res = journal_entries + payment_entries