Bug 30331 - Allow RenewalPeriodBase behavior to differ between manual and automatic renewals
Summary: Allow RenewalPeriodBase behavior to differ between manual and automatic renewals
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Lucas Gass (lukeg)
QA Contact: Andrew Fuerste-Henry
URL:
Keywords:
Depends on: 40969
Blocks: 42046 41771
  Show dependency treegraph
 
Reported: 2022-03-22 12:33 UTC by Andrew Fuerste-Henry
Modified: 2026-03-09 21:05 UTC (History)
8 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: Sponsored
Comma delimited list of Sponsors: MAIN Library Alliance
Crowdfunding goal: 0
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This patchset splits the RenewalPeriodBase system preference into two separate system preferences so the renewal base period can be controlled separately for for manual and automatic renewals. The new system preferences are ManualRenewalPeriodBase and AutomaticRenewalPeriodBase.
Version(s) released in:
26.05.00
Circulation function:


Attachments
Bug 30331: Rename RenewalPeriodBase as ManualRenewalPeriodBase and add AutomaticRenewalPeriodBase sys pref (8.99 KB, patch)
2025-10-07 15:54 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 30331: Implement manual and automatic renewal base period (2.34 KB, patch)
2025-10-07 18:07 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 30331: Unit tests (6.74 KB, patch)
2025-10-07 20:53 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 30331: Update system preference descriptions (3.18 KB, patch)
2025-10-07 21:06 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 30331: Rename RenewalPeriodBase as ManualRenewalPeriodBase and add AutomaticRenewalPeriodBase sys pref (8.99 KB, patch)
2025-10-10 18:05 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 30331: Implement manual and automatic renewal base period (2.34 KB, patch)
2025-10-10 18:05 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 30331: Unit tests (6.39 KB, patch)
2025-10-10 18:05 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 30331: Update system preference descriptions (3.18 KB, patch)
2025-10-10 18:05 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 30331: Rename RenewalPeriodBase as ManualRenewalPeriodBase and add AutomaticRenewalPeriodBase sys pref (9.05 KB, patch)
2025-10-10 18:08 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 30331: Implement manual and automatic renewal base period (2.39 KB, patch)
2025-10-10 18:08 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 30331: Unit tests (6.45 KB, patch)
2025-10-10 18:08 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 30331: Update system preference descriptions (3.24 KB, patch)
2025-10-10 18:08 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 30331: Rename RenewalPeriodBase as ManualRenewalPeriodBase and add AutomaticRenewalPeriodBase sys pref (9.11 KB, patch)
2026-01-09 19:58 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 30331: Implement manual and automatic renewal base period (2.46 KB, patch)
2026-01-09 19:58 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 30331: Unit tests (6.51 KB, patch)
2026-01-09 19:58 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 30331: Update system preference descriptions (3.30 KB, patch)
2026-01-09 19:58 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 30331: (follow-up) Fix count of tests (780 bytes, patch)
2026-01-09 19:58 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 30331: Rename RenewalPeriodBase as ManualRenewalPeriodBase and add AutomaticRenewalPeriodBase sys pref (9.12 KB, patch)
2026-01-29 20:12 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 30331: Implement manual and automatic renewal base period (2.93 KB, patch)
2026-01-29 20:12 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 30331: Unit tests (11.52 KB, patch)
2026-01-29 20:12 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 30331: Update system preference descriptions (3.30 KB, patch)
2026-01-29 20:12 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 30331: Update tests, mock the system preference (856 bytes, patch)
2026-01-29 20:26 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Fuerste-Henry 2022-03-22 12:33:29 UTC
We should have a way to make auto-renewals and manual renewals follow different RenewalPeriodBase behavior.

I'm working with a library that uses a mix of manual and automatic renewals. For items that auto-renew, the renewal happens two days before the item is due, so they want RenewalPeriodBase set to add time on to the existing due date so the patron gets their full renewal period. But for items renewed manually, they want RenewalPeriodBase set to calculate from the renewal date, though, so patrons can't renew early and lock in extra time with the item.
Comment 1 Lucas Gass (lukeg) 2025-10-07 15:54:04 UTC
Created attachment 187537 [details] [review]
Bug 30331: Rename RenewalPeriodBase as ManualRenewalPeriodBase and add AutomaticRenewalPeriodBase sys pref
Comment 2 Lucas Gass (lukeg) 2025-10-07 18:07:37 UTC
Created attachment 187543 [details] [review]
Bug 30331: Implement manual and automatic renewal base period

