#5328·hrms

fix: Professional Tax / Provident Fund reports crash on sites without the India regional setup ("Unknown column component_type")

Author: jairofloressCreated Sep 29, 2026Updated Sep 29, 2026

Environment

  • frappe: 17.0.0-dev
  • erpnext: 17.0.0-dev
  • hrms: 17.0.0-dev

Steps to reproduce

  1. Use a site/company without the India regional setup (e.g. a Nicaragua company created by a non-India installer).
  2. Open the Payroll report Professional Tax Deductions (/app/query-report/Professional Tax Deductions) with any valid filters (company + period).
  3. The report crashes with a 500.

Traceback (tail)

File "apps/hrms/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.py", line 49, in get_data
    .run(pluck="name")
MySQLdb.OperationalError: (1054, "Unknown column 'component_type' in 'field list'")

Root cause

professional_tax_deductions.py queries tabSalary Component.component_type:

python
component_type_list = (
    frappe.qb.from_(SalaryComponent)
    .select(SalaryComponent.name, SalaryComponent.component_type)
    .where(SalaryComponent.component_type == "Professional Tax")
    .run(pluck="name")
)

but component_type is not part of the Salary Component doctype (the doctype field is type). It is a custom field created only by the India regional setup (hrms/regional/india/setup.py → get_custom_fields(), options Provident Fund / Additional Provident Fund / Provident Fund Loan / Professional Tax).

On any site where that regional setup was not applied, the column does not exist and the report is unusable.

Related

hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.py has the same latent issue: execute() calls frappe.db.exists("Salary Component", {"component_type": ["in", ...]}), which also hits the missing column, fails silently and the report shows a misleading "Salary components of type Provident Fund ... are not set up." message instead of "not applicable".

Suggested fix (minimal, no behaviour change for India sites)

Early-return when the custom field does not exist, e.g.:

python
def get_data(filters):
    data = []
    SalarySlip = DocType("Salary Slip")
    SalaryDetail = DocType("Salary Detail")
    SalaryComponent = DocType("Salary Component")

    # `component_type` is created by the India regional setup only
    if not frappe.get_meta("Salary Component").has_field("component_type"):
        return []

    component_type_list = (...)

and the same guard in provident_fund_deductions.execute() / get_data().

Alternatively, gate these statutory reports by country/regional setup so they are not exposed on non-India sites at all (the reports are India-specific: Professional Tax / Provident Fund).

Happy to open a PR with the guard if the approach is acceptable.