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: set correct work experience during gratuity calculation #2460

Merged
merged 4 commits into from
Dec 12, 2024

Conversation

AyshaHakeem
Copy link
Contributor

@AyshaHakeem AyshaHakeem commented Nov 27, 2024

Fix work experience calculation for gratuity rules using the Take Exact Completed Years method. Previously, the experience was rounded to a whole number instead of using the exact decimal value (eg. 1.4 years was incorrectly treated as 1 year).

Gratuity Rule:
Screenshot 2024-11-29 at 12 59 56 PM

Before:
Screenshot 2024-11-29 at 1 12 41 PM

After:
Screenshot 2024-11-29 at 1 15 47 PM

@@ -159,7 +159,7 @@ def get_work_experience(self) -> float:
if rule.method == "Round off Work Experience":
work_experience = round(work_experience)
else:
work_experience = floor(work_experience)
work_experience = flt(work_experience, precision=1)
Copy link
Member

@ruchamahabal ruchamahabal Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
work_experience = flt(work_experience, precision=1)
work_experience = flt(work_experience, self.precision("current_work_experience"))

Instead of using a hardcoded precision let's set field level precision. You can set 1 as the default precision in core for this field. So when people want to have more precision, they can just customize field level precision and this calculation will get adjusted

@ruchamahabal ruchamahabal self-assigned this Dec 10, 2024
ruchamahabal
ruchamahabal previously approved these changes Dec 11, 2024
@ruchamahabal
Copy link
Member

Why didn't linter catch this da17577? 🤔

@ruchamahabal
Copy link
Member

@Mergifyio backport version-14-hotfix version-15-hotfix

Copy link
Contributor

mergify bot commented Dec 16, 2024

backport version-14-hotfix version-15-hotfix

✅ Backports have been created

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants