src-db/database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml
author Antonio Moreno <antonio.moreno@openbravo.com>
Wed, 23 Apr 2008 17:34:12 +0000
changeset 756 ae11e4610537
parent 735 database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml@daced7e311c9
child 1605 8a0fe0193bef
permissions -rw-r--r--
Moved database folder to src-db folder
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
gorka@401
     9
adrian@94
    10
    /*************************************************************************
adrian@94
    11
    * The contents of this file are subject to the Openbravo  Public  License
adrian@94
    12
    * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
adrian@94
    13
    * Version 1.1  with a permitted attribution clause; you may not  use this
adrian@94
    14
    * file except in compliance with the License. You  may  obtain  a copy of
adrian@94
    15
    * the License at http://www.openbravo.com/legal/license.html
adrian@94
    16
    * Software distributed under the License  is  distributed  on  an "AS IS"
adrian@94
    17
    * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
adrian@94
    18
    * License for the specific  language  governing  rights  and  limitations
adrian@94
    19
    * under the License.
adrian@94
    20
    * The Original Code is Openbravo ERP.
adrian@94
    21
    * The Initial Developer of the Original Code is Openbravo SL
adrian@94
    22
    * All portions are Copyright (C) 2001-2006 Openbravo SL
adrian@94
    23
    * All Rights Reserved.
adrian@94
    24
    * Contributor(s):  ______________________________________.
adrian@94
    25
    ************************************************************************/
gorkaion@280
    26
    v_DateNull DATE := TO_DATE('01-01-1900', 'DD-MM-YYYY');
carlos@31
    27
    BEGIN
adrian@94
    28
    IF UPDATING
adrian@94
    29
    THEN  IF(:old.Processed='Y'
gorkaion@280
    30
    AND ((COALESCE(:old.DATEDOC, v_DateNull) <> COALESCE(:new.DATEDOC, v_DateNull))
gorkaion@239
    31
    OR(COALESCE(:old.C_PERIOD_ID, 0) <> COALESCE(:new.C_PERIOD_ID, 0))
gorkaion@239
    32
    OR(COALESCE(:old.CURRENCYRATE, 0) <> COALESCE(:new.CURRENCYRATE, 0))
gorkaion@239
    33
    OR(COALESCE(:old.CURRENCYRATETYPE, '.') <> COALESCE(:new.CURRENCYRATETYPE, '.'))
gorka@401
    34
    OR(COALESCE(:old.CONTROLAMT, 0) <> COALESCE(:new.CONTROLAMT, 0))
gorka@401
    35
    OR(COALESCE(:old.AD_ORG_ID, 0) <> COALESCE(:new.AD_ORG_ID, 0))
gorka@401
    36
    OR(COALESCE(:old.AD_CLIENT_ID, 0) <> COALESCE(:new.AD_CLIENT_ID, 0))))
adrian@94
    37
    THEN  RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    38
    END IF;
gorkaion@280
    39
  IF(:old.Posted='Y' AND ((COALESCE(:old.DATEACCT, v_DateNull) <> COALESCE(:new.DATEACCT, v_DateNull)) 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
    40
   RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    41
  END IF;
adrian@94
    42
 END IF;
adrian@94
    43
 IF(DELETING) THEN
adrian@94
    44
  IF(:old.Processed='Y') THEN
adrian@94
    45
    RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    46
  END IF;
adrian@94
    47
 END IF;
adrian@94
    48
 IF(INSERTING) THEN
adrian@94
    49
  IF(:NEW.Processed='Y') THEN
adrian@94
    50
    RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    51
  END IF;
adrian@94
    52
 END IF;
antonio@735
    53
END GL_JOURNAL_CHK_RESTRICT_TRG
gorkaion@239
    54
]]></body>
adrian@94
    55
    </trigger>
adrian@94
    56
  </database>