From d20b4d554d2a8e4de394180d43eed2cb014dfe84 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 12 Mar 2025 03:45:30 +0000 Subject: [PATCH] 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 Works as advertised, including the tests. Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer (cherry picked from commit 2b770e5e770c174a092fa2d57048e7f61ced1523) Signed-off-by: Fridolin Somers --- C4/Circulation.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index ab8438ae67..f9f7c290ff 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -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 ) {