[Bug 42997] New: Keep booking end dates in sync with checkout due dates at issue and renewal
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42997 Bug ID: 42997 Summary: Keep booking end dates in sync with checkout due dates at issue and renewal Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Circulation Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com, kyle@bywatersolutions.com Target Milestone: --- Depends on bug 41898 (booking status lifecycle). With the 'issued' booking status in place, the booking and its linked checkout can drift apart whenever the due date differs from the booking end date - at issue time (staff due date overrides) and at renewal. This patchset makes the checkout due date authoritative and keeps the booking in step with it: - AddIssue syncs any due date override back to booking.end_date the moment the booking transitions to 'issued'; if the override would clash with a subsequent booking the checkout proceeds with the booking's original end date - CanBookBeIssued raises a new BOOKED_DUE_DATE_CLASH confirmation on the checkout screen when an explicitly requested due date runs into the next booking for the item, so staff are warned before continuing - circulation.pl now honours an explicit due date override for booked items instead of silently clamping it to the booking end date - CanBookBeRenewed no longer allows a renewal to run straight through the start of the next booking: the patron's own booking previously hid subsequent bookings from the clash lookup. Requested due dates (checkouts screen renewal date, circ/renew.pl hard due date) are now validated against bookings too - AddRenewal pulls the linked booking's end_date along with the renewed due date, mirroring the AddIssue behaviour Test plan: 1. Run t/db_dependent/Circulation.t and t/db_dependent/Koha/Item.t 2. Create two consecutive bookings on one item for two patrons; check the item out to the first patron with a due date beyond the second booking's start; confirm the warning appears and, on confirming, the checkout uses the requested date whilst the booking keeps its original end date 3. Check out a booked item with a non-clashing due date override and confirm the booking end date follows it 4. Renew a booked checkout and confirm the booking end date follows the new due date; attempt to renew past the next booking's start and confirm the renewal is refused -- 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=42997 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |41898 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41898 [Bug 41898] Expired bookings do not display when expired filter is used in patron record -- 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=42997 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |42998 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42998 [Bug 42998] Allow a requested due date when renewing a checkout via the REST API -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42997 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED -- 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=42997 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk -- 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=42997 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Sponsorship status|--- |Unsponsored Status|ASSIGNED |Needs Signoff Patch complexity|--- |Medium patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42997 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201542 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201542&action=edit Bug 42997: Sync booking end_date with due date override at checkout When a booked item is checked out, the due date defaults to the booking end_date. Staff may override the due date at checkout time, which previously left the booking end_date out of sync with the checkout, blocking the booked period for longer or shorter than the actual loan. This patch updates C4::Circulation::AddIssue to sync any due date override back to booking.end_date the moment the booking transitions to 'issued', keeping the booking and the checkout aligned from the point of issue. The existing Koha::Booking->store clash detection is used to guard the update: if the overridden due date would clash with a subsequent booking for the same item, the checkout proceeds with the booking's original end_date instead. Test plan: 1) Run t/db_dependent/Circulation.t and confirm the new 'AddIssue | booking end_date sync with due date override' subtest passes 2) Create a booking for a patron on a specific item 3) Check the item out to the patron, overriding the suggested due date 4) Confirm the booking's end_date now matches the overridden due date -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42997 --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201543 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201543&action=edit Bug 42997: Don't let a booking's own checkout block it in check_booking Koha::Item->check_booking refuses any booking period that starts before the item's current checkout is due back. That is correct when assessing a new booking against someone else's loan, but it also fired when the checkout in question is the booking's own linked loan - making it impossible to ever move an issued booking's end_date, as any update would 'clash' with its own checkout. This patch skips the checkout guard when the checkout's booking_id matches the booking_id passed for exclusion, i.e. when the checkout belongs to the very booking being updated. This is a prerequisite for keeping booking end dates in sync with checkout due dates in this patchset, and for the booking extension pathway on bug 42790. Test plan: 1) Run t/db_dependent/Koha/Item.t and confirm the check_booking subtest passes, including the two new checkout-related tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42997 --- Comment #3 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201544 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201544&action=edit Bug 42997: Warn staff when a due date override runs into the next booking When checking out a booked item, staff may override the suggested due date. If that override runs into the next booking for the item, the previous patch would silently keep the booking's original end date - staff had no way of knowing their override crossed another booking. This patch adds an exclude_booking_id option to Koha::Item->find_booking so a lookup can skip a specific booking (here: the patron's own booking being collected), and uses it in CanBookBeIssued to detect when an explicitly requested due date would run into the next booking for the item. When it would, a new BOOKED_DUE_DATE_CLASH confirmation is raised and displayed on the checkout screen, telling staff the linked booking will keep its original end date if they continue. Only explicitly requested due dates trigger the confirmation - calculated due dates are clamped to the booking end date later in the staff checkout flow, so checking them would produce false positives. SIP is unaffected as it never passes a requested due date. Test plan: 1) Run t/db_dependent/Circulation.t and t/db_dependent/Koha/Item.t 2) Create two consecutive bookings on the same item for two patrons 3) Check the item out to the first patron specifying a due date beyond the second booking's start date; confirm the new confirmation message appears and checkout only proceeds once confirmed -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42997 --- Comment #4 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201545 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201545&action=edit Bug 42997: Prevent renewals running into the next booking CanBookBeRenewed checked bookings by asking Koha::Item->find_booking for the first booking that clashes with the renewal period. When the renewing patron's own booking satisfies this checkout, that booking is returned first and renewal is allowed - subsequent bookings for the item were never considered. A patron could therefore renew a booked item straight through the start of the next patron's booking. Additionally, when staff renew with an explicit due date (the renewal due date input on the checkouts screen, or the hard due date on circ/renew.pl), CanBookBeRenewed validated a *calculated* due date whilst AddRenewal then applied the *requested* one, so the requested date was never checked against bookings at all. This patch: * repeats the booking lookup with the patron's own booking excluded, refusing the renewal ('booked') when it would run into the next booking for the item * adds an optional $date_due parameter to CanBookBeRenewed, used in place of the calculated due date for the bookings check, and threads the requested date through from svc/renew and circ/renew.pl Test plan: 1) Run t/db_dependent/Circulation.t - the extended 'CanBookBeRenewed | bookings' subtest covers both the calculated and requested due date cases 2) Check out a booked item to its patron, add a subsequent booking for another patron, and attempt to renew past the second booking's start date from the checkouts screen; confirm the renewal is refused as 'booked' -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42997 --- Comment #5 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201546 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201546&action=edit Bug 42997: Sync booking end_date with the due date at renewal When a checkout satisfying a booking is renewed, the booking previously kept its original end_date, blocking the booked period from other patrons for the wrong window and leaving the two records out of sync. This patch updates C4::Circulation::AddRenewal to pull the linked booking's end_date along with the renewed due date, mirroring the behaviour introduced for AddIssue earlier in this patchset. As at issue time, if the new due date would clash with a subsequent booking (possible when the renewal was explicitly allowed past a clash), the booking keeps its original end_date. Together with the previous patch this makes a renewal the natural way to extend an issued booking: CanBookBeRenewed refuses renewals that would run into the next booking, and AddRenewal keeps the booking in step with the loan. Test plan: 1) Run t/db_dependent/Circulation.t and confirm the new 'AddRenewal | booking end_date sync' subtest passes 2) Check out a booked item, renew it from the checkouts screen and confirm the booking end date follows the new due date -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42997 --- Comment #6 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201547 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201547&action=edit Bug 42997: Honour explicit due date overrides for booked items at checkout When checking out a booked item, circulation.pl unconditionally replaced the due date with the booking end date, silently discarding any due date staff had explicitly specified - even after they had just confirmed the BOOKED_DUE_DATE_CLASH warning saying they wanted it. The booking end date remains the default when no due date is specified; an explicit override (with SpecifyDueDate enabled) is now passed through to AddIssue, which syncs the booking end_date with it where possible and keeps the original end date when the override would clash with a subsequent booking (as warned). Test plan: 1) Create a booking and check the item out without specifying a due date; confirm the due date defaults to the booking end date 2) Return the item, book it again, and check out specifying an explicit due date; confirm the checkout uses that date and the booking end date follows it -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org