Koha-clms/C4
Martin Renvoize dcd3bdbf28
Bug 40296: (follow-up) Fix booking patron ownership and cancellation logic
This follow-up addresses critical issues in the initial implementation:

1. **Patron Ownership Check**: Only mark bookings as 'completed' when
   the patron checking out the item is the same patron who made the booking

2. **Smart Cancellation**: When another patron checks out an item that
   conflicts with an existing booking:
   - Cancel the booking only if checkout overlaps with actual booking period
   - Respect lead/trail periods - don't cancel if conflict is only during
     preparation periods (allows librarian override scenarios)

3. **Date Logic**: Proper overlap detection using start_date and end_date
   rather than periods extended by lead time

This prevents incorrect booking completion and handles librarian override
scenarios appropriately.

Test plan:
1. Apply previous patch and this follow-up
2. Enable bookings and create a bookable item

Test A - Patron's own booking completion:
3. Create booking for Patron A: start = today, end = +7 days
4. Check out item to Patron A (due date = +5 days)
5. Verify booking status = 'completed'

Test B - Lead period override scenario:
11. Return item, set bookings_lead_period circulation rule = 3 days
12. Create booking for Patron A: start = +5 days, end = +8 days
13. Check out item to Patron B (due date = +4 days) - conflicts with lead period
14. Override the booking conflict warning
15. Verify Patron A's booking status remains 'new' (not cancelled)
16. This respects librarian's decision that item will return in time

Test C - No booking scenario:
17. Return item, ensure no active bookings exist
18. Check out item to any patron
19. Verify checkout works normally without errors

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 2f849fd79c)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-08-26 20:37:26 +02:00
..
AuthoritiesMarc Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Barcodes Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
ClassSortRoutine Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
ClassSplitRoutine Bug 40388: Remove warning from t/Labels.t 2025-07-24 10:23:31 +02:00
Creators Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
External Bug 39834: Replace some tabs with spaces 2025-06-17 21:42:59 +02:00
Form Bug 34776: Add unit tests for sub restore_form_values 2025-07-10 22:47:22 +02:00
Heading Bug 39415: (follow-up) Add 651g to bib heading fields as well 2025-05-06 18:48:18 +02:00
ILSDI Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
Installer Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
Labels Bug 34157: Exporting labels as a barcode range can cause 500 error 2025-07-24 10:23:17 +02:00
Linker Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
Members Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
OAI Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Output Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Patroncards Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
Reports Bug 39325: Manual fixes 2025-04-28 18:51:23 +02:00
SIP Bug 40270: Fix uninitialized value warnings in SIP logging 2025-08-22 09:48:24 +02:00
Search Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
Serials Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Utils/DataTables Bug 39427: Searching lists table by owner can only enter firstname or surname 2025-08-22 09:48:26 +02:00
Accounts.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
Acquisition.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
Auth.pm Bug 40401: Implement Koha::Patron->is_anonymous 2025-07-24 21:04:38 +02:00
Auth_cas_servers.yaml.sample Bug 17065 - Rename C4/Auth_cas_servers.yaml.orig 2016-08-08 13:16:36 +00:00
Auth_with_cas.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
Auth_with_ldap.pm Bug 39834: Replace some tabs with spaces 2025-06-17 21:42:59 +02:00
Auth_with_shibboleth.pm Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
AuthoritiesMarc.pm Bug 40119: (QA follow-up) Small additional comment 2025-06-22 23:48:48 +02:00
Barcodes.pm Bug 39834: Replace some tabs with spaces 2025-06-17 21:42:59 +02:00
Biblio.pm Bug 40403: Remove warning from Circulation_holdsqueue.t 2025-07-24 10:23:29 +02:00
Breeding.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Budgets.pm Bug 39834: Replace some tabs with spaces 2025-06-17 21:42:59 +02:00
Calendar.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Charset.pm Bug 39834: Replace some tabs with spaces 2025-06-17 21:42:59 +02:00
Circulation.pm Bug 40296: (follow-up) Fix booking patron ownership and cancellation logic 2025-08-26 20:37:26 +02:00
ClassSortRoutine.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
ClassSource.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
ClassSplitRoutine.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Context.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
Contract.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
CourseReserves.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Creators.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
HTML5Media.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Heading.pm Bug 38729: Linker should consider diacritics 2025-04-14 08:50:57 +02:00
HoldsQueue.pm Bug 20747: (follow-up) Fix hold queue to work with LocalHoldPriority Group options 2025-05-15 08:34:20 +02:00
ImportBatch.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
ImportExportFramework.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
InstallAuth.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
Installer.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
ItemCirculationAlertPreference.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Items.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
Koha.pm Bug 40277: Remove warn in C4::Koha::GetAuthorisedValues() 2025-07-10 22:47:31 +02:00
Labels.pm Bug 21395: Make perlcritic happy 2020-06-29 12:37:02 +02:00
Languages.pm Bug 39325: Tidy 2025-04-28 18:51:27 +02:00
Letters.pm Bug 40037: (follow-up) Remove redundancy in `before_send_messages` 2025-08-22 09:48:13 +02:00
Linker.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Log.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
MarcModificationTemplates.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Matcher.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
Members.pm Bug 37418: delete_patrons.pl: Exclude patrons with restrictions 2025-04-25 08:46:53 +02:00
Message.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Output.pm Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
Overdues.pm Bug 39405: (follow-up) Add the parameter borrowernumber to the overwrite_calc_fine plugin hook 2025-04-25 08:46:49 +02:00
Patroncards.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Record.pm Bug 39834: Replace some tabs with spaces 2025-06-17 21:42:59 +02:00
Reports.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Reserves.pm Bug 40055: Make MoveReserve be passed objects instead of ids 2025-06-24 11:30:06 +02:00
Ris.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
RotatingCollections.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
SMS.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
Scheduler.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
Scrubber.pm Bug 40079: (follow-up) Improve test coverage and fix undef handling 2025-07-10 22:47:17 +02:00
Search.pm Bug 36947: Add system preference for configurable locale-based facet sorting 2025-07-24 10:23:42 +02:00
Serials.pm Bug 39834: Replace some tabs with spaces 2025-06-17 21:42:59 +02:00
Service.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
ShelfBrowser.pm Bug 39834: Replace some tabs with spaces 2025-06-17 21:42:59 +02:00
SocialData.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Stats.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Suggestions.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
TTParser.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
Tags.pm Bug 39834: Replace some tabs with spaces 2025-06-17 21:42:59 +02:00
Templates.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
TmplToken.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
TmplTokenType.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
UsageStats.pm Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
XISBN.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
XSLT.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00