From e65a76067dae8496ab56bb33f3ae4ef5a38fe026 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 change lost/long-overdue 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 or goes long-overdue 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) "Reinstate overdue fines on lost item return" setting is enabled 4c) System dutifully voids the lost fines/fees 4d) System dutifully reinstates the overdue fines So we add an YAOUS to ensure that when a lost item is returned and the balance of the transaction is exactly $0, the lost fines and fees are not voided EVEN IF "void fines and fees on lost/long-overdue return" settings are enabled, and voided overdue fees are likewise not reinstated EVEN IF "restore overdue on lost/long-overdue return" settings are enabled. The reason for the second condition is that the point of this new setting is to have Evergreen consider zero-balance lost/long-overdue transactions as "handled", and that they should not automatically change. Signed-off-by: Mike Rylander Signed-off-by: Kathy Lussier --- .../lib/OpenILS/Application/Circ/Circulate.pm | 19 ++++++++++++++++--- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 10 ++++++++++ ...X.data.avoid_lost_void_on_zero_balance.sql | 15 +++++++++++++++ 3 files changed, 41 insertions(+), 3 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..6cfe056d88 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_change_on_zero => 'circ.checkin.lost_zero_balance.do_not_change', 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_change_on_zero => 'circ.checkin.lost_zero_balance.do_not_change', 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_change = $U->ou_ancestor_setting_value( + $circ_lib, $args{ous_dont_change_on_zero}, $self->editor) || 0; + + if ($dont_change) { + my ($obt) = $U->fetch_mbts($circ->id, $self->editor); + $dont_change = 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 and reinstatement.") if ($dont_change); + 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,11 +3606,11 @@ 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_change); $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_change); $self->checkin_handle_lost_or_lo_now_found_restore_od($circ_lib) - if $restore_od && ! $self->void_overdues; + if ! $dont_change && $restore_od && ! $self->void_overdues; } if ($circ_lib != $self->circ_lib) { 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..4eaa6e64ac 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_change', 'circ', + oils_i18n_gettext('circ.checkin.lost_zero_balance.do_not_change', + 'Do not change fines/fees on zero-balance LOST transaction', + 'coust', 'label'), + oils_i18n_gettext('circ.checkin.lost_zero_balance.do_not_change', + 'When an item has been marked lost and all fines/fees have been completely paid on the transaction, do not void or reinstate 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..9934cc9da1 --- /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_change', + 'circ', + 'Do not change 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 or reinstate any fines/fees EVEN IF circ.void_lost_on_checkin and/or circ.void_lost_proc_fee_on_checkin are enabled', + 'bool'); + +COMMIT; + -- 2.43.2