details:   https://code.openbravo.com/erp/devel/pi/rev/5665f6599a48
changeset: 26394:5665f6599a48
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Wed Apr 29 13:56:15 2015 +0200
summary:   Fixes issue 29720: Wrong accounting in Cost Adjusment

Wrong accounting of the cost adjusment lines in case of Goods Movement From.
In this case, accounting should consider negative amounts, in order to have a 
net effect of the goods movement adjustment accounting as 0.

details:   https://code.openbravo.com/erp/devel/pi/rev/bb4b37bb475e
changeset: 26395:bb4b37bb475e
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Wed Apr 29 16:35:18 2015 +0200
summary:   Related to issue 29720: Modify TestCosting tests

Modify GM11, GM12, GM13 and GM5 tests, where cost adjustments from goods 
movements are created, to update accounting amounts

diffstat:

 src-test/src/org/openbravo/test/costing/TestCosting.java    |  37 ++++++------
 src/org/openbravo/erpCommon/ad_forms/DocCostAdjustment.java |  10 +-
 2 files changed, 23 insertions(+), 24 deletions(-)

diffs (144 lines):

diff -r 549146dc9be2 -r bb4b37bb475e 
src-test/src/org/openbravo/test/costing/TestCosting.java
--- a/src-test/src/org/openbravo/test/costing/TestCosting.java  Wed Mar 04 
16:09:45 2015 +0100
+++ b/src-test/src/org/openbravo/test/costing/TestCosting.java  Wed Apr 29 
16:35:18 2015 +0200
@@ -2835,12 +2835,12 @@
       // Post cost adjustment and assert it
       postDocument(costAdjustmentList.get(0));
       List<DocumentPostAssert> documentPostAssertList1 = new 
