summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-08-20 03:59:13 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-08-20 03:59:13 +0000
commit5469e9016ccfbbbf58e1630a39461a686a106355 (patch)
treea1c806eff6344f72b76dc2ef860535c02d95d450 /sql
parent4e500228f3066b14c987910f0afa53ed320b480e (diff)
Making account numbers clickable on customer/vendor screen, correcting contact editing population (needs a little more work there), and adding control code search
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2285 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'sql')
-rw-r--r--sql/modules/Company.sql9
-rw-r--r--sql/modules/Person.sql2
2 files changed, 7 insertions, 4 deletions
diff --git a/sql/modules/Company.sql b/sql/modules/Company.sql
index e7499ca1..04056164 100644
--- a/sql/modules/Company.sql
+++ b/sql/modules/Company.sql
@@ -16,7 +16,7 @@ CREATE OR REPLACE FUNCTION company__search
(in_account_class int, in_contact text, in_contact_info text[],
in_meta_number text, in_address text, in_city text, in_state text,
in_mail_code text, in_country text, in_date_from date, in_date_to date,
- in_business_id int, in_legal_name text)
+ in_business_id int, in_legal_name text, in_control_code text)
RETURNS SETOF company_search_result AS $$
DECLARE
out_row company_search_result;
@@ -34,6 +34,8 @@ BEGIN
JOIN entity_credit_account ec ON (ec.entity_id = e.id)
LEFT JOIN business b ON (ec.business_id = b.id)
WHERE ec.entity_class = in_account_class
+ AND (e.control_code = in_control_code
+ or in_control_code IS NULL)
AND (c.id IN (select company_id FROM company_to_contact
WHERE contact LIKE ALL(t_contact_info))
OR '' LIKE ALL(t_contact_info))
@@ -438,6 +440,7 @@ $$ LANGUAGE PLPGSQL;
CREATE TYPE contact_list AS (
class text,
+ class_id int,
description text,
contact text
);
@@ -447,7 +450,7 @@ RETURNS SETOF contact_list AS $$
DECLARE out_row contact_list;
BEGIN
FOR out_row IN
- SELECT cl.class, c.description, c.contact
+ SELECT cl.class, cl.id, c.description, c.contact
FROM company_to_contact c
JOIN contact_class cl ON (c.contact_class_id = cl.id)
WHERE company_id =
@@ -699,7 +702,7 @@ RETURNS SETOF contact_list AS $$
DECLARE out_row contact_list;
BEGIN
FOR out_row IN
- SELECT cl.class, c.description, c.contact
+ SELECT cl.class, cl.id, c.description, c.contact
FROM eca_to_contact c
JOIN contact_class cl ON (c.contact_class_id = cl.id)
WHERE credit_id = in_credit_id
diff --git a/sql/modules/Person.sql b/sql/modules/Person.sql
index 98b4dcb1..cd84fefc 100644
--- a/sql/modules/Person.sql
+++ b/sql/modules/Person.sql
@@ -106,7 +106,7 @@ $$
DECLARE out_row RECORD;
BEGIN
FOR out_row IN
- SELECT cc.class, c.description, c.contact
+ SELECT cc.class, cc.id, c.description, c.contact
FROM person_to_contact c
JOIN contact_class cc ON (c.contact_class_id = cc.id)
JOIN person p ON (c.person_id = p.id)