Skip to content

Commit

Permalink
fix(Payroll): skip dependent component update if no formula is set (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchamahabal authored Sep 4, 2024
1 parent 4e55a0c commit eaa8d3d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions hrms/payroll/doctype/salary_slip/salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,12 +813,11 @@ def is_var_updated(var: str | list[str]) -> bool:
other_component_type = "deductions" if component_type == "earnings" else "earnings"

for d in self._salary_structure_doc.get(component_type):
if not d.amount_based_on_formula:
continue
for var in get_variables_from_formula(d.formula):
if is_var_updated(var):
self.add_structure_component(d, component_type)
self.update_dependent_components_recursively(other_component_type, d.abbr)
if d.amount_based_on_formula and d.formula:
for var in get_variables_from_formula(d.formula):
if is_var_updated(var):
self.add_structure_component(d, component_type)
self.update_dependent_components_recursively(other_component_type, d.abbr)

def set_net_pay(self):
self.total_deduction = self.get_component_totals("deductions")
Expand Down Expand Up @@ -2350,4 +2349,6 @@ def email_salary_slips(names) -> None:


def get_variables_from_formula(formula: str) -> list[str]:
# compile expects a string
formula = cstr(formula)
return [node.id for node in ast.walk(ast.parse(formula, mode="eval")) if isinstance(node, ast.Name)]

0 comments on commit eaa8d3d

Please sign in to comment.