Koha-clms/circ
Martin Renvoize d463fce02d
Bug 37966: Fix renewal on hold override in circulation.pl
This extends the fix from Bug 37966 to circ/circulation.pl. The original
bug fix addressed circ/renew.pl, where renewing a book on hold with an
empty due date would result in the due date being set to "now" (today).

The same issue occurs in circ/circulation.pl when:
1. Attempting to check out an item that is already checked out to the
   same patron (which triggers a renewal)
2. The item has a hold on it, triggering the hold override dialog
3. The librarian overrides the hold without specifying a due date

In this scenario, the renewal would incorrectly set the due date to
today instead of calculating it based on circulation rules.

CHANGES:

1. circ/circulation.pl (lines 550-558)
   - Added logic to handle the `renewonholdduedate` parameter when
     both RENEW_ISSUE and RESERVED conditions are present
   - Follows the same pattern as circ/renew.pl
   - If `renewonholdduedate` is empty, passes empty string to AddIssue/
     AddRenewal, allowing proper date calculation

2. koha-tmpl/.../circulation.tt (lines 351-356)
   - Added "Renewal due date" input field in the hold override dialog
   - Only appears when both RESERVED and RENEW_ISSUE are true
   - Optional field - if left empty, due date is calculated per
     circulation rules

TEST PLAN:

1. Enable the RenewalOnHoldOverride system preference (set to "Allow")

2. Set up a patron, item, and circulation rules:
   - Create a patron (or use existing)
   - Create an item (or use existing)
   - Ensure circulation rules have a renewal period (e.g., 14 days)

3. Create a hold scenario:
   - Check out the item to the patron
   - Place a title-level hold on the same item (you may need a second
     patron or use the same patron depending on your holds rules)

4. Test renewal via circulation.pl:
   - Go to Circulation (Home > Circulation)
   - Scan the patron's barcode
   - Scan the item's barcode (the one that's already checked out with
     a hold)
   - Observe the hold override dialog appears

5. Test WITHOUT this patch:
   - Leave the "Renewal due date" field empty
   - Click "Yes, renew"
   - BUG: The due date is set to today (same as check-in date)

6. Test WITH this patch:
   - Leave the "Renewal due date" field empty
   - Click "Yes, renew"
   - SUCCESS: The due date is calculated based on circulation rules
     (e.g., 14 days from now if that's your renewal period)

7. Test optional due date override:
   - Repeat the renewal process
   - This time, enter a specific date in "Renewal due date" field
   - Click "Yes, renew"
   - SUCCESS: The due date is set to your specified date

8. Test SpecifyDueDate preference interaction:
   - If SpecifyDueDate is enabled and a due date is set via that
     interface, it should take precedence over renewonholdduedate

TECHNICAL NOTES:

The fix ensures that when `renewonholdduedate` is empty (empty string),
it's passed through to AddIssue which then calls AddRenewal. The
improved empty string handling in C4::Circulation (from the follow-up
commit) ensures empty strings are not parsed as "now" but instead
trigger proper date calculation based on circulation rules.

This matches the behavior fixed in circ/renew.pl and provides a
consistent user experience across both circulation interfaces.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-04-29 09:09:11 -06:00
..
add_message.pl Bug 39781: Allow limiting of custom message notices by library 2026-03-24 15:38:08 +01:00
article-request-slip.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
article-requests.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
bookcount.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
branchoverdues.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
branchtransfers.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
checkout-notes.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
circulation-home.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
circulation.pl Bug 37966: Fix renewal on hold override in circulation.pl 2026-04-29 09:09:11 -06:00
curbside_pickups.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
del_message.pl Bug 41904: "Use of uninitialized value..." warning in del_message.pl 2026-03-05 08:33:55 -07:00
hold-transfer-slip.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
on-site_checkouts.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
overdue.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
pendingbookings.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
pendingreserves.pl Bug 40529: Behavior change: Main patch 2025-11-03 14:13:22 -07:00
renew.pl Bug 23415: Add debt override support to circulation checkout page 2026-03-22 23:27:26 +01:00
request-article.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
reserveratios.pl Bug 21941: Fix GROUP BY in circ/reserveratios.pl 2026-04-09 08:27:25 -06:00
returns.pl Bug 41957: Show hold group information on 'Hold found' modal 2026-04-10 09:48:02 -06:00
set-library.pl Bug 41229: Fix desk and register session persistence on library change 2025-12-01 08:34:05 -07:00
transfer-slip.pl Bug 35267: Apply preferences to preview and mailing 2026-04-17 09:18:06 -06:00
transfers_to_send.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
transferstoreceive.pl Bug 41206: Add collection code to transfers to receive 2026-02-06 15:17:10 -07:00
view_holdsqueue.pl Bug 40335: Fix mistake in template params 2025-10-14 14:51:57 -06:00
waitingreserves.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00