details:   https://code.openbravo.com/erp/devel/pi/rev/b87f60cb229d
changeset: 26292:b87f60cb229d
user:      Unai Martirena <unai.martirena <at> openbravo.com>
date:      Mon Mar 30 11:14:37 2015 +0200
summary:   Fixes bug 29430: Net Unit Price in Costing is properly calculated


Using Cost Adjustments the Net Unit Price of a product on a transaction could 
be affected with those. Starting from now the Net Unit Price assigned in 
Costing tab is going to take into account the Cost Adjustments of type Unit 
Cost.

So the calculation would be: ((originalPrice * qty) + adjustmentsAmount) / qty.

details:   https://code.openbravo.com/erp/devel/pi/rev/8f36b14dbc05
changeset: 26293:8f36b14dbc05
user:      Unai Martirena <unai.martirena <at> openbravo.com>
date:      Mon Mar 30 11:15:30 2015 +0200
summary:   Related to bug 29430: Adapt de test to the new behavior

diffstat:

 src-test/src/org/openbravo/test/costing/TestCosting.java |  126 +++++++-------
 src/org/openbravo/costing/AverageCostAdjustment.java     |   30 ++-
 2 files changed, 82 insertions(+), 74 deletions(-)

diffs (truncated from 594 to 300 lines):

diff -r 82682f61da0c -r 8f36b14dbc05 
src-test/src/org/openbravo/test/costing/TestCosting.java
--- a/src-test/src/org/openbravo/test/costing/TestCosting.java  Fri Mar 27 
14:02:59 2015 +0100
+++ b/src-test/src/org/openbravo/test/costing/TestCosting.java  Mon Mar 30 
11:15:30 2015 +0200
@@ -442,7 +442,7 @@
       List<ProductCostingAssert> productCostingAssertList = new 
ArrayList<ProductCostingAssert>();
       productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(0), price1, null,
           price1, quantity1));
-      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(1), price5, price4,
+      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(1), price3, price4,
           price5, quantity1.add(quantity2)));
       assertProductCosting(product.getId(), productCostingAssertList);
 
@@ -999,7 +999,7 @@
           price2, quantity2));
       productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(1), price2, price1,
           price2, quantity2.add(quantity3)));
-      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(3), price6, price5,
+      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(3), price4, price5,
           price6, 
quantity2.add(quantity3).add((quantity4).negate()).add(quantity5)));
       productCostingAssertList
           .add(new ProductCostingAssert(transactionList.get(4), price4, 
price3, price7, quantity2
@@ -1618,7 +1618,7 @@
       List<ProductCostingAssert> productCostingAssertList = new 
ArrayList<ProductCostingAssert>();
       productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(0), price1, null,
           price1, quantity1));
-      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(1), price2, price3,
+      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(1), price4, price3,
           price2, quantity2));
       assertProductCosting(product.getId(), productCostingAssertList);
 
@@ -2543,7 +2543,7 @@
       List<ProductCostingAssert> productCostingAssertList = new 
ArrayList<ProductCostingAssert>();
       productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(1), price1, price2,
           price1, quantity2));
-      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(0), price5, price3,
+      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(0), price4, price3,
           price6, quantity3));
       assertProductCosting(product.getId(), productCostingAssertList);
 
@@ -2814,7 +2814,7 @@
       productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(2), WAREHOUSE2_ID,
           price2, price1, price2, quantity2));
       productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(1), WAREHOUSE1_ID,
-          price5, price5, price4, quantity3));
+          price2, price5, price4, quantity3));
       assertProductCosting(product.getId(), productCostingAssertList);
 
       // Assert cost adjustment
@@ -2938,7 +2938,7 @@
       productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(2), WAREHOUSE2_ID,
           price4, price1, price4, quantity2));
       productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(1), WAREHOUSE1_ID,
-          price5, price6, price5, quantity3));
+          price3, price6, price5, quantity3));
       assertProductCosting(product.getId(), productCostingAssertList);
 
       // Assert cost adjustment
@@ -3073,7 +3073,7 @@
       productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(2), WAREHOUSE2_ID,
           price3, price1, price3, quantity2));
       productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(1), WAREHOUSE1_ID,
-          price5, price4, price3, quantity3));
+          price3, price4, price3, quantity3));
       assertProductCosting(product.getId(), productCostingAssertList);
 
       // Assert cost adjustment
@@ -3263,9 +3263,9 @@
       productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(1), WAREHOUSE2_ID,
           price3, price2, price3, quantity1));
       productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(4), WAREHOUSE1_ID,
-          price6, price3, price6, quantity6));
+          price4, price3, price6, quantity6));
       productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(6), WAREHOUSE1_ID,
