new feature: Added max-claims-returned-count setting. if a patron hits this amount...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 18 Sep 2009 19:37:33 +0000 (19:37 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 18 Sep 2009 19:37:33 +0000 (19:37 +0000)
new perm SET_CIRC_CLAIMS_RETURNED.override

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

updated some inline docs

git-svn-id: svn://svn.open-ils.org/ILS/trunk@14058 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ.pm
Open-ILS/src/sql/Pg/upgrade/0005.data.org-setting-max-claims-return-count.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/0006.data.override-max-claims-returned-perm.sql [new file with mode: 0644]

index c04724f..8401118 100644 (file)
@@ -270,13 +270,28 @@ sub new_set_circ_lost {
 __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 {
@@ -298,6 +313,35 @@ sub set_circ_claims_returned {
         {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;
 
diff --git a/Open-ILS/src/sql/Pg/upgrade/0005.data.org-setting-max-claims-return-count.sql b/Open-ILS/src/sql/Pg/upgrade/0005.data.org-setting-max-claims-return-count.sql
new file mode 100644 (file)
index 0000000..b7bfa6f
--- /dev/null
@@ -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;
+
diff --git a/Open-ILS/src/sql/Pg/upgrade/0006.data.override-max-claims-returned-perm.sql b/Open-ILS/src/sql/Pg/upgrade/0006.data.override-max-claims-returned-perm.sql
new file mode 100644 (file)
index 0000000..c68bbe7
--- /dev/null
@@ -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;
+