To test:

1. APPLY PATCH, updatedatabase, restart_all
2. Go to your circulation rules and do the following:
    -Automatic renewal: Yes
    -No renewal before: 5
    -No automatic renewal before: 5
    -Renewal period: 5

3. Set ManualRenewalPeriodBase to "the old due date of the checkout".
4. Set  AutomaticRenewalPeriodBase to "current date".

5. Check out an item and set the due date to 2 days from today
6. Attempt to manually renewal the item.
7. Notice the new date is calculated based on the old checkout date.
8. Check out an item another item and set the due date to 2 days from today.
9. Run `perl /kohadevbox/koha/misc/cronjobs/automatic_renewals.pl -c -v`
10. Notice the new date is calculated based on the current date.

11. Set ManualRenewalPeriodBase to "current date".
12. Set  AutomaticRenewalPeriodBase to "the old due date of the checkout".

13. Check out an item and set the due date to 2 days from today
14. Attempt to manually renewal the item.
15. Notice the new date is calculated based on the current date.
16. Check out an item another item and set the due date to 2 days from today.
17. Run `perl /kohadevbox/koha/misc/cronjobs/automatic_renewals.pl -c -v`
18. Notice the new date is calculated based on the old checkout date.
Comment 3 Lucas Gass (lukeg) 2025-10-07 20:53:20 UTC
Created attachment 187552 [details] [review]
Bug 30331: Unit tests
Comment 4 Lucas Gass (lukeg) 2025-10-07 21:06:44 UTC
Created attachment 187553 [details] [review]
Bug 30331: Update system preference descriptions
Comment 5 Lucas Gass (lukeg) 2025-10-10 18:05:37 UTC
Created attachment 187757 [details] [review]
Bug 30331: Rename RenewalPeriodBase as ManualRenewalPeriodBase and add AutomaticRenewalPeriodBase sys pref
Comment 6 Lucas Gass (lukeg) 2025-10-10 18:05:40 UTC
Created attachment 187758 [details] [review]
Bug 30331: Implement manual and automatic renewal base period

To test:

1. APPLY PATCH, updatedatabase, restart_all
2. Go to your circulation rules and do the following:
    -Automatic renewal: Yes
    -No renewal before: 5
    -No automatic renewal before: 5
    -Renewal period: 5

3. Set ManualRenewalPeriodBase to "the old due date of the checkout".
4. Set  AutomaticRenewalPeriodBase to "current date".

5. Check out an item and set the due date to 2 days from today
6. Attempt to manually renewal the item.
7. Notice the new date is calculated based on the old checkout date.
8. Check out an item another item and set the due date to 2 days from today.
9. Run `perl /kohadevbox/koha/misc/cronjobs/automatic_renewals.pl -c -v`
10. Notice the new date is calculated based on the current date.

11. Set ManualRenewalPeriodBase to "current date".
12. Set  AutomaticRenewalPeriodBase to "the old due date of the checkout".

13. Check out an item and set the due date to 2 days from today
14. Attempt to manually renewal the item.
15. Notice the new date is calculated based on the current date.
16. Check out an item another item and set the due date to 2 days from today.
17. Run `perl /kohadevbox/koha/misc/cronjobs/automatic_renewals.pl -c -v`
18. Notice the new date is calculated based on the old checkout date.
Comment 7 Lucas Gass (lukeg) 2025-10-10 18:05:44 UTC
Created attachment 187759 [details] [review]
Bug 30331: Unit tests
Comment 8 Lucas Gass (lukeg) 2025-10-10 18:05:48 UTC
Created attachment 187760 [details] [review]
Bug 30331: Update system preference descriptions
Comment 9 Andrew Fuerste-Henry 2025-10-10 18:08:42 UTC
Created attachment 187761 [details] [review]
Bug 30331: Rename RenewalPeriodBase as ManualRenewalPeriodBase and add AutomaticRenewalPeriodBase sys pref

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 10 Andrew Fuerste-Henry 2025-10-10 18:08:45 UTC
Created attachment 187762 [details] [review]
Bug 30331: Implement manual and automatic renewal base period

