[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[4294] branches/1.3



Revision: 4294
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4294&view=rev
Author:   tshvr
Date:     2012-02-08 15:06:15 +0000 (Wed, 08 Feb 2012)
Log Message:
-----------
format_amount numberformat make sure numbers stay BigFloat

Modified Paths:
--------------
    branches/1.3/LedgerSMB/GL.pm
    branches/1.3/bin/gl.pl

Modified: branches/1.3/LedgerSMB/GL.pm
===================================================================
--- branches/1.3/LedgerSMB/GL.pm	2012-02-07 13:50:13 UTC (rev 4293)
+++ branches/1.3/LedgerSMB/GL.pm	2012-02-08 15:06:15 UTC (rev 4294)
@@ -548,6 +548,9 @@
     $sth = $dbh->prepare($query);
     $sth->execute || $form->dberror($query);
 
+    my $minusOne=new Math::BigFloat(-1);#HV make sure BigFloat stays BigFloat
+    my $zeroBF=new Math::BigFloat(0);#HV make sure BigFloat stays BigFloat
+
     while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
 
         # gl
@@ -578,12 +581,12 @@
         }
 
         if ( $ref->{amount} < 0 ) {
-            $ref->{debit}  = $ref->{amount} * -1;
-            $ref->{credit} = 0;
+            $ref->{debit}  = $ref->{amount} * $minusOne;
+            $ref->{credit} = $zeroBF;
         }
         else {
             $ref->{credit} = $ref->{amount};
-            $ref->{debit}  = 0;
+            $ref->{debit}  = $zeroBF;
         }
 
         push @{ $form->{GL} }, $ref;

Modified: branches/1.3/bin/gl.pl
===================================================================
--- branches/1.3/bin/gl.pl	2012-02-07 13:50:13 UTC (rev 4293)
+++ branches/1.3/bin/gl.pl	2012-02-08 15:06:15 UTC (rev 4294)
@@ -501,7 +501,7 @@
     $form->{sort} = "transdate" unless $form->{sort};
     $form->{amountfrom} = $form->parse_amount(\%myconfig, $form->{amountfrom});
     $form->{amountto} = $form->parse_amount(\%myconfig, $form->{amountto});
-    my ($totaldebit, $totalcredit) = (0, 0);
+    my ($totaldebit, $totalcredit)=(new Math::BigFloat(0),new Math::BigFloat(0));
 
     GL->all_transactions( \%myconfig, \%$form );
 
@@ -534,7 +534,7 @@
     } else {
         $form->{title} = $locale->text('General Ledger');
     }
-    $ml = ( $form->{category} =~ /(A|E)/ ) ? -1 : 1;
+    $ml=new Math::BigFloat(($form->{category} =~ /(A|E)/)?-1:1);
 
     if (defined $form->{category} and $form->{category} ne 'X' ) {
         $form->{title} .=
@@ -715,12 +715,12 @@
     $hiddens{sort} = $form->{sort};
     $hiddens{callback} = $form->{callback};
 
-    $cml = 1;
+    $cml=new Math::BigFloat(1);
 
     # initial item for subtotals
     if ( @{ $form->{GL} } ) {
         $sameitem = $form->{GL}->[0]->{ $form->{sort} };
-        $cml = -1 if $form->{contra};
+        $cml=new Math::BigFloat(-1) if $form->{contra};
     }
 
     my @rows;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.