diff --git a/Koha/Item.pm b/Koha/Item.pm index b9e35ae352..d2e475df02 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -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( [ diff --git a/circ/circulation.pl b/circ/circulation.pl index acabfa4d1d..9230347ce0 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -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; } }