Bug 39313 - OpacTrustedCheckout self-checkout modal not checking out valid barcode
Summary: OpacTrustedCheckout self-checkout modal not checking out valid barcode
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low blocker
Assignee: Aleisha Amohia
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
Depends on: 38505
Blocks: 38184
  Show dependency treegraph
 
Reported: 2025-03-12 03:31 UTC by Aleisha Amohia
Modified: 2025-03-17 07:28 UTC (History)
1 user (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.05.00
Circulation function:


Attachments
Bug 39313: Make OpacTrustedCheckout self-checkout modal accept valid barcode (1.96 KB, patch)
2025-03-12 03:50 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 39313: Make OpacTrustedCheckout self-checkout modal accept valid barcode (2.05 KB, patch)
2025-03-12 07:47 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 39313: Make OpacTrustedCheckout self-checkout modal accept valid barcode (2.11 KB, patch)
2025-03-12 10:17 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 39313: Unit test for passing valid item object to CanBookBeIssued (1.66 KB, patch)
2025-03-14 00:09 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 39313: Unit test for passing valid item object to CanBookBeIssued (1.71 KB, patch)
2025-03-14 12:33 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 39313: Make OpacTrustedCheckout self-checkout modal accept valid barcode (2.11 KB, patch)
2025-03-14 13:10 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 39313: Unit test for passing valid item object to CanBookBeIssued (1.77 KB, patch)
2025-03-14 13:10 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Aleisha Amohia 2025-03-12 03:31:46 UTC
Entering a valid barcode into the self-checkout modal returns an error "Message code 'UNKNOWN_BARCODE' with data '1'"

Requires OpacTrustedCheckout to be enabled
Comment 1 Aleisha Amohia 2025-03-12 03:32:36 UTC
This is due to a change introduced in Bug 38505

kohadev-koha@kohadevbox:koha((v24.11.02-1))$ git checkout origin/main 
Previous HEAD position was 7707a62f91f Update release notes for 24.11.02 release
HEAD is now at cb89b42f817 Bug 38663: DBIC schema update
kohadev-koha@kohadevbox:koha((cb89b42f817...))$ git bisect start
status: waiting for both good and bad commits
kohadev-koha@kohadevbox:koha((cb89b42f817...)|BISECTING)$ git bisect bad
status: waiting for good commit(s), bad commit known
kohadev-koha@kohadevbox:koha((cb89b42f817...)|BISECTING)$ git bisect good v24.11.02-1 
Bisecting: a merge base must be tested
[9bbb73fa2682d9065f42ffde5fa4548dc8592d43] Koha 24.11 is here!
kohadev-koha@kohadevbox:koha((v24.11.00)|BISECTING)$ git bisect good
Bisecting: 553 revisions left to test after this (roughly 9 steps)
[c57cd77bd29e7da7f27333e7abb546f23421908b] Bug 38714: biblio-title-head.inc
kohadev-koha@kohadevbox:koha((c57cd77bd29...)|BISECTING)$ git bisect bad
Bisecting: 276 revisions left to test after this (roughly 8 steps)
[143220d0c6d2d82bc007be029221ee3ede676f2f] Bug 37832: Fix Rental discount to be decimal like other similar fields
kohadev-koha@kohadevbox:koha((143220d0c6d...)|BISECTING)$ git bisect bad
Bisecting: 138 revisions left to test after this (roughly 7 steps)
[4fb4b7527ef80519a6ff9c794505fc128d62c534] Bug 37761: Add focus on patron search when on the tab
kohadev-koha@kohadevbox:koha((4fb4b7527ef...)|BISECTING)$ git bisect good
Bisecting: 69 revisions left to test after this (roughly 6 steps)
[04c095c4734e6851637382e5c50081fd0933183c] Bug 34068: Add tests
kohadev-koha@kohadevbox:koha((04c095c4734...)|BISECTING)$ git bisect good
Bisecting: 34 revisions left to test after this (roughly 5 steps)
[9f5f4aa1d63f24c7aa84e2428f67825e6feba0b3] Bug 38503: Do not list the objects
kohadev-koha@kohadevbox:koha((9f5f4aa1d63...)|BISECTING)$ git bisect bad
Bisecting: 17 revisions left to test after this (roughly 4 steps)
[ecd0604a8ded12803846de6d3e7dac5e9eed2765] Bug 38505: CirculateILL: Add UNKNOWN_BARCODE warning message
kohadev-koha@kohadevbox:koha((ecd0604a8de...)|BISECTING)$ git bisect bad
Bisecting: 8 revisions left to test after this (roughly 3 steps)
[2a6bc075f6c7c7eadda044dda892d36997884f50] Bug 38751: Add tests
kohadev-koha@kohadevbox:koha((2a6bc075f6c...)|BISECTING)$ git bisect good
Bisecting: 4 revisions left to test after this (roughly 2 steps)
[c42cfecd43b36048414615622f7121c7de31e657] Bug 37448: Add build_sample_ill_request
kohadev-koha@kohadevbox:koha((c42cfecd43b...)|BISECTING)$ git bisect good
Bisecting: 2 revisions left to test after this (roughly 1 step)
[45626c75c4d83075892015233634106814f26942] Bug 38505: CanBookBeIssued preparation: Add tests for falsy barcode
kohadev-koha@kohadevbox:koha((45626c75c4d...)|BISECTING)$ git bisect good
Bisecting: 0 revisions left to test after this (roughly 1 step)
[90304e7632547fcb275d93a88afc88e4a52dd1ed] Bug 38505: ill-requests.tt: Use .alert-warning when .alert exists
kohadev-koha@kohadevbox:koha((90304e76325...)|BISECTING)$ git bisect bad
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[89b7f160a75e063582793a30636c137ddacdc96d] Bug 38505: CanBookBeIssued preparation: Appropriate behavior when barcode is falsy
kohadev-koha@kohadevbox:koha((89b7f160a75...)|BISECTING)$ git bisect bad
89b7f160a75e063582793a30636c137ddacdc96d is the first bad commit
commit 89b7f160a75e063582793a30636c137ddacdc96d
Author: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Date:   Thu Nov 21 14:23:19 2024 -0100

    Bug 38505: CanBookBeIssued preparation: Appropriate behavior when barcode is falsy
    
    Before applying this patch, apply the CanBookBeIssued preparation: tests patch and run that,
    Verify it fails, apply this patch. Run that same tests file again.
    
    ----- About this change -----
    
    CanBookBeIssued wants to find one item given a barcode.
    If a falsy (undef, empty) barcode is supplied, UNKNOWN_BARCODE should be returned.
    
    Ensure this change does not introduce any 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
    
    Signed-off-by: Ray Delahunty <r.delahunty@arts.ac.uk>
    Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
    Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>

 C4/Circulation.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 2 Aleisha Amohia 2025-03-12 03:50:14 UTC Comment hidden (obsolete)
Comment 3 Magnus Enger 2025-03-12 07:47:35 UTC
Created attachment 179192 [details] [review]
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.
Comment 4 Martin Renvoize (ashimema) 2025-03-12 10:17:18 UTC
Created attachment 179196 [details] [review]
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>
Comment 5 Martin Renvoize (ashimema) 2025-03-12 10:27:45 UTC
We should add a unit test for this to prevent a future regression
Comment 6 Aleisha Amohia 2025-03-14 00:09:22 UTC
Created attachment 179296 [details] [review]
Bug 39313: Unit test for passing valid item object to CanBookBeIssued

rather than a barcode.

Will be tested within previous test plan.

Sponsored-by: Reserve Bank of New Zealand
Comment 7 Owen Leonard 2025-03-14 12:33:08 UTC
Created attachment 179324 [details] [review]
Bug 39313: Unit test for passing valid item object to CanBookBeIssued

rather than a barcode.

Will be tested within previous test plan.

Sponsored-by: Reserve Bank of New Zealand
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 8 Martin Renvoize (ashimema) 2025-03-14 13:10:03 UTC
Created attachment 179327 [details] [review]
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>
Comment 9 Martin Renvoize (ashimema) 2025-03-14 13:10:06 UTC
Created attachment 179328 [details] [review]
Bug 39313: Unit test for passing valid item object to CanBookBeIssued

rather than a barcode.

Will be tested within previous test plan.

Sponsored-by: Reserve Bank of New Zealand
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 10 Martin Renvoize (ashimema) 2025-03-14 13:10:25 UTC
Thankyou :)
Comment 11 Katrin Fischer 2025-03-17 07:28:56 UTC
Pushed for 25.05!

Well done everyone, thank you!