Bug 27753 - Automate resolution of return claim when checking in an item
Summary: Automate resolution of return claim when checking in an item
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Laura Escamilla
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
Depends on:
Blocks: 27919 38246
  Show dependency treegraph
 
Reported: 2021-02-22 15:59 UTC by Andrew Fuerste-Henry
Modified: 2024-10-29 12:13 UTC (History)
15 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact: Caroline Cyr La Rose
Documentation submission: https://gitlab.com/koha-community/koha-manual/-/merge_requests/966
Text to go in the release notes:
This patch adds two new system preferences, ‘AutoClaimReturnStatusOnCheckin’ and ‘AutoClaimReturnStatusOnCheckout’, to allow automatic resolution of return claims on checkin and/or on checkout of the item claimed as returned. Both system preferences allow choosing between "Found in library" or "Returned by patron" as reasons for the resolution. The default value for both preferences is empty, meaning automatic resolution on checkin/checkout is turned off by default. **Sponsored by** *Altadena Library District*
Version(s) released in:
24.05.00
Circulation function:


Attachments
Bug 27753: Added two new system preferences for automatically resolving claims. (9.38 KB, patch)
2024-02-27 20:17 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Added two new system preferences for automatically resolving claims. (11.04 KB, patch)
2024-03-11 21:03 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Testing - not ready (10.72 KB, patch)
2024-03-11 21:04 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Testing - not ready (10.72 KB, patch)
2024-03-11 21:06 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Testing - not ready (10.72 KB, patch)
2024-03-11 21:06 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Added new system preferences for automatically resolving claims (10.62 KB, patch)
2024-03-12 04:12 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Adding patch for AutoClaimReturnStatusOnCheckout syspref (1.50 KB, patch)
2024-03-12 04:17 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Adding patch for AutoClaimReturnStatusOnCheckout syspref (1.54 KB, patch)
2024-03-12 12:41 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 27753: Added new system preferences for automatically resolving claims (12.11 KB, patch)
2024-03-19 18:33 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Unit tests (2.13 KB, patch)
2024-03-19 18:33 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Unit tests (2.13 KB, patch)
2024-03-19 18:55 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Unit tests (675 bytes, patch)
2024-03-19 18:55 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Added new system preferences for automatically resolving claims (12.12 KB, patch)
2024-03-19 18:57 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Unit tests (2.33 KB, patch)
2024-03-19 18:57 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Added new system preferences for automatically resolving claims (12.20 KB, patch)
2024-03-19 20:43 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 27753: Unit tests (2.39 KB, patch)
2024-03-19 20:43 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 27753: Follow up updates to C4/Circulation.pm (1.47 KB, patch)
2024-04-30 15:21 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Follow up with updated unit tests (3.69 KB, patch)
2024-04-30 15:21 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Added new system preferences for automatically resolving claims (12.18 KB, patch)
2024-04-30 16:06 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Unit tests (2.38 KB, patch)
2024-04-30 16:06 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Follow up updates to C4/Circulation.pm (2.08 KB, patch)
2024-04-30 16:06 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Follow up with updated unit tests (2.55 KB, patch)
2024-04-30 16:06 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Tidy (2.25 KB, patch)
2024-04-30 16:06 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Tidy Circulation.pl (798 bytes, patch)
2024-04-30 16:06 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: Tidy unit tests (5.30 KB, patch)
2024-04-30 16:06 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 27753: (QA follow-up) Check that item exists before using it (3.20 KB, patch)
2024-05-01 09:59 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27753: (QA follow-up) Improve unit tests (5.69 KB, patch)
2024-05-01 09:59 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27753: Further unit tests highlighting possible issues (3.93 KB, patch)
2024-05-01 12:00 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27753: Example of how we might set to librarian instead of patron (916 bytes, patch)
2024-05-01 12:00 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27753: Added new system preferences for automatically resolving claims (12.40 KB, patch)
2024-05-03 14:16 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27753: Unit tests (2.52 KB, patch)
2024-05-03 14:16 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27753: (follow-up) Update logic in AddReturn (2.36 KB, patch)
2024-05-03 14:16 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27753: (follow-up) Tidy introduced code in Circulation.pm (2.36 KB, patch)
2024-05-03 14:16 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27753: (follow-up) Tidy new code in circulation.pl (889 bytes, patch)
2024-05-03 14:16 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27753: (follow-up) Tidy unit tests (3.12 KB, patch)
2024-05-03 14:16 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27753: (QA follow-up) Check that item exists before using it (3.26 KB, patch)
2024-05-03 14:16 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27753: (QA follow-up) Improve unit tests (4.37 KB, patch)
2024-05-03 14:16 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27753: (QA follow-up) Enhance unit tests (4.18 KB, patch)
2024-05-03 14:16 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27753: (QA follow-up) Use librarian as resolver (1.62 KB, patch)
2024-05-03 14:17 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 Andrew Fuerste-Henry 2021-02-22 15:59:01 UTC
When an item has been marked Claims Returned and is later checked in, it would be good to let Koha automatically resolve that claim. We'd need a way to tell it which resolution status to go to.
Comment 1 Lisette Scheer 2021-02-23 01:17:27 UTC
Ideally from a workflow perspective checking in a claim return item would open up the options to set the resolution and update the note if needed.
Comment 2 Andrew Fuerste-Henry 2021-02-23 01:32:25 UTC
That's a fine idea -- to have the alert at checkin include some interface with which to mark the claim as resolve, rather than just a link to the patron -- but I'm suggesting something wholly automated.
Comment 3 Lisette Scheer 2021-02-23 01:47:43 UTC
(In reply to Andrew Fuerste-Henry from comment #2)
> That's a fine idea -- to have the alert at checkin include some interface
> with which to mark the claim as resolve, rather than just a link to the
> patron -- but I'm suggesting something wholly automated.

Ah yes that makes sense.
Maybe a sys pref that can say "If a claim return item is checked in on the returns.pl resolve the claim and set it to X resolution?"
Comment 4 Rebecca Coert 2021-03-12 20:11:59 UTC
> Maybe a sys pref that can say "If a claim return item is checked in on the
> returns.pl resolve the claim and set it to X resolution?"

That's exactly what we'd like to see happen.  Fully automated and no staff interaction required.
Comment 5 Koha Team University Lyon 3 2021-09-09 13:45:56 UTC
Hi,
For me if a book is really returned, the claims retruned note should desappear.

> Maybe a sys pref that can say "If a claim return item is checked in on the
> returns.pl resolve the claim and set it to X resolution?"

I'm Ok for a syspref but it should also be done if the return is done on a selfcheckout system via SIP.
Comment 6 cghattas 2023-07-10 20:01:18 UTC
Yes, we would like to see this as an automated resolution in Koha upon check-in by staff.
Comment 7 Laura Escamilla 2024-02-27 20:17:07 UTC Comment hidden (obsolete)
Comment 8 Laura Escamilla 2024-03-11 21:03:20 UTC Comment hidden (obsolete)
Comment 9 Laura Escamilla 2024-03-11 21:04:26 UTC Comment hidden (obsolete)
Comment 10 Laura Escamilla 2024-03-11 21:06:20 UTC Comment hidden (obsolete)
Comment 11 Laura Escamilla 2024-03-11 21:06:38 UTC Comment hidden (obsolete)
Comment 12 Laura Escamilla 2024-03-12 04:12:01 UTC
Created attachment 163084 [details] [review]
Bug 27753: Added new system preferences for automatically resolving claims

To test:
1. Configure Claims returned
    1. Go to Administration > Authorized Values > LOST
    2. Add a new authorized value with value:6 and description:Claims returned
    3. Go to Administration > System Preferences
    4. Set ClaimReturnedLostValue to 6 and save
2. Check out an item to a patron.
    1. Mark the item as claim returned
    2. Check the item in.
    3. A message stating that the item has been claimed as returned pops up with an option to resolve.
    4. Resolve the claim.
3. Check out the item to the patron again.
    1. Mark the item as claim returned.
    2. Check out the item to a new patron. Select “Yes, check out”
    3. Go back to the previous patron. Notice that their claim was not resolved.
4. Apply the patch.
    1. Updatedatabase
    2. restart_all
    3. Go to the system preferences and set the system preference ‘AutoClaimReturnStatusOnCheckin’ to ‘Returned by patron’
    4. Set ‘AutoClaimReturnStatusOnCheckout’ to ‘Found in library’
5. Redo step 2
    1. When checking the claim returned item in you will now see a message that says “The previously claimed returned item has been found, automatically resolving the associated claim.”
    2. View the previous patron. Their claim has automatically been resolved with a status of ‘Returned by patron’
6. Redo step 3
    1. Upon checking the item out to another patron you will see a message that says “The previously claimed returned item has been found, automatically resolving the associated claim.”
    2. View the previous patron. Their claim has automatically been resolved with a status of ‘Found in library’.
7. Sign off and have a wonderful day!
Comment 13 Laura Escamilla 2024-03-12 04:17:33 UTC
Created attachment 163085 [details] [review]
Bug 27753: Adding patch for AutoClaimReturnStatusOnCheckout syspref
Comment 14 ByWater Sandboxes 2024-03-12 12:41:05 UTC
Created attachment 163090 [details] [review]
Bug 27753: Adding patch for AutoClaimReturnStatusOnCheckout syspref

Signed-off-by: Michelle <mspinney@clamsnet.org>
Comment 15 Laura Escamilla 2024-03-19 18:33:34 UTC Comment hidden (obsolete)
Comment 16 Laura Escamilla 2024-03-19 18:33:37 UTC Comment hidden (obsolete)
Comment 17 Laura Escamilla 2024-03-19 18:55:10 UTC Comment hidden (obsolete)
Comment 18 Laura Escamilla 2024-03-19 18:55:12 UTC Comment hidden (obsolete)
Comment 19 Laura Escamilla 2024-03-19 18:57:44 UTC
Created attachment 163476 [details] [review]
Bug 27753: Added new system preferences for automatically resolving claims

To test:
1. Configure Claims returned
    1. Go to Administration > Authorized Values > LOST
    2. Add a new authorized value with value:6 and description:Claims returned
    3. Go to Administration > System Preferences
    4. Set ClaimReturnedLostValue to 6 and save
2. Check out an item to a patron.
    1. Mark the item as claim returned
    2. Check the item in.
    3. A message stating that the item has been claimed as returned pops up with an option to resolve.
    4. Resolve the claim.
3. Check out the item to the patron again.
    1. Mark the item as claim returned.
    2. Check out the item to a new patron. Select “Yes, check out”
    3. Go back to the previous patron. Notice that their claim was not resolved.
4. Apply the patch.
    1. Updatedatabase
    2. restart_all
    3. Go to the system preferences and set the system preference ‘AutoClaimReturnStatusOnCheckin’ to ‘Returned by patron’
    4. Set ‘AutoClaimReturnStatusOnCheckout’ to ‘Found in library’
5. Redo step 2
    1. When checking the claim returned item in you will now see a message that says “The previously claimed returned item has been found, automatically resolving the associated claim.”
    2. View the previous patron. Their claim has automatically been resolved with a status of ‘Returned by patron’
6. Redo step 3
    1. Upon checking the item out to another patron you will see a message that says “The previously claimed returned item has been found, automatically resolving the associated claim.”
    2. View the previous patron. Their claim has automatically been resolved with a status of ‘Found in library’.
7. Sign off and have a wonderful day!
Comment 20 Laura Escamilla 2024-03-19 18:57:47 UTC
Created attachment 163477 [details] [review]
Bug 27753: Unit tests
Comment 21 Andrew Fuerste-Henry 2024-03-19 20:43:04 UTC
Created attachment 163479 [details] [review]
Bug 27753: Added new system preferences for automatically resolving claims

To test:
1. Configure Claims returned
    1. Go to Administration > Authorized Values > LOST
    2. Add a new authorized value with value:6 and description:Claims returned
    3. Go to Administration > System Preferences
    4. Set ClaimReturnedLostValue to 6 and save
2. Check out an item to a patron.
    1. Mark the item as claim returned
    2. Check the item in.
    3. A message stating that the item has been claimed as returned pops up with an option to resolve.
    4. Resolve the claim.
3. Check out the item to the patron again.
    1. Mark the item as claim returned.
    2. Check out the item to a new patron. Select “Yes, check out”
    3. Go back to the previous patron. Notice that their claim was not resolved.
4. Apply the patch.
    1. Updatedatabase
    2. restart_all
    3. Go to the system preferences and set the system preference ‘AutoClaimReturnStatusOnCheckin’ to ‘Returned by patron’
    4. Set ‘AutoClaimReturnStatusOnCheckout’ to ‘Found in library’
5. Redo step 2
    1. When checking the claim returned item in you will now see a message that says “The previously claimed returned item has been found, automatically resolving the associated claim.”
    2. View the previous patron. Their claim has automatically been resolved with a status of ‘Returned by patron’
6. Redo step 3
    1. Upon checking the item out to another patron you will see a message that says “The previously claimed returned item has been found, automatically resolving the associated claim.”
    2. View the previous patron. Their claim has automatically been resolved with a status of ‘Found in library’.
7. Sign off and have a wonderful day!

Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Comment 22 Andrew Fuerste-Henry 2024-03-19 20:43:07 UTC
Created attachment 163480 [details] [review]
Bug 27753: Unit tests

Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Comment 23 Andrew Fuerste-Henry 2024-03-19 20:46:03 UTC
> 6. Redo step 3
>     1. Upon checking the item out to another patron you will see a message
> that says “The previously claimed returned item has been found,
> automatically resolving the associated claim.”

One small point, this checkout to another patron required a confirmation before Koha would proceed to return it from the one patron and check out to the other. However, the claim resolved immediately, before I responded to the confirmation about the checkout.

I can't think of a reason to *not* resolve the claim even if you don't complete the checkout, so I signed off anyway.
Comment 24 Martin Renvoize (ashimema) 2024-04-29 11:17:22 UTC
Do we need both system preferences introduced here?  Could we not rely on just the one for which status to change to.. i.e. if not set don't change, otherwise set to selected status?
Comment 25 Martin Renvoize (ashimema) 2024-04-30 12:12:41 UTC
OK.. I misread the prefs.. it's one for Checkout and one for Checkin!.. totally misread that first time around.. ignore my previous comment.
Comment 26 Martin Renvoize (ashimema) 2024-04-30 12:25:31 UTC
Comment on attachment 163479 [details] [review]
Bug 27753: Added new system preferences for automatically resolving claims

Review of attachment 163479 [details] [review]:
-----------------------------------------------------------------

::: C4/Circulation.pm
@@ +2531,5 @@
>  
>      if ( C4::Context->preference('ClaimReturnedLostValue') ) {
> +        my $autoClaimReturnCheckin = C4::Context->preference('AutoClaimReturnStatusOnCheckin');
> +
> +        if ($autoClaimReturnCheckin) {

I think the placement of this statement is wrong.. now it all relies on there being an autoClaimReturnedCheckin status set..

I think we need to move the check for ReturnClaims up outside of this block and trigger the autoResolve or not based on this check only (and the differing return of course)
Comment 27 Martin Renvoize (ashimema) 2024-04-30 12:26:13 UTC
I also hate to say it, but can we get a unit test for the Circulation.pm change pretty please.

This is so close, I'd love to see it over the line for release.. you have a couple of days.
Comment 28 Laura Escamilla 2024-04-30 15:21:11 UTC
Created attachment 165911 [details] [review]
Bug 27753: Follow up updates to C4/Circulation.pm
Comment 29 Laura Escamilla 2024-04-30 15:21:14 UTC
Created attachment 165912 [details] [review]
Bug 27753: Follow up with updated unit tests
Comment 30 Laura Escamilla 2024-04-30 16:06:00 UTC
Created attachment 165914 [details] [review]
Bug 27753: Added new system preferences for automatically resolving claims

To test:
1. Configure Claims returned
    1. Go to Administration > Authorized Values > LOST
    2. Add a new authorized value with value:6 and description:Claims returned
    3. Go to Administration > System Preferences
    4. Set ClaimReturnedLostValue to 6 and save
2. Check out an item to a patron.
    1. Mark the item as claim returned
    2. Check the item in.
    3. A message stating that the item has been claimed as returned pops up with an option to resolve.
    4. Resolve the claim.
3. Check out the item to the patron again.
    1. Mark the item as claim returned.
    2. Check out the item to a new patron. Select “Yes, check out”
    3. Go back to the previous patron. Notice that their claim was not resolved.
4. Apply the patch.
    1. Updatedatabase
    2. restart_all
    3. Go to the system preferences and set the system preference ‘AutoClaimReturnStatusOnCheckin’ to ‘Returned by patron’
    4. Set ‘AutoClaimReturnStatusOnCheckout’ to ‘Found in library’
5. Redo step 2
    1. When checking the claim returned item in you will now see a message that says “The previously claimed returned item has been found, automatically resolving the associated claim.”
    2. View the previous patron. Their claim has automatically been resolved with a status of ‘Returned by patron’
6. Redo step 3
    1. Upon checking the item out to another patron you will see a message that says “The previously claimed returned item has been found, automatically resolving the associated claim.”
    2. View the previous patron. Their claim has automatically been resolved with a status of ‘Found in library’.
7. Sign off and have a wonderful day!

Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Comment 31 Laura Escamilla 2024-04-30 16:06:03 UTC
Created attachment 165915 [details] [review]
Bug 27753: Unit tests

Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Comment 32 Laura Escamilla 2024-04-30 16:06:06 UTC
Created attachment 165916 [details] [review]
Bug 27753: Follow up updates to C4/Circulation.pm
Comment 33 Laura Escamilla 2024-04-30 16:06:09 UTC
Created attachment 165917 [details] [review]
Bug 27753: Follow up with updated unit tests
Comment 34 Laura Escamilla 2024-04-30 16:06:11 UTC
Created attachment 165918 [details] [review]
Bug 27753: Tidy
Comment 35 Laura Escamilla 2024-04-30 16:06:14 UTC
Created attachment 165919 [details] [review]
Bug 27753: Tidy Circulation.pl
Comment 36 Laura Escamilla 2024-04-30 16:06:17 UTC
Created attachment 165920 [details] [review]
Bug 27753: Tidy unit tests
Comment 37 Martin Renvoize (ashimema) 2024-05-01 09:59:21 UTC
Created attachment 165952 [details] [review]
Bug 27753: (QA follow-up) Check that item exists before using it

We're actioning the change of claim status outside of any block that
checks the $item exists. As such we'll want to add that check in here.

I did consider that this should live inside AddIssue, but on reflection
the librarian may want to not proceed with the issue given other return
values from the CanBookBeIssued call, but you still want the
AutoClaimReturn to fire regardless as you've now found the item.
Comment 38 Martin Renvoize (ashimema) 2024-05-01 09:59:25 UTC
Created attachment 165953 [details] [review]
Bug 27753: (QA follow-up) Improve unit tests

This patch adds unit tests that test the functionality more specifically
and adds a few notes/fixme for things we need to consider here
Comment 39 Martin Renvoize (ashimema) 2024-05-01 12:00:36 UTC
Created attachment 165958 [details] [review]
Bug 27753: Further unit tests highlighting possible issues
Comment 40 Martin Renvoize (ashimema) 2024-05-01 12:00:39 UTC
Created attachment 165959 [details] [review]
Bug 27753: Example of how we might set to librarian instead of patron
Comment 41 Martin Renvoize (ashimema) 2024-05-01 12:01:07 UTC
OK.. I'm happy to tidy up here and get this over the line.. however, I have some questions.

1) In AddReturn, was it deliberate to use 'patron from last checkout' as the 'resolved_by'.. or should that be the librarian performing the return action? (Remember in both cases this could be undefined.. if we use 'librarian' then we can get that from the userenv of the session.. this "should" always be set these days.. if we are using the patron then the checkout may have already been marked at completed in which case the relation accessor will fail and you won't have a patron and the call to resolve will fail.

2) Should we be handling the lost_item_status in any way?  In the interactive approach we give the librarian the option to set a new lost item status (and the resolve method accepts said status if passed).. should we be setting that here too.. or is that perhaps another bug?

3) Checkout functionality suffers from the same questions as above?

4) I tend to like subtests to be a little more self-contained with a database transaction and rollback rather than relying on other test data defined earlier in the test.. I stuck to how you started the tests here but as a future point it may be a good practice if you can to make them more isolated.

