Backout of issue 19469
authorJavier Etxarri <javier.echarri@openbravo.com>
Wed, 29 Feb 2012 18:34:57 +0100
changeset 15669 6de349321d77
parent 15668 62eb2ad3d760
child 15670 3d1ceed5bdb1
Backout of issue 19469
src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java
src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice_data.xsql
--- a/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java	Wed Feb 29 18:27:27 2012 +0100
+++ b/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java	Wed Feb 29 18:34:57 2012 +0100
@@ -450,7 +450,6 @@
     CreateFromInvoiceData[] data = null;
     XmlDocument xmlDocument;
     String strPO = vars.getStringParameter("inpPurchaseOrder");
-    String strPI = vars.getSessionValue(strWindowId + "|C_INVOICE_ID");
     String strShipment = vars.getStringParameter("inpShipmentReciept");
     final String isSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId);
     if (vars.commandIn("FIND_PO"))
@@ -473,7 +472,7 @@
                 Utility.getContext(this, vars, "#User_Client", strWindowId),
                 Utility.getContext(this, vars, "#User_Org", strWindowId), strPO);
           else
-            data = CreateFromInvoiceData.selectFromPO(this, vars.getLanguage(), strPI,
+            data = CreateFromInvoiceData.selectFromPO(this, vars.getLanguage(),
                 Utility.getContext(this, vars, "#User_Client", strWindowId),
                 Utility.getContext(this, vars, "#User_Org", strWindowId), strPO);
         } else {
@@ -482,7 +481,7 @@
                 Utility.getContext(this, vars, "#User_Client", strWindowId),
                 Utility.getContext(this, vars, "#User_Org", strWindowId), strPO);
           else
-            data = CreateFromInvoiceData.selectFromPOTrl(this, vars.getLanguage(), strPI,
+            data = CreateFromInvoiceData.selectFromPOTrl(this, vars.getLanguage(),
                 Utility.getContext(this, vars, "#User_Client", strWindowId),
                 Utility.getContext(this, vars, "#User_Org", strWindowId), strPO);
         }
@@ -1451,7 +1450,6 @@
     final String strClaves = Utility.stringList(vars.getRequiredInParameter("inpcOrderId",
         IsIDFilter.instance));
     final String isSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId);
-    String strPI = vars.getSessionValue(strWindowId + "|C_INVOICE_ID");
     String strPO = "", priceActual = "0", priceLimit = "0", priceList = "0", strPriceListVersion = "", priceStd = "0";
     CreateFromInvoiceData[] data = null;
     CreateFromInvoiceData[] dataAux = null;
@@ -1480,7 +1478,7 @@
           if (isSOTrx.equals("Y"))
             data = CreateFromInvoiceData.selectFromPOUpdateSOTrx(conn, this, ids[k]);
           else
