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

SF.net SVN: ledger-smb:[6127] branches/1.3



Revision: 6127
          http://sourceforge.net/p/ledger-smb/code/6127
Author:   einhverfr
Date:     2013-10-14 07:45:32 +0000 (Mon, 14 Oct 2013)
Log Message:
-----------
Merging in sql trigger fix from trunk

Modified Paths:
--------------
    branches/1.3/Changelog
    branches/1.3/sql/Pg-database.sql
    branches/1.3/sql/modules/Fixes.sql

Modified: branches/1.3/Changelog
===================================================================
--- branches/1.3/Changelog	2013-10-14 07:35:52 UTC (rev 6126)
+++ branches/1.3/Changelog	2013-10-14 07:45:32 UTC (rev 6127)
@@ -41,6 +41,7 @@
 * Fixed trouble emailing recurring transactions (873, Erik H)
 * Fixed saving company saving incorrectly to DB (886, John L)
 * Can now search for batches/drafts without specifying a class (Erik H)
+* Added trigger to prevent transactions in closed periods (Chris T)
 
 Chris T is Chris Travers
 Erik H is Erik Huelsmann

Modified: branches/1.3/sql/Pg-database.sql
===================================================================
--- branches/1.3/sql/Pg-database.sql	2013-10-14 07:35:52 UTC (rev 6126)
+++ branches/1.3/sql/Pg-database.sql	2013-10-14 07:45:32 UTC (rev 6127)
@@ -1139,6 +1139,10 @@
 for payments.$$;
 
 CREATE INDEX acc_trans_voucher_id_idx ON acc_trans(voucher_id);
+
+-- preventing closed transactions
+
+
 --
 CREATE TABLE parts (
   id serial PRIMARY KEY,
@@ -1976,7 +1980,32 @@
 $$ This provides centralized support for insertions into audittrail.
 $$;
 
-CREATE TRIGGER gl_audit_trail AFTER insert or update or delete ON gl
+CREATE FUNCTION prevent_closed_transactions() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+DECLARE t_end_date date;
+BEGIN
+SELECT max(end_date) into t_end_date FROM account_checkpoint;
+IF new.transdate <= t_end_date THEN
+    RAISE EXCEPTION 'Transaction entered into closed period.  Transdate: %',
+                   new.transdate;
+END IF;
+RETURN new;
+END;
+$$;
+
+CREATE TRIGGER acc_trans_prevent_closed BEFORE INSERT ON acc_trans 
+FOR EACH ROW EXECUTE PROCEDURE prevent_closed_transactions();
+CREATE TRIGGER ap_prevent_closed BEFORE INSERT ON ap 
+FOR EACH ROW EXECUTE PROCEDURE prevent_closed_transactions();
+CREATE TRIGGER ar_prevent_closed BEFORE INSERT ON ar 
+FOR EACH ROW EXECUTE PROCEDURE prevent_closed_transactions();
+CREATE TRIGGER gl_prevent_closed BEFORE INSERT ON gl 
+FOR EACH ROW EXECUTE PROCEDURE prevent_closed_transactions();
+
+
+
+CREATE TRIGGER gl_audit_trail AFTER INSERT OR UPDATE OR DELETE ON gl
 FOR EACH ROW EXECUTE PROCEDURE gl_audit_trail_append();
 
 CREATE TRIGGER ar_audit_trail AFTER insert or update or delete ON ar

Modified: branches/1.3/sql/modules/Fixes.sql
===================================================================
--- branches/1.3/sql/modules/Fixes.sql	2013-10-14 07:35:52 UTC (rev 6126)
+++ branches/1.3/sql/modules/Fixes.sql	2013-10-14 07:45:32 UTC (rev 6127)
@@ -643,3 +643,32 @@
    SET value = 'sales_quotation' 
  where value = 'quotation' AND attribute='template';
 COMMIT;
+
+BEGIN;
+CREATE FUNCTION prevent_closed_transactions() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+DECLARE t_end_date date;
+BEGIN
+SELECT max(end_date) into t_end_date FROM account_checkpoint;
+IF new.transdate <= t_end_date THEN
+    RAISE EXCEPTION 'Transaction entered into closed period.  Transdate: %',
+                   new.transdate;
+END IF;
+RETURN new;
+END;
+$$;
+
+
+CREATE TRIGGER acc_trans_prevent_closed BEFORE INSERT ON acc_trans 
+FOR EACH ROW EXECUTE PROCEDURE prevent_closed_transactions();
+CREATE TRIGGER ap_prevent_closed BEFORE INSERT ON ap 
+FOR EACH ROW EXECUTE PROCEDURE prevent_closed_transactions();
+CREATE TRIGGER ar_prevent_closed BEFORE INSERT ON ar 
+FOR EACH ROW EXECUTE PROCEDURE prevent_closed_transactions();
+CREATE TRIGGER gl_prevent_closed BEFORE INSERT ON gl 
+FOR EACH ROW EXECUTE PROCEDURE prevent_closed_transactions();
+COMMIT;
+
+
+

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


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits