summaryrefslogtreecommitdiff
path: root/sql/modules/Vendor.sql
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-22 03:31:05 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-22 03:31:05 +0000
commit0190093b09369a6fcf50887620a65b242199478e (patch)
tree4f8b43257fc1703e609345be230d0493ae653860 /sql/modules/Vendor.sql
parent47b7f03901913406bf666fa6dd20b1856d1de7fd (diff)
More customer fixes
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1888 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'sql/modules/Vendor.sql')
-rw-r--r--sql/modules/Vendor.sql10
1 files changed, 7 insertions, 3 deletions
diff --git a/sql/modules/Vendor.sql b/sql/modules/Vendor.sql
index 8e9e12a9..1e3b640b 100644
--- a/sql/modules/Vendor.sql
+++ b/sql/modules/Vendor.sql
@@ -170,7 +170,7 @@ $$ language 'plpgsql';
create or replace function _entity_location_save(
- in_company_id int, in_location_id int,
+ in_entity_id int, in_location_id int,
in_location_class int, in_line_one text, in_line_two text,
in_line_three text, in_city TEXT, in_state TEXT, in_mail_code text,
in_country_code int
@@ -179,9 +179,13 @@ create or replace function _entity_location_save(
DECLARE
l_row location;
l_id INT;
+ t_company_id int;
BEGIN
+ SELECT id INTO t_company_id
+ FROM company WHERE entity_id = in_entity_id;
+
DELETE FROM company_to_location
- WHERE company_id = in_company_id
+ WHERE company_id = t_company_id
AND location_class = in_location_class
AND location_id = in_location_id;
@@ -191,7 +195,7 @@ create or replace function _entity_location_save(
INSERT INTO company_to_location
(company_id, location_class, location_id)
- VALUES (in_company_id, in_location_class, l_id);
+ VALUES (t_company_id, in_location_class, l_id);
RETURN l_id;
END;