src-db/database/model/triggers/A_AMORTIZATIONLINE_TRG.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Wed, 03 Sep 2008 17:55:37 +0000
changeset 1605 8a0fe0193bef
parent 756 ae11e4610537
child 1895 6c92cf572f7f
permissions -rw-r--r--
Merge r2.5x intro trunk
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER A_AMORTIZATIONLINE_TRG">
adrian@94
     3
    <trigger name="A_AMORTIZATIONLINE_TRG" table="A_AMORTIZATIONLINE" fires="before" insert="true" update="true" delete="true" foreach="row">
gorkaion@239
     4
      <body><![CDATA[
gorkaion@239
     5
adrian@170
     6
adrian@94
     7
carlos@59
     8
carlos@0
     9
/*************************************************************************
carlos@0
    10
* The contents of this file are subject to the Openbravo  Public  License
carlos@0
    11
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
carlos@0
    12
* Version 1.1  with a permitted attribution clause; you may not  use this
carlos@0
    13
* file except in compliance with the License. You  may  obtain  a copy of
carlos@0
    14
* the License at http://www.openbravo.com/legal/license.html
carlos@0
    15
* Software distributed under the License  is  distributed  on  an "AS IS"
carlos@0
    16
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
carlos@0
    17
* License for the specific  language  governing  rights  and  limitations
carlos@0
    18
* under the License.
carlos@0
    19
* The Original Code is Openbravo ERP.
carlos@0
    20
* The Initial Developer of the Original Code is Openbravo SL
carlos@0
    21
* All portions are Copyright (C) 2001-2007 Openbravo SL
carlos@0
    22
* All Rights Reserved.
carlos@0
    23
* Contributor(s):  ______________________________________.
carlos@0
    24
************************************************************************/
carlos@0
    25
  v_Processed CHAR(1) ;
carlos@0
    26
  v_Posted CHAR(1) ;
juanpablo@1605
    27
  v_AmortizationID varchar2(32);
carlos@0
    28
BEGIN
carlos@0
    29
  -- ReadOnly Check
carlos@0
    30
  IF (UPDATING OR INSERTING) THEN
carlos@0
    31
    v_AmortizationID := :NEW.A_Amortization_ID;
carlos@0
    32
  ELSE
carlos@0
    33
    v_AmortizationID := :OLD.A_Amortization_ID;
carlos@0
    34
  END IF;
antonio@737
    35
carlos@0
    36
    begin
carlos@0
    37
      SELECT processed,
carlos@0
    38
             POSTED
carlos@0
    39
      INTO v_Processed,
carlos@0
    40
        v_Posted
carlos@0
    41
      FROM A_Amortization
carlos@0
    42
      WHERE A_Amortization.A_Amortization_ID=v_AmortizationID;
carlos@0
    43
    exception
carlos@0
    44
    when others then
carlos@0
    45
      v_processed:=null;
carlos@0
    46
    end;
carlos@0
    47
carlos@0
    48
  if(UPDATING) THEN
carlos@0
    49
    IF coalesce(v_Processed, 'N')='Y'
juanpablo@1605
    50
   and(  COALESCE(:old.A_AMORTIZATIONLINE_ID, '0') <> COALESCE(:new.A_AMORTIZATIONLINE_ID, '0')
juanpablo@1605
    51
       or COALESCE(:old.AD_CLIENT_ID, '0') <> COALESCE(:new.AD_CLIENT_ID, '0')
juanpablo@1605
    52
       or COALESCE(:old.AD_ORG_ID, '0') <> COALESCE(:new.AD_ORG_ID, '0')
gorkaion@239
    53
       or COALESCE(:old.ISACTIVE, '') <> COALESCE(:new.ISACTIVE, '')
juanpablo@1605
    54
       or COALESCE(:old.A_AMORTIZATION_ID, '0') <> COALESCE(:new.A_AMORTIZATION_ID, '0')
gorkaion@239
    55
       or COALESCE(:old.LINE, 0) <> COALESCE(:new.LINE, 0)
juanpablo@1605
    56
       or COALESCE(:old.A_ASSET_ID, '0') <> COALESCE(:new.A_ASSET_ID, '0')
gorkaion@239
    57
       or COALESCE(:old.AMORTIZATION_PORCENTAGE, 0) <> COALESCE(:new.AMORTIZATION_PORCENTAGE, 0)
gorkaion@239
    58
       or COALESCE(:old.AMORTIZATIONAMT, 0) <> COALESCE(:new.AMORTIZATIONAMT, 0)
juanpablo@1605
    59
       or COALESCE(:old.C_CURRENCY_ID, '0') <> COALESCE(:new.C_CURRENCY_ID, '0'))
carlos@0
    60
  then
carlos@0
    61
      RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
carlos@0
    62
    end if;
carlos@0
    63
  end if;
carlos@0
    64
  if (INSERTING OR DELETING) THEN
carlos@0
    65
    IF(coalesce(v_Processed, 'N')='Y'
carlos@0
    66
   or coalesce(v_posted, 'N')='Y')
carlos@0
    67
  then
carlos@0
    68
      RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
carlos@0
    69
    end if;
carlos@0
    70
  end if;
antonio@735
    71
END A_AMORTIZATIONLINE_TRG
gorkaion@239
    72
]]></body>
adrian@94
    73
    </trigger>
adrian@94
    74
  </database>