src-db/database/model/triggers/C_ORDERLINE_TRG3.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_ORDERLINE_TRG3">
victor@6475
     3
    <trigger name="C_ORDERLINE_TRG3" table="C_ORDERLINE" fires="before" insert="true" update="true" delete="false" foreach="row">
david@6474
     4
      <body><![CDATA[
david@6474
     5
david@6474
     6
/*************************************************************************
david@6474
     7
* The contents of this file are subject to the Openbravo  Public  License
david@6474
     8
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
david@6474
     9
* Version 1.1  with a permitted attribution clause; you may not  use this
david@6474
    10
* file except in compliance with the License. You  may  obtain  a copy of
david@6474
    11
* the License at http://www.openbravo.com/legal/license.html
david@6474
    12
* Software distributed under the License  is  distributed  on  an "AS IS"
david@6474
    13
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
david@6474
    14
* License for the specific  language  governing  rights  and  limitations
david@6474
    15
* under the License.
david@6474
    16
* The Original Code is Openbravo ERP.
david@6474
    17
* The Initial Developer of the Original Code is Openbravo SL
david@6474
    18
* All portions are Copyright (C) 2010 Openbravo SL
david@6474
    19
* All Rights Reserved.
david@6474
    20
* Contributor(s):  ______________________________________.
david@6474
    21
************************************************************************/
david@6474
    22
  V_PRECISION NUMBER;
david@6474
    23
BEGIN
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_CURRENCY C
victor@6475
    29
    WHERE C.C_CURRENCY_ID=:NEW.C_CURRENCY_ID;
victor@6475
    30
  
david@6474
    31
    IF (round(to_number(:NEW.QTYORDERED) * to_number(:NEW.PRICEACTUAL),V_PRECISION) != to_number(:NEW.LINENETAMT)) THEN
david@6474
    32
      RAISE_APPLICATION_ERROR(-20000, '@LineAmountNotCorrect@') ;
david@6474
    33
    END IF;
david@6474
    34
  END IF;
david@6474
    35
  END C_ORDERLINE_TRG3
victor@6475
    36
]]></body>
david@6474
    37
    </trigger>
david@6474
    38
  </database>