Fixes Issue 20005: Internal consumption mov. do not appear in product mov. rep.
authorUnai Martirena <unai.martirena@openbravo.com>
Wed, 21 Mar 2012 17:34:15 +0100
changeset 15925 3d5a75391c27
parent 15924 023c0a102dea
child 15926 d63853373a53
Fixes Issue 20005: Internal consumption mov. do not appear in product mov. rep.
src/org/openbravo/erpCommon/ad_reports/ReportProductMovement.html
src/org/openbravo/erpCommon/ad_reports/ReportProductMovement.java
src/org/openbravo/erpCommon/ad_reports/ReportProductMovement.xml
src/org/openbravo/erpCommon/ad_reports/ReportProductMovement_data.xsql
--- a/src/org/openbravo/erpCommon/ad_reports/ReportProductMovement.html	Wed Mar 21 16:07:10 2012 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportProductMovement.html	Wed Mar 21 17:34:15 2012 +0100
@@ -122,6 +122,7 @@
   <input type="hidden" name="inpmInventoryId"></input>
   <input type="hidden" name="inpmMovementId"></input>
   <input type="hidden" name="inpmProductionplanId"></input>
+  <input type="hidden" name="inpmInternalConsumptionId"></input>
   <input type="hidden" name="inpLastFieldChanged" value=""/>
   <table height="100%" border="0" cellpadding="0" cellspacing="0" id="main">
     <tr>
@@ -389,6 +390,11 @@
               <td class="ContentCell"> </td>
             </tr>
             <tr>
+              <td class="TitleCell"><span class="LabelText">Internal Consumption</span></td>
+              <td class="Radio_Check_ContentCell"><span class="Checkbox_container_NOT_Focused"><input type="checkbox" name="inpInternalConsumption" id="paramInternalConsumption" value="-1" checked></input></span></td>
+              <td class="ContentCell"> </td>
+            </tr>
+            <tr>
               <td colspan="6">
                 <table class="FieldGroup" cellspacing="0" cellpadding="0" border="0">
                 <tbody>
@@ -664,6 +670,49 @@
                   </div>
                 </table>
                 <div style="height:15px;" />
+                <table cellspacing="0" cellpadding="0" width="100%" class="DataGrid_Header_Table DataGrid_Body_Table" style="table-layout: auto;" id="selEliminar5">
+                  <tr class="DataGrid_Body_Row">
+                    <th class="DataGrid_Header_Cell" align="center" colspan="8"><span>Internal Consumption</span></th>
+                  </tr>
+                  <div id="sectionPartner4"> 
+                    <tr class="DataGrid_Body_Row">
+                      <th class="DataGrid_Header_Cell" colspan="8"><span>Customer<span>:&nbsp;</span><span id="fieldPartnername4">xxAguinaga</span></span></th>
+                    </tr>
+                    <tr class="DataGrid_Body_Row">
+                      <th class="DataGrid_Header_Cell" width="8%">Date</td>
+                      <th class="DataGrid_Header_Cell" width="26%">Movement</td>
+                      <th class="DataGrid_Header_Cell" width="26%">Description</td>
+                      <th class="DataGrid_Header_Cell" width="12%" colspan="3">
+                        <table width="100%" border="0" cellspacing="0" cellpadding="0" style="background: none; border: 0px none">
+                          <tr class="DataGrid_Body_Row">
+                            <th class="DataGrid_Header_Cell" width="100%" colspan="3" style="background: none; border: 0px none">Location</th>
+                          </tr>
+                          <tr class="DataGrid_Body_Row">
+                            <th class="DataGrid_Header_Cell" width="34%" style="background: none; border: 0px none">X</th>
+                            <th class="DataGrid_Header_Cell" width="33%" style="background: none; border: 0px none">Y</th>
+                            <th class="DataGrid_Header_Cell" width="33%" style="background: none; border: 0px none">Z</th>
+                          </tr>
+                        </table>
+                      </th>
+                      <th class="DataGrid_Header_Cell"  width="6%">Exit</th>
+                      <th class="DataGrid_Header_Cell"  width="15%">Quantity</th>
+                    </tr>
+                    <div id="sectionDetail4"> 
+                      <tr class="DataGrid_Body_Row DataGrid_Body_Row_yy" id="funcEvenOddRow5xx">
+                        <td class="DataGrid_Body_Cell" width="8%" id="fieldMovementdate4">xx23-02-2004</td>
+                        <td class="DataGrid_Body_Cell" width="26%"> <a href="#" onclick="submitCommandFormParameter('DIRECT', document.frmMain.inpmInternalConsumptionId, 'xx', false, document.frmMain, '../InternalConsumption/Header_Relation.html', null, false, true);return false;" onmouseover="window.status='yy';return true;" onmouseout="window.status='';return true;" class="LabelLink" id="fieldId5">
+                          <span id="fieldMovement3">xx850000007</span></a></td>
+                        <td class="DataGrid_Body_Cell" width="26%" id="fieldName4">xx2345</td>
+                        <td class="DataGrid_Body_Cell" width="4%"  id="fieldXOrigin4">xx3</td>
+                        <td class="DataGrid_Body_Cell" width="4%"  id="fieldYOrigin4">xx3</td>
+                        <td class="DataGrid_Body_Cell" width="4%"  id="fieldZOrigin4">xx3</td>
+                        <td class="DataGrid_Body_Cell" width="6%"  id="fieldOut4">xxsi</td>
+                        <td class="DataGrid_Body_Cell" width="15%" id="fieldMovementqty4">xx23</td>
+                      </tr>
+                    </div>
+                  </div>
+                </table>
+                <div style="height:15px;" />
 
                       <!-- USER CONTROLS -->
               </td>
