src-db/database/model/triggers/C_INVOICELINE_TRG4.xml
author Víctor Martínez Romanos <victor.martinez@openbravo.com>
Tue, 23 Feb 2010 17:50:44 +0100
changeset 6475 35dc05a84c8b
parent 6474 4e03817a571b
child 6701 690d2af86089
permissions -rw-r--r--
Issue 12366: Recoded triggers to pass the JUnit tests
david@6474
     1
<?xml version="1.0"?>
david@6474
     2
  <database name="TRIGGER C_INVOICELINE_TRG4">
victor@6475
     3
    <trigger name="C_INVOICELINE_TRG4" table="C_INVOICELINE" fires="before" insert="true" update="true" delete="false" foreach="row">
david@6474
     4
      <body><![CDATA[
david@6474
     5
  /*************************************************************************
david@6474
     6
  * The contents of this file are subject to the Openbravo  Public  License
david@6474
     7
  * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
david@6474
     8
  * Version 1.1  with a permitted attribution clause; you may not  use this
david@6474
     9
  * file except in compliance with the License. You  may  obtain  a copy of
david@6474
    10
  * the License at http://www.openbravo.com/legal/license.html
david@6474
    11
  * Software distributed under the License  is  distributed  on  an "AS IS"
david@6474
    12
  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
david@6474
    13
  * License for the specific  language  governing  rights  and  limitations
david@6474
    14
  * under the License.
david@6474
    15
  * The Original Code is Openbravo ERP.
david@6474
    16
  * The Initial Developer of the Original Code is Openbravo SL
david@6474
    17
  * All portions are Copyright (C) 2010 Openbravo SL
david@6474
    18
  * All Rights Reserved.
david@6474
    19
  * Contributor(s):  ______________________________________.
david@6474
    20
  ************************************************************************/
david@6474
    21
  V_PRECISION NUMBER;
david@6474
    22
BEGIN
david@6474
    23
david@6474
    24
  IF AD_isTriggerEnabled()='N' THEN RETURN;
david@6474
    25
  END IF;
david@6474
    26
david@6474
    27
  IF(INSERTING OR UPDATING) THEN
victor@6475
    28
    SELECT C.STDPRECISION INTO V_PRECISION FROM C_INVOICE I, C_CURRENCY C 
victor@6475
    29
    WHERE I.C_CURRENCY_ID=C.C_CURRENCY_ID 
victor@6475
    30
    AND I.C_INVOICE_ID=:NEW.C_INVOICE_ID;
victor@6475
    31
 
david@6474
    32
    IF (ROUND(TO_NUMBER(:NEW.QTYINVOICED) * TO_NUMBER(:NEW.PRICEACTUAL),V_PRECISION)!=TO_NUMBER(:NEW.LINENETAMT)) THEN
david@6474
    33
      RAISE_APPLICATION_ERROR(-20501,'Line Amount Is Not Correct');
david@6474
    34
    END IF;
david@6474
    35
  END IF;
victor@6475
    36
  END C_INVOICELINE_TRG4
victor@6475
    37
]]></body>
david@6474
    38
    </trigger>
david@6474
    39
  </database>