WHY ARE THEY DIFFERENT?!?! ... it works now
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 Sep 2006 02:53:37 +0000 (02:53 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 Sep 2006 02:53:37 +0000 (02:53 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6073 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/money.pm

index cce232b..6a15e89 100644 (file)
@@ -19,6 +19,7 @@ sub _make_mbts {
                 my $lb = undef;
                 for my $b ($x->billings) {
                         next if ($b->voided);
                 my $lb = undef;
                 for my $b ($x->billings) {
                         next if ($b->voided);
+                       #$log->debug( "billing is ".$b->amount, DEBUG );
                         $to += int($b->amount * 100);
                         $lb ||= $b->billing_ts;
                         if ($b->billing_ts ge $lb) {
                         $to += int($b->amount * 100);
                         $lb ||= $b->billing_ts;
                         if ($b->billing_ts ge $lb) {
@@ -29,12 +30,13 @@ sub _make_mbts {
                         }
                 }
 
                         }
                 }
 
-                $s->total_owed( sprintf('%0.2f', $to / 100 ) );
+                $s->total_owed( sprintf('%0.2f', int($to) / 100 ) );
 
                 my $tp = 0;
                 my $lp = undef;
                 for my $p ($x->payments) {
 
                 my $tp = 0;
                 my $lp = undef;
                 for my $p ($x->payments) {
-                        next if ($p->voided);
+                       #$log->debug( "payment is ".$p->amount." voided = ".$p->voided, DEBUG );
+                        next if ($p->voided eq 't');
                         $tp += int($p->amount * 100);
                         $lp ||= $p->payment_ts;
                         if ($p->payment_ts ge $lp) {
                         $tp += int($p->amount * 100);
                         $lp ||= $p->payment_ts;
                         if ($p->payment_ts ge $lp) {
@@ -44,9 +46,10 @@ sub _make_mbts {
                                 $s->last_payment_type($p->payment_type);
                         }
                 }
                                 $s->last_payment_type($p->payment_type);
                         }
                 }
-                $s->total_paid( sprintf('%0.2f', $tp / 100 ) );
+                $s->total_paid( sprintf('%0.2f', int($tp) / 100 ) );
 
 
-                $s->balance_owed( sprintf('%0.2f', int($to - $tp) / 100) );
+                $s->balance_owed( sprintf('%0.2f', int(int($to) - int($tp)) / 100) );
+               #$log->debug( "balance of ".$x->id." == ".$s->balance_owed, DEBUG );
 
                 $s->xact_type( 'grocery' ) if (money::grocery->retrieve($x->id));
                 $s->xact_type( 'circulation' ) if (action::circulation->retrieve($x->id));
 
                 $s->xact_type( 'grocery' ) if (money::grocery->retrieve($x->id));
                 $s->xact_type( 'circulation' ) if (action::circulation->retrieve($x->id));