Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0038307Openbravo ERP04. Warehouse managementpublic2018-04-10 13:462018-05-17 21:41
gorkaion 
gorkaion 
urgentmajoralways
closedfixed 
5
pi 
3.0PR18Q3 
aferraz
Core
No
0038307: Wrong negative correction amount when trx has no unit cost adjustments
Consider a receipt with a NO unit cost adjustment (a Landed Cost or Manual adjustment). If this receipt has to be also adjusted with the Negative Stock Correction the NO unit cost adjustment amount is not properly considered in the calculations and the effect in the Average Cost of the adjustment is lost.

When calculating the transaction price it should consider all adjustments except other negative stock corrections.

For example:

Scenario 1:

Receipt 1. 10 ud at 10EUR each. Avg Cost 10EUR/ud. (Trx Amt: 100EUR)
Shipment 1. -15 ud. (Trx Amt: -150EUR)
Receipt 2. 10 ud at 10EUR each. Landed Cost of 50EUR. (Trx Amt: 150EUR)

In this scenario the expected Avg Cost should be the price of the Receipt 2 taking into account the landed cost (100EUR+50EUR)/10 = 15 EUR/Ud.

But if Negative Stock Correction is enabled the trx Price is calculated considering only the Unit Cost adjustments so the average is reverted to 10EUR/Ud.

Scenario 2:
Receipt 1. 10 ud at 10EUR each. Avg Cost 10EUR/ud. (Trx Amt: 100EUR)
Shipment 1. -15 ud. (Trx Amt: -150EUR)
Receipt 2. 10 ud at 12EUR each. Landed Cost of 50EUR. (Trx Amt: 170EUR)

In this case the Price of the Receipt 2 should be 170EUR/10Ud = 17EUR/ud.That is the average cost that should be left after the negative stock correction.
1. In Costing Rules window enable the Fix Backdated Transaction for 2018 in the rule of F&B Spain.
2. In Preferences window add a new preference using property "Enable Negative Stock Corrections" and value "Y" for everyone.
Logout and login.
3. Create a new Product "Test" in F&B Spain with price 10EUR.
4. Create a Physical Inventory of 10ud with cost 10EUR.
5. Create another Physical Inventory that adds another 10ud with cost 10EUR and movement date 5 days after the first inventory.
6. Execute the Costing Background process.
7. In Product -> Transactions tab for the New product. Select the second inventory transaction and add a Manual Cost Adjustment. Amount 50EUR, incremental: Yes, unit cost: No.
8. Check that the costing of the inventory changes to 12.5 EUR/Ud.
9. Create a shipment with movement date between both physical inventories. Add the Test Product, quantity 15 Ud.
10. Execute the Costing Background process.
11. Check the Costing tab of the product and see that the second average cost has changed to 10EUR/Ud.
12. Check the Transaction Costs of the second inventory and see that there is a line related to a negative correction of -50EUR which should be -25EUR. To ensure that the average cost is 15EUR as the price of the inventory plus the manual adjustment.
When calculating the trxPrice we should also add the adjustment amounts that have Unit Cost = No and Is Negative Correction = No.

Or alternatively calculate it using the trxCost and subtracting the adjustment amounts with Unit Cost = No and Is Negative Correction = Yes
No tags attached.
related to defect 0038203 closed AtulOpenbravo Permanently adjusted transactions wrongly included in Cost Adjustment process. 
Issue History
2018-04-10 13:46gorkaionNew Issue
2018-04-10 13:46gorkaionAssigned To => Triage Finance
2018-04-10 13:46gorkaionModules => Core
2018-04-10 13:46gorkaionResolution time => 1525125600
2018-04-10 13:46gorkaionTriggers an Emergency Pack => No
2018-04-10 13:46gorkaionIssue generated from0038203
2018-04-10 13:46gorkaionRelationship addedrelated to 0038203
2018-04-10 16:16aferrazAssigned ToTriage Finance => collazoandy4
2018-04-18 02:36collazoandy4Statusnew => scheduled
2018-04-26 16:55ngarciaIssue Monitored: ngarcia
2018-05-11 14:01vmromanosAssigned Tocollazoandy4 => gorkaion
2018-05-14 12:45gorkaionAssigned Togorkaion => Triage Finance
2018-05-14 12:46gorkaionNote Added: 0104492
2018-05-17 12:51gorkaionSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=17153#r17153
2018-05-17 13:14hgbotCheckin
2018-05-17 13:14hgbotNote Added: 0104561
2018-05-17 13:14hgbotStatusscheduled => resolved
2018-05-17 13:14hgbotResolutionopen => fixed
2018-05-17 13:14hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/53de8c2379789a5560e17f93b26dc20895e10ed4 [^]
2018-05-17 13:14hgbotCheckin
2018-05-17 13:14hgbotNote Added: 0104562
2018-05-17 13:15aferrazAssigned ToTriage Finance => gorkaion
2018-05-17 13:15aferrazNote Added: 0104563
2018-05-17 13:15aferrazReview Assigned To => aferraz
2018-05-17 13:15aferrazNote Added: 0104564
2018-05-17 13:15aferrazStatusresolved => closed
2018-05-17 13:15aferrazFixed in Version => 3.0PR18Q3
2018-05-17 21:41hudsonbotCheckin
2018-05-17 21:41hudsonbotNote Added: 0104580
2018-05-17 21:41hudsonbotCheckin
2018-05-17 21:41hudsonbotNote Added: 0104581

Notes
(0104492)
gorkaion   
2018-05-14 12:46   
I sent a proposal patch to the team last friday. I'm not expecting more actions on my side.
(0104561)
hgbot   
2018-05-17 13:14   
Repository: erp/devel/pi
Changeset: 53de8c2379789a5560e17f93b26dc20895e10ed4
Author: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
Date: Wed May 16 18:30:19 2018 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/53de8c2379789a5560e17f93b26dc20895e10ed4 [^]

Fixes issue 38307: Wrong NSC when trx has no unit cost adjustments

When calculating the trxPrice we should take into account every adjustment amount (unit cost or not unit cost), but negative stock corrections.

---
M src-test/src/org/openbravo/test/costing/TestCostingLandedCost.java
M src-test/src/org/openbravo/test/costing/TestCostingNoSourceAdjustments.java
M src/org/openbravo/costing/AverageCostAdjustment.java
---
(0104562)
hgbot   
2018-05-17 13:14   
Repository: erp/devel/pi
Changeset: 6d9d6f5386411139029decf2b1304ed74779e098
Author: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
Date: Thu May 17 13:14:16 2018 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/6d9d6f5386411139029decf2b1304ed74779e098 [^]

Related to issue 38307: Remove unused prices in TestCostingLandedCost.java

---
M src-test/src/org/openbravo/test/costing/TestCostingLandedCost.java
---
(0104563)
aferraz   
2018-05-17 13:15   
Fix done by gorkaion.
(0104564)
aferraz   
2018-05-17 13:15   
Code review + Testing OK
(0104580)
hudsonbot   
2018-05-17 21:41   
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/4e28963f0fe6 [^]
Maturity status: Test
(0104581)
hudsonbot   
2018-05-17 21:41   
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/4e28963f0fe6 [^]
Maturity status: Test