summaryrefslogtreecommitdiff
path: root/sql/modules
diff options
context:
space:
mode:
Diffstat (limited to 'sql/modules')
-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 $$;