[Bug 43838] New: Dayweek pushes dates by a whole week when it should move to the next open day
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43838 Bug ID: 43838 Summary: Dayweek pushes dates by a whole week when it should move to the next open day Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Circulation Assignee: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com, kyle@bywatersolutions.com Blocks: 42334 Target Milestone: --- With useDaysMode (or the daysmode circulation rule) set to 'Dayweek', the "push to the same weekday" logic is applied in places where it shouldn't, moving dates a whole week instead of to the nearest open day. The cause is in Koha::Library::Calendar: next_open_days and prev_open_days call get_push_amt on every closed day they step over. Under Dayweek, get_push_amt returns 7 unless the weekday is a weekly closure. So any time those methods meet a closed day that is not a weekly closure, they jump a whole week, even when the caller just wants the next/previous open day. This dates back to bug 15260 (2019), which introduced Dayweek. Affected cases (library with no weekly closures, closed on Tue 2026-11-10 and Wed 2026-11-11, Dayweek): 1. ReturnBeforeExpiry: due date clamped to the patron expiry date on a closed day is moved back with prev_open_days( $datedue, 1 ). prev_open_days(Wed 11, 1) returns Tue 2026-11-03, expected Mon 2026-11-09. 2. TalkingTech_itiva_outbound.pl: waiting date on a closed day uses next_open_days( $waiting_date, 1 ) to compute days_since_waiting. next_open_days(Tue 10, 1) returns Wed 2026-11-18, expected Thu 2026-11-12. 3. Non-weekly loan periods: the syspref description says Dayweek pushes to "the next open day otherwise", but a 10-day loan from Sat 2026-10-31 (landing on Tue 10) is due Wed 2026-11-18, expected Thu 2026-11-12. Hourly loans ending on a closed day are affected in the same way, as addHours uses next_open_days too. Weekly loan periods should keep pushing to the next open matching weekday, as documented. Proposed fix: next_open_days and prev_open_days always step one day at a time, and only addDays applies the weekly push, for Dayweek and loan periods that are a whole number of weeks. This blocks bug 42334, which moves this logic to a new class. Fixing it here first keeps the fix small enough to be backported. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42334 [Bug 42334] Introduce Koha::Calendar::DateCalculator for date arithmetic -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43838 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43838 --- Comment #1 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 208392 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208392&action=edit Bug 43838: Regression tests This patch adds tests for useDaysMode 'Dayweek' showing that next_open_days, prev_open_days and addDuration jump a whole week over closed days that are not weekly closures, where they should move to the next (or previous) open day: - prev_open_days / next_open_days (used by ReturnBeforeExpiry and TalkingTech_itiva_outbound.pl) - non-weekly loan periods - hourly loans It also adds tests to make sure weekly loan periods keep moving to the next open matching weekday. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Library/Calendar.t => FAIL: Tests fail! Dates are moved a whole week 3. Sign off :-D Assisted-by: Opus 5.5 (Anthropic) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43838 --- Comment #2 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 208393 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208393&action=edit Bug 43838: Don't jump a whole week outside weekly Dayweek periods With useDaysMode set to 'Dayweek', next_open_days and prev_open_days called get_push_amt on every closed day they met, which returns 7 unless the weekday is a weekly closure. Any caller asking for the next or previous open day got a date a whole week away instead: - ReturnBeforeExpiry (CalcDateDue) - TalkingTech_itiva_outbound.pl - non-weekly loan periods, which the syspref describes as pushed to "the next open day otherwise" - hourly loans ending on a closed day This patch makes next_open_days and prev_open_days skip closed days one day at a time, whatever the useDaysMode value. The move to the next open matching weekday is now only applied by addDays, for 'Dayweek' and loan periods that are a whole number of weeks, through a new _push_to_open_weekday helper. Weekly loan periods behave as before. Test plan: 1. Apply the regression tests 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Library/Calendar.t => FAIL: Tests fail! Dates are moved a whole week 3. Apply this patch 4. Repeat step 2 => SUCCESS: Tests pass! 5. Run: k$ prove t/db_dependent/Calendar.t \ t/db_dependent/Circulation/CalcDateDue.t \ t/db_dependent/Circulation.t => SUCCESS: Tests pass! 6. Sign off :-D Assisted-by: Opus 5.5 (Anthropic) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43838 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Text to go in the| |When useDaysMode (or the release notes| |"Days mode" circulation | |rule) is set to "Same week | |day" (Dayweek), due dates | |for loan periods that are | |not a whole number of weeks | |are now pushed to the next | |open day, as documented. | |Previously, if two or more | |closed days (that are not | |weekly closures) were in a | |row, the date jumped | |forward a whole week at a | |time. For example, a 10-day | |loan due on a closed 24 | |December, with 25 December | |and 1 January also closed, | |was due on 8 January | |instead of 26 December. The | |same applied to hourly | |loans ending on a closed | |day and to due dates moved | |back to the patron's expiry | |date (ReturnBeforeExpiry). | | | |Weekly loan periods are not | |affected: they still move | |to the next open matching | |weekday. | | | |Libraries using "Same week | |day" may see earlier due | |dates in these cases. CC| |tomascohen@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43838 --- Comment #3 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 208394 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208394&action=edit Bug 43838: Regression tests [=<26.05.x] This patch adds tests for useDaysMode 'Dayweek' showing that next_open_days, prev_open_days and addDuration jump a whole week over closed days that are not weekly closures, where they should move to the next (or previous) open day: - prev_open_days / next_open_days (used by ReturnBeforeExpiry and TalkingTech_itiva_outbound.pl) - non-weekly loan periods - hourly loans It also adds tests to make sure weekly loan periods keep moving to the next open matching weekday. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Calendar.t => FAIL: Tests fail! Dates are moved a whole week 3. Sign off :-D Assisted-by: Opus 5.5 (Anthropic) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43838 --- Comment #4 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 208395 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208395&action=edit Bug 43838: Don't jump a whole week outside weekly Dayweek periods [=<26.05.x] With useDaysMode set to 'Dayweek', next_open_days and prev_open_days called get_push_amt on every closed day they met, which returns 7 unless the weekday is a weekly closure. Any caller asking for the next or previous open day got a date a whole week away instead: - ReturnBeforeExpiry (CalcDateDue) - TalkingTech_itiva_outbound.pl - non-weekly loan periods, which the syspref describes as pushed to "the next open day otherwise" - hourly loans ending on a closed day This patch makes next_open_days and prev_open_days skip closed days one day at a time, whatever the useDaysMode value. The move to the next open matching weekday is now only applied by addDays, for 'Dayweek' and loan periods that are a whole number of weeks, through a new _push_to_open_weekday helper. Weekly loan periods behave as before. Test plan: 1. Apply the regression tests 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Calendar.t => FAIL: Tests fail! Dates are moved a whole week 3. Apply this patch 4. Repeat step 2 => SUCCESS: Tests pass! 5. Run: k$ prove t/db_dependent/Calendar.t \ t/db_dependent/Circulation/CalcDateDue.t \ t/db_dependent/Circulation.t => SUCCESS: Tests pass! 6. Sign off :-D Assisted-by: Opus 5.5 (Anthropic) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43838 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43838 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208392|0 |1 is obsolete| | Attachment #208393|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43838 --- Comment #5 from David Nind <david@davidnind.com> --- Created attachment 208396 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208396&action=edit Bug 43838: Regression tests This patch adds tests for useDaysMode 'Dayweek' showing that next_open_days, prev_open_days and addDuration jump a whole week over closed days that are not weekly closures, where they should move to the next (or previous) open day: - prev_open_days / next_open_days (used by ReturnBeforeExpiry and TalkingTech_itiva_outbound.pl) - non-weekly loan periods - hourly loans It also adds tests to make sure weekly loan periods keep moving to the next open matching weekday. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Library/Calendar.t => FAIL: Tests fail! Dates are moved a whole week 3. Sign off :-D Assisted-by: Opus 5.5 (Anthropic) Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43838 --- Comment #6 from David Nind <david@davidnind.com> --- Created attachment 208397 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208397&action=edit Bug 43838: Don't jump a whole week outside weekly Dayweek periods With useDaysMode set to 'Dayweek', next_open_days and prev_open_days called get_push_amt on every closed day they met, which returns 7 unless the weekday is a weekly closure. Any caller asking for the next or previous open day got a date a whole week away instead: - ReturnBeforeExpiry (CalcDateDue) - TalkingTech_itiva_outbound.pl - non-weekly loan periods, which the syspref describes as pushed to "the next open day otherwise" - hourly loans ending on a closed day This patch makes next_open_days and prev_open_days skip closed days one day at a time, whatever the useDaysMode value. The move to the next open matching weekday is now only applied by addDays, for 'Dayweek' and loan periods that are a whole number of weeks, through a new _push_to_open_weekday helper. Weekly loan periods behave as before. Test plan: 1. Apply the regression tests 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Library/Calendar.t => FAIL: Tests fail! Dates are moved a whole week 3. Apply this patch 4. Repeat step 2 => SUCCESS: Tests pass! 5. Run: k$ prove t/db_dependent/Calendar.t \ t/db_dependent/Circulation/CalcDateDue.t \ t/db_dependent/Circulation.t => SUCCESS: Tests pass! 6. Sign off :-D Assisted-by: Opus 5.5 (Anthropic) Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43838 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208394|0 |1 is obsolete| | Attachment #208395|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43838 --- Comment #7 from David Nind <david@davidnind.com> --- Created attachment 208398 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208398&action=edit Bug 43838: Regression tests [=<26.05.x] This patch adds tests for useDaysMode 'Dayweek' showing that next_open_days, prev_open_days and addDuration jump a whole week over closed days that are not weekly closures, where they should move to the next (or previous) open day: - prev_open_days / next_open_days (used by ReturnBeforeExpiry and TalkingTech_itiva_outbound.pl) - non-weekly loan periods - hourly loans It also adds tests to make sure weekly loan periods keep moving to the next open matching weekday. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Calendar.t => FAIL: Tests fail! Dates are moved a whole week 3. Sign off :-D Assisted-by: Opus 5.5 (Anthropic) Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43838 --- Comment #8 from David Nind <david@davidnind.com> --- Created attachment 208399 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208399&action=edit Bug 43838: Don't jump a whole week outside weekly Dayweek periods [=<26.05.x] With useDaysMode set to 'Dayweek', next_open_days and prev_open_days called get_push_amt on every closed day they met, which returns 7 unless the weekday is a weekly closure. Any caller asking for the next or previous open day got a date a whole week away instead: - ReturnBeforeExpiry (CalcDateDue) - TalkingTech_itiva_outbound.pl - non-weekly loan periods, which the syspref describes as pushed to "the next open day otherwise" - hourly loans ending on a closed day This patch makes next_open_days and prev_open_days skip closed days one day at a time, whatever the useDaysMode value. The move to the next open matching weekday is now only applied by addDays, for 'Dayweek' and loan periods that are a whole number of weeks, through a new _push_to_open_weekday helper. Weekly loan periods behave as before. Test plan: 1. Apply the regression tests 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Calendar.t => FAIL: Tests fail! Dates are moved a whole week 3. Apply this patch 4. Repeat step 2 => SUCCESS: Tests pass! 5. Run: k$ prove t/db_dependent/Calendar.t \ t/db_dependent/Circulation/CalcDateDue.t \ t/db_dependent/Circulation.t => SUCCESS: Tests pass! 6. Sign off :-D Assisted-by: Opus 5.5 (Anthropic) Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43838 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |emily.lamancusa@montgomeryc |y.org |ountymd.gov -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org