From b315bc676b16cf95a67be1151060d1fe05fab722 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 ;) --- .../bug_33664_CancelOrdersInClosedBaskets.pl | 22 +++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../prog/en/modules/acqui/basket.tt | 94 +++++++++---------- .../admin/preferences/acquisitions.pref | 6 ++ 4 files changed, 76 insertions(+), 47 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 30197591a8..82de5eadb2 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -127,6 +127,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 604d1a2f36..868e22762e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -475,11 +475,11 @@ [% IF Koha.Preference('EDIFACT') && ediaccount %] Supplier report [% END %] - [% IF ( active ) %] - [% UNLESS ( closedate ) %] - Modify - Cancel order - [% END %] + [% IF ( active && !closedate ) %] +   + [% END %] + [% IF !closedate || Koha.Preference('CancelOrdersInClosedBaskets') %] +   [% END %] @@ -505,11 +505,11 @@ [% IF Koha.Preference('EDIFACT') && ediaccount %]   [% END %] - [% IF ( active ) %] - [% UNLESS ( closedate ) %] + [% IF ( active && !closedate ) %]   -   - [% END %] + [% END %] + [% IF !closedate || Koha.Preference('CancelOrdersInClosedBaskets') %] +   [% END %] [% END %] @@ -533,11 +533,11 @@ [% IF Koha.Preference('EDIFACT') && ediaccount %]   [% END %] - [% IF ( active ) %] - [% UNLESS ( closedate ) %] + [% IF ( active && !closedate ) %]   -   - [% END %] + [% END %] + [% IF !closedate || Koha.Preference('CancelOrdersInClosedBaskets') %] +   [% END %] @@ -653,42 +653,42 @@ [% IF Koha.Preference('EDIFACT') && ediaccount %] [% books_loo.suppliers_report | html %] [% END %] - [% IF ( active ) %] - [% UNLESS ( closedate ) %] - - Modify - [% UNLESS (books_loo.order_received) %] -
- 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 4e2c18512e..70f6b9dbc5 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.30.2