LP 980296: Void Lost Fines if copy claims returned.
authorJason Stephenson <jstephenson@mvlc.org>
Mon, 1 Oct 2012 18:30:44 +0000 (14:30 -0400)
committerBen Shum <bshum@biblio.org>
Wed, 3 Oct 2012 15:36:17 +0000 (11:36 -0400)
Add an ou setting (circ.void_lost_on_claimsreturned) to control whether or
not lost fines are voided when a lost circulation is claims returned.

Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.coust_void_lost_on_claimsreturned.sql [new file with mode: 0644]

index 5c2a754..9fbdf9b 100644 (file)
@@ -483,6 +483,17 @@ sub set_circ_claims_returned {
            $e->update_asset_copy($copy) or return $e->die_event;
     }
 
+    # Check if the copy circ lib wants lost fees voided on claims
+    # returned.
+    if ($U->is_true($U->ou_ancestor_setting_value($copy->circ_lib, 'circ.void_lost_on_claimsreturned', $e))) {
+        my $result = OpenILS::Application::Circ::CircCommon->void_lost(
+            $e,
+            $circ,
+            3
+        );
+        return $result if ($result);
+    }
+
     $e->commit;
     return 1;
 }
index 613447f..e31112d 100644 (file)
@@ -72,6 +72,35 @@ sub void_overdues {
        return undef;
 }
 
+# ------------------------------------------------------------------
+# remove charge from patron's account if lost item is returned
+# ------------------------------------------------------------------
+sub void_lost {
+    my ($class, $e, $circ, $btype) = @_;
+
+    my $bills = $e->search_money_billing(
+        {
+            xact => $circ->id,
+            btype => $btype
+        }
+    );
+
+    $logger->debug("voiding lost item charge of  ".scalar(@$bills));
+    for my $bill (@$bills) {
+        if( !$U->is_true($bill->voided) ) {
+            $logger->info("lost item returned - voiding bill ".$bill->id);
+            $bill->voided('t');
+            $bill->void_time('now');
+            $bill->voider($e->requestor->id);
+            my $note = ($bill->note) ? $bill->note . "\n" : '';
+            $bill->note("${note}System: VOIDED FOR LOST ITEM RETURNED");
+
+            return $e->die_event
+                unless $e->update_money_billing($bill);
+        }
+    }
+    return undef;
+}
 
 sub reopen_xact {
     my($class, $e, $xactid) = @_;
index 83a46a8..cafcdff 100644 (file)
@@ -3813,32 +3813,12 @@ sub make_trigger_events {
 
 sub checkin_handle_lost_now_found {
     my ($self, $bill_type) = @_;
-
-    # ------------------------------------------------------------------
-    # remove charge from patron's account if lost item is returned
-    # ------------------------------------------------------------------
-
-    my $bills = $self->editor->search_money_billing(
-        {
-            xact => $self->circ->id,
-            btype => $bill_type
-        }
+    my $result = OpenILS::Application::Circ::CircCommon->void_lost(
+        $self->editor,
+        $self->circ,
+        $bill_type
     );
-
-    $logger->debug("voiding lost item charge of  ".scalar(@$bills));
-    for my $bill (@$bills) {
-        if( !$U->is_true($bill->voided) ) {
-            $logger->info("lost item returned - voiding bill ".$bill->id);
-            $bill->voided('t');
-            $bill->void_time('now');
-            $bill->voider($self->editor->requestor->id);
-            my $note = ($bill->note) ? $bill->note . "\n" : '';
-            $bill->note("${note}System: VOIDED FOR LOST ITEM RETURNED");
-
-            $self->bail_on_events($self->editor->event)
-                unless $self->editor->update_money_billing($bill);
-        }
-    }
+    $self->bail_on_events($result) if ($result);
 }
 
 sub checkin_handle_lost_now_found_restore_od {
index e5daf85..51b9804 100644 (file)
@@ -11843,3 +11843,15 @@ INSERT into config.org_unit_setting_type
         'bool'
     );
 
+INSERT INTO config.org_unit_setting_type
+    (name, grp, label, description, datatype)
+    VALUES
+        ('circ.void_lost_on_claimsreturned',
+         'circ',
+         oils_i18n_gettext('circ.void_lost_on_claimsreturned',
+             'Void lost item billing when claims returned',
+             'coust', 'label'),
+         oils_i18n_gettext('circ.void_lost_on_claimsreturned',
+             'Void lost item billing when claims returned',
+             'coust', 'description'),
+         'bool');
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.coust_void_lost_on_claimsreturned.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.coust_void_lost_on_claimsreturned.sql
new file mode 100644 (file)
index 0000000..4180672
--- /dev/null
@@ -0,0 +1,18 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO config.org_unit_setting_type
+    (name, grp, label, description, datatype)
+    VALUES
+        ('circ.void_lost_on_claimsreturned',
+         'circ',
+         oils_i18n_gettext('circ.void_lost_on_claimsreturned',
+             'Void lost item billing when claims returned',
+             'coust', 'label'),
+         oils_i18n_gettext('circ.void_lost_on_claimsreturned',
+             'Void lost item billing when claims returned',
+             'coust', 'description'),
+         'bool');
+
+COMMIT;