From 2cb2e05b19f140fef59331e9a3c95b7a0175feb6 Mon Sep 17 00:00:00 2001 From: Asmita Hase Date: Wed, 6 Aug 2025 10:34:48 +0530 Subject: [PATCH 1/3] refactor: get advance payment doctypes from hooks --- .../advance_payment_ledger_entry.py | 4 ++-- erpnext/accounts/utils.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/advance_payment_ledger_entry/advance_payment_ledger_entry.py b/erpnext/accounts/doctype/advance_payment_ledger_entry/advance_payment_ledger_entry.py index a9392fc9367..fa863741d51 100644 --- a/erpnext/accounts/doctype/advance_payment_ledger_entry/advance_payment_ledger_entry.py +++ b/erpnext/accounts/doctype/advance_payment_ledger_entry/advance_payment_ledger_entry.py @@ -4,7 +4,7 @@ import frappe from frappe.model.document import Document -from erpnext.accounts.utils import update_voucher_outstanding +from erpnext.accounts.utils import get_advance_payment_doctypes, update_voucher_outstanding class AdvancePaymentLedgerEntry(Document): @@ -29,7 +29,7 @@ class AdvancePaymentLedgerEntry(Document): def on_update(self): if ( - self.against_voucher_type in ["Purchase Order", "Sales Order"] + self.against_voucher_type in get_advance_payment_doctypes() and self.flags.update_outstanding == "Yes" and not frappe.flags.is_reverse_depr_entry ): diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 9c97f6e7187..e25ba013a3d 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -481,7 +481,6 @@ def reconcile_against_document( reconciled_entries[(row.voucher_type, row.voucher_no)] = [] reconciled_entries[(row.voucher_type, row.voucher_no)].append(row) - for key, entries in reconciled_entries.items(): voucher_type, voucher_no = key @@ -1835,6 +1834,7 @@ def get_payment_ledger_entries(gl_entries, cancel=0): dr_or_cr = 0 account_type = None + for gle in gl_entries: if gle.account in receivable_or_payable_accounts: account_type = get_account_type(gle.account) @@ -1939,7 +1939,8 @@ def update_voucher_outstanding(voucher_type, voucher_no, account, party_type, pa if not voucher_type or not voucher_no: return - if voucher_type in ["Purchase Order", "Sales Order"]: + # todo use get advanced dotypes hooks + if voucher_type in get_advance_payment_doctypes(): ref_doc = frappe.get_lazy_doc(voucher_type, voucher_no) ref_doc.set_total_advance_paid() return From a273147b6ea4e71c78e507f1c563abf1e120651a Mon Sep 17 00:00:00 2001 From: Asmita Hase Date: Wed, 6 Aug 2025 10:36:18 +0530 Subject: [PATCH 2/3] chore: add account type to employee advance account in standard chart of accounts --- .../chart_of_accounts/verified/standard_chart_of_accounts.py | 2 +- .../verified/standard_chart_of_accounts_with_account_number.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py index 5c223d079fc..6f34a652822 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py +++ b/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py @@ -13,7 +13,7 @@ def get(): _("Bank Accounts"): {"account_type": "Bank", "is_group": 1}, _("Cash In Hand"): {_("Cash"): {"account_type": "Cash"}, "account_type": "Cash"}, _("Loans and Advances (Assets)"): { - _("Employee Advances"): {}, + _("Employee Advances"): {"account_type": "Payable"}, }, _("Securities and Deposits"): {_("Earnest Money"): {}}, _("Stock Assets"): { diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts_with_account_number.py b/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts_with_account_number.py index ee4da732e71..07962df149e 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts_with_account_number.py +++ b/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts_with_account_number.py @@ -20,7 +20,7 @@ def get(): "account_number": "1100", }, _("Loans and Advances (Assets)"): { - _("Employee Advances"): {"account_number": "1610"}, + _("Employee Advances"): {"account_number": "1610", "account_type": "Payable"}, "account_number": "1600", }, _("Securities and Deposits"): { From b4f831a93137ad9fdc1cb83f777d006730a408aa Mon Sep 17 00:00:00 2001 From: Asmita Hase Date: Wed, 6 Aug 2025 10:42:47 +0530 Subject: [PATCH 3/3] chore: removed uncessary comment --- erpnext/accounts/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index e25ba013a3d..597eef7e828 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -1939,7 +1939,6 @@ def update_voucher_outstanding(voucher_type, voucher_no, account, party_type, pa if not voucher_type or not voucher_no: return - # todo use get advanced dotypes hooks if voucher_type in get_advance_payment_doctypes(): ref_doc = frappe.get_lazy_doc(voucher_type, voucher_no) ref_doc.set_total_advance_paid()