From: Dan Wells Date: Tue, 1 Apr 2014 19:13:00 +0000 (-0400) Subject: LP 1198465: Delay creation of bill map for special bill handling X-Git-Tag: sprint4-merge-nov22~1304 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b933439a93e3465fc36a685d261e97a44d8cef7b;p=working%2FEvergreen.git LP 1198465: Delay creation of bill map for special bill handling We were making the map, then deciding whether we wanted to void or adjust. Since we only want the map if we adjust (and it creates havoc when voiding), let's just get the bill IDs, then let the adjustment code create the map it needs. Signed-off-by: Dan Wells Signed-off-by: Kathy Lussier Signed-off-by: Ben Shum --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm index faa6651a6f..20ff28daed 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm @@ -142,35 +142,33 @@ sub void_lost { sub void_or_zero_bills_of_type { my ($class, $e, $circ, $copy, $btype, $for_note) = @_; - # Get a bill payment map. - my $bpmap = $class->bill_payment_map_for_xact($e, $circ); - if ($bpmap && @$bpmap) { - # Filter out the unvoided bills of the type we're looking for: - my @bills = map {$_->{bill}} grep { $_->{bill}->btype() == $btype && $_->{bill_amount} > $_->{void_amount} } @$bpmap; - if (@bills) { - # settings for lost come from copy circlib. - my $prohibit_neg_balance_lost = ( - $U->ou_ancestor_setting_value($copy->circ_lib(), 'bill.prohibit_negative_balance_on_lost') - || - $U->ou_ancestor_setting_value($copy->circ_lib(), 'bill.prohibit_negative_balance_default') - ); - my $neg_balance_interval_lost = ( - $U->ou_ancestor_setting_value($copy->circ_lib(), 'bill.negative_balance_interval_on_lost') - || - $U->ou_ancestor_setting_value($copy->circ_lib(), 'bill.negative_balance_interval_default') - ); - my $result; - if ( - $U->is_true($prohibit_neg_balance_lost) - and !_has_refundable_payments($e, $circ->id, $neg_balance_interval_lost) - ) { - $result = $class->adjust_bills_to_zero($e, \@bills, "System: ADJUSTED $for_note"); - } else { - $result = $class->void_bills($e, \@bills, "System: VOIDED $for_note"); - } - if (ref($result)) { - return $result; - } + my $billids = $e->search_money_billing( + {xact => $circ->id(), btype => $btype}, + {idlist=>1} + ); + if ($billids && @$billids) { + # settings for lost come from copy circlib. + my $prohibit_neg_balance_lost = ( + $U->ou_ancestor_setting_value($copy->circ_lib(), 'bill.prohibit_negative_balance_on_lost') + || + $U->ou_ancestor_setting_value($copy->circ_lib(), 'bill.prohibit_negative_balance_default') + ); + my $neg_balance_interval_lost = ( + $U->ou_ancestor_setting_value($copy->circ_lib(), 'bill.negative_balance_interval_on_lost') + || + $U->ou_ancestor_setting_value($copy->circ_lib(), 'bill.negative_balance_interval_default') + ); + my $result; + if ( + $U->is_true($prohibit_neg_balance_lost) + and !_has_refundable_payments($e, $circ->id, $neg_balance_interval_lost) + ) { + $result = $class->adjust_bills_to_zero($e, $billids, "System: ADJUSTED $for_note"); + } else { + $result = $class->void_bills($e, $billids, "System: VOIDED $for_note"); + } + if (ref($result)) { + return $result; } }