---- Reported by email@example.com 2009-09-03 13:51:06 ----
The Barcode.pl script attempts to auto-increment the barcode by isolating the maximum barcode in the item database. It does this by isolating the last four numerals of the barcodes and choosing the maximum value.
The problem is that the SELECT query assumes a two letter branch code. If the branch code varies, the SELECT query fails to isolate the correct portion of the branch code. It therefore incorrectly maximises and the increment is wrong causing duplicate barcodes.
The exact line is:
$query = "SELECT MAX(CAST(SUBSTRING(barcode,7,4) AS signed)) FROM items WHERE barcode REGEXP ?";
The solution would be to limit branch codes to two letters or to isolate only the last four numerals of the barcode string before maximising.
Incidently, surely this also limits the barcode to 9999 items?
--- Bug imported by firstname.lastname@example.org 2010-05-21 01:12 UTC ---
This bug was previously known as _bug_ 3577 at http://bugs.koha.org/cgi-bin/bugzilla3/show_bug.cgi?id=3577
Unknown operating system Linux - Debian. Setting to default OS "All".
Actual time not defined. Setting to 0.0
The original reporter of this bug does not have
an account here. Reassigning to the person who moved
it here: email@example.com.
Previous reporter was firstname.lastname@example.org.
Created attachment 3024 [details] [review]
Proposed fix for bug 3577
Katrin to test (for bug 5659)
*** Bug 5659 has been marked as a duplicate of this bug. ***
Created attachment 3032 [details]
the patch works great for the example libraries which all have 3 letter branchcodes. We use the ISIL as branchcode for our libraries. After I added a new library using the ISIL only the next barcode was generated correctly. After that the same barcode was being generated again and again. After I deleted the item for the ISL branch, the barcodes were generated correctly again. (see screensot)
This is marked as Failed QA, but I'm seeing an equivalent fix in the current HEAD... can anyone confirm that this is still an issue?
I tested this on current master and still see problems and with the change form the patch:
1) Turn system preference autobarcode to hbyymmincr
2) Add items to a new record
a) Add 2 items for branch MPL - Midway. Works. (MPL11070001,MPL11070002)
b) Add 1 item for branch DE-576 - works. (DE-57611070003)
c) Add 2nd item for branch DE-576 (DE-57611070003 - duplicate!)
Perhaps the - in the branch code is the cause of the problem. I can add 1 item for it at the time, and add MPL items after it. But it's not possible to add 2 items in a row for DE-576.
Yes, the pb is the - in the branchcode.
This is corrected with patch proposed in bug 6474 http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=6474
*** This bug has been marked as a duplicate of bug 6474 ***