diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py index 98816a4a2d4..1c2e561e992 100644 --- a/erpnext/accounts/doctype/gl_entry/gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py @@ -18,7 +18,7 @@ from erpnext.accounts.party import ( validate_party_frozen_disabled, validate_party_gle_currency, ) -from erpnext.accounts.utils import get_account_currency, get_fiscal_year +from erpnext.accounts.utils import OUTSTANDING_DOCTYPES, get_account_currency, get_fiscal_year from erpnext.exceptions import InvalidAccountCurrency exclude_from_linked_with = True @@ -382,7 +382,7 @@ def update_outstanding_amt( ) ) - if against_voucher_type in ["Sales Invoice", "Purchase Invoice", "Fees"]: + if against_voucher_type in OUTSTANDING_DOCTYPES: ref_doc = frappe.get_doc(against_voucher_type, against_voucher) # Didn't use db_set for optimization purpose diff --git a/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.py b/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.py index f48ee9ee6d1..30e885adacc 100644 --- a/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.py +++ b/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.py @@ -16,7 +16,7 @@ from erpnext.accounts.doctype.gl_entry.gl_entry import ( validate_balance_type, validate_frozen_account, ) -from erpnext.accounts.utils import update_voucher_outstanding +from erpnext.accounts.utils import OUTSTANDING_DOCTYPES, update_voucher_outstanding from erpnext.exceptions import InvalidAccountDimensionError, MandatoryAccountDimensionError @@ -168,7 +168,7 @@ class PaymentLedgerEntry(Document): # update outstanding amount if ( - self.against_voucher_type in ["Journal Entry", "Sales Invoice", "Purchase Invoice", "Fees"] + self.against_voucher_type in OUTSTANDING_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 9d73681cf95..3a395d837f7 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -49,6 +49,7 @@ class PaymentEntryUnlinkError(frappe.ValidationError): GL_REPOSTING_CHUNK = 100 +OUTSTANDING_DOCTYPES = frozenset(["Sales Invoice", "Purchase Invoice", "Fees"]) @frappe.whitelist() @@ -1884,12 +1885,7 @@ def update_voucher_outstanding(voucher_type, voucher_no, account, party_type, pa # on cancellation outstanding can be an empty list voucher_outstanding = ple_query.get_voucher_outstandings(vouchers, common_filter=common_filter) - if ( - voucher_type in ["Sales Invoice", "Purchase Invoice", "Fees"] - and party_type - and party - and voucher_outstanding - ): + if voucher_type in OUTSTANDING_DOCTYPES and party_type and party and voucher_outstanding: outstanding = voucher_outstanding[0] ref_doc = frappe.get_lazy_doc(voucher_type, voucher_no) outstanding_amount = flt(