Bug 26582

Summary: Add Koha::Acquisition::Basket->close
Product: Koha Reporter: Tomás Cohen Arazi <tomascohen>
Component: AcquisitionsAssignee: Tomás Cohen Arazi <tomascohen>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: andrewfh, jonathan.druart, katrin.fischer, lucas, martin.renvoize, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23971
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.11.00
Bug Depends on: 26515    
Bug Blocks: 23971, 26584    
Attachments: Bug 26582: Unit tests
Bug 26582: Add Koha::Acquisition::Basket->close
Bug 26582: Unit tests
Bug 26582: Add Koha::Acquisition::Basket->close
Bug 26582: Unit tests
Bug 26582: Add Koha::Acquisition::Basket->close
Bug 26582: (QA follow-up) Rename closed => is_closed

Description Tomás Cohen Arazi 2020-09-30 17:39:10 UTC
This method should implement the current behaviour:
- Mark all open orders as 'requested'
- Mark the basket as closed
Comment 1 Tomás Cohen Arazi 2020-09-30 17:48:45 UTC
Created attachment 111003 [details] [review]
Bug 26582: Unit tests
Comment 2 Tomás Cohen Arazi 2020-09-30 17:48:50 UTC
Created attachment 111004 [details] [review]
Bug 26582: Add Koha::Acquisition::Basket->close

This patch adds two methods to Koha::Acquisition::Basket:
- 'closed': that tells if the basket is closed
- 'close': that closes the basket

It inherits the behaviour from CloseBasket (as it actually makes sense).
It improves CloseBasket by wrapping the action inside a transaction. It
uses the $orders->update call with no_trigger as there's no trigger to
trigger and the update can be done on a single DB call.

A new exceptions file is added for basket-related exceptions. The only
specific exception that gets added is
Koha::Exceptions::Acquisition::Basket::AlreadyClosed

To test:
1. Apply this patches
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Acquisition/Basket.t
=> SUCCESS: Tests pass!
3. Sign off :-D
Comment 3 Martin Renvoize 2020-10-01 11:26:01 UTC
Created attachment 111032 [details] [review]
Bug 26582: Unit tests

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2020-10-01 11:26:08 UTC
Created attachment 111033 [details] [review]
Bug 26582: Add Koha::Acquisition::Basket->close

This patch adds two methods to Koha::Acquisition::Basket:
- 'closed': that tells if the basket is closed
- 'close': that closes the basket

It inherits the behaviour from CloseBasket (as it actually makes sense).
It improves CloseBasket by wrapping the action inside a transaction. It
uses the $orders->update call with no_trigger as there's no trigger to
trigger and the update can be done on a single DB call.

A new exceptions file is added for basket-related exceptions. The only
specific exception that gets added is
Koha::Exceptions::Acquisition::Basket::AlreadyClosed

To test:
1. Apply this patches
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Acquisition/Basket.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 5 Martin Renvoize 2020-10-01 11:26:45 UTC
Works as expected, tests pass..  QA Script throws a false failure (POD).

Signing off
Comment 6 Katrin Fischer 2020-10-13 11:18:40 UTC
Created attachment 111528 [details] [review]
Bug 26582: Unit tests

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 7 Katrin Fischer 2020-10-13 11:18:46 UTC
Created attachment 111529 [details] [review]
Bug 26582: Add Koha::Acquisition::Basket->close

This patch adds two methods to Koha::Acquisition::Basket:
- 'closed': that tells if the basket is closed
- 'close': that closes the basket

It inherits the behaviour from CloseBasket (as it actually makes sense).
It improves CloseBasket by wrapping the action inside a transaction. It
uses the $orders->update call with no_trigger as there's no trigger to
trigger and the update can be done on a single DB call.

A new exceptions file is added for basket-related exceptions. The only
specific exception that gets added is
Koha::Exceptions::Acquisition::Basket::AlreadyClosed

To test:
1. Apply this patches
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Acquisition/Basket.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 8 Jonathan Druart 2020-10-15 14:28:13 UTC
"closed" should be "is_closed" (and we need a guideline for this).
Comment 9 Tomás Cohen Arazi 2020-10-15 14:33:50 UTC
Created attachment 111748 [details] [review]
Bug 26582: (QA follow-up) Rename closed => is_closed

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 10 Jonathan Druart 2020-11-05 14:25:30 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 11 Lucas Gass 2020-11-16 21:58:54 UTC
enhancement will not be backported to 20.05.x