Bug 39313: Make OpacTrustedCheckout self-checkout modal accept valid barcode

This patch fixes a regression introduced by Bug 38505.

To test:

1. Enabled OpacTrustedCheckout system preference
2. Search for an item and get the barcode
3. Go to the OPAC
4. Click the Self-checkout button at the top
5. Enter the barcode and submit
6. Notice you are given an error UNKNOWN_BARCODE and the item is not checked out

7. Apply the patch and restart services

8. Repeat steps 4-6 and confirm you are able to successfully check out the item
9. Test submitting the modal with no barcode entered - confirm you are shown an appropriate error
10. Test with a fake barcode that does not exist - confirm you are shown an appropriate error

11. Run tests to confirm no regressions
prove t/db_dependent/Circulation*
prove t/db_dependent/DecreaseLoanHighHolds.t
prove t/db_dependent/rollingloans.t
prove t/db_dependent/api/v1/checkouts.t
prove t/db_dependent/Patron/Borrower_PrevCheckout.t
prove t/db_dependent/Koha/ILL/Requests.t

Sponsored-by: Reserve Bank of New Zealand
Signed-off-by: Magnus Enger <magnus@libriotech.no>
Works as advertised, including the tests.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 2b770e5e77)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Aleisha Amohia 2025-03-12 03:45:30 +00:00 committed by Fridolin Somers
parent bda71423bf
commit d20b4d554d
1 changed files with 4 additions and 2 deletions

View File

@ -780,8 +780,10 @@ sub CanBookBeIssued {
my $onsite_checkout = $params->{onsite_checkout} || 0;
my $override_high_holds = $params->{override_high_holds} || 0;
my $item_object = !$barcode ? undef : $params->{item}
// Koha::Items->find( { barcode => $barcode } );
my $item_object = $params->{item};
if ( !$item_object and $barcode ) {
$item_object = Koha::Items->find( { barcode => $barcode } );
}
# MANDATORY CHECKS - unless item exists, nothing else matters
unless ( $item_object ) {