From 8531fe732347d8b8023c3d2d4a41e8ce740ed11c Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Tue, 21 Jan 2014 10:32:51 -0500 Subject: [PATCH] Fix reverse sort logic for generate_fines in Storage/Publisher/action.pm. We were getting multiple overdue billings for a single period because the @fine_map was coming up empty owing to convoluted logic. This commit simplifies that logic and fixes another logic bug in calculating the total of the current fines. In the latter case, we had a < where we needed >. Signed-off-by: Jason Stephenson Signed-off-by: Kathy Lussier --- .../lib/OpenILS/Application/Storage/Publisher/action.pm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm index d2151e2816..81912e5f26 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm @@ -1120,9 +1120,7 @@ sub generate_fines { my $bill_payment_map = $CC->bill_payment_map_for_xact(undef, $c); # Pull out those entries for overdue bills in reverse date order. - my @fine_map = sort { $b->{bill}->billing_ts() <=> $a->{bill}->billing_ts() } - grep { $_->{bill}->btype() == 1 && $_->{bill}->billing_ts() > $c->$due_date_method } - @{$bill_payment_map}; + my @fine_map = reverse grep { $_->{bill}->btype() == 1 } @{$bill_payment_map}; my $f_idx = 0; my $current_fine_total = 0; @@ -1135,9 +1133,9 @@ sub generate_fines { } # Set the $fine to be used for $last_fine below. $fine = $fine_map[$f_idx]->{bill} if ($fine_map[$f_idx]); - # Calculate the current fine total using the modified bill amounts from the bill payment map. - map { $current_fine_total += int($_->{bill}->amount() * 100) } - grep { $_->{bill_amount} < $_->{void_amount} } @fine_map; + # Calculate the current fine total using the original bill amounts from the bill payment map. + map { $current_fine_total += int($_->{bill_amount} * 100) } + grep { $_->{bill_amount} > $_->{void_amount} } @fine_map; } my $last_fine; -- 2.11.0