Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: gratuity calculation for 'Sum of all previous slabs' option #2471

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions hrms/payroll/doctype/gratuity/gratuity.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,14 @@ def get_gratuity_amount(self, experience: float) -> float:
* total_component_amount
* slab.fraction_of_applicable_earnings
)
years_left -= slab.to_year - slab.from_year
slab_found = True

elif self._is_experience_within_slab(slab, experience):
gratuity_amount += (
years_left * total_component_amount * slab.fraction_of_applicable_earnings
)
slab_found = True
years_left -= slab.to_year - slab.from_year

if not slab_found:
frappe.throw(
Expand Down Expand Up @@ -311,7 +311,7 @@ def get_gratuity_rule_slabs(self) -> list[dict]:
)

def _is_experience_within_slab(self, slab: dict, experience: float) -> bool:
return bool(slab.from_year <= experience and (experience < slab.to_year or slab.to_year == 0))
return bool(slab.from_year <= experience and (experience <= slab.to_year or slab.to_year == 0))

def _is_experience_beyond_slab(self, slab: dict, experience: float) -> bool:
return bool(slab.from_year < experience and (slab.to_year < experience and slab.to_year != 0))
Expand Down
Loading