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 => 46; |
21 |
use Test::More tests => 47; |
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
use Test::Deep qw( cmp_deeply ); |
23 |
use Test::Deep qw( cmp_deeply ); |
24 |
|
24 |
|
Lines 2954-2960
subtest 'Set waiting flag' => sub {
Link Here
|
2954 |
}; |
2954 |
}; |
2955 |
|
2955 |
|
2956 |
subtest 'Cancel transfers on lost items' => sub { |
2956 |
subtest 'Cancel transfers on lost items' => sub { |
2957 |
plan tests => 5; |
2957 |
plan tests => 6; |
2958 |
my $library_1 = $builder->build( { source => 'Branch' } ); |
2958 |
my $library_1 = $builder->build( { source => 'Branch' } ); |
2959 |
my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
2959 |
my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
2960 |
my $library_2 = $builder->build( { source => 'Branch' } ); |
2960 |
my $library_2 = $builder->build( { source => 'Branch' } ); |
Lines 2981-2995
subtest 'Cancel transfers on lost items' => sub {
Link Here
|
2981 |
my $do_transfer = 1; |
2981 |
my $do_transfer = 1; |
2982 |
my ( $res, $rr ) = AddReturn( $item->barcode, $library_1->{branchcode} ); |
2982 |
my ( $res, $rr ) = AddReturn( $item->barcode, $library_1->{branchcode} ); |
2983 |
ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id ); |
2983 |
ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id ); |
2984 |
C4::Circulation::transferbook( $library_2->{branchcode}, $item->barcode ); |
2984 |
C4::Circulation::transferbook({ |
|
|
2985 |
from_branch => $library_1->{branchcode}, |
2986 |
to_branch => $library_2->{branchcode}, |
2987 |
barcode => $item->barcode, |
2988 |
}); |
2985 |
my $hold = Koha::Holds->find( $reserve_id ); |
2989 |
my $hold = Koha::Holds->find( $reserve_id ); |
2986 |
is( $hold->found, 'T', 'Hold is in transit' ); |
2990 |
is( $hold->found, 'T', 'Hold is in transit' ); |
2987 |
|
2991 |
|
2988 |
#Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost |
2992 |
#Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost |
2989 |
my ($datesent,$frombranch,$tobranch) = GetTransfers($item->itemnumber); |
2993 |
my ($datesent,$frombranch,$tobranch) = GetTransfers($item->itemnumber); |
2990 |
is( $tobranch, $library_2->{branchcode}, 'The transfer record exists in the branchtransfers table'); |
2994 |
is( $frombranch, $library_1->{branchcode}, 'The transfer is generated from the correct library'); |
|
|
2995 |
is( $tobranch, $library_2->{branchcode}, 'The transfer is generated to the correct library'); |
2991 |
my $itemcheck = Koha::Items->find($item->itemnumber); |
2996 |
my $itemcheck = Koha::Items->find($item->itemnumber); |
2992 |
is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Items holding branch is the transfers origin branch before it is marked as lost' ); |
2997 |
is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Items holding branch is the transfers origination branch before it is marked as lost' ); |
2993 |
|
2998 |
|
2994 |
#Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch |
2999 |
#Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch |
2995 |
ModItem( { itemlost => 1 }, $item->biblionumber, $item->itemnumber ); |
3000 |
ModItem( { itemlost => 1 }, $item->biblionumber, $item->itemnumber ); |
Lines 2998-3003
subtest 'Cancel transfers on lost items' => sub {
Link Here
|
2998 |
is( $tobranch, undef, 'The transfer on the lost item has been deleted as the LostItemCancelOutstandingTransfer is enabled'); |
3003 |
is( $tobranch, undef, 'The transfer on the lost item has been deleted as the LostItemCancelOutstandingTransfer is enabled'); |
2999 |
$itemcheck = Koha::Items->find($item->itemnumber); |
3004 |
$itemcheck = Koha::Items->find($item->itemnumber); |
3000 |
is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Lost item with cancelled hold has holding branch equallying the transfers source branch' ); |
3005 |
is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Lost item with cancelled hold has holding branch equallying the transfers source branch' ); |
|
|
3006 |
|
3007 |
}; |
3008 |
|
3009 |
subtest 'transferbook test' => sub { |
3010 |
plan tests => 5; |
3011 |
|
3012 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
3013 |
my $item = $builder->build_sample_item(); |
3014 |
ok( $item->holdingbranch ne $library->branchcode && $item->homebranch ne $library->branchcode, "Item is not held or owned by library"); |
3015 |
C4::Circulation::transferbook({ |
3016 |
from_branch => $library->branchcode, |
3017 |
to_branch => $item->homebranch, |
3018 |
barcode => $item->barcode, |
3019 |
}); |
3020 |
my ($datesent,$from_branch,$to_branch) = GetTransfers($item->itemnumber); |
3021 |
is( $from_branch, $library->branchcode, 'The transfer is initiated from the specified branch, not the items home or holdingbranch'); |
3022 |
is( $to_branch, $item->homebranch, 'The transfer is initiated to the specified branch'); |
3023 |
C4::Circulation::transferbook({ |
3024 |
from_branch => $item->homebranch, |
3025 |
to_branch => $library->branchcode, |
3026 |
barcode => $item->barcode, |
3027 |
}); |
3028 |
($datesent,$from_branch,$to_branch) = GetTransfers($item->itemnumber); |
3029 |
is( $from_branch, $item->homebranch, 'The transfer is initiated from the specified branch'); |
3030 |
is( $to_branch, $library->branchcode, 'The transfer is initiated to the specified branch'); |
3031 |
|
3001 |
}; |
3032 |
}; |
3002 |
|
3033 |
|
3003 |
subtest 'CanBookBeIssued | is_overdue' => sub { |
3034 |
subtest 'CanBookBeIssued | is_overdue' => sub { |