src/org/openbravo/erpCommon/ad_reports/ReportProductMovement_data.xsql
author David Baz Fayos <david.baz@openbravo.com>
Tue, 27 May 2008 15:26:10 +0000
changeset 1044 8691bbc94032
parent 423 ecf368072c48
child 1506 0b4c48b88274
permissions -rw-r--r--
Removed old frame parameter of windowTableId
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 
carlos@0
    15
 * All portions are Copyright (C) 2001-2006 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[
carlos@0
    31
      SELECT M_PRODUCT.VALUE, M_PRODUCT.NAME, M_TRANSACTION.MOVEMENTDATE, C_BPARTNER.NAME AS PARTNERNAME,
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,
carlos@0
    38
      (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN 'Si' ELSE 'No' END) AS OUT,
carlos@0
    39
      (SUM(M_TRANSACTION.MOVEMENTQTY)||' '||C_UOM.NAME) AS MOVEMENTQTY, M_INOUT.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
carlos@0
    43
                     right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID,
carlos@0
    44
           M_LOCATOR, M_INOUTLINE, M_INOUT, C_UOM
carlos@0
    45
      WHERE M_TRANSACTION.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
carlos@0
    46
      AND M_TRANSACTION.M_INOUTLINE_ID = M_INOUTLINE.M_INOUTLINE_ID
carlos@0
    47
      AND M_INOUTLINE.M_INOUT_ID = M_INOUT.M_INOUT_ID
carlos@0
    48
      AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
carlos@0
    49
      AND M_TRANSACTION.M_INOUTLINE_ID IS NOT NULL 
carlos@0
    50
      AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
carlos@0
    51
      AND M_TRANSACTION.AD_ORG_ID IN ('1')
carlos@0
    52
      AND 1=1
carlos@0
    53
      GROUP BY M_PRODUCT.VALUE, M_PRODUCT.NAME, M_TRANSACTION.MOVEMENTDATE, C_BPARTNER.NAME, M_LOCATOR.X, M_LOCATOR.Y, 
carlos@0
    54
      M_LOCATOR.Z, M_INOUT.ISSOTRX, C_UOM.NAME, M_INOUT.M_INOUT_ID, M_INOUT.DOCUMENTNO
carlos@0
    55
      ORDER BY C_BPARTNER.NAME, M_TRANSACTION.MOVEMENTDATE DESC
carlos@0
    56
     ]]></Sql>
carlos@0
    57
    <Field name="rownum" value="count"/>
carlos@0
    58
    <Parameter name="adUserClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
    59
    <Parameter name="adOrgClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_ORG_ID IN (" text="'1'"/>
carlos@0
    60
    <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE >= to_date(?)]]></Parameter>
carlos@0
    61
    <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
carlos@423
    62
    <Parameter name="cBpartner" optional="true" after="AND 1=1"><![CDATA[ AND C_BPARTNER.C_BPARTNER_ID = TO_NUMBER(?)]]></Parameter>
carlos@423
    63
    <Parameter name="mProductId" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID = TO_NUMBER(?)]]></Parameter>
carlos@0
    64
  </SqlMethod>
carlos@0
    65
carlos@0
    66
  <SqlMethod name="selectInventory" type="preparedStatement" return="multiple">
carlos@0
    67
    <SqlMethodComment></SqlMethodComment>
carlos@0
    68
    <Sql>
carlos@0
    69
    <![CDATA[
carlos@0
    70
      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
    71
      (SUM(M_TRANSACTION.MOVEMENTQTY)||' '||C_UOM.NAME) AS MOVEMENTQTY, M_TRANSACTION.MOVEMENTDATE, 'No' AS OUT,
carlos@0
    72
      M_INVENTORY.M_INVENTORY_ID, M_INVENTORY.NAME AS MOVEMENT, M_INVENTORY.NAME AS MOVEMENT_DESCRIPTION
carlos@0
    73
      FROM M_PRODUCT left join C_BPARTNER on M_PRODUCT.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
carlos@0
    74
                     right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID,
carlos@0
    75
          M_LOCATOR,  C_UOM, M_INVENTORYLINE, M_INVENTORY
carlos@0
    76
      WHERE  M_TRANSACTION.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
carlos@0
    77
      AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
carlos@0
    78
      AND M_TRANSACTION.M_INVENTORYLINE_ID = M_INVENTORYLINE.M_INVENTORYLINE_ID
carlos@0
    79
      AND M_INVENTORYLINE.M_INVENTORY_ID = M_INVENTORY.M_INVENTORY_ID
carlos@0
    80
      AND M_TRANSACTION.M_INVENTORYLINE_ID IS NOT NULL
carlos@0
    81
      AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
carlos@0
    82
      AND M_TRANSACTION.AD_ORG_ID IN ('1')
carlos@0
    83
      AND 1=1
carlos@0
    84
      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
    85
      M_TRANSACTION.MOVEMENTDATE, M_INVENTORY.M_INVENTORY_ID, M_INVENTORY.NAME
carlos@0
    86
      HAVING SUM(M_TRANSACTION.MOVEMENTQTY) <> 0
carlos@0
    87
      ORDER BY C_BPARTNER.NAME, M_TRANSACTION.MOVEMENTDATE DESC
carlos@0
    88
     ]]></Sql>
