Skip to content

Commit c173ff9

Browse files
fix(payroll): classify slip fieldtypes with the framework sets
The local numeric set omitted Long Int, so a custom Long Int field was seeded as a string and broke arithmetic formulas -- the same failure mode as the hard-coded fieldname list this fixes. Use frappe.model.numeric_fieldtypes and no_value_fields instead of maintaining either set here. The no-value set also gains Attachment Gallery, which is present upstream on develop but was missing locally.
1 parent abb648b commit c173ff9

2 files changed

Lines changed: 8 additions & 20 deletions

File tree

hrms/payroll/doctype/salary_structure_assignment/test_salary_structure_assignment.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# See license.txt
33

44
import frappe
5+
from frappe.model import numeric_fieldtypes
56
from frappe.utils import get_first_day, nowdate
67

78
from erpnext.setup.doctype.employee.test_employee import make_employee
@@ -178,7 +179,7 @@ def test_salary_slip_eval_defaults_cover_every_slip_field(self):
178179
meta = frappe.get_meta("Salary Slip")
179180

180181
for field in meta.fields:
181-
if field.fieldtype in ("Currency", "Float", "Int", "Percent", "Check"):
182+
if field.fieldtype in numeric_fieldtypes:
182183
self.assertIn(field.fieldname, defaults)
183184
self.assertEqual(defaults[field.fieldname], 0)
184185

hrms/payroll/utils.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import frappe
55
from frappe import _
6+
from frappe.model import no_value_fields, numeric_fieldtypes
67
from frappe.utils import ceil, floor, get_first_day, get_last_day, get_link_to_form, getdate, rounded
78

89

@@ -61,23 +62,6 @@ def _fetch_component_values():
6162
return frappe.cache().get_value("salary_component_values", generator=_fetch_component_values)
6263

6364

64-
NUMERIC_FIELDTYPES = {"Currency", "Float", "Int", "Percent", "Check"}
65-
66-
# Fieldtypes that hold no value of their own and must stay out of the formula context.
67-
NON_VALUE_FIELDTYPES = {
68-
"Button",
69-
"Column Break",
70-
"Fold",
71-
"Heading",
72-
"HTML",
73-
"Image",
74-
"Section Break",
75-
"Tab Break",
76-
"Table",
77-
"Table MultiSelect",
78-
}
79-
80-
8165
def get_salary_slip_eval_defaults() -> dict:
8266
"""Zero/empty default for every Salary Slip field.
8367
@@ -89,11 +73,14 @@ def get_salary_slip_eval_defaults() -> dict:
8973
These are only defaults. The real value overrides them whenever there is one --
9074
the salary slip overlays its own fields, and the assignment pre-pass seeds the
9175
period fields it can derive.
76+
77+
The fieldtype sets come from the framework rather than a local list, so a
78+
fieldtype added upstream is classified without another edit here.
9279
"""
9380
return {
94-
field.fieldname: 0 if field.fieldtype in NUMERIC_FIELDTYPES else ""
81+
field.fieldname: 0 if field.fieldtype in numeric_fieldtypes else ""
9582
for field in frappe.get_meta("Salary Slip").fields
96-
if field.fieldname and field.fieldtype not in NON_VALUE_FIELDTYPES
83+
if field.fieldname and field.fieldtype not in no_value_fields
9784
}
9885

9986

0 commit comments

Comments
 (0)