I'm failing QA for now, but will happily continue to support in getting this over the line.
Comment 42 Laura Escamilla 2024-05-02 14:19:58 UTC
(In reply to Martin Renvoize from comment #41)
> OK.. I'm happy to tidy up here and get this over the line.. however, I have
> some questions.
> 
> 1) In AddReturn, was it deliberate to use 'patron from last checkout' as the
> 'resolved_by'.. or should that be the librarian performing the return
> action? (Remember in both cases this could be undefined.. if we use
> 'librarian' then we can get that from the userenv of the session.. this
> "should" always be set these days.. if we are using the patron then the
> checkout may have already been marked at completed in which case the
> relation accessor will fail and you won't have a patron and the call to
> resolve will fail.

    ---Ack. For logging purposes I believe it would be useful to use the 'librarian'. 
> 
> 2) Should we be handling the lost_item_status in any way?  In the
> interactive approach we give the librarian the option to set a new lost item
> status (and the resolve method accepts said status if passed).. should we be
> setting that here too.. or is that perhaps another bug?
    --- Let's file a follow-up bug for this. 
> 
> 3) Checkout functionality suffers from the same questions as above?
> 
> 4) I tend to like subtests to be a little more self-contained with a
> database transaction and rollback rather than relying on other test data
> defined earlier in the test.. I stuck to how you started the tests here but
> as a future point it may be a good practice if you can to make them more
> isolated.
   --- Thank you for the feedback on unit tests!
