summaryrefslogtreecommitdiff
path: root/sql/modules
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-14 04:56:25 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-14 04:56:25 +0000
commit2d77aea8bdf80d27ffe88b5e14bf5d7cb5d8214b (patch)
tree150d9cb6aee14c54ff47e7423e3a2e6ce80ebffb /sql/modules
parent4f6413f31a8009efc7ce2d01f0be9c687b260a09 (diff)
Adding multi-vendor searches now require the account number for the AR/AP account
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1596 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'sql/modules')
-rw-r--r--sql/modules/Payment.sql11
1 files changed, 9 insertions, 2 deletions
diff --git a/sql/modules/Payment.sql b/sql/modules/Payment.sql
index 6ecce576..15415f81 100644
--- a/sql/modules/Payment.sql
+++ b/sql/modules/Payment.sql
@@ -95,7 +95,8 @@ CREATE TYPE payment_contact_invoice AS (
CREATE OR REPLACE FUNCTION payment_get_all_contact_invoices
(in_account_class int, in_business_type int, in_currency char(3),
- in_date_from date, in_date_to date, in_batch_id int)
+ in_date_from date, in_date_to date, in_batch_id int,
+ in_ar_ap_accno text)
RETURNS SETOF payment_contact_invoice AS
$$
DECLARE payment_item payment_contact_invoice;
@@ -135,8 +136,14 @@ BEGIN
WHERE batch_id = in_batch_id))
AND c.entity_class = in_account_class
AND a.curr = in_currency
+ AND EXISTS (select trans_id FROM acc_trans
+ WHERE trans_id = a.id AND
+ chart_id = (SELECT id frOM chart
+ WHERE accno
+ = in_ar_ap_accno)
+ )
GROUP BY e.id, e.name, c.meta_number, c.threshold
- HAVING sum(amount - a.paid) > c.threshold
+ HAVING sum(a.amount - a.paid) > c.threshold
LOOP
RETURN NEXT payment_item;
END LOOP;