From ae28e6f2e125fe2d3c0314d09fe2e44fafffd2f1 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 Signed-off-by: Andrew Fuerste Henry --- C4/Circulation.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 65e61f71cf9..52b04abdd4c 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3307,7 +3307,7 @@ sub CanBookBeRenewed { unless CanItemBeReserved( $patron_with_reserve, $other_item, undef, { ignore_hold_counts => 1 } - )->{status} eq 'OK'; + )->{status} eq 'OK'; # NOTE: At checkin we call 'CheckReserves' which checks hold 'policy' # CanItemBeReserved checks 'rules' and 'policies' which means @@ -3470,8 +3470,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