|
Lines 2600-2606
subtest 'bookings' => sub {
Link Here
|
| 2600 |
}; |
2600 |
}; |
| 2601 |
|
2601 |
|
| 2602 |
subtest 'find_booking' => sub { |
2602 |
subtest 'find_booking' => sub { |
| 2603 |
plan tests => 6; |
2603 |
plan tests => 7; |
| 2604 |
|
2604 |
|
| 2605 |
$schema->storage->txn_begin; |
2605 |
$schema->storage->txn_begin; |
| 2606 |
|
2606 |
|
|
Lines 2707-2712
subtest 'find_booking' => sub {
Link Here
|
| 2707 |
"Koha::Item->find_booking returns the current booking not a future one" |
2707 |
"Koha::Item->find_booking returns the current booking not a future one" |
| 2708 |
); |
2708 |
); |
| 2709 |
|
2709 |
|
|
|
2710 |
subtest "Preparation period handling" => sub { |
| 2711 |
plan tests => 3; |
| 2712 |
|
| 2713 |
# Delete current booking, is the future booking returned? |
| 2714 |
$booking2->delete(); |
| 2715 |
$found_booking = $item->find_booking( |
| 2716 |
{ |
| 2717 |
checkout_date => dt_from_string(), |
| 2718 |
due_date => dt_from_string()->add( days => 7 ), |
| 2719 |
} |
| 2720 |
); |
| 2721 |
|
| 2722 |
is( |
| 2723 |
$found_booking, |
| 2724 |
undef, |
| 2725 |
"Koha::Item->find_booking returns undefined when the current booking is deleted and the future booking is out of range and there's no lead period rule" |
| 2726 |
); |
| 2727 |
|
| 2728 |
# Adding lead period rule |
| 2729 |
Koha::CirculationRules->set_rules( |
| 2730 |
{ |
| 2731 |
branchcode => '*', |
| 2732 |
itemtype => $item->effective_itemtype, |
| 2733 |
rules => { |
| 2734 |
bookings_lead_period => 3, |
| 2735 |
}, |
| 2736 |
} |
| 2737 |
); |
| 2738 |
|
| 2739 |
$found_booking = $item->find_booking( |
| 2740 |
{ |
| 2741 |
checkout_date => dt_from_string(), |
| 2742 |
due_date => dt_from_string()->add( days => 7 ), |
| 2743 |
} |
| 2744 |
); |
| 2745 |
|
| 2746 |
is( |
| 2747 |
ref($found_booking), |
| 2748 |
'Koha::Booking', |
| 2749 |
"Koha::Item->find_booking returns a Koha::Booking if one exists that would clash with the passed dates including lead period" |
| 2750 |
); |
| 2751 |
is( |
| 2752 |
$found_booking->booking_id, $booking3->booking_id, |
| 2753 |
"Koha::Item->find_booking returns the future booking when lead period is included" |
| 2754 |
); |
| 2755 |
|
| 2756 |
}; |
| 2757 |
|
| 2710 |
$schema->storage->txn_rollback; |
2758 |
$schema->storage->txn_rollback; |
| 2711 |
}; |
2759 |
}; |
| 2712 |
|
2760 |
|
| 2713 |
- |
|
|