summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-29 02:44:06 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-29 02:44:06 +0000
commitc5733b59242a43f386a2e5cf5be35b80e8ba93d4 (patch)
treee05bbb78863321e86ace6be80f887c00d25aee14
parentaaf5222fc502164ed7193a1c7036a0b80824ca27 (diff)
A narrow shim in the payment logic that needs more review and thought before making permanent
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1915 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--sql/modules/Payment.sql18
1 files changed, 11 insertions, 7 deletions
diff --git a/sql/modules/Payment.sql b/sql/modules/Payment.sql
index 1562a2ed..7accdae1 100644
--- a/sql/modules/Payment.sql
+++ b/sql/modules/Payment.sql
@@ -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;