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

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



Revision: 5283
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5283&view=rev
Author:   einhverfr
Date:     2012-11-28 08:12:48 +0000 (Wed, 28 Nov 2012)
Log Message:
-----------
Further corrections to cash basis income statements, test cases there added too

Modified Paths:
--------------
    trunk/sql/modules/PNL.sql
    trunk/t/43-dbtest.t

Modified: trunk/sql/modules/PNL.sql
===================================================================
--- trunk/sql/modules/PNL.sql	2012-11-28 07:02:24 UTC (rev 5282)
+++ trunk/sql/modules/PNL.sql	2012-11-28 08:12:48 UTC (rev 5283)
@@ -133,7 +133,12 @@
      JOIN account_heading ah on a.heading = ah.id
      JOIN acc_trans ac ON a.id = ac.chart_id AND ac.approved
      JOIN tx_report gl ON ac.trans_id = gl.id
-     JOIN cash_impact ca ON gl.id = ca.id
+     JOIN (SELECT id, sum(portion) as portion
+             FROM cash_impact ca 
+            WHERE ($1 IS NULL OR ca.transdate >= $1)
+                  AND ($2 IS NULL OR ca.transdate <= $2)
+           GROUP BY id
+          ) ca ON gl.id = ca.id 
 LEFT JOIN (select array_agg(path) as bu_ids, entry_id
              FROM business_unit_ac buac
              JOIN bu_tree ON bu_tree.id = buac.bu_id
@@ -142,8 +147,6 @@
     WHERE ac.approved is true 
           AND ($3 = '{}' 
               OR $3 is null or in_tree($3, bu_ids))
-          AND ($1 IS NULL OR ac.transdate >= $1) 
-          AND ($2 IS NULL OR ac.transdate <= $2)
           AND a.category IN ('I', 'E')
  GROUP BY a.id, a.accno, a.description, a.category, 
           ah.id, ah.accno, ah.description

Modified: trunk/t/43-dbtest.t
===================================================================
--- trunk/t/43-dbtest.t	2012-11-28 07:02:24 UTC (rev 5282)
+++ trunk/t/43-dbtest.t	2012-11-28 08:12:48 UTC (rev 5283)
@@ -5,7 +5,7 @@
 	plan skip_all => 'Skipping all.  Told not to test db.';
 }
 else {
-	plan tests => 292;
+	plan tests => 309;
 	if (defined $ENV{LSMB_NEW_DB}){
 		$ENV{PGDATABASE} = $ENV{LSMB_NEW_DB};
 	}
@@ -15,7 +15,7 @@
 }
 
 my @testscripts = qw(Account Reconciliation Business_type Company Draft Payment 
-			Session Voucher System Taxform COGS-FIFO);
+			Session Voucher System Taxform COGS-FIFO PNL);
 
 chdir 'sql/modules/test/';
 

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