removing rounding errors
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 8 Sep 2006 01:58:06 +0000 (01:58 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 8 Sep 2006 01:58:06 +0000 (01:58 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6019 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm

index 06128b5..6be58f8 100644 (file)
@@ -1862,11 +1862,11 @@ sub _make_mbts {
                $s->xact_start( $x->xact_start );
                $s->xact_finish( $x->xact_finish );
 
-               my $to = 0.0;
+               my $to = 0;
                my $lb = undef;
                for my $b (@{ $x->billings }) {
                        next if ($U->is_true($b->voided));
-                       $to += $b->amount;
+                       $to += int($b->amount * 100);
                        $lb ||= $b->billing_ts;
                        if ($b->billing_ts ge $lb) {
                                $lb = $b->billing_ts;
@@ -1875,13 +1875,13 @@ sub _make_mbts {
                                $s->last_billing_type($b->billing_type);
                        }
                }
-               $s->total_owed( $to );
+               $s->total_owed( sprintf('%0.2f', $to / 100 );
 
-               my $tp = 0.0;
+               my $tp = 0;
                my $lp = undef;
                for my $p (@{ $x->payments }) {
                        next if ($U->is_true($p->voided));
-                       $tp += $p->amount;
+                       $tp += int($p->amount * 100);
                        $lp ||= $p->payment_ts;
                        if ($p->payment_ts ge $lp) {
                                $lp = $p->payment_ts;
@@ -1890,9 +1890,9 @@ sub _make_mbts {
                                $s->last_payment_type($p->payment_type);
                        }
                }
-               $s->total_paid( $tp );
+               $s->total_paid( sprintf('%0.2f', $tp / 100 );
 
-               $s->balance_owed( $s->total_owed - $s->total_paid );
+               $s->balance_owed( sprintf('%0.2f', int($to - $tp) / 100);
 
                $s->xact_type( 'grocery' ) if ($x->grocery);
                $s->xact_type( 'circulation' ) if ($x->circulation);
index 569891a..b1571b2 100644 (file)
@@ -499,11 +499,11 @@ sub _make_mbts {
                 $s->xact_start( $x->xact_start );
                 $s->xact_finish( $x->xact_finish );
 
-                my $to = 0.0;
+                my $to = 0;
                 my $lb = undef;
                 for my $b (@{ $x->billings }) {
                        next if ($U->is_true($b->voided));
-                        $to += $b->amount;
+                        $to += int($b->amount * 100);
                         $lb ||= $b->billing_ts;
                         if ($b->billing_ts ge $lb) {
                                 $lb = $b->billing_ts;
@@ -512,13 +512,13 @@ sub _make_mbts {
                                 $s->last_billing_type($b->billing_type);
                         }
                 }
-                $s->total_owed( $to );
+               $s->total_owed( sprintf('%0.2f', $to / 100 );
 
-                my $tp = 0.0;
+                my $tp = 0;
                 my $lp = undef;
                 for my $p (@{ $x->payments }) {
                        next if ($U->is_true($p->voided));
-                        $tp += $p->amount;
+                        $tp += int($p->amount * 100);
                         $lp ||= $p->payment_ts;
                         if ($p->payment_ts ge $lp) {
                                 $lp = $p->payment_ts;
@@ -527,9 +527,9 @@ sub _make_mbts {
                                 $s->last_payment_type($p->payment_type);
                         }
                 }
-                $s->total_paid( $tp );
+               $s->total_paid( sprintf('%0.2f', $tp / 100 );
 
-                $s->balance_owed( $s->total_owed - $s->total_paid );
+               $s->balance_owed( sprintf('%0.2f', int($to - $tp) / 100);
 
                 $s->xact_type( 'grocery' ) if ($x->grocery);
                 $s->xact_type( 'circulation' ) if ($x->circulation);