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

            Bug ID: 42608
           Summary: Hold-shelf expiration over-extends when
                    ExcludeHolidaysFromMaxPickUpDelay is on and
                    useDaysMode=Dayweek
   Initiative type: ---
        Sponsorship ---
            status:
           Product: Koha
           Version: Main
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P5 - low
         Component: Hold requests
          Assignee: [email protected]
          Reporter: [email protected]
        QA Contact: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

When ExcludeHolidaysFromMaxPickUpDelay is on and useDaysMode is set to
Dayweek, the pickup expiration date set for a hold by Koha::Hold::set_waiting
is inflated by a whole week whenever the pickup window crosses a single
(one-off) closure on a normally-open weekday -- for example a Bank Holiday
Monday.


Steps to reproduce
==================

System preferences:

  ReservesMaxPickUpDelay            = 6
  ExcludeHolidaysFromMaxPickUpDelay = ON
  ExpireReservesOnHolidays          = ON
  useDaysMode                       = Dayweek

Branch calendar:

  - Sundays marked as a weekly closed day.
  - A single (one-off) holiday on a Monday two weeks out -- for example
    2026-05-04 (the early May Bank Holiday).

Trap a hold to waiting at that branch on Tuesday 2026-04-28.


Actual result
=============

expirationdate is set to 2026-05-12 -- a 14-day pickup window.


Expected result
===============

expirationdate should be 2026-05-06 -- a 6-open-day pickup window.

The intent of ExcludeHolidaysFromMaxPickUpDelay is to give the patron the
full ReservesMaxPickUpDelay count of *open* days to come and collect the
item, by extending the window by one calendar day for every closed day that
falls inside it. useDaysMode (Dayweek / Datedue / Calendar / Days) is a
loan-due-date concept -- the patron picks no weekday for a hold pickup;
staff trap the item, and the only thing that should influence the
expiration date is how many open days the patron should get to collect.


Wider example table
===================

Same configuration as above. Sunday 3 May and Monday 4 May 2026 are
closed at the branch. Comparison of current (buggy) vs expected
expiration dates for each weekday a hold could be trapped that week:

  Hold trapped on    Current (buggy)    Expected
  -----------------  -----------------  -----------------
  Mon 27 Apr 2026    Mon 11 May 2026    Tue 5  May 2026
  Tue 28 Apr 2026    Tue 12 May 2026    Wed 6  May 2026
  Wed 29 Apr 2026    Wed 13 May 2026    Thu 7  May 2026
  Thu 30 Apr 2026    Thu 14 May 2026    Fri 8  May 2026
  Fri 1  May 2026    Fri 15 May 2026    Sat 9  May 2026

In each case the expected expiration is `waitingdate + ReservesMaxPickUpDelay`
open days, with Sun 3 May and Mon 4 May skipped (not counted toward the
6-day window). The current buggy expirations are all 14 calendar days from
the trap date -- a whole extra week.


Reproduction snippet
====================

  use Koha::Calendar;
  use Koha::DateUtils qw(dt_from_string);

  # Test branch: Sundays weekly closed, single holiday 2026-05-04.
  my $cal = Koha::Calendar->new(
      branchcode => 'BR',
      days_mode  => 'Dayweek',
  );

  # Bug: prints 2026-05-12 (14 days).
  # Expected: 2026-05-06 (6 open days).
  say $cal->days_forward( dt_from_string('2026-04-28'), 6 )->ymd;


Notes
=====

Loan due dates calculated by Koha::Calendar::addDays under useDaysMode=Dayweek
behave correctly -- the bug only surfaces on hold pickup expiration dates.
A fix should not regress the loan due-date behaviour, which is the original
purpose of the Dayweek mode (keeping a Friday-due loan due on a Friday over
closures).

-- 
You are receiving this mail because:
You are the assignee for the bug.
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