details:   https://code.openbravo.com/erp/devel/pi/rev/b37dfca128c9
changeset: 33180:b37dfca128c9
user:      Armaignac <collazoandy4 <at> gmail.com>
date:      Fri Jan 05 18:57:17 2018 -0500
summary:   Fixes issue 37580: "division by zero" error when book sales order 
with BOM
products

When closing a sales order with a BOM product a division by zeror error was 
raise
while the process tries to calculate the v_PriceActual variable.

A validation was added to only calculate the value when the qtyordered is
different from cero, if not the v_PriceActual value is cero.

diffstat:

 src-db/database/model/triggers/C_ORDERLINE_TRG.xml |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (25 lines):

diff -r d0f17b56bf6e -r b37dfca128c9 
src-db/database/model/triggers/C_ORDERLINE_TRG.xml
--- a/src-db/database/model/triggers/C_ORDERLINE_TRG.xml        Mon Jan 08 
18:25:25 2018 +0100
+++ b/src-db/database/model/triggers/C_ORDERLINE_TRG.xml        Fri Jan 05 
18:57:17 2018 -0500
@@ -17,7 +17,7 @@
   * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
   * All Rights Reserved.
   * Contributor(s): Openbravo SLU
-  * Contributions are Copyright (C) 2001-2017 Openbravo, S.L.U.
+  * Contributions are Copyright (C) 2001-2018 Openbravo, S.L.U.
   *
   * Specifically, this derivative work is based upon the following Compiere
   * file and version.
@@ -224,7 +224,11 @@
         v_CalcLine := C_GET_NET_AMOUNT_FROM_GROSS(Cur_BOM.TAX, v_Line, v_Line, 
v_Prec);
         v_NetActual := v_NetActual + v_CalcLine; -- Acum the net
       END LOOP;    
-      v_PriceActual := ROUND(v_NetActual / :new.qtyordered, v_price_prec);     
+      IF (:new.qtyordered <> 0) THEN
+        v_PriceActual := ROUND(v_NetActual / :new.qtyordered, v_price_prec);
+      ELSE
+        v_PriceActual := 0;
+      END IF;     
     ELSE
       -- Regular taxes
       v_NetActual := C_GET_NET_AMOUNT_FROM_GROSS(:new.c_tax_id, 
:new.line_gross_amount, :new.taxbaseamt, v_Prec);

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to