src-db/database/model/triggers/C_ORDER_TRG2.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Wed, 03 Sep 2008 17:55:37 +0000
changeset 1605 8a0fe0193bef
parent 756 ae11e4610537
child 2078 cf88ca44cdd2
permissions -rw-r--r--
Merge r2.5x intro trunk
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER C_ORDER_TRG2">
adrian@94
     3
    <trigger name="C_ORDER_TRG2" table="C_ORDER" fires="after" insert="false" update="true" delete="false" 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');
adrian@94
    26
    BEGIN  IF(UPDATING)
gorkaion@239
    27
    THEN  IF((COALESCE(:old.PaymentRule, '.') <> COALESCE(:NEW.PaymentRule, '.')
juanpablo@1605
    28
    OR COALESCE(:old.C_PaymentTerm_ID, '0') <> COALESCE(:NEW.C_PaymentTerm_ID, '0')
gorkaion@280
    29
    OR COALESCE(:old.DateAcct, v_DateNull) <> COALESCE(:NEW.DateAcct, v_DateNull)))
adrian@94
    30
    THEN
adrian@94
    31
    -- Propagate Changes of Payment Info to existing invoices
adrian@94
    32
  UPDATE C_Invoice
adrian@94
    33
    SET PaymentRule=:new.PaymentRule,
adrian@94
    34
    C_PaymentTerm_ID=:new.C_PaymentTerm_ID,
adrian@94
    35
    DateAcct=:new.DateAcct
adrian@94
    36
  WHERE C_Order_ID=:new.C_Order_ID
adrian@94
    37
    AND DocStatus NOT IN('RE', 'CL', 'CO') ;
adrian@94
    38
  END IF;
adrian@94
    39
 END IF;
antonio@735
    40
END C_ORDER_TRG2
gorkaion@239
    41
]]></body>
adrian@94
    42
    </trigger>
adrian@94
    43
  </database>