From 0190093b09369a6fcf50887620a65b242199478e Mon Sep 17 00:00:00 2001 From: einhverfr Date: Thu, 22 Nov 2007 03:31:05 +0000 Subject: More customer fixes git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1888 4979c152-3d1c-0410-bac9-87ea11338e46 --- sql/modules/Vendor.sql | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'sql/modules/Vendor.sql') 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; -- cgit v1.2.3