Bug 21937

Summary: Syspref autoBarcode annual doesn't increment properly barcode in some cases
Product: Koha Reporter: Frédéric Demians <f.demians>
Component: CatalogingAssignee: Frédéric Demians <f.demians>
Status: CLOSED FIXED QA Contact: Martin Renvoize <martin.renvoize>
Severity: normal    
Priority: P5 - low CC: katrin.fischer, lucas, m.de.rooy, martin.renvoize, nick
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
19.05.00, 18.11.05
Attachments: Bug 21937: Syspref autoBarcode annual doesn't increment properly barcode in some cases
Bug 21937: syspref autoBarcode annual doesn't increment properly barcode
Bug 21937: Syspref autoBarcode annual doesn't increment properly barcode in some cases
Bug 21937: syspref autoBarcode annual doesn't increment properly barcode
Bug 21937: Add test to show autoBarcode annual increment bug
Bug 21937: Syspref autoBarcode annual doesn't increment properly barcode

Description Frédéric Demians 2018-12-03 20:57:33 UTC
When autoBarcode is set to 'annual', and there is an existing barcode beginning with the 4 digit of the current year, the auto generated barcode may be wrong.

For example, you have this barcode '20184526546'. If you ask for the next 2018-000X barcode, you will 20184526547
Comment 1 Frédéric Demians 2018-12-03 21:01:50 UTC
Created attachment 82828 [details] [review]
Bug 21937: Syspref autoBarcode annual doesn't increment properly barcode in some cases

This patch show the issue. If the DB contains a barcode (not auto attributed
by Koha) which begin with the year used to generate automatically a new one,
there may be a 'collision'.

prove -v t/db_dependent/Barcodes_ValueBuilder.t
Comment 2 Frédéric Demians 2018-12-03 21:03:04 UTC
Created attachment 82829 [details] [review]
Bug 21937: syspref autoBarcode annual doesn't increment properly barcode

This patch fix the barcode annual builder. The test wil work.
Comment 3 Michal Denar 2019-04-14 18:53:19 UTC
Created attachment 87953 [details] [review]
Bug 21937: Syspref autoBarcode annual doesn't increment properly barcode in some cases

This patch show the issue. If the DB contains a barcode (not auto attributed
by Koha) which begin with the year used to generate automatically a new one,
there may be a 'collision'.

prove -v t/db_dependent/Barcodes_ValueBuilder.t

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 4 Michal Denar 2019-04-14 18:53:22 UTC
Created attachment 87954 [details] [review]
Bug 21937: syspref autoBarcode annual doesn't increment properly barcode

This patch fix the barcode annual builder. The test wil work.

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 5 Martin Renvoize 2019-04-17 10:39:51 UTC
Created attachment 88162 [details] [review]
Bug 21937: Add test to show autoBarcode annual increment bug

This patch show the issue. If the DB contains a barcode (not auto attributed
by Koha) which begin with the year used to generate automatically a new one,
there may be a 'collision'.

prove -v t/db_dependent/Barcodes_ValueBuilder.t

Signed-off-by: Michal Denar <black23@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 6 Martin Renvoize 2019-04-17 10:39:54 UTC
Created attachment 88163 [details] [review]
Bug 21937: Syspref autoBarcode annual doesn't increment properly barcode

This patch fix the barcode annual builder. The test should pass.

Signed-off-by: Michal Denar <black23@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 7 Martin Renvoize 2019-04-17 10:40:38 UTC
No regressions found, QA scripts pass and patches make sense.

Passing QA
Comment 8 Nick Clemens 2019-04-19 14:54:41 UTC
Awesome work all!

Pushed to master for 19.05
Comment 9 Martin Renvoize 2019-04-26 14:33:43 UTC
Pushed to 18.11.x for 18.11.05
Comment 10 Lucas Gass 2019-05-14 21:37:56 UTC
backported t0 18.05.x for 18.05.13