We should add more flexibility to generating barcodes by letting libraries define branch specific prefix for their barcodes. For this we need to add new barcode option to syspref "autobarcode" and new systempreference where prefixes are set.
Created attachment 132221 [details] [review] Bug 30328: Add ability to generate barcode with branch specific prefix We should add more flexibility to generating barcodes by letting libraries define branch specific prefix for their barcodes. This patch adds new option "preyyyymmincr" in systempreference "autoBarcode" and new systempreference "BarcodePrefix" to define branch specific prefix Test plan: 1. Apply patch and update database 2. Set syspref "autoBarcode" as 3. Add some values to syspref "Barcodeprefix" e.g.: Default: DEF CPL: CPL FFL: FFL 4. Now change your library to CPL (if needed) and add an item 5. Click barcode input field => barcode should be CPL<current_year><current_month>00001 6. Add another item and click barcode field => barcode should be CPL<current_year><current_month>00002 7. Change your library to FFL and add an item => barcode should now be FFL<current_year><current_month>00001 8. Change your library to e.g. FPL (or another as long as it doesn't have prefix value in "Barcodeprefix"), add an item and click barcode field => barcode should now be DEF<current_year><current_month>00001 9. Try to add multiple items => barcodes incremental value should increase in order (no skipping values, no errors) Also prove t/db_dependent/Barcodes_ValueBuilder.t and t/Barcodes_preyyyymmincr.t Sponsored-by: Koha-Suomi Oy
Created attachment 132954 [details] [review] Bug 30328: Add ability to generate barcode with branch specific prefix We should add more flexibility to generating barcodes by letting libraries define branch specific prefix for their barcodes. This patch adds new option "preyyyymmincr" in systempreference "autoBarcode" and new systempreference "BarcodePrefix" to define branch specific prefix Test plan: 1. Apply patch and update database 2. Set syspref "autoBarcode" as 3. Add some values to syspref "Barcodeprefix" e.g.: Default: DEF CPL: CPL FFL: FFL 4. Now change your library to CPL (if needed) and add an item 5. Click barcode input field => barcode should be CPL<current_year><current_month>00001 6. Add another item and click barcode field => barcode should be CPL<current_year><current_month>00002 7. Change your library to FFL and add an item => barcode should now be FFL<current_year><current_month>00001 8. Change your library to e.g. FPL (or another as long as it doesn't have prefix value in "Barcodeprefix"), add an item and click barcode field => barcode should now be DEF<current_year><current_month>00001 9. Try to add multiple items => barcodes incremental value should increase in order (no skipping values, no errors) Also prove t/db_dependent/Barcodes_ValueBuilder.t and t/Barcodes_preyyyymmincr.t Sponsored-by: Koha-Suomi Oy
Created attachment 134009 [details] [review] Bug 30328: Add ability to generate barcode with branch specific prefix We should add more flexibility to generating barcodes by letting libraries define branch specific prefix for their barcodes. This patch adds new option "preyyyymmincr" in systempreference "autoBarcode" and new systempreference "BarcodePrefix" to define branch specific prefix Test plan for adding item: 1. Apply patch and update database 2. Set syspref "autoBarcode" as 3. Add some values to syspref "Barcodeprefix" e.g.: Default: DEF CPL: CPL FFL: FFL 4. Now change your library to CPL (if needed) and add an item 5. Click barcode input field => barcode should be CPL<current_year><current_month>00001 6. Add another item and click barcode field => barcode should be CPL<current_year><current_month>00002 7. Change your library to FFL and add an item => barcode should now be FFL<current_year><current_month>00001 8. Change your library to e.g. FPL (or another as long as it doesn't have prefix value in "Barcodeprefix"), add an item and click barcode field => barcode should now be DEF<current_year><current_month>00001 9. Try to add multiple items => barcodes incremental value should increase in order (no skipping values, no errors) Test plan for adding multiple aqcuisitions: 1. Set syspref "AcqCreateItem" as "placing order". 2. Create an order and add multiple items to it. 3. Save the order. 4. Navigate to that biblios detail page to which you added items. => ordered items barcodes incremental value should increase in order (no skipping values, no errors) Also prove t/db_dependent/Barcodes_ValueBuilder.t and t/Barcodes_preyyyymmincr.t Sponsored-by: Koha-Suomi Oy
Previous patch didn't have custom methods in C4/Barcodes/preyyyymmincr.pm so adding an order with multiple items produced error 500. Added methods and test plan for this scenario.
I think the description of the BarcodePrefix preference should say that it is used in connection with the autoBarcode preference, and include a link to it (and vice versa). For example: "Define library specific barcode prefixes in YAML format. This defines the behavior of the <code><prefix>yyyymm0001</code> option of <a>autoBarcode</a>." And added to the autoBarcode description, "Define the behavior of the <code><prefix>yyyymm0001</code> option using <a>BarcodePrefix</a>." Should the BarcodePrefix preference provide an example for the syntax which is expected? Or perhaps a link to the wiki like OpacHiddenItems has? Otherwise everything was working well when tested in cataloging.
Also: The BarcodePrefix textarea should be a CodeMirror editor using "text/x-yaml" syntax. See OpacHiddenItems in opac.pref for example.
Created attachment 134202 [details] [review] Bug 30328: Add ability to generate barcode with branch specific prefix We should add more flexibility to generating barcodes by letting libraries define branch specific prefix for their barcodes. This patch adds new option "preyyyymmincr" in systempreference "autoBarcode" and new systempreference "BarcodePrefix" to define branch specific prefix Test plan for adding item: 1. Apply patch and update database 2. Set syspref "autoBarcode" as 3. Add some values to syspref "Barcodeprefix" e.g.: Default: DEF CPL: CPL FFL: FFL 4. Now change your library to CPL (if needed) and add an item 5. Click barcode input field => barcode should be CPL<current_year><current_month>00001 6. Add another item and click barcode field => barcode should be CPL<current_year><current_month>00002 7. Change your library to FFL and add an item => barcode should now be FFL<current_year><current_month>00001 8. Change your library to e.g. FPL (or another as long as it doesn't have prefix value in "Barcodeprefix"), add an item and click barcode field => barcode should now be DEF<current_year><current_month>00001 9. Try to add multiple items => barcodes incremental value should increase in order (no skipping values, no errors) Test plan for adding multiple aqcuisitions: 1. Set syspref "AcqCreateItem" as "placing order". 2. Create an order and add multiple items to it. 3. Save the order. 4. Navigate to that biblios detail page to which you added items. => ordered items barcodes incremental value should increase in order (no skipping values, no errors) Also prove t/db_dependent/Barcodes_ValueBuilder.t and t/Barcodes_preyyyymmincr.t Sponsored-by: Koha-Suomi Oy
(In reply to Owen Leonard from comment #5) > I think the description of the BarcodePrefix preference should say that it > is used in connection with the autoBarcode preference, and include a link to > it (and vice versa). For example: > > "Define library specific barcode prefixes in YAML format. This defines the > behavior of the <code><prefix>yyyymm0001</code> option of > <a>autoBarcode</a>." > > And added to the autoBarcode description, "Define the behavior of the > <code><prefix>yyyymm0001</code> option using <a>BarcodePrefix</a>." > Added links to descriptions and also changed BarcodePrefix as CodeMirror editor. > Should the BarcodePrefix preference provide an example for the syntax which > is expected? Or perhaps a link to the wiki like OpacHiddenItems has? > Oh, I didn't notice this one. But I guess it would be more convenient to provide example on the sysprefs description rather than external wiki page. Something like "Syntax for barcodes is e.g. <code>DEF2022040001</code>".
Created attachment 134206 [details] [review] Bug 30328: Add ability to generate barcode with branch specific prefix We should add more flexibility to generating barcodes by letting libraries define branch specific prefix for their barcodes. This patch adds new option "preyyyymmincr" in systempreference "autoBarcode" and new systempreference "BarcodePrefix" to define branch specific prefix Test plan for adding item: 1. Apply patch and update database 2. Set syspref "autoBarcode" as 3. Add some values to syspref "Barcodeprefix" e.g.: Default: DEF CPL: CPL FFL: FFL 4. Now change your library to CPL (if needed) and add an item 5. Click barcode input field => barcode should be CPL<current_year><current_month>00001 6. Add another item and click barcode field => barcode should be CPL<current_year><current_month>00002 7. Change your library to FFL and add an item => barcode should now be FFL<current_year><current_month>00001 8. Change your library to e.g. FPL (or another as long as it doesn't have prefix value in "Barcodeprefix"), add an item and click barcode field => barcode should now be DEF<current_year><current_month>00001 9. Try to add multiple items => barcodes incremental value should increase in order (no skipping values, no errors) Test plan for adding multiple aqcuisitions: 1. Set syspref "AcqCreateItem" as "placing order". 2. Create an order and add multiple items to it. 3. Save the order. 4. Navigate to that biblios detail page to which you added items. => ordered items barcodes incremental value should increase in order (no skipping values, no errors) Also prove t/db_dependent/Barcodes_ValueBuilder.t and t/Barcodes_preyyyymmincr.t
I'm getting an error when I try to use the "Add multiple copies" option: DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Data too long for column 'barcode' at row 1 at /kohadevbox/koha/Koha/Object.pm line 170 at /usr/share/perl5/DBIx/Class/Exception.pm line 77 I'm not sure why this happened--it wasn't because I'd added a prefix which would cause the barcode to be too long. However, it does highlight that it is a possibility: If someone uses a prefix 10 characters long the barcode will always exceed the size of items.barcode. It also occurs to me... Shouldn't the prefix be determined by the item's home library, not by the user's logged-in library? In our system, for instance, cataloging for all the branches is done at one location.
(In reply to Owen Leonard from comment #10) > I'm getting an error when I try to use the "Add multiple copies" option: > > DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st > execute failed: Data too long for column 'barcode' at row 1 at > /kohadevbox/koha/Koha/Object.pm line 170 > at /usr/share/perl5/DBIx/Class/Exception.pm line 77 > > I'm not sure why this happened--it wasn't because I'd added a prefix which > would cause the barcode to be too long. However, it does highlight that it > is a possibility: If someone uses a prefix 10 characters long the barcode > will always exceed the size of items.barcode. > Last changes which fixed ability to add multiple aqcuisitions items, broke the ability to add multiple items. Will fix it asap. > It also occurs to me... Shouldn't the prefix be determined by the item's > home library, not by the user's logged-in library? In our system, for > instance, cataloging for all the branches is done at one location. This sure doesn't take that possibility into account. I'll take a look at this also.
Created attachment 139350 [details] [review] Bug 30328: Add ability to generate barcode with branch specific prefix We should add more flexibility to generating barcodes by letting libraries define branch specific prefix for their barcodes. This patch adds new option "preyyyymmincr" in systempreference "autoBarcode" and new systempreference "BarcodePrefix" to define branch specific prefix Test plan for adding item: 1. Apply patch and update database 2. Set syspref "autoBarcode" as 3. Add some values to syspref "Barcodeprefix" e.g.: Default: DEF CPL: CPL FFL: FFL 4. Now change your library to CPL (if needed) and add an item 5. Click barcode input field => barcode should be CPL<current_year><current_month>00001 6. Add another item and click barcode field => barcode should be CPL<current_year><current_month>00002 7. Change your library to FFL and add an item => barcode should now be FFL<current_year><current_month>00001 8. Change your library to e.g. FPL (or another as long as it doesn't have prefix value in "Barcodeprefix"), add an item and click barcode field => barcode should now be DEF<current_year><current_month>00001 9. Try to add multiple items => barcodes incremental value should increase in order (no skipping values, no errors) Test plan for adding multiple aqcuisitions: 1. Set syspref "AcqCreateItem" as "placing order". 2. Create an order and add multiple items to it. 3. Save the order. 4. Navigate to that biblios detail page to which you added items. => ordered items barcodes incremental value should increase in order (no skipping values, no errors) Also prove t/db_dependent/Barcodes_ValueBuilder.t and t/Barcodes_preyyyymmincr.t Sponsored-by: Koha-Suomi Oy
Fixed adding multiple items. Still thinking if we really can use items home library to determine barcode prefix.
(In reply to Emmi Takkinen from comment #13) > Fixed adding multiple items. Still thinking if we really can use items home > library to determine barcode prefix. There are plugin hooks for barcodes now: https://github.com/bywatersolutions/dev-koha-plugin-kitchen-sink/commit/0ee1ea69bf01b47e63c1406e4f2a0831ebec906b And we have a plugin for prefixing barcodes with library prefixes: https://github.com/bywatersolutions/koha-plugin-barcode-prefixer Just mentioning as that may work for this case
What is the status of this? Emmi, did you decide to use the plugin?
(In reply to Katrin Fischer from comment #15) > What is the status of this? Emmi, did you decide to use the plugin? We tested it and unfortunately it doesn't fit our workflow :( I haven't been able to work with this for a while but I'm determined to finally catch up with all my assigned bugs which have been left hanging :D
(In reply to Emmi Takkinen from comment #16) > (In reply to Katrin Fischer from comment #15) > > What is the status of this? Emmi, did you decide to use the plugin? > > We tested it and unfortunately it doesn't fit our workflow :( > > I haven't been able to work with this for a while but I'm determined to > finally catch up with all my assigned bugs which have been left hanging :D Happy to hear that :) Going into summer in this part of the world we are always lacking hands (with the people attached to them).
There are couple problems here. First, if incremental part of barcode is generated by fetching max value from last added item, there is a change that a duplicate barcode is generated. Using timestamp (yyyymmddHHMMSS) would probably be an usable solution here, but we haven't tested this yet. Second is getting items home library. This requires creating an AJAX call, which isn't problem itself. Problem is that Kohas way of generating barcodes is... interesting. And complex. I tested this a little while ago and using AJAX call advanced incremental part of barcode by 2 or even more. Which can cause issues in large libraries when limit of monthly increment parts is filled before end of month. But again, using timestamp could be useful here.