Bugzilla – Attachment 132555 Details for
Bug 20517
Use the "sort bin" field in SIP2 Checkin Response
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20517: Use the "sort bin" field in SIP2 Checkin Response
Bug-20517-Use-the-sort-bin-field-in-SIP2-Checkin-R.patch (text/plain), 6.42 KB, created by
Nick Clemens (kidclamp)
on 2022-03-30 11:12:20 UTC
(
hide
)
Description:
Bug 20517: Use the "sort bin" field in SIP2 Checkin Response
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-03-30 11:12:20 UTC
Size:
6.42 KB
patch
obsolete
>From 520fe3d60e2be016cae8175e85d1535d5ad07d40 Mon Sep 17 00:00:00 2001 >From: Magnus Enger <magnus@libriotech.no> >Date: Fri, 24 Apr 2020 12:02:02 +0200 >Subject: [PATCH] Bug 20517: Use the "sort bin" field in SIP2 Checkin Response > >This bug adds the SIP2SortBinMapping to make it possible to tell >the Koha SIP2 server to include a sort_bin/CL field in the >Checkin Response, if appropriate. > >To test: >- Check out an item and return it via SIP2: > $ telnet localhost 8023 > 9300CNterm1|COterm1|CPCPL| > 09N20200422 12430020200422 124300APCPL|AOCPL|AB001|AC| > (Where 001 in |AB001| is the barcode of the item in question) >- Check there is no CL field in the last response >- Apply the patch, fill in SIP2SortBinMapping with e.g.: > CPL:itype:BK:3 >- Repeat the first step >- Check the respons contains a CL field with a value of 3 (or what > you put in the config). The field should look like |CL3| >- Signe ye offe > >2020-06-25: Pass an item to _get_sort_bin, not a checkout. Rebase. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > C4/SIP/ILS/Transaction/Checkin.pm | 60 +++++++++++++++++++ > .../mysql/atomicupdate/bug20517-sort-bin.perl | 8 +++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../admin/preferences/circulation.pref | 7 +++ > 4 files changed, 76 insertions(+) > create mode 100644 installer/data/mysql/atomicupdate/bug20517-sort-bin.perl > >diff --git a/C4/SIP/ILS/Transaction/Checkin.pm b/C4/SIP/ILS/Transaction/Checkin.pm >index a4e09304ac..c2120929af 100644 >--- a/C4/SIP/ILS/Transaction/Checkin.pm >+++ b/C4/SIP/ILS/Transaction/Checkin.pm >@@ -168,6 +168,10 @@ sub do_checkin { > $self->alert( !$return || defined $self->alert_type ); > } > >+ # Set sort bin based on info in the item associated with the issue, and the >+ # mapping from SIP2SortBinMapping >+ $self->sort_bin( _get_sort_bin( $self->{item} ) ); >+ > $self->ok($return); > > return { messages => $messages }; >@@ -191,4 +195,60 @@ sub patron_id { > return $self->{patron}->id; > } > >+=head1 _get_sort_bin >+ >+Takes an item represented as a hashref as argument. >+ >+Uses the contents of the SIP2SortBinMapping syspref to determine the sort_bin >+value that should be returned for an item checked in via SIP2. >+ >+The mapping should be: >+ >+ <branchcode>:<item field>:<item field value>:<sort bin number> >+ >+For example: >+ >+ CPL:itype:BOOK:1 >+ CPL:location:OFFICE:2 >+ >+This will give: >+ >+=over 4 >+ >+=item * sort_bin = "1" for items at the CPL branch with an itemtype of BOOK >+ >+=item * sort_bin = "2" for items at the CPL branch with a location of OFFICE >+ >+=back >+ >+Returns the ID of the appropriate sort_bin, if there is one, or undef. >+ >+=cut >+ >+sub _get_sort_bin { >+ >+ # We should get an item represented as a hashref here >+ my ( $item ) = @_; >+ return undef unless $item; >+ >+ # Get the mapping and split on newlines >+ my $raw_map = C4::Context->preference('SIP2SortBinMapping'); >+ return unless $raw_map; >+ my @lines = split /\r\n/, $raw_map; >+ >+ # Iterate over the mapping. The first hit wins. >+ foreach my $line ( @lines ) { >+ # Split the line into fields >+ my ( $branchcode, $item_property, $value, $sort_bin ) = split /:/, $line; >+ # Check the fields against values in the item >+ if ( ( $item->{homebranch} eq $branchcode ) && ( $item->{$item_property} eq $value ) ) { >+ return $sort_bin; >+ } >+ } >+ >+ # Return undef if no hits were found >+ return undef; >+ >+} >+ > 1; >diff --git a/installer/data/mysql/atomicupdate/bug20517-sort-bin.perl b/installer/data/mysql/atomicupdate/bug20517-sort-bin.perl >new file mode 100644 >index 0000000000..1462118f5a >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug20517-sort-bin.perl >@@ -0,0 +1,8 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ $dbh->do(q{ >+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES >+ ('SIP2SortBinMapping','',NULL,'Use the following mappings to determine the sort_bin of a returned item. The mapping should be on the form \"branchcode:item field:item field value:sort bin number\", with one mapping per line.','free'),; >+ }); >+ NewVersion( $DBversion, 20517, "Add SIP2SortBinMapping system preference"); >+} >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 755df4506d..663314a35b 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -622,6 +622,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('ShowPatronImageInWebBasedSelfCheck','0','','If ON, displays patron image when a patron uses web-based self-checkout','YesNo'), > ('ShowReviewer','full','none|full|first|surname|firstandinitial|username','Choose how a commenter\'s identity is presented alongside comments in the OPAC','Choice'), > ('ShowReviewerPhoto','1','','If ON, photo of reviewer will be shown beside comments in OPAC','YesNo'), >+('SIP2SortBinMapping','',NULL,'Use the following mappings to determine the sort_bin of a returned item. The mapping should be on the form \"branchcode:item field:item field value:sort bin number\", with one mapping per line.','free'), > ('SkipHoldTrapOnNotForLoanValue','',NULL,'If set, Koha will never trap items for hold with this notforloan value','Integer'), > ('SlipCSS','',NULL,'Slips CSS url.','free'), > ('SMSSendDriver','','','Sets which SMS::Send driver is used to send SMS messages.','free'), >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 3e81898de6..012341aa3d 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 >@@ -1284,3 +1284,10 @@ Circulation: > 1: Use > 0: "Don't use" > - recalls. Make sure you configure <a href="/cgi-bin/koha/admin/smart-rules.pl">circulation and fines rules</a> for recalls once enabled. >+ >+ SIP2: >+ - >+ - "Use the following mappings to determine the sort_bin of a returned item. The mapping should be on the form 'branchcode:item field:item field value:sort bin number', with one mapping per line." >+ - pref: SIP2SortBinMapping >+ type: textarea >+ class: long >-- >2.30.2
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 20517
:
75126
|
75369
|
103689
|
106291
|
129846
|
129847
|
129848
|
129849
|
129850
|
129851
|
129852
|
129853
|
129854
|
129855
|
132555
|
132556
|
132557
|
132558
|
132559
|
132591
|
132592
|
132593
|
132594
|
132595
|
132596