From 020f43563fffb68c2977b45619c7e606826c94ab Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 19 Oct 2020 17:04:35 -0400 Subject: [PATCH] LP1786312 Due date extension honors max fine When calculating the amount billed to a patron in overdue fines, inspect all such fines on the transaction, regardless of billing timestamp. Signed-off-by: Bill Erickson --- .../lib/OpenILS/Application/Circ/CircCommon.pm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) 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 73b79a3856..f89fa43349 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm @@ -447,7 +447,6 @@ sub generate_fines { my $handling_resvs = 0; for my $c (@$circs) { - my $ctype = ref($c); if (!$ctype) { # we received only an idlist, not objects @@ -525,20 +524,31 @@ sub generate_fines { "\tItem was due on or before: ".localtime($due)."\n") if $conn; my @fines = @{$e->search_money_billing([ - { xact => $c->id, - btype => 1, - billing_ts => { '>' => $c->$due_date_method } }, + { xact => $c->id, btype => 1 }, { order_by => {mb => 'billing_ts DESC'}, flesh => 1, flesh_fields => {mb => ['adjustments']} } ])}; - my $f_idx = 0; - my $fine = $fines[$f_idx] if (@fines); + # Calcuate fine totals using all overdue fines, regardless + # of billing creation time. my $current_fine_total = 0; $current_fine_total += $_->amount * 100 for (grep { $_ and !$U->is_true($_->voided) } @fines); $current_fine_total -= $_->amount * 100 for (map { @{$_->adjustments} } @fines); + + $logger->info( + sprintf("Current overdue fine total for xact %d is %0.2f", + $c->id, ($current_fine_total / 100))); + + # Determine the billing period of the next fine to generate + # based on the billing time of the most recent fine *which + # occurred after the current due date*. Otherwise, when a + # due date changes, the fine generator will back-fill billings + # for a period of time where the item was not technically overdue. + @fines = grep { $_->billing_ts > $c->$due_date_method } @fines; + my $f_idx = 0; + my $fine = $fines[$f_idx] if (@fines); my $last_fine; if ($fine) { $conn->respond( "Last billing time: ".$fine->billing_ts." (clensed format: ".clean_ISO8601( $fine->billing_ts ).")") if $conn; -- 2.11.0