Bug 39236 - writeoff_debts.pl does not run
Summary: writeoff_debts.pl does not run
Status: Pushed to stable
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Nick Clemens (kidclamp)
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
Depends on: 22435 31095
Blocks: 37920
  Show dependency treegraph
 
Reported: 2025-03-04 13:46 UTC by Nick Clemens (kidclamp)
Modified: 2025-03-23 14:15 UTC (History)
3 users (show)

See Also:
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:


Attachments
Bug 39236: writeoff_debts.pl needs adjustments (1.64 KB, patch)
2025-03-04 13:58 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 39236: writeoff_debts.pl needs adjustments (1.69 KB, patch)
2025-03-11 08:39 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 39236: writeoff_debts.pl needs adjustments (1.76 KB, patch)
2025-03-11 11:03 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 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