From: blake Date: Fri, 3 Feb 2017 22:45:29 +0000 (-0600) Subject: LP1170795: Void deposits on checkin X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3f5d1e1cc7bd8d9582e88610aec744cac73c52c5;p=evergreen%2Ftadl.git LP1170795: Void deposits on checkin Introduce a library setting circ.void_item_deposit. When set, the money.billing deposit row will be voided on checkin. Signed-off-by: blake Signed-off-by: Jason Boyer Signed-off-by: Terran McCanna Signed-off-by: Jason Boyer --- 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 7a6751df3b..40fe4b0c84 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -2788,6 +2788,9 @@ sub do_checkin { $self->handle_fines; } + # Void any item deposits if the library wants to + $self->check_circ_deposit(1); + $self->checkin_handle_circ_finish; return if $self->bail_out; $self->checkin_changed(1); @@ -3043,18 +3046,32 @@ sub finish_fines_and_voiding { } -# if a deposit was payed for this item, push the event +# if a deposit was paid for this item, push the event +# if called with a truthy param perform the void, depending on settings sub check_circ_deposit { my $self = shift; + my $void = shift; + return unless $self->circ; + my $deposit = $self->editor->search_money_billing( { btype => 5, xact => $self->circ->id, voided => 'f' }, {idlist => 1})->[0]; - $self->push_events(OpenILS::Event->new( - 'ITEM_DEPOSIT_PAID', payload => $deposit)) if $deposit; + return unless $deposit; + + if ($void) { + my $void_on_checkin = $U->ou_ancestor_setting_value( + $self->circ_lib,OILS_SETTING_VOID_ITEM_DEPOSIT_ON_CHECKIN,$self->editor); + if ( $void_on_checkin ) { + my $evt = $CC->void_bills($self->editor,[$deposit], "DEPOSIT ITEM RETURNED"); + return $evt if $evt; + } + } else { # if void is unset this is just a check, notify that there was a deposit billing + $self->push_events(OpenILS::Event->new('ITEM_DEPOSIT_PAID', payload => $deposit)); + } } sub reshelve_copy { diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Const.pm b/Open-ILS/src/perlmods/lib/OpenILS/Const.pm index 85e8b71889..f65118efdb 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Const.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Const.pm @@ -98,6 +98,7 @@ econst OILS_SETTING_BLOCK_HOLD_FOR_EXPIRED_PATRON => 'circ.holds.expired_p econst OILS_SETTING_ALLOW_RENEW_FOR_EXPIRED_PATRON => 'circ.renew.expired_patron_allow'; econst OILS_SETTING_GENERATE_OVERDUE_ON_LOST_RETURN => 'circ.lost.generate_overdue_on_checkin'; econst OILS_SETTING_MAX_DUPLICATE_HOLDS => 'circ.holds.max_duplicate_holds'; +econst OILS_SETTING_VOID_ITEM_DEPOSIT_ON_CHECKIN => 'circ.void_item_deposit'; 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 027aecb0ff..7b27f5db2f 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -4239,6 +4239,15 @@ INSERT into config.org_unit_setting_type 'coust', 'description'), 'bool', null) +,( 'circ.void_item_deposit', 'circ', + oils_i18n_gettext('circ.void_item_deposit', + 'Void item deposit fee on checkin', + 'coust', 'label'), + oils_i18n_gettext('circ.void_item_deposit', + 'If a deposit was charged when checking out an item, void it when the item is returned', + 'coust', 'description'), + 'bool', null) + ,( 'circ.void_lost_proc_fee_on_checkin', 'circ', oils_i18n_gettext('circ.void_lost_proc_fee_on_checkin', 'Void processing fee on lost item return', diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.void_deposit_on_checkin.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.void_deposit_on_checkin.sql new file mode 100755 index 0000000000..d9329bfadd --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.void_deposit_on_checkin.sql @@ -0,0 +1,17 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); -- blake / jboyer + +INSERT INTO config.org_unit_setting_type +( name, grp, label, description, datatype, fm_class ) VALUES +( 'circ.void_item_deposit', 'circ', + oils_i18n_gettext('circ.void_item_deposit', + 'Void item deposit fee on checkin', + 'coust', 'label'), + oils_i18n_gettext('circ.void_item_deposit', + 'If a deposit was charged when checking out an item, void it when the item is returned', + 'coust', 'description'), + 'bool', null); + +COMMIT; +