Bug 25712 - Add plugin hooks to transform patron and item barcodes
Summary: Add plugin hooks to transform patron and item barcodes
Status: RESOLVED MOVED
Alias: None
Product: Koha
Classification: Unclassified
Component: Plugin architecture (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Kyle M Hall (khall)
QA Contact: Testopia
URL:
Keywords:
Depends on: 24031
Blocks:
  Show dependency treegraph
 
Reported: 2020-06-11 12:14 UTC by Kyle M Hall (khall)
Modified: 2020-09-03 11:18 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 25712: Add plugin hooks to transform patron and item barcodes (17.75 KB, patch)
2020-07-06 12:16 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 25712: Add plugin hooks to transform patron and item barcodes (18.49 KB, patch)
2020-07-06 12:24 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 25712: Add plugin hooks to transform patron and item barcodes (18.43 KB, patch)
2020-07-06 12:41 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 25712: Add plugin hooks to transform patron and item barcodes (18.44 KB, patch)
2020-07-20 18:38 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 25712: (QA follow-up) Fix QA script warnings (1.76 KB, patch)
2020-08-21 15:05 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 25712: Add plugin hooks to transform patron and item barcodes (18.48 KB, patch)
2020-08-24 23:33 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 25712: (QA follow-up) Fix QA script warnings (1.80 KB, patch)
2020-08-24 23:33 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall (khall) 2020-06-11 12:14:27 UTC
Some of our partners have unusual barcode requirements that have required us to transform scanned barcodes using javascript. This is not the most reliable method. It would make more sense to have Koha transform the barcodes on the backend using a plugin. We should add hooks to transform and generate new item and patron barcodes.
Comment 1 Kyle M Hall (khall) 2020-07-06 12:16:48 UTC
Created attachment 106577 [details] [review]
Bug 25712: Add plugin hooks to transform patron and item barcodes

Some of our partners have unusual barcode requirements that have
required us to transform scanned barcodes using javascript. This is not
the most reliable method. It would make more sense to have Koha
transform the barcodes on the backend using a plugin. We should add
hooks to transform and generate new item and patron barcodes.
Comment 2 Kyle M Hall (khall) 2020-07-06 12:24:12 UTC
Created attachment 106578 [details] [review]
Bug 25712: Add plugin hooks to transform patron and item barcodes

Some of our partners have unusual barcode requirements that have
required us to transform scanned barcodes using javascript. This is not
the most reliable method. It would make more sense to have Koha
transform the barcodes on the backend using a plugin. We should add
hooks to transform and generate new item and patron barcodes.

Test Plan:
1) Apply this patch
2) Download and install the Barcode Transformer plugin
   https://github.com/bywatersolutions/koha-plugin-barcode-transformer/releases/download/v1.0.1/koha-plugin-barcode-transformer-v1.0.1.kpz
3) Go to the plugin configuration page, set the configuration to the example configuration from the same page
4) In the patron search and anywhere else you can scan a patron
cardnumber, type in some cardnumbers but prefix them with A and postfix
them with A or B, e.g. A12345A, A12345B
5) Note the letters are removed by Koha!
6) Try a cardnumber like X123456Y
7) Note Koha converts it to Z13456Z
8) Try an item barcode now with the same A A|B format from step 4
9) The item barcode should have the letters removed by Koha as well!
Comment 3 Kyle M Hall (khall) 2020-07-06 12:41:30 UTC
Created attachment 106579 [details] [review]
Bug 25712: Add plugin hooks to transform patron and item barcodes

Some of our partners have unusual barcode requirements that have
required us to transform scanned barcodes using javascript. This is not
the most reliable method. It would make more sense to have Koha
transform the barcodes on the backend using a plugin. We should add
hooks to transform and generate new item and patron barcodes.

Test Plan:
1) Apply this patch
2) Download and install the Barcode Transformer plugin
   https://github.com/bywatersolutions/koha-plugin-barcode-transformer/releases/
3) Go to the plugin configuration page, set the configuration to the example configuration from the same page
4) In the patron search and anywhere else you can scan a patron
cardnumber, type in some cardnumbers but prefix them with A and postfix
them with A or B, e.g. A12345A, A12345B
5) Note the letters are removed by Koha!
6) Try a cardnumber like X123456Y
7) Note Koha converts it to Z13456Z
8) Try an item barcode now with the same A A|B format from step 4
9) The item barcode should have the letters removed by Koha as well!
Comment 4 Andrew Fuerste-Henry 2020-07-17 18:22:29 UTC
Patch doesn't apply. Thanks!
Comment 5 Katrin Fischer 2020-07-18 17:54:32 UTC
Can you please update https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks too? Thanks!
Comment 6 Kyle M Hall (khall) 2020-07-20 18:38:49 UTC
Created attachment 107125 [details] [review]
Bug 25712: Add plugin hooks to transform patron and item barcodes

Some of our partners have unusual barcode requirements that have
required us to transform scanned barcodes using javascript. This is not
the most reliable method. It would make more sense to have Koha
transform the barcodes on the backend using a plugin. We should add
hooks to transform and generate new item and patron barcodes.

