database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml
author Adrián Romero <adrian.romero@openbravo.com>
Tue, 20 Nov 2007 16:27:14 +0000
changeset 94 4e7ba7b8a4ad
parent 31 31008df6a637
child 132 33c5ca45fcff
permissions -rw-r--r--
fix: Changed check constraint names and foreign key names to fit in to
30 characteres.
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER GL_JOURNAL_CHK_RESTRICT_TRG">
adrian@94
     3
    <trigger name="GL_JOURNAL_CHK_RESTRICT_TRG" table="GL_JOURNAL" fires="before" insert="true" update="true" delete="true" foreach="row">
adrian@94
     4
      <body>
adrian@94
     5
adrian@94
     6
adrian@94
     7
    /*************************************************************************
adrian@94
     8
    * The contents of this file are subject to the Openbravo  Public  License
adrian@94
     9
    * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
adrian@94
    10
    * Version 1.1  with a permitted attribution clause; you may not  use this
adrian@94
    11
    * file except in compliance with the License. You  may  obtain  a copy of
adrian@94
    12
    * the License at http://www.openbravo.com/legal/license.html
adrian@94
    13
    * Software distributed under the License  is  distributed  on  an "AS IS"
adrian@94
    14
    * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
adrian@94
    15
    * License for the specific  language  governing  rights  and  limitations
adrian@94
    16
    * under the License.
adrian@94
    17
    * The Original Code is Openbravo ERP.
adrian@94
    18
    * The Initial Developer of the Original Code is Openbravo SL
adrian@94
    19
    * All portions are Copyright (C) 2001-2006 Openbravo SL
adrian@94
    20
    * All Rights Reserved.
adrian@94
    21
    * Contributor(s):  ______________________________________.
adrian@94
    22
    ************************************************************************/
carlos@31
    23
    BEGIN
adrian@94
    24
    IF UPDATING
adrian@94
    25
    THEN  IF(:old.Processed='Y'
adrian@94
    26
    AND ((COALESCE(:old.DATEDOC, '01-01-1386') &lt;&gt; COALESCE(:new.DATEDOC, '01-01-1386'))
adrian@94
    27
    OR(COALESCE(:old.C_PERIOD_ID, 0) &lt;&gt; COALESCE(:new.C_PERIOD_ID, 0))
adrian@94
    28
    OR(COALESCE(:old.CURRENCYRATE, 0) &lt;&gt; COALESCE(:new.CURRENCYRATE, 0))
adrian@94
    29
    OR(COALESCE(:old.CURRENCYRATETYPE, '.') &lt;&gt; COALESCE(:new.CURRENCYRATETYPE, '.'))
adrian@94
    30
    OR(COALESCE(:old.CONTROLAMT, 0) &lt;&gt; COALESCE(:new.CONTROLAMT, 0))))
adrian@94
    31
    THEN  RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    32
    END IF;
adrian@94
    33
  IF(:old.Posted='Y' AND ((COALESCE(:old.DATEACCT, '01-01-1386') &lt;&gt; COALESCE(:new.DATEACCT, '01-01-1386')) OR(COALESCE(:old.C_ACCTSCHEMA_ID, 0) &lt;&gt; COALESCE(:new.C_ACCTSCHEMA_ID, 0)) OR(COALESCE(:old.GL_CATEGORY_ID, 0) &lt;&gt; COALESCE(:new.GL_CATEGORY_ID, 0)) OR(COALESCE(:old.POSTINGTYPE, '.') &lt;&gt; COALESCE(:new.POSTINGTYPE, '.')))) THEN
adrian@94
    34
   RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    35
  END IF;
adrian@94
    36
 END IF;
adrian@94
    37
 IF(DELETING) THEN
adrian@94
    38
  IF(:old.Processed='Y') THEN
adrian@94
    39
    RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    40
  END IF;
adrian@94
    41
 END IF;
adrian@94
    42
 IF(INSERTING) THEN
adrian@94
    43
  IF(:NEW.Processed='Y') THEN
adrian@94
    44
    RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    45
  END IF;
adrian@94
    46
 END IF;
adrian@94
    47
END GL_Journal_Chk_Restrict_Trg
adrian@94
    48
adrian@94
    49
</body>
adrian@94
    50
    </trigger>
adrian@94
    51
  </database>