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

SF.net SVN: ledger-smb:[4907] trunk/sql



Revision: 4907
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4907&view=rev
Author:   einhverfr
Date:     2012-06-18 06:52:13 +0000 (Mon, 18 Jun 2012)
Log Message:
-----------
Triggers now replicate approved status to transactions table too so we can just check there instead of lots of UNION ALLs between ar, ap, and gl.  Also corrected per-contact class roles

Modified Paths:
--------------
    trunk/sql/Pg-database.sql
    trunk/sql/modules/Roles.sql

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2012-06-18 06:07:47 UTC (rev 4906)
+++ trunk/sql/Pg-database.sql	2012-06-18 06:52:13 UTC (rev 4907)
@@ -588,6 +588,7 @@
   id int PRIMARY KEY,
   table_name text,
   locked_by int references "session" (session_id) ON DELETE SET NULL,
+  approved bool,
   approved_by int references entity (id),
   approved_at timestamp
 );
@@ -2249,13 +2250,15 @@
 $$
 BEGIN
 	IF tg_op = 'INSERT' THEN
-		INSERT INTO transactions (id, table_name) 
-		VALUES (new.id, TG_RELNAME);
+		INSERT INTO transactions (id, table_name, approved) 
+		VALUES (new.id, TG_RELNAME, new.approved);
 	ELSEIF tg_op = 'UPDATE' THEN
-		IF new.id = old.id THEN
+		IF new.id = old.id AND new.approved = old.approved THEN
 			return new;
 		ELSE
-			UPDATE transactions SET id = new.id WHERE id = old.id;
+			UPDATE transactions SET id = new.id, 
+                                                approved = new.approved
+                         WHERE id = old.id;
 		END IF;
 	ELSE 
 		DELETE FROM transactions WHERE id = old.id;

Modified: trunk/sql/modules/Roles.sql
===================================================================
--- trunk/sql/modules/Roles.sql	2012-06-18 06:07:47 UTC (rev 4906)
+++ trunk/sql/modules/Roles.sql	2012-06-18 06:52:13 UTC (rev 4907)
@@ -1787,7 +1787,7 @@
 
 -- PERMISSIONS ENFORCEMENT PER ENTITY CLASS
 
-CREATE FUNCTION tg_enforce_perms_eclass () RETURNS TRIGGER AS 
+CREATE OR REPLACE FUNCTION tg_enforce_perms_eclass () RETURNS TRIGGER AS 
 $$
 DECLARE
    r_eclass entity_class;
@@ -1803,7 +1803,7 @@
                                 || 'contact_class_' || lower(regexp_replace(
                                                         r_eclass.class, 
                                                         ' ', 
-                                                        '_')))
+                                                        '_')), 'USAGE')
    THEN
       RETURN NEW;
    ELSE

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