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 <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Katrin Fischer 2023-07-28 15:39:38 +00:00 committed by Tomas Cohen Arazi
parent 508d55eb7b
commit 9c4cd7380e
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
4 changed files with 77 additions and 48 deletions

View File

@ -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'";
},
};

View File

@ -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'),

View File

@ -483,11 +483,11 @@
<th>Supplier report</th>
[% END %]
<th class="NoSort">Place hold</th>
[% IF ( active ) %]
[% UNLESS ( closedate ) %]
[% IF ( active && !closedate ) %]
<th class="NoSort">Modify</th>
<th class="NoSort">Cancel order</th>
[% END %]
[% END %]
[% IF !closedate || Koha.Preference('CancelOrdersInClosedBaskets') %]
<th class="NoSort">Cancel order</th>
[% END %]
</tr>
</thead>
@ -517,11 +517,11 @@
<th>&nbsp;</th>
[% END %]
<th>&nbsp;</th>
[% IF ( active ) %]
[% UNLESS ( closedate ) %]
<th>&nbsp;</th>
<th>&nbsp;</th>
[% END %]
[% IF ( active && !closedate ) %]
<th>&nbsp;</th>
[% END %]
[% IF !closedate || Koha.Preference('CancelOrdersInClosedBaskets') %]
<th>&nbsp;</th>
[% END %]
</tr>
[% END %]
@ -549,11 +549,11 @@
<th>&nbsp;</th>
[% END %]
<th>&nbsp;</th>
[% IF ( active ) %]
[% UNLESS ( closedate ) %]
<th>&nbsp;</th>
<th>&nbsp;</th>
[% END %]
[% IF ( active && !closedate ) %]
<th>&nbsp;</th>
[% END %]
[% IF !closedate || Koha.Preference('CancelOrdersInClosedBaskets') %]
<th>&nbsp;</th>
[% END %]
</tr>
</tfoot>
@ -686,42 +686,42 @@
</a>
[% END %]
</td>
[% IF ( active ) %]
[% UNLESS ( closedate ) %]
<td>
[% UNLESS (books_loo.order_received) %]
<a href="neworderempty.pl?ordernumber=[% books_loo.ordernumber | uri %]&amp;booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Modify</a>
<br />
<a href="#" class="transfer_order" data-ordernumber="[% books_loo.ordernumber | html %]">Transfer</a>
[% IF ( active && !closedate ) %]
<td>
<a href="neworderempty.pl?ordernumber=[% books_loo.ordernumber | uri %]&amp;booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Modify</a>
[% UNLESS (books_loo.order_received) %]
<br />
<a href="#" class="transfer_order" data-ordernumber="[% books_loo.ordernumber | html %]">Transfer</a>
[% END %]
</td>
[% END %]
[% IF ( !closedate || Koha.Preference('CancelOrdersInClosedBaskets') ) %]
<td>
[% IF ( books_loo.orderstatus != "complete") %]
[% IF ( books_loo.left_holds_on_order ) %]
<span class="button" title="Can't cancel order, ([% books_loo.holds_on_order | html %]) holds are linked with this order. Cancel holds first">Can't cancel order</span><br>
[% ELSE %]
<a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=[% books_loo.ordernumber | uri %]&biblionumber=[% books_loo.biblionumber | uri %]&basketno=[% basketno | uri %]&referrer=/cgi-bin/koha/acqui/basket.pl%3Fbasketno=[% basketno | uri %]" class="button">Cancel order</a><br>
[% END %]
</td>
<td>
[% IF ( books_loo.orderstatus != "complete") %]
[% IF ( books_loo.left_holds_on_order ) %]
<span class="button" title="Can't cancel order, ([% books_loo.holds_on_order | html %]) holds are linked with this order. Cancel holds first">Can't cancel order</span><br>
[% ELSE %]
<a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=[% books_loo.ordernumber | uri %]&biblionumber=[% books_loo.biblionumber | uri %]&basketno=[% basketno | uri %]&referrer=/cgi-bin/koha/acqui/basket.pl%3Fbasketno=[% basketno | uri %]" class="button">Cancel order</a><br>
[% END %]
[% IF ( books_loo.can_del_bib ) %]
<a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=[% books_loo.ordernumber | uri %]&biblionumber=[% books_loo.biblionumber | uri %]&basketno=[% basketno | uri %]&del_biblio=1&referrer=/cgi-bin/koha/acqui/basket.pl%3Fbasketno=[% basketno | uri %]" class="button">Cancel order and delete catalog record</a><br>
[% ELSE %]
<span class="button" title="Can't delete catalog record, see constraints below">Can't cancel order and delete catalog record</span><br>
[% END %]
[% IF ( books_loo.left_item ) %]
<strong title="Can't delete catalog record, because of [% books_loo.items | html %] existing hold(s)" >[% books_loo.items | html %] item(s) left</strong><br>
[% END %]
[% IF ( books_loo.left_biblio ) %]
<strong title="Can't delete catalog record, delete other orders linked to it first">[% books_loo.biblios | html %] order(s) left</strong><br>
[% END %]
[% IF ( books_loo.left_subscription ) %]
<strong title="Can't delete catalog record, delete subscriptions first">[% books_loo.subscriptions | html %] subscription(s) left</strong><br>
[% END %]
[% IF ( books_loo.left_holds ) %]
<strong title="Can't delete catalog record or order, cancel holds first">[% books_loo.holds | html %] hold(s) left</strong>
[% END %]
[% IF ( books_loo.can_del_bib ) %]
<a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=[% books_loo.ordernumber | uri %]&biblionumber=[% books_loo.biblionumber | uri %]&basketno=[% basketno | uri %]&del_biblio=1&referrer=/cgi-bin/koha/acqui/basket.pl%3Fbasketno=[% basketno | uri %]" class="button">Cancel order and delete catalog record</a><br>
[% ELSE %]
<span class="button" title="Can't delete catalog record, see constraints below">Can't cancel order and delete catalog record</span><br>
[% END %]
</td>
[% END %]
[% IF ( books_loo.left_item ) %]
<strong title="Can't delete catalog record, because of [% books_loo.items | html %] existing hold(s)" >[% books_loo.items | html %] item(s) left</strong><br>
[% END %]
[% IF ( books_loo.left_biblio ) %]
<strong title="Can't delete catalog record, delete other orders linked to it first">[% books_loo.biblios | html %] order(s) left</strong><br>
[% END %]
[% IF ( books_loo.left_subscription ) %]
<strong title="Can't delete catalog record, delete subscriptions first">[% books_loo.subscriptions | html %] subscription(s) left</strong><br>
[% END %]
[% IF ( books_loo.left_holds ) %]
<strong title="Can't delete catalog record or order, cancel holds first">[% books_loo.holds | html %] hold(s) left</strong>
[% END %]
[% END %]
</td>
[% END %]
</tr>
[% END %]

View File

@ -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