src/org/openbravo/erpCommon/ad_reports/ReportProductMovement_data.xsql
author Vinoth Babu <vinoth.babu@openbravo.com>
Tue, 21 Apr 2009 11:42:02 +0530
changeset 3684 9bd469a5a025
parent 3600 973c74129894
child 6702 690d2af86089
permissions -rw-r--r--
Fixes bug 8448 Added attribute column In Product movements report
carlos@0
     1
<?xml version="1.0" encoding="UTF-8" ?>
carlos@0
     2
<!--
carlos@0
     3
 *************************************************************************
carlos@0
     4
 * The contents of this file are subject to the Openbravo  Public  License
carlos@0
     5
 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
carlos@0
     6
 * Version 1.1  with a permitted attribution clause; you may not  use this
carlos@0
     7
 * file except in compliance with the License. You  may  obtain  a copy of
carlos@0
     8
 * the License at http://www.openbravo.com/legal/license.html 
carlos@0
     9
 * Software distributed under the License  is  distributed  on  an "AS IS"
carlos@0
    10
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
carlos@0
    11
 * License for the specific  language  governing  rights  and  limitations
carlos@0
    12
 * under the License. 
carlos@0
    13
 * The Original Code is Openbravo ERP. 
carlos@0
    14
 * The Initial Developer of the Original Code is Openbravo SL 
rafael@1506
    15
 * All portions are Copyright (C) 2001-2008 Openbravo SL 
carlos@0
    16
 * All Rights Reserved. 
carlos@0
    17
 * Contributor(s):  ______________________________________.
carlos@0
    18
 ************************************************************************
carlos@0
    19
-->
carlos@0
    20
carlos@0
    21
carlos@0
    22
carlos@0
    23
carlos@0
    24
carlos@0
    25
<SqlClass name="ReportProductMovementData" package="org.openbravo.erpCommon.ad_reports">
carlos@0
    26
  <SqlClassComment></SqlClassComment>
carlos@0
    27
  <SqlMethod name="select" type="preparedStatement" return="multiple">
carlos@0
    28
    <SqlMethodComment></SqlMethodComment>
carlos@0
    29
    <Sql>
carlos@0
    30
    <![CDATA[
vinoth@3684
    31
      SELECT M_PRODUCT.VALUE, M_PRODUCT.NAME, M_TRANSACTION.MOVEMENTDATE, C_BPARTNER.NAME AS PARTNERNAME,M_ATTRIBUTESETINSTANCE.DESCRIPTION AS ATTR,
carlos@0
    32
      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN TO_CHAR(M_LOCATOR.X) ELSE '-' END) AS X_ORIGIN, 
carlos@0
    33
      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN TO_CHAR(M_LOCATOR.Y) ELSE '-' END) AS Y_ORIGIN, 
carlos@0
    34
      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN TO_CHAR(M_LOCATOR.Z) ELSE '-' END) AS Z_ORIGIN, 
carlos@0
    35
      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN '-' ELSE TO_CHAR(M_LOCATOR.X) END) AS X_DESTINY, 
carlos@0
    36
      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN '-' ELSE TO_CHAR(M_LOCATOR.Y) END) AS Y_DESTINY, 
carlos@0
    37
      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN '-' ELSE TO_CHAR(M_LOCATOR.Z) END) AS Z_DESTINY,
rafael@1506
    38
      AD_MESSAGE_GET2(M_INOUT.ISSOTRX,?) AS OUT,
ainhoa@3600
    39
      (SUM(M_TRANSACTION.MOVEMENTQTY)||' '||C_UOM.NAME) AS MOVEMENTQTY, M_INOUT.ISSOTRX AS ISSOTRX, M_INOUT.M_INOUT_ID,
carlos@0
    40
      M_INOUT.DOCUMENTNO AS DOCUMENTNO, '' AS M_MOVEMENTLINE_ID, '' AS MOVEMENT, '' AS MOVEMENT_DESCRIPTION,
carlos@0
    41
      '' AS M_INVENTORY_ID, '' AS M_MOVEMENT_ID, '' AS M_PRODUCTIONPLAN_ID, '' AS PRODUCTION_PLAN
carlos@0
    42
      FROM M_PRODUCT left join C_BPARTNER on M_PRODUCT.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
vinoth@3684
    43
                     right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID
vinoth@3684
    44
                     left join M_ATTRIBUTESETINSTANCE ON M_ATTRIBUTESETINSTANCE.M_ATTRIBUTESETINSTANCE_ID=M_TRANSACTION.M_ATTRIBUTESETINSTANCE_ID,
carlos@0
    45
           M_LOCATOR, M_INOUTLINE, M_INOUT, C_UOM
carlos@0
    46
      WHERE M_TRANSACTION.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
