LP1891369 Renewal exentions uses min interval
authorBill Erickson <berickxx@gmail.com>
Fri, 25 Jun 2021 17:03:10 +0000 (13:03 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 01:04:26 +0000 (21:04 -0400)
Specify the minimum renewal extension interval as an interval instead of
a percentage of the total duration.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
Open-ILS/src/sql/Pg/100.circ_matrix.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.renewals-use-full-time.sql
docs/RELEASE_NOTES_NEXT/Circulation/renewals-extend-due-date.adoc

index e22a2eb..a4fb45b 100644 (file)
@@ -2196,7 +2196,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field name="available_copy_hold_ratio" reporter:datatype="float" reporter:label="Minimum Available Copy/Hold Ratio"/>
                        <field name="description" reporter:datatype="text" reporter:label="Description"/>
                        <field name="renew_extends_due_date" reporter:datatype="bool" reporter:label="Early Renewal Extends Due Date"/>
-                       <field name="renew_extend_percent" reporter:datatype="float" reporter:label="Early Renewal Minimum Duration Percent"/>
+                       <field name="renew_extend_min_interval" reporter:datatype="interval" reporter:label="Early Renewal Minimum Duration Interval"/>
                </fields>
                <links>
                        <link field="org_unit" reltype="has_a" key="id" map="" class="aou"/>
index 68273a2..88d2d73 100644 (file)
@@ -2392,19 +2392,16 @@ sub extend_renewal_due_date {
 
     my $now_time = DateTime->now->epoch;
 
-    if (my $percent = $matchpoint->renew_extend_percent) {
-        # If the percent is zero, all renewals are extended.
+    if (my $interval = $matchpoint->renew_extend_min_interval) {
 
-        my $total_duration = $end_time - $start_time;
+        my $min_duration = OpenILS::Utils::DateTime->interval_to_seconds($interval);
         my $checkout_duration = $now_time - $start_time;
-        my $duration_percent = ($checkout_duration / $total_duration) * 100;
 
-        return if $duration_percent < $percent;
+        return if $checkout_duration < $min_duration;
     }
 
     my $remaining_duration = $end_time - $now_time;
 
-    # $circ->due_date is already in the correct timezone.
     my $due_date = DateTime::Format::ISO8601->new
         ->parse_datetime(clean_ISO8601($circ->due_date));
 
@@ -2412,6 +2409,7 @@ sub extend_renewal_due_date {
 
     $logger->info("circulator: extended renewal due date to $due_date");
 
+    # $circ->due_date is already in the needed timezone.
     $circ->due_date($due_date->strftime('%FT%T%z'));
 }
 
index 1eff550..1badabe 100644 (file)
@@ -83,9 +83,9 @@ CREATE TABLE config.circ_matrix_matchpoint (
     script_test          TEXT,                           -- javascript source 
     total_copy_hold_ratio     FLOAT,
     available_copy_hold_ratio FLOAT,
+    description               TEXT,
     renew_extends_due_date    BOOLEAN NOT NULL DEFAULT FALSE,
-    renew_extend_percent      FLOAT NOT NULL DEFAULT 0,
-    description          TEXT
+    renew_extend_min_interval INTERVAL
 );
 
 -- Nulls don't count for a constraint match, so we have to coalesce them into something that does.
index 3e2a0d8..640bc7e 100644 (file)
@@ -4,6 +4,6 @@ BEGIN;
 
 ALTER TABLE config.circ_matrix_matchpoint
     ADD COLUMN renew_extends_due_date BOOLEAN NOT NULL DEFAULT FALSE,
-    ADD COLUMN renew_extend_percent FLOAT NOT NULL DEFAULT 0;
+    ADD COLUMN renew_extend_min_interval INTERVAL;
 
 COMMIT;
index b7b1b90..25c20e5 100644 (file)
@@ -16,12 +16,15 @@ Circulation Policies.
 
 Enables this new feature for a circulation policy.
 
-*Early Renewal Minimum Duration Percent*
+*Early Renewal Minimum Duration Interval*
 
-Specifies how early in a checkout a renewal will result in an extended
-due date.  E.g. A value of 50 (percent) means no due date extension
-would occur if an attempt to renew occurred after 5 days of a 14 day
-circulation duration.  In this case, the renewal would still be allowed,
-it just wouldn't get the extended due date.
+Specifies the amount of time a circulation has to be checked out before a 
+renewal will result in an extended due date.
 
+For example, if you wanted to support due date extensions on 14-day checkout
+renewals, but only if the item has been checked out at least 8 days, you 
+would enter "8 days" for the value of this field.
+
+If no value is set for a given matchpoint that supports renewal extension, 
+all renewals using that matchpoint will be eligible.