From fd65464f8fbe8689021b846695403fe20b598342 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 28 Jan 2015 08:40:20 -0500 Subject: [PATCH] LP#1413592: Don't void LOST fines/fees on zero-balance 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 --- .../perlmods/lib/OpenILS/Application/Circ/Circulate.pm | 17 +++++++++++++++-- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 10 ++++++++++ .../XXX.data.avoid_lost_void_on_zero_balance.sql | 15 +++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXX.data.avoid_lost_void_on_zero_balance.sql diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm index 549e27e719..0c342363d3 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -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; } diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 0f0e9f3118..8ae6a8e7e3 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -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 index 0000000000..124e311423 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXX.data.avoid_lost_void_on_zero_balance.sql @@ -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; + -- 2.11.0