carlos@0
    89
    <Field name="rownum" value="count"/>
carlos@0
    90
    <Parameter name="adUserClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
    91
    <Parameter name="adOrgClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_ORG_ID IN (" text="'1'"/>
carlos@0
    92
    <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE >= to_date(?)]]></Parameter>
carlos@0
    93
    <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
carlos@423
    94
    <Parameter name="cBpartner" optional="true" after="AND 1=1"><![CDATA[ AND C_BPARTNER.C_BPARTNER_ID = TO_NUMBER(?)]]></Parameter>
carlos@423
    95
    <Parameter name="mProductId" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID = TO_NUMBER(?)]]></Parameter>
carlos@0
    96
  </SqlMethod>
carlos@0
    97
carlos@0
    98
  <SqlMethod name="selectMovement" type="preparedStatement" return="multiple">
carlos@0
    99
    <SqlMethodComment></SqlMethodComment>
carlos@0
   100
    <Sql>
carlos@0
   101
    <![CDATA[
carlos@0
   102
        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
   103
        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
   104
        (M_TRANSACTION.MOVEMENTQTY||' '||C_UOM.NAME) AS MOVEMENTQTY, M_TRANSACTION.MOVEMENTDATE, 'No' AS OUT,
carlos@0
   105
        M_MOVEMENTLINE.M_MOVEMENT_ID, M_MOVEMENT.NAME AS MOVEMENT
carlos@0
   106
        FROM  M_PRODUCT left join C_BPARTNER on M_PRODUCT.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
carlos@0
   107
                        right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID,
carlos@0
   108
         M_MOVEMENTLINE, M_LOCATOR, M_LOCATOR M_L,  C_UOM,
carlos@0
   109
        M_MOVEMENT
carlos@0
   110
        WHERE M_TRANSACTION.M_MOVEMENTLINE_ID = M_MOVEMENTLINE.M_MOVEMENTLINE_ID
carlos@0
   111
        AND M_MOVEMENTLINE.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
carlos@0
   112
        AND M_MOVEMENTLINE.M_LOCATORTO_ID = M_L.M_LOCATOR_ID
carlos@0
   113
        AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
carlos@0
   114
        AND M_TRANSACTION.M_MOVEMENTLINE_ID IS NOT NULL
carlos@0
   115
        AND M_MOVEMENTLINE.M_MOVEMENT_ID = M_MOVEMENT.M_MOVEMENT_ID
carlos@0
   116
        AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
carlos@0
   117
        AND M_TRANSACTION.AD_ORG_ID IN ('1')
carlos@0
   118
        AND 1=1
carlos@0
   119
        AND M_TRANSACTION.MOVEMENTQTY >0
carlos@0
   120
        ORDER BY C_BPARTNER.NAME, M_TRANSACTION.MOVEMENTDATE DESC
carlos@0
   121
     ]]></Sql>
carlos@0
   122
    <Field name="rownum" value="count"/>
carlos@0
   123
    <Parameter name="adUserClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
   124
    <Parameter name="adOrgClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_ORG_ID IN (" text="'1'"/>
carlos@0
   125
    <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE >= to_date(?)]]></Parameter>
carlos@0
   126
    <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
carlos@423
   127
    <Parameter name="cBpartner" optional="true" after="AND 1=1"><![CDATA[ AND C_BPARTNER.C_BPARTNER_ID = TO_NUMBER(?)]]></Parameter>
carlos@423
   128
    <Parameter name="mProductId" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID = TO_NUMBER(?)]]></Parameter>
carlos@0
   129
  </SqlMethod>
carlos@0
   130
carlos@0
   131
  <SqlMethod name="selectProduction" type="preparedStatement" return="multiple">
carlos@0
   132
    <SqlMethodComment></SqlMethodComment>
carlos@0
   133
    <Sql>
