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
<?xml version="1.0"?>
  <database name="TRIGGER C_ORDERLINE_TRG3">
    <trigger name="C_ORDERLINE_TRG3" table="C_ORDERLINE" fires="before" insert="true" update="true" delete="false" foreach="row">
      <body><![CDATA[

/*************************************************************************
* The contents of this file are subject to the Openbravo  Public  License
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
* Version 1.1  with a permitted attribution clause; you may not  use this
* file except in compliance with the License. You  may  obtain  a copy of
* the License at http://www.openbravo.com/legal/license.html
* Software distributed under the License  is  distributed  on  an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific  language  governing  rights  and  limitations
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SL
* All portions are Copyright (C) 2010 Openbravo SL
* All Rights Reserved.
* Contributor(s):  ______________________________________.
************************************************************************/
  V_PRECISION NUMBER;
BEGIN
  IF AD_isTriggerEnabled()='N' THEN RETURN;
  END IF;

  IF(INSERTING OR UPDATING) THEN
    SELECT C.STDPRECISION INTO V_PRECISION FROM C_CURRENCY C
    WHERE C.C_CURRENCY_ID=:NEW.C_CURRENCY_ID;
  
    IF (round(to_number(:NEW.QTYORDERED) * to_number(:NEW.PRICEACTUAL),V_PRECISION) != to_number(:NEW.LINENETAMT)) THEN
      RAISE_APPLICATION_ERROR(-20000, '@LineAmountNotCorrect@') ;
    END IF;
  END IF;
  END C_ORDERLINE_TRG3
]]></body>
    </trigger>
  </database>