Bug 41730

Summary: Automate change Withdrawn status when item is paid for
Product: Koha Reporter: Andrew Fuerste-Henry <andrew>
Component: Fines and feesAssignee: Nick Clemens (kidclamp) <nick>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: nick, raymund.delahunty
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22740
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Crowdfunding committed: 0
Crowdfunding contact: Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on:    
Bug Blocks: 41731    
Attachments: Bug 41730: Add ability to update item withdrawn status when lost item paid
Bug 41730: Unit tests
Bug 41730: Correct SQL punctuation in atomicupdate
Bug 41730: Add ability to update item withdrawn status when lost item paid
Bug 41730: Unit tests
Bug 41730: Add ability to update item withdrawn status when lost item paid
Bug 41730: Unit tests
Bug 41730: Add ability to update item withdrawn status when lost item paid
Bug 41730: Unit tests

Description Andrew Fuerste-Henry 2026-01-28 20:36:25 UTC
For many libraries, when a lost item is paid for the library does not want the item back -- it should not check in, it should not get marked found, it should not generate a lost fee refund. Functionally, the patron has purchased the book and gets to keep it (should they find it).

It would be helpful for Koha to automatically apply a withdrawn status when an item is paid, similar to the UpdateItemLostStatusWhenPaid functionality added in Bug 22740.
Comment 1 Nick Clemens (kidclamp) 2026-01-28 21:16:54 UTC
Created attachment 192137 [details] [review]
Bug 41730: Add ability to update item withdrawn status when lost item paid

This patch implements a new system preference, "UpdateItemWithdrawnStatusWhenPaid" that allows you to specify the withdrawn status to change an item to when the outstanding balance of a lost item is paid. This preference is tied to the WITHDRAWN authorised values set.

Test Plan:
 - Set one the system preference to any of the available values
 - Set an item as lost
 - Make a manual invoice for your desired user and assign it to the barcode of the above item
 - Save and Pay
 - Select Pay
 - Pay
 - Note that the withdrawn status of the item has changed to the status you set with the system preference
 - Check that when the system preference is left blank and no option is chosen, the withdrawn status does not update.
Comment 2 Nick Clemens (kidclamp) 2026-01-28 21:16:56 UTC
Created attachment 192138 [details] [review]
Bug 41730: Unit tests
Comment 3 Ray Delahunty 2026-01-30 11:34:50 UTC
Attempted signoff, and everything looks OK in a biblibre sandbox (borrowernumber=19). Test plan 100%. Unable to return (for refund) item made 'Withdrawn- item lost' as (my new) WITHDARWN status. Unsure if I should signoff as log file reported an error. 

Bug 41730 - Automate change Withdrawn status when item is paid for
192137 - Bug 41730: Add ability to update item withdrawn status when lost item paid
192138 - Bug 41730: Unit tests
Apply? [(y)es, (n)o, (i)nteractive] Applying: Bug 41730: Add ability to update item withdrawn status when lost item paid
Applying: Bug 41730: Unit tests

DEV atomic update /kohadevbox/koha/installer/data/mysql/atomicupdate/bug_41730.pl  [11:08:24]: Bug 41730 - Add UpdateItemWithdrawnStatusWhenPaid
	[31mERROR: {UNKNOWN}: DBI Exception: DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 2 at /kohadevbox/koha/C4/Installer.pm line 825
	[0m
Comment 4 Andrew Fuerste-Henry 2026-01-30 16:57:32 UTC
Created attachment 192252 [details] [review]
Bug 41730: Correct SQL punctuation in atomicupdate
Comment 5 Nick Clemens (kidclamp) 2026-01-30 17:02:57 UTC
Created attachment 192255 [details] [review]
Bug 41730: Add ability to update item withdrawn status when lost item paid

This patch implements a new system preference, "UpdateItemWithdrawnStatusWhenPaid" that allows you to specify the withdrawn status to change an item to when the outstanding balance of a lost item is paid. This preference is tied to the WITHDRAWN authorised values set.

Test Plan:
 - Set one the system preference to any of the available values
 - Set an item as lost
 - Make a manual invoice for your desired user and assign it to the barcode of the above item
 - Save and Pay
 - Select Pay
 - Pay
 - Note that the withdrawn status of the item has changed to the status you set with the system preference
 - Check that when the system preference is left blank and no option is chosen, the withdrawn status does not update.
Comment 6 Nick Clemens (kidclamp) 2026-01-30 17:03:00 UTC
Created attachment 192256 [details] [review]
Bug 41730: Unit tests
Comment 7 Andrew Fuerste-Henry 2026-01-30 18:24:28 UTC
Created attachment 192263 [details] [review]
Bug 41730: Add ability to update item withdrawn status when lost item paid

This patch implements a new system preference, "UpdateItemWithdrawnStatusWhenPaid" that allows you to specify the withdrawn status to change an item to when the outstanding balance of a lost item is paid. This preference is tied to the WITHDRAWN authorised values set.

Test Plan:
 - Set one the system preference to any of the available values
 - Set an item as lost
 - Make a manual invoice for your desired user and assign it to the barcode of the above item
 - Save and Pay
 - Select Pay
 - Pay
 - Note that the withdrawn status of the item has changed to the status you set with the system preference
 - Check that when the system preference is left blank and no option is chosen, the withdrawn status does not update.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 8 Andrew Fuerste-Henry 2026-01-30 18:24:31 UTC
Created attachment 192264 [details] [review]
Bug 41730: Unit tests

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 9 Biblibre Sandboxes 2026-01-30 18:57:23 UTC
Created attachment 192269 [details] [review]
Bug 41730: Add ability to update item withdrawn status when lost item paid

This patch implements a new system preference, "UpdateItemWithdrawnStatusWhenPaid" that allows you to specify the withdrawn status to change an item to when the outstanding balance of a lost item is paid. This preference is tied to the WITHDRAWN authorised values set.

Test Plan:
 - Set one the system preference to any of the available values
 - Set an item as lost
 - Make a manual invoice for your desired user and assign it to the barcode of the above item
 - Save and Pay
 - Select Pay
 - Pay
 - Note that the withdrawn status of the item has changed to the status you set with the system preference
 - Check that when the system preference is left blank and no option is chosen, the withdrawn status does not update.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Ray <raymund.delahunty@outlook.com>
Comment 10 Biblibre Sandboxes 2026-01-30 18:57:25 UTC
Created attachment 192270 [details] [review]
Bug 41730: Unit tests

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Ray <raymund.delahunty@outlook.com>
Comment 11 Ray Delahunty 2026-01-30 19:11:04 UTC
The test plan worked just fine, and I added a signoff, but as part of the test I did break the rule that WITHDRAWN authorised values must be numerical, when I created a new value for it. Then (as I expected) the change was not made. I’m tempted to add a new bug suggesting that the Description field in the Authorised value screen mentions the numerical requirement, while we wait for a fix to Bug 27512 - Block creation of invalid authorised values for LOST, NOTFORLOAN, DAMAGED, RESTRICTED, and WITHDRAWN. Just a thought…