From 035eca2f3512d4a7dce0c52c9755d0e61b9d1c5f Mon Sep 17 00:00:00 2001 From: miker Date: Sun, 3 Sep 2006 23:30:00 +0000 Subject: [PATCH] aggregate billings from a single session git-svn-id: svn://svn.open-ils.org/ILS/trunk@5904 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../Application/Storage/Publisher/action.pm | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm index e405ce9e43..751ae16640 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm @@ -543,7 +543,8 @@ sub generate_fines { } $client->respond( "\t$pending_fine_count pending fine(s)\n" ); - + + my ($latest_billing_ts, $latest_amount); for (my $bill = 1; $bill <= $pending_fine_count; $bill++) { if ($current_fine_total > $c->max_fine) { @@ -573,20 +574,23 @@ sub generate_fines { ); next if (@cl); - my $billing = money::billing->create( - { xact => ''.$c->id, - note => "System Generated Overdue Fine", - billing_type => "Overdue materials", - amount => ''.$c->recuring_fine, - billing_ts => $timestamptz, - } - ); - - $current_fine_total += $billing->amount; + $current_fine_total += $c->recuring_fine; + $latest_amount += $c->recuring_fine; + $latest_billing_ts = $timestamptz; - $client->respond( "\t\tCreating fine of ".$billing->amount." for period starting ".$billing->billing_ts."\n" ); + $client->respond( "\t\tAdding aggregate fine of ".$c->recuring_fine." for period starting ".$$timestamptz."\n" ); } + money::billing->create( + { xact => ''.$c->id, + note => "System Generated Overdue Fine", + billing_type => "Overdue materials", + amount => ''.$latest_amount + billing_ts => $latest_billing_ts, + } + ) if ($latest_billing_ts and $latest_amount > 0.0); + + $self->method_lookup('open-ils.storage.transaction.commit')->run; $penalty->request( -- 2.11.0