details:   https://code.openbravo.com/erp/devel/pi/rev/e86261103636
changeset: 28691:e86261103636
user:      Atul Gaware <atul.gaware <at> openbravo.com>
date:      Mon Feb 29 18:07:19 2016 +0530
summary:   Fixes Issue 32337:Division by zero error when completing an invoice
associated to a closed order (quantity 0) with a promotion

While calculating promotion if qty ordered is non zero then only
use divide by statement else set values to zero

diffstat:

 src-db/database/model/functions/M_PROMOTION_CALCULATE.xml |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 88faf8e87290 -r e86261103636 
src-db/database/model/functions/M_PROMOTION_CALCULATE.xml
--- a/src-db/database/model/functions/M_PROMOTION_CALCULATE.xml Tue Mar 01 
18:02:57 2016 +0100
+++ b/src-db/database/model/functions/M_PROMOTION_CALCULATE.xml Mon Feb 29 
18:07:19 2016 +0530
@@ -22,7 +22,7 @@
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SLU
-* All portions are Copyright (C) 2012-2015 Openbravo SLU
+* All portions are Copyright (C) 2012-2016 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
@@ -180,8 +180,13 @@
           v_totalamt := Cur_Offer.totalamt;
           v_displayedtotalamt := Cur_Offer.displayedtotalamt;
         else
-          v_totalamt := round(Cur_Offer.totalamt * v_qtyinvoiced / 
v_qtyordered, v_precision);
-          v_displayedtotalamt := round(Cur_Offer.displayedtotalamt * 
v_qtyinvoiced / v_qtyordered, v_precision);
+          IF(v_qtyordered <> 0) THEN
+            v_totalamt := round(Cur_Offer.totalamt * v_qtyinvoiced / 
v_qtyordered, v_precision);
+            v_displayedtotalamt := round(Cur_Offer.displayedtotalamt * 
v_qtyinvoiced / v_qtyordered, v_precision);
+          ELSE
+            v_totalamt := 0;
+            v_displayedtotalamt := 0;
+          END IF;
         end if;
         
         insert into c_invoiceline_offer

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to