src/org/openbravo/erpCommon/ad_reports/ReportInventory_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 1605 8a0fe0193bef
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="ReportInventoryData" 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 T.M_LOCATOR_ID, M.VALUE AS LOCATOR, T.M_PRODUCT_ID, P.NAME AS PRODUCT, 
carlos@0
    32
      ROUND(SUM(T.QTYONHAND), 2) AS PRODUCT_QTY, T.C_UOM_ID, C1.NAME AS PRODUCT_UOM, 
carlos@0
    33
      T.M_PRODUCT_UOM_ID, C2.NAME AS ORDER_UOM, 
carlos@0
    34
      ROUND(SUM(T.QTYORDERONHAND), 2) AS ORDER_QTY, 
carlos@0
    35
      ATT.DESCRIPTION AS LOT
carlos@0
    36
      FROM M_STORAGE_DETAIL T left join M_ATTRIBUTESETINSTANCE ATT on T.M_ATTRIBUTESETINSTANCE_ID = ATT.M_ATTRIBUTESETINSTANCE_ID 
carlos@0
    37
                              right join M_PRODUCT_UOM P_UOM        on T.M_PRODUCT_UOM_ID = P_UOM.M_PRODUCT_UOM_ID 
carlos@0
    38
                              left join C_UOM C2                   on P_UOM.C_UOM_ID = C2.C_UOM_ID,
carlos@0
    39
           M_LOCATOR M, M_PRODUCT P,  C_UOM C1
carlos@423
    40
      WHERE T.M_PRODUCT_ID = TO_NUMBER(?) 
carlos@0
    41
      AND T.M_PRODUCT_ID = P.M_PRODUCT_ID 
carlos@0
    42
      AND T.M_LOCATOR_ID = M.M_LOCATOR_ID 
carlos@0
    43
      AND T.C_UOM_ID = C1.C_UOM_ID 
carlos@0
    44
      AND COALESCE(C1.C_UOM_ID,0) = COALESCE(to_number(?), 0)
carlos@423
    45
      AND T.M_LOCATOR_ID = TO_NUMBER(?) 
carlos@0
    46
      AND T.AD_CLIENT_ID IN ('1') 
carlos@0
    47
      AND T.AD_ORG_ID IN ('2') 
carlos@0
    48
      AND 1=1
carlos@0
    49
      AND ROUND(T.QTYONHAND, 2) <> 0 
carlos@0
    50
      GROUP BY T.M_LOCATOR_ID, M.VALUE, T.M_PRODUCT_ID, P.NAME, T.C_UOM_ID, C1.NAME, T.M_PRODUCT_UOM_ID, C2.NAME, ATT.DESCRIPTION
carlos@0
    51
      ORDER BY M.VALUE, P.NAME , ATT.DESCRIPTION 
carlos@0
    52
      ]]></Sql>
carlos@0
    53
      <Parameter name="mProductId"/>
carlos@0
    54
      <Parameter name="mProductUom"/>
carlos@0
    55
      <Parameter name="mLocatorId"/>
carlos@0
    56
      <Parameter name="adClientId" optional="true" type="replace" after="AND T.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
    57
      <Parameter name="adOrgId" optional="true" type="replace" after="AND T.AD_ORG_ID IN (" text="'2'"/>
carlos@0
    58
  </SqlMethod>
carlos@0
    59
  <SqlMethod name="selectSinDetalle" type="preparedStatement" return="multiple">
carlos@0
    60
    <SqlMethodComment></SqlMethodComment>
carlos@0
    61
    <Sql>
carlos@0
    62
    <![CDATA[
carlos@0
    63
      SELECT  T.M_LOCATOR_ID, M.VALUE AS LOCATOR, T.M_PRODUCT_ID, P.NAME AS PRODUCT, 
carlos@0
    64
      ROUND(SUM(T.QTYONHAND), 2) AS PRODUCT_QTY, T.C_UOM_ID, C1.NAME AS PRODUCT_UOM, 
carlos@0
    65
      T.M_PRODUCT_UOM_ID, C2.NAME AS ORDER_UOM, 
carlos@0
    66
      ROUND(SUM(T.QTYORDERONHAND), 2) AS ORDER_QTY 
carlos@0
    67
      FROM M_PRODUCT_UOM P_UOM left join C_UOM C2 on P_UOM.C_UOM_ID = C2.C_UOM_ID 
carlos@0
    68
                               right join M_STORAGE_DETAIL T on T.M_PRODUCT_UOM_ID = P_UOM.M_PRODUCT_UOM_ID,
carlos@0
    69
           M_LOCATOR M, M_WAREHOUSE MW, M_PRODUCT P,  C_UOM C1
carlos@0
    70
      WHERE T.M_PRODUCT_ID = P.M_PRODUCT_ID 
carlos@0
    71
      AND T.M_LOCATOR_ID = M.M_LOCATOR_ID 
carlos@0
    72
      AND MW.M_WAREHOUSE_ID = M.M_WAREHOUSE_ID
carlos@0
    73
      AND T.C_UOM_ID = C1.C_UOM_ID 
carlos@0
    74
      AND T.AD_CLIENT_ID IN ('1') 
carlos@0
    75
      AND T.AD_ORG_ID IN ('2') 
carlos@0
    76
      AND (ROUND(T.QTYONHAND, 2) <> 0 OR ROUND(T.QTYORDERONHAND, 2) <> 0)
carlos@0
    77
      GROUP BY T.M_LOCATOR_ID, M.VALUE, T.M_PRODUCT_ID, P.NAME, T.C_UOM_ID, C1.NAME, T.M_PRODUCT_UOM_ID, C2.NAME
carlos@0
    78
      ORDER BY LOCATOR, PRODUCT
carlos@0
    79
      ]]></Sql>
carlos@423
    80
      <Parameter name="mWarehouseId" optional="true" after="WHERE " text=" MW.M_WAREHOUSE_ID = TO_NUMBER(?) AND "/>
carlos@0
    81
      <Parameter name="adClientId" optional="true" type="replace" after="AND T.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
    82
      <Parameter name="adOrgId" optional="true" type="replace" after="AND T.AD_ORG_ID IN (" text="'2'"/>
carlos@0
    83
  </SqlMethod>
carlos@0
    84
  <SqlMethod name="set" type="constant" return="multiple">
carlos@0
    85
      <SqlMethodComment></SqlMethodComment>
carlos@0
    86
      <Sql></Sql>
carlos@0
    87
  </SqlMethod>
carlos@0
    88
  <SqlMethod name="warehouseDescription" type="preparedStatement" return="String" default="">
carlos@0
    89
    <SqlMethodComment></SqlMethodComment>
carlos@0
    90
    <Sql>
carlos@0
    91
    SELECT VALUE FROM M_WAREHOUSE
carlos@423
    92
    WHERE M_WAREHOUSE_ID = TO_NUMBER(?)
carlos@0
    93
    </Sql>
carlos@0
    94
    <Parameter name="mLocatorId"/>
carlos@0
    95
  </SqlMethod>
carlos@0
    96
</SqlClass>