From 9c4cd7380ef358fef0953e4d861cf5a50aff3e83 Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Fri, 28 Jul 2023 15:39:38 +0000 Subject: [PATCH] Bug 33664: Add ability to cancel order lines in closed baskets At the moment it's only possible to cancel order lines while the basket is still open or from the pending orders page during processing a shipment. The latter requires you to add a shipment and fake an invoice. To make things easier we want to optionally allow cancelling order lines in closed baskets from the basket summary page. Before applying the patch: 1) Set up data * Create a new basket * Create a few order lines, at least 3 * Close the basket * Receive shipment and receive one order line 2) Verify current behaviour * On basket summary page: you cannot cancel while the basket is closed * On the pending orders page you can cancel Apply patch, run database update, restart_all 3) Verify new behaviour * Verify that nothing has changed on pending orders and basket summary * Switch new system preference CancelOrdersInClosedBaskets to "Allow" * Verify that pending orders hasn't changed a bit * Verify that you now can cancel your order lines in the closed basket Exception: the received order line should not be cancellable Test anything else that you think might make sense ;) Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi --- .../bug_33664_CancelOrdersInClosedBaskets.pl | 22 +++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../prog/en/modules/acqui/basket.tt | 96 +++++++++---------- .../admin/preferences/acquisitions.pref | 6 ++ 4 files changed, 77 insertions(+), 48 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_33664_CancelOrdersInClosedBaskets.pl diff --git a/installer/data/mysql/atomicupdate/bug_33664_CancelOrdersInClosedBaskets.pl b/installer/data/mysql/atomicupdate/bug_33664_CancelOrdersInClosedBaskets.pl new file mode 100755 index 0000000000..82b3e0c08c --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_33664_CancelOrdersInClosedBaskets.pl @@ -0,0 +1,22 @@ +use Modern::Perl; + +return { + bug_number => "33664", + description => "Allow cancelling of orders from closed baskets", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Do you stuffs here + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type` ) + VALUES + ('CancelOrdersInClosedBaskets', '0', NULL, 'Allow/Do not allow cancelling order lines in closed baskets.', 'YesNo') + } + ); + + # sysprefs + say $out "Added new system preference 'CancelOrdersInClosedBaskets'"; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 314efd51a8..50ab4e1521 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -130,6 +130,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('CanMarkHoldsToPullAsLost','do_not_allow','do_not_allow|allow|allow_and_notify','Add a button to the "Holds to pull" screen to mark an item as lost and notify the patron.','Choice'), ('canreservefromotherbranches','1','','With Independent branches on, can a user from one library place a hold on an item from another library','YesNo'), ('CardnumberLength', '', '', 'Set a length for card numbers with a maximum of 32 characters.', 'Free'), +('CancelOrdersInClosedBaskets', '0', NULL, 'Allow/Do not allow cancelling order lines in closed baskets.', 'YesNo'), ('casAuthentication','0','','Enable or disable CAS authentication','YesNo'), ('casLogout','0','','Does a logout from Koha should also log the user out of CAS?','YesNo'), ('casServerUrl','https://localhost:8443/cas','','URL of the cas server','Free'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt index 78e61ad302..1d5b546123 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -483,11 +483,11 @@ Supplier report [% END %] Place hold - [% IF ( active ) %] - [% UNLESS ( closedate ) %] + [% IF ( active && !closedate ) %] Modify - Cancel order - [% END %] + [% END %] + [% IF !closedate || Koha.Preference('CancelOrdersInClosedBaskets') %] + Cancel order [% END %] @@ -517,11 +517,11 @@   [% END %]   - [% IF ( active ) %] - [% UNLESS ( closedate ) %] -   -   - [% END %] + [% IF ( active && !closedate ) %] +   + [% END %] + [% IF !closedate || Koha.Preference('CancelOrdersInClosedBaskets') %] +   [% END %] [% END %] @@ -549,11 +549,11 @@   [% END %]   - [% IF ( active ) %] - [% UNLESS ( closedate ) %] -   -   - [% END %] + [% IF ( active && !closedate ) %] +   + [% END %] + [% IF !closedate || Koha.Preference('CancelOrdersInClosedBaskets') %] +   [% END %] @@ -686,42 +686,42 @@ [% END %] - [% IF ( active ) %] - [% UNLESS ( closedate ) %] - - [% UNLESS (books_loo.order_received) %] - Modify -
- Transfer + [% IF ( active && !closedate ) %] + + Modify + [% UNLESS (books_loo.order_received) %] +
+ Transfer + [% END %] + + [% END %] + [% IF ( !closedate || Koha.Preference('CancelOrdersInClosedBaskets') ) %] + + [% IF ( books_loo.orderstatus != "complete") %] + [% IF ( books_loo.left_holds_on_order ) %] + Can't cancel order
+ [% ELSE %] + Cancel order
[% END %] - - - [% IF ( books_loo.orderstatus != "complete") %] - [% IF ( books_loo.left_holds_on_order ) %] - Can't cancel order
- [% ELSE %] - Cancel order
- [% END %] - [% IF ( books_loo.can_del_bib ) %] - Cancel order and delete catalog record
- [% ELSE %] - Can't cancel order and delete catalog record
- [% END %] - [% IF ( books_loo.left_item ) %] - [% books_loo.items | html %] item(s) left
- [% END %] - [% IF ( books_loo.left_biblio ) %] - [% books_loo.biblios | html %] order(s) left
- [% END %] - [% IF ( books_loo.left_subscription ) %] - [% books_loo.subscriptions | html %] subscription(s) left
- [% END %] - [% IF ( books_loo.left_holds ) %] - [% books_loo.holds | html %] hold(s) left - [% END %] + [% IF ( books_loo.can_del_bib ) %] + Cancel order and delete catalog record
+ [% ELSE %] + Can't cancel order and delete catalog record
[% END %] - - [% END %] + [% IF ( books_loo.left_item ) %] + [% books_loo.items | html %] item(s) left
+ [% END %] + [% IF ( books_loo.left_biblio ) %] + [% books_loo.biblios | html %] order(s) left
+ [% END %] + [% IF ( books_loo.left_subscription ) %] + [% books_loo.subscriptions | html %] subscription(s) left
+ [% END %] + [% IF ( books_loo.left_holds ) %] + [% books_loo.holds | html %] hold(s) left + [% END %] + [% END %] + [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref index b184d6dbe1..5e8897e2c2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref @@ -20,6 +20,12 @@ Acquisitions: choices: 1: always ask for confirmation. 2: do not ask for confirmation. + - + - pref: CancelOrdersInClosedBaskets + choices: + 1: Allow + 0: "Don't allow" + - cancelling order lines in closed baskets. - - Show baskets - pref: AcqViewBaskets -- 2.39.5