src-db/database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml
changeset 26421 908de9299675
parent 21737 fcb87e990fcd
child 26422 17cd117fb31b
--- a/src-db/database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml	Fri Mar 27 15:57:12 2015 -0500
+++ b/src-db/database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml	Mon Mar 23 14:11:56 2015 -0500
@@ -19,12 +19,12 @@
     * under the License.
     * The Original Code is Openbravo ERP.
     * The Initial Developer of the Original Code is Openbravo SLU
-    * All portions are Copyright (C) 2001-2012 Openbravo SLU
+    * All portions are Copyright (C) 2001-2015 Openbravo SLU
     * All Rights Reserved.
     * Contributor(s):  ______________________________________.
     ************************************************************************/
     v_DateNull DATE := TO_DATE('01-01-1900', 'DD-MM-YYYY');
-        
+    v_ValidPeriod NUMBER;    
 BEGIN
     
     IF AD_isTriggerEnabled()='N' THEN RETURN;
@@ -59,6 +59,13 @@
         )) 
         THEN RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
       END IF;    
+
+      
+      IF (:old.DateAcct <> :new.DateAcct and 
+        c_chk_open_period(:new.AD_ORG_ID, :new.DATEACCT, null, :new.C_DOCTYPE_ID) <> 1) THEN 
+        RAISE_APPLICATION_ERROR(-20000, '@PeriodNotValid@');
+      END IF;
+
     END IF;
     IF(DELETING) THEN
       IF(:old.Processed='Y') THEN
@@ -69,6 +76,9 @@
       IF(:NEW.Processed='Y') THEN
         RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
       END IF;
+      IF (c_chk_open_period(:new.AD_ORG_ID, :new.DATEACCT, null, :new.C_DOCTYPE_ID) <> 1) THEN 
+        RAISE_APPLICATION_ERROR(-20000, '@PeriodNotValid@');
+      END IF;
     END IF;
     END GL_JOURNAL_CHK_RESTRICT_TRG
 ]]></body>