Bugzilla – Attachment 149826 Details for
Bug 33098
Revert suggestion status to 'Accepted' when orders made from a suggestion are cancelled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33098: Revert suggestion status when orders are cancelled
Bug-33098-Revert-suggestion-status-when-orders-are.patch (text/plain), 4.38 KB, created by
Victor Grousset/tuxayo
on 2023-04-18 18:45:05 UTC
(
hide
)
Description:
Bug 33098: Revert suggestion status when orders are cancelled
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2023-04-18 18:45:05 UTC
Size:
4.38 KB
patch
obsolete
>From 09b31062c62ec5954e1773cc0f638286bd2fc39c Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Wed, 1 Mar 2023 01:02:01 +0000 >Subject: [PATCH] Bug 33098: Revert suggestion status when orders are cancelled > >This enhancement will revert the status of a suggestion from ORDERED to >ACCEPTED when an order made from a suggestion is cancelled. > >To test: >1. Log into the OPAC and go to purchase suggestions >2. Add a new purchase suggestion >3. Log into the staff interface. The suggestion will show on the home >page >4. Select the suggestion and mark it as Accepted >5. Go to Acquisitions. Find or create a basket >6. Add an order to the basket from a suggestion >7. You'll be redirected to the suggestions page. Click the order button >next to your suggestion >8. Fill out the order details as normal and confirm the order. >9. In a new tab, go to the suggestions management page and confirm the >suggestion now shows as ORDERED. >10. In the other tab with your basket, cancel the order you just made >from the suggestion. >11. Refresh the suggestions management tab. Confirm the suggestion now >shows as ACCEPTED. >12. Confirm tests pass t/db_dependent/Koha/Acquisition/Order.t > >Sponsored-by: Waikato Institute of Technology >Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com> >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > Koha/Acquisition/Order.pm | 13 ++++++++ > t/db_dependent/Koha/Acquisition/Order.t | 43 ++++++++++++++++++++++++- > 2 files changed, 55 insertions(+), 1 deletion(-) > >diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm >index c73f977791..444f9e6bec 100644 >--- a/Koha/Acquisition/Order.pm >+++ b/Koha/Acquisition/Order.pm >@@ -21,6 +21,7 @@ use Carp qw( croak ); > > use C4::Biblio qw( DelBiblio ); > use C4::Acquisition; >+use C4::Suggestions qw( ModSuggestion ); > > use Koha::Acquisition::Baskets; > use Koha::Acquisition::Funds; >@@ -143,6 +144,18 @@ sub cancel { > } > } > >+ # If ordered from a suggestion, revert the suggestion status to ACCEPTED >+ my $suggestion = Koha::Suggestions->find({ biblionumber => $self->biblionumber, status => "ORDERED" }); >+ if ( $suggestion and $suggestion->id ) { >+ ModSuggestion( >+ { >+ suggestionid => $suggestion->id, >+ biblionumber => $self->biblionumber, >+ STATUS => 'ACCEPTED', >+ } >+ ); >+ } >+ > my $biblio = $self->biblio; > if ( $biblio and $delete_biblio ) { > >diff --git a/t/db_dependent/Koha/Acquisition/Order.t b/t/db_dependent/Koha/Acquisition/Order.t >index 4d96e3b7d9..1aea49d9c4 100755 >--- a/t/db_dependent/Koha/Acquisition/Order.t >+++ b/t/db_dependent/Koha/Acquisition/Order.t >@@ -624,7 +624,7 @@ subtest 'filter_by_current & filter_by_cancelled' => sub { > > subtest 'cancel() tests' => sub { > >- plan tests => 54; >+ plan tests => 56; > > $schema->storage->txn_begin; > >@@ -860,6 +860,47 @@ subtest 'cancel() tests' => sub { > @messages = @{ $order->object_messages }; > is( scalar @messages, 0, 'No errors' ); > >+ # Scenario: >+ # * order made from a suggestion with same biblionumber >+ # => order is cancelled >+ # => suggestion status is changed to ACCEPTED >+ >+ $item = $builder->build_sample_item; >+ $biblio_id = $item->biblionumber; >+ >+ # Add the suggestion >+ my $suggestion = $builder->build_object( >+ { >+ class => 'Koha::Suggestions', >+ value => { >+ biblionumber => $biblio_id, >+ suggesteddate => dt_from_string, >+ STATUS => 'ORDERED', >+ archived => 0, >+ } >+ } >+ ); >+ >+ $order = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { >+ orderstatus => 'new', >+ biblionumber => $biblio_id, >+ datecancellationprinted => undef, >+ cancellationreason => undef, >+ } >+ } >+ ); >+ >+ $order->cancel({ reason => $reason }) >+ ->discard_changes; >+ >+ $suggestion = Koha::Suggestions->find( $suggestion->id ); >+ >+ is( $order->orderstatus, 'cancelled', 'Order is marked as cancelled' ); >+ is( $suggestion->STATUS, 'ACCEPTED', 'Suggestion status is correctly reverted after order is cancelled' ); >+ > # Scenario: > # * order with two items attached > # * one of the items is on loan >-- >2.40.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33098
:
147526
| 149826