Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0042492Openbravo ERP04. Warehouse managementpublic2019-12-09 15:062019-12-20 10:28
ngarcia 
AtulOpenbravo 
urgentmajoralways
closedfixed 
5
 
3.0PR20Q1 
dmiguelez
Core
No
0042492: Fix Backdated From finishes with an empty error if the ending date of a calculated cost is manually edited
Fix Backdated From finishes with an empty error if the ending date of a calculated cost is manually edited

The problem is in the following line of extendPreviousCosting function of AverageCostAdjustment:

    lastCosting.setEndingDate(bdCosting.getEndingDate());

bdCosting is null because it does not exist any costing entry with an ending date equal to the starting date of the current costing entry
As group admin role:
   Create a new product
   Set it as stocked
   Add a purchase price list to it
   Create three goods receipts with the following dates:
      1st: 09-12-2019
      2nd: 12-12-2019
      3rd: 11-12-2019
   Add previously created product in the three of them and complete them
   Schedule the Costing Background Process to be run immediately
   Change the ending date of the costing entry related to the transaction of the 12-12-2019 to yesterday (one day before the transaction process date)
   Go to Costing Rules window and launch the Fix Backdated Transactions process
   Select 01-01-2019 as Fix Backdated From
   Check an empty error message is shown

   The log shows:
      ERROR org.openbravo.costing.FixBackdatedTransactionsProcess - null
java.lang.NullPointerException: null
    at org.openbravo.costing.AverageCostAdjustment.extendPreviousCosting(AverageCostAdjustment.java:957) ~[classes/:?]
    at org.openbravo.costing.AverageCostAdjustment.calculateBackdatedTrxAdjustment(AverageCostAdjustment.java:592) ~[classes/:?]
    at org.openbravo.costing.CostingAlgorithmAdjustmentImp.searchRelatedTransactionCosts(CostingAlgorithmAdjustmentImp.java:148) ~[classes/:?]
    at org.openbravo.costing.CostAdjustmentProcess.calculateAdjustmentAmount(CostAdjustmentProcess.java:238) ~[classes/:?]
    at org.openbravo.costing.CostAdjustmentProcess.processCostAdjustment(CostAdjustmentProcess.java:86) ~[classes/:?]
    at org.openbravo.costing.CostAdjustmentProcess.doProcessCostAdjustment(CostAdjustmentProcess.java:342) ~[classes/:?]
    at org.openbravo.costing.FixBackdatedTransactionsProcess.doExecute(FixBackdatedTransactionsProcess.java:143) [classes/:?]
    at org.openbravo.client.application.process.BaseProcessActionHandler.execute(BaseProcessActionHandler.java:150) [classes/:?]
No tags attached.
Issue History
2019-12-09 15:06ngarciaNew Issue
2019-12-09 15:06ngarciaAssigned To => Triage Finance
2019-12-09 15:06ngarciaModules => Core
2019-12-09 15:06ngarciaResolution time => 1577660400
2019-12-09 15:06ngarciaTriggers an Emergency Pack => No
2019-12-10 18:55dmiguelezAssigned ToTriage Finance => AtulOpenbravo
2019-12-17 12:41AtulOpenbravoStatusnew => scheduled
2019-12-20 06:27AtulOpenbravoNote Added: 0116449
2019-12-20 07:42AtulOpenbravoReview Assigned To => dmiguelez
2019-12-20 10:27hgbotCheckin
2019-12-20 10:27hgbotNote Added: 0116456
2019-12-20 10:27hgbotStatusscheduled => resolved
2019-12-20 10:27hgbotResolutionopen => fixed
2019-12-20 10:27hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/462c35e38ba5c680442dfcba905e5d3a80e10d68 [^]
2019-12-20 10:28dmiguelezNote Added: 0116457
2019-12-20 10:28dmiguelezStatusresolved => closed
2019-12-20 10:28dmiguelezFixed in Version => 3.0PR20Q1

Notes
(0116449)
AtulOpenbravo   
2019-12-20 06:27   
Test Plan

- Login as F&B International Group admin role
- Create a new product
   - Set it as stocked
   - Add a purchase price list to it
- Create three goods receipts with the following dates:
      1st: 09-12-2019
      2nd: 12-12-2019
      3rd: 11-12-2019
   Add previously created product in the three of them and complete them
- Schedule the Costing Background Process to be run immediately
- Change the ending date of the costing entry related to the transaction of the 12-12-2019 to yesterday (one day before the transaction process date)
- Go to Costing Rules window and launch the Fix Backdated Transactions process
  - Select 01-01-2019 as Fix Backdated From
  - Realize that process is completed successfully and end date of modified costing record is set correctly.
(0116456)
hgbot   
2019-12-20 10:27   
Repository: erp/devel/pi
Changeset: 462c35e38ba5c680442dfcba905e5d3a80e10d68
Author: Atul Gaware <atul.gaware <at> openbravo.com>
Date: Thu Dec 19 19:21:43 2019 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/462c35e38ba5c680442dfcba905e5d3a80e10d68 [^]

Fixes BUG-42492:Fix Backdated From finishes with an empty error if
the ending date of a calculated cost is manually edited

**In extendPreviousCosting method of Average Cost Adjustment class
get costing record by addiin condition <= enddate, sort costing record
with enddate desc order in extendPreviousCosting, set fetch size to 1

---
M src/org/openbravo/costing/AverageCostAdjustment.java
---
(0116457)
dmiguelez   
2019-12-20 10:28   
Code Review + Testing Ok