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

SF.net SVN: ledger-smb: [1915] trunk/sql/modules/Payment.sql



Revision: 1915
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1915&view=rev
Author:   einhverfr
Date:     2007-11-28 18:44:06 -0800 (Wed, 28 Nov 2007)

Log Message:
-----------
A narrow shim in the payment logic that needs more review and thought before making permanent

Modified Paths:
--------------
    trunk/sql/modules/Payment.sql

Modified: trunk/sql/modules/Payment.sql
===================================================================
--- trunk/sql/modules/Payment.sql	2007-11-29 01:21:15 UTC (rev 1914)
+++ trunk/sql/modules/Payment.sql	2007-11-29 02:44:06 UTC (rev 1915)
@@ -1,13 +1,15 @@
-
+-- payment_get_open_accounts and the option to get all accounts need to be
+-- refactored and redesigned.  -- CT
 CREATE OR REPLACE FUNCTION payment_get_open_accounts(in_account_class int) 
 returns SETOF entity AS
 $$
 DECLARE out_entity entity%ROWTYPE;
 BEGIN
 	FOR out_entity IN
-		SELECT * FROM entity 
-		WHERE id IN (SELECT entity_id FROM entity_credit_account
-				WHERE entity_class = in_account_class)
+		SELECT ec.id, e.name, e.entity_class, e.created 
+		FROM entity e
+		JOIN entity_credit_account ec ON (ec.entity_id = e.id)
+			WHERE ec.entity_class = in_account_class
 		      AND CASE WHEN in_account_class = 1 THEN
 				id IN (SELECT entity_id FROM ap 
 					WHERE amount <> paid
@@ -33,9 +35,11 @@
 DECLARE out_entity entity%ROWTYPE;
 BEGIN
 	FOR out_entity IN
-		SELECT * FROM entity
-		WHERE id IN (seLECT entity_id FROM entity_credit_account
-				WHERE entity_class = in_account_class)
+		SELECT  ec.id, 
+			e.name, e.entity_class, e.created 
+		FROM entity e
+		JOIN entity_credit_account ec ON (ec.entity_id = e.id)
+				WHERE e.entity_class = in_account_class
 	LOOP
 		RETURN NEXT out_entity;
 	END LOOP;


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