[Koha-patches] [PATCH] [SIGNED-OFF] Bug 5418: Rev-5 patch new itemBarcodeInputFilter for libsuite8 style barcodes

Katrin Fischer katrin.fischer at bsz-bw.de
Tue Dec 7 04:06:47 CET 2010


From: Koustubha Kale <kmkale at anantcorp.com>

In India a ILS product called Libsuite8 prints barcodes like b0007432. The barcode is not stored anywhere in libsuite8's database. Neither is barcode available in any of the reports generated by the software.

The barcode 'b0007432' when scanned into the libsuite8 software is de-constructed like 'b' which is the itemtype i.e. Book in this instance, and '7432' which is the 'Accession Number'. The software then takes the logged in staff's branchcode and does a join on three tables 'Location', 'Media_Type', and 'Books' to retrieve the particular record from the database.

There is no possibility of recreating the barcodes for insertion in Koha while doing a retrospective conversion, because of arbitrary length of the barcode string AND arbitrary number of zeros in the numeric part of the printed barcode AND the fact that there are no reports available from the software which contain barcodes AND the fact that the barcode is not stored in the database.
But most importantly due to the simple fact that printed barcodes are duplicated among branches.

Therefore this patch emulates the functionality of Libsuite8 software of converting the scanned barcode into one stored in Koha using the itemBarcodeInputFilter system preference.

To use this new itemBarcodeInputFilter systempreference choice called 'libsuite8', the barcodes stored in Koha must match the pattern of <branchcode>-<itemtype_code>-<accession_number>. This is easy to achieve while doing retrospective conversion from Libsuite8 to Koha.

As expected the itemBarcodeInputFilter will return unmodified barcode if presented with a barcode of pattern <branchcode>-<itemtype_code>-<accession_number>

This revision corrects the way updatedatabase.pl is changed in order to correctly update version and insert the libsuite8 option in the database. Also kohaversion.pl is changed in the recommended format of 3.0X.0X.XXX to reflect database has changed.

This revision also changes the erronorous itemBarcodeInputFilter description in koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref from 'scanned patron barcodes' to 'scanned item barcodes' there by eliminating need for a separate patch for bug 5417.

Signed-off-by: Katrin Fischer <katrin.fischer at bsz-bw.de>

1) applied patch to HEAD
2) set next database number in kohaversion.pl and updatedatabase.pl
3) webinstaller kicked in, update ok
4) typed the barcodes from test cases into check-in

Barcodes used my local branch code, everything seemed ok to me.
---
 C4/Circulation.pm                                  |    9 +++++++++
 installer/data/mysql/en/mandatory/sysprefs.sql     |    2 +-
 installer/data/mysql/updatedatabase.pl             |    8 ++++++++
 .../en/modules/admin/preferences/circulation.pref  |    3 ++-
 .../prog/en/modules/circ/circulation.tmpl          |    2 +-
 kohaversion.pl                                     |    2 +-
 t/Circulation_barcodedecode.t                      |    6 +++++-
 7 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index 10c3c11..c5ac344 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -137,6 +137,7 @@ System Pref options.
 #
 sub barcodedecode {
     my ($barcode, $filter) = @_;
+    my $branch = C4::Branch::mybranch();
     $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
     $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
 	if ($filter eq 'whitespace') {
@@ -155,6 +156,14 @@ sub barcodedecode {
         # FIXME: $barcode could be "T1", causing warning: substr outside of string
         # Why drop the nonzero digit after the T?
         # Why pass non-digits (or empty string) to "T%07d"?
+	} elsif ($filter eq 'libsuite8') {
+		unless($barcode =~ m/^($branch)-/i){	#if barcode starts with branch code its in Koha style. Skip it.
+			if($barcode =~ m/^(\d)/i){	#Some barcodes even start with 0's & numbers and are assumed to have b as the item type in the libsuite8 software
+                                $barcode =~ s/^[0]*(\d+)$/$branch-b-$1/i;
+                        }else{
+				$barcode =~ s/^(\D+)[0]*(\d+)$/$branch-$1-$2/i;
+			}
+		}
 	}
     return $barcode;    # return barcode, modified or not
 }
diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql
index d4fb9a2..61fc22d 100644
--- a/installer/data/mysql/en/mandatory/sysprefs.sql
+++ b/installer/data/mysql/en/mandatory/sysprefs.sql
@@ -145,7 +145,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('finesMode','test','Choose the fines mode, \'off\', \'test\' (emails admin report) or \'production\' (accrue overdue fines).  Requires accruefines cronjob.','off|test|production','Choice');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('globalDueDate','','If set, allows a global static due date for all checkouts','10','free');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ceilingDueDate','','If set, date due will not be past this date.  Enter date according to the dateformat System Preference',NULL,'free');
-INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemBarcodeInputFilter','','If set, allows specification of a item barcode input filter','whitespace|T-prefix|cuecat','Choice');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemBarcodeInputFilter','','If set, allows specification of a item barcode input filter','whitespace|T-prefix|cuecat|libsuite8','Choice');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('singleBranchMode',0,'Operate in Single-branch mode, hide branch selection in the OPAC',NULL,'YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('URLLinkText','','Text to display as the link anchor in the OPAC',NULL,'free');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACViewOthersSuggestions',0,'If ON, allows all suggestions to be displayed in the OPAC',NULL,'YesNo');
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index d093946..ee39fe2 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -3876,6 +3876,14 @@ VALUES
     SetVersion ($DBversion);
 };
 
