Koha-clms/misc/cronjobs
Matt Blenkinsop 01f5214f0f
Bug 26355: Add the class methods and endpoint to handle renewal
This is part of a sponsored piece of development from one of our customers. There was a specification of requirements but I was conscious of the ideas already discussed on this bug and wanted to try and develop a solution that would balance both sets of requirements. The concept works as follows:
- Self-renewal can be enabled and controlled at a category level
    - The window within which it is available is customisable (both pre and post-expiry)
        - Defaults to the NotifyBorrowerDeparture syspref
    - The amount in fines that block self-renewal is customisable
        - Defaults to the category level charges and then the noissescharge preference
    - The message to display if renewal fails is customisable
- Libraries can also add information to display to the patron at the start of the process.
- The self-renewal process will also respect the OPACPatronDetails and AutoApprovePatronProfileSettings sysprefs. If OPACPatronDetails is enabled, the renewal will redirect the patron to the OPAC details form and ask them to confirm their details are still correct. Any changes will be logged as patron modifications and approved in line with the auto approval syspref
- Renewal happens regardless of whether OPACPatronDetails is enabled, only the details changes are logged as modification requests
- Notifications are sent to the patron in line with their messaging preferences

Test plan:
1. Apply all patches and reset_all
2. In the intranet, navigate to patron categories and edit the ‘Patron’ category
3. Scroll to the bottom, there should be a section called ‘Account expiry and self-renewal’
4. Set ‘Allow self-renewal’ to Yes
5. Set Self-renewal availability period to be 10 days
6. Set Self-renewal availability post-expiry’ to also be 10 days and save
7. In system preferences, set the OPACPatronDetails preference to ‘Don’t allow’
8. Choose a patron that has the ‘Patron’ type category
9. Edit that patron so that you can log into the OPAC and set their expiry date to be yesterday’s date
10. Log into the OPAC as that patron (it may be easiest to do this in incognito as we will be swapping between the intranet and OPAC throughout the test plan and it will remove the need to keep logging out and in)
11. You should see a message that says “You are eligible for self-renewal. Please click here to renew your account.”
12. Click that link - you will be presented with a modal that says “Are you sure you want to renew your account?”
13. Click “Close” - we don’t want to complete renewal yet as there is more functionality available to test
14. Navigate to the patron category again, set ‘Self-renewal availability post-expiry’ to be 0
15. Refresh the OPAC, the self-renewal link should not be there as we are now outside the patron self-renewal window
16. Undo that change in the patron category, the link should reappear when refreshing the OPAC
17. Now set the patron’s expiry date to be tomorrow
18. In the category, set ‘Self-renewal availability period’ to be blank
19. Refresh the OPAC, it should still show the link as it is defaulting to NotifyBorrowerDeparture
20. Set NotifyBorrowerDeparture to 0
21. Refresh the OPAC, the link should vanish
22. In the category, restore ‘Self-renewal availability period’ to 10 days
23. Refresh the OPAC, the link should reappear
24. In the intranet, set the patron to be debarred using a manual restriction
25. In the OPAC refresh the page - self-renewal should no longer be available
26. Remove the restriction - the renewal link will be visible again
27. Set a fine on the patron record of 6 USD
28. Refresh the OPAC, the self-renewal link will be gone because we are over the global ‘noissuescharge’ preference value of 5
29. In the category, set ‘Checkout charge limit’ to 7
30. Refresh the OPAC, the link will be visible because we are now under the category charge
31. Add an additional fine of 2 to the patron account
32. Refresh the OPAC, the self-renewal link is gone
33. In the category, set ‘Self-renewal charge limit’ to be 10
34. Refresh the OPAC, the link will be visible again
35. In the category, set ‘Self-renewal failure message’ to be whatever you want
36. In the OPAC, refresh the page and then click into the self-renewal process
37. This time, click “No” - you should see the failure message you have just set
38. Click “Close” and refresh the page to reset this message
39. In the category, set a message in the “Self-renewal information message”
40. In the OPAC, refresh the page and then click the renewal link again
41. You should be met with the modal, this time displaying the information message we just set up in the patron attributes
42. Click “Yes” - you should see the “Are you sure you want to renew your account?” message again
43. This time when prompted with the “Are you sure” message, click “Yes”
44. The page should refresh and display a confirmation with the new expiry date.
45. In the intranet, view the patron’s record - the date should have been updated
46. In the Modification log tab, there should be a log entry for “Membership renewed”
47. Change the patron’s expiry date again, this time to be yesterday’s date
48. In the OPAC, click on “Personal detail”, the new expiry date should show there
49. Now set the OPACPatronDetails syspref to be “Allow”
50. Click on “Summary” again, the self-renewal link should be there again
51. Click into the self-renewal process and click “Yes” on your verification step
52. This time you should be met with a message that says “Confirm your account details”
53. Click “Continue” - you will be redirected to the OPAC details form
54. There should be a message at the top that says “Please verify your details to proceed with your self-renewal.”
55. Update a field somewhere on the patron form
56. Scroll to the bottom - the button should say “Submit renewal request”
57. Click this button
58. You will be shown the renewal confirmation message
59. In the intranet, on the homepage you should now see a modification request
60. Check the request, it should match the fields you changed - don’t approve or deny for now
61. Set ‘AutoApprovePatronProfileSettings’ in sysprefs to “Enable”
62. Reset your patron’s expiry date to today’s date
63. In the OPAC, click into Personal details and then back into Summary again (we need to do this to remove the success parameter from the URL)
64. The renewal link will be visible again - go through the process again
65. On the form, you should see an alert that you have already sent a modification request
66. This time, change a different field to the previous attempt
67. Submit the form
68. In the intranet there should be no modification this time and the change should be visible in the patron record as it has been automatically approved and handled as per the syspref
69. prove t/db_dependent/Koha/Patron.t
70. prove t/db_dependent/api/v1/patrons_self_renewal.t
71. yarn cypress run --spec t/cypress/integration/Islands/SelfRenewal.ts
72. Sign off!

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-05-01 09:30:00 -06:00
..
holds Bug 35700: Holds reminder cronjob - Fix --triggered switch if the day to send notice hits concurrent holidays 2025-10-09 14:58:38 -06:00
recalls Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
rss Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
social_data Bug 40748: Check for HTTP URLs and skip shell when using system() 2025-09-26 09:10:20 -06:00
thirdparty Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
CONFIGURE.gmail Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
advance_notices.pl Bug 41393: Set the correct reply to address for advance notices 2026-02-26 09:04:11 -07:00
anonymize_last_borrowers.pl Bug 23260: Update cron to exit if AnonymousPatron is not set 2026-03-05 08:33:48 -07:00
archive_purchase_suggestions.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
automatic_checkin.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
automatic_item_modification_by_age.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
automatic_renewals.pl Bug 23415: (QA follow-up) Fix spelling: oweing -> owing 2026-03-22 23:15:45 +01:00
backup.sh Bug 9235 - Hardcoded values in cronjobs/backup.sh 2012-12-21 07:20:50 -05:00
batch_anonymise.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
build_browser_and_cloud.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
cart_to_shelf.pl Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
check-url-quick.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
cleanup_database.pl Bug 41967: Ensure --cards argument accepts an integer in cleanup_database.pl 2026-04-16 15:54:07 -06:00
cloud-kw.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
cloud-sample.conf
…
create_koc_db.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
crontab.example Bug 39250: Add archive_purchase_suggestions.pl to cron.daily commented 2025-03-07 15:41:17 +01:00
debar_patrons_with_fines.pl Bug 39532: Use new FINES restriction type to avoid conflict with SUSPENSION 2025-11-21 08:41:51 -07:00
delete_items.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
delete_patrons.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
delete_records_via_leader.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
edi_cron.pl Bug 41851: (QA follow-up) Log completion before exiting 2026-04-17 09:18:03 -06:00
erm_run_harvester.pl Bug 41062: Add an option to erm_run_harvester.pl to specify provider IDs 2026-04-23 09:24:47 -06:00
fines.pl Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
gather_print_notices.pl Bug 35267: (follow-up) Fix PrintSlipCSS accordion and CSS in HTML output 2026-04-17 09:18:09 -06:00
harvest_oai.pl Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
import_webservice_batch.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
longoverdue.pl Bug 35612: Recorded branch context for OVERDUE, LOST, and PROCESSING fees 2026-02-27 11:38:49 -07:00
marc_ordering_process.pl Bug 40953: marc_ordering_process.pl broken due to accidental newline 2025-10-06 09:15:23 -06:00
membership_expiry.pl Bug 26355: Add the class methods and endpoint to handle renewal 2026-05-01 09:30:00 -06:00
merge_authorities.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
notice_unprocessed_suggestions.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
overdue_notices.pl Bug 41316: Use patrons homelibrary for selecting overdues that should be sent 2026-03-05 08:33:54 -07:00
patron_emailer.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
plugins_nightly.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
printoverdues.sh Bug 10127 : Printoverdues.sh should tar only pdf files 2013-07-16 15:47:13 +00:00
process_message_queue.pl Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
purge_suggestions.pl Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
reconcile_balances.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
remove_temporary_edifiles.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
restrict_patrons_with_failed_notices.pl Bug 39749: RestrictPatronsWithFailedNotices should not trigger for DUPLICATE_MESSAGE failures 2026-03-05 08:33:52 -07:00
runreport.pl Bug 33308: (QA follow-up) Use simplified File::Transport API from bug 40811 2026-01-21 15:28:18 -07:00
serialsUpdate.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
sftp_file.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
share_usage_with_koha_community.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
sitemap.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
staticfines.pl Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
stockrotation.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
update_patrons_category.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
update_totalissues.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
writeoff_debts.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00