carlos@0
    47
      AND M_TRANSACTION.M_INOUTLINE_ID = M_INOUTLINE.M_INOUTLINE_ID
carlos@0
    48
      AND M_INOUTLINE.M_INOUT_ID = M_INOUT.M_INOUT_ID
carlos@0
    49
      AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
carlos@0
    50
      AND M_TRANSACTION.M_INOUTLINE_ID IS NOT NULL 
carlos@0
    51
      AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
carlos@0
    52
      AND M_TRANSACTION.AD_ORG_ID IN ('1')
carlos@0
    53
      AND 1=1
carlos@0
    54
      GROUP BY M_PRODUCT.VALUE, M_PRODUCT.NAME, M_TRANSACTION.MOVEMENTDATE, C_BPARTNER.NAME, M_LOCATOR.X, M_LOCATOR.Y, 
vinoth@3684
    55
      M_LOCATOR.Z, M_INOUT.ISSOTRX, C_UOM.NAME, M_INOUT.M_INOUT_ID, M_INOUT.DOCUMENTNO, M_ATTRIBUTESETINSTANCE.DESCRIPTION
carlos@0
    56
      ORDER BY C_BPARTNER.NAME, M_TRANSACTION.MOVEMENTDATE DESC
carlos@0
    57
     ]]></Sql>
rafael@1506
    58
    <Parameter name="adLanguage"/>
carlos@0
    59
    <Field name="rownum" value="count"/>
carlos@0
    60
    <Parameter name="adUserClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
    61
    <Parameter name="adOrgClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_ORG_ID IN (" text="'1'"/>
carlos@0
    62
    <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE >= to_date(?)]]></Parameter>
carlos@0
    63
    <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
juanpablo@1605
    64
    <Parameter name="cBpartner" optional="true" after="AND 1=1"><![CDATA[ AND C_BPARTNER.C_BPARTNER_ID = ?]]></Parameter>
juanpablo@1605
    65
    <Parameter name="mProductId" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID = ?]]></Parameter>
juanpablo@1605
    66
    <Parameter name="parmAttributeSetInstanceId" optional="true" after="AND 1=1"><![CDATA[AND M_TRANSACTION.M_ATTRIBUTESETINSTANCE_ID = ?]]></Parameter>
carlos@0
    67
  </SqlMethod>
carlos@0
    68
carlos@0
    69
  <SqlMethod name="selectInventory" type="preparedStatement" return="multiple">
carlos@0
    70
    <SqlMethodComment></SqlMethodComment>
carlos@0
    71
    <Sql>
carlos@0
    72
    <![CDATA[
carlos@0
    73
      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, 
carlos@0
    74
      (SUM(M_TRANSACTION.MOVEMENTQTY)||' '||C_UOM.NAME) AS MOVEMENTQTY, M_TRANSACTION.MOVEMENTDATE, 'No' AS OUT,
carlos@0
    75
      M_INVENTORY.M_INVENTORY_ID, M_INVENTORY.NAME AS MOVEMENT, M_INVENTORY.NAME AS MOVEMENT_DESCRIPTION
carlos@0
    76
      FROM M_PRODUCT left join C_BPARTNER on M_PRODUCT.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
carlos@0
    77
                     right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID,
carlos@0
    78
          M_LOCATOR,  C_UOM, M_INVENTORYLINE, M_INVENTORY
carlos@0
    79
      WHERE  M_TRANSACTION.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
carlos@0
    80
      AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
carlos@0
    81
      AND M_TRANSACTION.M_INVENTORYLINE_ID = M_INVENTORYLINE.M_INVENTORYLINE_ID
carlos@0
    82
      AND M_INVENTORYLINE.M_INVENTORY_ID = M_INVENTORY.M_INVENTORY_ID
carlos@0
    83
      AND M_TRANSACTION.M_INVENTORYLINE_ID IS NOT NULL
carlos@0
    84
      AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
carlos@0
    85
      AND M_TRANSACTION.AD_ORG_ID IN ('1')
carlos@0
    86
      AND 1=1
carlos@0
    87
      GROUP BY M_PRODUCT.VALUE, M_PRODUCT.NAME, M_LOCATOR.X, M_LOCATOR.Y, M_LOCATOR.Z, C_BPARTNER.NAME, C_UOM.NAME, 
carlos@0
    88
      M_TRANSACTION.MOVEMENTDATE, M_INVENTORY.M_INVENTORY_ID, M_INVENTORY.NAME
carlos@0
    89
      HAVING SUM(M_TRANSACTION.MOVEMENTQTY) <> 0
carlos@0
    90
      ORDER BY C_BPARTNER.NAME, M_TRANSACTION.MOVEMENTDATE DESC
carlos@0
    91
     ]]></Sql>
