Bug 34326 - Add forbidden notforloan status
Summary: Add forbidden notforloan status
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: SIP2 (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Thibaud Guillot (thibaud_g)
QA Contact: Testopia
URL:
Keywords: no-sandbox
Depends on:
Blocks:
 
Reported: 2023-07-20 14:54 UTC by Thibaud Guillot (thibaud_g)
Modified: 2025-04-16 12:07 UTC (History)
4 users (show)

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


Attachments
Bug 34326: Add forbidden notforloan status option (3.43 KB, patch)
2023-07-21 07:45 UTC, Thibaud Guillot (thibaud_g)
Details | Diff | Splinter Review
Bug 34326: (follow-up) Add forbidden notforloan status option (5.63 KB, patch)
2025-04-09 13:25 UTC, Marion Durand
Details | Diff | Splinter Review
Bug 34326: Add forbidden notforloan status option (3.44 KB, patch)
2025-04-10 07:33 UTC, Marion Durand
Details | Diff | Splinter Review
Bug 34326: (follow-up) Add forbidden notforloan status option (5.72 KB, patch)
2025-04-10 07:33 UTC, Marion Durand
Details | Diff | Splinter Review
Bug 34326: Add forbidden notforloan status option (3.58 KB, patch)
2025-04-11 08:44 UTC, Emmanuel Bétemps
Details | Diff | Splinter Review
Bug 34326: (follow-up) Add forbidden notforloan status option (5.87 KB, patch)
2025-04-11 08:44 UTC, Emmanuel Bétemps
Details | Diff | Splinter Review
Bug 34326: Add forbidden notforloan status option (3.64 KB, patch)
2025-04-16 12:07 UTC, Marion Durand
Details | Diff | Splinter Review
Bug 34326: (follow-up) Add forbidden notforloan status option (5.92 KB, patch)
2025-04-16 12:07 UTC, Marion Durand
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Thibaud Guillot (thibaud_g) 2023-07-20 14:54:09 UTC
Hello everyone,

SIP allows you to manage item statuses, but it may be useful to add a list of statuses related to "notforloan" in order to specifically reject some of them.
Comment 1 Thibaud Guillot (thibaud_g) 2023-07-21 07:45:43 UTC
Created attachment 153756 [details] [review]
Bug 34326: Add forbidden notforloan status option

Test plan:

1) Add on your sip account an option called "forbidden_notforloan_status"
   and specify values separated by commas like "1,4,6" related to your
   notforloan statuses.
2) Restart your SIP server after that
3) Launch your SIP command on checkin with some items with these
   statuses. See the normal output
4) Apply this patch
5) Do step 3 again and see the new output with forbidden status and lib
   related to
Comment 2 Katrin Fischer 2023-07-21 08:14:06 UTC
Hi Thibad, can you explain this a bit more? Is it to prevent checkin of certain items on the self check?
Comment 3 Thibaud Guillot (thibaud_g) 2023-07-21 08:23:13 UTC
Hi Katrin,

Sorry maybe I pushed it a little bit quickly :)

It will add a special SIP option, to prevent the checkin of items if they have a special status. For example, if an item has the status "in treasury", we'd like to prevent it from being returned via SIP. So it's based on a customer case but I hope that you understand the way it would work
Comment 4 Emmanuel Bétemps 2024-02-09 07:09:40 UTC
Hi,

I'd like to test this patch but I only have access to sandboxes
Do you confirm that, with this condition, I can't test ?
Comment 5 David Nind 2024-04-26 20:24:43 UTC
Added the no-sandbox keyword, as you can't normally test SIP2 changes using the sandboxes.

Could you please provide some before and after examples for the SIP commands? 

For those of us not familiar with SIP2 commands, step-by-step instructions to walk through the commands are essential.

