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

SF.net SVN: ledger-smb:[3087] addons/1.3/enhanced_tb/trunk/sql/modules/ trial_balance.sql



Revision: 3087
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3087&view=rev
Author:   einhverfr
Date:     2010-10-05 04:08:46 +0000 (Tue, 05 Oct 2010)

Log Message:
-----------
Corrections in which sprocs are called, and minor corrections in their return values for the enhanced trial balance add-on.

Modified Paths:
--------------
    addons/1.3/enhanced_tb/trunk/sql/modules/trial_balance.sql

Modified: addons/1.3/enhanced_tb/trunk/sql/modules/trial_balance.sql
===================================================================
--- addons/1.3/enhanced_tb/trunk/sql/modules/trial_balance.sql	2010-10-05 03:45:41 UTC (rev 3086)
+++ addons/1.3/enhanced_tb/trunk/sql/modules/trial_balance.sql	2010-10-05 04:08:46 UTC (rev 3087)
@@ -107,10 +107,10 @@
 			               AND ac.transdate > cpb.end_date) OR
 			               (cpb.end_date IS NULL
 			               AND ac.transdate >= date_from) 
-			            THEN ac.amount
+			            THEN ac.amount * -1
 			        WHEN (cpb.end_date IS NOT NULL AND
 			              ac.transdate < date_from)
-			            THEN -ac.amount
+			            THEN ac.amount * -1
 			        ELSE 0
 			    END
 			END), 0) - 
@@ -165,7 +165,7 @@
      	 (cpa_date IS NULL AND cpb_date IS NULL) OR 
      	 (cpa_date IS NOT NULL AND cpb_date IS NULL AND 
      	 ac.transdate > cpa_date))) ac ON  (ac.chart_id = a.id)
-     	LEFT JOIN 
+     	JOIN 
      	(SELECT id, approved FROM ar
  		 UNION
          SELECT id, approved FROM gl
@@ -180,9 +180,10 @@
                     FROM account_checkpoint
                     WHERE end_date = cpb_date) cpb
                     ON (cpb.account_id = a.id)
-		WHERE ((in_heading IS NOT NULL AND a.heading = in_heading) OR 
-			  (in_accounts IS NOT NULL AND a.id = any(in_accounts)) OR
-			  (in_accounts IS NULL AND in_heading IS NULL))
+		WHERE ((a.heading = in_heading) OR 
+			  (a.id = any(in_accounts)) OR
+			  ((in_accounts IS NULL or in_accounts = '{}') 
+                          AND in_heading IS NULL))
 		GROUP BY a.id, a.description, a.accno, a.gifi_accno, 
 				 a.contra, a.category,cpa.end_date, cpb.end_date,
                  cpa.amount, cpb.amount, cpa.debits, cpb.debits,


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