Lines 18-24
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
use utf8; |
19 |
use utf8; |
20 |
|
20 |
|
21 |
use Test::More tests => 68; |
21 |
use Test::More tests => 69; |
22 |
use Test::Exception; |
22 |
use Test::Exception; |
23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
24 |
use Test::Deep qw( cmp_deeply ); |
24 |
use Test::Deep qw( cmp_deeply ); |
Lines 42-47
use C4::Overdues qw( CalcFine UpdateFine get_chargeable_units );
Link Here
|
42 |
use C4::Members::Messaging qw( SetMessagingPreference ); |
42 |
use C4::Members::Messaging qw( SetMessagingPreference ); |
43 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
43 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
44 |
use Koha::Database; |
44 |
use Koha::Database; |
|
|
45 |
use Koha::Bookings; |
45 |
use Koha::Items; |
46 |
use Koha::Items; |
46 |
use Koha::Item::Transfers; |
47 |
use Koha::Item::Transfers; |
47 |
use Koha::Checkouts; |
48 |
use Koha::Checkouts; |
Lines 4584-4589
subtest 'CanBookBeIssued | recalls' => sub {
Link Here
|
4584 |
$recall->set_cancelled; |
4585 |
$recall->set_cancelled; |
4585 |
}; |
4586 |
}; |
4586 |
|
4587 |
|
|
|
4588 |
subtest 'CanBookBeIssued | bookings' => sub { |
4589 |
plan tests => 4; |
4590 |
|
4591 |
my $schema = Koha::Database->schema; |
4592 |
$schema->storage->txn_begin; |
4593 |
|
4594 |
my $patron1 = $builder->build_object( { class => 'Koha::Patrons' } ); |
4595 |
my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } ); |
4596 |
my $item = $builder->build_sample_item( { bookable => 1 } ); |
4597 |
|
4598 |
# item-level booking |
4599 |
my $booking = Koha::Booking->new( |
4600 |
{ |
4601 |
patron_id => $patron1->borrowernumber, |
4602 |
item_id => $item->itemnumber, |
4603 |
biblio_id => $item->biblio->biblionumber, |
4604 |
start_date => dt_from_string()->subtract( days => 1), |
4605 |
end_date => dt_from_string()->add( days => 6 ), |
4606 |
} |
4607 |
)->store(); |
4608 |
|
4609 |
# Booking encompasses proposed checkout |
4610 |
my ( $issuingimpossible, $needsconfirmation, $alerts, $messages ) = |
4611 |
CanBookBeIssued( $patron2, $item->barcode, |
4612 |
dt_from_string()->add( days => 5 ), |
4613 |
undef, undef, undef ); |
4614 |
is( |
4615 |
$issuingimpossible->{BOOKED_TO_ANOTHER}->booking_id, |
4616 |
$booking->booking_id, |
4617 |
"Another patron has booked this item with a start date before the proposed due date" |
4618 |
); |
4619 |
|
4620 |
( $issuingimpossible, $needsconfirmation, $alerts, $messages ) = |
4621 |
CanBookBeIssued( $patron1, $item->barcode, |
4622 |
dt_from_string()->add( days => 5 ), |
4623 |
undef, undef, undef ); |
4624 |
is( $alerts->{BOOKED}->booking_id, |
4625 |
$booking->booking_id, "Booked to this user" ); |
4626 |
|
4627 |
# Booking start will clash before issue due |
4628 |
$booking->start_date( dt_from_string()->add( days => 3 ) )->store(); |
4629 |
|
4630 |
( $issuingimpossible, $needsconfirmation, $alerts, $messages ) = |
4631 |
CanBookBeIssued( $patron2, $item->barcode, |
4632 |
dt_from_string()->add( days => 5 ), |
4633 |
undef, undef, undef ); |
4634 |
is( |
4635 |
$needsconfirmation->{BOOKED_TO_ANOTHER}->booking_id, |
4636 |
$booking->booking_id, |
4637 |
"Another patron has booked this item for a period starting before the proposed due date" |
4638 |
); |
4639 |
|
4640 |
( $issuingimpossible, $needsconfirmation, $alerts, $messages ) = |
4641 |
CanBookBeIssued( $patron1, $item->barcode, |
4642 |
dt_from_string()->add( days => 5 ), |
4643 |
undef, undef, undef ); |
4644 |
is( $needsconfirmation->{BOOKED_EARLY}->booking_id, |
4645 |
$booking->booking_id, |
4646 |
"Booked to this user, but they're collecting early" ); |
4647 |
|
4648 |
$schema->storage->txn_rollback; |
4649 |
}; |
4650 |
|
4587 |
subtest 'AddReturn should clear items.onloan for unissued items' => sub { |
4651 |
subtest 'AddReturn should clear items.onloan for unissued items' => sub { |
4588 |
plan tests => 1; |
4652 |
plan tests => 1; |
4589 |
|
4653 |
|
4590 |
- |
|
|