Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0039993Openbravo ERP04. Warehouse managementpublic2019-01-22 11:142019-03-28 14:56
ngarcia 
AtulOpenbravo 
urgentmajoralways
closedfixed 
5
 
3.0PR19Q2 
Sandrahuguet
Core
No
0039993: / by zero error in Costing Background Process with backdated and negative stock correction and voided goods receipt
/ by zero error in Costing Background Process with backdated and negative stock correction and voided goods receipt
As group admin role:
   Set the 'Enable Negative Stock Corrections' to Y
   Log out and log in

   Go to Costing Rules window, select 'F&B España, S.A', launch 'Fix Backdated Transactions' process with '01-01-2019' starting date

   Create a new product
   Set a price of 5 in Tarifa Bebidas Alegres

   Create a new goods receipt with '16-01-2019' movement date and 2 units of the product
   Create a new goods shipment with '17-01-2019' movement date and 2 units of the product
   Void the goods receipt with a movement date of 'today'

   Create a purchase order with '16-01-2019' movement date and 2 units of the product. Increase its price to 7
   Create the related goods receipt with a movement date of '16-01-2019'

   Launch the Costing Background Process and check the following message is shown in Process Log field:
     / by zero

The log shows:
   [DefaultQuartzScheduler_Worker-8] ERROR org.openbravo.costing.CostingBackground - / by zero
java.lang.ArithmeticException: / by zero
    at java.math.BigDecimal.divideAndRound(BigDecimal.java:4106) ~[?:1.8.0_171]
    at java.math.BigDecimal.divide(BigDecimal.java:5183) ~[?:1.8.0_171]
    at java.math.BigDecimal.divide(BigDecimal.java:1561) ~[?:1.8.0_171]
    at java.math.BigDecimal.divide(BigDecimal.java:1591) ~[?:1.8.0_171]
    at org.openbravo.costing.AverageCostAdjustment.getRelatedTransactionsByAlgorithm(AverageCostAdjustment.java:376) ~[AverageCostAdjustment.class:?]
    at org.openbravo.costing.CostingAlgorithmAdjustmentImp.searchRelatedTransactionCosts(CostingAlgorithmAdjustmentImp.java:164) ~[CostingAlgorithmAdjustmentImp.class:?]
    at org.openbravo.costing.CostAdjustmentProcess.calculateAdjustmentAmount(CostAdjustmentProcess.java:235) ~[CostAdjustmentProcess.class:?]
    at org.openbravo.costing.CostAdjustmentProcess.processCostAdjustment(CostAdjustmentProcess.java:86) ~[CostAdjustmentProcess.class:?]
    at org.openbravo.costing.CostAdjustmentProcess.doProcessCostAdjustment(CostAdjustmentProcess.java:339) ~[CostAdjustmentProcess.class:?]
    at org.openbravo.costing.CostingServer.createAdjustment(CostingServer.java:385) ~[CostingServer.class:?]
    at org.openbravo.costing.CostingServer.checkCostAdjustments(CostingServer.java:313) ~[CostingServer.class:?]
    at org.openbravo.costing.CostingServer.process(CostingServer.java:136) ~[CostingServer.class:?]
    at org.openbravo.costing.CostingBackground.doExecute(CostingBackground.java:137) [CostingBackground.class:?]
    at org.openbravo.service.db.DalBaseProcess.execute(DalBaseProcess.java:84) [DalBaseProcess.class:?]
    at org.openbravo.scheduling.DefaultJob.execute(DefaultJob.java:64) [DefaultJob.class:?]
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [quartz-1.6.2.jar:1.6.2]
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525) [quartz-1.6.2.jar:1.6.2]
      
No tags attached.
Issue History
2019-01-22 11:14ngarciaNew Issue
2019-01-22 11:14ngarciaAssigned To => Triage Finance
2019-01-22 11:14ngarciaModules => Core
2019-01-22 11:14ngarciaResolution time => 1549926000
2019-01-22 11:14ngarciaTriggers an Emergency Pack => No
2019-01-22 11:15ngarciaIssue Monitored: networkb
2019-01-22 11:45PracticsIssue Monitored: Practics
2019-01-24 16:53SandrahuguetAssigned ToTriage Finance => AtulOpenbravo
2019-01-28 16:50ngarciaSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=18201#r18201
2019-01-29 09:40AtulOpenbravoStatusnew => scheduled
2019-01-29 09:40AtulOpenbravoNote Added: 0109294
2019-02-05 17:40hgbotCheckin
2019-02-05 17:40hgbotNote Added: 0109600
2019-02-05 17:40hgbotStatusscheduled => resolved
2019-02-05 17:40hgbotResolutionopen => fixed
2019-02-05 17:40hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/94c8cd7d1c55e39587b68a2fe4e3a67b7e79bac9 [^]
2019-02-05 17:42SandrahuguetReview Assigned To => Sandrahuguet
2019-02-05 17:42SandrahuguetNote Added: 0109601
2019-02-05 17:42SandrahuguetStatusresolved => closed
2019-02-05 17:42SandrahuguetFixed in Version => 3.0PR19Q2
2019-03-28 14:56hudsonbotCheckin
2019-03-28 14:56hudsonbotNote Added: 0110797

Notes
(0109294)
AtulOpenbravo   
2019-01-29 09:40   
- Login as F&B International Group admin role:
- Set the 'Enable Negative Stock Corrections' to Y
  Log out and log in

- Go to Costing Rules window, select 'F&B España, S.A', launch 'Fix Backdated Transactions' process with '01-01-2019' starting date

- Create a new product
- Set a price of 5 in Tarifa Bebidas Alegres

- Create a new goods receipt with '16-01-2019' movement date and 2 units of the product
- Create a new goods shipment with '17-01-2019' movement date and 2 units of the product
- Void the goods receipt with '16-01-2019' movement date and in pop up enter void date as 'today'. (This step will raise error for insufficient stock. To avoid this error, change status of storage to Undefined - OverIssue)
- Create a purchase order with '16-01-2019' movement date and 2 units of the product. Increase its price to 7
- Create the related goods receipt with a movement date of '16-01-2019'
- Launch the Costing Background Process and check the following message is shown in process log is Process completed successfully.
(0109600)
hgbot   
2019-02-05 17:40   
Repository: erp/devel/pi
Changeset: 94c8cd7d1c55e39587b68a2fe4e3a67b7e79bac9
Author: Atul Gaware <atul.gaware <at> openbravo.com>
Date: Tue Jan 29 23:13:57 2019 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/94c8cd7d1c55e39587b68a2fe4e3a67b7e79bac9 [^]

Fixes Issue 0039993: / by zero error in Costing Background Process
with backdated and negative stock correction and voided goods
receipt

In case of negative stock correction, handle divide by zero when
currentStock value is zero

---
M src/org/openbravo/costing/AverageCostAdjustment.java
---
(0109601)
Sandrahuguet   
2019-02-05 17:42   
Code review + testing OK
(0110797)
hudsonbot   
2019-03-28 14:56   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/b2fbc1588df4 [^]
Maturity status: Test