From: Dan Wells Date: Thu, 13 Sep 2018 19:45:24 +0000 (-0400) Subject: LP#1562061 Clean up set_item_lost_or_lod() X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=62efb118298fbc24b51295ebc7299c7e13a6186c;p=working%2FEvergreen.git LP#1562061 Clean up set_item_lost_or_lod() This commit attempts to make no substantive functional changes. It does the following: - indents newly conditional branch for billing processing - moves some of the setting gathering into the conditional branch, since it is the only place those settings are needed - improves code comments in a few places Signed-off-by: Dan Wells --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm index e3de9e4d0e..a46ef43617 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm @@ -848,10 +848,6 @@ sub set_item_lost_or_lod { {flesh => 1, flesh_fields => {'acp' => ['call_number']}}]) or return $e->die_event; - my $owning_lib = - ($copy->call_number->id == OILS_PRECAT_CALL_NUMBER) ? - $copy->circ_lib : $copy->call_number->owning_lib; - my $circ = $e->search_action_circulation( {checkin_time => undef, target_copy => $copy->id} )->[0] or return $e->die_event; @@ -862,14 +858,7 @@ sub set_item_lost_or_lod { if ($copy->status == $args{status}); # --------------------------------------------------------------------- - # fetch the related org settings - my $proc_fee = $U->ou_ancestor_setting_value( - $owning_lib, $args{ous_proc_fee}, $e) || 0; - my $void_overdue = $U->ou_ancestor_setting_value( - $owning_lib, $args{ous_void_od}, $e) || 0; - - # --------------------------------------------------------------------- - # move the copy into LOST status + # move the copy into requested status $copy->status($args{status}); $copy->editor($e->requestor->id); $copy->edit_date('now'); @@ -880,39 +869,51 @@ sub set_item_lost_or_lod { # circulation my $stop_fines = $circ->stop_fines || ''; if ($stop_fines !~ /^(LOST|LONGOVERDUE)$/) { - my $price = $U->get_copy_price($e, $copy, $copy->call_number); + # --------------------------------------------------------------------- + # fetch the related org settings + my $owning_lib = + ($copy->call_number->id == OILS_PRECAT_CALL_NUMBER) ? + $copy->circ_lib : $copy->call_number->owning_lib; + my $proc_fee = $U->ou_ancestor_setting_value( + $owning_lib, $args{ous_proc_fee}, $e) || 0; + my $void_overdue = $U->ou_ancestor_setting_value( + $owning_lib, $args{ous_void_od}, $e) || 0; + + my $price = $U->get_copy_price($e, $copy, $copy->call_number); + + if( $price > 0 ) { + my $evt = OpenILS::Application::Circ::CircCommon->create_bill($e, + $price, $args{bill_type}, $args{bill_note}, $circ->id); + return $evt if $evt; + } - if( $price > 0 ) { - my $evt = OpenILS::Application::Circ::CircCommon->create_bill($e, - $price, $args{bill_type}, $args{bill_note}, $circ->id); - return $evt if $evt; - } + # --------------------------------------------------------------------- + # if there is a processing fee, charge that too + if( $proc_fee > 0 ) { + my $evt = OpenILS::Application::Circ::CircCommon->create_bill($e, + $proc_fee, $args{bill_fee_type}, $args{bill_fee_note}, $circ->id); + return $evt if $evt; + } - # --------------------------------------------------------------------- - # if there is a processing fee, charge that too - if( $proc_fee > 0 ) { - my $evt = OpenILS::Application::Circ::CircCommon->create_bill($e, - $proc_fee, $args{bill_fee_type}, $args{bill_fee_note}, $circ->id); - return $evt if $evt; - } + # --------------------------------------------------------------------- + # stop the fines + $circ->stop_fines($args{stop_fines}); + $circ->stop_fines_time('now') unless $circ->stop_fines_time; + $e->update_action_circulation($circ) or return $e->die_event; - # --------------------------------------------------------------------- - # mark the circ as lost and stop the fines - $circ->stop_fines($args{stop_fines}); - $circ->stop_fines_time('now') unless $circ->stop_fines_time; - $e->update_action_circulation($circ) or return $e->die_event; + # --------------------------------------------------------------------- + # zero out overdue fines on this circ if configured + if( $void_overdue ) { + my $evt = OpenILS::Application::Circ::CircCommon->void_or_zero_overdues($e, $circ, {force_zero => 1, note => "System: OVERDUE REVERSED for " . $args{bill_note} . " Processing"}); + return $evt if $evt; + } - # --------------------------------------------------------------------- - # zero out overdue fines on this circ if configured - if( $void_overdue ) { - my $evt = OpenILS::Application::Circ::CircCommon->void_or_zero_overdues($e, $circ, {force_zero => 1, note => "System: OVERDUE REVERSED for " . $args{bill_note} . " Processing"}); + # --------------------------------------------------------------------- + # check if circ needs to be reopened due to billing changes + my $evt = OpenILS::Application::Circ::CircCommon->reopen_xact($e, $circ->id); return $evt if $evt; } - my $evt = OpenILS::Application::Circ::CircCommon->reopen_xact($e, $circ->id); - return $evt if $evt; - } - my $ses = OpenSRF::AppSession->create('open-ils.trigger'); $ses->request( 'open-ils.trigger.event.autocreate',