-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: allocate correct quarterly earned leaves #3428
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
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughSupport for quarterly earned leave allocation was introduced alongside existing monthly allocation. This includes new backend methods for quarterly leave calculations, refactoring of date helper functions, frontend form updates to restrict allocation options based on frequency, and new/updated tests validating quarterly leave allocation scenarios. No unrelated control flow or error handling changes were made. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend (Leave Type Form)
participant Backend (LeavePolicyAssignment)
participant DB
User->>Frontend (Leave Type Form): Select "earned_leave_frequency"
Frontend (Leave Type Form)->>Frontend (Leave Type Form): Update "allocate_on_day" options
User->>Backend (LeavePolicyAssignment): Trigger leave allocation
Backend (LeavePolicyAssignment)->>Backend (LeavePolicyAssignment): Check "earned_leave_frequency"
alt Monthly
Backend (LeavePolicyAssignment)->>Backend (LeavePolicyAssignment): Call get_leaves_for_passed_months
else Quarterly
Backend (LeavePolicyAssignment)->>Backend (LeavePolicyAssignment): Call get_leaves_for_passed_quarters
end
Backend (LeavePolicyAssignment)->>DB: Update leave allocation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
test: allocate quarterly leaves in the middle of the period
c8abe13
to
0987fbe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
hrms/hr/doctype/leave_allocation/test_earned_leaves.py
(2 hunks)hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.py
(6 hunks)hrms/hr/doctype/leave_type/leave_type.js
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- hrms/hr/doctype/leave_type/leave_type.js
- hrms/hr/doctype/leave_allocation/test_earned_leaves.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Python Unit Tests (1)
- GitHub Check: Python Unit Tests (2)
- GitHub Check: Summary
🔇 Additional comments (3)
hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.py (3)
12-12
: LGTM! Import changes support quarterly calculations.The new imports for quarter-related utilities (
get_quarter_ending
,get_quarter_start
,month_diff
,add_to_date
) are correctly added and necessary for the quarterly earned leave functionality.Also applies to: 21-24
249-258
: LGTM! Clean refactoring of date calculation logic.The extraction of the date calculation logic into a reusable public method is well done. The logic correctly handles edge cases and maintains the original functionality while enabling reuse in both monthly and quarterly calculations.
320-328
: Omission of “Date of Joining” Is Intentional for Quarterly FrequencyThe frontend form’s
earned_leave_frequency
handler limitsallocate_on_day
to only “First Day” and “Last Day” whenever the frequency is not “Monthly,” so excluding the “Date of Joining” branch fromis_earned_leave_applicable_for_current_quarter
aligns with the UI behavior and requires no further changes.
hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.py
Outdated
Show resolved
Hide resolved
hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.py
Outdated
Show resolved
Hide resolved
hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.py
Outdated
Show resolved
Hide resolved
315a91e
to
27e5f2d
Compare
…alculate as usual
2c8e1f8
to
1f928b8
Compare
Why are so many unrelated tests failing |
Similar tests failing over at eprnext too with frappe/erpnext#48561 |
Recently changes made to advance doctypes handling in payment reference. check PR: frappe/erpnext#48341 |
Summary by CodeRabbit
New Features
Tests