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

SF.net SVN: ledger-smb: [1146] trunk



Revision: 1146
          http://svn.sourceforge.net/ledger-smb/?rev=1146&view=rev
Author:   einhverfr
Date:     2007-05-06 23:02:55 -0700 (Sun, 06 May 2007)

Log Message:
-----------
Applying patch to bugs 1699718 and 1713439

Modified Paths:
--------------
    trunk/LedgerSMB/AA.pm
    trunk/LedgerSMB/AM.pm
    trunk/LedgerSMB/CP.pm
    trunk/LedgerSMB/Form.pm
    trunk/LedgerSMB/IR.pm
    trunk/LedgerSMB/IS.pm
    trunk/LedgerSMB/OE.pm
    trunk/LedgerSMB/PriceMatrix.pm
    trunk/LedgerSMB/RC.pm
    trunk/LedgerSMB/RP.pm
    trunk/LedgerSMB.pm
    trunk/UPGRADE

Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm	2007-05-07 06:02:01 UTC (rev 1145)
+++ trunk/LedgerSMB/AA.pm	2007-05-07 06:02:55 UTC (rev 1146)
@@ -875,6 +875,7 @@
     $sth->execute(@paidargs) || $form->dberror($query);
 
     while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+	$form->db_parse_numeric(sth => $sth, hashref => $ref);
         $ref->{exchangerate} = 1 unless $ref->{exchangerate};
 
         if ( $ref->{linetotal} <= 0 ) {
@@ -963,7 +964,7 @@
     $sth->execute(@queryargs) || $form->dberror($query);
 
     $ref = $sth->fetchrow_hashref(NAME_lc);
-
+    $form->db_parse_numeric(sth => $sth, hashref => $ref);
     if ( $form->{id} ) {
         for (qw(currency employee employee_id intnotes)) {
             delete $ref->{$_};
@@ -1028,7 +1029,9 @@
     $sth = $dbh->prepare($query);
     $sth->execute( $form->{"$form->{vc}_id"} ) || $form->dberror($query);
 
-    while ( my ( $amount, $exch ) = $sth->fetchrow_array ) {
+    while ( my @ref = $sth->fetchrow_array ) {
+        $form->db_parse_numeric(sth => $sth, arrayref => ..hidden..);
+        my ($amount, $exch) = @ref;
         $exch = 1 unless $exch;
         $form->{creditremaining} -= $amount * $exch;
     }
@@ -1099,6 +1102,7 @@
     my %a = ();
 
     while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+        $form->db_parse_numeric(sth => $sth, hashref => $hashref);
 
         if ( $tax{ $ref->{accno} } ) {
             if ( not exists $a{ $ref->{accno} } ) {

Modified: trunk/LedgerSMB/AM.pm
===================================================================
--- trunk/LedgerSMB/AM.pm	2007-05-07 06:02:01 UTC (rev 1145)
+++ trunk/LedgerSMB/AM.pm	2007-05-07 06:02:55 UTC (rev 1146)
@@ -382,7 +382,7 @@
     }
 
     $sth = $dbh->prepare($query);
-    $sth->execute(@queryargs) || $form->dberror;
+    $sth->execute(@queryargs) || $form->dberror($query);
     $sth->finish;
     $dbh->commit;
 

Modified: trunk/LedgerSMB/CP.pm
===================================================================
--- trunk/LedgerSMB/CP.pm	2007-05-07 06:02:01 UTC (rev 1145)
+++ trunk/LedgerSMB/CP.pm	2007-05-07 06:02:55 UTC (rev 1146)
@@ -499,7 +499,7 @@
             $form->{"paid_$i"} =
               $form->round_amount( $form->{"paid_$i"} * $exchangerate, 2 );
 
-            $pth->execute( $form->{"id_$i"} ) || $form->dberror;
+            $pth->execute( $form->{"id_$i"} ) || $form->dberror($pth->statement);
             ($amount) = $pth->fetchrow_array;
             $pth->finish;
 
@@ -774,7 +774,7 @@
 
             $paid = $form->round_amount( $paid * $exchangerate, 2 );
 
-            $pth->execute( $form->{"id_$i"} ) || $form->dberror;
+            $pth->execute( $form->{"id_$i"} ) || $form->dberror($pth->statement);
             ($amount) = $pth->fetchrow_array;
             $pth->finish;
 

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2007-05-07 06:02:01 UTC (rev 1145)
+++ trunk/LedgerSMB/Form.pm	2007-05-07 06:02:55 UTC (rev 1146)
@@ -585,6 +585,25 @@
     return $amount;
 }
 
+sub db_parse_numeric {
+    my $self = shift;
+    my %args = @_;
+    my ($sth, $arrayref, $hashref) = ($args{sth}, $args{arrayref}, 
+          $args{hashref});
+    my @types = @{$sth->{TYPE}};
+    my @names = @{$sth->{NAME_lc}};
+    for (0 .. $#names){
+        if ($types[$_] == 3){
+            $arrayref[$_] = Math::BigFloat->new($arrayref[$_]) 
+              if defined $arrayref;
+            $hashref->{$names[$_]} = Math::BigFloat->new($hashref->{$names[$_]})
+              if defined $hashref;
+        }
+
+    }
+    return ($hashref || $arrayref);
+}
+
 sub callproc {
     my $procname = shift @_;
     my $argstr   = "";
@@ -1407,7 +1426,7 @@
 
         $mm--;
 
-        @t = localtime( timelocal( 0, 0, 0, $dd, $mm, $yy ) + $diff );
+        @t = localtime( Time::Local::timelocal( 0, 0, 0, $dd, $mm, $yy ) + $diff );
 
         $t[4]++;
         $mm = substr( "0$t[4]", -2 );
@@ -1732,6 +1751,7 @@
         $sth->execute( $curr, $transdate );
 
         ($exchangerate) = $sth->fetchrow_array;
+	$exchangerate = Math::BigFloat->new($exchangerate);
     }
 
     $sth->finish;
@@ -2177,6 +2197,10 @@
     # get last customers or vendors
     my ( $query, $sth );
 
+    if (!$self->{dbh}) {
+        $self->db_init($myconfig);
+    }
+
     $dbh = $self->{dbh};
 
     my %xkeyref = ();
@@ -2238,6 +2262,7 @@
         $sth->execute( $self->{id} ) || $self->dberror($query);
 
         $ref = $sth->fetchrow_hashref(NAME_lc);
+        $self->db_parse_numeric(sth=>$sth, hashref=>$ref);
 
         foreach $key ( keys %$ref ) {
             $self->{$key} = $ref->{$key};
@@ -2713,19 +2738,19 @@
     $query = qq|DELETE FROM recurring
 				 WHERE id = ?|;
 
-    $sth = $dbh->prepare($query);
+    $sth = $dbh->prepare($query) || $self->dberror($query);
     $sth->execute( $self->{id} ) || $self->dberror($query);
 
     $query = qq|DELETE FROM recurringemail
 				 WHERE id = ?|;
 
-    $sth = $dbh->prepare($query);
+    $sth = $dbh->prepare($query) || $self->dberror($query);
     $sth->execute( $self->{id} ) || $self->dberror($query);
 
     $query = qq|DELETE FROM recurringprint
 				 WHERE id = ?|;
 
-    $sth = $dbh->prepare($query);
+    $sth = $dbh->prepare($query) || $self->dberror($query);
     $sth->execute( $self->{id} ) || $self->dberror($query);
 
     if ( $self->{recurring} ) {
@@ -2756,10 +2781,10 @@
 
         # calculate nextdate
         $query = qq|
-			SELECT current_date - date ? AS a,
-				date ? - current_date AS b|;
+			SELECT current_date - ?::date AS a,
+				?::date - current_date AS b|;
 
-        $sth = $dbh->prepare($query);
+        $sth = $dbh->prepare($query) || $self->dberror($query);
         $sth->execute( $s{startdate}, $enddate );
         my ( $a, $b ) = $sth->fetchrow_array;
 
@@ -2775,16 +2800,9 @@
         my $nextdate = $enddate;
         if ( $advance > 0 ) {
             if ( $advance < ( $s{repeat} * $s{howmany} ) ) {
-                %interval = (
-                    'Pg' =>
-                      "(date '$s{startdate}' + interval '$advance $s{unit}')",
-                    'DB2' => qq|(date ('$s{startdate}') + "$advance $s{unit}")|,
-                );
 
-                $interval{Oracle} = $interval{PgPP} = $interval{Pg};
+                $query = qq|SELECT (date '$s{startdate}' + interval '$advance $s{unit}')|;
 
-                $query = qq|SELECT $interval{$myconfig->{dbdriver}}|;
-
                 ($nextdate) = $dbh->selectrow_array($query);
             }
 
@@ -3262,7 +3280,7 @@
                         $sth->bind_param( $i++, $newtrail{$key}{$_} );
                     }
                     $sth->bind_param( $i++, $employee_id );
-                    $sth->execute || $self->dberror;
+                    $sth->execute() || $self->dberror($query);
                     $sth->finish;
                 }
             }

Modified: trunk/LedgerSMB/IR.pm
===================================================================
--- trunk/LedgerSMB/IR.pm	2007-05-07 06:02:01 UTC (rev 1145)
+++ trunk/LedgerSMB/IR.pm	2007-05-07 06:02:55 UTC (rev 1146)
@@ -337,6 +337,7 @@
                 my $totalqty = $form->{"qty_$i"};
 
                 while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+                    $form->db_parse_numeric(sth=>$sth, hashref => $ref);
 
                     my $qty = $ref->{qty} + $ref->{allocated};
 
@@ -1034,6 +1035,7 @@
         $sth->execute( $form->{id} ) || $form->dberror($query);
 
         $ref = $sth->fetchrow_hashref(NAME_lc);
+        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
         for ( keys %$ref ) {
             $form->{$_} = $ref->{$_};
         }
@@ -1093,6 +1095,7 @@
         my $ptref;
 
         while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+            $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
 
             my ($dec) = ( $ref->{fxsellprice} =~ /\.(\d+)/ );
             $dec = length $dec;
@@ -1103,6 +1106,7 @@
             my $taxrate = 0;
 
             while ( $ptref = $tth->fetchrow_hashref(NAME_lc) ) {
+                $form->db_parse_numeric(sth => $tth, hashref => $ptref);
                 $ref->{taxaccounts} .= "$ptref->{accno} ";
                 $taxrate += $form->{"$ptref->{accno}_rate"};
             }
@@ -1215,6 +1219,7 @@
     my $ptref;
 
     while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
 
         my ($dec) = ( $ref->{sellprice} =~ /\.(\d+)/ );
         $dec = length $dec;
@@ -1277,7 +1282,9 @@
     # get exchange rates for transdate or max
     foreach $var ( split /:/, substr( $form->{currencies}, 4 ) ) {
         $eth1->execute( $var, $form->{transdate} );
-        ( $form->{$var} ) = $eth1->fetchrow_array;
+        @array = $eth1->fetchrow_array;
+	$form->db_parse_numeric(sth=> $eth1, arrayref=>..hidden..);
+        $form->{$var} = shift @array;
         if ( !$form->{$var} ) {
             $eth2->execute($var);
 

Modified: trunk/LedgerSMB/IS.pm
===================================================================
--- trunk/LedgerSMB/IS.pm	2007-05-07 06:02:01 UTC (rev 1145)
+++ trunk/LedgerSMB/IS.pm	2007-05-07 06:02:55 UTC (rev 1146)
@@ -1516,6 +1516,7 @@
     my $qty;
 
     while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+	$form->db_parse_numeric(sth=>$sth, hashref=>$ref);
         if ( ( $qty = ( ( $ref->{qty} * -1 ) - $ref->{allocated} ) ) >
             $totalqty )
         {
@@ -1751,6 +1752,7 @@
         $sth->execute( $form->{id} ) || $form->dberror($query);
 
         $ref = $sth->fetchrow_hashref(NAME_lc);
+        $form->db_parse_numeric(sth=> $sth, hashref=>$ref_);
         for ( keys %$ref ) { $form->{$_} = $ref->{$_} }
         $sth->finish;
 
@@ -1808,7 +1810,7 @@
         my $ptref;
 
         while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-
+            $form->db_parse_numeric(sth=>$sth, hashref => $ref);
             my ($dec) = ( $ref->{fxsellprice} =~ /\.(\d+)/ );
             $dec = length $dec;
             my $decimalplaces = ( $dec > 2 ) ? $dec : 2;
@@ -1935,6 +1937,7 @@
     my $transdate = $form->datetonum( $myconfig, $form->{transdate} );
 
     while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+        $form->db_parse_numeric(sth => $sth, hashref => $ref);
 
         my ($dec) = ( $ref->{sellprice} =~ /\.(\d+)/ );
         $dec = length $dec;

Modified: trunk/LedgerSMB/OE.pm
===================================================================
--- trunk/LedgerSMB/OE.pm	2007-05-07 06:02:01 UTC (rev 1145)
+++ trunk/LedgerSMB/OE.pm	2007-05-07 06:02:55 UTC (rev 1146)
@@ -220,6 +220,7 @@
 
     my %oid = ();
     while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+	$form->db_parse_numeric(sth=>$sth, hashref=>$ref);
         $ref->{exchangerate} = 1 unless $ref->{exchangerate};
         if ( $ref->{id} != $oid{id}{ $ref->{id} } ) {
             push @{ $form->{OE} }, $ref;
@@ -774,6 +775,7 @@
         $sth->execute( $form->{id} ) || $form->dberror($query);
 
         $ref = $sth->fetchrow_hashref(NAME_lc);
+        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
         for ( keys %$ref ) { $form->{$_} = $ref->{$_} }
         $sth->finish;
 
@@ -848,6 +850,7 @@
         my $listprice;
 
         while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+            $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
 
             ($decimalplaces) = ( $ref->{sellprice} =~ /\.(\d+)/ );
             $decimalplaces = length $decimalplaces;
@@ -941,11 +944,16 @@
     # get exchange rates for transdate or max
     foreach $var ( split /:/, substr( $form->{currencies}, 4 ) ) {
         $eth1->execute( $var, $form->{transdate} );
-        ( $form->{$var} ) = $eth1->fetchrow_array;
+        my @exchangelist;
+        @exchangelist = $eth1->fetchrow_array;
+        $form->db_parse_numeric(sth=>$eth1, arrayref=>..hidden..);
+        $form->{$var} = shift @array;
         if ( !$form->{$var} ) {
             $eth2->execute($var);
+            @exchangelist = $eth2->fetchrow_array;
+            $form->db_parse_numeric(sth=>$eth2, arrayref=>..hidden..);
 
-            ( $form->{$var} ) = $eth2->fetchrow_array;
+            ( $form->{$var} ) = @exchangelist; 
             ( $null, $form->{$var} ) = split / /, $form->{$var};
             $form->{$var} = 1 unless $form->{$var};
             $eth2->finish;
@@ -1116,7 +1124,10 @@
             $sth->execute( $form->{"id_$i"}, $form->{warehouse_id} )
               || $form->dberror;
 
-            ($qty) = $sth->fetchrow_array;
+            my @qtylist = $sth->fetchrow_array;
+            $form->db_parse_numeric(sth=>$sth, arrayref=>..hidden..);
+
+            ($qty) = @qtylist; $sth->fetchrow_array;
             $sth->finish;
 
             $form->{"qty_$i"} = 0 if $qty == 0;
@@ -1604,6 +1615,7 @@
     $sth->execute($id) || $form->dberror($query);
 
     while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
 
         for (qw(partnumber description partsgroup)) {
             $form->{"a_$_"} = $ref->{$_};
@@ -1774,7 +1786,9 @@
             $wth->execute( $form->{"id_$i"}, $warehouse_id )
               || $form->dberror;
 
-            ($qty) = $wth->fetchrow_array;
+            @qtylist = $wth->fetchrow_array;
+            $form->db_parse_numeric(sth=>$wth, arrayref=>..hidden..);
+            ($qty) = @qtylist;
             $wth->finish;
 
             if ( $ship > $qty ) {
@@ -2066,6 +2080,7 @@
     $sth->execute || $form->dberror($query);
 
     while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
         $ref->{qty} = $ref->{onhand} - $ref->{qty};
         push @{ $form->{all_inventory} }, $ref if $ref->{qty} > 0;
     }
@@ -2153,6 +2168,7 @@
             $sth->execute( $form->{"ndx_$i"} );
 
             while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+                $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
                 &add_items_required( "", $dbh, $form, $ref->{id},
                     $ref->{required}, $ref->{assembly} );
             }
@@ -2188,6 +2204,7 @@
         $sth->execute || $form->dberror($query);
 
         while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+            $form->db_parse_numeric(sth=> $sth, hashref=> $ref);
             &add_items_required( "", $dbh, $form, $ref->{id},
                 $required * $ref->{qty},
                 $ref->{assembly} );
@@ -2204,6 +2221,7 @@
         $sth = $dbh->prepare($query);
         $sth->execute($parts_id) || $form->dberror($query);
         $ref = $sth->fetchrow_hashref(NAME_lc);
+        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
         for ( keys %$ref ) {
             $form->{orderitems}{$parts_id}{$_} = $ref->{$_};
         }
@@ -2292,6 +2310,7 @@
         $sth = $dbh->prepare($query);
         $sth->execute($vendor_id) || $form->dberror($query);
         while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+            $form->db_parse_numeric(sth=>$sth, hashref=> $ref);
             $curr                 = $ref->{curr};
             $taxincluded          = $ref->{taxincluded};
             $tax{ $ref->{accno} } = $ref->{rate};

Modified: trunk/LedgerSMB/PriceMatrix.pm
===================================================================
--- trunk/LedgerSMB/PriceMatrix.pm	2007-05-07 06:02:01 UTC (rev 1145)
+++ trunk/LedgerSMB/PriceMatrix.pm	2007-05-07 06:02:55 UTC (rev 1146)
@@ -122,6 +122,7 @@
 
         while ( $mref = $pmh->fetchrow_hashref(NAME_lc) ) {
 
+            $form->db_parse_numeric(sth=>$sth, hashref=>$mref);
             # check date
             if ( $mref->{validfrom} ) {
                 next
@@ -193,6 +194,7 @@
         $pmh->execute( $ref->{id} );
 
         $mref = $pmh->fetchrow_hashref(NAME_lc);
+        $form->db_parse_numeric(sth=>$sth, hashref=>$mref);
 
         if ( $mref->{partnumber} ne "" ) {
             $ref->{partnumber} = $mref->{partnumber};

Modified: trunk/LedgerSMB/RC.pm
===================================================================
--- trunk/LedgerSMB/RC.pm	2007-05-07 06:02:01 UTC (rev 1145)
+++ trunk/LedgerSMB/RC.pm	2007-05-07 06:02:55 UTC (rev 1146)
@@ -53,6 +53,7 @@
     my $sth = $dbh->prepare($query);
     $sth->execute( $pos_config{till_accno} ) || $form->dberror($query);
     while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
         push @{ $form->{TB} }, $ref;
     }
     $sth->finish;
@@ -64,6 +65,7 @@
     my $sth = $dbh->prepare($query);
     $sth->execute( $pos_config{till_accno} ) || $form->dberror($query);
     my $ref = $sth->fetchrow_hashref(NAME_lc);
+    $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
     $form->{sum} = $ref->{sum};
     $sth->finish;
 }
@@ -101,6 +103,7 @@
     my $sth = $dbh->prepare($query);
     $sth->execute( $form->{accno} ) || $form->dberror($query);
     my $ref = $sth->fetchrow_hashref(NAME_lc);
+    $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
     $form->{balance} = $ref->{balance};
 }
 
@@ -162,7 +165,9 @@
 		 WHERE ch.accno = ? $transdate $cleared |;
     $sth = $dbh->prepare($query);
     $sth->execute( $form->{accno} );
-    ( $form->{beginningbalance} ) = $sth->fetchrow_array();
+    my @balancelist = $sth->fetchrow_array();
+    $form->db_parse_numeric(sth=>$sth, arraylist=>..hidden..);
+    ( $form->{beginningbalance} ) = @balancelist;
 
     $query = qq|
 		SELECT sum(ac.amount)
@@ -173,7 +178,9 @@
 
     $sth = $dbh->prepare($query);
     $sth->execute( $form->{accno} );
-    ( $form->{fx_balance} ) = $sth->fetchrow_array();
+    @balancelist = $sth->fetchrow_array();
+    $form->db_parse_numeric(sth=>$sth, arraylist=>..hidden..);
+    ( $form->{fx_balance} ) = @balancelist;
 
     $transdate = "";
     if ( $form->{todate} ) {
@@ -190,7 +197,9 @@
 
     $sth = $dbh->prepare($query);
     $sth->execute( $form->{accno} );
-    ( $form->{endingbalance} ) = $sth->fetchrow_array();
+    @balancelist = $sth->fetchrow_array();
+    $form->db_parse_numeric(sth=>$sth, arraylist=>..hidden..);
+    ( $form->{endingbalance} ) = @balancelist;
 
     # fx balance
     $query = qq|
@@ -201,7 +210,9 @@
 
     $sth = $dbh->prepare($query);
     $sth->execute( $form->{accno} );
-    ( $form->{fx_endingbalance} ) = $sth->fetchrow_array();
+    @balancelist = $sth->fetchrow_array();
+    $form->db_parse_numeric(sth=>$sth, arraylist=>..hidden..);
+    ( $form->{fx_endingbalance} ) = @balancelist;
 
     $cleared = qq| AND ac.cleared = '0'| unless $form->{fromdate};
 
@@ -392,6 +403,7 @@
     my $ref;
 
     while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
 
         if ( $form->{summary} ) {
 

Modified: trunk/LedgerSMB/RP.pm
===================================================================
--- trunk/LedgerSMB/RP.pm	2007-05-07 06:02:01 UTC (rev 1145)
+++ trunk/LedgerSMB/RP.pm	2007-05-07 06:02:55 UTC (rev 1146)
@@ -91,6 +91,7 @@
     $sth->execute() || $form->dberror($query);
     @cols = qw(description sold revenue partnumber received expense);
     while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
         $ref->{net_income} = $ref->{revenue} - $ref->{expense};
         map { $ref->{$_} =~ s/^\s*// } @cols;
         map { $ref->{$_} =~ s/\s*$// } @cols;
@@ -1224,6 +1225,7 @@
 
     while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
 
+        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
         # get last heading account
         @accno = grep { $_ le "$ref->{accno}" } @headingaccounts;
         $accno = pop @accno;
@@ -1347,6 +1349,7 @@
         $sth->execute || $form->dberror($query);
 
         while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+            $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
             $ref->{amount} = $form->round_amount( $ref->{amount}, 2 );
             $balance{ $ref->{accno} } = $ref->{amount};
 
@@ -1381,6 +1384,7 @@
     $sth->execute || $form->dberror($query);
 
     while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
         $trb{ $ref->{accno} }{description} = $ref->{description};
         $trb{ $ref->{accno} }{charttype}   = 'H';
         $trb{ $ref->{accno} }{category}    = $ref->{category};
@@ -1472,6 +1476,7 @@
 
     # calculate debit and credit for the period
     while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
         $trb{ $ref->{accno} }{description} = $ref->{description};
         $trb{ $ref->{accno} }{charttype}   = 'A';
         $trb{ $ref->{accno} }{category}    = $ref->{category};
@@ -1511,7 +1516,9 @@
                   || $form->dberror($query);
 
                 ( $debit, $credit ) = ( 0, 0 );
-                while ( ( $debit, $credit ) = $drcr->fetchrow_array ) {
+                while ( my @drcrlist = $drcr->fetchrow_array ) {
+                    $form->db_parse_numeric(sth=>$drcr, arrayref=>..hidden..);
+                    ($debit, $credit) = @drcrlist;
                     $ref->{debit}  += $debit;
                     $ref->{credit} += $credit;
                 }
@@ -1758,6 +1765,7 @@
                 $sth->execute(@var);
 
                 while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+		    $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
                     $ref->{module} =
                       ( $ref->{invoice} )
                       ? $invoice
@@ -1780,6 +1788,7 @@
     $sth->execute || $form->dberror($query);
 
     while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
         push @{ $form->{all_language} }, $ref;
     }
     $sth->finish;
@@ -2197,6 +2206,7 @@
     $sth->execute || $form->dberror($query);
 
     while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
         $ref->{tax} = $form->round_amount( $ref->{tax}, 2 );
         if ( $form->{report} =~ /nontaxable/ ) {
             push @{ $form->{TR} }, $ref if $ref->{netamount};
@@ -2368,6 +2378,7 @@
         $sth->execute || $form->dberror($query);
 
         while ( my $pr = $sth->fetchrow_hashref(NAME_lc) ) {
+            $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
             push @{ $form->{ $ref->{id} } }, $pr;
         }
         $sth->finish;

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2007-05-07 06:02:01 UTC (rev 1145)
+++ trunk/LedgerSMB.pm	2007-05-07 06:02:55 UTC (rev 1146)
@@ -438,7 +438,7 @@
     my @names = @{$sth->{NAME_lc}};
     while ( my $ref = $sth->fetchrow_hashref('NAME_lc') ) {
 	for (0 .. $#names){
-            if ($types[$_] eq 'NUMERIC'){
+            if ($types[$_] == 3){
                 $ref->{$names[$_]} = Math::BigFloat->new($ref->{$names[$_]});
             }
         }

Modified: trunk/UPGRADE
===================================================================
--- trunk/UPGRADE	2007-05-07 06:02:01 UTC (rev 1145)
+++ trunk/UPGRADE	2007-05-07 06:02:55 UTC (rev 1146)
@@ -53,8 +53,12 @@
 
   a) cd to the sql/legacy/ directory of the new ledger directory
   b) run "psql" with appropriate options to connect to your database.
-  c) Note the db version by running the following query:
-     "SELECT version FROM defaults;"
+  c) Note the db schema version by running the following query:
+     "SELECT value from defaults where setting_key = 'version';" (1.2.0 or 
+     later)
+       or
+     "SELECT version FROM defaults;" (SQL-Ledger 2.6.x or LedgerSMB 1.1.x 
+     or earlier)
   d) Run the SQL upgrade scripts in order starting with the one whose name
      begins with "Pg-upgrade-[version]" (each of these scripts will upgrade to
      the next database version which is also identified in the file name).


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