ArrayList<DocumentPostAssert>();
-      documentPostAssertList1.add(new DocumentPostAssert("35000", amount0, 
quantity2.multiply(
+      documentPostAssertList1.add(new DocumentPostAssert("35000", 
quantity2.multiply(price1).add(
+          quantity2.multiply(price2).negate()), amount0, null));
+      documentPostAssertList1.add(new DocumentPostAssert("61000", amount0, 
quantity2.multiply(
           price1).add(quantity2.multiply(price2).negate()), null));
       documentPostAssertList1.add(new DocumentPostAssert("61000", 
quantity2.multiply(price1).add(
           quantity2.multiply(price2).negate()), amount0, null));
-      documentPostAssertList1.add(new DocumentPostAssert("61000", 
quantity2.multiply(price1).add(
-          quantity2.multiply(price2).negate()), amount0, null));
       documentPostAssertList1.add(new DocumentPostAssert("35000", amount0, 
quantity2.multiply(
           price1).add(quantity2.multiply(price2).negate()), null));
       CostAdjustment costAdjustment1 = 
OBDal.getInstance().get(CostAdjustment.class,
@@ -2963,12 +2963,12 @@
       // Post cost adjustment and assert it
       postDocument(costAdjustmentList.get(0));
       List<DocumentPostAssert> documentPostAssertList1 = new 
ArrayList<DocumentPostAssert>();
-      documentPostAssertList1.add(new DocumentPostAssert("35000", amount0, 
quantity2.multiply(
+      documentPostAssertList1.add(new DocumentPostAssert("35000", 
quantity2.multiply(price1).add(
+          quantity2.multiply(price2).negate()), amount0, null));
+      documentPostAssertList1.add(new DocumentPostAssert("61000", amount0, 
quantity2.multiply(
           price1).add(quantity2.multiply(price2).negate()), null));
       documentPostAssertList1.add(new DocumentPostAssert("61000", 
quantity2.multiply(price1).add(
           quantity2.multiply(price2).negate()), amount0, null));
-      documentPostAssertList1.add(new DocumentPostAssert("61000", 
quantity2.multiply(price1).add(
-          quantity2.multiply(price2).negate()), amount0, null));
       documentPostAssertList1.add(new DocumentPostAssert("35000", amount0, 
quantity2.multiply(
           price1).add(quantity2.multiply(price2).negate()), null));
       CostAdjustment costAdjustment1 = 
OBDal.getInstance().get(CostAdjustment.class,
@@ -2982,12 +2982,12 @@
           price3).add(quantity1.multiply(price1).negate()), null));
       documentPostAssertList2.add(new DocumentPostAssert("35000", 
quantity1.multiply(price3).add(
           quantity1.multiply(price1).negate()), amount0, null));
-      documentPostAssertList2.add(new DocumentPostAssert("35000", 
quantity2.multiply(price3).add(
+      documentPostAssertList2.add(new DocumentPostAssert("35000", amount0, 
quantity2.multiply(
+          price3).add(quantity2.multiply(price1).negate()), null));
+      documentPostAssertList2.add(new DocumentPostAssert("61000", 
quantity2.multiply(price3).add(
           quantity2.multiply(price1).negate()), amount0, null));
       documentPostAssertList2.add(new DocumentPostAssert("61000", amount0, 
quantity2.multiply(
           price3).add(quantity2.multiply(price1).negate()), null));
-      documentPostAssertList2.add(new DocumentPostAssert("61000", amount0, 
quantity2.multiply(
-          price3).add(quantity2.multiply(price1).negate()), null));
       documentPostAssertList2.add(new DocumentPostAssert("35000", 
quantity2.multiply(price3).add(
           quantity2.multiply(price1).negate()), amount0, null));
       CostAdjustment costAdjustment2 = 
OBDal.getInstance().get(CostAdjustment.class,
@@ -3018,7 +3018,6 @@
     final BigDecimal price2 = new BigDecimal("10.00");
     final BigDecimal price3 = new BigDecimal("15.00");
     final BigDecimal price4 = new BigDecimal("11.9524");
-    final BigDecimal price5 = new BigDecimal("16.9524");
     final BigDecimal quantity1 = new BigDecimal("820");
     final BigDecimal quantity2 = new BigDecimal("400");
     final BigDecimal quantity3 = new BigDecimal("420");
@@ -3098,12 +3097,12 @@
       // Post cost adjustment and assert it
       postDocument(costAdjustmentList.get(0));
       List<DocumentPostAssert> documentPostAssertList1 = new 
ArrayList<DocumentPostAssert>();
-      documentPostAssertList1.add(new DocumentPostAssert("35000", amount0, 
quantity2.multiply(
+      documentPostAssertList1.add(new DocumentPostAssert("35000", 
quantity2.multiply(price1).add(
+          quantity2.multiply(price2).negate()), amount0, null));
+      documentPostAssertList1.add(new DocumentPostAssert("61000", amount0, 
quantity2.multiply(
           price1).add(quantity2.multiply(price2).negate()), null));
       documentPostAssertList1.add(new DocumentPostAssert("61000", 
quantity2.multiply(price1).add(
           quantity2.multiply(price2).negate()), amount0, null));
-      documentPostAssertList1.add(new DocumentPostAssert("61000", 
quantity2.multiply(price1).add(
-          quantity2.multiply(price2).negate()), amount0, null));
       documentPostAssertList1.add(new DocumentPostAssert("35000", amount0, 
quantity2.multiply(
           price1).add(quantity2.multiply(price2).negate()), null));
       CostAdjustment costAdjustment1 = 
OBDal.getInstance().get(CostAdjustment.class,
@@ -3117,12 +3116,12 @@
           price3).add(quantity1.multiply(price1).negate()), null));
       documentPostAssertList2.add(new DocumentPostAssert("35000", 
quantity1.multiply(price3).add(
           quantity1.multiply(price1).negate()), amount0, null));
-      documentPostAssertList2.add(new DocumentPostAssert("35000", 
quantity2.multiply(price3).add(
+      documentPostAssertList2.add(new DocumentPostAssert("35000", amount0, 
quantity2.multiply(
+          price3).add(quantity2.multiply(price2).negate()), null));
+      documentPostAssertList2.add(new DocumentPostAssert("61000", 
quantity2.multiply(price3).add(
           quantity2.multiply(price2).negate()), amount0, null));
       documentPostAssertList2.add(new DocumentPostAssert("61000", amount0, 
quantity2.multiply(
           price3).add(quantity2.multiply(price2).negate()), null));
-      documentPostAssertList2.add(new DocumentPostAssert("61000", amount0, 
quantity2.multiply(
-          price3).add(quantity2.multiply(price2).negate()), null));
       documentPostAssertList2.add(new DocumentPostAssert("35000", 
quantity2.multiply(price3).add(
           quantity2.multiply(price2).negate()), amount0, null));
       CostAdjustment costAdjustment2 = 
OBDal.getInstance().get(CostAdjustment.class,
@@ -3332,12 +3331,12 @@
       // Post cost adjustment and assert it
       postDocument(costAdjustmentList.get(2));
       List<DocumentPostAssert> documentPostAssertList3 = new 
ArrayList<DocumentPostAssert>();
-      documentPostAssertList3.add(new DocumentPostAssert("35000", amount0, 
quantity5.multiply(
+      documentPostAssertList3.add(new DocumentPostAssert("35000", 
quantity5.multiply(price3).add(
+          quantity5.multiply(price5).negate()), amount0, null));
+      documentPostAssertList3.add(new DocumentPostAssert("61000", amount0, 
quantity5.multiply(
           price3).add(quantity5.multiply(price5).negate()), null));
       documentPostAssertList3.add(new DocumentPostAssert("61000", 
quantity5.multiply(price3).add(
           quantity5.multiply(price5).negate()), amount0, null));
-      documentPostAssertList3.add(new DocumentPostAssert("61000", 
quantity5.multiply(price3).add(
-          quantity5.multiply(price5).negate()), amount0, null));
       documentPostAssertList3.add(new DocumentPostAssert("35000", amount0, 
quantity5.multiply(
           price3).add(quantity5.multiply(price5).negate()), null));
       CostAdjustment costAdjustment3 = 
OBDal.getInstance().get(CostAdjustment.class,
diff -r 549146dc9be2 -r bb4b37bb475e 
src/org/openbravo/erpCommon/ad_forms/DocCostAdjustment.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocCostAdjustment.java       Wed Mar 
04 16:09:45 2015 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocCostAdjustment.java       Wed Apr 
29 16:35:18 2015 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2014 Openbravo SLU
+ * All portions are Copyright (C) 2014-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -54,8 +54,8 @@
     super(AD_Client_ID, AD_Org_ID, connectionProvider);
   }
 
-  public void loadObjectFieldProvider(ConnectionProvider conn,
-      @SuppressWarnings("hiding") String AD_Client_ID, String Id) throws 
ServletException {
+  public void loadObjectFieldProvider(ConnectionProvider conn, 
@SuppressWarnings("hiding")
+  String AD_Client_ID, String Id) throws ServletException {
     setObjectFieldProvider(DocCostAdjustmentData.selectRegistro(conn, 
AD_Client_ID, Id));
   }
 
@@ -251,11 +251,11 @@
             + getAccountByWarehouse(AcctServer.ACCTTYPE_InvDifferences, as, 
line.getWarehouseId(),
                 conn).C_ValidCombination_ID);
         if (line.isTransactionNegative()) {
-          amtDebit = amount.toPlainString();
+          amtDebit = amount.negate().toPlainString();
           amtCredit = "";
         } else {
           amtDebit = "";
-          amtCredit = amount.toPlainString();
+          amtCredit = amount.negate().toPlainString();
         }
         fact.createLine(line, p.getAccount(ProductInfo.ACCTTYPE_P_Asset, as, 
conn),
             line.m_C_Currency_ID, amtDebit, amtCredit, Fact_Acct_Group_ID, 
nextSeqNo(SeqNo),

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to