-          price7, price8, price7, quantity7));
+          price5, price8, price7, quantity7));
       productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(5), WAREHOUSE2_ID,
           price9, null, price9, quantity2));
       assertProductCosting(product.getId(), productCostingAssertList);
@@ -3456,7 +3456,7 @@
       // Assert product costing
       List<MaterialTransaction> transactionList2 = 
getProductTransactions(product.getId());
       List<ProductCostingAssert> productCostingAssertList2 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(0), price4,
+      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(0), price1,
           price1, price4, quantity1));
       assertProductCosting(product.getId(), productCostingAssertList2);
 
@@ -4065,7 +4065,7 @@
       List<ProductCostingAssert> productCostingAssertList = new 
ArrayList<ProductCostingAssert>();
       productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(0), price2, price1,
           price2, quantity1));
-      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(1), price4, price5,
+      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(1), price2, price5,
           price4, quantity1.add(quantity2.negate())));
       assertProductCosting(product.getId(), productCostingAssertList);
 
@@ -4394,7 +4394,7 @@
       // Assert product costing
       List<MaterialTransaction> transactionList = 
getProductTransactions(product.getId());
       List<ProductCostingAssert> productCostingAssertList = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(0), price5, price1,
+      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(0), price2, price1,
           price5, quantity1));
       assertProductCosting(product.getId(), productCostingAssertList);
 
@@ -4517,11 +4517,11 @@
       // Assert product costing
       List<MaterialTransaction> transactionList = 
getProductTransactions(product.getId());
       List<ProductCostingAssert> productCostingAssertList = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(0), price5, price1,
+      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(0), price4, price1,
           price5, quantity2));
-      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(1), price5, price1,
+      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(1), price4, price1,
           price5, quantity2.add(quantity3)));
-      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(2), price5, price1,
+      productCostingAssertList.add(new 
ProductCostingAssert(transactionList.get(2), price4, price1,
           price5, quantity2.add(quantity3).add(quantity4)));
       assertProductCosting(product.getId(), productCostingAssertList);
 
@@ -4773,11 +4773,11 @@
       List<ProductCostingAssert> productCostingAssertList1 = new 
ArrayList<ProductCostingAssert>();
       productCostingAssertList1.add(new ProductCostingAssert(null, null, null, 
price1, null,
           costType));
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(0), price6,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(0), price1,
           price1, price6, quantity1));
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(1), price7,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(1), price1,
           price1, price12, quantity1.add(quantity3)));
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(2), price8,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(2), price1,
           price1, price13, quantity1.add(quantity3).add(quantity5)));
       assertProductCosting(product1.getId(), productCostingAssertList1);
 
@@ -4786,11 +4786,11 @@
       List<ProductCostingAssert> productCostingAssertList2 = new 
ArrayList<ProductCostingAssert>();
       productCostingAssertList2.add(new ProductCostingAssert(null, null, null, 
price2, null,
           costType));
-      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(0), price9,
+      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(0), price2,
           price2, price9, quantity2));
-      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(1), price14,
+      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(1), price5,
           price2, price14, quantity2.add(quantity4)));
-      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(2), price11,
+      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(2), price2,
           price2, price15, quantity2.add(quantity4).add(quantity6)));
       assertProductCosting(product2.getId(), productCostingAssertList2);
 
@@ -4952,14 +4952,14 @@
       // Assert product costing 1
       List<MaterialTransaction> transactionList1 = 
getProductTransactions(product1.getId());
       List<ProductCostingAssert> productCostingAssertList1 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(0), price5,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(0), price1,
           price1, price5, quantity1));
       assertProductCosting(product1.getId(), productCostingAssertList1);
 
       // Assert product costing 2
       List<MaterialTransaction> transactionList2 = 
getProductTransactions(product2.getId());
       List<ProductCostingAssert> productCostingAssertList2 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(0), price6,
+      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(0), price2,
           price2, price6, quantity2));
       assertProductCosting(product2.getId(), productCostingAssertList2);
 
@@ -5070,14 +5070,14 @@
       // Assert product costing 1
       List<MaterialTransaction> transactionList1 = 
getProductTransactions(product1.getId());
       List<ProductCostingAssert> productCostingAssertList1 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(0), price6,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(0), price1,
           price1, price6, quantity1));
       assertProductCosting(product1.getId(), productCostingAssertList1);
 
       // Assert product costing 2
       List<MaterialTransaction> transactionList2 = 
getProductTransactions(product2.getId());
       List<ProductCostingAssert> productCostingAssertList2 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(0), price7,
+      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(0), price2,
           price2, price7, quantity2));
       assertProductCosting(product2.getId(), productCostingAssertList2);
 
