[open-ils-commits] r14068 - in trunk/Open-ILS/src: perlmods/OpenILS/Application/Circ sql/Pg/upgrade (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Sep 21 09:53:54 EDT 2009


Author: erickson
Date: 2009-09-21 09:53:52 -0400 (Mon, 21 Sep 2009)
New Revision: 14068

Added:
   trunk/Open-ILS/src/sql/Pg/upgrade/0007.data.org-setting-checkout-auto-renew-age.sql
Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
Log:
Added support for auto-renewal ages.  If a checkout occurs and the item is already checked out to the same patron and they have had the item for more than a configred amount of time, tell the caller and let the caller decide if it should force a renewal

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm	2009-09-20 14:16:51 UTC (rev 14067)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm	2009-09-21 13:53:52 UTC (rev 14068)
@@ -790,12 +790,44 @@
 
     # no claims returned circ was found, check if there is any open circ
     unless( $self->is_renewal ) {
+
         my $circs = $self->editor->search_action_circulation(
             { target_copy => $copy->id, checkin_time => undef }
         );
 
-        return $self->bail_on_events(
-            OpenILS::Event->new('OPEN_CIRCULATION_EXISTS')) if @$circs;
+        if(my $old_circ = $circs->[0]) { # an open circ was found
+
+            my $payload; # event payload
+
+            if($old_circ->usr == $self->patron->id) {
+
+                # If there is an open circulation on the checkout item and an auto-renew 
+                # interval is defined, inform the caller that they should go 
+                # ahead and renew the item instead of warning about open circulations.
+    
+                my $auto_renew_intvl = $U->ou_ancestor_setting_value(        
+                    $self->editor->requestor->ws_ou, 
+                    'circ.checkout_auto_renew_age', 
+                    $self->editor
+                );
+
+                if($auto_renew_intvl) {
+                    my $intvl_seconds = OpenSRF::Utils->interval_to_seconds($auto_renew_intvl);
+                    my $checkout_time = DateTime::Format::ISO8601->new->parse_datetime( clense_ISO8601($old_circ->xact_start) );
+
+                    if(DateTime->now > $checkout_time->add(seconds => $intvl_seconds)) {
+                        $payload = {
+                            old_circ => $old_circ,
+                            auto_renew => 1
+                        }
+                    }
+                }
+            }
+
+            return $self->bail_on_events(
+                OpenILS::Event->new('OPEN_CIRCULATION_EXISTS', payload => $payload)
+            );
+        }
     }
 }
 

Added: trunk/Open-ILS/src/sql/Pg/upgrade/0007.data.org-setting-checkout-auto-renew-age.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0007.data.org-setting-checkout-auto-renew-age.sql	                        (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0007.data.org-setting-checkout-auto-renew-age.sql	2009-09-21 13:53:52 UTC (rev 14068)
@@ -0,0 +1,13 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0007.data.org-setting-checkout-auto-renew-age.sql');
+
+INSERT INTO config.org_unit_setting_type (name, label, description, datatype) VALUES (
+    'circ.checkout_auto_renew_age',
+    'Checkout auto renew age',
+    'When an item has been checked out for at least this amount of time, an attempt to check out the item to the patron that it is already checked out to will simply renew the circulation',
+    'interval'
+);
+
+COMMIT;
+



More information about the open-ils-commits mailing list