|
Lines 2629-2676
subtest 'Cancel transfers on lost items' => sub {
Link Here
|
| 2629 |
my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
2629 |
my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
| 2630 |
my $library_2 = $builder->build( { source => 'Branch' } ); |
2630 |
my $library_2 = $builder->build( { source => 'Branch' } ); |
| 2631 |
my $patron_2 = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
2631 |
my $patron_2 = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
| 2632 |
my $biblio = $builder->build( { source => 'Biblio' } ); |
2632 |
my $biblio = $builder->build_sample_biblio({branchcode => $library->{branchcode}}); |
| 2633 |
my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } ); |
2633 |
my $item = $builder->build_sample_item( |
| 2634 |
my $item = $builder->build( |
|
|
| 2635 |
{ |
2634 |
{ |
| 2636 |
source => 'Item', |
2635 |
class => 'Koha::Items', |
| 2637 |
value => { |
2636 |
value => { |
| 2638 |
homebranch => $library_1->{branchcode}, |
2637 |
biblionumber => $biblio->biblionumber, |
| 2639 |
holdingbranch => $library_1->{branchcode}, |
2638 |
library => $library_1->{branchcode}, |
| 2640 |
notforloan => 0, |
|
|
| 2641 |
itemlost => 0, |
| 2642 |
withdrawn => 0, |
| 2643 |
biblionumber => $biblioitem->{biblionumber}, |
| 2644 |
} |
2639 |
} |
| 2645 |
} |
2640 |
} |
| 2646 |
); |
2641 |
); |
| 2647 |
|
2642 |
|
| 2648 |
set_userenv( $library_2 ); |
2643 |
set_userenv( $library_2 ); |
| 2649 |
my $reserve_id = AddReserve( |
2644 |
my $reserve_id = AddReserve( |
| 2650 |
$library_2->{branchcode}, $patron_2->{borrowernumber}, $biblioitem->{biblionumber}, '', 1, undef, undef, '', undef, $item->{itemnumber}, |
2645 |
$library_2->{branchcode}, $patron_2->{borrowernumber}, $item->biblionumber, '', 1, undef, undef, '', undef, $item->itemnumber, |
| 2651 |
); |
2646 |
); |
| 2652 |
|
2647 |
|
| 2653 |
#Return book and add transfer |
2648 |
#Return book and add transfer |
| 2654 |
set_userenv( $library_1 ); |
2649 |
set_userenv( $library_1 ); |
| 2655 |
my $do_transfer = 1; |
2650 |
my $do_transfer = 1; |
| 2656 |
my ( $res, $rr ) = AddReturn( $item->{barcode}, $library_1->{branchcode} ); |
2651 |
my ( $res, $rr ) = AddReturn( $item->barcode, $library_1->{branchcode} ); |
| 2657 |
ModReserveAffect( $item->{itemnumber}, undef, $do_transfer, $reserve_id ); |
2652 |
ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id ); |
| 2658 |
C4::Circulation::transferbook( $library_2->{branchcode}, $item->{barcode} ); |
2653 |
C4::Circulation::transferbook( $library_2->{branchcode}, $item->barcode ); |
| 2659 |
my $hold = Koha::Holds->find( $reserve_id ); |
2654 |
my $hold = Koha::Holds->find( $reserve_id ); |
| 2660 |
is( $hold->found, 'T', 'Hold is in transit' ); |
2655 |
is( $hold->found, 'T', 'Hold is in transit' ); |
| 2661 |
|
2656 |
|
| 2662 |
#Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost |
2657 |
#Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost |
| 2663 |
my ($datesent,$frombranch,$tobranch) = GetTransfers($item->{itemnumber}); |
2658 |
my ($datesent,$frombranch,$tobranch) = GetTransfers($item->itemnumber); |
| 2664 |
is( $tobranch, $library_2->{branchcode}, 'The transfer record exists in the branchtransfers table'); |
2659 |
is( $tobranch, $library_2->{branchcode}, 'The transfer record exists in the branchtransfers table'); |
| 2665 |
my $itemcheck = Koha::Items->find($item->{itemnumber}); |
2660 |
my $itemcheck = Koha::Items->find($item->itemnumber); |
| 2666 |
is( $itemcheck->holdingbranch, $library_2->{branchcode}, 'Items holding branch is the transfers destination branch before it is marked as lost' ); |
2661 |
is( $itemcheck->holdingbranch, $library_2->{branchcode}, 'Items holding branch is the transfers destination branch before it is marked as lost' ); |
| 2667 |
|
2662 |
|
| 2668 |
#Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch |
2663 |
#Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch |
| 2669 |
ModItem( { itemlost => 1 }, $biblio->{biblionumber}, $item->{itemnumber} ); |
2664 |
ModItem( { itemlost => 1 }, $item->biblionumber, $item->itemnumber ); |
| 2670 |
LostItem( $item->{itemnumber}, 'test', 1 ); |
2665 |
LostItem( $item->itemnumber, 'test', 1 ); |
| 2671 |
($datesent,$frombranch,$tobranch) = GetTransfers($item->{itemnumber}); |
2666 |
($datesent,$frombranch,$tobranch) = GetTransfers($item->itemnumber); |
| 2672 |
is( $tobranch, undef, 'The transfer on the lost item has been deleted as the LostItemCancelOutstandingTransfer is enabled'); |
2667 |
is( $tobranch, undef, 'The transfer on the lost item has been deleted as the LostItemCancelOutstandingTransfer is enabled'); |
| 2673 |
$itemcheck = Koha::Items->find($item->{itemnumber}); |
2668 |
$itemcheck = Koha::Items->find($item->itemnumber); |
| 2674 |
is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Lost item with cancelled hold has holding branch equallying the transfers source branch' ); |
2669 |
is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Lost item with cancelled hold has holding branch equallying the transfers source branch' ); |
| 2675 |
}; |
2670 |
}; |
| 2676 |
|
2671 |
|
| 2677 |
- |
|
|