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

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



Revision: 2824
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2824&view=rev
Author:   einhverfr
Date:     2009-12-14 18:19:49 +0000 (Mon, 14 Dec 2009)

Log Message:
-----------
Applying Lacey's fixes

Modified Paths:
--------------
    trunk/LedgerSMB/Form.pm
    trunk/LedgerSMB/GL.pm
    trunk/install-mycompany.sh
    trunk/sql/modules/Company.sql
    trunk/sql/modules/Customer.sql
    trunk/sql/modules/Entity.sql
    trunk/sql/modules/Person.sql
    trunk/sql/modules/Roles.sql
    trunk/sql/modules/Vendor.sql
    trunk/sql/modules/install.sql

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2009-12-13 19:55:09 UTC (rev 2823)
+++ trunk/LedgerSMB/Form.pm	2009-12-14 18:19:49 UTC (rev 2824)
@@ -899,7 +899,7 @@
     my $query = qq|
 		SELECT employeenumber FROM employee 
 		 WHERE entity_id = 
-			(select entity_id from users where login = ?)|;
+			(SELECT entity_id FROM users WHERE username = ?)|;
     my $sth = $dbh->prepare($query);
     $sth->execute( $self->{login} ) || $self->dberror($query);
 

Modified: trunk/LedgerSMB/GL.pm
===================================================================
--- trunk/LedgerSMB/GL.pm	2009-12-13 19:55:09 UTC (rev 2823)
+++ trunk/LedgerSMB/GL.pm	2009-12-14 18:19:49 UTC (rev 2824)
@@ -425,7 +425,9 @@
         source      => 7,
         accno       => 9,
         department  => 15,
-        memo        => 16
+        memo        => 16,
+        trans_id    => 18,
+        chart_id    => 19
     );
 
     my @a = ( id, transdate, reference, source, description, accno );
@@ -450,7 +452,7 @@
 						  g.description, ac.transdate, ac.source,
 						  ac.amount, c.accno, c.gifi_accno, g.notes, c.link,
 						  '' AS till, ac.cleared, d.description AS department,
-						  ac.memo, c.description AS accname
+						  ac.memo, c.description AS accname, ac.trans_id, ac.chart_id
 					 FROM gl AS g
 					 JOIN acc_trans ac ON (g.id = ac.trans_id)
 					 JOIN chart c ON (ac.chart_id = c.id)
@@ -468,7 +470,7 @@
 						  e.name, ac.transdate, ac.source,
 						  ac.amount, c.accno, c.gifi_accno, a.notes, c.link,
 						  a.till, ac.cleared, d.description AS department,
-						  ac.memo, c.description AS accname
+						  ac.memo, c.description AS accname, ac.trans_id, ac.chart_id
 					 FROM ar a
 					 JOIN acc_trans ac ON (a.id = ac.trans_id)
 					 JOIN chart c ON (ac.chart_id = c.id)
@@ -488,7 +490,7 @@
 						  e.name, ac.transdate, ac.source,
 						  ac.amount, c.accno, c.gifi_accno, a.notes, c.link,
 						  a.till, ac.cleared, d.description AS department,
-						  ac.memo, c.description AS accname
+						  ac.memo, c.description AS accname, ac.trans_id, ac.chart_id
 					 FROM ap a
 					 JOIN acc_trans ac ON (a.id = ac.trans_id)
 					 JOIN chart c ON (ac.chart_id = c.id)

Modified: trunk/install-mycompany.sh
===================================================================
--- trunk/install-mycompany.sh	2009-12-13 19:55:09 UTC (rev 2823)
+++ trunk/install-mycompany.sh	2009-12-14 18:19:49 UTC (rev 2824)
@@ -2,30 +2,40 @@
 
 CWD=`pwd`
 
+MYCOMPANY='cmd'
+MYUSER='lacey_cmd'
+PGVERSION=8.4
+
 # The following path can vary per distribution
-#CONTRIB=/usr/share/postgresql-8.3/contrib
-CONTRIB=/usr/local/pgsql/share/contrib
+# Debian/Ubuntu
+CONTRIB=/usr/share/postgresql/8.3/contrib/
+# Compiled from source.
+#CONTRIB=/usr/local/pgsql/share/contrib
 
