Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0039822
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Openbravo ERP] 09. Financial managementmajoralways2018-12-17 16:192019-03-28 14:55
ReporterdmiguelezView Statuspublic 
Assigned Todmiguelez 
PriorityhighResolutionfixedFixed in Version3.0PR19Q2
StatusclosedFix in branchFixed in SCM revision11dbadbe4ba4
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned ToSandrahuguet
Web browser
ModulesCore
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0039822: Wrong Cost Adjustment created with Landed Cost and Negative Stock correction

DescriptionWhen two types of cost adjustments are created in the same document, both are merged into one.

This is creating a problem in the next cost adjustment calculations if the merge is not correct (when merges cost adjustments that are unit cost and not unit cost into one, for example)
Steps To ReproduceLog in as F&B Admin

1. Enable Negative Stock Corrections
Go to Preference window and create a new record with:
  - Organization: *
  - Property: Enable Negative Stock Corrections
  - Value: Y
  - Visibility fields all empty

Log out and Log in again

2. Create BOM Products
Go to Product window and create a new record with:
  - Organization: F&B US
  - SearchKey: Raw Material
  - Name: Raw Material
Move to Price Tab and create two records with:
  - Price List Version: Be Soft Drinker Price List
  - Unit Price: 10
  - List Price: 10
  - Price List Version: General Sales
  - Unit Price: 10
  - List Price: 10
Move to Costing Tab and create a new record with:
  - Organization: F&B US
  - Cost Type: Average
  - Cost: 10
  - Starting Date: 01-01-2000
  - Ending Date: 09-09-9999
  - Currency: USD
  - Manual: Yes
  - Permanent: Yes

Go to Product window and create a new record with:
  - Organization: F&B US
  - SearchKey: Final Product
  - Name: Final Product
  - Bill of Materials: Yes
Move to Price Tab and create two records with:
  - Price List Version: Be Soft Drinker Price List
  - Unit Price: 10
  - List Price: 10
  - Price List Version: General Sales
  - Unit Price: 10
  - List Price: 10
Move to Costing Tab and create a new record with:
  - Organization: F&B US
  - Cost Type: Average
  - Cost: 10
  - Starting Date: 01-01-2000
  - Ending Date: 09-09-9999
  - Currency: USD
  - Manual: Yes
  - Permanent: Yes
Move to Bill of Materials Tab and create a new record with:
  - BOM Product: Raw Material
  - BOM Quantity: 2
Click on Verify BOM and Ok (Process Completed Successfully)

3. Create Negative Stock for one Product
Go to Warehouse and Storage Bins Window
Select the Warehouse with name US West Coast
Move to Storage Bin Tab and select the Bin with Search Key: WC-0-0-0
Click on Change Status button and select the status with name Backflush. Click on done (Process Completed Successfully)

Go to Goods Shipment Window and create a new record with:
  - Organization: US West Coast
  - Business Partner: Healthy Food Supermarkets
  - Warehouse: US West Coast
Move to lines and create a record with:
  - Product: Final Product (click on the magnifying glass and remove filters first to be able to find it)
  - Movement Quantity: 1000
  - Storage Bin: WC-0-0-0
Click on Complete and Ok (Process Completed Successfully)

4. Create a Reception for the other Product
Go to Goods Receipt Window and create a new record with:
  - Organization: US West Coast
  - Business Partner: Be Soft Drinker
  - Warehouse: US West Coast
Move to Lines and create a record with:
  - Product: Raw Material (click on the magnifying glass and remove filters first to be able to find it)
  - Storage Bin: WC-0-0-0
  - Quantity Count: 1000
Click on Complete (Process Completed Successfully)

Go to Process Request Window and create a new record with:
  - Client: F&B International
  - Organization: *
  - Process: Costing Background process
  - Timing: Run Immediately
Click on Schedule Process

Check that the previous products have transactions with cost calculated.
Go to Product window, fitler by the previous products, go to transactions tab and check that the records have Costing Status: Cost Calculated

5. Create BOM Productions
Repeat this process three times to have three different BOM Productions
Go to Bill of Materials Production and create a new record with:
  - Organization US West Coast
  - Name: Production 1
Move to Production Plan and create a record with:
  - Production: Final Product
  - Production Quantity: 1
  - Storage Bin: WC-0-0-0
Click on Create/Process Production button and check that it has created values in the I/O Products Tab
Click on Create/Process Production button again.

Go to Process Request window and launch the Costing Background again.
Check again that the transaction costs have been calculated.
Check the transactions of the Final Product ordered by Transaction Process Date
Realize that the first production has a Total Cost of -9.980 (due to a negative stock correction)

