src/org/openbravo/erpCommon/ad_reports/ReportProductMovement_data.xsql
changeset 0 0247c26f10c6
child 423 ecf368072c48
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportProductMovement_data.xsql	Tue Nov 06 08:33:31 2007 +0000
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SL 
+ * All portions are Copyright (C) 2001-2006 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+-->
+
+
+
+
+
+<SqlClass name="ReportProductMovementData" package="org.openbravo.erpCommon.ad_reports">
+  <SqlClassComment></SqlClassComment>
+  <SqlMethod name="select" type="preparedStatement" return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+    <![CDATA[
+      SELECT M_PRODUCT.VALUE, M_PRODUCT.NAME, M_TRANSACTION.MOVEMENTDATE, C_BPARTNER.NAME AS PARTNERNAME,
+      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN TO_CHAR(M_LOCATOR.X) ELSE '-' END) AS X_ORIGIN, 
+      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN TO_CHAR(M_LOCATOR.Y) ELSE '-' END) AS Y_ORIGIN, 
+      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN TO_CHAR(M_LOCATOR.Z) ELSE '-' END) AS Z_ORIGIN, 
+      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN '-' ELSE TO_CHAR(M_LOCATOR.X) END) AS X_DESTINY, 
+      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN '-' ELSE TO_CHAR(M_LOCATOR.Y) END) AS Y_DESTINY, 
+      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN '-' ELSE TO_CHAR(M_LOCATOR.Z) END) AS Z_DESTINY,
+      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN 'Si' ELSE 'No' END) AS OUT,
+      (SUM(M_TRANSACTION.MOVEMENTQTY)||' '||C_UOM.NAME) AS MOVEMENTQTY, M_INOUT.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
+      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, M_INOUTLINE, M_INOUT, C_UOM
+      WHERE M_TRANSACTION.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
+      AND M_TRANSACTION.M_INOUTLINE_ID = M_INOUTLINE.M_INOUTLINE_ID
+      AND M_INOUTLINE.M_INOUT_ID = M_INOUT.M_INOUT_ID
+      AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
+      AND M_TRANSACTION.M_INOUTLINE_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_TRANSACTION.MOVEMENTDATE, C_BPARTNER.NAME, M_LOCATOR.X, M_LOCATOR.Y, 
+      M_LOCATOR.Z, M_INOUT.ISSOTRX, C_UOM.NAME, M_INOUT.M_INOUT_ID, M_INOUT.DOCUMENTNO
+      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="selectInventory" 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_INVENTORY.M_INVENTORY_ID, M_INVENTORY.NAME AS MOVEMENT, M_INVENTORY.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_INVENTORYLINE, M_INVENTORY
+      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_INVENTORYLINE_ID = M_INVENTORYLINE.M_INVENTORYLINE_ID
+      AND M_INVENTORYLINE.M_INVENTORY_ID = M_INVENTORY.M_INVENTORY_ID
+      AND M_TRANSACTION.M_INVENTORYLINE_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_INVENTORY.M_INVENTORY_ID, M_INVENTORY.NAME
+      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="selectMovement" 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, 
+        M_L.X AS X_DESTINY, M_L.Y AS Y_DESTINY, M_L.Z AS Z_DESTINY, C_BPARTNER.NAME AS PARTNERNAME, 
+        (M_TRANSACTION.MOVEMENTQTY||' '||C_UOM.NAME) AS MOVEMENTQTY, M_TRANSACTION.MOVEMENTDATE, 'No' AS OUT,
+        M_MOVEMENTLINE.M_MOVEMENT_ID, M_MOVEMENT.NAME AS MOVEMENT
+        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_MOVEMENTLINE, M_LOCATOR, M_LOCATOR M_L,  C_UOM,
+        M_MOVEMENT
+        WHERE M_TRANSACTION.M_MOVEMENTLINE_ID = M_MOVEMENTLINE.M_MOVEMENTLINE_ID
+        AND M_MOVEMENTLINE.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
+        AND M_MOVEMENTLINE.M_LOCATORTO_ID = M_L.M_LOCATOR_ID
+        AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
+        AND M_TRANSACTION.M_MOVEMENTLINE_ID IS NOT NULL
+        AND M_MOVEMENTLINE.M_MOVEMENT_ID = M_MOVEMENT.M_MOVEMENT_ID
+        AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
+        AND M_TRANSACTION.AD_ORG_ID IN ('1')
+        AND 1=1
+        AND 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="selectProduction" 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, '-' AS X_DESTINY, '-' AS Y_DESTINY, '-' AS Z_DESTINY, 
+        (SUM(M_TRANSACTION.MOVEMENTQTY)||' '||C_UOM.NAME) AS MOVEMENTQTY, M_TRANSACTION.MOVEMENTDATE, 'No' AS OUT,
+        M_PRODUCTIONPLAN.M_PRODUCTIONPLAN_ID, (M_PRODUCTION.NAME || ' - ' || M_PRODUCTIONPLAN.LINE) AS PRODUCTION_PLAN
+        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_PRODUCTIONLINE, M_PRODUCTIONPLAN, M_PRODUCTION
+        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_PRODUCTIONLINE_ID = M_PRODUCTIONLINE.M_PRODUCTIONLINE_ID
+        AND M_PRODUCTIONLINE.M_PRODUCTIONPLAN_ID = M_PRODUCTIONPLAN.M_PRODUCTIONPLAN_ID
+        AND M_PRODUCTIONPLAN.M_PRODUCTION_ID = M_PRODUCTION.M_PRODUCTION_ID
+        AND M_TRANSACTION.M_PRODUCTIONLINE_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_PRODUCTIONPLAN.M_PRODUCTIONPLAN_ID, M_PRODUCTION.NAME, M_PRODUCTIONPLAN.LINE
+        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>
+    <Sql>
+    <![CDATA[
+      SELECT C_BPARTNER.NAME
+      FROM C_BPARTNER
+      WHERE C_BPARTNER.C_BPARTNER_ID = ?
+     ]]></Sql>
+    <Parameter name="cBpartnerId"/>
+  </SqlMethod>
+
+  <SqlMethod name="selectMproduct" type="preparedStatement" return="String" default="">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+    <![CDATA[
+      SELECT M_PRODUCT.NAME
+      FROM M_PRODUCT
+      WHERE M_PRODUCT.M_PRODUCT_ID = ?
+     ]]></Sql>
+    <Parameter name="mProductId"/>
+  </SqlMethod>
+
+  <SqlMethod name="set" type="constant" return="multiple">
+      <SqlMethodComment></SqlMethodComment>
+      <Sql></Sql>
+  </SqlMethod>
+</SqlClass>