Bug 34440: Take preparation period into account at checkout

This patch ensures we catch checkouts that would interfer with the
preparation period set for an existing booking by adding said period to
the bookings search.

We also reduce the proposed due date for the checkout to be confirmed by
the preparation period for the item.

Test plan
1) Set a booking preparation period for an itemtype
2) Add a booking for an item with that itemtype to fall beyond the due
   date that the item would be assigned if you were to check it out now
   to your test user, but within the number of days you've set for your
   preparation period.
3) Attempt to check the item out to your test user.
4) Note that we catch the booking and warn and that the latest return
   date suggested take the preparation period into account.

Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Signed-off-by: Kristi Krueger <KKRUEGER@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Martin Renvoize 2024-03-27 17:29:00 +00:00 committed by Katrin Fischer
parent f053ca032b
commit 620527f971
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 21 additions and 1 deletions

View File

@ -602,6 +602,16 @@ sub find_booking {
my $due_date = $params->{due_date};
my $biblio = $self->biblio;
my $rule = Koha::CirculationRules->get_effective_rule(
{
rule_name => 'bookings_lead_period',
itemtype => $self->effective_itemtype,
branchcode => "*"
}
);
my $preparation_period = $rule ? $rule->rule_value : 0;
$due_date = $due_date->clone->add( days => $preparation_period );
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
my $bookings = $biblio->bookings(
[

View File

@ -52,6 +52,7 @@ use Koha::Plugins;
use Koha::Database;
use Koha::BiblioFrameworks;
use Koha::Items;
use Koha::CirculationRules;
use Koha::SearchEngine;
use Koha::SearchEngine::Search;
use Koha::Patron::Modifications;
@ -482,8 +483,17 @@ if (@$barcodes && $op eq 'cud-checkout') {
$template_params->{NEEDSCONFIRMATION} = 1;
$confirm_required = 1;
if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) {
my $rule = Koha::CirculationRules->get_effective_rule(
{
rule_name => 'bookings_lead_period',
itemtype => $item->effective_itemtype,
branchcode => "*"
}
);
my $preparation_period = $rule ? $rule->rule_value : 1;
my $reduceddue =
dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date )->subtract( days => 1 );
dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date )
->subtract( days => $preparation_period );
$template_params->{reduceddue} = $reduceddue;
}
}