+$DBversion = '3.0X.0X.XXX';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("update `systempreferences` set options='whitespace|T-prefix|cuecat|libsuite8' where variable='itemBarcodeInputFilter'");
+    print "Upgrade to $DBversion done (Add itemBarcodeInputFilter choice libsuite8)\n";
+    SetVersion ($DBversion);
+}
+
+
 =head1 FUNCTIONS
 
 =head2 DropAllForeignKeys($table)
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 c4d4305..8fd9423 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
@@ -14,7 +14,8 @@ Circulation:
                   whitespace: Remove spaces from
                   cuecat: Convert from CueCat form
                   T-prefix: Remove the first number from T-prefix style
-            - scanned patron barcodes.
+                  libsuite8: Convert from Libsuite8 form
+            - scanned item barcodes.
         -
             - Sort previous checkouts on the circulation page from
             - pref: previousIssuesDefaultSortOrder
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl
index 89016e9..f719187 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl
@@ -293,7 +293,7 @@ function refocus(calendar) {
         <!-- /TMPL_IF -->
 
         <!-- TMPL_IF NAME="UNKNOWN_BARCODE" -->
-            <li>The barcode was not found</li>
+            <li>The barcode was not found <!-- TMPL_VAR NAME="barcode" --></li>
         <!-- /TMPL_IF -->
 
         <!-- TMPL_IF NAME="NOT_FOR_LOAN" -->
diff --git a/kohaversion.pl b/kohaversion.pl
index 53c1724..fc453fb 100644
--- a/kohaversion.pl
+++ b/kohaversion.pl
@@ -16,7 +16,7 @@ the kohaversion is divided in 4 parts :
 use strict;
 
 sub kohaversion {
-    our $VERSION = '3.03.00.004';
+    our $VERSION = '3.0X.0X.XXX';
     # version needs to be set this way
     # so that it can be picked up by Makefile.PL
     # during install
diff --git a/t/Circulation_barcodedecode.t b/t/Circulation_barcodedecode.t
index 5f2edc2..9c4a6e6 100644
--- a/t/Circulation_barcodedecode.t
+++ b/t/Circulation_barcodedecode.t
@@ -4,7 +4,9 @@
 use strict;
 use warnings;
 
-use Test::More tests => 16;
+use Test::More tests => 24;
+C4::Context->_new_userenv(123456);
+C4::Context->set_userenv(1,'kmkale' , 1, 'kk1' , 'IMS', 0, 'kmkale at anantcorp.com');
 
 BEGIN {
     use_ok('C4::Circulation');
@@ -15,12 +17,14 @@ our %inputs = (
                     'q.C3nZC3nZC3nWDNzYDxf2CNnY.fHmc.C3DWC3nZCNjXD3nW.', '.C3nZC3nZC3nWCxjWE3D1C3nX.cGf2.ENr7C3v7D3T3ENj3C3zYDNnZ.' ],
     whitespace => [" 26002315", "26002315 ", "\n\t26002315\n"],
     'T-prefix' => [qw(T0031472 T32)],
+    'libsuite8' => ['b000126', 'b12', 'B0126', 'IMS-B-126', 'ims-b-126','CD0000024','00123','11998'],
     other      => [qw(26002315 T0031472 T32 Alphanum123), "Alpha Num 345"],
 );
 our %outputs = (
     cuecat     => ["26002315", "046675000808", "046675000808", "043000112403", "978068484914051500"],
     whitespace => [qw(26002315 26002315 26002315)],
     'T-prefix' => [qw(T0031472 T0000002         )],
+    'libsuite8' => ['IMS-b-126', 'IMS-b-12', 'IMS-B-126', 'IMS-B-126', 'ims-b-126','IMS-CD-24','IMS-b-123','IMS-b-11998'],
     other      => [qw(26002315 T0031472 T32 Alphanum123), "Alpha Num 345"],
 );
     
-- 
1.6.3.3




More information about the Koha-patches mailing list