From a97bc3863c821dcbc019f88dfcc826610c97ce64 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 19 Nov 2014 07:24:20 -0500 Subject: [PATCH] [PASSED QA] Bug 13297 - Shelving location PROC does not work according to manual According to the manual, "Items will stay in the PROC location until they are checked in". This is not the actual behavior. Right now items will only change from PROC to CART, and that is only if InProcessingToShelvingCart is enabled. Some libraries want to use the PROC to permanent location feature, without using the CART. Additionally, the location is only removed if using returns.pl, but that is not what the manual says either. What if the library uses SIP2 devices for handling returns? This should be taken into account. Test Plan: 1) Apply this patch 2) Set an item's current location to PROC, and it's permananet location to a different location. 3) Check the item in any way you wish 4) Note the shelving location is updated to the permanent location 5) prove t/db_dependent/Circulation/Returns.t Signed-off-by: Owen Leonard I tested this with items which had items.location set to 'PROC' and items.permanent_location set to NULL, '', and a real value, and it worked correctly in all cases. I tested with check-ins from returns.pl and from the table of checkouts in circulation and the PROC location was correctly removed in both cases. Signed-off-by: Katrin Fischer Works as described, passes tests and QA script. --- C4/Circulation.pm | 12 +++++++++ circ/returns.pl | 8 ------ t/db_dependent/Circulation/Returns.t | 50 ++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 t/db_dependent/Circulation/Returns.t diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 062b165..f24f2f7 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1774,6 +1774,18 @@ sub AddReturn { } my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed"; + + if ( $item->{'location'} eq 'PROC' ) { + if ( C4::Context->preference("InProcessingToShelvingCart") ) { + $item->{'location'} = 'CART'; + } + else { + $item->{location} = $item->{permanent_location}; + } + + ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} ); + } + # full item data, but no borrowernumber or checkout info (no issue) # we know GetItem should work because GetItemnumberFromBarcode worked my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch"; diff --git a/circ/returns.pl b/circ/returns.pl index 14997a1..adc2f1e 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -237,14 +237,6 @@ if ($barcode) { $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter'); $itemnumber = GetItemnumberFromBarcode($barcode); - if ( C4::Context->preference("InProcessingToShelvingCart") ) { - my $item = GetItem( $itemnumber ); - if ( $item->{'location'} eq 'PROC' ) { - $item->{'location'} = 'CART'; - ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} ); - } - } - # # save the return # diff --git a/t/db_dependent/Circulation/Returns.t b/t/db_dependent/Circulation/Returns.t new file mode 100644 index 0000000..e8545d1 --- /dev/null +++ b/t/db_dependent/Circulation/Returns.t @@ -0,0 +1,50 @@ +use Modern::Perl; +use Test::More tests => 2; + +use C4::Biblio; +use C4::Circulation; +use C4::Items; +use C4::Members; +use Koha::DateUtils; + +use MARC::Record; + +*C4::Context::userenv = \&Mock_userenv; + +my $dbh = C4::Context->dbh; +$dbh->{AutoCommit} = 0; +$dbh->{RaiseError} = 1; + +my $record = MARC::Record->new(); +my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' ); + +my ( undef, undef, $itemnumber ) = AddItem( + { + homebranch => 'CPL', + holdingbranch => 'CPL', + barcode => 'i_dont_exist', + location => 'PROC', + permanent_location => 'TEST' + }, + $biblionumber +); + +my $item; + +C4::Context->set_preference( "InProcessingToShelvingCart", 1 ); +AddReturn( 'i_dont_exist', 'CPL' ); +$item = GetItem($itemnumber); +is( $item->{location}, 'CART', "InProcessingToShelvingCart functions as intended" ); + +$item->{location} = 'PROC'; +ModItem( $item, undef, $itemnumber ); + +C4::Context->set_preference( "InProcessingToShelvingCart", 0 ); +AddReturn( 'i_dont_exist', 'CPL' ); +$item = GetItem($itemnumber); +is( $item->{location}, 'TEST', "InProcessingToShelvingCart functions as intended" ); + +# C4::Context->userenv +sub Mock_userenv { + return { branch => 'CPL' }; +} -- 1.9.1