src/org/openbravo/erpCommon/info/Invoice_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 732 88d93ac777a9
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="InvoiceData" 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>
carlos@0
    30
      <![CDATA[
ivan@712
    31
        SELECT * FROM ( SELECT '0' AS RN1, A.* FROM ( 
carlos@0
    32
          SELECT
ivan@712
    33
          i.C_Invoice_ID, i.DocumentNo||' - '||TO_CHAR(i.DateInvoiced,to_char(?))||' - '||i.GrandTotal AS Name,
ivan@712
    34
          REPLACE((i.DocumentNo||' - '||TO_CHAR(i.DateInvoiced,to_char(?))||' - '||i.GrandTotal), '''', CHR(92) || '''') AS Name_HIDDEN,
carlos@0
    35
          (SELECT Name FROM C_BPartner bp WHERE bp.C_BPartner_ID=i.C_BPartner_ID) AS BPartnerName,
carlos@0
    36
          i.DateInvoiced,
carlos@0
    37
          i.DocumentNo,
carlos@0
    38
          (SELECT ISO_Code FROM C_Currency c WHERE c.C_Currency_ID=i.C_Currency_ID) AS Currency,
carlos@0
    39
          i.GrandTotal,
carlos@0
    40
          C_Base_Convert(i.GrandTotal, i.C_Currency_ID, i.AD_Client_ID, i.DateAcct, 0) AS ConvertedAmount,
carlos@0
    41
          0 AS OpenAmt,
carlos@0
    42
          i.IsPaid,
carlos@0
    43
          i.IsSOTrx,
carlos@0
    44
          i.Description,
ivan@712
    45
          i.POReference,
ivan@712
    46
          i.C_Invoice_ID || '#' || i.DocumentNo || ' - ' || TO_CHAR(i.DateInvoiced, TO_CHAR(?)) as RowKey
carlos@0
    47
          FROM C_Invoice_v i
carlos@0
    48
          WHERE i.AD_Client_ID IN ('1') 
carlos@0
    49
          AND i.AD_Org_ID IN ('1') 
carlos@0
    50
          AND i.IsActive='Y'
carlos@0
    51
          AND i.IsPaid = ?
ivan@712
    52
          ORDER BY 2
ivan@712
    53
        ) A ) B
ivan@712
    54
        WHERE 1=1
carlos@0
    55
        ]]>
carlos@0
    56
        </Sql>
carlos@0
    57
        <Field name="position" value="count"/>
ivan@712
    58
        <Parameter name="rownum" type="replace" optional="true" after="FROM ( SELECT " text="'0'" />
carlos@0
    59
        <Parameter name="dateFormat"/>
carlos@0
    60
        <Parameter name="dateFormat"/>
ivan@712
    61
        <Parameter name="dateFormat"/>        
carlos@0
    62
        <Parameter name="adUserClient" type="replace" optional="true" after="i.AD_Client_ID IN (" text="'1'"/>
carlos@0
    63
        <Parameter name="adUserOrg" type="replace" optional="true" after="i.AD_Org_ID IN (" text="'1'"/>
carlos@0
    64
        <Parameter name="key" optional="true" after="AND i.IsActive='Y'"><![CDATA[ AND UPPER(i.DocumentNo) LIKE UPPER(?) ]]></Parameter>
carlos@0
    65
        <Parameter name="description" optional="true" after="AND i.IsActive='Y'"><![CDATA[ AND UPPER(i.Description) LIKE UPPER(?) ]]></Parameter>
carlos@423
    66
        <Parameter name="businesPartner" optional="true" after="AND i.IsActive='Y'"><![CDATA[ AND i.C_BPartner_ID = TO_NUMBER(?) ]]></Parameter>
ivan@712
    67
        <Parameter name="order" optional="true" after="AND i.IsActive='Y'"><![CDATA[ AND i.POReference = TO_NUMBER(?) ]]></Parameter>
ivan@712
    68
        <Parameter name="dateFrom" optional="true" after="AND i.IsActive='Y'"><![CDATA[ AND i.DateInvoiced >= TO_DATE(?) ]]></Parameter>
ivan@712
    69
        <Parameter name="dateTo" optional="true" after="AND i.IsActive='Y'"><![CDATA[ AND i.DateInvoiced < TO_DATE(?) ]]></Parameter>
ivan@712
    70
        <Parameter name="grandTotalFrom" optional="true" after="AND i.IsActive='Y'"><![CDATA[ AND i.GrandTotal >= TO_NUMBER(?) ]]></Parameter>
ivan@712
    71
        <Parameter name="grandTotalTo" optional="true" after="AND i.IsActive='Y'"><![CDATA[ AND i.GrandTotal <= TO_NUMBER(?) ]]></Parameter>
carlos@0
    72
        <Parameter name="sotrx" optional="true" after="AND i.IsActive='Y'"><![CDATA[ AND i.IsSOTrx = ? ]]></Parameter>
carlos@0
    73
        <Parameter name="paid"/>
ivan@712
    74
        <Parameter name="orderBy" type="replace" optional="true" after="ORDER BY " text="2" />
ivan@712
    75
        <Parameter name="oraLimit" type="argument" optional="true" after="WHERE 1=1"><![CDATA[AND RN1 BETWEEN ]]></Parameter>
ivan@712
    76
        <Parameter name="pgLimit" type="argument" optional="true" after="WHERE 1=1"><![CDATA[LIMIT ]]></Parameter>
carlos@0
    77
   </SqlMethod>
carlos@0
    78
   <SqlMethod name="set" type="constant" return="multiple">
carlos@0
    79
      <SqlMethodComment></SqlMethodComment>
carlos@0
    80
      <Sql></Sql>
carlos@0
    81
   </SqlMethod>
carlos@0
    82
   <SqlMethod name="selectKey" type="preparedStatement" return="multiple">
carlos@0
    83
      <SqlMethodComment></SqlMethodComment>
carlos@0
    84
      <Sql> 
carlos@0
    85
      <![CDATA[
carlos@0
    86
        SELECT
carlos@0
    87
          i.C_Invoice_ID, i.DocumentNo||' - '||TO_DATE(i.DateInvoiced,to_char(?))||' - '||i.GrandTotal AS Name,
carlos@0
    88
          (SELECT Name FROM C_BPartner bp WHERE bp.C_BPartner_ID=i.C_BPartner_ID) AS BPartnerName,
carlos@0
    89
          i.DateInvoiced,
carlos@0
    90
          i.DocumentNo,
carlos@0
    91
          (SELECT ISO_Code FROM C_Currency c WHERE c.C_Currency_ID=i.C_Currency_ID) AS Currency,
carlos@0
    92
          i.GrandTotal,
carlos@0
    93
          C_Base_Convert(i.GrandTotal, i.C_Currency_ID, i.AD_Client_ID, i.DateAcct, 0) AS ConvertedAmount,
carlos@0
    94
          0 AS OpenAmt,
carlos@0
    95
          i.IsPaid,
carlos@0
    96
          i.IsSOTrx,
carlos@0
    97
          i.Description,
carlos@0
    98
          i.POReference
carlos@0
    99
          FROM C_Invoice_v i
carlos@0
   100
          WHERE i.AD_Client_ID IN ('1') 
carlos@0
   101
          AND i.AD_Org_ID IN ('1') 
carlos@0
   102
          AND i.IsActive='Y'
carlos@0
   103
          AND UPPER(i.DocumentNo) LIKE UPPER(?)
carlos@0
   104
      ]]>
carlos@0
   105
      </Sql>
carlos@0
   106
        <Parameter name="dateFormat"/>
carlos@0
   107
        <Parameter name="adUserClient" type="replace" optional="true" after="i.AD_Client_ID IN (" text="'1'"/>
carlos@0
   108
        <Parameter name="adUserOrg" type="replace" optional="true" after="i.AD_Org_ID IN (" text="'1'"/>
carlos@0
   109
        <Parameter name="sotrx" optional="true" after="AND i.IsActive='Y'"><![CDATA[ AND i.IsSOTrx = ? ]]></Parameter>
carlos@0
   110
        <Parameter name="key"/>
carlos@0
   111
   </SqlMethod>
carlos@0
   112
</SqlClass>