Bug 29808 - Stock rotation fails to advance when an item is checked out from the branch that is the next stage
Summary: Stock rotation fails to advance when an item is checked out from the branch t...
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Nick Clemens
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-06 12:27 UTC by Nick Clemens
Modified: 2022-12-12 21:24 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00,21.11.03,21.05.11


Attachments
Bug 29808: Unit tests (2.15 KB, patch)
2022-01-06 12:43 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 29808: Do not receive transfer for checked out items (1.83 KB, patch)
2022-01-06 12:43 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 29808: Unit tests (2.22 KB, patch)
2022-01-06 13:42 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 29808: Do not receive transfer for checked out items (1.89 KB, patch)
2022-01-06 13:42 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens 2022-01-06 12:27:31 UTC
When an item is advanced we generate a transfer to the next branch.

If the item is already at that branch we receive the transfer

If an item is issued, an exception is thrown when receiving a transfer

To recreate:
1 - Enable  StockRotation system preference
2 - Browse to Tools->Stock rotation->New Rota and create a new rota, set as cyclical
3 - Manage->stages and add two stages, each with 0 day duration
4 - Manage->items - add an item
5 - Checkout the item from the first branch of rotation
6 - Tools->Stock rotation->Manage->items->move to next stage
7 - Error:
    [Transfer item is currently checked out] at /usr/share/perl5/Exception/Class/Base.pm line 88
Comment 1 Nick Clemens 2022-01-06 12:43:31 UTC
Created attachment 129061 [details] [review]
Bug 29808: Unit tests
Comment 2 Nick Clemens 2022-01-06 12:43:34 UTC
Created attachment 129062 [details] [review]
Bug 29808: Do not receive transfer for checked out items

This patch adds a check to StockRotationItem->advance to check if an
item is checked out from the destination branch. If so, we do not receive the transfer

To test:
 1 - Enable StockRotation system preference
 2 - Browse to Tools->Stock rotation->New Rota and create a new rota, set as cyclical
 3 - Manage->stages and add two stages, each with 0 day duration
 4 - Manage->items - add an item
 5 - Checkout the item from the first branch of rotation
 6 - Tools->Stock rotation->Manage->items->move to next stage
 7 - Error:
    [Transfer item is currently checked out] at /usr/share/perl5/Exception/Class/Base.pm line 88
 8 - Check in the item at first branch
 9 - Checkout the item from the second stage branch
10 - Apply patch
11 - Tools->Stock rotation->Manage->items->move to next stage
12 - No error!
13 - Check in item at second branch
14 - Checkout from first branch
15 - Tools->Stock rotation->Manage->items->move to next stage
16 - Still no error!
Comment 3 Martin Renvoize 2022-01-06 13:42:53 UTC
Created attachment 129082 [details] [review]
Bug 29808: Unit tests

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2022-01-06 13:42:57 UTC
Created attachment 129083 [details] [review]
Bug 29808: Do not receive transfer for checked out items

This patch adds a check to StockRotationItem->advance to check if an
item is checked out from the destination branch. If so, we do not receive the transfer

To test:
 1 - Enable StockRotation system preference
 2 - Browse to Tools->Stock rotation->New Rota and create a new rota, set as cyclical
 3 - Manage->stages and add two stages, each with 0 day duration
 4 - Manage->items - add an item
 5 - Checkout the item from the first branch of rotation
 6 - Tools->Stock rotation->Manage->items->move to next stage
 7 - Error:
    [Transfer item is currently checked out] at /usr/share/perl5/Exception/Class/Base.pm line 88
 8 - Check in the item at first branch
 9 - Checkout the item from the second stage branch
10 - Apply patch
11 - Tools->Stock rotation->Manage->items->move to next stage
12 - No error!
13 - Check in item at second branch
14 - Checkout from first branch
15 - Tools->Stock rotation->Manage->items->move to next stage
16 - Still no error!

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 5 Martin Renvoize 2022-01-06 13:43:17 UTC
Going straight for QA on this one..
Comment 6 Martin Renvoize 2022-01-06 13:44:08 UTC
Fix works as expected and I can see exactly how/where I introduced the issue (Thanks for spotting and fixing it Nick!).

Covered by new unit tests, tests passing, no regressions found and fixes the bug reported.

QA script also happy, Passing QA.
Comment 7 Fridolin Somers 2022-01-18 00:56:49 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 8 Kyle M Hall 2022-02-04 19:01:54 UTC
Pushed to 21.11.x for 21.11.03
Comment 9 Andrew Fuerste-Henry 2022-02-11 15:39:39 UTC
Pushed to 21.05.x for 21.05.11
Comment 10 Victor Grousset/tuxayo 2022-02-20 13:19:28 UTC
Can't backport to 20.11.x: can't solve a conflict.
If there is an interest in having this backported, please submit a patch for 20.11.

It seems to be due to Bug 24446 missing and more importantly Bug 22569. So maybe 20.11. isn't even affected.