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

SF.net SVN: ledger-smb:[2366] trunk/LedgerSMB/RP.pm



Revision: 2366
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2366&view=rev
Author:   einhverfr
Date:     2008-10-11 16:40:30 +0000 (Sat, 11 Oct 2008)

Log Message:
-----------
Filtering out unapproved ar/ap/gl transactions from trial balance.

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

Modified: trunk/LedgerSMB/RP.pm
===================================================================
--- trunk/LedgerSMB/RP.pm	2008-10-10 19:32:21 UTC (rev 2365)
+++ trunk/LedgerSMB/RP.pm	2008-10-11 16:40:30 UTC (rev 2366)
@@ -1078,8 +1078,13 @@
 				    FROM acc_trans ac
 				    JOIN chart c ON (c.id = ac.chart_id)
 				    JOIN gifi g ON (c.gifi_accno = g.accno)
+				    JOIN (SELECT id, approved FROM gl UNION
+				          SELECT id, approved FROM ar UNION
+				          SELECT id, approved FROM ap) gl
+				         ON (ac.trans_id = gl.id)
 				         $dpt_join
 				   WHERE $where $ywhere $dpt_where $category
+				         AND gl.approved AND ac.approved
 				         $project
 				GROUP BY g.accno, g.description, c.category
 	      
@@ -1361,9 +1366,14 @@
 				    JOIN chart c ON (ac.chart_id = c.id)
 				    JOIN gifi g ON (c.gifi_accno = g.accno)
 				         $dpt_join
+				    JOIN (SELECT id, approved FROM gl UNION
+				          SELECT id, approved FROM ar UNION
+				          SELECT id, approved FROM ap) gl
+				         ON (ac.trans_id = gl.id)
 				   WHERE ac.transdate < '$form->{fromdate}'
 				         $dpt_where $project
 				         AND ($approved OR ac.approved)
+				         AND ($approved OR gl.approved)
 				GROUP BY g.accno, c.category, g.description, 
 				         c.contra|;
 
@@ -1377,9 +1387,14 @@
 				    FROM acc_trans ac
 				    JOIN chart c ON (ac.chart_id = c.id)
 				         $dpt_join
+				    JOIN (SELECT id, approved FROM gl UNION
+				          SELECT id, approved FROM ar UNION
+				          SELECT id, approved FROM ap) gl
+				         ON (ac.trans_id = gl.id)
 				   WHERE ac.transdate < '$form->{fromdate}'
 				         $dpt_where $project
 				         AND ($approved OR ac.approved)
+				         AND ($approved OR gl.approved)
 				GROUP BY c.accno, c.category, c.description, 
 				         c.contra|;
 
@@ -1458,8 +1473,13 @@
 			    JOIN chart c ON (c.id = ac.chart_id)
 			    JOIN gifi g ON (c.gifi_accno = g.accno)
 			         $dpt_join
+			    JOIN (SELECT id, approved FROM gl UNION
+			          SELECT id, approved FROM ar UNION
+			          SELECT id, approved FROM ap) gl
+			         ON (ac.trans_id = gl.id)
 			   WHERE $where $dpt_where $project
-				         AND ($approved OR ac.approved)
+			         AND ($approved OR ac.approved)
+			         AND ($approved OR gl.approved)
 			GROUP BY g.accno, g.description, c.category, c.contra
 			ORDER BY accno|;
 
@@ -1472,8 +1492,13 @@
 			    FROM acc_trans ac
 			    JOIN chart c ON (c.id = ac.chart_id)
 			         $dpt_join
+			    JOIN (SELECT id, approved FROM gl UNION
+			          SELECT id, approved FROM ar UNION
+			          SELECT id, approved FROM ap) gl
+			         ON (ac.trans_id = gl.id)
 			   WHERE $where $dpt_where $project
-				         AND ($approved OR ac.approved)
+			         AND ($approved OR ac.approved)
+			         AND ($approved OR gl.approved)
 			GROUP BY c.accno, c.description, c.category, c.contra
 			ORDER BY accno|;
 
@@ -1487,14 +1512,24 @@
 		SELECT (SELECT SUM(ac.amount) * -1 FROM acc_trans ac
 		          JOIN chart c ON (c.id = ac.chart_id)
 		               $dpt_join
+			  JOIN (SELECT id, approved FROM gl UNION
+			        SELECT id, approved FROM ar UNION
+			        SELECT id, approved FROM ap) gl
+			       ON (ac.trans_id = gl.id)
 		          WHERE $where $dpt_where $project AND ac.amount < 0
-				         AND ($approved OR ac.approved)
+				 AND ($approved OR ac.approved)
+			         AND ($approved OR gl.approved)
 		                 AND c.accno = ?) AS debit,
 		       (SELECT SUM(ac.amount) FROM acc_trans ac
 		          JOIN chart c ON (c.id = ac.chart_id)
 		               $dpt_join
+			  JOIN (SELECT id, approved FROM gl UNION
+			        SELECT id, approved FROM ar UNION
+			        SELECT id, approved FROM ap) gl
+			       ON (ac.trans_id = gl.id)
 		         WHERE $where $dpt_where $project AND ac.amount > 0
-				         AND ($approved OR ac.approved)
+			       AND ($approved OR ac.approved)
+			       AND ($approved OR gl.approved)
 		               AND c.accno = ?) AS credit |;
 
     if ( $form->{accounttype} eq 'gifi' ) {


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