Bugzilla – Attachment 77487 Details for
Bug 21159
Update item shelving location (952$c) on checkout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21159 - Implementing 2 sysprefs to enable blanking location
Bug-21159---Implementing-2-sysprefs-to-enable-blan.patch (text/plain), 11.64 KB, created by
Alex Buckley
on 2018-08-06 03:25:06 UTC
(
hide
)
Description:
Bug 21159 - Implementing 2 sysprefs to enable blanking location
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2018-08-06 03:25:06 UTC
Size:
11.64 KB
patch
obsolete
>From 5d201071b666cffaf5f0b62bf62b151b9298fe05 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Mon, 6 Aug 2018 14:56:47 +1200 >Subject: [PATCH] Bug 21159 - Implementing 2 sysprefs to enable blanking > location > >This patch introduces two new system preferences: BlankingShelvingLocationOnIssue and BlankingShelvingLocationOnReturn. By default both are off. > >If BlankingShelvingLocationOnIssue is enabled then when an item is issued it's shelving location 952$c field will be set to '' in C4::Items->BlankShelvingLocation() > >If BlankingShelvingLocationOnReturn is enabled then when an item is returned it's shelving location field will be set to '' in C4::Items->BlankShelvingLocation(). > >t/db_dependent/Circulation/issue.t contains tests for BlankShelvingLocationOnIssue > >t/db_dependen/Circulation/Returns.t contains tests for BlankShelvingLocationOnReturn > >Test plan: >1. Create a new biblio and associated item and set the value of the shelving location for the item to 'CART' >2. Checkout the item to a user and notice that the status does not change >3. Apply patch, and run ./updatedatabase.pl inside the koha shell >4. Now return the checked out item (when you updated the database you added two new sysprefs: BlankShelvingLocationOnIssue and BlankShelvingLocationOnReturn both of which are off by default) >5. Notice the shelving location has not changed, showing with the BlankShelvingLocationOnReturn syspref not enabled the shelving location is not changed upon return >6. Check the item out again and notice the shelving location is not changed, showing that when the BlankShelvingLocationOnIssue is not enabled the shelving location is not changed upon issue. >7. Enable both aforementioned sysprefs in the Administration->Global system preferences->Circulation interface >8. Return the item and notice the Shelving location has changed from 'Cart' to no value, showing when the BlankShelvingLocationOnReturn syspref is enabled it blanks the shelving location value on the return of the item >9. Edit the item changing the shelving location back to 'Shelving Trolley'(CART) >10. Check out the item and notice the shelving location is changed to no value, showing when the BlankShelvingLocationOnIssue syspref is enabled it blanks the shelving location on the issue of an item. >11. Run t/db_dependent/Circulation/Returns.t >12. Run t/db_dependent/Circulation/issue.t > >Sponsored-By: Toi Ohomai Institute of Technology, New Zealand >--- > C4/Circulation.pm | 10 ++- > C4/Items.pm | 20 +++++ > .../blank_shelving_locations_on_circulation.sql | 3 + > .../en/modules/admin/preferences/circulation.pref | 12 +++ > t/db_dependent/Circulation/Returns.t | 85 +++++++++++++++++++++- > t/db_dependent/Circulation/issue.t | 24 ++++++ > 6 files changed, 152 insertions(+), 2 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/blank_shelving_locations_on_circulation.sql > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 3e72f20..7b8a113 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1398,6 +1398,11 @@ sub AddIssue { > } > } > >+ if ( C4::Circulation->preferences('BlankShelvingLocationOnIssue') ) { >+ # BlankShelvingLocationInIssue is on, set the value of Shelving location items.location to blank >+ BlankShelvingLocation( $item->{'itemnumber'}); >+ } >+ > if ( C4::Context->preference('ReturnToShelvingCart') ) { > # ReturnToShelvingCart is on, anything issued should be taken off the cart. > CartToShelf( $item->{'itemnumber'} ); >@@ -1859,7 +1864,10 @@ sub AddReturn { > } > } > >- if ( $item->{'location'} eq 'PROC' ) { >+ if (C4::Context->preference('BlankShelvingLocationOnReturn')) { >+ # BlankShelvingLocationInReturn is on, set the value of Shelving location items.location to blank >+ BlankShelvingLocation( $item->{'itemnumber'}); >+ } elsif ( $item->{'location'} eq 'PROC' ) { > if ( C4::Context->preference("InProcessingToShelvingCart") ) { > $item->{'location'} = 'CART'; > } >diff --git a/C4/Items.pm b/C4/Items.pm >index e7279ff..7749516 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -220,6 +220,26 @@ sub ShelfToCart { > ModItem($item, undef, $itemnumber); > } > >+=head BlankShelvingLocation >+ BlankShelvingLocation($itemnumber); >+ >+Set the value of the shelving location to blank when an item is issued or returned. >+ >+This is called by C4::Circulation->AddIssue if the BlankShelvingLocationOnIssue syspref is enabled >+ >+=cut >+ >+sub BlankShelvingLocation { >+ my ($itemnumber) = @_; >+ unless ($itemnumber ) { >+ croak "Failed BlankShelvingLocation() - no itemnumber supplied"; >+ } >+ >+ my $item = GetItem($itemnumber); >+ $item->{'location'} =''; >+ ModItem($item, undef, $itemnumber); >+} >+ > =head2 AddItemFromMarc > > my ($biblionumber, $biblioitemnumber, $itemnumber) >diff --git a/installer/data/mysql/atomicupdate/blank_shelving_locations_on_circulation.sql b/installer/data/mysql/atomicupdate/blank_shelving_locations_on_circulation.sql >new file mode 100644 >index 0000000..0e73e80 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/blank_shelving_locations_on_circulation.sql >@@ -0,0 +1,3 @@ >+INSERT INTO systempreferences (variable, value, explanation, type) VALUES ('BlankShelvingLocationOnIssue', 0, 'Blank the 952$c (Shelving Location) field of item when it is issued', 'YesNo'); >+INSERT INTO systempreferences (variable, value, explanation, type) VALUES ('BlankShelvingLocationOnReturn', 0, 'Blank the 952$c (Shelving Location) field of item when it is returned', 'YesNo'); >+ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >index 88fd35a..18382ec 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >@@ -220,6 +220,18 @@ Circulation: > no: "Don't move" > - all items to the location CART when they are checked in. > - >+ - pref: BlankShelvingLocationOnIssue >+ choices: >+ yes: Blank >+ no: "Don't blank" >+ - Blank the 952$c (Shelving Location) field of item when it is issued. >+ - >+ - pref: BlankShelvingLocationOnReturn >+ choices: >+ yes: Blank >+ no: "Don't blank" >+ - Blank the 952$c (Shelving Location) field of item when it is returned >+ - > - pref: AutomaticItemReturn > choices: > yes: Do >diff --git a/t/db_dependent/Circulation/Returns.t b/t/db_dependent/Circulation/Returns.t >index a8e4dda..fc549ed 100644 >--- a/t/db_dependent/Circulation/Returns.t >+++ b/t/db_dependent/Circulation/Returns.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 6; > use Test::MockModule; > use Test::Warn; > >@@ -101,6 +101,89 @@ subtest "InProcessingToShelvingCart tests" => sub { > "InProcessingToShelvingCart functions as intended" ); > }; > >+subtest "BlankShelvingLocationOnReturn tests" => sub { >+ >+ plan tests => 2; >+ >+ $branch = $builder->build({ source => 'Branch' })->{ branchcode }; >+ my $permanent_location = 'TEST'; >+ my $location = 'PROC'; >+ >+ # Create a biblio record with biblio-level itemtype >+ my $record = MARC::Record->new(); >+ my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' ); >+ my $built_item = $builder->build({ >+ source => 'Item', >+ value => { >+ biblionumber => $biblionumber, >+ homebranch => $branch, >+ holdingbranch => $branch, >+ location => $location, >+ permanent_location => $permanent_location >+ } >+ }); >+ my $barcode = $built_item->{ barcode }; >+ my $itemnumber = $built_item->{ itemnumber }; >+ my $item; >+ >+ t::lib::Mocks::mock_preference( "BlankShelvingLocationOnReturn", 1 ); >+ AddReturn( $barcode, $branch ); >+ $item = GetItem( $itemnumber ); >+ is( $item->{location}, '', >+ "BlankShelvingLocationOnReturn functions as intended" ); >+ >+ $item->{location} = $location; >+ ModItem( $item, undef, $itemnumber ); >+ >+ t::lib::Mocks::mock_preference( "BlankShelvingLocationOnReturn", 0 ); >+ AddReturn( $barcode, $branch ); >+ $item = GetItem( $itemnumber ); >+ is( $item->{location}, $permanent_location, >+ "BlankShelvingLocationOnReturn functions as intended" ); >+}; >+ >+subtest "BlankShelvingLocationOnIssue tests" => sub { >+ >+ plan tests => 2; >+ >+ $branch = $builder->build({ source => 'Branch' })->{ branchcode }; >+ my $permanent_location = 'TEST'; >+ my $location = 'PROC'; >+ >+ # Create a biblio record with biblio-level itemtype >+ my $record = MARC::Record->new(); >+ my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' ); >+ my $built_item = $builder->build({ >+ source => 'Item', >+ value => { >+ biblionumber => $biblionumber, >+ homebranch => $branch, >+ holdingbranch => $branch, >+ location => $location, >+ permanent_location => $permanent_location >+ } >+ }); >+ my $barcode = $built_item->{ barcode }; >+ my $itemnumber = $built_item->{ itemnumber }; >+ my $item; >+ >+ t::lib::Mocks::mock_preference( "BlankShelvingLocationOnIssue", 1 ); >+ my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; >+ $item = GetItem( $itemnumber ); >+ AddIssue( $borrower, $item->{barcode}); >+ $item = GetItem( $itemnumber ); >+ is( $item->{location}, '', >+ "BlankShelvingLocationOnIssue functions as intended" ); >+ >+ $item->{location} = $location; >+ ModItem( $item, undef, $itemnumber ); >+ >+ t::lib::Mocks::mock_preference( "BlankShelvingLocationOnReturn", 0 ); >+ AddIssue( $borrower, $item->{barcode} ); >+ $item = GetItem( $itemnumber ); >+ is( $item->{location}, $permanent_location, >+ "BlankShelvingLocationOnReturn functions as intended" ); >+}; > > subtest "AddReturn logging on statistics table (item-level_itypes=1)" => sub { > >diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t >index 68160dd..5d9d2ad 100644 >--- a/t/db_dependent/Circulation/issue.t >+++ b/t/db_dependent/Circulation/issue.t >@@ -371,6 +371,30 @@ AddReturn( 'barcode_3', $branchcode_1 ); > $item = GetItem( $itemnumber ); > ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} ); > >+my $itemnumber2; >+($biblionumber, $biblioitemnumber, $itemnumber2) = C4::Items::AddItem( >+ { >+ barcode => 'barcode_4', >+ itemcallnumber => 'callnumber4', >+ homebranch => $branchcode_1, >+ holdingbranch => $branchcode_1, >+ location => 'CART', >+ itype => $itemtype >+ }, >+ $biblionumber >+); >+ >+#Test BlankShelvingLocationOnIssue >+t::lib::Mocks::Mock_preference('BlankShelvingLocationOnIssue', 0); >+AddIssue($borrower_1, 'barcode_4', $daysago10, 0, $today, 0); >+$item2 = GetItem($itemnumber2); >+ok($item2->{location} eq 'CART', q{BlankShelvingLocationOnIssue does not update shelving location value from 'CART' to '' when not enabled} ); >+ >+t::lib::Mocks::mock_preference('BlankShelvingLocationOnIssue', 1); >+AddIssue($borrower_1, 'barcode_4', $daysago10, 0, $today, ''); >+$item2 = GetItem($itemnumber2); >+ok($item2->{location} eq '', q{BlankShelvingLocationOnIssue updates shelving location value from 'CART' to '' when enabled} ); >+ > # Bug 14640 - Cancel the hold on checking out if asked > my $reserve_id = AddReserve($branchcode_1, $borrower_id1, $biblionumber, > undef, 1, undef, undef, "a note", "a title", undef, ''); >-- >2.7.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 21159
:
77487
|
77549
|
77594
|
77775
|
77859
|
77869
|
77870
|
77871
|
80892
|
80893
|
80894
|
80895
|
87037
|
87038
|
87041
|
87693
|
87694
|
87695
|
139097
|
139098
|
139099
|
139103
|
139104
|
139105
|
139106
|
139107
|
139108
|
139109
|
139220
|
146602
|
146603
|
146604
|
146605
|
146606
|
146607
|
146608
|
154147
|
154148
|
154149
|
154150
|
154151
|
154152
|
155284
|
155285
|
155771
|
155772
|
155773
|
155774
|
158146
|
158147
|
158149
|
158150
|
158169
|
158170
|
158171
|
158172
|
158173
|
158521
|
158522