From 61f3924d904bb4f5f96363aa76098c85c282ce0a Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 7 Oct 2025 18:06:27 +0000 Subject: [PATCH] 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 --- C4/Circulation.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index d96fd7c0e12..884d0b15bfd 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3471,8 +3471,10 @@ sub AddRenewal { my $itemtype = $item_object->effective_itemtype; unless ($datedue) { + my $renewal_base_pref = $automatic ? 'AutomaticRenewalPeriodBase' : 'ManualRenewalPeriodBase'; + $datedue = - ( C4::Context->preference('ManualRenewalPeriodBase') eq 'date_due' ) + ( C4::Context->preference($renewal_base_pref) eq 'date_due' ) ? dt_from_string( $issue->date_due, 'sql' ) : dt_from_string(); $datedue = CalcDateDue( $datedue, $itemtype, $circ_library->branchcode, $patron, 'is a renewal' ); -- 2.39.5