Bugzilla – Attachment 51479 Details for
Bug 15878
C4::Barcodes::hbyymmincr inccorectly calculates max and should warn when no branchcode present
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15878 - C4::Barcodes::hbyymmincr inccorectly calculates max and should warn when no branchcode present
Bug-15878---C4Barcodeshbyymmincr-inccorectly-calcu.patch (text/plain), 2.01 KB, created by
Nick Clemens (kidclamp)
on 2016-05-13 18:06:42 UTC
(
hide
)
Description:
Bug 15878 - C4::Barcodes::hbyymmincr inccorectly calculates max and should warn when no branchcode present
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2016-05-13 18:06:42 UTC
Size:
2.01 KB
patch
obsolete
>From 89380af8bdc5b4574315d07d7e8a4d4de3a1a070 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 13 May 2016 14:03:37 -0400 >Subject: [PATCH] Bug 15878 - C4::Barcodes::hbyymmincr inccorectly calculates > max and should warn when no branchcode present > >Test plan: > >1 - prove t/db_dependent/Barcodes.t >2 - All should pass >3 - Apply first patch (unit tests update) > 4 - Tests should fail on values and warnings > 5 - Apply second patch > 6 - All tests should now pass >--- > C4/Barcodes/hbyymmincr.pm | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > >diff --git a/C4/Barcodes/hbyymmincr.pm b/C4/Barcodes/hbyymmincr.pm >index 4942443..51b2a50 100644 >--- a/C4/Barcodes/hbyymmincr.pm >+++ b/C4/Barcodes/hbyymmincr.pm >@@ -44,7 +44,7 @@ INIT { > > sub db_max { > my $self = shift; >- my $query = "SELECT MAX(SUBSTRING(barcode,-$width)), barcode FROM items WHERE barcode REGEXP ? GROUP BY barcode"; >+ my $query = "SELECT SUBSTRING(barcode,-$width) AS chunk, barcode FROM items WHERE barcode REGEXP ? ORDER BY chunk DESC LIMIT 1"; > $debug and print STDERR "(hbyymmincr) db_max query: $query\n"; > my $sth = C4::Context->dbh->prepare($query); > my ($iso); >@@ -75,6 +75,7 @@ sub initial { > my $self = shift; > # FIXME: populated branch? > my $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # like "2008-07-02" >+ if ( $self->branch eq '' ) { warn "HBYYMM Barcode was not passed a branch, default is blank" } > return $self->branch . substr($iso,2,2) . substr($iso,5,2) . sprintf('%' . "$width.$width" . 'd',1); > } > >@@ -116,6 +117,7 @@ sub new_object { > my $self = $class_or_object->default_self('hbyymmincr'); > bless $self, $type; > $self->branch(@_ ? shift : $from_obj ? $class_or_object->branch : $branch); >+ if ( $self->branch() eq '' ) { warn "HBYYMM Barcode created with no branchcode, default is blank"; } > # take the branch from argument, or existing object, or default > use Data::Dumper; > $debug and print STDERR "(hbyymmincr) new_object: ", Dumper($self), "\n"; >-- >2.1.4
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 15878
:
51477
|
51478
|
51479
|
51624
|
51625
|
51688
|
51690
|
51691
|
51692
|
51694
|
51695