Bug 18317 - Allow check out of already checked out items through SIP
Summary: Allow check out of already checked out items through SIP
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: SIP2 (show other bugs)
Version: Main
Hardware: All All
: P3 enhancement
Assignee: David Cook
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-23 07:40 UTC by Marianne Rolfsen
Modified: 2024-11-18 17:40 UTC (History)
13 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This enhancement allows checkouts of items already checked out to someone else when using SIP2. This is enabled using the new system preference AllowItemsOnLoanCheckoutSIP. Example use case: Patron A has checked out a book and tried to return it, but for some reason it hasn't been properly checked in - but it was re-shelved anyway. Patron B wants to borrow this book from an unstaffed library, but the self-checkout blocks them because the book is still checked out to Patron A.
Version(s) released in:
24.11.00
Circulation function:


Attachments
Bug 18317: Allow check out of already checked out items through SIP (5.47 KB, patch)
2021-07-19 04:19 UTC, David Cook
Details | Diff | Splinter Review
Bug 18317: Allow check out of already checked out items through SIP (5.47 KB, patch)
2023-11-09 02:05 UTC, David Cook
Details | Diff | Splinter Review
Bug 18317: Perl tidy (2.38 KB, patch)
2023-11-09 02:05 UTC, David Cook
Details | Diff | Splinter Review
Bug 18317: Allow check out of already checked out items through SIP (5.52 KB, patch)
2023-11-20 02:09 UTC, David Nind
Details | Diff | Splinter Review
Bug 18317: Perl tidy (2.42 KB, patch)
2023-11-20 02:09 UTC, David Nind
Details | Diff | Splinter Review
Bug 18317: Allow check out of already checked out items through SIP (5.56 KB, patch)
2024-02-23 18:13 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 18317: Perl tidy (2.48 KB, patch)
2024-02-23 18:13 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 18317: (QA follow-up) Clean up code and add unit tests (5.88 KB, patch)
2024-02-23 18:13 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 18317: Add database update (1.30 KB, patch)
2024-05-01 13:31 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 18317: Allow check out of already checked out items through SIP (5.63 KB, patch)
2024-07-04 08:42 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 18317: Perl tidy (2.55 KB, patch)
2024-07-04 08:42 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 18317: (QA follow-up) Clean up code and add unit tests (5.94 KB, patch)
2024-07-04 08:42 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 18317: Add database update (1.36 KB, patch)
2024-07-04 08:42 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 18317: (QA follow-up) Fix missing `,` (1.53 KB, patch)
2024-07-04 08:42 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 Marianne Rolfsen 2017-03-23 07:40:51 UTC
We see the need to have the ability to allow already checked out material to be checked out by an another patron automatically when using the automat (sip). 

Today a patron is not allowed to check out already checked out material when using the automat (sip).(In the staff client you can override this if you scan the barcode).

There are several reason for allowing this:

Case 1:
If a patron, patron no.1, fails to deliver the item properly (the item is still on loan on his account) and the item is placed on the shelf where it belongs.
The next patron(no.2) who picks it up and borrows it, can in this way correct the error of patron no.1 without contacting the staff. 

Today we risk that patron no.1 will receive fines even though he has delivered it. Or even worse patron no.2 has borrowed  it (failed to see og ignored the message on the automat) and patron nr. 1 gets the fines.


Case 2:  
If a patron has an item on loan that belongs to another branch, has no renewals left and wishes to borrow it again. He will be able to do so if there are no one on the waiting list.   


Because we have many branches that are open without any staff present, this feature  is even more important. The patrons will be much more self-sufficient -  also during the hours when the library is open but without staff.
Comment 1 Francesco Rivetti 2017-06-26 07:37:04 UTC
For future reference, here a possible workaround:

change in SIP/ILS/Transaction/Checkout.pm (commenting out the block _after_ ISSUED_TO_ANOTHER and probably adding a few more conditions there) 