To test:

1. APPLY PATCH, updatedatabase, restart_all
2. Go to your circulation rules and do the following:
    -Automatic renewal: Yes
    -No renewal before: 5
    -No automatic renewal before: 5
    -Renewal period: 5

3. Set ManualRenewalPeriodBase to "the old due date of the checkout".
4. Set  AutomaticRenewalPeriodBase to "current date".

5. Check out an item and set the due date to 2 days from today
6. Attempt to manually renewal the item.
7. Notice the new date is calculated based on the old checkout date.
8. Check out an item another item and set the due date to 2 days from today.
9. Run `perl /kohadevbox/koha/misc/cronjobs/automatic_renewals.pl -c -v`
10. Notice the new date is calculated based on the current date.

11. Set ManualRenewalPeriodBase to "current date".
12. Set  AutomaticRenewalPeriodBase to "the old due date of the checkout".

13. Check out an item and set the due date to 2 days from today
14. Attempt to manually renewal the item.
15. Notice the new date is calculated based on the current date.
16. Check out an item another item and set the due date to 2 days from today.
17. Run `perl /kohadevbox/koha/misc/cronjobs/automatic_renewals.pl -c -v`
18. Notice the new date is calculated based on the old checkout date.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 11 Andrew Fuerste-Henry 2025-10-10 18:08:48 UTC
Created attachment 187763 [details] [review]
Bug 30331: Unit tests

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 12 Andrew Fuerste-Henry 2025-10-10 18:08:51 UTC
Created attachment 187764 [details] [review]
Bug 30331: Update system preference descriptions

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 13 Andrew Fuerste-Henry 2026-01-09 19:58:03 UTC
Created attachment 191219 [details] [review]
Bug 30331: Rename RenewalPeriodBase as ManualRenewalPeriodBase and add AutomaticRenewalPeriodBase sys pref

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 14 Andrew Fuerste-Henry 2026-01-09 19:58:06 UTC
Created attachment 191220 [details] [review]
Bug 30331: Implement manual and automatic renewal base period

To test:

1. APPLY PATCH, updatedatabase, restart_all
2. Go to your circulation rules and do the following:
    -Automatic renewal: Yes
    -No renewal before: 5
    -No automatic renewal before: 5
    -Renewal period: 5

3. Set ManualRenewalPeriodBase to "the old due date of the checkout".
4. Set  AutomaticRenewalPeriodBase to "current date".

5. Check out an item and set the due date to 2 days from today
6. Attempt to manually renewal the item.
7. Notice the new date is calculated based on the old checkout date.
8. Check out an item another item and set the due date to 2 days from today.
9. Run `perl /kohadevbox/koha/misc/cronjobs/automatic_renewals.pl -c -v`
10. Notice the new date is calculated based on the current date.

11. Set ManualRenewalPeriodBase to "current date".
12. Set  AutomaticRenewalPeriodBase to "the old due date of the checkout".

13. Check out an item and set the due date to 2 days from today
14. Attempt to manually renewal the item.
15. Notice the new date is calculated based on the current date.
16. Check out an item another item and set the due date to 2 days from today.
17. Run `perl /kohadevbox/koha/misc/cronjobs/automatic_renewals.pl -c -v`
18. Notice the new date is calculated based on the old checkout date.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 15 Andrew Fuerste-Henry 2026-01-09 19:58:10 UTC
Created attachment 191221 [details] [review]
Bug 30331: Unit tests

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 16 Andrew Fuerste-Henry 2026-01-09 19:58:13 UTC
Created attachment 191222 [details] [review]
Bug 30331: Update system preference descriptions

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 17 Andrew Fuerste-Henry 2026-01-09 19:58:16 UTC
Created attachment 191223 [details] [review]
Bug 30331: (follow-up) Fix count of tests

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 18 Lucas Gass (lukeg) 2026-01-29 20:12:44 UTC
Created attachment 192195 [details] [review]
Bug 30331: Rename RenewalPeriodBase as ManualRenewalPeriodBase and add AutomaticRenewalPeriodBase sys pref

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 19 Lucas Gass (lukeg) 2026-01-29 20:12:47 UTC
Created attachment 192196 [details] [review]
Bug 30331: Implement manual and automatic renewal base period