-            data = CreateFromInvoiceData.selectFromPOUpdate(conn, this, strPI, ids[k]);
+            data = CreateFromInvoiceData.selectFromPOUpdate(conn, this, ids[k]);
         }
         if (data != null) {
           for (int i = 0; i < data.length; i++) {
--- a/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice_data.xsql	Wed Feb 29 18:27:27 2012 +0100
+++ b/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice_data.xsql	Wed Feb 29 18:34:57 2012 +0100
@@ -29,11 +29,7 @@
       <![CDATA[
         SELECT o.C_ORDER_ID as ID, Ad_Column_Identifier(to_char('C_Order'), to_char(o.c_order_id), to_char(?)) AS NAME, o.DocumentNo AS NAMEORDER,
         '' AS NAMESHIPMENT,
-        l.QtyOrdered-SUM(COALESCE(m.Qty,0))-COALESCE((SELECT SUM(COALESCE(CI.QtyINVOICED, 0))  
-       FROM C_ORDERLINE CO LEFT JOIN C_INVOICELINE CI ON CI.C_ORDERLINE_ID = CO.C_ORDERLINE_ID
-       WHERE  CI.C_INVOICE_ID=? AND CO.C_ORDERLINE_ID = l.c_orderline_id
-       GROUP BY CI.C_orderline_id , CO.QtyORDERED),0) AS QTY, 
-       l.C_UOM_ID,uom.UOMSymbol, l.M_Product_ID,p.NAME AS RELATION_NAME, 
+        l.QtyOrdered-SUM(COALESCE(m.Qty,0)) AS QTY, l.C_UOM_ID,uom.UOMSymbol, l.M_Product_ID,p.NAME AS RELATION_NAME, 
         l.C_OrderLine_ID,l.Line, l.ad_org_id, '' as STDPRECISION, 
         '' as M_InOutLine_ID, '' AS PriceActual, '' AS PriceList, '' AS PriceLimit, '' AS Description, '' as PriceStd,
         '' AS QUANTITYORDER, '' AS M_Product_UOM_ID, '' AS M_ATTRIBUTESETINSTANCE_ID, '' AS M_Offer_ID, '' AS PricePrecision,
@@ -49,11 +45,6 @@
         AND l.C_UOM_ID=uom.C_UOM_ID
         AND l.M_Product_ID=p.M_Product_ID
         AND l.C_Order_ID = ? 
-        AND NOT EXISTS (SELECT 1
-                       FROM C_ORDERLINE CO LEFT JOIN C_INVOICELINE CI ON CI.C_ORDERLINE_ID = CO.C_ORDERLINE_ID
-                       WHERE CO.C_ORDERLINE_ID = l.c_orderline_id AND CI.C_INVOICE_ID=?
-                       GROUP BY CI.C_orderline_id , CO.QtyORDERED
-                       HAVING (SUM(COALESCE(CI.QtyINVOICED, 0))-COALESCE(CO.QtyORDERED,0)) = 0 )   
         GROUP BY o.C_ORDER_ID, o.DocumentNo, o.DateOrdered, o.GrandTotal, l.QtyOrdered,l.C_UOM_ID,
         uom.UOMSymbol,l.M_Product_ID,p.NAME,l.Line,l.C_OrderLine_ID, l.ad_org_id, l.taxbaseamt,l.CancelPriceAD
         HAVING (l.QtyOrdered-SUM(COALESCE(m.Qty,0))) <> 0
@@ -62,11 +53,9 @@
     </Sql>
     <Field name="rownum" value="count"/>
     <Parameter name="language"/>
-    <Parameter name="piId"/>
     <Parameter name="adUserClient" type="replace" optional="true" after="o.AD_Client_ID IN (" text="'1'"/>
     <Parameter name="adOrgClient" type="replace" optional="true" after="o.AD_Org_ID IN (" text="'1'"/>
     <Parameter name="poId"/>
-    <Parameter name="piId"/>
   </SqlMethod>
   <SqlMethod name="selectFromPOCombo" type="preparedStatement" return="multiple">
     <SqlMethodComment></SqlMethodComment>
@@ -146,12 +135,7 @@
     <Sql>
       <![CDATA[
         SELECT o.C_ORDER_ID as ID, Ad_Column_Identifier(to_char('C_Order'), to_char(o.c_order_id), to_char(?)) AS NAME, o.DocumentNo AS NAMEORDER,
-        l.QtyOrdered-SUM(COALESCE(m.Qty,0))-
-        COALESCE((SELECT SUM(COALESCE(CI.QtyINVOICED, 0))  
-        FROM C_ORDERLINE CO LEFT JOIN C_INVOICELINE CI ON CI.C_ORDERLINE_ID = CO.C_ORDERLINE_ID
-        WHERE  CI.C_INVOICE_ID=? AND CO.C_ORDERLINE_ID = l.c_orderline_id
-        GROUP BY CI.C_orderline_id , CO.QtyORDERED),0) AS QTY, 
-        l.C_UOM_ID, COALESCE(uomt.UOMSYMBOL, uom.UOMSymbol) AS UOMSymbol, 
+        l.QtyOrdered-SUM(COALESCE(m.Qty,0)) AS QTY, l.C_UOM_ID, COALESCE(uomt.UOMSYMBOL, uom.UOMSymbol) AS UOMSymbol, 
         l.M_Product_ID,p.NAME AS RELATION_NAME, l.C_OrderLine_ID,l.Line, l.taxbaseamt 
         FROM C_UOM uom left join  C_UOM_TRL uomt on uom.C_UOM_ID = uomt.C_UOM_ID
                                                 and uomt.AD_Language = ?,
@@ -166,11 +150,6 @@
         AND l.C_UOM_ID=uom.C_UOM_ID 
         AND l.M_Product_ID=p.M_Product_ID  
         AND l.C_Order_ID = ? 
-        AND NOT EXISTS (SELECT 1
-                       FROM C_ORDERLINE CO LEFT JOIN C_INVOICELINE CI ON CI.C_ORDERLINE_ID = CO.C_ORDERLINE_ID
-                       WHERE CO.C_ORDERLINE_ID = l.c_orderline_id AND CI.C_INVOICE_ID=?
-                       GROUP BY CI.C_orderline_id , CO.QtyORDERED
-                       HAVING (SUM(COALESCE(CI.QtyINVOICED, 0))-COALESCE(CO.QtyORDERED,0)) = 0 )  
         GROUP BY o.C_ORDER_ID, o.DocumentNo, o.DateOrdered, o.GrandTotal, l.QtyOrdered,l.C_UOM_ID,
         uom.UOMSymbol, uomt.UOMSYMBOL,l.M_Product_ID,p.NAME,l.Line,l.C_OrderLine_ID,
         l.taxbaseamt 
@@ -180,12 +159,10 @@
     </Sql>
     <Field name="rownum" value="count"/>
     <Parameter name="adLanguage"/>
-    <Parameter name="piId"/>
     <Parameter name="adUserClient" type="replace" optional="true" after="o.AD_Client_ID IN (" text="'1'"/>
     <Parameter name="adOrgClient" type="replace" optional="true" after="o.AD_Org_ID IN (" text="'1'"/>
     <Parameter name="adLanguage"/>
     <Parameter name="poId"/>
-    <Parameter name="piId"/>
   </SqlMethod>
   <SqlMethod name="selectFromPOTrlSOTrx" type="preparedStatement" return="multiple">
     <SqlMethodComment></SqlMethodComment>
@@ -228,16 +205,9 @@
       (CASE WHEN B.M_InOutLine_ID IS NULL THEN A.M_Product_UOM_ID ELSE B.M_Product_UOM_ID END) AS M_Product_UOM_ID, A.M_ATTRIBUTESETINSTANCE_ID, A.ad_org_id,
       A.taxbaseamt
       FROM c_currency cur,C_UOM uom, M_PRODUCT p, 
-      (SELECT l.ad_org_id,l.C_CURRENCY_ID,l.C_UOM_ID, l.M_Product_ID, l.Line, l.Description, l.C_OrderLine_ID, (l.QtyOrdered-SUM(COALESCE(mp.Qty,0))-
-       COALESCE((SELECT SUM(COALESCE(CI.QtyINVOICED, 0))  
-       FROM C_ORDERLINE CO LEFT JOIN C_INVOICELINE CI ON CI.C_ORDERLINE_ID = CO.C_ORDERLINE_ID
-       WHERE  CI.C_INVOICE_ID=? AND CO.C_ORDERLINE_ID = l.c_orderline_id
-       GROUP BY CI.C_orderline_id , CO.QtyORDERED),0)) AS QTY,
-      l.quantityOrder*C_DIVIDE((l.QtyOrdered-SUM(COALESCE(mp.Qty,0))-COALESCE((SELECT SUM(COALESCE(CI.QtyINVOICED, 0))  
-       FROM C_ORDERLINE CO LEFT JOIN C_INVOICELINE CI ON CI.C_ORDERLINE_ID = CO.C_ORDERLINE_ID
-       WHERE  CI.C_INVOICE_ID=? AND CO.C_ORDERLINE_ID = l.c_orderline_id
-       GROUP BY CI.C_orderline_id , CO.QtyORDERED),0)),l.QtyOrdered) as quantityOrder, 
-       l.M_Product_UOM_ID, l.M_ATTRIBUTESETINSTANCE_ID, l.taxbaseamt
+      (SELECT l.ad_org_id,l.C_CURRENCY_ID,l.C_UOM_ID, l.M_Product_ID, l.Line, l.Description, l.C_OrderLine_ID, (l.QtyOrdered-SUM(COALESCE(mp.Qty,0))) AS QTY,
+      l.quantityOrder*C_DIVIDE((l.QtyOrdered-SUM(COALESCE(mp.Qty,0))),l.QtyOrdered) as quantityOrder, l.M_Product_UOM_ID, l.M_ATTRIBUTESETINSTANCE_ID,
+      l.taxbaseamt
         FROM C_ORDERLINE l left join M_MATCHPO mp on l.C_OrderLine_ID=mp.C_OrderLine_ID
                                                   and mp.C_InvoiceLine_ID IS NOT NULL
         GROUP BY l.ad_org_id,l.C_CURRENCY_ID,l.C_UOM_ID, l.M_Product_ID, l.Line, l.Description, l.C_OrderLine_ID, l.QtyOrdered, l.quantityOrder, l.M_Product_UOM_ID,
@@ -257,8 +227,6 @@
       ORDER BY A.Line
       ]]>
     </Sql>
-    <Parameter name="piId"/>
-    <Parameter name="piId"/>
     <Parameter name="cOrderlineId" optional="true" type="argument" after="AND A.M_Product_ID=p.M_Product_ID" text=" AND A.C_OrderLine_ID IN "/>
   </SqlMethod>
   <SqlMethod name="selectFromPOUpdateSOTrx" type="preparedStatement" connection="true" return="multiple">