src/org/openbravo/erpCommon/ad_reports/ReportProductMovement_data.xsql
author Sandra Huguet <sandra.huguet@openbravo.com>
Wed, 25 Apr 2012 10:38:10 +0200
changeset 16207 705c297b4a4e
parent 15925 3d5a75391c27
child 17681 73c450ac46da
permissions -rw-r--r--
Fixed issue 14610 Add warehouse to Product Movements Report
Add a new column with warehouse for each table 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
priya@9085
     5
 * Version  1.1  (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. 
ggi@6702
    14
 * The Initial Developer of the Original Code is Openbravo SLU 
sandra@16207
    15
 * All portions are Copyright (C) 2001-2012 Openbravo SLU 
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,
sandra@16207
    32
      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN TO_CHAR(M_WAREHOUSE.NAME) ELSE '-' END)AS WA_ORIGIN,
carlos@0
    33
      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN TO_CHAR(M_LOCATOR.X) ELSE '-' END) AS X_ORIGIN, 
carlos@0
    34
      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN TO_CHAR(M_LOCATOR.Y) ELSE '-' END) AS Y_ORIGIN, 
sandra@16207
    35
      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN TO_CHAR(M_LOCATOR.Z) ELSE '-' END) AS Z_ORIGIN,
sandra@16207
    36
      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN '-' ELSE TO_CHAR(M_WAREHOUSE.NAME) END) AS WA_DESTINY, 
carlos@0
    37
      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN '-' ELSE TO_CHAR(M_LOCATOR.X) END) AS X_DESTINY, 
carlos@0
    38
      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN '-' ELSE TO_CHAR(M_LOCATOR.Y) END) AS Y_DESTINY, 
carlos@0
    39
      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN '-' ELSE TO_CHAR(M_LOCATOR.Z) END) AS Z_DESTINY,
rafael@1506
    40
      AD_MESSAGE_GET2(M_INOUT.ISSOTRX,?) AS OUT,
ainhoa@3600
    41
      (SUM(M_TRANSACTION.MOVEMENTQTY)||' '||C_UOM.NAME) AS MOVEMENTQTY, M_INOUT.ISSOTRX AS ISSOTRX, M_INOUT.M_INOUT_ID,
carlos@0
    42
      M_INOUT.DOCUMENTNO AS DOCUMENTNO, '' AS M_MOVEMENTLINE_ID, '' AS MOVEMENT, '' AS MOVEMENT_DESCRIPTION,
unai@15925
    43
      '' AS M_INVENTORY_ID, '' AS M_MOVEMENT_ID, '' AS M_PRODUCTIONPLAN_ID, '' AS PRODUCTION_PLAN, '' AS M_INTERNAL_CONSUMPTION_ID
carlos@0
    44
      FROM M_PRODUCT left join C_BPARTNER on M_PRODUCT.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
vinoth@3684
    45
                     right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID
vinoth@3684
    46
                     left join M_ATTRIBUTESETINSTANCE ON M_ATTRIBUTESETINSTANCE.M_ATTRIBUTESETINSTANCE_ID=M_TRANSACTION.M_ATTRIBUTESETINSTANCE_ID,
sandra@16207
    47
           M_LOCATOR, M_INOUTLINE, M_INOUT, C_UOM, M_WAREHOUSE
carlos@0
    48
      WHERE M_TRANSACTION.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
carlos@0
    49
      AND M_TRANSACTION.M_INOUTLINE_ID = M_INOUTLINE.M_INOUTLINE_ID
carlos@0
    50
      AND M_INOUTLINE.M_INOUT_ID = M_INOUT.M_INOUT_ID
carlos@0
    51
      AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
sandra@16207
    52
      AND M_LOCATOR.M_WAREHOUSE_ID = M_WAREHOUSE.M_WAREHOUSE_ID 
carlos@0
    53
      AND M_TRANSACTION.M_INOUTLINE_ID IS NOT NULL 
carlos@0
    54
      AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
carlos@0
    55
      AND M_TRANSACTION.AD_ORG_ID IN ('1')
carlos@0
    56
      AND 1=1
carlos@0
    57
      GROUP BY M_PRODUCT.VALUE, M_PRODUCT.NAME, M_TRANSACTION.MOVEMENTDATE, C_BPARTNER.NAME, M_LOCATOR.X, M_LOCATOR.Y, 
sandra@16207
    58
      M_LOCATOR.Z, M_INOUT.ISSOTRX, C_UOM.NAME, M_INOUT.M_INOUT_ID, M_INOUT.DOCUMENTNO, M_ATTRIBUTESETINSTANCE.DESCRIPTION,
