summaryrefslogtreecommitdiff
path: root/sql/modules/Payment.sql
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-27 20:09:23 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-27 20:09:23 +0000
commit3560cf58d9214c8d80e4fb95ecb42024607d868f (patch)
tree301d0ecc8684830d78efa2164b04bd05eaa535c0 /sql/modules/Payment.sql
parenta1203f811bb7c5a84fb4eed01dcb65417c0f406d (diff)
Fixing wrong index on location table
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1911 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'sql/modules/Payment.sql')
-rw-r--r--sql/modules/Payment.sql7
1 files changed, 4 insertions, 3 deletions
diff --git a/sql/modules/Payment.sql b/sql/modules/Payment.sql
index 7f2d16e7..b5beb196 100644
--- a/sql/modules/Payment.sql
+++ b/sql/modules/Payment.sql
@@ -66,13 +66,13 @@ BEGIN
SELECT a.id AS invoice_id, a.invnumber,
a.transdate AS invoice_date, a.amount,
CASE WHEN discount_terms
- > extract('days' FROM age(a.transdate))
+ < extract('days' FROM age(a.transdate))
THEN 0
ELSE (a.amount - a.paid) * c.discount / 100
END AS discount,
a.amount - a.paid -
CASE WHEN discount_terms
- > extract('days' FROM age(a.transdate))
+ < extract('days' FROM age(a.transdate))
THEN 0
ELSE (a.amount - a.paid) * c.discount / 100
END AS due
@@ -88,6 +88,7 @@ BEGIN
WHERE a.invoice_class = in_account_class
AND c.entity_class = in_account_class
AND a.curr = in_curr
+ AND a.entity_id = coalesce(in_entity_id, a.entity_id)
LOOP
RETURN NEXT payment_inv;
END LOOP;
@@ -346,4 +347,4 @@ DECLARE
END;
$$ language plpgsql;
COMMENT ON FUNCTION payment_get_vc_info(in_entity_id int) IS
-$$ This function return vendor or customer info, its under construction $$; \ No newline at end of file
+$$ This function return vendor or customer info, its under construction $$;