details:   https://code.openbravo.com/erp/devel/main/rev/7abaeb58412f
changeset: 19636:7abaeb58412f
user:      Eduardo Argal Guibert <eduardo.argal <at> openbravo.com>
date:      Thu Feb 14 12:31:52 2013 +0100
summary:   Fixes bug 23061

details:   https://code.openbravo.com/erp/devel/main/rev/88b698e7fedc
changeset: 19637:88b698e7fedc
user:      Eduardo Argal Guibert <eduardo.argal <at> openbravo.com>
date:      Fri Feb 15 11:31:06 2013 +0100
summary:   Fixes bug 23061

diffstat:

 src/org/openbravo/erpCommon/ad_forms/DocInOut.java          |  31 +++++++++---
 src/org/openbravo/erpCommon/ad_forms/DocLineInOut_data.xsql |   5 +-
 src/org/openbravo/erpCommon/ad_forms/DocLine_Material.java  |   9 +++
 3 files changed, 36 insertions(+), 9 deletions(-)

diffs (136 lines):

diff -r a1c3c8369588 -r 88b698e7fedc 
src/org/openbravo/erpCommon/ad_forms/DocInOut.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocInOut.java        Fri Feb 15 
10:45:06 2013 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInOut.java        Fri Feb 15 
11:31:06 2013 +0100
@@ -107,6 +107,7 @@
       DocLine_Material docLine = new DocLine_Material(DocumentType, Record_ID, 
Line_ID);
       docLine.loadAttributes(data[i], this);
       docLine.setQty(data[i].getField("MOVEMENTQTY"), conn); // sets Trx
+      docLine.setBreakdownQty(data[i].getField("BREAKDOWNQTY"));
       // and
       // Storage
       // Qty
@@ -183,7 +184,6 @@
     // Line pointers
     FactLine dr = null;
     FactLine cr = null;
-    String strScale = DocInOutData.selectClientCurrencyPrecission(conn, 
vars.getClient());
     // Sales or Return from Customer
     if (DocumentType.equals(AcctServer.DOCTYPE_MatShipment)) {
       Boolean matReturn = IsReturn.equals("Y");
@@ -198,6 +198,13 @@
         } else if (line.transaction != null && line.transaction.getCurrency() 
!= null) {
           costCurrency = line.transaction.getCurrency();
         }
+        int standardPrecision = 2;
+        OBContext.setAdminMode(false);
+        try {
+          standardPrecision = costCurrency.getStandardPrecision().intValue();
+        } finally {
+          OBContext.restorePreviousMode();
+        }
         C_Currency_ID = costCurrency.getId();
         Account cogsAccount = null;
         if (matReturn) {
@@ -254,8 +261,8 @@
               + line.getAccount(ProductInfo.ACCTTYPE_P_Cogs, as, conn));
           log4jDocInOut.debug("(MatShipment) - DR costs: " + costs);
         }
-        BigDecimal b_Costs = new BigDecimal(costs).setScale(new 
Integer(strScale),
-            RoundingMode.HALF_UP);
+        BigDecimal b_Costs = new BigDecimal(costs).multiply(new 
BigDecimal(line.getBreakdownQty()))
+            .divide(new BigDecimal(line.m_qty), standardPrecision, 
RoundingMode.HALF_UP);
         String strCosts = b_Costs.toString();
         if (b_Costs.compareTo(BigDecimal.ZERO) == 0 && 
!CostingStatus.getInstance().isMigrated()
             && DocInOutData.existsCost(conn, DateAcct, 
line.m_M_Product_ID).equals("0")) {
@@ -310,6 +317,13 @@
           costCurrency = line.transaction.getCurrency();
         }
         C_Currency_ID = costCurrency.getId();
+        int standardPrecision = 2;
+        OBContext.setAdminMode(false);
+        try {
+          standardPrecision = costCurrency.getStandardPrecision().intValue();
+        } finally {
+          OBContext.restorePreviousMode();
+        }
         String costs = "0";
         String strCosts = "0";
         if (product.isBookUsingPurchaseOrderPrice()) {
@@ -325,8 +339,8 @@
             setMessageResult(conn, STATUS_NoRelatedPO, "error", parameters);
             throw new IllegalStateException();
           }
-          costs = 
ol.getUnitPrice().multiply(inOutLine.getMovementQuantity()).toString();
-          BigDecimal b_Costs = new BigDecimal(costs).setScale(new 
Integer(strScale),
+          costs = ol.getUnitPrice().multiply(new 
BigDecimal(line.getBreakdownQty())).toString();
+          BigDecimal b_Costs = new 
BigDecimal(costs).setScale(standardPrecision,
               RoundingMode.HALF_UP);
           strCosts = b_Costs.toString();
         } else {
@@ -350,8 +364,9 @@
             }
           }
           costs = line.getProductCosts(DateAcct, as, conn, con);