6. Create a Landed Cost
Go to Landed Cost Type Window and create a new record with:
  - Organization: F&B US
  - Name: LCT
  - Landed Cost Distribution Algorithm: Distribution by Amount
  - Account: Company Capital

Go to Landed Cost Window and create a new record with:
  - Organization: F&B US
Move to Cost Tab and create a new record with:
  - Landed Cost Type: LCT
  - Amount: 50000
  - Currency: USD
Move to Receipt Tab and create a new record with:
  - Goods Receipt: select the previously created Goods Receipt
Click on Process

Go back to Product window and check the transactions of the final Product
The first production transaction has a total cost of -109880 and has a new transaction cost entry
But this transaction cost is not Unit Cost. This is already wrong.
It should have created two transaction costs, one unit cost of 100 usd and one not unit cost of -100000

7. Create another Landed Cost
Go to Landed Cost Window and create a new record with:
  - Organization: F&B US
Move to Cost Tab and create a new record with:
  - Landed Cost Type: LCT
  - Amount: 30000
  - Currency: USD
Move to Receipt Tab and create a new record with:
  - Goods Receipt: select the previously created Goods Receipt
Click on Process

Go back to Product window and check the transactions of the final Product
The first production transaction has a total cost of -69920 and has a new transaction cost entry
But this transaction cost is not Unit Cost
The second production transaction now has a cost of -99720.
This is wrong and is due to the fact that the other adjustment was not set as unit cost

It should be, the first transaction with total cost of -169820 and the second and third transactions with cost of 180 each
TagsNo tags attached.
Attached Filesdiff file icon Proposal39822.diff [^] (46,569 bytes) 2018-12-17 17:52 [Show Content]

- Relationships Relation Graph ] Dependency Graph ]

-  Notes
(0108649)
dmiguelez (developer)
2018-12-17 16:20

Test Plan:

Log in as F&B Admin

1. Enable Negative Stock Corrections
Go to Preference window and create a new record with:
  - Organization: *
  - Property: Enable Negative Stock Corrections
  - Value: Y
  - Visibility fields all empty

Log out and Log in again

2. Create BOM Products
Go to Product window and create a new record with:
  - Organization: F&B US
  - SearchKey: Raw Material
  - Name: Raw Material
Move to Price Tab and create two records with:
  - Price List Version: Be Soft Drinker Price List
  - Unit Price: 10
  - List Price: 10
  - Price List Version: General Sales
  - Unit Price: 10
  - List Price: 10
Move to Costing Tab and create a new record with:
  - Organization: F&B US
  - Cost Type: Average
  - Cost: 10
  - Starting Date: 01-01-2000
  - Ending Date: 09-09-9999
  - Currency: USD
  - Manual: Yes
  - Permanent: Yes

Go to Product window and create a new record with:
  - Organization: F&B US
  - SearchKey: Final Product
  - Name: Final Product
  - Bill of Materials: Yes
Move to Price Tab and create two records with:
  - Price List Version: Be Soft Drinker Price List
  - Unit Price: 10
  - List Price: 10
  - Price List Version: General Sales
  - Unit Price: 10
  - List Price: 10
Move to Costing Tab and create a new record with:
  - Organization: F&B US
  - Cost Type: Average
  - Cost: 10
  - Starting Date: 01-01-2000
  - Ending Date: 09-09-9999
  - Currency: USD
  - Manual: Yes
  - Permanent: Yes
Move to Bill of Materials Tab and create a new record with:
  - BOM Product: Raw Material
  - BOM Quantity: 2
Click on Verify BOM and Ok (Process Completed Successfully)

3. Create Negative Stock for one Product
Go to Warehouse and Storage Bins Window
Select the Warehouse with name US West Coast
Move to Storage Bin Tab and select the Bin with Search Key: WC-0-0-0
Click on Change Status button and select the status with name Backflush. Click on done (Process Completed Successfully)

Go to Goods Shipment Window and create a new record with:
  - Organization: US West Coast
  - Business Partner: Healthy Food Supermarkets
  - Warehouse: US West Coast
Move to lines and create a record with:
  - Product: Final Product (click on the magnifying glass and remove filters first to be able to find it)
  - Movement Quantity: 1000
  - Storage Bin: WC-0-0-0
Click on Complete and Ok (Process Completed Successfully)

4. Create a Reception for the other Product
Go to Goods Receipt Window and create a new record with:
  - Organization: US West Coast
  - Business Partner: Be Soft Drinker
  - Warehouse: US West Coast
Move to Lines and create a record with:
  - Product: Raw Material (click on the magnifying glass and remove filters first to be able to find it)
  - Storage Bin: WC-0-0-0
  - Quantity Count: 1000
