src-db/database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml
author Javier Etxarri <javier.echarri@openbravo.com>
Tue, 31 Dec 2013 17:08:12 +0100
changeset 21737 fcb87e990fcd
parent 21682 337545057885
child 26421 908de9299675
permissions -rw-r--r--
Fixes issue 25414, fixes issue 25415:
Wrong currency rate is applied when posting a GL Journal line
G/L Journal lines accounting amounts are not updated when changing the header rate
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
priya@9072
    12
    * Version  1.1  (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.
ggi@6701
    21
    * The Initial Developer of the Original Code is Openbravo SLU
naiara@16390
    22
    * All portions are Copyright (C) 2001-2012 Openbravo SLU
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');
asier@2084
    27
        
asier@2078
    28
BEGIN
asier@2084
    29
    
asier@2084
    30
    IF AD_isTriggerEnabled()='N' THEN RETURN;
asier@2078
    31
    END IF;
asier@2078
    32
asier@2078
    33
javier@21682
    34
    IF UPDATING THEN  
javier@21682
    35
      IF(:old.Processed='Y'
javier@21682
    36
        AND ((COALESCE(:old.DATEDOC, v_DateNull) <> COALESCE(:new.DATEDOC, v_DateNull))
javier@21682
    37
        OR(COALESCE(:old.C_PERIOD_ID, '0') <> COALESCE(:new.C_PERIOD_ID, '0'))
javier@21682
    38
        OR(COALESCE(:old.CURRENCYRATE, 0) <> COALESCE(:new.CURRENCYRATE, 0))
javier@21682
    39
        OR(COALESCE(:old.CURRENCYRATETYPE, '.') <> COALESCE(:new.CURRENCYRATETYPE, '.'))
javier@21682
    40
        OR(COALESCE(:old.CONTROLAMT, 0) <> COALESCE(:new.CONTROLAMT, 0))
javier@21682
    41
        OR(COALESCE(:old.AD_ORG_ID, '0') <> COALESCE(:new.AD_ORG_ID, '0'))
javier@21682
    42
        OR(COALESCE(:old.AD_CLIENT_ID, '0') <> COALESCE(:new.AD_CLIENT_ID, '0'))))
javier@21682
    43
        THEN  RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
javier@21682
    44
      END IF;
javier@21682
    45
    
javier@21682
    46
      IF(:old.Posted='Y' 
javier@21682
    47
        AND ((COALESCE(:old.DATEACCT, v_DateNull) <> COALESCE(:new.DATEACCT, v_DateNull)) 
javier@21682
    48
        OR(COALESCE(:old.C_ACCTSCHEMA_ID, '0') <> COALESCE(:new.C_ACCTSCHEMA_ID, '0')) 
javier@21682
    49
        OR(COALESCE(:old.GL_CATEGORY_ID, '0') <> COALESCE(:new.GL_CATEGORY_ID, '0')) 
javier@21682
    50
        OR(COALESCE(:old.POSTINGTYPE, '.') <> COALESCE(:new.POSTINGTYPE, '.'))
javier@21682
    51
        OR(COALESCE(:OLD.User1_ID, '0') <> COALESCE(:NEW.User1_ID, '0'))
javier@21682
    52
        OR(COALESCE(:OLD.User2_ID, '0') <> COALESCE(:NEW.User2_ID, '0'))
javier@21682
    53
        OR(COALESCE(:OLD.C_Campaign_ID, '0') <> COALESCE(:NEW.C_Campaign_ID, '0'))
javier@21682
    54
        OR(COALESCE(:OLD.C_Project_ID, '0') <> COALESCE(:NEW.C_Project_ID, '0'))
javier@21682
    55
        OR(COALESCE(:OLD.A_Asset_ID, '0') <> COALESCE(:NEW.A_Asset_ID, '0'))
javier@21682
    56
        OR(COALESCE(:OLD.C_Costcenter_ID, '0') <> COALESCE(:NEW.C_Costcenter_ID, '0'))
javier@21682
    57
        OR(COALESCE(:OLD.C_BPartner_ID, '0') <> COALESCE(:NEW.C_BPartner_ID, '0'))
javier@21682
    58
        OR(COALESCE(:OLD.M_Product_ID, '0') <> COALESCE(:NEW.M_Product_ID, '0'))
javier@21682
    59
        )) 
javier@21682
    60
        THEN RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
javier@21737
    61
      END IF;    
adrian@94
    62
    END IF;
javier@21682
    63
    IF(DELETING) THEN
javier@21682
    64
      IF(:old.Processed='Y') THEN
javier@21682
    65
        RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
javier@21682
    66
      END IF;
pandeeswari@18880
    67
    END IF;
javier@21682
    68
    IF(INSERTING) THEN
javier@21682
    69
      IF(:NEW.Processed='Y') THEN
javier@21682
    70
        RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
javier@21682
    71
      END IF;
javier@21682
    72
    END IF;
javier@21682
    73
    END GL_JOURNAL_CHK_RESTRICT_TRG
gorkaion@239
    74
]]></body>
adrian@94
    75
    </trigger>
adrian@94
    76
  </database>