Bug 41437

Summary: Patrons should never receive two consecutive auto renewal failure notices
Product: Koha Reporter: Lucas Gass (lukeg) <lucas>
Component: CirculationAssignee: Lucas Gass (lukeg) <lucas>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: gmcharlt, kyle, lisette
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 41437: Prevent sending an auto renewal failure if one already exists

Description Lucas Gass (lukeg) 2025-12-11 21:48:13 UTC
To recreate:

0. Set RestrictionBlockRenewing to 'block'
1. Set up a patron for auto rewenal and then check something out to them. Make sure the patron has an email address and has messaging preferences set to receive auto renewals. 
2. Now do something that would make an auto renewal fail. I placed the item from step 1 on hold for someone else.
2. Run the auto renewals cron ( perl /kohadevbox/koha/misc/cronjobs/automatic_renewals.pl -c -v )
3. A notice should be generated telling the patron the thing cannot renew with the error code of `on_reserve`. ( good )
4. Restrict the patron, doing this manually is fine. 
5. Run the auto renewals cron again.
6. Another auto rewenal is sent tell the patron the thing cannot renew with the error code `restriction`. ( bad )

This is confusing. The item is still on hold, we shouldn't inform the patron that the items cannot auto renew, they already know!
Comment 1 Lucas Gass (lukeg) 2025-12-17 13:09:45 UTC
I think we should be checking the previous auto renewal error, if it exists we should send a new failure notice. The exception is 'auto_too_soon'.
Comment 2 Lucas Gass (lukeg) 2025-12-17 14:22:24 UTC
Created attachment 190584 [details] [review]
Bug 41437: Prevent sending an auto renewal failure if one already exists

To test:
0. Set RestrictionBlockRenewing to 'block'
1. Set up a patron for auto rewenal and then check something out to them. Make sure the patron has an email address and has messaging preferences set to receive auto renewals.
2. Now do something that would make an auto renewal fail. I placed the item from step 1 on hold for someone else.
2. Run the auto renewals cron ( perl /kohadevbox/koha/misc/cronjobs/automatic_renewals.pl -c -v )
3. A notice should be generated telling the patron the thing cannot renew with the error code of `on_reserve`. ( good )
4. Restrict the patron, doing this manually is fine.
5. Run the auto renewals cron again.
6. Another auto renewal is sent tell the patron the thing cannot renew with the error code `restriction`. ( bad )
7. APPLY PATCH, restart_all
8. Reset the test plan and try all the steps again. Tthis time at step 8 you should NOT get a 2nd consecutive failure notice.
9. Lift the restriction and run the automatic_renewals.pl script once again, you shold get a notice that the renewal succeeds.
10. Repeat this process for digest notices.