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 ) = CanBookBeIssued( |
4611 |
$patron2, $item->barcode, |
4612 |
dt_from_string()->add( days => 5 ), |
4613 |
undef, undef, undef |
4614 |
); |
4615 |
is( |
4616 |
$issuingimpossible->{BOOKED_TO_ANOTHER}->booking_id, |
4617 |
$booking->booking_id, |
4618 |
"Another patron has booked this item with a start date before the proposed due date" |
4619 |
); |
4620 |
|
4621 |
( $issuingimpossible, $needsconfirmation, $alerts, $messages ) = CanBookBeIssued( |
4622 |
$patron1, $item->barcode, |
4623 |
dt_from_string()->add( days => 5 ), |
4624 |
undef, undef, undef |
4625 |
); |
4626 |
is( |
4627 |
$alerts->{BOOKED}->booking_id, |
4628 |
$booking->booking_id, "Booked to this user" |
4629 |
); |
4630 |
|
4631 |
# Booking start will clash before issue due |
4632 |
$booking->start_date( dt_from_string()->add( days => 3 ) )->store(); |
4633 |
|
4634 |
( $issuingimpossible, $needsconfirmation, $alerts, $messages ) = CanBookBeIssued( |
4635 |
$patron2, $item->barcode, |
4636 |
dt_from_string()->add( days => 5 ), |
4637 |
undef, undef, undef |
4638 |
); |
4639 |
is( |
4640 |
$needsconfirmation->{BOOKED_TO_ANOTHER}->booking_id, |
4641 |
$booking->booking_id, |
4642 |
"Another patron has booked this item for a period starting before the proposed due date" |
4643 |
); |
4644 |
|
4645 |
( $issuingimpossible, $needsconfirmation, $alerts, $messages ) = CanBookBeIssued( |
4646 |
$patron1, $item->barcode, |
4647 |
dt_from_string()->add( days => 5 ), |
4648 |
undef, undef, undef |
4649 |
); |
4650 |
is( |
4651 |
$needsconfirmation->{BOOKED_EARLY}->booking_id, |
4652 |
$booking->booking_id, |
4653 |
"Booked to this user, but they're collecting early" |
4654 |
); |
4655 |
|
4656 |
$schema->storage->txn_rollback; |
4657 |
}; |
4658 |
|
4587 |
subtest 'AddReturn should clear items.onloan for unissued items' => sub { |
4659 |
subtest 'AddReturn should clear items.onloan for unissued items' => sub { |
4588 |
plan tests => 1; |
4660 |
plan tests => 1; |
4589 |
|
4661 |
|
4590 |
- |
|
|