diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2008-08-12 16:37:02 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2008-08-12 16:37:02 +0000 |
commit | bca5826c5485e2c1f3d8cfdf36f247826ea4afed (patch) | |
tree | 651a841e2f495ac776aa88a273562160b8f8c23f /sql/modules | |
parent | 16c6c27b451f4ff3d35e82db757f8417847b44c7 (diff) |
Merging fix for bug 1974974
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2250 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'sql/modules')
-rw-r--r-- | sql/modules/Payment.sql | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sql/modules/Payment.sql b/sql/modules/Payment.sql index 2a7e6e56..bee243f8 100644 --- a/sql/modules/Payment.sql +++ b/sql/modules/Payment.sql @@ -187,7 +187,12 @@ BEGIN FOR payment_item IN SELECT c.id AS contact_id, e.name AS contact_name, c.meta_number AS account_number, - sum(p.due) AS total_due, + sum (coalesce(p.due, 0) - + CASE WHEN c.discount_terms + > extract('days' FROM age(a.transdate)) + THEN 0 + ELSE (coalesce(p.due, 0)) * coalesce(c.discount, 0) / 100 + END) AS total_due, compound_array(ARRAY[[ a.id::text, a.invnumber, a.transdate::text, a.amount::text, (a.amount - p.due)::text, |