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

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



Revision: 3099
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3099&view=rev
Author:   einhverfr
Date:     2010-10-18 17:07:18 +0000 (Mon, 18 Oct 2010)

Log Message:
-----------
Alexey's patch for performance

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-14 00:45:11 UTC (rev 3098)
+++ addons/1.3/enhanced_tb/trunk/sql/modules/trial_balance.sql	2010-10-18 17:07:18 UTC (rev 3099)
@@ -68,6 +68,9 @@
     END IF;
     
     -- setup checkpoint stuff since can't do this in the from clause so well
+
+    -- the latest checkpoint before the start of the balance period
+
     IF i_date_from IS NOT NULL THEN
         SELECT end_date INTO cpa_date 
         FROM account_checkpoint
@@ -76,16 +79,14 @@
     ELSE
         cpa_date = NULL;
     END IF;
+   
+    -- the latest checkpoint before the end of the balance period
+    SELECT end_date INTO cpb_date
+    FROM account_checkpoint
+    WHERE end_date >= date_from AND end_date <= date_to
+    ORDER BY end_date DESC LIMIT 1;
+ 
     
-    IF i_date_to IS NOT NULL THEN
-        SELECT end_date INTO cpb_date
-        FROM account_checkpoint
-        WHERE end_date >= date_from AND end_date <= date_to
-        ORDER BY end_date DESC LIMIT 1;
-    ELSE
-        cpb_date = NULL;
-    END IF;
-    
 	FOR out_row IN
                 -- main trial balance query
 		SELECT a.id, a.accno, a.description, a.gifi_accno,


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