--- a/src/org/openbravo/erpCommon/ad_reports/ReportProductMovement.java	Wed Mar 21 16:07:10 2012 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportProductMovement.java	Wed Mar 21 17:34:15 2012 +0100
@@ -60,8 +60,10 @@
           "-1");
       String strProduction = vars.getGlobalVariable("inpProduction",
           "ReportProductMovement|production", "-1");
+      String strInternalConsumption = vars.getGlobalVariable("inpInternalConsumption",
+              "ReportProductMovement|internalConsumption", "-1");
       printPageDataSheet(response, vars, strDateFrom, strDateTo, strcBpartnerId, strmProductId,
-          strInout, strInventory, strMovement, strProduction, strmAttributesetinstanceId);
+          strInout, strInventory, strMovement, strProduction, strmAttributesetinstanceId, strInternalConsumption);
     } else if (vars.commandIn("DIRECT")) {
       String strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportProductMovement|dateFrom",
           "");
@@ -79,9 +81,11 @@
           "");
       String strProduction = vars.getGlobalVariable("inpProduction",
           "ReportProductMovement|production", "");
+      String strInternalConsumption = vars.getGlobalVariable("inpInternalConsumption",
+              "ReportProductMovement|internalConsumption", "");
       setHistoryCommand(request, "DIRECT");
       printPageDataSheet(response, vars, strDateFrom, strDateTo, strcBpartnerId, strmProductId,
-          strInout, strInventory, strMovement, strProduction, strmAttributesetinstanceId);
+          strInout, strInventory, strMovement, strProduction, strmAttributesetinstanceId, strInternalConsumption);
     } else if (vars.commandIn("FIND")) {
       String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom",
           "ReportProductMovement|dateFrom");
@@ -99,9 +103,11 @@
           "ReportProductMovement|movement");
       String strProduction = vars.getRequestGlobalVariable("inpProduction",
           "ReportProductMovement|production");
+      String strInternalConsumption = vars.getRequestGlobalVariable("inpInternalConsumption",
+              "ReportProductMovement|internalConsumption");
       setHistoryCommand(request, "DIRECT");
       printPageDataSheet(response, vars, strDateFrom, strDateTo, strcBpartnerId, strmProductId,
-          strInout, strInventory, strMovement, strProduction, strmAttributesetinstanceId);
+          strInout, strInventory, strMovement, strProduction, strmAttributesetinstanceId, strInternalConsumption);
     } else
       pageError(response);
   }
@@ -109,7 +115,7 @@
   private void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars,
       String strDateFrom, String strDateTo, String strcBpartnerId, String strmProductId,
       String strInout, String strInventory, String strMovement, String strProduction,
-      String strmAttributesetinstanceId) throws IOException, ServletException {
+      String strmAttributesetinstanceId, String strInternalConsumption) throws IOException, ServletException {
     if (log4j.isDebugEnabled())
       log4j.debug("Output: dataSheet");
     response.setContentType("text/html; charset=UTF-8");
@@ -119,7 +125,8 @@
     ReportProductMovementData[] data1 = null;
     ReportProductMovementData[] data2 = null;
     ReportProductMovementData[] data3 = null;
-    String discard[] = { "discard", "discard", "discard", "discard" };
+    ReportProductMovementData[] data4 = null;
+    String discard[] = { "discard", "discard", "discard", "discard", "discard" };
     if (strDateFrom.equals("") && strDateTo.equals("")) {
       strDateTo = DateTimeData.today(this);
       strDateFrom = DateTimeData.weekBefore(this);
@@ -181,15 +188,31 @@
         discard[3] = "selEliminar4";
         data3 = ReportProductMovementData.set();
       }
+      if (strInternalConsumption.equals("-1")) {
+          data4 = ReportProductMovementData.selectInternalConsumption(this,
+              Utility.getContext(this, vars, "#User_Client", "ReportProductMovement"),
+              Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportProductMovement"),
+              strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strcBpartnerId,
+              strmProductId);
+          if (data4 == null || data4.length == 0) {
+            discard[4] = "selEliminar5";
+            data4 = ReportProductMovementData.set();
+          }
+        } else {
+          discard[4] = "selEliminar5";
+          data4 = ReportProductMovementData.set();
+        }
     } else {
       discard[0] = "selEliminar1";
       discard[1] = "selEliminar2";
       discard[2] = "selEliminar3";
       discard[3] = "selEliminar4";
+      discard[4] = "selEliminar5";
       data = ReportProductMovementData.set();
       data1 = ReportProductMovementData.set();
       data2 = ReportProductMovementData.set();
       data3 = ReportProductMovementData.set();
+      data4 = ReportProductMovementData.set();
     }
     xmlDocument = xmlEngine.readXmlTemplate(
         "org/openbravo/erpCommon/ad_reports/ReportProductMovement", discard).createXmlDocument();