commenting out the _whole_ if case around "Item checked out to another patron" in C4/SIP/ILS.pm
Comment 2 Magnus Enger 2018-03-28 22:47:15 UTC
At least one library in Sweden would like to see this implemented too.
Comment 3 Colin Campbell 2018-09-05 08:50:58 UTC
Some sip clients already implement this - they force a discharge then proceed with the issue
Comment 4 David Cook 2021-07-19 03:56:23 UTC
(In reply to Francesco Rivetti from comment #1)
> For future reference, here a possible workaround:
> 
> change in SIP/ILS/Transaction/Checkout.pm (commenting out the block _after_
> ISSUED_TO_ANOTHER and probably adding a few more conditions there) 
> 
> commenting out the _whole_ if case around "Item checked out to another
> patron" in C4/SIP/ILS.pm

I have a library that has been carrying this customization for a few years now.

To be acceptable for Koha, I think that we'll have to wrap it with a system preference. 

Perhaps "AllowItemsOnLoanCheckoutSIP" (patterned after "AllowItemsOnHoldCheckoutSIP").
Comment 5 David Cook 2021-07-19 04:19:23 UTC
Created attachment 122934 [details] [review]
Bug 18317: Allow check out of already checked out items through SIP

This patch allows checkouts to be processed via SIP even when
the item is already checked out to a user.

Test plan:
0) Apply the patch
1) koha-sip --stop kohadev
2) koha-sip --start kohadev
3) misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkout --patron koha --item 39999000001310
4) misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkout --patron 23529000035676 --item 39999000001310
5) Note the output includes "AFItem checked out to another patron"
6) Enable system preference "AllowItemsOnLoanCheckoutSIP"
7) misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkout --patron 23529000035676 --item 39999000001310
8) Note the output no longer includes "AFItem checked out to another patron" and the item has been checked out to patron 23529000035676
Comment 6 David Cook 2021-07-19 04:20:14 UTC
Note that I developed this patch against 21.05 rather than master, so it might not actually apply. 

My priority is the local change, so I figured it was better to attach 21.05 patches here rather than not send anything upstream.
Comment 7 David Nind 2021-10-31 06:52:08 UTC
Just to confirm that the patch doesn't apply in master 8-(..

Applying: Bug 18317: Allow check out of already checked out items through SIP
Using index info to reconstruct a base tree...
M	C4/SIP/ILS.pm
M	C4/SIP/ILS/Transaction/Checkout.pm
M	installer/data/mysql/mandatory/sysprefs.sql
M	koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
Falling back to patching base and 3-way merge...
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
Auto-merging installer/data/mysql/mandatory/sysprefs.sql
Auto-merging C4/SIP/ILS/Transaction/Checkout.pm
Auto-merging C4/SIP/ILS.pm
CONFLICT (content): Merge conflict in C4/SIP/ILS.pm
error: Failed to merge in the changes.
Patch failed at 0001 Bug 18317: Allow check out of already checked out items through SIP
Comment 8 Lari Strand 2023-11-08 08:03:37 UTC
SIP server configuration has the option prevcheckout_block_checkout="0" that should work for this. Haven't tested though. Does this suffice as a solution?
Comment 9 Katrin Fischer 2023-11-08 08:11:44 UTC
(In reply to Lari Strand from comment #8)
> SIP server configuration has the option prevcheckout_block_checkout="0" that
> should work for this. Haven't tested though. Does this suffice as a solution?

I think the it's a bit of a different use case here.

prevcheckout blocks if you had it checked out in the past and have it returned since.
This is about checkouts you currently haven on your account, if I understand it correctly.
Comment 10 David Cook 2023-11-08 22:51:51 UTC
(In reply to Katrin Fischer from comment #9)
> (In reply to Lari Strand from comment #8)
> > SIP server configuration has the option prevcheckout_block_checkout="0" that
> > should work for this. Haven't tested though. Does this suffice as a solution?
> 
> I think the it's a bit of a different use case here.
> 
> prevcheckout blocks if you had it checked out in the past and have it
> returned since.
> This is about checkouts you currently haven on your account, if I understand
> it correctly.

prevcheckout_block_checkout isn't relevant here.

The use case here is that Patron A has checked out a book. Patron A has tried to return that book, but for some reason it hasn't been properly checked in, and it's been re-shelfed anyway. Patron B wants to borrow this book from an unstaffed library, but the self-checkout blocks them because the book is still checked out to Patron A.

Just a reminder that this has been running in production for a multi-branch public library for something like 5-7 years now. 

I'll have to look at rebasing at some point...
Comment 11 David Cook 2023-11-09 02:05:33 UTC
Created attachment 158688 [details] [review]
Bug 18317: Allow check out of already checked out items through SIP

This patch allows checkouts to be processed via SIP even when
the item is already checked out to a user.

Test plan:
0) Apply the patch
1) koha-sip --stop kohadev
2) koha-sip --start kohadev
3) misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkout --patron koha --item 39999000001310
4) misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkout --patron 23529000035676 --item 39999000001310
5) Note the output includes "AFItem checked out to another patron"
6) Enable system preference "AllowItemsOnLoanCheckoutSIP"
7) misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkout --patron 23529000035676 --item 39999000001310
8) Note the output no longer includes "AFItem checked out to another patron" and the item has been checked out to patron 23529000035676
Comment 12 David Cook 2023-11-09 02:05:37 UTC
Created attachment 158689 [details] [review]
Bug 18317: Perl tidy
Comment 13 David Nind 2023-11-20 02:09:53 UTC
Created attachment 159130 [details] [review]
Bug 18317: Allow check out of already checked out items through SIP