sandra@16207
    59
      M_WAREHOUSE.NAME
carlos@0
    60
      ORDER BY C_BPARTNER.NAME, M_TRANSACTION.MOVEMENTDATE DESC
carlos@0
    61
     ]]></Sql>
rafael@1506
    62
    <Parameter name="adLanguage"/>
carlos@0
    63
    <Field name="rownum" value="count"/>
carlos@0
    64
    <Parameter name="adUserClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
    65
    <Parameter name="adOrgClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_ORG_ID IN (" text="'1'"/>
carlos@0
    66
    <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE >= to_date(?)]]></Parameter>
carlos@0
    67
    <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
juanpablo@1605
    68
    <Parameter name="cBpartner" optional="true" after="AND 1=1"><![CDATA[ AND C_BPARTNER.C_BPARTNER_ID = ?]]></Parameter>
juanpablo@1605
    69
    <Parameter name="mProductId" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID = ?]]></Parameter>
juanpablo@1605
    70
    <Parameter name="parmAttributeSetInstanceId" optional="true" after="AND 1=1"><![CDATA[AND M_TRANSACTION.M_ATTRIBUTESETINSTANCE_ID = ?]]></Parameter>
carlos@0
    71
  </SqlMethod>
carlos@0
    72
carlos@0
    73
  <SqlMethod name="selectInventory" type="preparedStatement" return="multiple">
carlos@0
    74
    <SqlMethodComment></SqlMethodComment>
carlos@0
    75
    <Sql>
carlos@0
    76
    <![CDATA[
sandra@16207
    77
      SELECT M_PRODUCT.VALUE, M_PRODUCT.NAME, M_WAREHOUSE.NAME as WA_ORIGIN, 
sandra@16207
    78
      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
    79
      (SUM(M_TRANSACTION.MOVEMENTQTY)||' '||C_UOM.NAME) AS MOVEMENTQTY, M_TRANSACTION.MOVEMENTDATE, 'No' AS OUT,
carlos@0
    80
      M_INVENTORY.M_INVENTORY_ID, M_INVENTORY.NAME AS MOVEMENT, M_INVENTORY.NAME AS MOVEMENT_DESCRIPTION
carlos@0
    81
      FROM M_PRODUCT left join C_BPARTNER on M_PRODUCT.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
carlos@0
    82
                     right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID,
sandra@16207
    83
          M_LOCATOR,  C_UOM, M_INVENTORYLINE, M_INVENTORY,  M_WAREHOUSE
carlos@0
    84
      WHERE  M_TRANSACTION.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
carlos@0
    85
      AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
carlos@0
    86
      AND M_TRANSACTION.M_INVENTORYLINE_ID = M_INVENTORYLINE.M_INVENTORYLINE_ID
carlos@0
    87
      AND M_INVENTORYLINE.M_INVENTORY_ID = M_INVENTORY.M_INVENTORY_ID
sandra@16207
    88
      AND M_LOCATOR.M_WAREHOUSE_ID = M_WAREHOUSE.M_WAREHOUSE_ID 
carlos@0
    89
      AND M_TRANSACTION.M_INVENTORYLINE_ID IS NOT NULL
carlos@0
    90
      AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
carlos@0
    91
      AND M_TRANSACTION.AD_ORG_ID IN ('1')
carlos@0
    92
      AND 1=1
carlos@0
    93
      GROUP BY M_PRODUCT.VALUE, M_PRODUCT.NAME, M_LOCATOR.X, M_LOCATOR.Y, M_LOCATOR.Z, C_BPARTNER.NAME, C_UOM.NAME, 
sandra@16207
    94
      M_TRANSACTION.MOVEMENTDATE, M_INVENTORY.M_INVENTORY_ID, M_INVENTORY.NAME, M_WAREHOUSE.NAME
carlos@0
    95
      HAVING SUM(M_TRANSACTION.MOVEMENTQTY) <> 0
carlos@0
    96
      ORDER BY C_BPARTNER.NAME, M_TRANSACTION.MOVEMENTDATE DESC
carlos@0
    97
     ]]></Sql>
carlos@0
    98
    <Field name="rownum" value="count"/>
carlos@0
    99
    <Parameter name="adUserClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
   100
    <Parameter name="adOrgClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_ORG_ID IN (" text="'1'"/>
carlos@0
   101
    <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE >= to_date(?)]]></Parameter>
carlos@0
   102
    <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
juanpablo@1605
   103
    <Parameter name="cBpartner" optional="true" after="AND 1=1"><![CDATA[ AND C_BPARTNER.C_BPARTNER_ID = ?]]></Parameter>
