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>
Tue, 13 Jan 2015 21:58:10 +0000 (16:58 -0500)
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>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.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 4ed6bf0..3e8dc15 100644 (file)
@@ -475,6 +475,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 1315a8c..d518dad 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 bf47472..107906d 100644 (file)
@@ -14134,5 +14134,15 @@ INSERT INTO config.global_flag (name, label, value, enabled) VALUES (
     TRUE
 );
 
-
-
+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;