Fixes issue 29736: Wrong accounting in Cost Adjusment
authorAlvaro Ferraz <alvaro.ferraz@openbravo.com>
Wed, 29 Apr 2015 13:56:15 +0200
changeset 26665 95ec611b34c2
parent 26664 5350a1553674
child 26666 f448061a64cf
Fixes issue 29736: 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.
src/org/openbravo/erpCommon/ad_forms/DocCostAdjustment.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocCostAdjustment.java	Wed Apr 29 16:51:01 2015 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/DocCostAdjustment.java	Wed Apr 29 13:56:15 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),