fix: fetch holiday list of an employee based on month end date filter…#4199
fix: fetch holiday list of an employee based on month end date filter…#4199asmitahase merged 2 commits intofrappe:developfrom
Conversation
2f46be1 to
32b2192
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe change updates the 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
hrms/api/roster.py (1)
199-210:⚠️ Potential issue | 🟠 Major
month_endstill applies the wrong holiday list for mid-month reassignments.This fixes the old “use today’s assignment” behavior, but it still resolves only one holiday list for the entire month. In
hrms/utils/holiday_list.py:119-139,get_assigned_holiday_listreturns the latest assignment whosefrom_date <= as_on, so if an employee switches lists on January 16, 2026, rendering January 2026 withas_on=2026-01-31will still apply the January 16 list to January 1-15. Please resolve holiday lists per effective-date range within[month_start, month_end]and add a regression test for an in-month holiday-list change.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@hrms/api/roster.py` around lines 199 - 210, The loop in roster.py uses get_holiday_list_for_employee(as_on=month_end) and applies one holiday_list for the whole month, which misapplies mid-month reassignments; change the logic to resolve holiday list assignments per effective-date range inside [month_start, month_end] (e.g., obtain all holiday-list assignments for the employee that overlap the month, iterate each assignment range, fetch holidays for that assignment constrained to the assignment start/end intersected with month_start/month_end, and append/merge into holidays[employee]); update/introduce a regression test that creates an employee with a holiday-list change mid-month (assignment before and another from mid-month) and asserts holidays for the first half come from the first list and second half from the second. Use function names/vars get_holiday_list_for_employee, month_start, month_end, holiday_lists, holidays to locate and replace the single-as_on lookup with per-range resolution and per-range queries.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@hrms/api/roster.py`:
- Around line 199-210: The loop in roster.py uses
get_holiday_list_for_employee(as_on=month_end) and applies one holiday_list for
the whole month, which misapplies mid-month reassignments; change the logic to
resolve holiday list assignments per effective-date range inside [month_start,
month_end] (e.g., obtain all holiday-list assignments for the employee that
overlap the month, iterate each assignment range, fetch holidays for that
assignment constrained to the assignment start/end intersected with
month_start/month_end, and append/merge into holidays[employee]);
update/introduce a regression test that creates an employee with a holiday-list
change mid-month (assignment before and another from mid-month) and asserts
holidays for the first half come from the first list and second half from the
second. Use function names/vars get_holiday_list_for_employee, month_start,
month_end, holiday_lists, holidays to locate and replace the single-as_on lookup
with per-range resolution and per-range queries.
… applied in roster
32b2192 to
a00f691
Compare
…4199 fix: fetch holiday list of an employee based on month end date filter… (backport #4199)
…4199 fix: fetch holiday list of an employee based on month end date filter… (backport #4199)
…e filter… (backport #4199)"
…5-hotfix/pr-4199 fix: fetch holiday list of an employee based on month end date filter… (backport #4199)"
…e filter… (backport frappe#4199)"
Issue Ref: 61990
Issue Description: When assigning multiple Holiday Lists with different weekend configurations to the same employee, the system incorrectly updates past roster entries based on the latest assignment.
Before:


After:

backport needed in v15
Summary by CodeRabbit