-echo 'This script will create a mycompany dataset per INSTALL. Ctrl-C to cancel.'
+echo 'This script will create a $MYCOMPANY dataset per INSTALL. Ctrl-C to cancel.'
 
-dropdb -i -U postgres mycompany ; 
-for role in `psql -U postgres -t -c "SELECT rolname FROM pg_roles WHERE rolname LIKE 'lsmb_mycompany%';"`; do dropuser -U postgres $role; done
-dropuser -U postgres myuser ; 
-createdb -U postgres -O ledgersmb mycompany ; 
-createlang -U postgres plpgsql -d mycompany ; 
-psql -U postgres -d mycompany -f $CONTRIB/tsearch2.sql
-psql -U postgres -d mycompany -f $CONTRIB/tablefunc.sql
-psql -U postgres -d mycompany -f $CONTRIB/pg_trgm.sql
-psql -U postgres -d mycompany -f $CWD/sql/Pg-database.sql ;
-psql -U postgres -d mycompany -f $CWD/sql/modules/install.sql ; 
-psql -U postgres -d mycompany -f $CWD/sql/coa/us/chart/General.sql
-sed -e "s/<?lsmb dbname ?>/mycompany/g" $CWD/sql/modules/Roles.sql > $CWD/mycompany_roles.sql ; 
-psql -U postgres -d mycompany -f $CWD/mycompany_roles.sql ; 
-createuser --no-superuser --createdb --no-createrole -U postgres --pwprompt --encrypted myuser ; 
-psql -U postgres -d mycompany -t -c "INSERT INTO entity (name, entity_class, created, control_code) VALUES ('myuser', 3, NOW(), '123') RETURNING name, entity_class, created;" ; 
-psql -U postgres -d mycompany -t -c "INSERT INTO person (entity_id, first_name, last_name, created) VALUES (2, 'Firstname', 'Lastname', NOW()) RETURNING entity_id, first_name, last_name, created;" ; 
-psql -U postgres -d mycompany -t -c "INSERT INTO entity_employee (person_id, entity_id, startdate, role) VALUES (1, 2, NOW(), 'myuser') RETURNING person_id, entity_id, startdate, role;" ; 
-psql -U postgres -d mycompany -t -c "INSERT INTO users (username, entity_id) VALUES ('myuser', 2) RETURNING username, entity_id;" ; 
-psql -U postgres -d mycompany -t -c "INSERT INTO user_preference (id) VALUES (1) RETURNING id;" ; 
-psql -U postgres -d mycompany -t -c "CREATE OR REPLACE FUNCTION grant_all_roles(in_login varchar) RETURNS INT as \$\$ DECLARE role_info RECORD; BEGIN FOR role_info IN select * from pg_roles WHERE rolname LIKE 'lsmb%' LOOP EXECUTE 'GRANT ' || role_info.rolname || ' TO ' || in_login; END LOOP; RETURN 1; END; \$\$ language plpgsql;" ; 
-psql -U postgres -d mycompany -t -c "SELECT grant_all_roles('myuser');" ; 
+dropdb -i -U postgres $MYCOMPANY 
+for role in `psql -U postgres -t -c "SELECT rolname FROM pg_roles WHERE rolname LIKE 'lsmb_${MYCOMPANY}%';"`; do dropuser -U postgres $role; done
+dropuser -U postgres $MYUSER 
+dropuser -U postgres ledgersmb 
+createuser --no-superuser --createdb --no-createrole -U postgres --pwprompt --encrypted ledgersmb 
+createdb -U postgres -O ledgersmb $MYCOMPANY  
+createlang -U postgres plpgsql -d $MYCOMPANY 
+if [[ "$PGVERSION" == "8.0" || "$PGVERSION" == "8.1" || "$PGVERSION" == "8.2" ]]; then
+   psql -U postgres -d $MYCOMPANY -f $CONTRIB/tsearch2.sql
+fi
+psql -U postgres -d $MYCOMPANY -f $CONTRIB/tablefunc.sql
+psql -U postgres -d $MYCOMPANY -f $CONTRIB/pg_trgm.sql
+psql -U postgres -d $MYCOMPANY -f $CWD/sql/Pg-database.sql
+psql -U postgres -d $MYCOMPANY -f $CWD/sql/modules/install.sql 
+psql -U postgres -d $MYCOMPANY -f $CWD/sql/coa/us/chart/General.sql
+sed  -e "s/<?lsmb dbname ?>/$MYCOMPANY/g" $CWD/sql/modules/Roles.sql > $CWD/${MYCOMPANY}_roles.sql 
+psql -U postgres -d $MYCOMPANY -f $CWD/${MYCOMPANY}_roles.sql  
+createuser --no-superuser --createdb --no-createrole -U postgres --pwprompt --encrypted $MYUSER 
+psql -U postgres -d $MYCOMPANY --tuples-only -t -c "INSERT INTO entity (name, entity_class, created, control_code, country_id) VALUES ('$MYUSER', 3, NOW(), '123', 238) RETURNING id;"
+psql -U postgres -d $MYCOMPANY -t -c "INSERT INTO person (entity_id, first_name, last_name, created) VALUES (1, 'Firstname', 'Lastname', NOW()) RETURNING entity_id, first_name, last_name, created;" 
+psql -U postgres -d $MYCOMPANY -t -c "INSERT INTO entity_employee (entity_id, startdate, role) VALUES (1, NOW(), '$MYUSER') RETURNING entity_id, startdate, role;" 
+psql -U postgres -d $MYCOMPANY -t -c "INSERT INTO users (username, entity_id) VALUES ('$MYUSER', 1) RETURNING username, entity_id;" 
+psql -U postgres -d $MYCOMPANY -t -c "INSERT INTO user_preference (id) VALUES (1) RETURNING id;" 
+psql -U postgres -d $MYCOMPANY -t -c "CREATE OR REPLACE FUNCTION grant_all_roles(in_login varchar) RETURNS INT as \$\$ DECLARE role_info RECORD; BEGIN FOR role_info IN select * from pg_roles WHERE rolname LIKE 'lsmb%' LOOP EXECUTE 'GRANT ' || role_info.rolname || ' TO ' || in_login; END LOOP; RETURN 1; END; \$\$ language plpgsql;"
+psql -U postgres -d $MYCOMPANY -t -c "SELECT grant_all_roles('$MYUSER');" 

