Bug 39236

Summary: writeoff_debts.pl does not run
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: Command-line UtilitiesAssignee: Nick Clemens (kidclamp) <nick>
Status: Pushed to stable --- QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: normal    
Priority: P5 - low CC: martin.renvoize, paul.derscheid, robin
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.05.00,24.11.03
Circulation function:
Bug Depends on: 22435, 31095    
Bug Blocks: 37920    
Attachments: Bug 39236: writeoff_debts.pl needs adjustments
Bug 39236: writeoff_debts.pl needs adjustments
Bug 39236: writeoff_debts.pl needs adjustments

Description Nick Clemens (kidclamp) 2025-03-04 13:46:58 UTC
To recreate:
Add a fine to a patron account
Run the cronjob:
perl misc/cronjobs/writeoff_debts.pl -v -c --added-after 2025-01-01
Attempting to write off 1 debts
DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Data truncated for column 'type' at row 1 at /kohadevbox/koha/Koha/Object.pm line 174
Invalid value passed, type=WRITEOFF vim misc/cronjobs/writeoff_debts.pl 

Edit the cronjob and change the 'WRITEOFF' in the account offset to 'CREATE'

perl misc/cronjobs/writeoff_debts.pl -v -c --added-after 2025-01-01
Attempting to write off 1 debts
{UNKNOWN}: Can't locate object method "find" via package "Koha::Patrons" (perhaps you forgot to load "Koha::Patrons"?) at /kohadevbox/koha/Koha/Patron/Debarments.pm line 316. at misc/cronjobs/writeoff_debts.pl line 128
Comment 1 Nick Clemens (kidclamp) 2025-03-04 13:58:08 UTC Comment hidden (obsolete)
Comment 2 Magnus Enger 2025-03-11 08:39:48 UTC
Created attachment 179142 [details] [review]
Bug 39236: writeoff_debts.pl needs adjustments

From bug 22435 - we need to use 'CREATE' as the account_offset type
From bug 31095 - we need to 'use Koha::Patrons;'

To test:
1 - Add a fine to a patron account
2 - perl misc/cronjobs/writeoff_debts.pl -v -c --added-after 2025-01-01
3 - Cronjob dies
4 - Apply patch
5 - Rerun
6 - Job succeeds!
7 - Confirm patron's fine is written off
8 - Sign off

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Comment 3 Martin Renvoize (ashimema) 2025-03-11 11:03:04 UTC
Created attachment 179155 [details] [review]
Bug 39236: writeoff_debts.pl needs adjustments

From bug 22435 - we need to use 'CREATE' as the account_offset type
From bug 31095 - we need to 'use Koha::Patrons;'

To test:
1 - Add a fine to a patron account
2 - perl misc/cronjobs/writeoff_debts.pl -v -c --added-after 2025-01-01
3 - Cronjob dies
4 - Apply patch
5 - Rerun
6 - Job succeeds!
7 - Confirm patron's fine is written off
8 - Sign off

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize (ashimema) 2025-03-11 11:04:28 UTC
I'm confused by how this has been broken for years.. we've been using it in production for a long time and not notices.. maybe strict mode makes the difference

Either way, this is a sensible change and causes no regressions.

Passing QA
Comment 5 Katrin Fischer 2025-03-17 07:28:30 UTC
Pushed for 25.05!

Well done everyone, thank you!
Comment 6 Paul Derscheid 2025-03-23 14:09:36 UTC
Nice work everyone!

Pushed to 24.11.x for 24.11.03