Comment 43 Martin Renvoize (ashimema) 2024-05-03 14:16:30 UTC
Created attachment 166128 [details] [review]
Bug 27753: Added new system preferences for automatically resolving claims

To test:
1. Configure Claims returned
    1. Go to Administration > Authorized Values > LOST
    2. Add a new authorized value with value:6 and description:Claims returned
    3. Go to Administration > System Preferences
    4. Set ClaimReturnedLostValue to 6 and save
2. Check out an item to a patron.
    1. Mark the item as claim returned
    2. Check the item in.
    3. A message stating that the item has been claimed as returned pops up with
       an option to resolve.
    4. Resolve the claim.
3. Check out the item to the patron again.
    1. Mark the item as claim returned.
    2. Check out the item to a new patron. Select “Yes, check out”
    3. Go back to the previous patron. Notice that their claim was not resolved.
4. Apply the patch.
    1. Updatedatabase
    2. restart_all
    3. Go to the system preferences and set the system preference
       ‘AutoClaimReturnStatusOnCheckin’ to ‘Returned by patron’
    4. Set ‘AutoClaimReturnStatusOnCheckout’ to ‘Found in library’
5. Redo step 2
    1. When checking the claim returned item in you will now see a message that
       says “The previously claimed returned item has been found, automatically
       resolving the associated claim.”
    2. View the previous patron. Their claim has automatically been resolved
       with a status of ‘Returned by patron’