Modified: trunk/sql/modules/Company.sql
===================================================================
--- trunk/sql/modules/Company.sql	2009-12-13 19:55:09 UTC (rev 2823)
+++ trunk/sql/modules/Company.sql	2009-12-14 18:19:49 UTC (rev 2824)
@@ -1,5 +1,3 @@
--- BEGIN;
-
 CREATE TYPE company_search_result AS (
 	entity_id int,
 	entity_control_code text,
@@ -780,4 +778,3 @@
 END;
 $$ LANGUAGE PLPGSQL;
 
--- COMMIT;

Modified: trunk/sql/modules/Customer.sql
===================================================================
--- trunk/sql/modules/Customer.sql	2009-12-13 19:55:09 UTC (rev 2823)
+++ trunk/sql/modules/Customer.sql	2009-12-14 18:19:49 UTC (rev 2824)
@@ -1,6 +1,3 @@
-BEGIN;
-
-
 CREATE OR REPLACE FUNCTION customer_location_save (
     in_entity_id int,
     in_location_class int, in_line_one text, in_line_two text, 
@@ -51,5 +48,3 @@
     
 $$ language 'plpgsql'; 
 */
-
-COMMIT;

Modified: trunk/sql/modules/Entity.sql
===================================================================
--- trunk/sql/modules/Entity.sql	2009-12-13 19:55:09 UTC (rev 2823)
+++ trunk/sql/modules/Entity.sql	2009-12-14 18:19:49 UTC (rev 2824)
@@ -1,5 +1,4 @@
 --
-BEGIN;
 
 CREATE OR REPLACE FUNCTION entity_save(
     in_entity_id int, in_name text, in_entity_class INT
@@ -69,5 +68,3 @@
 $$ language plpgsql;
 
 
-
-commit;

Modified: trunk/sql/modules/Person.sql
===================================================================
--- trunk/sql/modules/Person.sql	2009-12-13 19:55:09 UTC (rev 2823)
+++ trunk/sql/modules/Person.sql	2009-12-14 18:19:49 UTC (rev 2824)
@@ -1,5 +1,3 @@
-begin;
-
 CREATE OR REPLACE FUNCTION person__get_my_entity_id() RETURNS INT AS
 $$
 	SELECT entity_id from users where username = SESSION_USER;
@@ -259,5 +257,3 @@
     WHERE p.id = $1;
 
 $$ language sql;
-
-commit;

Modified: trunk/sql/modules/Roles.sql
===================================================================
--- trunk/sql/modules/Roles.sql	2009-12-13 19:55:09 UTC (rev 2823)
+++ trunk/sql/modules/Roles.sql	2009-12-14 18:19:49 UTC (rev 2824)
@@ -1083,17 +1083,12 @@
 GRANT INSERT ON account TO "lsmb_<?lsmb dbname ?>__account_create";
 GRANT ALL ON account_id_seq TO "lsmb_<?lsmb dbname ?>__account_create";
 GRANT INSERT ON account_heading TO "lsmb_<?lsmb dbname ?>__account_create";
-GRANT ALL ON acount_heading_id_seq TO "lsmb_<?lsmb dbname ?>__account_create";
+GRANT ALL ON account_heading_id_seq TO "lsmb_<?lsmb dbname ?>__account_create";
 GRANT INSERT ON account_link TO "lsmb_<?lsmb dbname ?>__account_create";
-GRANT ALL ON account_link_id_seq TO "lsmb_<?lsmb dbname ?>__account_create";
+-- account_link no longer appears to have a sequence and references account(id)
+--GRANT ALL ON account_link_id_seq TO "lsmb_<?lsmb dbname ?>__account_create";
 
 INSERT INTO menu_acl (node_id, acl_type, role_name)
-GRANT INSERT ON account_heading TO "lsmb_<?lsmb dbname ?>__account_create";
-GRANT ALL ON acount_heading_id_seq TO "lsmb_<?lsmb dbname ?>__account_create";
-GRANT INSERT ON account_link TO "lsmb_<?lsmb dbname ?>__account_create";
-GRANT ALL ON account_link_id_seq TO "lsmb_<?lsmb dbname ?>__account_create";
-
-INSERT INTO menu_acl (node_id, acl_type, role_name)
 values (128, 'allow', 'lsmb_<?lsmb dbname ?>__account_create');
 INSERT INTO menu_acl (node_id, acl_type, role_name)
 values (136, 'allow', 'lsmb_<?lsmb dbname ?>__account_create');

Modified: trunk/sql/modules/Vendor.sql
===================================================================
--- trunk/sql/modules/Vendor.sql	2009-12-13 19:55:09 UTC (rev 2823)
+++ trunk/sql/modules/Vendor.sql	2009-12-14 18:19:49 UTC (rev 2824)
@@ -1,4 +1,3 @@
-BEGIN;
 
 -- TODO:  Move indexes to Pg-database
 /*  Disabling until we can do some more refactoring here.
@@ -41,4 +40,3 @@
     
 $$ language 'plpgsql';
 */
-COMMIT;

Modified: trunk/sql/modules/install.sql
===================================================================
--- trunk/sql/modules/install.sql	2009-12-13 19:55:09 UTC (rev 2823)
+++ trunk/sql/modules/install.sql	2009-12-14 18:19:49 UTC (rev 2824)
@@ -1,6 +1,5 @@
 BEGIN;
 \i sql/modules/Drafts.sql
-\i sql/modules/Chart.sql
 \i sql/modules/Account.sql
 \i sql/modules/Session.sql
 \i sql/modules/Business_type.sql
@@ -17,8 +16,7 @@
 \i sql/modules/Report.sql
 \i sql/modules/Voucher.sql
 \i sql/modules/Reconciliation.sql
-\i sql/modules/admin.sql -- Adds the new user functionality.
+-- Adds the new user functionality. 
+\i sql/modules/admin.sql 
 \i sql/modules/chart.sql
-
-
 COMMIT;


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