From: Jason Stephenson Date: Mon, 1 Oct 2012 15:32:15 +0000 (-0400) Subject: Address Launchpad Bug 793550. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d448a903a63f463a02d37c4684ebb8e5d220fb40;p=working%2FEvergreen.git Address Launchpad Bug 793550. Check for stop fines reason of CHECKIN or RENEW before closing a circulation transaction when the balance reaches zero. Also, if the stop fines reason is LOST, then check a new ou setting, circ.lost.xact_finish_on_zero, to determine if the transaction is closed or kept open. The setting is checked for the circulation copy's circ_lib. Signed-off-by: Jason Stephenson Signed-off-by: Ben Shum --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm index f8c276d28a..998c215135 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm @@ -333,9 +333,33 @@ sub make_payments { $credit += $cred; my $circ = $e->retrieve_action_circulation($transid); - if(!$circ || $circ->stop_fines) { - # If this is a circulation, we can't close the transaction - # unless stop_fines is set. + # Whether or not we close the transaction: + my $close = 0; + + if (!$circ) { + # Close if we have no circulation. + $close = 1; + } elsif ($circ->stop_fines) { + my $reason = $circ->stop_fines; + # We definitely want to close if this circulation was + # checked in or renewed. + if ($reason eq "CHECKIN" || $reason eq "RENEW") { + $close = 1; + } elsif ($reason eq "LOST") { + # Check the copy circ_lib to see if they close + # transactions when lost are paid. + my $copy = $e->retrieve_asset_copy($circ->target_copy); + if ($copy) { + $close = $U->ou_ancestor_setting_value( + $copy->circ_lib, + 'circ.lost.xact_finish_on_zero', + $e + ); + } + } + } + + if ($U->is_true($close)) { $trans = $e->retrieve_money_billable_transaction($transid); $trans->xact_finish("now"); if (!$e->update_money_billable_transaction($trans)) { 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 e5daf85d12..2846c59dde 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -11843,3 +11843,22 @@ INSERT into config.org_unit_setting_type 'bool' ); +INSERT INTO config.org_unit_setting_type + (name, grp, label, description, datatype) + VALUES ( + 'circ.lost.xact_finish_on_zero', + 'finance', + oils_i18n_gettext( + 'circ.lost.xact_finish_on_zero', + 'Close transaction when lost balance equals zero', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.lost.xact_finish_on_zero', + 'Close transaction when lost balance equals zero. This removes the lost copy from the patron record when it is paid', + 'coust', + 'description' + ), + 'bool' + ); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.coust_lost_xact_finish_on_zero.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.coust_lost_xact_finish_on_zero.sql new file mode 100644 index 0000000000..45b270e247 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.coust_lost_xact_finish_on_zero.sql @@ -0,0 +1,25 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +INSERT INTO config.org_unit_setting_type + (name, grp, label, description, datatype) + VALUES ( + 'circ.lost.xact_finish_on_zero', + 'finance', + oils_i18n_gettext( + 'circ.lost.xact_finish_on_zero', + 'Close transaction when lost balance equals zero', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.lost.xact_finish_on_zero', + 'Close transaction when lost balance equals zero. This removes the lost copy from the patron record when it is paid', + 'coust', + 'description' + ), + 'bool' + ); + +COMMIT;