details:   https://code.openbravo.com/erp/devel/pi/rev/c0638f312efc
changeset: 22847:c0638f312efc
user:      Pandeeswari Ramakrishnan <pandeeswari.ramakrishnan <at> 
openbravo.com>
date:      Wed Apr 09 17:01:17 2014 +0530
summary:   Fixes Issue 26143: Division by zero error calculating manufacturing 
transactions cost

diffstat:

 src-db/database/model/functions/MA_PRODUCTION_COST.xml |  16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diffs (33 lines):

diff -r 8552c3633a70 -r c0638f312efc 
src-db/database/model/functions/MA_PRODUCTION_COST.xml
--- a/src-db/database/model/functions/MA_PRODUCTION_COST.xml    Wed Apr 09 
08:27:03 2014 +0200
+++ b/src-db/database/model/functions/MA_PRODUCTION_COST.xml    Wed Apr 09 
17:01:17 2014 +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) 2001-2013 Openbravo SLU
+ * All portions are Copyright (C) 2001-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************/
@@ -373,11 +373,15 @@
           --Calculate costs for each produced product.
 
           --Calculate the proportional factor of the cost
-          SELECT COALESCE(SUM(ComponentCost),1)/v_CompCostSum INTO v_CompCost
-          FROM MA_WRPHASEPRODUCT
-          WHERE MA_WRPhase_ID = Cur_ProductionPlan.MA_WRPHASE_ID
-            AND M_Product_ID = Cur_ProductionLine.M_PRODUCT_ID
-            AND PRODUCTIONTYPE = '+';
+          IF (v_CompCostSum = 0) THEN
+            v_CompCost := 0;
+          ELSE
+            SELECT COALESCE(SUM(ComponentCost),1)/v_CompCostSum INTO v_CompCost
+            FROM MA_WRPHASEPRODUCT
+            WHERE MA_WRPhase_ID = Cur_ProductionPlan.MA_WRPHASE_ID
+              AND M_Product_ID = Cur_ProductionLine.M_PRODUCT_ID
+              AND PRODUCTIONTYPE = '+';
+          END IF;
           --Calculate the proportional cost of the production
           v_ResultStr := 'Update component cost';
           UPDATE M_PRODUCTIONLINE

------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to