carlos@0
   134
    <![CDATA[
carlos@0
   135
        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
   136
        C_BPARTNER.NAME AS PARTNERNAME, '-' AS X_DESTINY, '-' AS Y_DESTINY, '-' AS Z_DESTINY, 
carlos@0
   137
        (SUM(M_TRANSACTION.MOVEMENTQTY)||' '||C_UOM.NAME) AS MOVEMENTQTY, M_TRANSACTION.MOVEMENTDATE, 'No' AS OUT,
carlos@0
   138
        M_PRODUCTIONPLAN.M_PRODUCTIONPLAN_ID, (M_PRODUCTION.NAME || ' - ' || M_PRODUCTIONPLAN.LINE) AS PRODUCTION_PLAN
carlos@0
   139
        FROM M_PRODUCT left join C_BPARTNER on M_PRODUCT.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
carlos@0
   140
                       right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID,
carlos@0
   141
             M_LOCATOR, C_UOM, M_PRODUCTIONLINE, M_PRODUCTIONPLAN, M_PRODUCTION
carlos@0
   142
        WHERE M_TRANSACTION.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID
carlos@0
   143
        AND M_TRANSACTION.C_UOM_ID = C_UOM.C_UOM_ID
carlos@0
   144
        AND M_TRANSACTION.M_PRODUCTIONLINE_ID = M_PRODUCTIONLINE.M_PRODUCTIONLINE_ID
carlos@0
   145
        AND M_PRODUCTIONLINE.M_PRODUCTIONPLAN_ID = M_PRODUCTIONPLAN.M_PRODUCTIONPLAN_ID
carlos@0
   146
        AND M_PRODUCTIONPLAN.M_PRODUCTION_ID = M_PRODUCTION.M_PRODUCTION_ID
carlos@0
   147
        AND M_TRANSACTION.M_PRODUCTIONLINE_ID IS NOT NULL
carlos@0
   148
        AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
carlos@0
   149
        AND M_TRANSACTION.AD_ORG_ID IN ('1')
carlos@0
   150
        AND 1=1
carlos@0
   151
        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
   152
        M_TRANSACTION.MOVEMENTDATE,M_PRODUCTIONPLAN.M_PRODUCTIONPLAN_ID, M_PRODUCTION.NAME, M_PRODUCTIONPLAN.LINE
carlos@0
   153
        HAVING SUM(M_TRANSACTION.MOVEMENTQTY) <> 0
carlos@0
   154
        ORDER BY C_BPARTNER.NAME, M_TRANSACTION.MOVEMENTDATE DESC
carlos@0
   155
     ]]></Sql>
carlos@0
   156
    <Field name="rownum" value="count"/>
carlos@0
   157
    <Parameter name="adUserClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
   158
    <Parameter name="adOrgClient" type="replace" optional="true" after="AND M_TRANSACTION.AD_ORG_ID IN (" text="'1'"/>
carlos@0
   159
    <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE >= to_date(?)]]></Parameter>
carlos@0
   160
    <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
carlos@423
   161
    <Parameter name="cBpartner" optional="true" after="AND 1=1"><![CDATA[ AND C_BPARTNER.C_BPARTNER_ID = TO_NUMBER(?)]]></Parameter>
carlos@423
   162
    <Parameter name="mProductId" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID = TO_NUMBER(?)]]></Parameter>
carlos@0
   163
  </SqlMethod>
carlos@0
   164
carlos@0
   165
  <SqlMethod name="selectBpartner" type="preparedStatement" return="String" default="">
carlos@0
   166
    <SqlMethodComment></SqlMethodComment>
carlos@0
   167
    <Sql>
carlos@0
   168
    <![CDATA[
carlos@0
   169
      SELECT C_BPARTNER.NAME
carlos@0
   170
      FROM C_BPARTNER
carlos@423
   171
      WHERE C_BPARTNER.C_BPARTNER_ID = TO_NUMBER(?)
carlos@0
   172
     ]]></Sql>
carlos@0
   173
    <Parameter name="cBpartnerId"/>
carlos@0
   174
  </SqlMethod>
carlos@0
   175
carlos@0
   176
  <SqlMethod name="selectMproduct" type="preparedStatement" return="String" default="">
carlos@0
   177
    <SqlMethodComment></SqlMethodComment>
carlos@0
   178
    <Sql>
carlos@0
   179
    <![CDATA[
carlos@0
   180
      SELECT M_PRODUCT.NAME
carlos@0
   181
      FROM M_PRODUCT
carlos@423
   182
      WHERE M_PRODUCT.M_PRODUCT_ID = TO_NUMBER(?)
carlos@0
   183
     ]]></Sql>
carlos@0
   184
    <Parameter name="mProductId"/>
carlos@0
   185
  </SqlMethod>
carlos@0
   186
carlos@0
   187
  <SqlMethod name="set" type="constant" return="multiple">
carlos@0
   188
      <SqlMethodComment></SqlMethodComment>
carlos@0
   189
      <Sql></Sql>
carlos@0
   190
  </SqlMethod>
carlos@0
   191
</SqlClass>