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

SF.net SVN: ledger-smb: [2033] trunk/LedgerSMB/AA.pm



Revision: 2033
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2033&view=rev
Author:   einhverfr
Date:     2008-01-09 16:07:03 -0800 (Wed, 09 Jan 2008)

Log Message:
-----------
Correcting outstanding report

Modified Paths:
--------------
    trunk/LedgerSMB/AA.pm

Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm	2008-01-09 23:02:03 UTC (rev 2032)
+++ trunk/LedgerSMB/AA.pm	2008-01-10 00:07:03 UTC (rev 2033)
@@ -736,6 +736,7 @@
     my $buysell = 'buy';
     my $acc_trans_join;
     my $acc_trans_flds;
+    my $approved = ($form->{approved}) ? 'TRUE' : 'FALSE';
 
     if ( $form->{vc} eq 'vendor' ) {
         $ml      = -1;
@@ -754,7 +755,9 @@
 			SELECT SUM(ac.amount) * -1 * $ml
 			  FROM acc_trans ac
 			  JOIN chart c ON (c.id = ac.chart_id)
+		
 			 WHERE ac.trans_id = a.id
+			       AND ($approved OR ac.approved)
 			       AND (c.link LIKE '%${ARAP}_paid%' 
 			       OR c.link = '')|;
         if ( $form->{transdateto} ) {
@@ -957,9 +960,9 @@
     }
     
     # the third state, all invoices, sets no explicit toggles. It just selects them all, as normal. 
+    # $approved is safe as it is set to either "TRUE" or "FALSE"
 
-    $approved = ($form->{approved}) ? 'NULL' : 'FALSE';
-    $query .= "WHERE (coalesce($approved, TRUE) OR a.approved) AND $where
+    $query .= "WHERE ($approved OR a.approved) AND $where
 			ORDER BY $sortorder";
     my $sth = $dbh->prepare($query);
     $sth->execute(@paidargs) || $form->dberror($query);


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