[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [2173] trunk
- Subject: SF.net SVN: ledger-smb: [2173] trunk
- From: ..hidden..
- Date: Wed, 25 Jun 2008 13:29:32 -0700
Revision: 2173
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2173&view=rev
Author: einhverfr
Date: 2008-06-25 13:29:31 -0700 (Wed, 25 Jun 2008)
Log Message:
-----------
Correcting NULL entity_id errors saving vendor
Modified Paths:
--------------
trunk/LedgerSMB/DBObject/Company.pm
trunk/sql/modules/Company.sql
Modified: trunk/LedgerSMB/DBObject/Company.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Company.pm 2008-06-25 18:19:28 UTC (rev 2172)
+++ trunk/LedgerSMB/DBObject/Company.pm 2008-06-25 20:29:31 UTC (rev 2173)
@@ -51,7 +51,9 @@
my $self = shift @_;
$self->set_entity_class();
my ($ref) = $self->exec_method(funcname => 'company_save');
- $self->{id} = $ref->{company_save};
+ $self->{entity_id} = (values %$ref)[0];
+ $self->get;
+ $self->get_metadata;
$self->{dbh}->commit;
}
Modified: trunk/sql/modules/Company.sql
===================================================================
--- trunk/sql/modules/Company.sql 2008-06-25 18:19:28 UTC (rev 2172)
+++ trunk/sql/modules/Company.sql 2008-06-25 20:29:31 UTC (rev 2173)
@@ -237,8 +237,11 @@
DECLARE t_entity_id INT;
t_company_id INT;
BEGIN
+ t_company_id := in_id;
+
IF in_entity_id IS NULL THEN
IF in_id IS NULL THEN
+ RAISE NOTICE 'in_id is null';
SELECT id INTO t_company_id FROM company
WHERE legal_name = in_name AND
(tax_id = in_tax_id OR
@@ -247,32 +250,29 @@
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
+ IF t_entity_id IS NULL THEN
INSERT INTO entity (name, entity_class)
VALUES (in_name, in_entity_class);
t_entity_id := currval('entity_id_seq');
- ELSE
- t_entity_id := in_entity_id;
END IF;
UPDATE company
SET legal_name = in_name,
tax_id = in_tax_id,
sic_code = in_sic_code
- WHERE id = in_id;
+ WHERE id = t_company_id;
- IF FOUND THEN
- RETURN in_id;
- ELSE
+ IF NOT FOUND THEN
INSERT INTO company(entity_id, legal_name, tax_id, sic_code)
VALUES (t_entity_id, in_name, in_tax_id, in_sic_code);
- RETURN currval('company_id_seq');
END IF;
+ RETURN t_entity_id;
END;
$$ LANGUAGE PLPGSQL;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.