database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml
author Gorka Ion Damián <gorkaion.damian@openbravo.com>
Fri, 14 Dec 2007 16:21:33 +0000
changeset 239 a30acae847e1
parent 170 4b5493776a7f
child 280 e5336cf03dbe
permissions -rw-r--r--
Added CDATA to views, functions and triggers.
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">
gorkaion@239
     4
      <body><![CDATA[
gorkaion@239
     5
adrian@170
     6
adrian@94
     7
adrian@94
     8
adrian@94
     9
    /*************************************************************************
adrian@94
    10
    * The contents of this file are subject to the Openbravo  Public  License
adrian@94
    11
    * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
adrian@94
    12
    * Version 1.1  with a permitted attribution clause; you may not  use this
adrian@94
    13
    * file except in compliance with the License. You  may  obtain  a copy of
adrian@94
    14
    * the License at http://www.openbravo.com/legal/license.html
adrian@94
    15
    * Software distributed under the License  is  distributed  on  an "AS IS"
adrian@94
    16
    * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
adrian@94
    17
    * License for the specific  language  governing  rights  and  limitations
adrian@94
    18
    * under the License.
adrian@94
    19
    * The Original Code is Openbravo ERP.
adrian@94
    20
    * The Initial Developer of the Original Code is Openbravo SL
adrian@94
    21
    * All portions are Copyright (C) 2001-2006 Openbravo SL
adrian@94
    22
    * All Rights Reserved.
adrian@94
    23
    * Contributor(s):  ______________________________________.
adrian@94
    24
    ************************************************************************/
carlos@31
    25
    BEGIN
adrian@94
    26
    IF UPDATING
adrian@94
    27
    THEN  IF(:old.Processed='Y'
gorkaion@239
    28
    AND ((COALESCE(:old.DATEDOC, '01-01-1386') <> COALESCE(:new.DATEDOC, '01-01-1386'))
gorkaion@239
    29
    OR(COALESCE(:old.C_PERIOD_ID, 0) <> COALESCE(:new.C_PERIOD_ID, 0))
gorkaion@239
    30
    OR(COALESCE(:old.CURRENCYRATE, 0) <> COALESCE(:new.CURRENCYRATE, 0))
gorkaion@239
    31
    OR(COALESCE(:old.CURRENCYRATETYPE, '.') <> COALESCE(:new.CURRENCYRATETYPE, '.'))
gorkaion@239
    32
    OR(COALESCE(:old.CONTROLAMT, 0) <> COALESCE(:new.CONTROLAMT, 0))))
adrian@94
    33
    THEN  RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    34
    END IF;
gorkaion@239
    35
  IF(:old.Posted='Y' AND ((COALESCE(:old.DATEACCT, '01-01-1386') <> COALESCE(:new.DATEACCT, '01-01-1386')) OR(COALESCE(:old.C_ACCTSCHEMA_ID, 0) <> COALESCE(:new.C_ACCTSCHEMA_ID, 0)) OR(COALESCE(:old.GL_CATEGORY_ID, 0) <> COALESCE(:new.GL_CATEGORY_ID, 0)) OR(COALESCE(:old.POSTINGTYPE, '.') <> COALESCE(:new.POSTINGTYPE, '.')))) THEN
adrian@94
    36
   RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    37
  END IF;
adrian@94
    38
 END IF;
adrian@94
    39
 IF(DELETING) THEN
adrian@94
    40
  IF(:old.Processed='Y') THEN
adrian@94
    41
    RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    42
  END IF;
adrian@94
    43
 END IF;
adrian@94
    44
 IF(INSERTING) THEN
adrian@94
    45
  IF(:NEW.Processed='Y') THEN
adrian@94
    46
    RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    47
  END IF;
adrian@94
    48
 END IF;
adrian@94
    49
END GL_Journal_Chk_Restrict_Trg
adrian@94
    50
adrian@170
    51
gorkaion@239
    52
gorkaion@239
    53
]]></body>
adrian@94
    54
    </trigger>
adrian@94
    55
  </database>