Test Plan:
1) Apply this patch
2) Download and install the Barcode Transformer plugin
   https://github.com/bywatersolutions/koha-plugin-barcode-transformer/releases/
3) Go to the plugin configuration page, set the configuration to the example configuration from the same page
4) In the patron search and anywhere else you can scan a patron
cardnumber, type in some cardnumbers but prefix them with A and postfix
them with A or B, e.g. A12345A, A12345B
5) Note the letters are removed by Koha!
6) Try a cardnumber like X123456Y
7) Note Koha converts it to Z13456Z
8) Try an item barcode now with the same A A|B format from step 4
9) The item barcode should have the letters removed by Koha as well!
Comment 7 Lucas Gass (lukeg) 2020-08-18 15:59:54 UTC
Works awesome! The QA tool raised a few issues:

 OK	C4/Circulation.pm
 OK	C4/ILSDI/Services.pm
 OK	C4/Items.pm
 OK	C4/SIP/Sip/MsgType.pm
 OK	Koha/Item.pm
 OK	Koha/Patron.pm
 OK	Koha/Patron/Attribute.pm
 FAIL	cataloguing/additem.pl
   FAIL	  valid
		Global symbol "$addedolditem" requires explicit package name (did you forget to declare "my $addedolditem"?)
		Global symbol "$addedolditem" requires explicit package name (did you forget to declare "my $addedolditem"?)

 OK	circ/circulation.pl
 OK	circ/returns.pl
 OK	members/memberentry.pl
 OK	offline_circ/process_koc.pl
 OK	opac/sco/sco-main.pl
 OK	t/db_dependent/Koha/Plugins/Plugins.t
 FAIL	t/lib/Koha/Plugin/Test.pm
   FAIL	  critic
		# Variables::ProhibitUnusedVariables: Got 1 violation(s).

 FAIL	tools/batchMod.pl
   FAIL	  valid
		Global symbol "$barcode" requires explicit package name (did you forget to declare "my $barcode"?)
		tools/batchMod.pl had compilation errors.

 OK	tools/inventory.pl
Comment 8 Kyle M Hall (khall) 2020-08-21 15:05:24 UTC
Created attachment 108831 [details] [review]
Bug 25712: (QA follow-up) Fix QA script warnings
Comment 9 Kyle M Hall (khall) 2020-08-21 15:06:31 UTC
(In reply to Lucas Gass from comment #7)
>  FAIL	cataloguing/additem.pl
>    FAIL	  valid
> 		Global symbol "$addedolditem" requires explicit package name (did you
> forget to declare "my $addedolditem"?)
> 		Global symbol "$addedolditem" requires explicit package name (did you
> forget to declare "my $addedolditem"?)

Fixed!

>  FAIL	t/lib/Koha/Plugin/Test.pm
>    FAIL	  critic
> 		# Variables::ProhibitUnusedVariables: Got 1 violation(s).

This one's a false alarm and can be ignored.
 
>  FAIL	tools/batchMod.pl
>    FAIL	  valid
> 		Global symbol "$barcode" requires explicit package name (did you forget to
> declare "my $barcode"?)
> 		tools/batchMod.pl had compilation errors.

Fixed!
Comment 10 Lucas Gass (lukeg) 2020-08-24 23:33:35 UTC
Created attachment 109051 [details] [review]
Bug 25712: Add plugin hooks to transform patron and item barcodes

Some of our partners have unusual barcode requirements that have
required us to transform scanned barcodes using javascript. This is not
the most reliable method. It would make more sense to have Koha
transform the barcodes on the backend using a plugin. We should add
hooks to transform and generate new item and patron barcodes.

Test Plan:
1) Apply this patch
2) Download and install the Barcode Transformer plugin
   https://github.com/bywatersolutions/koha-plugin-barcode-transformer/releases/
3) Go to the plugin configuration page, set the configuration to the example configuration from the same page
4) In the patron search and anywhere else you can scan a patron
cardnumber, type in some cardnumbers but prefix them with A and postfix
them with A or B, e.g. A12345A, A12345B
5) Note the letters are removed by Koha!
6) Try a cardnumber like X123456Y
7) Note Koha converts it to Z13456Z
8) Try an item barcode now with the same A A|B format from step 4
9) The item barcode should have the letters removed by Koha as well!

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 11 Lucas Gass (lukeg) 2020-08-24 23:33:38 UTC
Created attachment 109052 [details] [review]
Bug 25712: (QA follow-up) Fix QA script warnings

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 12 Katrin Fischer 2020-08-29 11:16:47 UTC
I feel like this might have been better as 2 patches - cardnumbers and item barcodes separately. It touches a lot of the code, including SIP2, offline circulation etc.

 With this patch applied, but without any plugin installed:

1) When a barcode is not found, there is no error message, but only a page reload.

2) A patron search with the correct cardnumber (42 for sample data) in the checkout tab no longer brings up the patron.

I think maybe we need to check for a plugin installed?
Comment 13 Kyle M Hall (khall) 2020-09-02 13:36:21 UTC
Moved to bugs 26351 and 26352