More for QA, but I think your patch needs a description, as per the commit message guidelines https://wiki.koha-community.org/wiki/Commit_messages
Comment 6 Emmanuel Bétemps 2024-04-27 08:21:33 UTC
(In reply to David Nind from comment #5)
> Added the no-sandbox keyword, as you can't normally test SIP2 changes using
> the sandboxes.


ok, thanks !
Comment 7 Marion Durand 2025-04-09 13:25:18 UTC
Created attachment 180741 [details] [review]
Bug 34326: (follow-up) Add forbidden notforloan status option

Add a SIP option to prevent the checkin of items if they have a special status.

The follow-up fixes a bug where SIP reported a failed checkin even if the
checkin was correctly done by Koha.

Test plan (assuming ktd)
1- checkout 4 items to a single patron
In the following example I used barcode 3999900000017, 3999900000018,
3999900000019 and 3999900000020 and the patron cardnumber 23529000035676

2- Update these items notforloan value ($7 in marc21, $o in unimarc) with 3
different not for loan status and an empty not for loan status

In the following example I used
3999900000017 notforloan = 1 "Not for loan"
3999900000018 notforloan = 2 "Staff collection"
3999900000019 notforloan = 3 "Added to bundle"
3999900000020 notforloan is empty

3- Edit file /etc/koha/sites/kohadev/SIPconfig.xml
Add to one of the login the parameter "forbidden_notforloan_status"" with two
different notforloan status previously used

In the following example I used
<login id="term1" password="term1" delimiter="|" error-detect="enabled"
institution="CPL" encoding="ascii" checked_in_ok="1"
forbidden_notforloan_status="1,2" />

4- restart sip (in KTD "sudo koha-sip --stop kohadev" then "sudo koha-sip
--start kohadev")

5- checkin the first two items with sip_cli_emulator (the ones with the
forbidden notforloan status). The checkin should fail (response starts with
100), a screen message (AF field) is added to explain and these items should
still be checked out to the patron in the interface

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000017

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000018

6- checkin the last two items with sip_cli_emulator (the one with the allowed
notforloan status and the one without any notforloan status). The checkin
should succeed (response starts with 101) and these items should not appear in
the checked out items to the patron in the interface.

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000019

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000020
Comment 8 Emmanuel Bétemps 2025-04-09 18:28:32 UTC
Hi,

(I assumed step 0 was 'Apply patch, update the database, retart service')

here is what 'git bz apply 34326'gives : 

Applying: Bug 34326: Add forbidden notforloan status option
Using index info to reconstruct a base tree...
M	C4/SIP/ILS.pm
M	C4/SIP/ILS/Transaction/Checkin.pm
Falling back to patching base and 3-way merge...
Auto-merging C4/SIP/ILS/Transaction/Checkin.pm
CONFLICT (content): Merge conflict in C4/SIP/ILS/Transaction/Checkin.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 34326: Add forbidden notforloan status option
Comment 9 Marion Durand 2025-04-10 06:55:13 UTC
Hi

Thank you for testing.

You assume correctly I miss a step 0, I will update the test plan to add this step.

I will also fix the rebase conflict.
Comment 10 Marion Durand 2025-04-10 07:33:25 UTC
Created attachment 180750 [details] [review]
Bug 34326: Add forbidden notforloan status option

Test plan:

1) Add on your sip account an option called "forbidden_notforloan_status"
   and specify values separated by commas like "1,4,6" related to your
   notforloan statuses.
2) Restart your SIP server after that
3) Launch your SIP command on checkin with some items with these
   statuses. See the normal output
4) Apply this patch
5) Do step 3 again and see the new output with forbidden status and lib
   related to
Comment 11 Marion Durand 2025-04-10 07:33:27 UTC
Created attachment 180751 [details] [review]
Bug 34326: (follow-up) Add forbidden notforloan status option

Add a SIP option to prevent the checkin of items if they have a special status.

The follow-up fixes a bug where SIP reported a failed checkin even if the
checkin was correctly done by Koha.

Test plan (assuming ktd)
0- Apply the patch, restart services (restart_all with KTD) (no need to update database)

1- checkout 4 items to a single patron
In the following example I used barcode 3999900000017, 3999900000018,
3999900000019 and 3999900000020 and the patron cardnumber 23529000035676

2- Update these items notforloan value ($7 in marc21, $o in unimarc) with 3
different not for loan status and an empty not for loan status

In the following example I used
3999900000017 notforloan = 1 "Not for loan"
3999900000018 notforloan = 2 "Staff collection"
3999900000019 notforloan = 3 "Added to bundle"
3999900000020 notforloan is empty

3- Edit file /etc/koha/sites/kohadev/SIPconfig.xml
Add to one of the login the parameter "forbidden_notforloan_status"" with two
different notforloan status previously used

In the following example I used
<login id="term1" password="term1" delimiter="|" error-detect="enabled"
institution="CPL" encoding="ascii" checked_in_ok="1"
forbidden_notforloan_status="1,2" />

