[Bug 44309] New: hbyymmincr autoBarcode counts unrelated numeric barcodes and repeats 0001
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44309 Bug ID: 44309 Summary: hbyymmincr autoBarcode counts unrelated numeric barcodes and repeats 0001 Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Cataloging Assignee: koha-bugs@lists.koha-community.org Reporter: jacob.omara@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org CC: m.de.rooy@rijksmuseum.nl Target Milestone: --- When autoBarcode is set to "<branchcode>yymm0001" (hbyymmincr), the barcode value builder finds the next number with this pattern: ^[-a-zA-Z0-9]{1,}<yy><mm> The pattern has no end anchor, and the prefix accepts digits. Any barcode that contains <yy><mm> after the first character matches, and the last 4 characters of that barcode are used as the sequence number. For example, in November 2026 the numeric barcode 123456726119999 matches (1234567 + 2611 + 9999). The maximum becomes 9999, the sequence resets, and the value builder returns <branchcode>26110001 again. If that barcode already exists, the item cannot be saved because the barcode is not unique. Libraries with numeric barcodes from earlier systems are affected, because those barcodes often contain the current yymm. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44309 Jacob O'Mara <jacob.omara@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |jacob.omara@openfifth.co.uk |ity.org | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44309 --- Comment #1 from Jacob O'Mara <jacob.omara@openfifth.co.uk> --- Created attachment 212695 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212695&action=edit Bug 44309: Match hbyymmincr barcodes against real library codes This patch changes C4::Barcodes::ValueBuilder::hbyymmincr::get_barcode so that it only counts barcodes made of a real library code, then yymm, then exactly 4 digits. It uses one LIKE filter for each library code, so the query uses the barcode index and does not scan the full items table. Test plan: 1. Set the autoBarcode system preference to "generated in the form <branchcode>yymm0001". 2. Find the current year and month as yymm (for example 2611 for November 2026). 3. Edit an item and set its barcode to CPL<yymm>0001 (for example CPL26110001). 4. Edit a different item and set its barcode to 1234567<yymm>9999 (for example 123456726119999). 5. Open a bibliographic record and click New > New item. Make sure the home library is Centerville (CPL). 6. Click in the barcode field (952$p). => The barcode is CPL<yymm>0001. 7. Click "Add item". => The item is not saved, because the barcode is not unique. 8. Apply the patch and restart_all. 9. Repeat steps 5 and 6. => The barcode is CPL<yymm>0002. 10. Click "Add item". => The item is saved. 11. Run: prove t/db_dependent/Barcodes_ValueBuilder.t => All tests pass. Assisted-by: Claude Opus 5.5 (Anthropic) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44309 --- Comment #2 from Jacob O'Mara <jacob.omara@openfifth.co.uk> --- Created attachment 212696 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212696&action=edit Bug 44309: Add tests for hbyymmincr barcode prefix matching Assisted-by: Claude Opus 5.5 (Anthropic) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44309 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff CC| |martin.renvoize@openfifth.c | |o.uk -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44309 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |42221 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42221 [Bug 42221] autoBarcode set to incremental EAN-13 barcodes do not increment -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44309 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=42221 Depends on|42221 | Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42221 [Bug 42221] autoBarcode set to incremental EAN-13 barcodes do not increment -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44309 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |44311 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44311 [Bug 44311] hbyymmincr autoBarcode shares one 9999 sequence between all libraries -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44309 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44309 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #212695|0 |1 is obsolete| | Attachment #212696|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44309 --- Comment #3 from David Nind <david@davidnind.com> --- Created attachment 212731 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212731&action=edit Bug 44309: Match hbyymmincr barcodes against real library codes This patch changes C4::Barcodes::ValueBuilder::hbyymmincr::get_barcode so that it only counts barcodes made of a real library code, then yymm, then exactly 4 digits. It uses one LIKE filter for each library code, so the query uses the barcode index and does not scan the full items table. Test plan: 1. Set the autoBarcode system preference to "generated in the form <branchcode>yymm0001". 2. Find the current year and month as yymm (for example 2611 for November 2026). 3. Edit an item and set its barcode to CPL<yymm>0001 (for example CPL26110001). 4. Edit a different item and set its barcode to 1234567<yymm>9999 (for example 123456726119999). 5. Open a bibliographic record and click New > New item. Make sure the home library is Centerville (CPL). 6. Click in the barcode field (952$p). => The barcode is CPL<yymm>0001. 7. Click "Add item". => The item is not saved, because the barcode is not unique. 8. Apply the patch and restart_all. 9. Repeat steps 5 and 6. => The barcode is CPL<yymm>0002. 10. Click "Add item". => The item is saved. 11. Run: prove t/db_dependent/Barcodes_ValueBuilder.t => All tests pass. Assisted-by: Claude Opus 5.5 (Anthropic) Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44309 --- Comment #4 from David Nind <david@davidnind.com> --- Created attachment 212732 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212732&action=edit Bug 44309: Add tests for hbyymmincr barcode prefix matching Assisted-by: Claude Opus 5.5 (Anthropic) Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org