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

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Sep 18 15:37:38 EDT 2009


Author: erickson
Date: 2009-09-18 15:37:33 -0400 (Fri, 18 Sep 2009)
New Revision: 14058

Added:
   trunk/Open-ILS/src/sql/Pg/upgrade/0005.data.org-setting-max-claims-return-count.sql
   trunk/Open-ILS/src/sql/Pg/upgrade/0006.data.override-max-claims-returned-perm.sql
Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm
Log:

new feature:  Added max-claims-returned-count setting.  if a patron hits this amount, it requires staff override to mark an additional item as claims returned.

new perm SET_CIRC_CLAIMS_RETURNED.override

new api call open-ils.circ.circulation.set_claims_returned.override

updated some inline docs



Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm	2009-09-18 18:49:25 UTC (rev 14057)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm	2009-09-18 19:37:33 UTC (rev 14058)
@@ -270,15 +270,30 @@
 __PACKAGE__->register_method(
 	method	=> "set_circ_claims_returned",
 	api_name	=> "open-ils.circ.circulation.set_claims_returned",
-	signature	=> q/
-        Sets the circ for the given item as claims returned
-        If a backdate is provided, overdue fines will be voided
-        back to the backdate
-		@param auth
-		@param args : barcode, backdate
-	/
+	signature => {
+        desc => q/Sets the circ for a given item as claims returned
+                If a backdate is provided, overdue fines will be voided
+                back to the backdate/,
+        params => [
+            {desc => 'Authentication token', type => 'string'},
+            {desc => 'Arguments, including "barcode" and optional "backdate"', type => 'object'}
+        ],
+        return => {desc => q/1 on success, failure event on error, and 
+            PATRON_EXCEEDS_CLAIMS_RETURN_COUNT if the patron exceeds the 
+            configured claims return maximum/}
+    }
 );
 
+__PACKAGE__->register_method(
+	method	=> "set_circ_claims_returned",
+	api_name	=> "open-ils.circ.circulation.set_claims_returned.override",
+	signature => {
+        desc => q/This adds support for overrideing the configured max 
+                claims returned amount. 
+                @see open-ils.circ.circulation.set_claims_returned./,
+    }
+);
+
 sub set_circ_claims_returned {
     my( $self, $conn, $auth, $args ) = @_;
 
@@ -298,6 +313,35 @@
         {checkin_time => undef, target_copy => $copy->id})->[0]
             or return $e->die_event;
 
+    my $patron = $e->retrieve_actor_user($circ->usr);
+    my $max_count = $U->ou_ancestor_setting_value(
+        $circ->circ_lib, 'circ.max_patron_claim_return_count', $e);
+
+    # If the patron has too instances of many claims returned, 
+    # require an override to continue.  A configured max of 
+    # 0 means all attempts require an override
+    if(defined $max_count and $patron->claims_returned_count >= $max_count) {
+
+        if($self->api_name =~ /override/) {
+
+            # see if we're allowed to override
+            return $e->die_event unless 
+                $e->allowed('SET_CIRC_CLAIMS_RETURNED.override', $circ->circ_lib);
+
+        } else {
+
+            # exit early and return the max claims return event
+            $e->rollback;
+            return OpenILS::Event->new(
+                'PATRON_EXCEEDS_CLAIMS_RETURN_COUNT', 
+                payload => {
+                    patron_count => $patron->claims_returned_count,
+                    max_count => $max_count
+                }
+            );
+        }
+    }
+
     $e->allowed('SET_CIRC_CLAIMS_RETURNED', $circ->circ_lib) 
         or return $e->die_event;
 

Added: trunk/Open-ILS/src/sql/Pg/upgrade/0005.data.org-setting-max-claims-return-count.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0005.data.org-setting-max-claims-return-count.sql	                        (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0005.data.org-setting-max-claims-return-count.sql	2009-09-18 19:37:33 UTC (rev 14058)
@@ -0,0 +1,13 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0005.data.org-setting-max-claims-return-count.sql');
+
+INSERT INTO config.org_unit_setting_type (name, label, description, datatype) VALUES (
+    'circ.max_patron_claim_return_count',
+    'Max Patron Claims Returned Count',
+    'When this count is exceeded, a staff override is required to mark the item as claims returned',
+    'integer'
+);
+
+COMMIT;
+

Added: trunk/Open-ILS/src/sql/Pg/upgrade/0006.data.override-max-claims-returned-perm.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0006.data.override-max-claims-returned-perm.sql	                        (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0006.data.override-max-claims-returned-perm.sql	2009-09-18 19:37:33 UTC (rev 14058)
@@ -0,0 +1,11 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0006.data.override-max-claims-returned-perm.sql');
+
+INSERT INTO permission.perm_list (code, description) VALUES (
+    'SET_CIRC_CLAIMS_RETURNED.override',
+    'Allows staff to override the max claims returned value for a patron'
+);
+
+COMMIT;
+



More information about the open-ils-commits mailing list