4- restart sip (in KTD "sudo koha-sip --stop kohadev" then "sudo koha-sip
--start kohadev")

5- checkin the first two items with sip_cli_emulator (the ones with the
forbidden notforloan status). The checkin should fail (response starts with
100), a screen message (AF field) is added to explain and these items should
still be checked out to the patron in the interface

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000017

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000018

6- checkin the last two items with sip_cli_emulator (the one with the allowed
notforloan status and the one without any notforloan status). The checkin
should succeed (response starts with 101) and these items should not appear in
the checked out items to the patron in the interface.

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000019

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000020
Comment 12 Marion Durand 2025-04-10 07:34:06 UTC
Rebased for master
Comment 13 Emmanuel Bétemps 2025-04-10 20:16:05 UTC
Hi,

Many thanks for this test plan : it's really very clear, with many details!

As I discover ktd, it took time for me to find the good file to modify and the way to do it with vim

here is a copy of the line I changed :
 46   <accounts>
 47       <login id="term1"  password="term1" delimiter="|" error-detect="enabled" institution="CPL" encoding="ascii" checked_in_ok="1" forbidden_notfotloan_status="1,2" />


Unfortunately, this patch doesn't apply (but I may have missed something) : all checkins occurred



Here are the first and third checkins (you'll recognize the barcodes : I followed your examples)

kohadev-koha@kohadevbox:/$ /kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1 -sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000017
Attempting socket connection to 127.0.0.1:6001...connected!
Use of uninitialized value $hold_mode in string eq at /kohadevbox/koha/misc/sip_cli_emulator.pl line 127.
SEND: 9300CNterm1|COterm1|CPCPL|
READ: 941

Trying 'checkin'
SEND: 09N20250410    19515120250410    195151APCPL|AOCPL|AB3999900000017|ACterm1|BIN|
READ: 101YNN20250410    195151AOCPL|AB3999900000017|AQCPL|AJCrimes parfaits|AA23529000035676|CSCN_3784|

-------------------

kohadev-koha@kohadevbox:/$ /kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1 -sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000019
Attempting socket connection to 127.0.0.1:6001...connected!
Use of uninitialized value $hold_mode in string eq at /kohadevbox/koha/misc/sip_cli_emulator.pl line 127.
SEND: 9300CNterm1|COterm1|CPCPL|
READ: 941

Trying 'checkin'
SEND: 09N20250410    19562120250410    195621APCPL|AOCPL|AB3999900000019|ACterm1|BIN|
READ: 101YNN20250410    195622AOCPL|AB3999900000019|AQCPL|AJDerni?res nouvelles de la nuit|AA23529000035676|CSCN_1129|



Please, forgive me if this comment is too long or doesn't follow the protocol
Comment 14 Emmanuel Bétemps 2025-04-11 08:44:31 UTC
Created attachment 180819 [details] [review]
Bug 34326: Add forbidden notforloan status option

Test plan:

1) Add on your sip account an option called "forbidden_notforloan_status"
   and specify values separated by commas like "1,4,6" related to your
   notforloan statuses.
2) Restart your SIP server after that
3) Launch your SIP command on checkin with some items with these
   statuses. See the normal output
4) Apply this patch
5) Do step 3 again and see the new output with forbidden status and lib
   related to

Signed-off-by: Emmanuel Bétemps <e.betemps@gmail.com>
Comment 15 Emmanuel Bétemps 2025-04-11 08:44:34 UTC
Created attachment 180820 [details] [review]
Bug 34326: (follow-up) Add forbidden notforloan status option

Add a SIP option to prevent the checkin of items if they have a special status.

The follow-up fixes a bug where SIP reported a failed checkin even if the
checkin was correctly done by Koha.

Test plan (assuming ktd)
0- Apply the patch, restart services (restart_all with KTD) (no need to update database)

1- checkout 4 items to a single patron
In the following example I used barcode 3999900000017, 3999900000018,
3999900000019 and 3999900000020 and the patron cardnumber 23529000035676

2- Update these items notforloan value ($7 in marc21, $o in unimarc) with 3
different not for loan status and an empty not for loan status

In the following example I used
3999900000017 notforloan = 1 "Not for loan"
3999900000018 notforloan = 2 "Staff collection"
3999900000019 notforloan = 3 "Added to bundle"
3999900000020 notforloan is empty