This patch allows checkouts to be processed via SIP even when
the item is already checked out to a user.

Test plan:
0) Apply the patch
1) koha-sip --stop kohadev
2) koha-sip --start kohadev
3) misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkout --patron koha --item 39999000001310
4) misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkout --patron 23529000035676 --item 39999000001310
5) Note the output includes "AFItem checked out to another patron"
6) Enable system preference "AllowItemsOnLoanCheckoutSIP"
7) misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkout --patron 23529000035676 --item 39999000001310
8) Note the output no longer includes "AFItem checked out to another patron" and the item has been checked out to patron 23529000035676

Signed-off-by: David Nind <david@davidnind.com>
Comment 14 David Nind 2023-11-20 02:09:56 UTC
Created attachment 159131 [details] [review]
Bug 18317: Perl tidy

Signed-off-by: David Nind <david@davidnind.com>
Comment 15 Kyle M Hall (khall) 2024-02-23 18:07:03 UTC
Needs unit tests
Comment 16 Kyle M Hall (khall) 2024-02-23 18:13:19 UTC
Created attachment 162394 [details] [review]
Bug 18317: Allow check out of already checked out items through SIP

This patch allows checkouts to be processed via SIP even when
the item is already checked out to a user.

Test plan:
0) Apply the patch
1) koha-sip --stop kohadev
2) koha-sip --start kohadev
3) misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkout --patron koha --item 39999000001310
4) misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkout --patron 23529000035676 --item 39999000001310
5) Note the output includes "AFItem checked out to another patron"
6) Enable system preference "AllowItemsOnLoanCheckoutSIP"
7) misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkout --patron 23529000035676 --item 39999000001310
8) Note the output no longer includes "AFItem checked out to another patron" and the item has been checked out to patron 23529000035676

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 17 Kyle M Hall (khall) 2024-02-23 18:13:25 UTC
Created attachment 162395 [details] [review]
Bug 18317: Perl tidy

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 18 Kyle M Hall (khall) 2024-02-23 18:13:28 UTC
Created attachment 162396 [details] [review]
Bug 18317: (QA follow-up) Clean up code and add unit tests

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 19 Katrin Fischer 2024-04-19 16:12:46 UTC
Hi Kyle, it looks like you missed the database update - can you please follow-up? If you set back to Passed QA it will go back up to the top of my queue.
Comment 20 Kyle M Hall (khall) 2024-05-01 13:31:32 UTC
Created attachment 165972 [details] [review]
Bug 18317: Add database update
Comment 21 Katrin Fischer 2024-05-02 10:54:47 UTC
Hi Kyle, something is not quite right here, please fix:

 FAIL	installer/data/mysql/atomicupdate/bug_18317.pl
   FAIL	  valid
		syntax error
		Can't use global @_ in "my"
		Global symbol "$args" requires explicit package name (did you forget to declare "my $args"?)
		syntax error
		installer/data/mysql/atomicupdate/bug_18317.pl had compilation errors.
Comment 22 Martin Renvoize (ashimema) 2024-07-04 08:42:01 UTC
Created attachment 168489 [details] [review]
Bug 18317: Allow check out of already checked out items through SIP

This patch allows checkouts to be processed via SIP even when
the item is already checked out to a user.

Test plan:
0) Apply the patch
1) koha-sip --stop kohadev
2) koha-sip --start kohadev
3) misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkout --patron koha --item 39999000001310
4) misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkout --patron 23529000035676 --item 39999000001310
5) Note the output includes "AFItem checked out to another patron"
6) Enable system preference "AllowItemsOnLoanCheckoutSIP"
7) misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkout --patron 23529000035676 --item 39999000001310
8) Note the output no longer includes "AFItem checked out to another patron" and the item has been checked out to patron 23529000035676

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 23 Martin Renvoize (ashimema) 2024-07-04 08:42:04 UTC
Created attachment 168490 [details] [review]
Bug 18317: Perl tidy

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 24 Martin Renvoize (ashimema) 2024-07-04 08:42:07 UTC
Created attachment 168491 [details] [review]
Bug 18317: (QA follow-up) Clean up code and add unit tests

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 25 Martin Renvoize (ashimema) 2024-07-04 08:42:10 UTC
Created attachment 168492 [details] [review]
Bug 18317: Add database update

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 26 Martin Renvoize (ashimema) 2024-07-04 08:42:14 UTC
Created attachment 168493 [details] [review]
Bug 18317: (QA follow-up) Fix missing `,`

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 27 Katrin Fischer 2024-07-05 13:50:16 UTC
Pushed for 24.11!

Well done everyone, thank you!