src/org/openbravo/erpCommon/ad_reports/ReportWarehousePartner_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
<?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="ReportWarehousePartnerData" package="org.openbravo.erpCommon.ad_reports">
  <SqlClassComment></SqlClassComment>
  <SqlMethod name="select" type="preparedStatement" return="multiple">
    <SqlMethodComment></SqlMethodComment>
    <Sql>
    <![CDATA[
      SELECT M_PRODUCT_CATEGORY.NAME AS CATEGORYNAME, M_PRODUCT.VALUE||'-'||M_PRODUCT.NAME AS NAME, SUM(MOVEMENTQTY) AS MOVEMENTQTY, M_LOCATOR.X, M_LOCATOR.Y, 
      AD_COLUMN_IDENTIFIER('M_WAREHOUSE', to_char(M_LOCATOR.M_WAREHOUSE_ID), ?) AS WAREHOUSE,
      M_LOCATOR.Z, C1.NAME AS UOMMOVEMENTQTY, M_ATTRIBUTESETINSTANCE.M_ATTRIBUTESETINSTANCE_ID, M_ATTRIBUTESETINSTANCE.DESCRIPTION,
      (CASE WHEN M_TRANSACTION.M_PRODUCT_UOM_ID IS NULL THEN (CASE M_PRODUCT.WEIGHT*SUM(M_TRANSACTION.MOVEMENTQTY) WHEN 0 THEN NULL ELSE M_PRODUCT.WEIGHT*SUM(M_TRANSACTION.MOVEMENTQTY) END) ELSE SUM(M_TRANSACTION.QUANTITYORDER) END) AS WEIGHT, 
      (CASE WHEN M_TRANSACTION.M_PRODUCT_UOM_ID IS NULL THEN (CASE WHEN M_PRODUCT.WEIGHT = 0 THEN '' WHEN M_PRODUCT.WEIGHT IS NULL THEN '' ELSE 'Kgs' END) ELSE TO_CHAR(C2.NAME) END) AS UOMWEIGHT, '' as id
      FROM M_PRODUCT left join M_PRODUCT_CATEGORY on M_PRODUCT.M_PRODUCT_CATEGORY_ID  = M_PRODUCT_CATEGORY.M_PRODUCT_CATEGORY_ID,
           M_PRODUCT_UOM right join M_TRANSACTION on M_TRANSACTION.M_PRODUCT_UOM_ID = M_PRODUCT_UOM.M_PRODUCT_UOM_ID
                         left join C_UOM C2 on M_PRODUCT_UOM.C_UOM_ID = C2.C_UOM_ID,
        M_LOCATOR, C_UOM C1, M_ATTRIBUTESETINSTANCE
      WHERE M_TRANSACTION.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID
      AND M_TRANSACTION.M_ATTRIBUTESETINSTANCE_ID = M_ATTRIBUTESETINSTANCE.M_ATTRIBUTESETINSTANCE_ID
      AND M_TRANSACTION.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID 
      AND M_TRANSACTION.C_UOM_ID = C1.C_UOM_ID
      AND M_TRANSACTION.AD_CLIENT_ID IN ('1')
      AND M_TRANSACTION.AD_ORG_ID IN ('1')
      AND 1=1
      GROUP BY M_PRODUCT_CATEGORY.NAME,M_PRODUCT.VALUE, M_PRODUCT.NAME, M_ATTRIBUTESETINSTANCE.M_ATTRIBUTESETINSTANCE_ID, M_ATTRIBUTESETINSTANCE.DESCRIPTION, M_LOCATOR.M_LOCATOR_ID, M_LOCATOR.X, M_LOCATOR.Y, M_LOCATOR.Z, C1.NAME, M_PRODUCT.WEIGHT, C1.C_UOM_ID, M_TRANSACTION.M_PRODUCT_UOM_ID, C2.NAME, M_LOCATOR.M_WAREHOUSE_ID
      HAVING SUM(MOVEMENTQTY) > 0
      ORDER BY  M_PRODUCT_CATEGORY.NAME,M_PRODUCT.VALUE, M_PRODUCT.NAME, M_ATTRIBUTESETINSTANCE.DESCRIPTION,M_LOCATOR.X, M_LOCATOR.Y, M_LOCATOR.Z
     ]]></Sql>
    <Parameter name="language"/>
    <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="parDate" optional="true" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
    <Parameter name="mProduct" optional="true" type="argument" after="AND 1=1"><![CDATA[ AND M_TRANSACTION.M_PRODUCT_ID IN]]></Parameter>
    <Parameter name="mProductCategory" optional="true" after="AND 1=1"><![CDATA[ AND M_PRODUCT_CATEGORY.M_PRODUCT_CATEGORY_ID = TO_NUMBER(?)]]></Parameter>
    <Parameter name="locatorX" optional="true" after="AND 1=1"><![CDATA[ AND UPPER(M_LOCATOR.X) LIKE '%'||UPPER(?)||'%']]></Parameter>
    <Parameter name="locatorY" optional="true" after="AND 1=1"><![CDATA[ AND UPPER(M_LOCATOR.Y) LIKE '%'||UPPER(?)||'%']]></Parameter>
    <Parameter name="locatorZ" optional="true" after="AND 1=1"><![CDATA[ AND UPPER(M_LOCATOR.Z) LIKE '%'||UPPER(?)||'%']]></Parameter>
  </SqlMethod>
  <SqlMethod name="set" type="constant" return="multiple">
      <SqlMethodComment></SqlMethodComment>
      <Sql></Sql>
  </SqlMethod>
  <SqlMethod name="selectMproduct" type="preparedStatement" return="String" default="">
    <SqlMethodComment></SqlMethodComment>
    <Sql>
    <![CDATA[
      SELECT M_PRODUCT.NAME
      FROM M_PRODUCT
      WHERE M_PRODUCT_ID = TO_NUMBER(?)
     ]]></Sql>
     <Parameter name="mProductId"/>
  </SqlMethod>
  <SqlMethod name="selectMproduct2" type="preparedStatement" return="multiple">
    <SqlMethodComment></SqlMethodComment>
    <Sql>
    <![CDATA[
      SELECT M_PRODUCT.M_PRODUCT_ID AS ID,M_PRODUCT.NAME
      FROM M_PRODUCT
      WHERE AD_ORG_ID IN ('1') 
      AND AD_CLIENT_ID IN ('1') 
      AND (1=2 )
     ]]></Sql>
     <Parameter name="adOrgClient" type="replace" optional="true" after="AD_ORG_ID IN (" text="'1'"/>
     <Parameter name="adUserClient" type="replace" optional="true" after="AND AD_CLIENT_ID IN (" text="'1'"/>
     <Parameter name="mProductId" optional="true" type="argument" after="(1=2" text=" OR M_PRODUCT_ID IN"/>
  </SqlMethod>
</SqlClass>