3- Edit file /etc/koha/sites/kohadev/SIPconfig.xml
Add to one of the login the parameter "forbidden_notforloan_status"" with two
different notforloan status previously used

In the following example I used
<login id="term1" password="term1" delimiter="|" error-detect="enabled"
institution="CPL" encoding="ascii" checked_in_ok="1"
forbidden_notforloan_status="1,2" />

4- restart sip (in KTD "sudo koha-sip --stop kohadev" then "sudo koha-sip
--start kohadev")

5- checkin the first two items with sip_cli_emulator (the ones with the
forbidden notforloan status). The checkin should fail (response starts with
100), a screen message (AF field) is added to explain and these items should
still be checked out to the patron in the interface

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000017

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000018

6- checkin the last two items with sip_cli_emulator (the one with the allowed
notforloan status and the one without any notforloan status). The checkin
should succeed (response starts with 101) and these items should not appear in
the checked out items to the patron in the interface.

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000019

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000020

Signed-off-by: Emmanuel Bétemps <e.betemps@gmail.com>
Comment 16 Emmanuel Bétemps 2025-04-11 08:56:16 UTC
Hi,

- I changed the term1's password (in both staff interface and SIPconfig.xml) in Koha1234
- when I ran sip_cli_emulator.pl, I changed the '-sp' to get '-sp=Koha1234'

-> checkins which had to fail, failed
-> checkins which had to succeed, succeeded

(thanks again for this patch and test plan which taught me many things)
Comment 17 Marion Durand 2025-04-16 12:07:22 UTC
Created attachment 181003 [details] [review]
Bug 34326: Add forbidden notforloan status option

Test plan:

1) Add on your sip account an option called "forbidden_notforloan_status"
   and specify values separated by commas like "1,4,6" related to your
   notforloan statuses.
2) Restart your SIP server after that
3) Launch your SIP command on checkin with some items with these
   statuses. See the normal output
4) Apply this patch
5) Do step 3 again and see the new output with forbidden status and lib
   related to

Signed-off-by: Emmanuel Bétemps <e.betemps@gmail.com>
Sponsored-by: Médiathèque B. Pivot - Caluire-et-Cuire
Comment 18 Marion Durand 2025-04-16 12:07:25 UTC
Created attachment 181004 [details] [review]
Bug 34326: (follow-up) Add forbidden notforloan status option

Add a SIP option to prevent the checkin of items if they have a special status.

The follow-up fixes a bug where SIP reported a failed checkin even if the
checkin was correctly done by Koha.

Test plan (assuming ktd)
0- Apply the patch, restart services (restart_all with KTD) (no need to update database)

1- checkout 4 items to a single patron
In the following example I used barcode 3999900000017, 3999900000018,
3999900000019 and 3999900000020 and the patron cardnumber 23529000035676

2- Update these items notforloan value ($7 in marc21, $o in unimarc) with 3
different not for loan status and an empty not for loan status

In the following example I used
3999900000017 notforloan = 1 "Not for loan"
3999900000018 notforloan = 2 "Staff collection"
3999900000019 notforloan = 3 "Added to bundle"
3999900000020 notforloan is empty

3- Edit file /etc/koha/sites/kohadev/SIPconfig.xml
Add to one of the login the parameter "forbidden_notforloan_status"" with two
different notforloan status previously used

In the following example I used
<login id="term1" password="term1" delimiter="|" error-detect="enabled"
institution="CPL" encoding="ascii" checked_in_ok="1"
forbidden_notforloan_status="1,2" />

4- restart sip (in KTD "sudo koha-sip --stop kohadev" then "sudo koha-sip
--start kohadev")

5- checkin the first two items with sip_cli_emulator (the ones with the
forbidden notforloan status). The checkin should fail (response starts with
100), a screen message (AF field) is added to explain and these items should
still be checked out to the patron in the interface

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000017

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000018

6- checkin the last two items with sip_cli_emulator (the one with the allowed
notforloan status and the one without any notforloan status). The checkin
should succeed (response starts with 101) and these items should not appear in
the checked out items to the patron in the interface.

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000019

/kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1
-sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000020

Signed-off-by: Emmanuel Bétemps <e.betemps@gmail.com>
Sponsored-by: Médiathèque B. Pivot - Caluire-et-Cuire