juanpablo@1605
   104
    <Parameter name="mProductId" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID = ?]]></Parameter>
carlos@0
   105
  </SqlMethod>
carlos@0
   106
carlos@0
   107
  <SqlMethod name="selectMovement" type="preparedStatement" return="multiple">
carlos@0
   108
    <SqlMethodComment></SqlMethodComment>
carlos@0
   109
    <Sql>
carlos@0
   110
    <![CDATA[
sandra@16207
   111
        SELECT M_PRODUCT.VALUE, M_PRODUCT.NAME, M_WAREHOUSE.NAME as WA_ORIGIN, M_LOCATOR.X AS X_ORIGIN, 
sandra@16207
   112
        M_LOCATOR.Y AS Y_ORIGIN, M_LOCATOR.Z AS Z_ORIGIN, M_L_WAREHOUSE.NAME as WA_DESTINY,
carlos@0
   113
        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
   114
        (M_TRANSACTION.MOVEMENTQTY||' '||C_UOM.NAME) AS MOVEMENTQTY, M_TRANSACTION.MOVEMENTDATE, 'No' AS OUT,
carlos@0
   115
        M_MOVEMENTLINE.M_MOVEMENT_ID, M_MOVEMENT.NAME AS MOVEMENT
carlos@0
   116
        FROM  M_PRODUCT left join C_BPARTNER on M_PRODUCT.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
carlos@0
   117
                        right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID,
sandra@16207
   118
        M_MOVEMENTLINE, M_LOCATOR, M_LOCATOR M_L,  C_UOM,M_MOVEMENT,  M_WAREHOUSE, M_WAREHOUSE M_L_WAREHOUSE
carlos@0
   119
        WHERE M_TRANSACTION.M_MOVEMENTLINE_ID = M_MOVEMENTLINE.M_MOVEMENTLINE_ID
carlos@0
   120
        AND M_MOVEMENTLINE.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
carlos@0
   121
        AND M_MOVEMENTLINE.M_LOCATORTO_ID = M_L.M_LOCATOR_ID
carlos@0
   122
        AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
sandra@16207
   123
        AND M_LOCATOR.M_WAREHOUSE_ID = M_WAREHOUSE.M_WAREHOUSE_ID
sandra@16207
   124
        AND M_L.M_WAREHOUSE_ID = M_L_WAREHOUSE.M_WAREHOUSE_ID
carlos@0
   125
        AND M_TRANSACTION.M_MOVEMENTLINE_ID IS NOT NULL
carlos@0
   126
        AND M_MOVEMENTLINE.M_MOVEMENT_ID = M_MOVEMENT.M_MOVEMENT_ID
carlos@0
   127
        AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
carlos@0
   128
        AND M_TRANSACTION.AD_ORG_ID IN ('1')
carlos@0
   129
        AND 1=1
carlos@0
   130
        AND M_TRANSACTION.MOVEMENTQTY >0
carlos@0
   131
        ORDER BY C_BPARTNER.NAME, M_TRANSACTION.MOVEMENTDATE DESC
carlos@0
   132
     ]]></Sql>
carlos@0
   133
    <Field name="rownum" value="count"/>
carlos@0
   134
    <Parameter name="adUserClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
   135
    <Parameter name="adOrgClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_ORG_ID IN (" text="'1'"/>
carlos@0
   136
    <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE >= to_date(?)]]></Parameter>
carlos@0
   137
    <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
juanpablo@1605
   138
    <Parameter name="cBpartner" optional="true" after="AND 1=1"><![CDATA[ AND C_BPARTNER.C_BPARTNER_ID = ?]]></Parameter>
juanpablo@1605
   139
    <Parameter name="mProductId" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID = ?]]></Parameter>
carlos@0
   140
  </SqlMethod>
carlos@0
   141
carlos@0
   142
  <SqlMethod name="selectProduction" type="preparedStatement" return="multiple">
carlos@0
   143
    <SqlMethodComment></SqlMethodComment>
carlos@0
   144
    <Sql>