carlos@0
    92
    <Field name="rownum" value="count"/>
carlos@0
    93
    <Parameter name="adUserClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
    94
    <Parameter name="adOrgClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_ORG_ID IN (" text="'1'"/>
carlos@0
    95
    <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE >= to_date(?)]]></Parameter>
carlos@0
    96
    <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
juanpablo@1605
    97
    <Parameter name="cBpartner" optional="true" after="AND 1=1"><![CDATA[ AND C_BPARTNER.C_BPARTNER_ID = ?]]></Parameter>
juanpablo@1605
    98
    <Parameter name="mProductId" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID = ?]]></Parameter>
carlos@0
    99
  </SqlMethod>
carlos@0
   100
carlos@0
   101
  <SqlMethod name="selectMovement" type="preparedStatement" return="multiple">
carlos@0
   102
    <SqlMethodComment></SqlMethodComment>
carlos@0
   103
    <Sql>
carlos@0
   104
    <![CDATA[
carlos@0
   105
        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, 
carlos@0
   106
        M_L.X AS X_DESTINY, M_L.Y AS Y_DESTINY, M_L.Z AS Z_DESTINY, C_BPARTNER.NAME AS PARTNERNAME, 
carlos@0
   107
        (M_TRANSACTION.MOVEMENTQTY||' '||C_UOM.NAME) AS MOVEMENTQTY, M_TRANSACTION.MOVEMENTDATE, 'No' AS OUT,
carlos@0
   108
        M_MOVEMENTLINE.M_MOVEMENT_ID, M_MOVEMENT.NAME AS MOVEMENT
carlos@0
   109
        FROM  M_PRODUCT left join C_BPARTNER on M_PRODUCT.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
carlos@0
   110
                        right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID,
carlos@0
   111
         M_MOVEMENTLINE, M_LOCATOR, M_LOCATOR M_L,  C_UOM,
carlos@0
   112
        M_MOVEMENT
carlos@0
   113
        WHERE M_TRANSACTION.M_MOVEMENTLINE_ID = M_MOVEMENTLINE.M_MOVEMENTLINE_ID
carlos@0
   114
        AND M_MOVEMENTLINE.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
carlos@0
   115
        AND M_MOVEMENTLINE.M_LOCATORTO_ID = M_L.M_LOCATOR_ID
carlos@0
   116
        AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
carlos@0
   117
        AND M_TRANSACTION.M_MOVEMENTLINE_ID IS NOT NULL
carlos@0
   118
        AND M_MOVEMENTLINE.M_MOVEMENT_ID = M_MOVEMENT.M_MOVEMENT_ID
carlos@0
   119
        AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
carlos@0
   120
        AND M_TRANSACTION.AD_ORG_ID IN ('1')
carlos@0
   121
        AND 1=1
carlos@0
   122
        AND M_TRANSACTION.MOVEMENTQTY >0
carlos@0
   123
        ORDER BY C_BPARTNER.NAME, M_TRANSACTION.MOVEMENTDATE DESC
carlos@0
   124
     ]]></Sql>
carlos@0
   125
    <Field name="rownum" value="count"/>
carlos@0
   126
    <Parameter name="adUserClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
   127
    <Parameter name="adOrgClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_ORG_ID IN (" text="'1'"/>
carlos@0
   128
    <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE >= to_date(?)]]></Parameter>
carlos@0
   129
    <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
juanpablo@1605
   130
    <Parameter name="cBpartner" optional="true" after="AND 1=1"><![CDATA[ AND C_BPARTNER.C_BPARTNER_ID = ?]]></Parameter>
juanpablo@1605
   131
    <Parameter name="mProductId" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID = ?]]></Parameter>
carlos@0
   132
  </SqlMethod>
carlos@0
   133
carlos@0
   134
  <SqlMethod name="selectProduction" type="preparedStatement" return="multiple">
carlos@0
   135
    <SqlMethodComment></SqlMethodComment>
carlos@0
   136
    <Sql>
