Bugzilla – Attachment 139105 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: Update item location on checkout
Bug-21159-Update-item-location-on-checkout.patch (text/plain), 8.20 KB, created by
Alex Buckley
on 2022-08-15 02:01:19 UTC
(
hide
)
Description:
Bug 21159: Update item location on checkout
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2022-08-15 02:01:19 UTC
Size:
8.20 KB
patch
obsolete
>From dff3cdca1cb9d14b3cec8ea26cd5584204079eb2 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Wed, 10 Aug 2022 00:54:20 +0000 >Subject: [PATCH] Bug 21159: Update item location on checkout > >This patchset shifts the logic for changing the item location on checkin >(controlled by the UpdateItemLocationOnCheckin system preference) to a >new subroutine in Koha/Items.pm > >That subroutine logic is shared with the UpdateItemLocationOnCheckout >system preference. > >Test plan: >1. Apply patches, update databases and restart services > >2. Set the following system preferences: >- UpdateItemLocationOnCheckin: >FIC: PROC > >- UpdateItemLocationOnCheckout: >PROC: FIC > >3. Checkout an an item with items.location = 'PROC'. Observe it's >location is changed to 'FIC' > >4. Return the item. Observe it's location is changed to 'PROC' > >5. Change UpdateItemLocationOnCheckout to: >PROC: _BLANK_ > >6. Issue the item with items.location = 'PROC' and confirm it's location >is blanked on checkout > >7. Issue and return an item with a different location e.g. 'CART'. >Observe the location does not change on issue or return. > >Sponsored-by: Toi Ohomai Institute of Technology, New Zealand >--- > C4/Circulation.pm | 35 +++++++-------------------------- > Koha/Item.pm | 47 +++++++++++++++++++++++++++++++++++++++++++++ > circ/circulation.pl | 3 ++- > 3 files changed, 56 insertions(+), 29 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 9cb56f79d32..1c25a253477 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1498,7 +1498,7 @@ sub AddIssue { > my $dbh = C4::Context->dbh; > my $barcodecheck = CheckValidBarcode($barcode); > >- my $issue; >+ my ($issue, $messages); > > if ( $datedue && ref $datedue ne 'DateTime' ) { > $datedue = dt_from_string($datedue); >@@ -1675,6 +1675,9 @@ sub AddIssue { > CartToShelf( $item_object->itemnumber ); > } > >+ # Update item location >+ $messages = $item_object->update_item_location( 'checkout' ); >+ > if ( C4::Context->preference('UpdateTotalIssuesOnCirc') ) { > UpdateTotalIssues( $item_object->biblionumber, 1, undef, { skip_holds_queue => 1 } ); > } >@@ -1787,7 +1790,7 @@ sub AddIssue { > ) if C4::Context->preference('RealTimeHoldsQueue'); > } > } >- return $issue; >+ return ($issue, $messages); > } > > =head2 GetLoanLength >@@ -2104,32 +2107,8 @@ sub AddReturn { > my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not > my $patron_unblessed = $patron ? $patron->unblessed : {}; > >- my $update_loc_rules = Koha::Config::SysPrefs->find('UpdateItemLocationOnCheckin')->get_yaml_pref_hash(); >- map { $update_loc_rules->{$_} = $update_loc_rules->{$_}[0] } keys %$update_loc_rules; #We can only move to one location so we flatten the arrays >- if ($update_loc_rules) { >- if (defined $update_loc_rules->{_ALL_}) { >- if ($update_loc_rules->{_ALL_} eq '_PERM_') { $update_loc_rules->{_ALL_} = $item->permanent_location; } >- if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } >- if ( >- ( defined $item->location && $item->location ne $update_loc_rules->{_ALL_}) || >- (!defined $item->location && $update_loc_rules->{_ALL_} ne "") >- ) { >- $messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} }; >- $item->location($update_loc_rules->{_ALL_})->store({ log_action => 0, skip_record_index => 1, skip_holds_queue => 1}); >- } >- } >- else { >- foreach my $key ( keys %$update_loc_rules ) { >- if ( $update_loc_rules->{$key} eq '_PERM_' ) { $update_loc_rules->{$key} = $item->permanent_location; } >- if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} >- if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) { >- $messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} }; >- $item->location($update_loc_rules->{$key})->store({ log_action => 0, skip_record_index => 1, skip_holds_queue => 1}); >- last; >- } >- } >- } >- } >+ # Update item location >+ $messages = $item->update_item_location( 'checkin' ); > > my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin'); > if ($yaml) { >diff --git a/Koha/Item.pm b/Koha/Item.pm >index b3ac3623347..423bc40ce4c 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -1912,6 +1912,53 @@ sub is_notforloan { > return $is_notforloan; > } > >+=head3 update_item_location >+ >+ my $update_location = $item->update_item_location( $action ); >+ >+Update the item location on checkin or checkout. >+ >+=cut >+ >+sub update_item_location { >+ my ( $self, $action ) = @_; >+ >+ my ($update_loc_rules, $messages); >+ if ( $action eq 'checkin' ) { >+ $update_loc_rules = Koha::Config::SysPrefs->find('UpdateItemLocationOnCheckin')->get_yaml_pref_hash(); >+ } else { >+ $update_loc_rules = Koha::Config::SysPrefs->find('UpdateItemLocationOnCheckout')->get_yaml_pref_hash(); >+ } >+ >+ map { $update_loc_rules->{$_} = $update_loc_rules->{$_}[0] } keys %$update_loc_rules; #We can only move to one location so we flatten the arrays >+ if ($update_loc_rules) { >+ if (defined $update_loc_rules->{_ALL_}) { >+ if ($update_loc_rules->{_ALL_} eq '_PERM_') { $update_loc_rules->{_ALL_} = $self->permanent_location; } >+ if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } >+ if ( >+ ( defined $self->location && $self->location ne $update_loc_rules->{_ALL_}) || >+ (!defined $self->location && $update_loc_rules->{_ALL_} ne "") >+ ) { >+ $messages->{'ItemLocationUpdated'} = { from => $self->location, to => $update_loc_rules->{_ALL_} }; >+ $self->location($update_loc_rules->{_ALL_})->store({ log_action => 0, skip_record_index => 1, skip_holds_queue => 1}); >+ } >+ } >+ else { >+ foreach my $key ( keys %$update_loc_rules ) { >+ if ( $update_loc_rules->{$key} eq '_PERM_' ) { $update_loc_rules->{$key} = $self->permanent_location; } >+ if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} >+ if ( ($self->location eq $key && $self->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $self->location eq '' && $update_loc_rules->{$key} ne '') ) { >+ $messages->{'ItemLocationUpdated'} = { from => $self->location, to => $update_loc_rules->{$key} }; >+ $self->location($update_loc_rules->{$key})->store({ log_action => 0, skip_record_index => 1, skip_holds_queue => 1}); >+ last; >+ } >+ } >+ } >+ } >+ >+ return $messages; >+} >+ > =head3 _type > > =cut >diff --git a/circ/circulation.pl b/circ/circulation.pl >index d4b5dcfe945..cf2284dd5b2 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -401,8 +401,9 @@ if (@$barcodes) { > ); > $recall_id = ( $recall and $recall->id ) ? $recall->id : undef; > } >- my $issue = AddIssue( $patron->unblessed, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall, recall_id => $recall_id, } ); >+ my ($issue, $item_location_updated) = AddIssue( $patron->unblessed, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall, recall_id => $recall_id, } ); > $template_params->{issue} = $issue; >+ $template_params->{ItemLocationUpdated} = $item_location_updated; > $session->clear('auto_renew'); > $inprocess = 1; > } >-- >2.20.1
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