carlos@0
   145
    <![CDATA[
sandra@16207
   146
        SELECT M_PRODUCT.VALUE, M_PRODUCT.NAME, M_WAREHOUSE.NAME as WA_ORIGIN, M_LOCATOR.X AS X_ORIGIN, M_LOCATOR.Y AS Y_ORIGIN, M_LOCATOR.Z AS Z_ORIGIN,
sandra@16207
   147
        C_BPARTNER.NAME AS PARTNERNAME, '-' AS WA_DESTINY, '-' AS X_DESTINY, '-' AS Y_DESTINY, '-' AS Z_DESTINY, 
ainhoa@3600
   148
        (SUM(M_TRANSACTION.MOVEMENTQTY)||' '||C_UOM.NAME) AS MOVEMENTQTY, M_TRANSACTION.MOVEMENTDATE, 'No' AS OUT, M_PRODUCTION.ISSOTRX AS ISSOTRX,
ainhoa@3600
   149
        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
   150
        FROM M_PRODUCT left join C_BPARTNER on M_PRODUCT.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
carlos@0
   151
                       right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID,
sandra@16207
   152
             M_LOCATOR, C_UOM, M_PRODUCTIONLINE, M_PRODUCTIONPLAN, M_PRODUCTION, M_WAREHOUSE
carlos@0
   153
        WHERE M_TRANSACTION.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
carlos@0
   154
        AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
carlos@0
   155
        AND M_TRANSACTION.M_PRODUCTIONLINE_ID = M_PRODUCTIONLINE.M_PRODUCTIONLINE_ID
carlos@0
   156
        AND M_PRODUCTIONLINE.M_PRODUCTIONPLAN_ID = M_PRODUCTIONPLAN.M_PRODUCTIONPLAN_ID
carlos@0
   157
        AND M_PRODUCTIONPLAN.M_PRODUCTION_ID = M_PRODUCTION.M_PRODUCTION_ID
sandra@16207
   158
        AND M_LOCATOR.M_WAREHOUSE_ID = M_WAREHOUSE.M_WAREHOUSE_ID
carlos@0
   159
        AND M_TRANSACTION.M_PRODUCTIONLINE_ID IS NOT NULL
carlos@0
   160
        AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
carlos@0
   161
        AND M_TRANSACTION.AD_ORG_ID IN ('1')
carlos@0
   162
        AND 1=1
carlos@0
   163
        GROUP BY M_PRODUCT.VALUE, M_PRODUCT.NAME, M_LOCATOR.X, M_LOCATOR.Y, M_LOCATOR.Z, C_BPARTNER.NAME, C_UOM.NAME, 
sandra@16207
   164
        M_TRANSACTION.MOVEMENTDATE,M_PRODUCTIONPLAN.M_PRODUCTIONPLAN_ID, M_PRODUCTION.NAME, M_PRODUCTIONPLAN.LINE, M_PRODUCTION.ISSOTRX, M_PRODUCTION.DOCUMENTNO, M_WAREHOUSE.NAME
carlos@0
   165
        HAVING SUM(M_TRANSACTION.MOVEMENTQTY) <> 0
carlos@0
   166
        ORDER BY C_BPARTNER.NAME, M_TRANSACTION.MOVEMENTDATE DESC
carlos@0
   167
     ]]></Sql>
carlos@0
   168
    <Field name="rownum" value="count"/>
carlos@0
   169
    <Parameter name="adUserClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
   170
    <Parameter name="adOrgClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_ORG_ID IN (" text="'1'"/>
carlos@0
   171
    <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE >= to_date(?)]]></Parameter>
carlos@0
   172
    <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
juanpablo@1605
   173
    <Parameter name="cBpartner" optional="true" after="AND 1=1"><![CDATA[ AND C_BPARTNER.C_BPARTNER_ID = ?]]></Parameter>
juanpablo@1605
   174
    <Parameter name="mProductId" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID = ?]]></Parameter>
carlos@0
   175
  </SqlMethod>
unai@15925
   176
  
unai@15925
   177
  <SqlMethod name="selectInternalConsumption" type="preparedStatement" return="multiple">
unai@15925
   178
    <SqlMethodComment></SqlMethodComment>
unai@15925
   179
    <Sql>
