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: Calculate earned leaves pro-rata if policy assignment is created after the leave period (backport #2704) #2751

Merged
merged 7 commits into from
Feb 4, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Feb 4, 2025

Problem

If leave policy is assigned for a backdated year, earned leaves are still calculated based on the current date at which the assignment is created, this works out if the leave period is shorter than a year, but fails for a period when the months repeat.
For example,

  1. Leave Type is set to earned leave with a monthly frequency to be allocated on the last day of the month.
  2. Leave period is set to last years start date and end date
  3. Annual Leave are set as 12 in the leave policy
  4. Leave policy is assigned on this years first month

Then total leave allocated should 12, but 11 leave are assigned, the month in which is assignment is made is excluded because the assignment should be done on the last day, even though the month is outside the leave period

Solution

If a leave assignment is made outside the leave period that implies that employee has earned all leaves. Hence assign them pro-rata instead.

…d after the effective period

(cherry picked from commit bff9ed2)

# Conflicts:
#	hrms/hr/doctype/leave_policy_assignment/test_leave_policy_assignment.py
@mergify mergify bot added the conflicts label Feb 4, 2025
@mergify mergify bot requested a review from ruchamahabal as a code owner February 4, 2025 06:10
Copy link
Contributor Author

mergify bot commented Feb 4, 2025

Cherry-pick of bff9ed2 has failed:

On branch mergify/bp/version-14-hotfix/pr-2704
Your branch is ahead of 'origin/version-14-hotfix' by 1 commit.
  (use "git push" to publish your local commits)

You are currently cherry-picking commit bff9ed21.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.py

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   hrms/hr/doctype/leave_policy_assignment/test_leave_policy_assignment.py

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@asmitahase asmitahase merged commit e76856d into version-14-hotfix Feb 4, 2025
7 checks passed
@frappe-pr-bot
Copy link
Collaborator

🎉 This PR is included in version 14.36.6 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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