@@ -253,10 +276,12 @@
     xmlDocument.setParameter("inventory", strInventory);
     xmlDocument.setParameter("movement", strMovement);
     xmlDocument.setParameter("production", strProduction);
+    xmlDocument.setParameter("internalConsumption", strInternalConsumption);
     xmlDocument.setData("structure1", data);
     xmlDocument.setData("structure2", data1);
     xmlDocument.setData("structure3", data2);
     xmlDocument.setData("structure4", data3);
+    xmlDocument.setData("structure5", data4);
 
     out.println(xmlDocument.print());
     out.close();
--- a/src/org/openbravo/erpCommon/ad_reports/ReportProductMovement.xml	Wed Mar 21 16:07:10 2012 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportProductMovement.xml	Wed Mar 21 17:34:15 2012 +0100
@@ -42,6 +42,8 @@
   <PARAMETER id="paramMovement" name="movement" boolean="checked" withId="parameterMovement"/>
   <PARAMETER id="parameterProduction" name="constantProduction" default="-1"/>
   <PARAMETER id="paramProduction" name="production" boolean="checked" withId="parameterProduction"/>
+  <PARAMETER id="parameterInternalConsumption" name="constantInternalConsumption" default="-1"/>
+  <PARAMETER id="paramInternalConsumption" name="internalConsumption" boolean="checked" withId="parameterInternalConsumption"/>
   <PARAMETER id="paramCSS" name="theme" attribute="href" replace="Default"/>
   <PARAMETER id="tdleftTabs" name="leftTabs" default=""/>
   <PARAMETER id="paramParentTabContainer" name="parentTabContainer" default=" "/>
@@ -135,4 +137,21 @@
     <SECTION id="sectionPartner3" field="partnername"/>
     <SECTION id="sectionDetail3"/>
   </structure>
+  <structure name="structure5">
+    <FIELD id="fieldRownum5">rownum</FIELD>
+    <FUNCTION id="funcEvenOddRow5xx" name="MODULE" arg1="fieldRownum5" arg2="param2" format="integerEdition" attribute="class" replace="yy"/>
+    <FIELD id="fieldId5" attribute="onclick" replace="xx">mInternalConsumptionId</FIELD>
+    <FIELD id="fieldId5" attribute="onmouseover" replace="yy">movementDescription</FIELD>
+    <FIELD id="fieldMovement3">movement</FIELD>
+    <FIELD id="fieldName4">name</FIELD>
+    <FIELD id="fieldPartnername4">partnername</FIELD>
+    <FIELD id="fieldMovementdate4">movementdate</FIELD>
+    <FIELD id="fieldMovementqty4">movementqty</FIELD>
+    <FIELD id="fieldXOrigin4">xOrigin</FIELD>
+    <FIELD id="fieldYOrigin4">yOrigin</FIELD>
+    <FIELD id="fieldZOrigin4">zOrigin</FIELD>
+    <FIELD id="fieldOut4">out</FIELD>
+    <SECTION id="sectionPartner4" field="partnername"/>
+    <SECTION id="sectionDetail4"/>
+  </structure>
 </REPORT>
--- a/src/org/openbravo/erpCommon/ad_reports/ReportProductMovement_data.xsql	Wed Mar 21 16:07:10 2012 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportProductMovement_data.xsql	Wed Mar 21 17:34:15 2012 +0100
@@ -38,7 +38,7 @@
       AD_MESSAGE_GET2(M_INOUT.ISSOTRX,?) AS OUT,
       (SUM(M_TRANSACTION.MOVEMENTQTY)||' '||C_UOM.NAME) AS MOVEMENTQTY, M_INOUT.ISSOTRX AS ISSOTRX, M_INOUT.M_INOUT_ID,
       M_INOUT.DOCUMENTNO AS DOCUMENTNO, '' AS M_MOVEMENTLINE_ID, '' AS MOVEMENT, '' AS MOVEMENT_DESCRIPTION,
