[open-ils-commits] [GIT] Evergreen ILS branch master updated. 425c29e1e3c80b8d1fc637bf557dc3801e3245e6

Evergreen Git git at git.evergreen-ils.org
Thu Oct 13 21:03:25 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  425c29e1e3c80b8d1fc637bf557dc3801e3245e6 (commit)
      from  9c344376f62ddb4a917c5e8894ab8f909e4af5ba (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 425c29e1e3c80b8d1fc637bf557dc3801e3245e6
Author: Jason Stephenson <jstephenson at mvlc.org>
Date:   Thu Sep 22 12:52:08 2011 -0400

    Fixes for SIP2 Fee Payment.
    
    Skip negative or zero bill balance when paying multiple bills.
    
    Log amount paid, bill id, balance, and amount remaining when paying
    multiple bills.
    
    Use sprintf("%.2f") to avoid floating point errors.
    
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
    Signed-off-by: Dan Scott <dscott at laurentian.ca>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/FeePayment.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/FeePayment.pm
index 28de0dc..d0b3fa4 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/FeePayment.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/FeePayment.pm
@@ -126,6 +126,9 @@ sub do_fee_payment {
             foreach my $bill (@{$results}) {
                 my $payment;
                 syslog('LOG_INFO', 'OILS: bill '. $bill->id . ' amount ' . $bill->balance_owed);
+                # Skip negative or zero-balance bills. (Not that I've
+                # ever seen any.)
+                next if ($bill->balance_owed <= 0);
                 if ($bill->balance_owed >= $amount_paid) {
                     # We owe as much as or more than we have money
                     # left, so pay what we have left.
@@ -139,10 +142,13 @@ sub do_fee_payment {
                 }
                 # Add the payment to our array.
                 push(@payments, [$bill->id, $payment]);
+                # Attempt to round $amount_paid to avoid floating point error.
+                $amount_paid = sprintf("%.2f", $amount_paid);
+                syslog('LOG_INFO', "OILS: paid $payment on " . $bill->id . " with balance " . $bill->balance_owed . " and $amount_paid remaining");
                 # Leave if we ran out of money.
-                last if ($amount_paid == 0);
+                last if ($amount_paid == 0.00);
             }
-            if (@payments && $amount_paid == 0) {
+            if (@payments && $amount_paid == 0.00) {
                 # pay the bills with a reference to our payments
                 # array.
                 my $resp = $self->pay_bills(\@payments);

-----------------------------------------------------------------------

Summary of changes:
 .../lib/OpenILS/SIP/Transaction/FeePayment.pm      |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list