From 83ddf4244928b601727033a6d1ba3c037553fd86 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. --- C4/Circulation.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 2496a66abc2..7de1c9b9d5e 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3545,8 +3545,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