Skip to content

Commit

Permalink
fix: correct args for get_advance_payment_entries_for_regional
Browse files Browse the repository at this point in the history
(cherry picked from commit df13a4c)
  • Loading branch information
ljain112 authored and mergify[bot] committed Dec 23, 2024
1 parent 1a9dfec commit 875797e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,8 @@ def set_advances(self):

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
Expand All @@ -1229,18 +1231,28 @@ def get_advance_entries(self, include_unallocated=True):
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(
party_type, party, party_account, amount_field, order_doctype, order_list, include_unallocated
)

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
Expand Down

0 comments on commit 875797e

Please sign in to comment.