Bugzilla – Attachment 10127 Details for
Bug 6448
EAN-13 barcode support
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6448 [1/3] EAN-13/UPC-A itemBarcodeInputFilter
Bug-6448-13-EAN-13UPC-A-itemBarcodeInputFilter.patch (text/plain), 4.82 KB, created by
Dobrica Pavlinusic
on 2012-06-10 15:16:39 UTC
(
hide
)
Description:
Bug 6448 [1/3] EAN-13/UPC-A itemBarcodeInputFilter
Filename:
MIME Type:
Creator:
Dobrica Pavlinusic
Created:
2012-06-10 15:16:39 UTC
Size:
4.82 KB
patch
obsolete
>From f21bb5841e3e47877dc66e5f004bf96df1a31fc3 Mon Sep 17 00:00:00 2001 >From: Dobrica Pavlinusic <dpavlin@rot13.org> >Date: Wed, 28 Mar 2012 00:38:34 +0200 >Subject: [PATCH] Bug 6448 [1/3] EAN-13/UPC-A itemBarcodeInputFilter > >This filter which check validity of EAN-13 barcode and padd it with zeros >up to full 13 digit number. This will also expand 12 digit UPC-A barcodes >to EAN-13 automatically which is useful for older barcode readers which tend >to ignore first zero in EAN-13 if they have just UPC-A support. > >It should be noted that EAN-13 or UPC-A product codes printed on books are not >good choice for barcodes in Koha since each item has to have unique barcode. > >Test scenario: > >1. prove t/Circulation_barcodedecode.t > this checks expansion of 12 digit UPC-A to 13 digit EAN-13 and zero padding > >2. in systempreferences search for itemBarcodeInputFilter and select EAN-13 > >3. edit one item and assign it valid EAN-13 barcode, eg. 0000000695152, check it out > >4. test checkin with just 695152 to test leading zero expansion >--- > C4/Circulation.pm | 10 ++++++++++ > installer/data/mysql/updatedatabase.pl | 7 +++++++ > .../en/modules/admin/preferences/circulation.pref | 1 + > t/Circulation_barcodedecode.t | 4 +++- > 4 files changed, 21 insertions(+), 1 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 9b523e3..f760ae3 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -38,6 +38,8 @@ use C4::Branch; # GetBranches > use C4::Log; # logaction > use C4::Koha qw(GetAuthorisedValueByCode); > use C4::Overdues qw(CalcFine UpdateFine); >+use Algorithm::CheckDigits; >+ > use Data::Dumper; > use Koha::DateUtils; > use Koha::Calendar; >@@ -169,6 +171,14 @@ sub barcodedecode { > $barcode =~ s/^(\D+)[0]*(\d+)$/$branch-$1-$2/i; > } > } >+ } elsif ($filter eq 'EAN13') { >+ my $ean = CheckDigits('ean'); >+ if ( $ean->is_valid($barcode) ) { >+ #$barcode = sprintf('%013d',$barcode); # this doesn't work on 32-bit systems >+ $barcode = '0' x ( 13 - length($barcode) ) . $barcode; >+ } else { >+ warn "# [$barcode] not valid EAN-13/UPC-A\n"; >+ } > } > return $barcode; # return barcode, modified or not > } >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 62b4372..46c3308 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -5343,6 +5343,13 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.07.00.XXX"; # FIXME >+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >+ $dbh->do("UPDATE systempreferences SET options=concat(options,'|EAN13') WHERE variable='itembarcodeinputfilter' AND options NOT LIKE '%EAN13%'"); >+ print "Upgrade to $DBversion done (Add itemBarcodeInputFilter choice EAN13)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($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 d2d11b4..bc24372 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 >@@ -16,6 +16,7 @@ Circulation: > cuecat: Convert from CueCat form > T-prefix: Remove the first number from T-prefix style > libsuite8: Convert from Libsuite8 form >+ EAN13: EAN-13 or zero-padded UPC-A from > - scanned item barcodes. > - > - Sort previous checkouts on the circulation page from >diff --git a/t/Circulation_barcodedecode.t b/t/Circulation_barcodedecode.t >index 9c4a6e6..f76f7fc 100644 >--- a/t/Circulation_barcodedecode.t >+++ b/t/Circulation_barcodedecode.t >@@ -4,7 +4,7 @@ > use strict; > use warnings; > >-use Test::More tests => 24; >+use Test::More tests => 26; > C4::Context->_new_userenv(123456); > C4::Context->set_userenv(1,'kmkale' , 1, 'kk1' , 'IMS', 0, 'kmkale@anantcorp.com'); > >@@ -18,6 +18,7 @@ our %inputs = ( > whitespace => [" 26002315", "26002315 ", "\n\t26002315\n"], > 'T-prefix' => [qw(T0031472 T32)], > 'libsuite8' => ['b000126', 'b12', 'B0126', 'IMS-B-126', 'ims-b-126','CD0000024','00123','11998'], >+ EAN13 => [qw(892685001928 695152)], > other => [qw(26002315 T0031472 T32 Alphanum123), "Alpha Num 345"], > ); > our %outputs = ( >@@ -25,6 +26,7 @@ our %outputs = ( > 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'], >+ EAN13 => [qw(0892685001928 0000000695152)], > other => [qw(26002315 T0031472 T32 Alphanum123), "Alpha Num 345"], > ); > >-- >1.7.2.5
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 6448
:
8668
|
8669
|
8670
|
9192
|
10019
|
10127
|
10128
|
10129
|
10130
|
10134
|
11041
|
11042
|
11043
|
11349