6. Redo step 3
    1. Upon checking the item out to another patron you will see a message that
       says “The previously claimed returned item has been found, automatically
       resolving the associated claim.”
    2. View the previous patron. Their claim has automatically been resolved
       with a status of ‘Found in library’.
7. Sign off and have a wonderful day!

Sponsored-by: Altadena Library District
Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 44 Martin Renvoize (ashimema) 2024-05-03 14:16:34 UTC
Created attachment 166129 [details] [review]
Bug 27753: Unit tests

Add unit tests for new logic introduced to C4::Circulation::AddReturn

Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 45 Martin Renvoize (ashimema) 2024-05-03 14:16:37 UTC
Created attachment 166130 [details] [review]
Bug 27753: (follow-up) Update logic in AddReturn

The new logic in AddReturn was flawed, we were missing return messages
due to moving the if statement too high and catching more code than
intended.

Mentored-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 46 Martin Renvoize (ashimema) 2024-05-03 14:16:41 UTC
Created attachment 166131 [details] [review]
Bug 27753: (follow-up) Tidy introduced code in Circulation.pm

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 47 Martin Renvoize (ashimema) 2024-05-03 14:16:44 UTC
Created attachment 166132 [details] [review]
Bug 27753: (follow-up) Tidy new code in circulation.pl

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 48 Martin Renvoize (ashimema) 2024-05-03 14:16:48 UTC
Created attachment 166133 [details] [review]
Bug 27753: (follow-up) Tidy unit tests

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 49 Martin Renvoize (ashimema) 2024-05-03 14:16:51 UTC
Created attachment 166134 [details] [review]
Bug 27753: (QA follow-up) Check that item exists before using it