-          BigDecimal b_Costs = new BigDecimal(costs).setScale(new 
Integer(strScale),
-              RoundingMode.HALF_UP);
+          BigDecimal b_Costs = new BigDecimal(costs).multiply(
+              new BigDecimal(line.getBreakdownQty())).divide(new 
BigDecimal(line.m_qty),
+              standardPrecision, RoundingMode.HALF_UP);
           strCosts = b_Costs.toString();
           if (b_Costs.compareTo(BigDecimal.ZERO) == 0 && 
!CostingStatus.getInstance().isMigrated()
               && DocInOutData.existsCost(conn, DateAcct, 
line.m_M_Product_ID).equals("0")) {
@@ -533,7 +548,7 @@
                 } else {
                   trxCost = 
CostingUtils.getStandardCost(inOutLine.getProduct(), legalEntity,
                       inOut.getAccountingDate(), costDimensions, 
legalEntity.getCurrency())
-                      .multiply(inOutLine.getMovementQuantity());
+                      .multiply(new BigDecimal(data[i].breakdownqty));
                 }
               }
             }
diff -r a1c3c8369588 -r 88b698e7fedc 
src/org/openbravo/erpCommon/ad_forms/DocLineInOut_data.xsql
--- a/src/org/openbravo/erpCommon/ad_forms/DocLineInOut_data.xsql       Fri Feb 
15 10:45:06 2013 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/DocLineInOut_data.xsql       Fri Feb 
15 11:31:06 2013 +0100
@@ -27,12 +27,15 @@
     <Sql>
       <![CDATA[
           SELECT COALESCE(A.AD_ORG_ID,IO.AD_ORG_ID) AS AD_ORG_ID, 
IO.M_PRODUCT_ID, IO.LINE, IO.DESCRIPTION,
-          IO.C_UOM_ID, IO.M_INOUTLINE_ID, COALESCE(A.Quantity, IO.MOVEMENTQTY) 
as MOVEMENTQTY, IO.M_LOCATOR_ID,
+          IO.C_UOM_ID, IO.M_INOUTLINE_ID, IO.M_LOCATOR_ID,
+          COALESCE(A.Quantity, IO.MOVEMENTQTY) as BREAKDOWNQTY, 
+          IO.MOVEMENTQTY as MOVEMENTQTY, 
           A.C_Campaign_ID, COALESCE(A.C_Project_Id, IO.C_Project_Id) AS 
C_Project_Id, COALESCE(A.User1_ID, IO.User1_ID) AS user1Id,
           COALESCE(A.User2_ID, IO.User2_ID) AS user2Id, 
COALESCE(A.C_Costcenter_ID, IO.C_Costcenter_ID) AS C_Costcenter_ID,
           COALESCE(A.A_Asset_ID,IO.A_Asset_ID) AS A_Asset_ID, 
COALESCE(A.C_BPartner_ID, IO.C_BPartner_ID) AS C_BPartner_ID, A.C_Activity_ID
           FROM M_InOutLine IO left join M_InOutLine_AcctDimension A ON 
IO.M_InOutLine_ID = A.M_InOutLine_ID
           WHERE M_InOut_ID=?
+          AND COALESCE(A.Quantity, IO.MOVEMENTQTY) <> 0
           ORDER BY Line
      ]]>
      </Sql>
diff -r a1c3c8369588 -r 88b698e7fedc 
src/org/openbravo/erpCommon/ad_forms/DocLine_Material.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocLine_Material.java        Fri Feb 
15 10:45:06 2013 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/DocLine_Material.java        Fri Feb 
15 11:31:06 2013 +0100
@@ -54,6 +54,7 @@
   /** Production */
   public String m_Productiontype = "";
   public MaterialTransaction transaction = null;
+  public String m_breakdownqty = "";
 
   /**
    * Set Trasaction Quantity and Storage Qty
@@ -129,6 +130,14 @@
     return p_productInfo.getAccount(AcctType, as, conn);
   } // getAccount
 
+  public String getBreakdownQty() {
+    return m_breakdownqty;
+  }
+
+  public void setBreakdownQty(String breakdownqty) {
+    this.m_breakdownqty = breakdownqty;
+  }
+
   public String getServletInfo() {
     return "Servlet for the accounting";
   } // end of getServletInfo() method

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to