From abfe926a451949e16d08bd6d6973941b742e67c5 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Thu, 23 Jun 2022 11:01:00 +0530 Subject: [PATCH] fix(Salary Slip): Components not updated when amount evaluates to 0 due to payment days (#31425) * fix(Salary Slip): Components not updated when amount evaluates to 0 due to payment days * fix: remove 0 valued components that have been updated later --- erpnext/payroll/doctype/salary_slip/salary_slip.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/payroll/doctype/salary_slip/salary_slip.py b/erpnext/payroll/doctype/salary_slip/salary_slip.py index fcb415c00ed..e4c816c8fb4 100644 --- a/erpnext/payroll/doctype/salary_slip/salary_slip.py +++ b/erpnext/payroll/doctype/salary_slip/salary_slip.py @@ -625,7 +625,7 @@ class SalarySlip(TransactionBase): data = self.get_data_for_eval() for struct_row in self._salary_structure_doc.get(component_type): amount = self.eval_condition_and_formula(struct_row, data) - if amount and struct_row.statistical_component == 0: + if amount is not None and struct_row.statistical_component == 0: self.update_component_row(struct_row, amount, component_type) def get_data_for_eval(self): @@ -857,6 +857,10 @@ class SalarySlip(TransactionBase): component_row, joining_date, relieving_date )[0] + # remove 0 valued components that have been updated later + if component_row.amount == 0: + self.remove(component_row) + def set_precision_for_component_amounts(self): for component_type in ("earnings", "deductions"): for component_row in self.get(component_type):