database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml
author Gorka Ion Damián <gorkaion.damian@openbravo.com>
Wed, 02 Jan 2008 17:22:18 +0000
changeset 280 e5336cf03dbe
parent 239 a30acae847e1
child 401 0ae635a8fe7f
permissions -rw-r--r--
BugFix[1862189] Fixed default dates in database model objects to include the mask in the to_date function to avoid problems with NLS_DATE_FORMAT. All dates have been changed to January 1, 1900 for the lower case and December 31, 9999 for the higher case when comparations are needed.
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
    ************************************************************************/
gorkaion@280
    25
    v_DateNull DATE := TO_DATE('01-01-1900', 'DD-MM-YYYY');
carlos@31
    26
    BEGIN
adrian@94
    27
    IF UPDATING
adrian@94
    28
    THEN  IF(:old.Processed='Y'
gorkaion@280
    29
    AND ((COALESCE(:old.DATEDOC, v_DateNull) <> COALESCE(:new.DATEDOC, v_DateNull))
gorkaion@239
    30
    OR(COALESCE(:old.C_PERIOD_ID, 0) <> COALESCE(:new.C_PERIOD_ID, 0))
gorkaion@239
    31
    OR(COALESCE(:old.CURRENCYRATE, 0) <> COALESCE(:new.CURRENCYRATE, 0))
gorkaion@239
    32
    OR(COALESCE(:old.CURRENCYRATETYPE, '.') <> COALESCE(:new.CURRENCYRATETYPE, '.'))
gorkaion@239
    33
    OR(COALESCE(:old.CONTROLAMT, 0) <> COALESCE(:new.CONTROLAMT, 0))))
adrian@94
    34
    THEN  RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    35
    END IF;
gorkaion@280
    36
  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
    37
   RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    38
  END IF;
adrian@94
    39
 END IF;
adrian@94
    40
 IF(DELETING) THEN
adrian@94
    41
  IF(:old.Processed='Y') THEN
adrian@94
    42
    RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    43
  END IF;
adrian@94
    44
 END IF;
adrian@94
    45
 IF(INSERTING) THEN
adrian@94
    46
  IF(:NEW.Processed='Y') THEN
adrian@94
    47
    RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
adrian@94
    48
  END IF;
adrian@94
    49
 END IF;
adrian@94
    50
END GL_Journal_Chk_Restrict_Trg
adrian@94
    51
adrian@170
    52
gorkaion@239
    53
gorkaion@239
    54
]]></body>
adrian@94
    55
    </trigger>
adrian@94
    56
  </database>