-      '' AS M_INVENTORY_ID, '' AS M_MOVEMENT_ID, '' AS M_PRODUCTIONPLAN_ID, '' AS PRODUCTION_PLAN
+      '' AS M_INVENTORY_ID, '' AS M_MOVEMENT_ID, '' AS M_PRODUCTIONPLAN_ID, '' AS PRODUCTION_PLAN, '' AS M_INTERNAL_CONSUMPTION_ID
       FROM M_PRODUCT left join C_BPARTNER on M_PRODUCT.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
                      right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID
                      left join M_ATTRIBUTESETINSTANCE ON M_ATTRIBUTESETINSTANCE.M_ATTRIBUTESETINSTANCE_ID=M_TRANSACTION.M_ATTRIBUTESETINSTANCE_ID,
@@ -164,6 +164,38 @@
     <Parameter name="cBpartner" optional="true" after="AND 1=1"><![CDATA[ AND C_BPARTNER.C_BPARTNER_ID = ?]]></Parameter>
     <Parameter name="mProductId" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID = ?]]></Parameter>
   </SqlMethod>
+  
+  <SqlMethod name="selectInternalConsumption" type="preparedStatement" return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+    <![CDATA[
+      SELECT M_PRODUCT.VALUE, M_PRODUCT.NAME, M_LOCATOR.X AS X_ORIGIN, M_LOCATOR.Y AS Y_ORIGIN, M_LOCATOR.Z AS Z_ORIGIN, C_BPARTNER.NAME AS PARTNERNAME, 
+      (SUM(M_TRANSACTION.MOVEMENTQTY)||' '||C_UOM.NAME) AS MOVEMENTQTY, M_TRANSACTION.MOVEMENTDATE, 'No' AS OUT,
+      M_INTERNAL_CONSUMPTION.M_INTERNAL_CONSUMPTION_ID, M_INTERNAL_CONSUMPTION.NAME AS MOVEMENT, M_INTERNAL_CONSUMPTION.NAME AS MOVEMENT_DESCRIPTION
+      FROM M_PRODUCT left join C_BPARTNER on M_PRODUCT.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
+                     right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID,
+          M_LOCATOR,  C_UOM, M_INTERNAL_CONSUMPTIONLINE, M_INTERNAL_CONSUMPTION
+      WHERE  M_TRANSACTION.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
+      AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
+      AND M_TRANSACTION.M_INTERNAL_CONSUMPTIONLINE_ID = M_INTERNAL_CONSUMPTIONLINE.M_INTERNAL_CONSUMPTIONLINE_ID
+      AND M_INTERNAL_CONSUMPTIONLINE.M_INTERNAL_CONSUMPTION_ID = M_INTERNAL_CONSUMPTION.M_INTERNAL_CONSUMPTION_ID
+      AND M_TRANSACTION.M_INTERNAL_CONSUMPTIONLINE_ID IS NOT NULL
+      AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
+      AND M_TRANSACTION.AD_ORG_ID IN ('1')
+      AND 1=1
+      GROUP BY M_PRODUCT.VALUE, M_PRODUCT.NAME, M_LOCATOR.X, M_LOCATOR.Y, M_LOCATOR.Z, C_BPARTNER.NAME, C_UOM.NAME, 
+      M_TRANSACTION.MOVEMENTDATE, M_INTERNAL_CONSUMPTION.M_INTERNAL_CONSUMPTION_ID, M_INTERNAL_CONSUMPTION.NAME, M_INTERNAL_CONSUMPTION.DESCRIPTION
+      HAVING SUM(M_TRANSACTION.MOVEMENTQTY) <> 0
+      ORDER BY C_BPARTNER.NAME, M_TRANSACTION.MOVEMENTDATE DESC
+     ]]></Sql>
+    <Field name="rownum" value="count"/>
+    <Parameter name="adUserClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_CLIENT_ID IN (" text="'1'"/>
+    <Parameter name="adOrgClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_ORG_ID IN (" text="'1'"/>
+    <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE >= to_date(?)]]></Parameter>
+    <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
+    <Parameter name="cBpartner" optional="true" after="AND 1=1"><![CDATA[ AND C_BPARTNER.C_BPARTNER_ID = ?]]></Parameter>
+    <Parameter name="mProductId" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID = ?]]></Parameter>
+  </SqlMethod>
 
   <SqlMethod name="selectBpartner" type="preparedStatement" return="String" default="">
     <SqlMethodComment></SqlMethodComment>