Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0029194Openbravo ERP04. Warehouse managementpublic2015-02-26 12:442015-04-01 08:31
umartirena 
umartirena 
urgentmajoralways
closedfixed 
5
 
3.0PR15Q1.2 
aferraz
Core
3.0PR14Q4
No
0029194: [Cost Adjustments] / by zero error while calculating backdated cost for movement qty 0 receipt
/ by zero error is obtained in Cost Adjustments while calculating backdated cost for movement qty 0 receipts.
In pgadmin III, open m_inout_post function:

 * Comment the 3 following lines (not reproducible in pi due to this issue https://issues.openbravo.com/view.php?id=26163 [^]):

IF v_Message_Qty != '' THEN
             RAISE EXCEPTION '%', '@Inline@ '||v_Message_Qty||' '||'@ProductNotNullAndMovementQtyZero@' ; --OBTG:-20000--
END IF;

 * Save the function.


In live.builds as F&B International:

 * Create a Product for F&B España. Add a Purchase Pricelist of 10.
 * Go to Goods Receipt and create a Header:
   - Org: F&B España
   - Movement Date: 05/02/2015
 * Add a line:
   - Product: The created product
   - Movement Qty: 10
 * Complete it
 * Create another Goods Receipt Header:
   - Org: F&B España
   - Movement Date: 15/02/2015
 * Add a line:
   - Product: The created product
   - Movement Qty: 0
 * Complete it
 * Create another Goods Receipt Header:
   - Org: F&B España
   - Movement Date: 10/02/2015
 * Add a line:
   - Product: The created product
   - Movement Qty: 12
 * Complete it
 * Run Costing Background process
 * Realize that following error is obtained:

ERROR org.openbravo.costing.CostingBackground - / by zero
java.lang.ArithmeticException: / by zero
    at java.math.BigDecimal.divideAndRound(BigDecimal.java:1424)
    at java.math.BigDecimal.divide(BigDecimal.java:1398)
    at java.math.BigDecimal.divide(BigDecimal.java:1513)
    at org.openbravo.costing.AverageCostAdjustment.getRelatedTransactionsByAlgorithm(AverageCostAdjustment.java:305)
    at org.openbravo.costing.CostingAlgorithmAdjustmentImp.searchRelatedTransactionCosts(CostingAlgorithmAdjustmentImp.java:160)
Approved
blocks defect 0029076 closed umartirena [Cost Adjustments] / by zero error while calculating backdated cost for movement qty 0 receipt 
Issue History
2015-03-09 09:31umartirenaTypedefect => backport
2015-03-09 09:31umartirenaTarget Version => 3.0PR15Q1.2
2015-03-09 18:47hgbotCheckin
2015-03-09 18:47hgbotNote Added: 0075342
2015-03-09 18:47hgbotStatusscheduled => resolved
2015-03-09 18:47hgbotResolutionopen => fixed
2015-03-09 18:47hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/67607f6caaeef3bbc200e13b54801928b42396ee [^] => http://code.openbravo.com/erp/backports/3.0PR15Q1.2/rev/8ce0b518b9eae91e39b9afd4048eaa251b39ec3a [^]
2015-03-09 18:48aferrazNote Added: 0075343
2015-03-09 18:48aferrazStatusresolved => closed
2015-03-09 20:01dmitry_mezentsevTag Attached: Approved
2015-04-01 08:06hgbotCheckin
2015-04-01 08:06hgbotNote Added: 0076202
2015-04-01 08:06hgbotStatusclosed => resolved
2015-04-01 08:06hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/backports/3.0PR15Q1.2/rev/8ce0b518b9eae91e39b9afd4048eaa251b39ec3a [^] => http://code.openbravo.com/erp/backports/3.0PR15Q2/rev/8ce0b518b9eae91e39b9afd4048eaa251b39ec3a [^]
2015-04-01 08:31priyamStatusresolved => closed
2015-04-01 08:31priyamNote Added: 0076273

Notes
(0075342)
hgbot   
2015-03-09 18:47   
Repository: erp/backports/3.0PR15Q1.2
Changeset: 8ce0b518b9eae91e39b9afd4048eaa251b39ec3a
Author: Unai Martirena <unai.martirena <at> openbravo.com>
Date: Thu Feb 26 15:29:20 2015 +0100
URL: http://code.openbravo.com/erp/backports/3.0PR15Q1.2/rev/8ce0b518b9eae91e39b9afd4048eaa251b39ec3a [^]

Fixes bug 29194: Division by zero error managed in Costing Background.

Under certain circumnstance a division by zero error was happening in Cost Adjustments process inside Costing Background (when calculating backdated adjustments of a transaction of movementqty zero). This problem has been managed by being sure that this division will not happen again. If the movementqty of the transaction is zero, the cost of the full transaction will be zero as well.

---
M src/org/openbravo/costing/AverageCostAdjustment.java
---
(0075343)
aferraz   
2015-03-09 18:48   
Code review + Testing OK
(0076202)
hgbot   
2015-04-01 08:06   
Repository: erp/backports/3.0PR15Q2
Changeset: 8ce0b518b9eae91e39b9afd4048eaa251b39ec3a
Author: Unai Martirena <unai.martirena <at> openbravo.com>
Date: Thu Feb 26 15:29:20 2015 +0100
URL: http://code.openbravo.com/erp/backports/3.0PR15Q2/rev/8ce0b518b9eae91e39b9afd4048eaa251b39ec3a [^]

Fixes bug 29194: Division by zero error managed in Costing Background.

Under certain circumnstance a division by zero error was happening in Cost Adjustments process inside Costing Background (when calculating backdated adjustments of a transaction of movementqty zero). This problem has been managed by being sure that this division will not happen again. If the movementqty of the transaction is zero, the cost of the full transaction will be zero as well.

---
M src/org/openbravo/costing/AverageCostAdjustment.java
---
(0076273)
priyam   
2015-04-01 08:31   
closed again, as the status changed due the merge tag of 3.0PR15Q1.2 to backports/3.0PR15Q2