Lines 605-613
implementation.
Link Here
|
605 |
sub find_booking { |
605 |
sub find_booking { |
606 |
my ( $self, $params ) = @_; |
606 |
my ( $self, $params ) = @_; |
607 |
|
607 |
|
608 |
my $checkout_date = $params->{checkout_date}; |
608 |
my $start_date = $params->{checkout_date}; |
609 |
my $due_date = $params->{due_date}; |
609 |
my $end_date = $params->{due_date}; |
610 |
my $biblio = $self->biblio; |
610 |
my $biblio = $self->biblio; |
611 |
|
611 |
|
612 |
my $rule = Koha::CirculationRules->get_effective_rule( |
612 |
my $rule = Koha::CirculationRules->get_effective_rule( |
613 |
{ |
613 |
{ |
Lines 617-649
sub find_booking {
Link Here
|
617 |
} |
617 |
} |
618 |
); |
618 |
); |
619 |
my $preparation_period = $rule ? $rule->rule_value : 0; |
619 |
my $preparation_period = $rule ? $rule->rule_value : 0; |
620 |
$due_date = $due_date->clone->add( days => $preparation_period ); |
620 |
$end_date = $end_date->clone->add( days => $preparation_period ); |
621 |
|
621 |
|
622 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
622 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
623 |
my $bookings = $biblio->bookings( |
623 |
my $bookings = $biblio->bookings( |
624 |
[ |
624 |
{ |
625 |
# Proposed checkout starts during booked period |
625 |
'-and' => [ |
626 |
start_date => { |
626 |
{ |
627 |
'-between' => [ |
627 |
'-or' => [ |
628 |
$dtf->format_datetime($checkout_date), |
|
|
629 |
$dtf->format_datetime($due_date) |
630 |
] |
631 |
}, |
632 |
|
628 |
|
633 |
# Proposed checkout is due during booked period |
629 |
# Proposed checkout starts during booked period |
634 |
end_date => { |
630 |
start_date => { |
635 |
'-between' => [ |
631 |
'-between' => [ |
636 |
$dtf->format_datetime($checkout_date), |
632 |
$dtf->format_datetime($start_date), |
637 |
$dtf->format_datetime($due_date) |
633 |
$dtf->format_datetime($end_date) |
638 |
] |
634 |
] |
639 |
}, |
635 |
}, |
640 |
|
636 |
|
641 |
# Proposed checkout would contain the booked period |
637 |
# Proposed checkout is due during booked period |
642 |
{ |
638 |
end_date => { |
643 |
start_date => { '<' => $dtf->format_datetime($checkout_date) }, |
639 |
'-between' => [ |
644 |
end_date => { '>' => $dtf->format_datetime($due_date) } |
640 |
$dtf->format_datetime($start_date), |
645 |
} |
641 |
$dtf->format_datetime($end_date) |
646 |
], |
642 |
] |
|
|
643 |
}, |
644 |
|
645 |
# Proposed checkout would contain the booked period |
646 |
{ |
647 |
start_date => { '<' => $dtf->format_datetime($start_date) }, |
648 |
end_date => { '>' => $dtf->format_datetime($end_date) } |
649 |
} |
650 |
] |
651 |
}, |
652 |
{ status => { '-not_in' => [ 'cancelled', 'completed' ] } } |
653 |
] |
654 |
}, |
647 |
{ order_by => { '-asc' => 'start_date' } } |
655 |
{ order_by => { '-asc' => 'start_date' } } |
648 |
); |
656 |
); |
649 |
|
657 |
|
Lines 668-673
sub find_booking {
Link Here
|
668 |
|
676 |
|
669 |
# Booking for another item |
677 |
# Booking for another item |
670 |
elsif ( defined( $booking->item_id ) ) { |
678 |
elsif ( defined( $booking->item_id ) ) { |
|
|
679 |
|
671 |
# Due for another booking, remove from pool |
680 |
# Due for another booking, remove from pool |
672 |
delete $loanable_items->{ $booking->item_id }; |
681 |
delete $loanable_items->{ $booking->item_id }; |
673 |
next; |
682 |
next; |