From 7b093e580386e260dadda3ebb335ea1384c7a679 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 1 Jul 2022 10:35:59 +0530 Subject: [PATCH] fix(Salary Slip): Components not updated when amount evaluates to 0 due to payment days (backport #31425) (#31432) Co-authored-by: Rucha Mahabal --- 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 e1ccc117e7..7b7d0571b6 100644 --- a/erpnext/payroll/doctype/salary_slip/salary_slip.py +++ b/erpnext/payroll/doctype/salary_slip/salary_slip.py @@ -624,7 +624,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): @@ -854,6 +854,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):