To test:

1. APPLY PATCH, updatedatabase, restart_all
2. Go to your circulation rules and do the following:
    -Automatic renewal: Yes
    -No renewal before: 5
    -No automatic renewal before: 5
    -Renewal period: 5

3. Set ManualRenewalPeriodBase to "the old due date of the checkout".
4. Set  AutomaticRenewalPeriodBase to "current date".

5. Check out an item and set the due date to 2 days from today
6. Attempt to manually renewal the item.
7. Notice the new date is calculated based on the old checkout date.
8. Check out an item another item and set the due date to 2 days from today.
9. Run `perl /kohadevbox/koha/misc/cronjobs/automatic_renewals.pl -c -v`
10. Notice the new date is calculated based on the current date.

11. Set ManualRenewalPeriodBase to "current date".
12. Set  AutomaticRenewalPeriodBase to "the old due date of the checkout".

13. Check out an item and set the due date to 2 days from today
14. Attempt to manually renewal the item.
15. Notice the new date is calculated based on the current date.
16. Check out an item another item and set the due date to 2 days from today.
17. Run `perl /kohadevbox/koha/misc/cronjobs/automatic_renewals.pl -c -v`
18. Notice the new date is calculated based on the old checkout date.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 20 Lucas Gass (lukeg) 2026-01-29 20:12:49 UTC
Created attachment 192197 [details] [review]
Bug 30331: Unit tests

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 21 Lucas Gass (lukeg) 2026-01-29 20:12:52 UTC
Created attachment 192198 [details] [review]
Bug 30331: Update system preference descriptions

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 22 Lucas Gass (lukeg) 2026-01-29 20:26:10 UTC
Created attachment 192199 [details] [review]
Bug 30331: Update tests, mock the system preference
Comment 23 Lucas Gass (lukeg) 2026-01-30 17:55:36 UTC
Nice work everyone!

Pushed to main for 26.05
Comment 24 Jonathan Druart 2026-02-02 09:30:07 UTC
There is a diff in syspref's description for existing installs:

    #   Failed test 'Comparing AutomaticRenewalPeriodBase'       
    #   at t/db_dependent/check_sysprefs.t line 135.                                                      
    #     Structures begin differing at:                                                                  
    #          $got->{explanation} = 'Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal, for automatic renewals'
    #     $expected->{explanation} = 'Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal, for automatic renewals '
                                                                                                          
    #   Failed test 'Comparing ManualRenewalPeriodBase'
    #   at t/db_dependent/check_sysprefs.t line 135.                                                      
    #     Structures begin differing at:                                                                  
    #          $got->{explanation} = 'Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal '
    #     $expected->{explanation} = 'Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal, for manual renewals '
    # Looks like you failed 2 tests of 1753.
Comment 25 Lucas Gass (lukeg) 2026-02-04 16:24:51 UTC
(In reply to Jonathan Druart from comment #24)
> There is a diff in syspref's description for existing installs:
> 
>     #   Failed test 'Comparing AutomaticRenewalPeriodBase'       
>     #   at t/db_dependent/check_sysprefs.t line 135.                        
> 
>     #     Structures begin differing at:                                    
> 
>     #          $got->{explanation} = 'Set whether the renewal date should be
> counted from the date_due or from the moment the Patron asks for renewal,
> for automatic renewals'
>     #     $expected->{explanation} = 'Set whether the renewal date should be
> counted from the date_due or from the moment the Patron asks for renewal,
> for automatic renewals '
>                                                                             
> 
>     #   Failed test 'Comparing ManualRenewalPeriodBase'
>     #   at t/db_dependent/check_sysprefs.t line 135.                        
> 
>     #     Structures begin differing at:                                    
> 
>     #          $got->{explanation} = 'Set whether the renewal date should be
> counted from the date_due or from the moment the Patron asks for renewal '
>     #     $expected->{explanation} = 'Set whether the renewal date should be
> counted from the date_due or from the moment the Patron asks for renewal,
> for manual renewals '
>     # Looks like you failed 2 tests of 1753.

Instead of fixing here I am filing as a new bug: 

https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41771