From f81d520b5b7b4a8aba77fd193bb6d25478ec8f2d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 7 Dec 2018 14:32:00 -0500 Subject: [PATCH] Bug 21979: Add option to SIP2 config to send arbitrary item field in CR instead of collection code Some libraries need to send a different field as the collection code, depending on how the library catalogs items. We should allow any arbitrary item field to be used as the value for the CR field. Test Plan: 1) Apply this patch 2) Set the new option cr_item_field to 'shelving_location' 3) Restart the SIP server 3) Perform a checkin via SIP 4) Note the CR field contains the shelving location code in the response 5) Perform an item information request 6) Note the CR field contains the shelving location code in the response --- C4/SIP/ILS/Item.pm | 12 ++++++++---- C4/SIP/Sip/MsgType.pm | 11 ++++++++++- etc/SIPconfig.xml | 1 + 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/C4/SIP/ILS/Item.pm b/C4/SIP/ILS/Item.pm index 240e1990a0..5bf4836a89 100644 --- a/C4/SIP/ILS/Item.pm +++ b/C4/SIP/ILS/Item.pm @@ -81,10 +81,12 @@ sub new { return; } my $self = $item->unblessed; - $self->{ 'id' } = $item->barcode; # to SIP, the barcode IS the id. - $self->{permanent_location}= $item->homebranch; - $self->{'collection_code'} = $item->ccode; - $self->{ 'call_number' } = $item->itemcallnumber; + $self->{'id'} = $item->barcode; # to SIP, the barcode IS the id. + $self->{permanent_location} = $item->homebranch; + $self->{'collection_code'} = $item->ccode; + $self->{'call_number'} = $item->itemcallnumber; + $self->{'shelving_location'} = $item->location; + $self->{'permanent_shelving_location'} = $item->permanent_location; my $it = $item->effective_itemtype; my $itemtype = Koha::Database->new()->schema()->resultset('Itemtype')->find( $it ); @@ -129,6 +131,8 @@ my %fields = ( barcode => 0, onloan => 0, collection_code => 0, + shelving_location => 0, + permanent_shelving_location => 0, call_number => 0, enumchron => 0, location => 0, diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index 9ec126ed12..fca8c339c5 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -671,7 +671,11 @@ sub handle_checkin { if ($item) { $resp .= maybe_add( FID_MEDIA_TYPE, $item->sip_media_type ); $resp .= maybe_add( FID_ITEM_PROPS, $item->sip_item_properties ); - $resp .= maybe_add( FID_COLLECTION_CODE, $item->collection_code ); + if ( my $CR = $server->{account}->{cr_item_field} ) { + $resp .= maybe_add( FID_COLLECTION_CODE, $item->{$CR} ); + } else { + $resp .= maybe_add( FID_COLLECTION_CODE, $item->collection_code ); + } $resp .= maybe_add( FID_CALL_NUMBER, $item->call_number ); $resp .= maybe_add( FID_DESTINATION_LOCATION, $item->destination_loc ); $resp .= maybe_add( FID_HOLD_PATRON_ID, $item->hold_patron_bcode ); @@ -1140,6 +1144,11 @@ sub handle_item_information { $resp .= maybe_add( FID_PERM_LOCN, $item->permanent_location ); $resp .= maybe_add( FID_CURRENT_LOCN, $item->current_location ); $resp .= maybe_add( FID_ITEM_PROPS, $item->sip_item_properties ); + if ( my $CR = $server->{account}->{cr_item_field} ) { + $resp .= maybe_add( FID_COLLECTION_CODE, $item->$CR ); + } else { + $resp .= maybe_add( FID_COLLECTION_CODE, $item->collection_code ); + } if ( ( $i = $item->fee ) != 0 ) { $resp .= add_field( FID_CURRENCY, $item->fee_currency ); diff --git a/etc/SIPconfig.xml b/etc/SIPconfig.xml index 5d9ee98bc2..dfe7a48ca9 100644 --- a/etc/SIPconfig.xml +++ b/etc/SIPconfig.xml @@ -51,6 +51,7 @@ -- 2.17.2 (Apple Git-113)