From 6edb22810a2b61250e7f230a1f6e9088182e00e5 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Fri, 18 Jul 2008 21:36:05 +0000 Subject: Corrects bug: vendor filter not applied to vouchers in same batch. git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2215 4979c152-3d1c-0410-bac9-87ea11338e46 --- sql/modules/Payment.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sql/modules') diff --git a/sql/modules/Payment.sql b/sql/modules/Payment.sql index 6e935b81..b1093305 100644 --- a/sql/modules/Payment.sql +++ b/sql/modules/Payment.sql @@ -252,8 +252,6 @@ BEGIN AND p.due <> 0 AND a.amount <> a.paid AND NOT a.on_hold - AND (in_meta_number IS NULL - OR in_meta_number = c.meta_number) AND NOT (t.locked_by IS NOT NULL AND t.locked_by IN (select "session_id" FROM "session" WHERE users_id IN @@ -266,9 +264,11 @@ BEGIN = in_ar_ap_accno) )) GROUP BY c.id, e.name, c.meta_number, c.threshold - HAVING sum(p.due) > c.threshold + HAVING (in_meta_number IS NULL + OR in_meta_number = c.meta_number) AND + (sum(p.due) > c.threshold OR sum(case when a.batch_id = in_batch_id then 1 - else 0 END) > 0 + else 0 END) > 0) LOOP RETURN NEXT payment_item; END LOOP; -- cgit v1.2.3