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

SF.net SVN: ledger-smb:[5211] trunk/sql/Pg-database.sql



Revision: 5211
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5211&view=rev
Author:   einhverfr
Date:     2012-11-19 09:32:45 +0000 (Mon, 19 Nov 2012)
Log Message:
-----------
Cash impact view works for cash basis reports now.

Modified Paths:
--------------
    trunk/sql/Pg-database.sql

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2012-11-19 09:23:11 UTC (rev 5210)
+++ trunk/sql/Pg-database.sql	2012-11-19 09:32:45 UTC (rev 5211)
@@ -4764,13 +4764,17 @@
 CREATE VIEW cash_impact AS
 SELECT id, '1'::numeric AS portion, 'gl' as rel FROM gl
 UNION ALL
-SELECT id, gl.amount / (gl.amount - sum(ac.amount * -1)), 'ar' as rel
+SELECT id, CASE WHEN (gl.amount - sum(ac.amount * -1)) = 0 THEN 0 
+                ELSE gl.amount / (gl.amount - sum(ac.amount * -1))
+                END , 'ar' as rel
   FROM ar gl
   JOIN acc_trans ac ON ac.trans_id = gl.id
   JOIN account_link al ON ac.chart_id = al.account_id and al.description = 'AR'
  GROUP BY gl.id, gl.amount
 UNION ALL
-SELECT id, gl.amount / (gl.amount - sum(ac.amount)), 'ap' as rel
+SELECT id, CASE WHEN (gl.amount - sum(ac.amount)) = 0 THEN 0 
+                ELSE gl.amount / (gl.amount - sum(ac.amount))
+            END, 'ap' as rel
   FROM ap gl
   JOIN acc_trans ac ON ac.trans_id = gl.id
   JOIN account_link al ON ac.chart_id = al.account_id and al.description = 'AP'

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