Click on Complete (Process Completed Successfully)

Go to Process Request Window and create a new record with:
  - Client: F&B International
  - Organization: *
  - Process: Costing Background process
  - Timing: Run Immediately
Click on Schedule Process

Check that the previous products have transactions with cost calculated.
Go to Product window, fitler by the previous products, go to transactions tab and check that the records have Costing Status: Cost Calculated

5. Create BOM Productions
Repeat this process three times to have three different BOM Productions
Go to Bill of Materials Production and create a new record with:
  - Organization US West Coast
  - Name: Production 1
Move to Production Plan and create a record with:
  - Production: Final Product
  - Production Quantity: 1
  - Storage Bin: WC-0-0-0
Click on Create/Process Production button and check that it has created values in the I/O Products Tab
Click on Create/Process Production button again.

Go to Process Request window and launch the Costing Background again.
Check again that the transaction costs have been calculated.
Check the transactions of the Final Product ordered by Transaction Process Date
Realize that the first production has a Total Cost of -9.980 (due to a negative stock correction)

6. Create a Landed Cost
Go to Landed Cost Type Window and create a new record with:
  - Organization: F&B US
  - Name: LCT
  - Landed Cost Distribution Algorithm: Distribution by Amount
  - Account: Company Capital

Go to Landed Cost Window and create a new record with:
  - Organization: F&B US
Move to Cost Tab and create a new record with:
  - Landed Cost Type: LCT
  - Amount: 50000
  - Currency: USD
Move to Receipt Tab and create a new record with:
  - Goods Receipt: select the previously created Goods Receipt
Click on Process

Go back to Product window and check the transactions of the final Product
The first production transaction has a total cost of -109880 and has a new transaction cost entry
It should have two transaction costs, one unit cost of 100 usd and one not unit cost of -100000

7. Create another Landed Cost
Go to Landed Cost Window and create a new record with:
  - Organization: F&B US
Move to Cost Tab and create a new record with:
  - Landed Cost Type: LCT
  - Amount: 30000
  - Currency: USD
Move to Receipt Tab and create a new record with:
  - Goods Receipt: select the previously created Goods Receipt
Click on Process

Go back to Product window and check the transactions of the final Product
The first production transaction has a total cost of -169820 and has a new transaction cost entry that is unit cost and another that is not
The second production transaction now has a cost of 180
(0108956)
hgbot (developer)
2019-01-15 08:32

Repository: erp/devel/pi
Changeset: 11dbadbe4ba4e2fc35d84ff086b0395931fc1792
Author: David Miguelez <david.miguelez <at> openbravo.com>
Date: Mon Dec 17 17:50:52 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/11dbadbe4ba4e2fc35d84ff086b0395931fc1792 [^]

Fixes Issue 39822. Fixes issues when merging new cost adjustment lines
with existing ones.

To avoid creating more Adjusment Lines than needed, the process
tries to find existing cost adjustment lines and it adds the cost
adjusted to an existing line if any.
But when looking for existing lines it was not taking into account
the unit cost, negative correction or backdated flags.

To do so, it is necessary to send the parameters to the methods
that creates the lines. But adding more parameters to this
functions was too complex, as they already had many parameters.

What has been done is to create a new class to store the line information.
This class is initialized with just three parameters and the
rest are set to the default values.

Then, the developer can change any parameter with the setter methods.
This makes the code more clear and clean, instead of having a
function with more than 10 parameters, being 4 of them booleans,
now it creates a new object with three parameters and then it
sets the boolean values with methods that have a name with more
meaning.

After this change, all the information of the line is set through this
new object, so there is no need to change the line object afterwards,
since all the different parameters are set to the LineParameter object.

Changes:

Database:
* Change default value of needsposting column to use the same
  one as in AD and avoid confusion

CostAdjustmentLineParameters:
* New class to store lines information
* Does not allow to create adjustment lines with empty cost adjusment
  or empty Transaction
* Does not create an adjustment that is both negative and unit cost.
  This was not controlled before

CostAdjustmentUtils:
* Deprecated old methods that does not send the new flags
* Created new API to use the new LineParams object
* Modify query to take into account new flags
* Modify insert method to set all the parameters for the new
  Cost Adjusment Line

CostingAlgorithmAdjustmentImp:
* Modify inser line method to use new API

Adapted all the calls to old methods to use new API

