Skip to content

Commit

Permalink
feat: add server-side validation for Amount Based on Salary
Browse files Browse the repository at this point in the history
(cherry picked from commit ed46859)
  • Loading branch information
krantheman authored and mergify[bot] committed Dec 12, 2023
1 parent 8497f43 commit 7659b2d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions hrms/payroll/doctype/salary_structure/salary_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ def validate(self):
self.validate_payment_days_based_dependent_component()
self.validate_timesheet_component()

def before_save(self):
for detail in self.earnings:
if not detail.amount_based_on_formula and detail.formula:
frappe.msgprint(
_(
"Earning Row #{0}: Formula entered for Salary Component {1} even though 'Amount Based on Formula' has been disabled"
).format(detail.idx, detail.salary_component)
)

for detail in self.deductions:
if not detail.amount_based_on_formula and detail.formula:
frappe.msgprint(
_(
"Deduction Row #{0}: Formula entered for Salary Component {1} even though 'Amount Based on Formula' has been disabled"
).format(detail.idx, detail.salary_component)
)

def set_missing_values(self):
overwritten_fields = [
"depends_on_payment_days",
Expand Down

0 comments on commit 7659b2d

Please sign in to comment.