src/org/openbravo/erpCommon/info/Product_data.xsql
author Iván Perdomo <ivan.perdomo@openbravo.com>
Mon, 21 Apr 2008 19:06:47 +0000
changeset 712 aa0c40278c5a
parent 423 ecf368072c48
child 1605 8a0fe0193bef
permissions -rw-r--r--
Merged changes from ajaxgrids branch.
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="ProductData" package="org.openbravo.erpCommon.info">
carlos@0
    26
   <SqlClassComment></SqlClassComment>
carlos@0
    27
   <SqlMethod name="select" type="preparedStatement" return="multiple">
carlos@0
    28
      <SqlMethodComment></SqlMethodComment>
carlos@0
    29
      <Sql> <![CDATA[
ivan@712
    30
      SELECT * FROM ( SELECT '0' AS RN1, A.* FROM (
ivan@712
    31
      
carlos@0
    32
        SELECT p.M_Product_ID, p.Discontinued, p.Value, p.Name, AD_COLUMN_IDENTIFIER(TO_CHAR('M_Product'), TO_CHAR(p.M_Product_ID), 
carlos@0
    33
        TO_CHAR(?)) AS NAME_HIDDEN, 
carlos@0
    34
        BOM_Qty_Available(p.M_Product_ID,TO_NUMBER(?), NULL) AS QtyAvailable, 
carlos@0
    35
        BOM_PriceList(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceList,
carlos@0
    36
        BOM_PriceStd(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceStd, 
carlos@0
    37
        BOM_Qty_OnHand(p.M_Product_ID,to_number(?), NULL) AS QtyOnHand, 
carlos@0
    38
        BOM_Qty_Reserved(p.M_Product_ID,to_number(?), null) AS QtyReserved, 
carlos@0
    39
        BOM_Qty_Ordered(p.M_Product_ID,to_number(?), NULL) AS QtyOrdered, 
carlos@0
    40
        BOM_PriceStd(p.M_Product_ID, pr.M_PriceList_Version_ID)-BOM_PriceLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS Margin,
carlos@0
    41
        BOM_PriceLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceLimit,
ivan@712
    42
        p.C_UOM_ID, pl.C_Currency_ID,
ivan@712
    43
        p.M_Product_ID || '#' || p.Name || '#' || p.C_UOM_ID || '#' || BOM_PriceList(p.M_Product_ID, pr.M_PriceList_Version_ID)
ivan@712
    44
           || '#' || BOM_PriceStd(p.M_Product_ID, pr.M_PriceList_Version_ID)
ivan@712
    45
           || '#' || BOM_PriceLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) || '#' || pl.C_Currency_ID AS rowKey
carlos@0
    46
        FROM M_Product p, M_ProductPrice pr,  M_Pricelist pl, M_PriceList_Version pv
carlos@0
    47
        WHERE p.M_Product_ID=pr.M_Product_ID 
carlos@0
    48
        AND p.IsSummary='N' 
carlos@0
    49
        AND p.IsActive='Y' 
carlos@0
    50
        AND pr.IsActive='Y'
carlos@423
    51
        AND pr.M_PriceList_Version_ID = TO_NUMBER(?)
carlos@0
    52
        AND pr.M_PriceList_Version_ID=pv.M_PriceList_Version_ID
carlos@0
    53
        AND pv.M_PriceList_ID=pl.M_PriceList_ID
carlos@0
    54
        AND p.AD_Client_ID IN ('1') 
carlos@0
    55
        AND p.AD_Org_ID IN ('1') 
ivan@712
    56
        ORDER BY p.Value
ivan@712
    57
        
ivan@712
    58
        ) A ) B
ivan@712
    59
      WHERE 1=1
carlos@0
    60
      ]]></Sql>
carlos@0
    61
        <Field name="position" value="count"/>
ivan@712
    62
        <Parameter name="rownum" type="replace" optional="true" after="FROM ( SELECT " text="'0'" />
carlos@0
    63
        <Parameter name="language"/>
carlos@0
    64
        <Parameter name="warehouse"/>
carlos@0
    65
        <Parameter name="warehouse"/>
carlos@0
    66
        <Parameter name="warehouse"/>
carlos@0
    67
        <Parameter name="warehouse"/>
carlos@0
    68
        <Parameter name="key" optional="true" after="WHERE "><![CDATA[ UPPER(p.Value) LIKE UPPER(?) AND ]]></Parameter>
carlos@0
    69
        <Parameter name="name" optional="true" after="WHERE "><![CDATA[ UPPER(p.Name) LIKE UPPER(?) AND ]]></Parameter>
carlos@0
    70
        <Parameter name="priceListVersion"/>
carlos@0
    71
        <Parameter name="adUserClient" type="replace" optional="true" after="p.AD_Client_ID IN (" text="'1'"/>
carlos@0
    72
        <Parameter name="adUserOrg" type="replace" optional="true" after="p.AD_Org_ID IN (" text="'1'"/>
ivan@712
    73
        <Parameter name="orderBy" type="replace" optional="true" after="ORDER BY " text="p.Value" />
ivan@712
    74
        <Parameter name="oraLimit" type="argument" optional="true" after="WHERE 1=1"><![CDATA[AND RN1 BETWEEN ]]></Parameter>
ivan@712
    75
        <Parameter name="pgLimit" type="argument" optional="true" after="WHERE 1=1"><![CDATA[LIMIT ]]></Parameter>
carlos@0
    76
   </SqlMethod>
carlos@0
    77
   <SqlMethod name="set" type="constant" return="multiple">
carlos@0
    78
      <SqlMethodComment></SqlMethodComment>
carlos@0
    79
      <Sql></Sql>
carlos@0
    80
   </SqlMethod>
carlos@0
    81
carlos@0
    82
   <SqlMethod name="priceListDefault" type="preparedStatement" return="String">
carlos@0
    83
      <SqlMethodComment></SqlMethodComment>
carlos@0
    84
      <Sql> <![CDATA[
carlos@0
    85
        SELECT M_PRICELIST_ID FROM M_PRICELIST 
carlos@0
    86
        WHERE ISDEFAULT='Y' 
carlos@0
    87
        AND AD_Client_ID IN ('1') 
carlos@0
    88
        AND AD_Org_ID IN ('1') 
carlos@0
    89
      ]]></Sql>
carlos@0
    90
      <Parameter name="adUserClient" type="replace" optional="true" after="AD_Client_ID IN (" text="'1'"/>
carlos@0
    91
      <Parameter name="adUserOrg" type="replace" optional="true" after="AD_Org_ID IN (" text="'1'"/>
carlos@0
    92
   </SqlMethod>
carlos@0
    93
   <SqlMethod name="existsActual" type="preparedStatement" return="String" default="">
carlos@0
    94
      <SqlMethodComment></SqlMethodComment>
carlos@0
    95
      <Sql> <![CDATA[
carlos@0
    96
        SELECT name as name
carlos@0
    97
        FROM M_Product 
carlos@0
    98
        WHERE UPPER(AD_COLUMN_IDENTIFIER(TO_CHAR('M_Product'), TO_CHAR(M_Product_ID), TO_CHAR(?))) = UPPER(?)
carlos@423
    99
        AND M_Product_ID = TO_NUMBER(?) 
carlos@0
   100
        ORDER BY name
carlos@0
   101
      ]]></Sql>
carlos@0
   102
        <Parameter name="language"/>
carlos@0
   103
        <Parameter name="description"/>
carlos@0
   104
        <Parameter name="cBpartnerId"/>
carlos@0
   105
   </SqlMethod>
carlos@0
   106
   <SqlMethod name="existsActualValue" type="preparedStatement" return="String" default="">
carlos@0
   107
      <SqlMethodComment></SqlMethodComment>
carlos@0
   108
      <Sql> <![CDATA[
carlos@0
   109
        SELECT value as value
carlos@0
   110
        FROM M_Product 
carlos@0
   111
        WHERE UPPER(AD_COLUMN_IDENTIFIER(TO_CHAR('M_Product'), TO_CHAR(M_Product_ID), TO_CHAR(?))) = UPPER(?)
carlos@423
   112
        AND M_Product_ID = TO_NUMBER(?) 
carlos@0
   113
        ORDER BY value
carlos@0
   114
      ]]></Sql>
carlos@0
   115
        <Parameter name="language"/>
carlos@0
   116
        <Parameter name="description"/>
carlos@0
   117
        <Parameter name="cBpartnerId"/>
carlos@0
   118
   </SqlMethod>
carlos@0
   119
</SqlClass>