carlos@0
   137
    <![CDATA[
carlos@0
   138
        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,
carlos@0
   139
        C_BPARTNER.NAME AS PARTNERNAME, '-' AS X_DESTINY, '-' AS Y_DESTINY, '-' AS Z_DESTINY, 
ainhoa@3600
   140
        (SUM(M_TRANSACTION.MOVEMENTQTY)||' '||C_UOM.NAME) AS MOVEMENTQTY, M_TRANSACTION.MOVEMENTDATE, 'No' AS OUT, M_PRODUCTION.ISSOTRX AS ISSOTRX,
ainhoa@3600
   141
        M_PRODUCTIONPLAN.M_PRODUCTIONPLAN_ID, ((CASE WHEN M_PRODUCTION.NAME IS NULL THEN M_PRODUCTION.DOCUMENTNO ELSE M_PRODUCTION.NAME END) || ' - ' || M_PRODUCTIONPLAN.LINE) AS PRODUCTION_PLAN
carlos@0
   142
        FROM M_PRODUCT left join C_BPARTNER on M_PRODUCT.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
carlos@0
   143
                       right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID,
carlos@0
   144
             M_LOCATOR, C_UOM, M_PRODUCTIONLINE, M_PRODUCTIONPLAN, M_PRODUCTION
carlos@0
   145
        WHERE M_TRANSACTION.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
carlos@0
   146
        AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
carlos@0
   147
        AND M_TRANSACTION.M_PRODUCTIONLINE_ID = M_PRODUCTIONLINE.M_PRODUCTIONLINE_ID
carlos@0
   148
        AND M_PRODUCTIONLINE.M_PRODUCTIONPLAN_ID = M_PRODUCTIONPLAN.M_PRODUCTIONPLAN_ID
carlos@0
   149
        AND M_PRODUCTIONPLAN.M_PRODUCTION_ID = M_PRODUCTION.M_PRODUCTION_ID
carlos@0
   150
        AND M_TRANSACTION.M_PRODUCTIONLINE_ID IS NOT NULL
carlos@0
   151
        AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
carlos@0
   152
        AND M_TRANSACTION.AD_ORG_ID IN ('1')
carlos@0
   153
        AND 1=1
carlos@0
   154
        GROUP BY M_PRODUCT.VALUE, M_PRODUCT.NAME, M_LOCATOR.X, M_LOCATOR.Y, M_LOCATOR.Z, C_BPARTNER.NAME, C_UOM.NAME, 
ainhoa@3600
   155
        M_TRANSACTION.MOVEMENTDATE,M_PRODUCTIONPLAN.M_PRODUCTIONPLAN_ID, M_PRODUCTION.NAME, M_PRODUCTIONPLAN.LINE, M_PRODUCTION.ISSOTRX, M_PRODUCTION.DOCUMENTNO
carlos@0
   156
        HAVING SUM(M_TRANSACTION.MOVEMENTQTY) <> 0
carlos@0
   157
        ORDER BY C_BPARTNER.NAME, M_TRANSACTION.MOVEMENTDATE DESC
carlos@0
   158
     ]]></Sql>
carlos@0
   159
    <Field name="rownum" value="count"/>
carlos@0
   160
    <Parameter name="adUserClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
   161
    <Parameter name="adOrgClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_ORG_ID IN (" text="'1'"/>
carlos@0
   162
    <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE >= to_date(?)]]></Parameter>
carlos@0
   163
    <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
juanpablo@1605
   164
    <Parameter name="cBpartner" optional="true" after="AND 1=1"><![CDATA[ AND C_BPARTNER.C_BPARTNER_ID = ?]]></Parameter>
juanpablo@1605
   165
    <Parameter name="mProductId" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID = ?]]></Parameter>
carlos@0
   166
  </SqlMethod>
carlos@0
   167
carlos@0
   168
  <SqlMethod name="selectBpartner" type="preparedStatement" return="String" default="">
carlos@0
   169
    <SqlMethodComment></SqlMethodComment>
carlos@0
   170
    <Sql>
carlos@0
   171
    <![CDATA[
carlos@0
   172
      SELECT C_BPARTNER.NAME
carlos@0
   173
      FROM C_BPARTNER
juanpablo@1605
   174
      WHERE C_BPARTNER.C_BPARTNER_ID = ?
carlos@0
   175
     ]]></Sql>
carlos@0
   176
    <Parameter name="cBpartnerId"/>
carlos@0
   177
  </SqlMethod>
carlos@0
   178
carlos@0
   179
  <SqlMethod name="selectMproduct" type="preparedStatement" return="String" default="">
carlos@0
   180
    <SqlMethodComment></SqlMethodComment>
carlos@0
   181
    <Sql>
carlos@0
   182
    <![CDATA[
carlos@0
   183
      SELECT M_PRODUCT.NAME
carlos@0
   184
      FROM M_PRODUCT
juanpablo@1605
   185
      WHERE M_PRODUCT.M_PRODUCT_ID = ?
carlos@0
   186
     ]]></Sql>
carlos@0
   187
    <Parameter name="mProductId"/>
carlos@0
   188
  </SqlMethod>
carlos@0
   189
carlos@0
   190
  <SqlMethod name="set" type="constant" return="multiple">
carlos@0
   191
      <SqlMethodComment></SqlMethodComment>
carlos@0
   192
      <Sql></Sql>
carlos@0
   193
  </SqlMethod>
carlos@0
   194
</SqlClass>