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
<?xml version="1.0"?>
  <database name="TRIGGER C_INVOICELINE_TRG4">
    <trigger name="C_INVOICELINE_TRG4" table="C_INVOICELINE" 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_INVOICE I, C_CURRENCY C 
    WHERE I.C_CURRENCY_ID=C.C_CURRENCY_ID 
    AND I.C_INVOICE_ID=:NEW.C_INVOICE_ID;
 
    IF (ROUND(TO_NUMBER(:NEW.QTYINVOICED) * TO_NUMBER(:NEW.PRICEACTUAL),V_PRECISION)!=TO_NUMBER(:NEW.LINENETAMT)) THEN
      RAISE_APPLICATION_ERROR(-20501,'Line Amount Is Not Correct');
    END IF;
  END IF;
  END C_INVOICELINE_TRG4
]]></body>
    </trigger>
  </database>