[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [2169] trunk/sql/modules/Company.sql
- Subject: SF.net SVN: ledger-smb: [2169] trunk/sql/modules/Company.sql
- From: ..hidden..
- Date: Mon, 23 Jun 2008 10:08:59 -0700
Revision: 2169
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2169&view=rev
Author: einhverfr
Date: 2008-06-23 10:08:04 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
Updating customer/vendor saving to be more safe for multiple account entities.
Modified Paths:
--------------
trunk/sql/modules/Company.sql
Modified: trunk/sql/modules/Company.sql
===================================================================
--- trunk/sql/modules/Company.sql 2008-06-16 21:17:31 UTC (rev 2168)
+++ trunk/sql/modules/Company.sql 2008-06-23 17:08:04 UTC (rev 2169)
@@ -235,8 +235,23 @@
in_entity_id int, in_sic_code text
) RETURNS INT AS $$
DECLARE t_entity_id INT;
+ t_company_id INT;
BEGIN
IF in_entity_id IS NULL THEN
+ IF in_id IS NULL THEN
+ SELECT id INTO t_company_id FROM company
+ WHERE legal_name = in_name AND
+ (tax_id = in_tax_id OR
+ (tax_id IS NULL AND in_tax_id IS NULL));
+ END IF;
+ IF t_company_id IS NOT NULL THEN
+ SELECT entity_id INTO t_entity_id FROM company
+ WHERE id = t_company_id;
+ END IF;
+ ELSE
+ t_entity_id := in_entity_id;
+ END IF;
+ IF in_entity_id IS NULL THEN
INSERT INTO entity (name, entity_class)
VALUES (in_name, in_entity_class);
t_entity_id := currval('entity_id_seq');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.