Skip to content

Incorrect validation on Payroll Payable Account — Should allow account_type = "Payable" #3023

@QualityPoint

Description

@QualityPoint

Information about bug

When creating Salary Slips through the Payroll Entry Doctype, the method validate_payroll_payable_account() currently throws an error, before_submit, if the selected Payroll Payable Account has any account_type set:

def validate_payroll_payable_account(self):
if frappe.db.get_value("Account", self.payroll_payable_account, "account_type"):
frappe.throw(
_("Account type cannot be set for payroll payable account {0}, please remove and try again").format(
frappe.bold(get_link_to_form("Account", self.payroll_payable_account))
)
)

However, in correct accounting practice, the Payroll Payable Account should naturally have an account_type = "Payable".

Problem:

  • This validation forces users to select an account without an account_type, which is wrong.
  • Accounts used to accumulate payroll liabilities must be of type Payable.

Suggested fix:
Validation should allow account_type = "Payable", and only throw an error if the account_type is something else (like Asset, Expense, Income, etc).

Proposed Code Improvement:
def validate_payroll_payable_account(self):
account_type = frappe.db.get_value("Account", self.payroll_payable_account, "account_type")
if account_type and account_type != "Payable":
frappe.throw(
_("Payroll payable account {0} must have Account Type 'Payable'. Current account type: {1}.")
.format(
frappe.bold(get_link_to_form("Account", self.payroll_payable_account)),
frappe.bold(account_type)
)
)

Expected Behavior:

  • If account_type = "Payable" → ✅ Allow.
  • If account_type is anything else → ❌ Throw error.

Image
Image
Image
Image
Image

Module

Payroll

Version

Frappe: v15.66.1 (version-15)
ERPNext: v15.59.0 (version-15)
Frappe HR: v15.43.1 (version-15)

Installation method

manual install

Relevant log output / Stack trace / Full Error Message.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions