Bugzilla – Attachment 81782 Details for
Bug 21732
If an item is marked as lost, any outstanding transfers upon it should be cancelled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21732: (follow-up) Added tests to t/db_dependent/Circulation.t
Bug-21732-follow-up-Added-tests-to-tdbdependentCir.patch (text/plain), 5.98 KB, created by
Alex Buckley
on 2018-10-31 23:46:17 UTC
(
hide
)
Description:
Bug 21732: (follow-up) Added tests to t/db_dependent/Circulation.t
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2018-10-31 23:46:17 UTC
Size:
5.98 KB
patch
obsolete
>From 0282e531ddaa3dfd942ed308b088435e12bc5680 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Tue, 30 Oct 2018 19:26:02 +0000 >Subject: [PATCH] Bug 21732: (follow-up) Added tests to > t/db_dependent/Circulation.t > >Tests check: >* If transfer is deleted when item is marked as lost with the >LostItemCancelOutstandingTransfer enabled and disabled > >* If the items holdingbranch changes when item with transfers on it is >marked as lost. > >Also added call to ModItem() when transfers are deleted (if the >LostItemCancelOutstandingTransfers syspref is enabled and a transfer did >exist on the item) to set the items holdingbranch to the transfer source >branch so the 'from' library is responsible for the lost item. > >Sponsored-By: Brimbank Library, Australia >--- > C4/Circulation.pm | 6 ++++- > t/db_dependent/Circulation.t | 64 +++++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 68 insertions(+), 2 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 07ec1d4..4fca94a 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3702,8 +3702,12 @@ sub LostItem{ > MarkIssueReturned($borrowernumber,$itemnumber,undef,undef,$patron->privacy) if $mark_returned; > } > >+ #If LostItemCancelOutstandingTransfers syspref is enabled then when item is marked lost delete its transfers and set items holdingbranch to the transfer source branch (frombranch) > if ( C4::Context->preference('LostItemCancelOutstandingTransfers') ) { >- DeleteTransfer($itemnumber); >+ if (my ( $datesent,$frombranch,$tobranch ) = GetTransfers($itemnumber)) { >+ ModItem({holdingbranch => $frombranch}, undef, $itemnumber); >+ } >+ my $transferdeleted = DeleteTransfer($itemnumber); > } > > } >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 2d82c9f..68bac03 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 119; >+use Test::More tests => 120; > > use Data::Dumper; > use DateTime; >@@ -2279,6 +2279,7 @@ subtest '_FixAccountForLostAndReturned' => sub { > 'The patron balance is the difference between the PF and the credit' > ); > }; >+ > }; > > subtest '_FixOverduesOnReturn' => sub { >@@ -2406,6 +2407,67 @@ subtest 'Set waiting flag' => sub { > is( $status, 'Waiting', 'Now the hold is waiting'); > }; > >+subtest 'Cancel transfers on lost items' => sub { >+ plan tests => 5; >+ >+ my $library_1 = $builder->build( { source => 'Branch' } ); >+ my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } ); >+ my $library_2 = $builder->build( { source => 'Branch' } ); >+ my $patron_2 = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } ); >+ my $biblio = $builder->build( { source => 'Biblio' } ); >+ my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } ); >+ my $item = $builder->build( >+ { >+ source => 'Item', >+ value => { >+ homebranch => $library_1->{branchcode}, >+ holdingbranch => $library_1->{branchcode}, >+ notforloan => 0, >+ itemlost => 0, >+ withdrawn => 0, >+ biblionumber => $biblioitem->{biblionumber}, >+ } >+ } >+ ); >+ >+ set_userenv( $library_2 ); >+ my $reserve_id = AddReserve( >+ $library_2->{branchcode}, $patron_2->{borrowernumber}, $biblioitem->{biblionumber}, >+ '', 1, undef, undef, '', undef, $item->{itemnumber}, >+ ); >+ >+ #Return book and add transfer >+ set_userenv( $library_1 ); >+ my $do_transfer = 1; >+ my ( $res, $rr ) = AddReturn( $item->{barcode}, $library_1->{branchcode} ); >+ ModReserveAffect( $item->{itemnumber}, undef, $do_transfer, $reserve_id ); >+ C4::Circulation::transferbook( $library_2->{branchcode}, $item->{barcode} ); >+ my $hold = Koha::Holds->find( $reserve_id ); >+ is( $hold->found, 'T', 'Hold is in transit' ); >+ >+ #With the LostItemCancelOutstandingTransfers syspref disabled simulate item being marked as lost and confirm that the item transfer still exists and the items holding branch is the transfer destination branch >+ t::lib::Mocks::mock_preference('LostItemCancelOutstandingTransfers','0'); >+ ModItem( { itemlost => 1 }, $biblioitem->{biblionumber}, $item->{itemnumber} ); >+ LostItem( $item->{itemnumber}, 'test', 1 ); >+ my ($datesent,$frombranch,$tobranch) = GetTransfers($item->{itemnumber}); >+ is( $tobranch, $library_2->{branchcode}, 'The transfer on the lost item still exists as LostItemCancelOutstandingTransfer is disabled'); >+ my $itemcheck = GetItem($item->{itemnumber}); >+ is( $itemcheck->{holdingbranch}, $library_2->{branchcode}, 'Lost item with cancelled hold has holding branch equalling the transfers destination branch' ); >+ >+ #Reset itemlost field to 0 >+ t::lib::Mocks::mock_preference('LostItemCancelOutstandingTransfers','1'); >+ ModItem( { itemlost => 0 }, $biblio->{biblionumber}, $item->{itemnumber} ); >+ >+ #With the LostItemCancelOutstandingTransfers syspref enabled simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch >+ ModItem( { itemlost => 1 }, $biblio->{biblionumber}, $item->{itemnumber} ); >+ LostItem( $item->{itemnumber}, 'test', 1 ); >+ ($datesent,$frombranch,$tobranch) = GetTransfers($item->{itemnumber}); >+ is( $tobranch, undef, 'The transfer on the lost item has been deleted as the LostItemCancelOutstandingTransfer is enabled'); >+ $itemcheck = GetItem($item->{itemnumber}); >+ is( $itemcheck->{holdingbranch}, $library_1->{branchcode}, 'Lost item with cancelled hold has holding branch equallying the transfers source branch' ); >+ >+}; >+ > subtest 'CanBookBeIssued | is_overdue' => sub { > plan tests => 3; > >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21732
:
81695
|
81696
|
81701
|
81702
|
81703
|
81704
| 81782