https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38940

Martin Renvoize (ashimema) <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #188622|0                           |1
        is obsolete|                            |

--- Comment #7 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 189154
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=189154&action=edit
Bug 38940: Fix ConsiderLibraryHoursInCirculation when next day has no hours

When ConsiderLibraryHoursInCirculation is set to "shorten the loan
period and set the checkout to be due at the library's close time",
the feature fails to work if the next day has null/blank library hours
(e.g., weekends or closed days).

The code was incorrectly forcing the system to ignore library hours
entirely whenever EITHER today's hours OR tomorrow's hours were
undefined. This was too restrictive because:
- The 'close' option only needs today's closing time
- The 'open' option needs tomorrow's opening time

This patch modifies the logic to:
1. Only ignore library hours if today's hours are missing
2. For 'open' mode, require tomorrow's hours to extend the loan
3. For 'close' mode, allow it to work with just today's hours
4. Gracefully handle null tomorrow hours in both code paths

Test plan:
1. Apply patch and run tests:
   prove t/db_dependent/Circulation/CalcDateDue.t
   prove t/db_dependent/Circulation.t

2. Note the current time and day of week for your testing.
   You will configure Koha's library operating hours and circulation rules
   based on the current time to trigger the bug conditions.

3. Configure library operating hours at Administration > Libraries > [Select
your library] > Hours

   Set operating hours based on today's day of week:
   - TODAY (your current day): Set hours that include the current time
     Example: If it's currently 14:30, set hours like 09:00-17:00
   - TOMORROW: Leave completely blank (no hours defined at all)
     This is the key configuration that triggers the bug!
   - Other days: Can be set normally or left blank (doesn't affect this test)

   Example if testing on Tuesday at 14:30:
   - Tuesday: 09:00-17:00 (must include current time of 14:30)
   - Wednesday: Leave completely blank (tomorrow has no hours - this triggers
the bug)
   - Monday, Thursday-Sunday: Set normally or leave blank (doesn't matter)

4. Set system preferences:
   - ConsiderLibraryHoursInCirculation: "shorten the loan period to end when
the library closes"
   - useDaysMode: Can be set to either "Days" or "Calendar" (both code paths
are affected)

5. Create a circulation rule with hourly loan period:
   - Go to Administration > Circulation and fine rules
   - Set loan period in hours that would extend past today's closing time
   - Calculate: (Closing time - Current time) + 1 hour minimum
     Example: If it's 14:30 now and library closes at 17:00, set loan period
     to 4 or 5 hours so the loan would normally extend past 17:00

6. Test the 'close' behavior (shorten to closing time):
   - Check out an item using the hourly loan rule you created

   Without patch: Due date/time would extend well past closing time
                  (ignoring library hours because tomorrow has no hours
defined)
                  Example: 14:30 + 4 hours = 18:30 (ignoring 17:00 close)

   With patch: Due date/time should be shortened to today's closing time
               Example: 14:30 + 4 hour loan = 18:30, but shortened to 17:00

7. Verify the behavior is consistent:
   - The due date/time should match today's closing time exactly
   - Try checking out multiple items - all should have the same due time
     (today's closing time)

8. Test with ConsiderLibraryHoursInCirculation set to "extend to next opening
time":
   - Change the system preference to "extend the loan period to the library's
next opening time"
   - Check out an item with the same hourly loan rule
   - Since tomorrow has no defined operating hours, the system cannot
     determine when to extend the loan to
   - The checkout should fall back to standard loan duration (ignoring library
hours)
   - Example: 14:30 + 4 hour loan = 18:30 (ignoring the 17:00 closing time,
     since we cannot extend to tomorrow's undefined opening time)

NOTES FOR REVIEW:

When ConsiderLibraryHoursInCirculation is set to "extend the loan
period to the library's next opening time" and the next day has no
defined hours, this patch falls back to using the standard loan
duration (ignoring library hours).

Question for reviewers: Should we instead roll forward to find the
next day that HAS defined opening hours? For example, if checking out
Friday evening with the library closed Saturday/Sunday, should we
extend the due date to Monday's opening time rather than falling back
to ignoring library hours?

Sponsored-by: Open Fifth <https://openfith.co.uk>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to