From 848030ca3812916ea01c8885ec380b10ffd4dde0 Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 8 Sep 2006 01:58:06 +0000 Subject: [PATCH] removing rounding errors git-svn-id: svn://svn.open-ils.org/ILS/trunk@6019 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Actor.pm | 14 +++++++------- .../src/perlmods/OpenILS/Application/Circ/Money.pm | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index 06128b55d6..6be58f8fe9 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -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); diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm index 569891a920..b1571b2c48 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm @@ -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); -- 2.43.2