[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [864] trunk



Revision: 864
          http://svn.sourceforge.net/ledger-smb/?rev=864&view=rev
Author:   einhverfr
Date:     2007-03-08 10:28:59 -0800 (Thu, 08 Mar 2007)

Log Message:
-----------
renaming employee to employees and dropping insert tracking rule

Modified Paths:
--------------
    trunk/Changelog
    trunk/LedgerSMB/DBObject.pm
    trunk/LedgerSMB/Employee.pm
    trunk/sql/upgrade/1.2-1.3.sql

Modified: trunk/Changelog
===================================================================
--- trunk/Changelog	2007-03-08 07:07:59 UTC (rev 863)
+++ trunk/Changelog	2007-03-08 18:28:59 UTC (rev 864)
@@ -3,8 +3,10 @@
 * Basic RESTful web services dispatcher (Jason)
 * Timecard lists project descriptions as well as numbers (Chris)
 * Chart of Accounts files organized hierarchically by country code (Chris)
+* Employee table is now Employees and no longer part of global sequence. (Chris)
 
 
+
 Changelog for LedgerSMB 1.2.0
 
 Database:

Modified: trunk/LedgerSMB/DBObject.pm
===================================================================
--- trunk/LedgerSMB/DBObject.pm	2007-03-08 07:07:59 UTC (rev 863)
+++ trunk/LedgerSMB/DBObject.pm	2007-03-08 18:28:59 UTC (rev 864)
@@ -31,6 +31,18 @@
 
 @ISA = (LedgerSMB);
 
+sub new {
+	my $lsmb = shift @_;
+	if (! $lsmb->isa(LedgerSMB)){
+		$self->error("Constructor called without LedgerSMB object arg");
+	my $self = {};
+	for $attr (keys $lsmb){
+		$self->{$attr} = $lsmb->{$attr};
+	}
+	bless $self;
+}
+
+
 sub exec_method {
 	my ($self) = shift @_;
 	my ($funcname) = shift @_;

Modified: trunk/LedgerSMB/Employee.pm
===================================================================
--- trunk/LedgerSMB/Employee.pm	2007-03-08 07:07:59 UTC (rev 863)
+++ trunk/LedgerSMB/Employee.pm	2007-03-08 18:28:59 UTC (rev 864)
@@ -38,18 +38,6 @@
 	$self->exec_method($procname);
 }
 
-sub new {
-	my $lsmb = shift @_;
-	if (! $lsmb->isa(LedgerSMB)){
-		$self->error("Employee called without LedgerSMB object arg");
-	my $self = {};
-	for $attr (keys $lsmb){
-		$self->{$attr} = $lsmb->{$attr};
-	}
-	bless $self;
-}
-
-
 sub save {
 	my $hashref = shift ($self->exec_method("employee_save"));
 	$self->merge($hashref, 'id');
@@ -71,3 +59,5 @@
 sub search {
 	$self->{search_results} = $self->exec_method("employee_search");
 }
+
+1;

Modified: trunk/sql/upgrade/1.2-1.3.sql
===================================================================
--- trunk/sql/upgrade/1.2-1.3.sql	2007-03-08 07:07:59 UTC (rev 863)
+++ trunk/sql/upgrade/1.2-1.3.sql	2007-03-08 18:28:59 UTC (rev 864)
@@ -1,6 +1,8 @@
 BEGIN;
 
-CREATE TABLE location ( 
+ALTER TABLE employee RENAME TO employees;
+
+CREATE TABLE locations ( 
 	id SERIAL PRIMARY KEY,
 	companyname text,
 	address1 text,
@@ -11,14 +13,16 @@
 	zipcode text
 );	
 
-CREATE SEQUENCE employee_id_seq;
-SELECT setval('employee_id_seq', (select max(id) + 1 FROM employee));
+CREATE SEQUENCE employees_id_seq;
+SELECT setval('employees_id_seq', (select max(id) + 1 FROM employees));
 
-ALTER TABLE employee ADD COLUMN locations_id integer;
-ALTER TABLE employee ADD FOREIGN KEY (locations_id) REFERENCES location(id);
-ALTER TABLE employee ALTER COLUMN id DROP DEFAULT;
-ALTER TABLE employee ALTER COLUMN id SET DEFAULT  nextval('employee_id_seq');
+ALTER TABLE employees ADD COLUMN locations_id integer;
+ALTER TABLE employees ADD FOREIGN KEY (locations_id) REFERENCES locations(id);
+ALTER TABLE employees ALTER COLUMN id DROP DEFAULT;
+ALTER TABLE employees ALTER COLUMN id SET DEFAULT  nextval('employee_id_seq');
 
+DROP RULE employee_id_track_i ON employees; -- no longer needed
+
 CREATE OR REPLACE FUNCTION location_save
 (in_id int, in_companyname text, in_address1 text, in_address2 text, 
 	in_city text, in_state text, in_zipcode text, in_country text) 
@@ -27,7 +31,7 @@
 DECLARE
 	location_id integer;
 BEGIN
-	UPDATE location
+	UPDATE locations
 	SET companyname = in_companyname,
 		address1 = in_address1,
 		address2 = in_address2,
@@ -61,7 +65,7 @@
 AS
 $$
 BEGIN
-	UPDATE employee
+	UPDATE employees
 	SET location_id = in_location_id,
 		employeenumber = in_employeenumber,
 		name = in_name,
@@ -89,7 +93,7 @@
 	IF FOUND THEN
 		return in_id;
 	END IF;
-	INSERT INTO employee
+	INSERT INTO employees
 	(location_id, employeenumber, name, address1, address2, 
 		city, state, zipcode, country, workphone, homephone,
 		startdate, enddate, notes, role, sales, email, ssn,
@@ -107,25 +111,25 @@
 
 CREATE OR REPLACE FUNCTION employee_get
 (in_id integer)
-returns employee as
+returns employees as
 $$
 DECLARE
-	emp employee%ROWTYPE;
+	emp employees%ROWTYPE;
 BEGIN
-	SELECT * INTO emp FROM employee WHERE id = in_id;
+	SELECT * INTO emp FROM employees WHERE id = in_id;
 	RETURN emp;
 END;
 $$ language plpgsql;
 
 CREATE OR REPLACE FUNCTION employee_list_managers
 (in_id integer)
-RETURNS SETOF employee as
+RETURNS SETOF employees as
 $$
 DECLARE
-	emp employee%ROWTYPE;
+	emp employees%ROWTYPE;
 BEGIN
 	FOR emp IN 
-		SELECT * FROM employee 
+		SELECT * FROM employees 
 		WHERE sales = '1' AND role='manager'
 			AND id <> coalesce(in_id, -1)
 		ORDER BY name
@@ -139,7 +143,7 @@
 (in_id integer) returns void as
 $$
 BEGIN
-	DELETE FROM employee WHERE id = in_id;
+	DELETE FROM employees WHERE id = in_id;
 	RETURN;
 END;
 $$ language plpgsql;
@@ -147,7 +151,7 @@
 -- as long as we need the datatype, might as well get some other use out of it!
 CREATE OR REPLACE VIEW employee_search AS
 SELECT e.*, m.name AS manager 
-FROM employee e JOIN employee m ON (e.managerid = m.id);
+FROM employees e JOIN employees m ON (e.managerid = m.id);
 
 CREATE OR REPLACE FUNCTION employee_search
 (in_startdatefrom date, in_startdateto date, in_name varchar, in_notes text,


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.