We're actioning the change of claim status outside of any block that
checks the $item exists. As such we'll want to add that check in here.

I did consider that this should live inside AddIssue, but on reflection
the librarian may want to not proceed with the issue given other return
values from the CanBookBeIssued call, but you still want the
AutoClaimReturn to fire regardless as you've now found the item.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 50 Martin Renvoize (ashimema) 2024-05-03 14:16:55 UTC
Created attachment 166135 [details] [review]
Bug 27753: (QA follow-up) Improve unit tests

This patch adds unit tests that test the functionality more specifically
and adds a few notes/fixme for things we need to consider here

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 51 Martin Renvoize (ashimema) 2024-05-03 14:16:58 UTC
Created attachment 166136 [details] [review]
Bug 27753: (QA follow-up) Enhance unit tests

This patch further unit tests highlighting possible issues

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 52 Martin Renvoize (ashimema) 2024-05-03 14:17:02 UTC
Created attachment 166137 [details] [review]
Bug 27753: (QA follow-up) Use librarian as resolver

This patch updates the changed code to set the logged in librarian as
the person who resolved the return claim at checkin/checkout action.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 53 Martin Renvoize (ashimema) 2024-05-03 14:18:32 UTC
Great work, nice golfing with you Laura.

So.. in that final QA run I fixed up a few commit messages and added the sponsor details to the first commit for you.

It's all looking great now.

Passing QA
Comment 54 Katrin Fischer 2024-05-06 07:06:58 UTC
Fixed some tiny things before pushing:

1) +    bug_number  => "BUG_27753",
Needs to be just the numerical bug number.

2) Updates preference description to show the authorized value code following the existing pattern: git grep authorised_values.pl *.pref

Some notes:
I feel like the preference name is not very easy to understand. It took me a few reads. Maybe instead of AutoClaimREturnStatusOnCheckin we could have used something like AutoResolveReturnClaimOnCheckin.
Comment 55 Katrin Fischer 2024-05-06 07:13:04 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 56 Fridolin Somers 2024-05-24 13:24:15 UTC
Not backported to 23.11.x