Skip to content

Commit 95b124b

Browse files
Alicia ZanggerAly Badr
authored andcommitted
circulation: fix 'cancel request' with multiple requests
* Allows the cancellation of a request when there are several requests on the item. * Closes rero#1303. Co-Authored-by: Alicia Zangger <[email protected]> Co-Authored-by: Aly Badr <[email protected]>
1 parent a52930f commit 95b124b

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

Diff for: rero_ils/modules/items/api/circulation.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -547,14 +547,15 @@ def checks_before_a_cancel_item_request(self, loan, **kwargs):
547547
# CANCEL_REQUEST_5_1_2: when item at desk with pending loan, cancel
548548
# the loan triggers an automatic validation of first pending loan.
549549
actions_to_execute['validate_first_pending'] = True
550-
elif loan['state'] == LoanState.PENDING and (
551-
LoanState.ITEM_AT_DESK in loans_list or
552-
LoanState.ITEM_ON_LOAN in loans_list or
553-
LoanState.ITEM_IN_TRANSIT_FOR_PICKUP in loans_list or
554-
LoanState.ITEM_IN_TRANSIT_TO_HOUSE in loans_list
555-
):
556-
# CANCEL_REQUEST_2_2, CANCEL_REQUEST_3_2, CANCEL_REQUEST_4_2,
557-
# CANCEL_REQUEST_5_2:
550+
elif loan['state'] == LoanState.PENDING and \
551+
any(state in loans_list for state in [
552+
LoanState.ITEM_AT_DESK,
553+
LoanState.ITEM_ON_LOAN,
554+
LoanState.ITEM_IN_TRANSIT_FOR_PICKUP,
555+
LoanState.ITEM_IN_TRANSIT_TO_HOUSE,
556+
LoanState.PENDING]):
557+
# CANCEL_REQUEST_1_2, CANCEL_REQUEST_2_2, CANCEL_REQUEST_3_2,
558+
# CANCEL_REQUEST_4_2 CANCEL_REQUEST_5_2:
558559
# canceling a pending loan does not affect the other active loans.
559560
actions_to_execute['cancel_loan'] = True
560561

Diff for: tests/ui/circulation/test_actions_cancel_request.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
def test_cancel_request_on_item_on_shelf(
3131
item_lib_martigny, item_on_shelf_martigny_patron_and_loan_pending,
32-
loc_public_martigny, librarian_martigny_no_email):
32+
loc_public_martigny, librarian_martigny_no_email,
33+
patron2_martigny_no_email):
3334
"""Test cancel request on an on_shelf item."""
3435
# the following tests the circulation action CANCEL_REQUEST_1_1
3536
# on_shelf item with no pending requests, not possible to cancel a request.
@@ -42,6 +43,17 @@ def test_cancel_request_on_item_on_shelf(
4243
# on_shelf item with pending requests, cancel a pending loan is possible.
4344
# the item remains on_shelf
4445
item, patron, loan = item_on_shelf_martigny_patron_and_loan_pending
46+
# add request for another patron
47+
params = {
48+
'patron_pid': patron2_martigny_no_email.pid,
49+
'transaction_location_pid': loc_public_martigny.pid,
50+
'transaction_user_pid': librarian_martigny_no_email.pid,
51+
'pickup_location_pid': loc_public_martigny.pid
52+
}
53+
item, requested_loan = item_record_to_a_specific_loan_state(
54+
item=item, loan_state=LoanState.PENDING,
55+
params=params, copy_item=False)
56+
# cancel request
4557
params = {
4658
'pid': loan.pid,
4759
'transaction_location_pid': loc_public_martigny.pid,

0 commit comments

Comments
 (0)