unai@15925
   180
    <![CDATA[
sandra@16207
   181
      SELECT M_PRODUCT.VALUE, M_PRODUCT.NAME, M_WAREHOUSE.NAME as WA_ORIGIN, 
sandra@16207
   182
      M_LOCATOR.X AS X_ORIGIN, M_LOCATOR.Y AS Y_ORIGIN, M_LOCATOR.Z AS Z_ORIGIN, C_BPARTNER.NAME AS PARTNERNAME, 
unai@15925
   183
      (SUM(M_TRANSACTION.MOVEMENTQTY)||' '||C_UOM.NAME) AS MOVEMENTQTY, M_TRANSACTION.MOVEMENTDATE, 'No' AS OUT,
unai@15925
   184
      M_INTERNAL_CONSUMPTION.M_INTERNAL_CONSUMPTION_ID, M_INTERNAL_CONSUMPTION.NAME AS MOVEMENT, M_INTERNAL_CONSUMPTION.NAME AS MOVEMENT_DESCRIPTION
unai@15925
   185
      FROM M_PRODUCT left join C_BPARTNER on M_PRODUCT.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
unai@15925
   186
                     right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID,
sandra@16207
   187
          M_LOCATOR,  C_UOM, M_INTERNAL_CONSUMPTIONLINE, M_INTERNAL_CONSUMPTION, M_WAREHOUSE
unai@15925
   188
      WHERE  M_TRANSACTION.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
unai@15925
   189
      AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
unai@15925
   190
      AND M_TRANSACTION.M_INTERNAL_CONSUMPTIONLINE_ID = M_INTERNAL_CONSUMPTIONLINE.M_INTERNAL_CONSUMPTIONLINE_ID
unai@15925
   191
      AND M_INTERNAL_CONSUMPTIONLINE.M_INTERNAL_CONSUMPTION_ID = M_INTERNAL_CONSUMPTION.M_INTERNAL_CONSUMPTION_ID
sandra@16207
   192
      AND M_LOCATOR.M_WAREHOUSE_ID = M_WAREHOUSE.M_WAREHOUSE_ID
unai@15925
   193
      AND M_TRANSACTION.M_INTERNAL_CONSUMPTIONLINE_ID IS NOT NULL
unai@15925
   194
      AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
unai@15925
   195
      AND M_TRANSACTION.AD_ORG_ID IN ('1')
unai@15925
   196
      AND 1=1
unai@15925
   197
      GROUP BY M_PRODUCT.VALUE, M_PRODUCT.NAME, M_LOCATOR.X, M_LOCATOR.Y, M_LOCATOR.Z, C_BPARTNER.NAME, C_UOM.NAME, 
sandra@16207
   198
      M_TRANSACTION.MOVEMENTDATE, M_INTERNAL_CONSUMPTION.M_INTERNAL_CONSUMPTION_ID, M_INTERNAL_CONSUMPTION.NAME, M_INTERNAL_CONSUMPTION.DESCRIPTION, M_WAREHOUSE.NAME
unai@15925
   199
      HAVING SUM(M_TRANSACTION.MOVEMENTQTY) <> 0
unai@15925
   200
      ORDER BY C_BPARTNER.NAME, M_TRANSACTION.MOVEMENTDATE DESC
unai@15925
   201
     ]]></Sql>
unai@15925
   202
    <Field name="rownum" value="count"/>
unai@15925
   203
    <Parameter name="adUserClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_CLIENT_ID IN (" text="'1'"/>
unai@15925
   204
    <Parameter name="adOrgClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_ORG_ID IN (" text="'1'"/>
unai@15925
   205
    <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE >= to_date(?)]]></Parameter>
unai@15925
   206
    <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
unai@15925
   207
    <Parameter name="cBpartner" optional="true" after="AND 1=1"><![CDATA[ AND C_BPARTNER.C_BPARTNER_ID = ?]]></Parameter>
unai@15925
   208
    <Parameter name="mProductId" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID = ?]]></Parameter>
unai@15925
   209
  </SqlMethod>
carlos@0
   210
carlos@0
   211
  <SqlMethod name="selectBpartner" type="preparedStatement" return="String" default="">
carlos@0
   212
    <SqlMethodComment></SqlMethodComment>
carlos@0
   213
    <Sql>
carlos@0
   214
    <![CDATA[
carlos@0
   215
      SELECT C_BPARTNER.NAME
carlos@0
   216
      FROM C_BPARTNER
juanpablo@1605
   217
      WHERE C_BPARTNER.C_BPARTNER_ID = ?
carlos@0
   218
     ]]></Sql>
carlos@0
   219
    <Parameter name="cBpartnerId"/>
carlos@0
   220
  </SqlMethod>
carlos@0
   221
carlos@0
   222
  <SqlMethod name="selectMproduct" type="preparedStatement" return="String" default="">
carlos@0
   223
    <SqlMethodComment></SqlMethodComment>
carlos@0
   224
    <Sql>
carlos@0
   225
    <![CDATA[
carlos@0
   226
      SELECT M_PRODUCT.NAME
carlos@0
   227
      FROM M_PRODUCT
juanpablo@1605
   228
      WHERE M_PRODUCT.M_PRODUCT_ID = ?
carlos@0
   229
     ]]></Sql>
carlos@0
   230
    <Parameter name="mProductId"/>
carlos@0
   231
  </SqlMethod>
carlos@0
   232
carlos@0
   233
  <SqlMethod name="set" type="constant" return="multiple">
carlos@0
   234
      <SqlMethodComment></SqlMethodComment>
carlos@0
   235
      <Sql></Sql>
carlos@0
   236
  </SqlMethod>
carlos@0
   237
</SqlClass>