summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/Pg-database.sql1
-rw-r--r--sql/modules/Payment.sql7
2 files changed, 4 insertions, 4 deletions
diff --git a/sql/Pg-database.sql b/sql/Pg-database.sql
index ce443302..48275a5e 100644
--- a/sql/Pg-database.sql
+++ b/sql/Pg-database.sql
@@ -141,7 +141,6 @@ CREATE TABLE location (
inactive_date timestamp default null,
active boolean not null default TRUE
);
-CREATE INDEX location_unique_class_idx ON location (id,location_class);
CREATE TABLE company (
id serial UNIQUE,
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 $$;