From 5dc09da263cd3c3a790b4c2dd392399de1810572 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Wed, 21 Jan 2026 09:46:08 +0000 Subject: [PATCH] Bug 26355: Update opac-user and opac-memberentry to support the renewal workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 additional verification steps. This was a requirement for our customer and to enable it I’ve opted to use Patron attribute types because these are already configurable by category and library. This means you can add additional verification questions such as ‘Do you still live within X miles of the library?” - 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 0 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 Intranet, navigate to Admin > Patron attribute types 40. Click to create a new attribute 41. The code isn’t important here but we do need a description - this can be anything for the plan, for example “Do you still live locally to this library?” 42. Tick the new checkbox - Self-renewal verification check 43. Create a second attribute, this time set the description to something like “We don’t want to see this one!”. Do NOT click the self-renewal checkbox this time 44. In the OPAC, refresh the page and then click the renewal link again 45. You should be met with the modal, this time asking the verification question we just set up in the patron attributes 46. Click “Yes” - you should see the “Are you sure you want to renew your account?” message again 47. The second attribute that we set up without the self-renewal checkbox selected should not appear 48. This time when prompted with the “Are you sure” message, click “Yes” 49. The page should refresh and display a confirmation with the new expiry date. 50. In the intranet, view the patron’s record - the date should have been updated 51. In the Modification log tab, there should be a log entry for “Membership renewed” 52. Change the patron’s expiry date again, this time to be yesterday’s date 53. In the OPAC, click on “Personal detail”, the new expiry date should show there 54. Now set the OPACPatronDetails syspref to be “Allow” 55. Click on “Summary” again, the self-renewal link should be there again 56. Click into the self-renewal process and click “Yes” on your verification step 57. This time you should be met with a message that says “Confirm your account details” 58. Click “Continue” - you will be redirected to the OPAC details form 59. There should be a message at the top that says “Please verify your details to proceed with your self-renewal.” 60. Update a field somewhere on the patron form 61. Scroll to the bottom - the button should say “Submit renewal request” 62. Click this button 63. You will be shown the renewal confirmation message 64. In the intranet, on the homepage you should now see a modification request 65. Check the request, it should match the fields you changed - don’t approve or deny for now 66. Set ‘AutoApprovePatronProfileSettings’ in sysprefs to “Enable” 67. Reset your patron’s expiry date to today’s date 68. 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) 69. The renewal link will be visible again - go through the process again 70. On the form, you should see an alert that you have already sent a modification request 71. This time, change a different field to the previous attempt 72. Submit the form 73. 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 74. prove t/db_dependent/Koha/Patron.t 75. prove t/db_dependent/api/v1/patrons_self_renewal.t 76. yarn cypress run --spec t/cypress/integration/Islands/SelfRenewal.ts 77. Sign off! Sponsored-by: Westminster City Council Sponsored-by: Royal Borough of Kensington and Chelsea Sponsored-by: LibraryOn Signed-off-by: Hannah Dunne-Howrie --- .../bootstrap/en/modules/opac-memberentry.tt | 60 ++++++++++++++++--- .../bootstrap/en/modules/opac-user.tt | 41 ++++++++++++- opac/opac-memberentry.pl | 23 ++----- opac/opac-user.pl | 37 ++++++++---- 4 files changed, 121 insertions(+), 40 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt index 8a7563c7756..97fbbbe316f 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -92,6 +92,9 @@ [% IF nochanges %]
No changes were made.
[% END %] + [% IF self_renewal %] +
Please verify your details to proceed with your self-renewal.
+ [% END %] [% END %] [% IF empty_mandatory_fields %] @@ -241,7 +244,7 @@ > [% END %] -
+ [% INCLUDE 'csrf-token.inc' %] [% FOREACH field = ['streetnumber' 'streettype' 'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'preferred_name' 'middle_name' 'dateofbirth' 'initials' 'pronouns' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' 'B_streetnumber' 'B_address' 'B_address2' 'B_city' 'B_state' 'B_zipcode' 'B_country' 'B_phone' 'B_email' 'contactnote' 'altcontactsurname' 'altcontactfirstname' 'altcontactaddress1' 'altcontactaddress2' 'altcontactaddress3' 'altcontactstate' 'altcontactzipcode' 'altcontactcountry' 'altcontactphone' 'password' 'lang' ] %] @@ -1362,7 +1365,11 @@ [% IF OPACPatronDetails %]
- + [% IF (self_renewal) %] + + [% ELSE %] + + [% END %]
[% END %] [% ELSE %] @@ -1391,16 +1398,23 @@ [% INCLUDE 'calendar.inc' %] + [%# hold suspend modal form %]