---
M src-db/database/model/tables/M_COSTADJUSTMENTLINE.xml
M src-db/database/sourcedata/AD_MESSAGE.xml
M src/org/openbravo/costing/AverageCostAdjustment.java
M src/org/openbravo/costing/CostAdjustmentUtils.java
M src/org/openbravo/costing/CostingAlgorithmAdjustmentImp.java
M src/org/openbravo/costing/CostingServer.java
M src/org/openbravo/costing/FixBackdatedTransactionsProcess.java
M src/org/openbravo/costing/LCMatchingProcess.java
M src/org/openbravo/costing/LandedCostProcess.java
M src/org/openbravo/costing/ManualCostAdjustmentProcessHandler.java
M src/org/openbravo/costing/PriceDifferenceProcess.java
M src/org/openbravo/costing/StandardCostAdjustment.java
A src/org/openbravo/costing/CostAdjustmentLineParameters.java
---
(0108957)
hgbot (developer)
2019-01-15 08:32

Repository: erp/devel/pi
Changeset: 4b812cac3744deedf9f67de8ade01baa7b5d6650
Author: David Miguelez <david.miguelez <at> openbravo.com>
Date: Wed Dec 26 17:28:40 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/4b812cac3744deedf9f67de8ade01baa7b5d6650 [^]

Related to Issue 39822. Code Review Changes:

* Fixed typo in Message value
* Changed name of class variable from costAdjusted to adjustmentAmt (changed getter too)
* Added currency variable for parameters class
  * If not specified, it uses the currency of the transaction
  * If specified, it is used to create the line and to search
    for existing adjustment lines

---
M src-db/database/sourcedata/AD_MESSAGE.xml
M src/org/openbravo/costing/CostAdjustmentLineParameters.java
M src/org/openbravo/costing/CostAdjustmentUtils.java
M src/org/openbravo/costing/CostingAlgorithmAdjustmentImp.java
M src/org/openbravo/costing/LCMatchingProcess.java
M src/org/openbravo/costing/LandedCostProcess.java
---
(0108959)
hgbot (developer)
2019-01-15 08:32

Repository: erp/devel/pi
Changeset: 00f3ad11d13de112561ade277ad9512cb3c996fc
Author: David Miguelez <david.miguelez <at> openbravo.com>
Date: Mon Jan 14 12:10:40 2019 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/00f3ad11d13de112561ade277ad9512cb3c996fc [^]

Related to Issue 39822. Added previously deleted method and set it as deprecated
to avoid API Change.

This method however should be avoided as it should be removed in the future,
as the other deprecated methods in this issue.

---
M src/org/openbravo/costing/CostingAlgorithmAdjustmentImp.java
---
(0110724)
hudsonbot (developer)
2019-03-28 14:55

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
(0110725)
hudsonbot (developer)
2019-03-28 14:55

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
(0110727)
hudsonbot (developer)
2019-03-28 14:55

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

- Issue History
Date Modified Username Field Change
2018-12-17 16:19 dmiguelez New Issue
2018-12-17 16:19 dmiguelez Assigned To => Triage Finance
2018-12-17 16:19 dmiguelez Modules => Core
2018-12-17 16:19 dmiguelez Triggers an Emergency Pack => No
2018-12-17 16:20 dmiguelez Note Added: 0108649
2018-12-17 17:52 dmiguelez File Added: Proposal39822.diff
2018-12-20 15:08 ngarcia Issue Monitored: ngarcia
2019-01-10 09:51 jfrances Issue Monitored: jfrances
2019-01-15 08:32 hgbot Checkin
2019-01-15 08:32 hgbot Note Added: 0108956
2019-01-15 08:32 hgbot Status new => resolved
2019-01-15 08:32 hgbot Resolution open => fixed
2019-01-15 08:32 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/11dbadbe4ba4e2fc35d84ff086b0395931fc1792 [^]
2019-01-15 08:32 hgbot Checkin
2019-01-15 08:32 hgbot Note Added: 0108957
2019-01-15 08:32 hgbot Checkin
2019-01-15 08:32 hgbot Note Added: 0108959
2019-01-15 09:06 Sandrahuguet Assigned To Triage Finance => dmiguelez
2019-01-15 11:29 Sandrahuguet Review Assigned To => Sandrahuguet
2019-01-15 11:29 Sandrahuguet Status resolved => closed
2019-01-15 11:29 Sandrahuguet Fixed in Version => 3.0PR19Q2
2019-03-28 14:55 hudsonbot Checkin
2019-03-28 14:55 hudsonbot Note Added: 0110724
2019-03-28 14:55 hudsonbot Checkin
2019-03-28 14:55 hudsonbot Note Added: 0110725
2019-03-28 14:55 hudsonbot Checkin
2019-03-28 14:55 hudsonbot Note Added: 0110727


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker