LP#1413592: Don't void LOST fines/fees on zero-balance user/miker/lp-1413592-avoid-lost-void-on-zero-balance
authorMike Rylander <mrylander@gmail.com>
Wed, 28 Jan 2015 13:40:20 +0000 (08:40 -0500)
committerMike Rylander <mrylander@gmail.com>
Wed, 28 Jan 2015 18:40:50 +0000 (13:40 -0500)
The situation that has been reported as the worst offender for creating
negative balances for folks that do not want that to happen goes like this:

1) Item is lost
2) Fees/fines charged
3) Said fees/fines are paid in full
4) Item is found and returned
4a) "Void fines and fees on lost item return" settings are enabled
4b) System dutifully voids the fines/fees

So we add an YAOUS to ensure that when a lost item is returned and the
balance of the transaction is exactly $0, the fines and fees are not voided
EVEN IF "void fines and fees on lost item return" settings are enabled.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
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/XXX.data.avoid_lost_void_on_zero_balance.sql [new file with mode: 0644]

index 549e27e..0c34236 100644 (file)
@@ -3467,6 +3467,7 @@ sub checkin_handle_lost {
     return $self->checkin_handle_lost_or_longoverdue(
         circ_lib => $circ_lib,
         max_return => $max_return,
+        ous_dont_void_on_zero => 'circ.checkin.lost_zero_balance.do_not_void',
         ous_void_item_cost => OILS_SETTING_VOID_LOST_ON_CHECKIN,
         ous_void_proc_fee => OILS_SETTING_VOID_LOST_PROCESS_FEE_ON_CHECKIN,
         ous_restore_overdue => OILS_SETTING_RESTORE_OVERDUE_ON_LOST_RETURN,
@@ -3496,6 +3497,7 @@ sub checkin_handle_long_overdue {
         circ_lib => $circ_lib,
         max_return => $max_return,
         is_longoverdue => 1,
+        ous_dont_void_on_zero => 'circ.checkin.lost_zero_balance.do_not_void',
         ous_void_item_cost => 'circ.void_longoverdue_on_checkin',
         ous_void_proc_fee => 'circ.void_longoverdue_proc_fee_on_checkin',
         ous_restore_overdue => 'circ.restore_overdue_on_longoverdue_return',
@@ -3575,6 +3577,17 @@ sub checkin_handle_lost_or_longoverdue {
             "max return interval (or no interval is defined).  Proceeding ".
             "with fine/fee voiding, etc.");
 
+        my $dont_void = $U->ou_ancestor_setting_value(
+            $circ_lib, $args{ous_dont_void_on_zero}, $self->editor) || 0;
+
+        if ($dont_void) {
+            my ($obt) = $U->fetch_mbts($circ->id, $self->editor);
+            $dont_void = 0 if( $obt and $obt->balance_owed != 0 );
+        }
+
+        $logger->info("circulator: check-in of lost/lo item having a balance ".
+            "of zero, skipping fine/fee voiding.") if ($dont_void);
+
         my $void_cost = $U->ou_ancestor_setting_value(
             $circ_lib, $args{ous_void_item_cost}, $self->editor) || 0;
         my $void_proc_fee = $U->ou_ancestor_setting_value(
@@ -3593,9 +3606,9 @@ sub checkin_handle_lost_or_longoverdue {
         }
 
         $self->checkin_handle_lost_or_lo_now_found(
-            $args{void_cost_btype}, $args{is_longoverdue}) if $void_cost;
+            $args{void_cost_btype}, $args{is_longoverdue}) if ($void_cost and !$dont_void);
         $self->checkin_handle_lost_or_lo_now_found(
-            $args{void_fee_btype}, $args{is_longoverdue}) if $void_proc_fee;
+            $args{void_fee_btype}, $args{is_longoverdue}) if ($void_proc_fee and !$dont_void);
         $self->checkin_handle_lost_or_lo_now_found_restore_od($circ_lib) 
             if $restore_od && ! $self->void_overdues;
     }
index 0f0e9f3..8ae6a8e 100644 (file)
@@ -5016,6 +5016,16 @@ INSERT into config.org_unit_setting_type
      'Use Lost and Paid copy status when lost or long overdue billing is paid',
      'coust', 'description'),
  'bool', null)
+
+,( 'circ.checkin.lost_zero_balance.do_not_void', 'circ',
+    oils_i18n_gettext('circ.checkin.lost_zero_balance.do_not_void',
+        'Do not void fines/fees on zero-balance LOST transaction',
+        'coust', 'label'),
+    oils_i18n_gettext('circ.checkin.lost_zero_balance.do_not_void',
+        'When an item has been marked lost and all fines/fees have been completely paid on the transaction, do not void any fines/fees EVEN IF circ.void_lost_on_checkin and/or circ.void_lost_proc_fee_on_checkin are enabled',
+        'coust', 'description'),
+    'bool', null)
+
 ;
 
 UPDATE config.org_unit_setting_type
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXX.data.avoid_lost_void_on_zero_balance.sql b/Open-ILS/src/sql/Pg/upgrade/XXX.data.avoid_lost_void_on_zero_balance.sql
new file mode 100644 (file)
index 0000000..124e311
--- /dev/null
@@ -0,0 +1,15 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT into config.org_unit_setting_type
+( name, grp, label, description, datatype ) VALUES
+
+( 'circ.checkin.lost_zero_balance.do_not_void',
+  'circ',
+  'Do not void fines/fees on zero-balance LOST transaction',
+  'When an item has been marked lost and all fines/fees have been completely paid on the transaction, do not void any fines/fees EVEN IF circ.void_lost_on_checkin and/or circ.void_lost_proc_fee_on_checkin are enabled',
+  'bool');
+
+COMMIT;
+