@@ -5253,14 +5253,14 @@
       // Assert product costing 1
       List<MaterialTransaction> transactionList1 = 
getProductTransactions(product1.getId());
       List<ProductCostingAssert> productCostingAssertList1 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(0), price9,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(0), price1,
           price1, price9, quantity2));
       assertProductCosting(product1.getId(), productCostingAssertList1);
 
       // Assert product costing 2
       List<MaterialTransaction> transactionList2 = 
getProductTransactions(product2.getId());
       List<ProductCostingAssert> productCostingAssertList2 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(0), price11,
+      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(0), price10,
           price10, price11, quantity1));
       assertProductCosting(product2.getId(), productCostingAssertList2);
 
@@ -5412,7 +5412,7 @@
       // Assert product costing
       List<MaterialTransaction> transactionList = 
getProductTransactions(product.getId());
       List<ProductCostingAssert> productCostingAssertList1 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price4,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price1,
           price1, price4, quantity1));
       assertProductCosting(product.getId(), productCostingAssertList1);
 
@@ -5487,7 +5487,7 @@
       // Assert product costing
       List<MaterialTransaction> transactionList = 
getProductTransactions(product.getId());
       List<ProductCostingAssert> productCostingAssertList1 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price4,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price1,
           price1, price4, quantity1));
       assertProductCosting(product.getId(), productCostingAssertList1);
 
@@ -5584,7 +5584,7 @@
       // Assert product costing
       List<MaterialTransaction> transactionList = 
getProductTransactions(product.getId());
       List<ProductCostingAssert> productCostingAssertList1 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price6,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price1,
           price1, price6, quantity1));
       assertProductCosting(product.getId(), productCostingAssertList1);
 
@@ -5681,7 +5681,7 @@
       // Assert product costing
       List<MaterialTransaction> transactionList = 
getProductTransactions(product.getId());
       List<ProductCostingAssert> productCostingAssertList1 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price6,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price1,
           price1, price6, quantity1));
       assertProductCosting(product.getId(), productCostingAssertList1);
 
@@ -5781,7 +5781,7 @@
       // Assert product costing
       List<MaterialTransaction> transactionList = 
getProductTransactions(product.getId());
       List<ProductCostingAssert> productCostingAssertList1 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price6,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price1,
           price1, price6, quantity1));
       assertProductCosting(product.getId(), productCostingAssertList1);
 
@@ -5876,7 +5876,7 @@
       // Assert product costing
       List<MaterialTransaction> transactionList = 
getProductTransactions(product.getId());
       List<ProductCostingAssert> productCostingAssertList1 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price6,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price1,
           price1, price6, quantity1));
       assertProductCosting(product.getId(), productCostingAssertList1);
 
@@ -5957,7 +5957,7 @@
       // Assert product costing 1
       List<MaterialTransaction> transactionList1 = 
getProductTransactions(product1.getId());
       List<ProductCostingAssert> productCostingAssertList1 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(0), price4,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(0), price1,
           price1, price4, quantity1));
       assertProductCosting(product1.getId(), productCostingAssertList1);
 
@@ -6066,7 +6066,7 @@
       // Assert product costing
       List<MaterialTransaction> transactionList = 
getProductTransactions(product.getId());
       List<ProductCostingAssert> productCostingAssertList1 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price6,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price1,
           price1, price6, quantity1));
       assertProductCosting(product.getId(), productCostingAssertList1);
 
@@ -6238,7 +6238,7 @@
       // Assert product costing
       List<MaterialTransaction> transactionList = 
getProductTransactions(product.getId());
       List<ProductCostingAssert> productCostingAssertList1 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price6,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList.get(0), price1,
           price1, price6, quantity1));
       assertProductCosting(product.getId(), productCostingAssertList1);
 
@@ -6297,7 +6297,7 @@
       // Assert product costing
       List<MaterialTransaction> transactionList2 = 
getProductTransactions(product.getId());
       List<ProductCostingAssert> productCostingAssertList2 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(0), price7,
+      productCostingAssertList2.add(new 
ProductCostingAssert(transactionList2.get(0), price1,
           price1, price7, quantity1));
       assertProductCosting(product.getId(), productCostingAssertList2);
 
@@ -6451,7 +6451,7 @@
       // Assert product costing 1
       List<MaterialTransaction> transactionList1 = 
getProductTransactions(product1.getId());
       List<ProductCostingAssert> productCostingAssertList1 = new 
ArrayList<ProductCostingAssert>();
-      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(0), price6,
+      productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(0), price1,
           price1, price6, quantity1));
       productCostingAssertList1.add(new 
ProductCostingAssert(transactionList1.get(1), price1,
           price1, price7, quantity1.add(quantity6)));

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to