Bug 39717

Summary: Stock rotation stages cannot be moved
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: ToolsAssignee: Nick Clemens (kidclamp) <nick>
Status: Pushed to main --- QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: normal    
Priority: P5 - low CC: martin.renvoize
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
25.05.00
Circulation function:
Attachments: Bug 39717: Use numeric comparison for stock rotation stages
Bug 39717: Use numeric comparison for stock rotation stages
Bug 39717: Use numeric comparison for stock rotation stages

Description Nick Clemens (kidclamp) 2025-04-23 20:02:56 UTC
In the routine Koha::StockRotationStage->move_to we are doing a stringwise comparison of the position to move to, versus the count of stages

This works when we have a limited number of stages, but fails when we have many:

perl -e 'warn "Yes" if "3" le "26"'

It's not.

Changing to <= seems to fix this
Comment 1 Nick Clemens (kidclamp) 2025-04-23 20:13:56 UTC
Created attachment 181395 [details] [review]
Bug 39717: Use numeric comparison for stock rotation stages

To test:
 1 - Enable SotckRotation
     http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=StockRotation
 2 - Browse to "Cataloging -> StockRotation"
 3 - 'New rota' - fill out the form and save
 4 - Manage->stages
 5 - Add many stages, more than 10 at least
 6 - Try to move a stage form the bottom to position 3
 7 - Note message above list: Saving changes... Error: Bad Request
 8 - Apply patch, restart_all
 9 - Attempt to move stages, try many combinations
10 - Success!
Comment 2 Nick Clemens (kidclamp) 2025-04-23 20:14:22 UTC
Created attachment 181396 [details] [review]
Bug 39717: Use numeric comparison for stock rotation stages

To test:
 1 - Enable SotckRotation
     http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=StockRotation
 2 - Browse to "Cataloging -> StockRotation"
 3 - 'New rota' - fill out the form and save
 4 - Manage->stages
 5 - Add many stages, more than 10 at least
 6 - Try to move a stage form the bottom to position 3
 7 - Note message above list: Saving changes... Error: Bad Request
 8 - Apply patch, restart_all
 9 - Attempt to move stages, try many combinations
10 - Success!

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 3 Nick Clemens (kidclamp) 2025-04-23 20:14:46 UTC
Self SO, moving to QA, this is pretty straightforward
Comment 4 Martin Renvoize (ashimema) 2025-04-24 08:11:09 UTC
Created attachment 181401 [details] [review]
Bug 39717: Use numeric comparison for stock rotation stages

To test:
 1 - Enable SotckRotation
     http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=StockRotation
 2 - Browse to "Cataloging -> StockRotation"
 3 - 'New rota' - fill out the form and save
 4 - Manage->stages
 5 - Add many stages, more than 10 at least
 6 - Try to move a stage form the bottom to position 3
 7 - Note message above list: Saving changes... Error: Bad Request
 8 - Apply patch, restart_all
 9 - Attempt to move stages, try many combinations
10 - Success!

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Comment 5 Martin Renvoize (ashimema) 2025-04-24 08:12:21 UTC
Oops.. Passing QA
Comment 6 Katrin Fischer 2025-04-24 17:54:06 UTC
Pushed for 25.05!

Well done everyone, thank you!