Bug 31930

Summary: Ignore whitespace before and after barcodes when adding items to rotating collections
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: ToolsAssignee: Yvonne Waterman <yvonnewaterman>
Status: Pushed to stable --- QA Contact: Lucas Gass (lukeg) <lucas>
Severity: trivial    
Priority: P5 - low CC: aleisha, david, lucas, yanjun.li, yvonnewaterman
Version: MainKeywords: Academy
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Trivial patch Documentation contact:
Documentation submission: Text to go in the release notes:
This fixes adding or removing items to a rotating collection (Tools > Patrons and circulation > Rotating collections). If a barcode has a space before it, it is now ignored instead of generating an error message.
Version(s) released in:
25.11.00,25.05.03
Circulation function:
Attachments: Bug 31930: Ignore whitespace before and after barcodes
Bug 31930: Ignore whitespace before and after barcodes
Bug 31930: Ignore whitespace before and after barcodes
Bug 31930: Ignore whitespace before and after barcodes

Description Katrin Fischer 2022-10-23 13:31:57 UTC
When you add items to a rotating collection by copy and pasting the barcode, there will often be whitespace causing a 'barcode not found' error. We should automatically remove/ignore this leading/trailing whitespace as we do in other forms like the checkout/checkin forms.
Comment 1 Yanjun Li 2024-10-25 20:01:43 UTC
Hi Katrin, the whitespace doesn't affect the submission in the rotating collection page while adding new collection on my side. Let me know if you still have this issue.
Comment 2 Aleisha Amohia 2025-07-14 01:32:01 UTC
Can confirm that barcode whitespace is still not handled well in upstream

To reproduce:

1. Go to Tools -> Rotating collections
2. Create a rotating collection
3. Chose Actions -> Manage items
4. Paste a barcode and put some spaces around it, for example "          39999000010053             "
5. Click Submit => Shown an error, no item with matching barcode found, though the barcode is printed without all the whitespace
Comment 3 Yvonne Waterman 2025-07-17 23:49:16 UTC
Created attachment 184263 [details] [review]
Bug 31930: Ignore whitespace before and after barcodes

Decoded the barcode in add items to collection.

Test plan:
1. Go to Tools -> Rotating collections
2. Create a rotating collection
3. Chose Actions -> Manage items
4. Paste a barcode and put some spaces around it, for example "          39999000010053             "
5. Click Submit => Shown an error, no item with matching barcode found, though the barcode is printed without all the whitespace
6. Apply patch
7. Repeat steps 1 - 5, barcode should be accepted
Comment 4 Yvonne Waterman 2025-07-17 23:49:51 UTC
Created attachment 184264 [details] [review]
Bug 31930: Ignore whitespace before and after barcodes

Decoded the barcode in add items to collection.

Test plan:
1. Go to Tools -> Rotating collections
2. Create a rotating collection
3. Chose Actions -> Manage items
4. Paste a barcode and put some spaces around it, for example "          39999000010053             "
5. Click Submit => Shown an error, no item with matching barcode found, though the barcode is printed without all the whitespace
6. Apply patch
7. Repeat steps 1 - 5, barcode should be accepted
Comment 5 David Nind 2025-07-18 04:24:13 UTC
Created attachment 184274 [details] [review]
Bug 31930: Ignore whitespace before and after barcodes

Decoded the barcode in add items to collection.

Test plan:
1. Go to Tools -> Rotating collections
2. Create a rotating collection
3. Chose Actions -> Manage items
4. Paste a barcode and put some spaces around it, for example "          39999000010053             "
5. Click Submit => Shown an error, no item with matching barcode found, though the barcode is printed without all the whitespace
6. Apply patch
7. Repeat steps 1 - 5, barcode should be accepted

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 David Nind 2025-07-18 04:30:17 UTC
Nice work Yvonne, and thanks for the patch!

I've added a draft release note.

David Nind

Testing notes (using koha-testing-docker):
1. Before the patch, I was able to successfully add a barcode with spaces after it, but got an error if there were spaces before it.
2. After the patch, things work as expected.
3. Also, not related to this bug, if you remove an item using the action from the table (instead of pasting a barcode into the barcode field), the "Remove item from collection" remains ticked. So another bug to create.
Comment 7 Lucas Gass (lukeg) 2025-07-25 15:13:03 UTC
Created attachment 184647 [details] [review]
Bug 31930: Ignore whitespace before and after barcodes

Decoded the barcode in add items to collection.

Test plan:
1. Go to Tools -> Rotating collections
2. Create a rotating collection
3. Chose Actions -> Manage items
4. Paste a barcode and put some spaces around it, for example "          39999000010053             "
5. Click Submit => Shown an error, no item with matching barcode found, though the barcode is printed without all the whitespace
6. Apply patch
7. Repeat steps 1 - 5, barcode should be accepted

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 8 Lucas Gass (lukeg) 2025-07-25 20:34:36 UTC
Nice work everyone!

Pushed to main for 25.11
Comment 9 Paul Derscheid 2025-08-22 08:27:08 UTC
Nice work everyone!

Pushed to 25.05.x