fix: skip receivable/payable account validation in payroll entry if party is not available (backport #49585) (#49598)

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

(cherry picked from commit 8b543e5503)

Co-authored-by: Raheel Khan <raheel@frappe.io>
This commit is contained in:
mergify[bot]
2025-09-18 17:04:28 +05:30
committed by GitHub
parent d66aed52f7
commit 697f6ef086
2 changed files with 16 additions and 11 deletions

View File

@@ -131,18 +131,20 @@ class GLEntry(Document):
if not self.is_cancelled and not (self.party_type and self.party): if not self.is_cancelled and not (self.party_type and self.party):
account_type = frappe.get_cached_value("Account", self.account, "account_type") account_type = frappe.get_cached_value("Account", self.account, "account_type")
if account_type == "Receivable": # skipping validation for payroll entry creation in case party is not required
frappe.throw( if not frappe.flags.party_not_required_for_receivable_payable:
_("{0} {1}: Customer is required against Receivable account {2}").format( if account_type == "Receivable":
self.voucher_type, self.voucher_no, self.account frappe.throw(
_("{0} {1}: Customer is required against Receivable account {2}").format(
self.voucher_type, self.voucher_no, self.account
)
) )
) elif account_type == "Payable":
elif account_type == "Payable": frappe.throw(
frappe.throw( _("{0} {1}: Supplier is required against Payable account {2}").format(
_("{0} {1}: Supplier is required against Payable account {2}").format( self.voucher_type, self.voucher_no, self.account
self.voucher_type, self.voucher_no, self.account )
) )
)
# Zero value transaction is not allowed # Zero value transaction is not allowed
if not ( if not (

View File

@@ -542,8 +542,11 @@ class JournalEntry(AccountsController):
def validate_party(self): def validate_party(self):
for d in self.get("accounts"): for d in self.get("accounts"):
account_type = frappe.get_cached_value("Account", d.account, "account_type") 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 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( frappe.throw(
_( _(
"Row {0}: Party Type and Party is required for Receivable / Payable account {1}" "Row {0}: Party Type and Party is required for Receivable / Payable account {1}"