From 8b543e550389ea4530fb8db7d98085df44defe2f Mon Sep 17 00:00:00 2001 From: Raheel Khan Date: Wed, 17 Sep 2025 18:36:00 +0530 Subject: [PATCH] fix: skip receivable/payable account validation in payroll entry if party is not available (#49585) * fix: skip receivable/payable account validation if party is not available in creation of payroll entry * refactor: rename flag --- erpnext/accounts/doctype/gl_entry/gl_entry.py | 22 ++++++++++--------- .../doctype/journal_entry/journal_entry.py | 5 ++++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py index a0f5866fcd4..8a910443b14 100644 --- a/erpnext/accounts/doctype/gl_entry/gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py @@ -137,18 +137,20 @@ class GLEntry(Document): if not self.is_cancelled and not (self.party_type and self.party): account_type = frappe.get_cached_value("Account", self.account, "account_type") - if account_type == "Receivable": - frappe.throw( - _("{0} {1}: Customer is required against Receivable account {2}").format( - self.voucher_type, self.voucher_no, self.account + # skipping validation for payroll entry creation in case party is not required + if not frappe.flags.party_not_required_for_receivable_payable: + if account_type == "Receivable": + frappe.throw( + _("{0} {1}: Customer is required against Receivable account {2}").format( + self.voucher_type, self.voucher_no, self.account + ) ) - ) - elif account_type == "Payable": - frappe.throw( - _("{0} {1}: Supplier is required against Payable account {2}").format( - self.voucher_type, self.voucher_no, self.account + elif account_type == "Payable": + frappe.throw( + _("{0} {1}: Supplier is required against Payable account {2}").format( + self.voucher_type, self.voucher_no, self.account + ) ) - ) # Zero value transaction is not allowed if not ( diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 8aa27f2fa47..e20997645a3 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -644,8 +644,11 @@ class JournalEntry(AccountsController): def validate_party(self): for d in self.get("accounts"): account_type = frappe.get_cached_value("Account", d.account, "account_type") + + # skipping validation for payroll entry creation + skip_validation = frappe.flags.party_not_required_for_receivable_payable if account_type in ["Receivable", "Payable"]: - if not (d.party_type and d.party): + if not (d.party_type and d.party) and not skip_validation: frappe.throw( _( "Row {0}: Party Type and Party is required for Receivable / Payable account {1}"