src/org/openbravo/erpCommon/ad_reports/ReportInvoices_data.xsql
author David Baz Fayos <david.baz@openbravo.com>
Tue, 27 May 2008 15:26:10 +0000
changeset 1044 8691bbc94032
parent 752 bc18bf2d37e1
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="ReportInvoicesData" package="org.openbravo.erpCommon.ad_reports">
  <SqlClassComment></SqlClassComment>
  <SqlMethod name="select" type="preparedStatement" return="multiple">
    <SqlMethodComment></SqlMethodComment>
    <Sql>
    <![CDATA[
      SELECT NAMEBPARTNER,INVOICEID, INVOICEDOCUMENTNO, DOCNOORDER, DESCRIPTIONINVOICE, DATEINVOICED,
      LINE, NAMEPRODUCT, QTYINVOICED, UOMSYMBOL, PRICEACTUAL, TAX, BASE, LINENETAMT
      FROM (
      SELECT B.NAME AS NAMEBPARTNER, I.C_INVOICE_ID AS INVOICEID, I.DOCUMENTNO AS INVOICEDOCUMENTNO, O.DOCUMENTNO AS DOCNOORDER,I.DESCRIPTION AS DESCRIPTIONINVOICE, I.DATEINVOICED AS DATEINVOICED,
      C_INVOICELINE.LINE, P.NAME AS NAMEPRODUCT,
      IL.QTYINVOICED AS QTYINVOICED, TO_CHAR(C_UOM.UOMSYMBOL) AS UOMSYMBOL,IL.PRICEACTUAL AS PRICEACTUAL, C_TAX.RATE AS TAX, IL.LINENETAMT AS LINENETAMT,
      NULL AS BASE
      FROM C_INVOICE I left join C_ORDER O on I.C_ORDER_ID = O.C_ORDER_ID
                       right join RV_C_INVOICELINE IL on IL.C_INVOICE_ID = I.C_INVOICE_ID,
           C_BPARTNER B, M_PRODUCT P, C_UOM, C_INVOICELINE, C_TAX
      WHERE IL.M_PRODUCT_ID = P.M_PRODUCT_ID
      AND IL.C_BPARTNER_ID = B.C_BPARTNER_ID
      AND IL.C_INVOICELINE_ID = C_INVOICELINE.C_INVOICELINE_ID
      AND C_INVOICELINE.C_UOM_ID = C_UOM.C_UOM_ID
      AND C_INVOICELINE.C_TAX_ID = C_TAX.C_TAX_ID
      AND I.AD_Client_ID IN ('1')
      AND I.AD_ORG_ID IN ('1')
      AND 1=1
      UNION 
      SELECT B.NAME AS NAMEBPARTNER, I2.C_INVOICE_ID AS INVOICEID, I2.DOCUMENTNO AS INVOICEDOCUMENTNO, O.DOCUMENTNO AS DOCNOORDER, I2.DESCRIPTION AS DESCRIPTIONINVOICE, I2.DATEINVOICED AS DATEINVOICED,
      NULL AS LINE , C_TAX.NAME AS NAMEPRODUCT,
      NULL AS QTYINVOICED, '' AS UOMSYMBOL, NULL AS PRICEACTUAL, NULL AS TAX, C_INVOICETAX.TAXAMT AS LINENETAMT, C_INVOICETAX.TAXBASEAMT AS BASE
      FROM C_INVOICE I2 left join RV_C_INVOICELINE IL on IL.C_INVOICE_ID = I2.C_INVOICE_ID
                        left join C_ORDER O           on I2.C_ORDER_ID = O.C_ORDER_ID,
       C_BPARTNER B, M_PRODUCT P, C_TAX, C_INVOICETAX
      WHERE IL.M_PRODUCT_ID = P.M_PRODUCT_ID
      AND IL.C_BPARTNER_ID = B.C_BPARTNER_ID
      AND C_INVOICETAX.C_INVOICE_ID= I2.C_INVOICE_ID
      AND C_INVOICETAX.C_TAX_ID = C_TAX.C_TAX_ID
      AND I2.AD_Client_ID IN ('2')
      AND I2.AD_ORG_ID IN ('2')
      AND 2=2) A
      ORDER BY NAMEBPARTNER, INVOICEDOCUMENTNO, LINE
      ]]></Sql>
    <Parameter name="adUserClient" type="replace" optional="true" after="I.AD_Client_ID IN (" text="'1'"/>
    <Parameter name="adUserOrg" type="replace" optional="true" after="AND I.AD_ORG_ID IN (" text="'1'"/>
    <Parameter name="parBGroupId" optional="true" after="AND 1=1">AND B.C_BP_GROUP_ID = TO_NUMBER(?)</Parameter>
    <Parameter name="parPCategoryId" optional="true" after="AND 1=1">AND P.M_PRODUCT_CATEGORY_ID = TO_NUMBER(?)</Parameter>
    <Parameter name="parBPartnerId" optional="true" after="AND 1=1">AND B.C_BPARTNER_ID = TO_NUMBER(?)</Parameter>
    <Parameter name="parMProductId" optional="true" after="AND 1=1">AND P.M_PRODUCT_ID = TO_NUMBER(?)</Parameter>
    <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[AND I.DATEINVOICED >= to_date(?)]]></Parameter>
    <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[AND I.DATEINVOICED < to_date(?)]]></Parameter>
    <Parameter name="parDocNo" optional="true" after="AND 1=1">AND I.DOCUMENTNO = ?</Parameter>
    <Parameter name="sales" optional="true" type="none" after="1=1" text="AND O.ISSOTRX = 'Y'"/>
    <Parameter name="purchase" optional="true" type="none" after="1=1" text="AND O.ISSOTRX = 'N'"/>
    <Parameter name="adUserClient" type="replace" optional="true" after="I2.AD_Client_ID IN (" text="'2'"/>
    <Parameter name="adUserOrg" type="replace" optional="true" after="AND I2.AD_ORG_ID IN (" text="'2'"/>
    <Parameter name="parBGroupId" optional="true" after="AND 2=2">AND B.C_BP_GROUP_ID = TO_NUMBER(?)</Parameter>
    <Parameter name="parPCategoryId" optional="true" after="AND 2=2">AND P.M_PRODUCT_CATEGORY_ID = TO_NUMBER(?)</Parameter>
    <Parameter name="parBPartnerId" optional="true" after="AND 2=2">AND B.C_BPARTNER_ID = TO_NUMBER(?)</Parameter>
    <Parameter name="parMProductId" optional="true" after="AND 2=2">AND P.M_PRODUCT_ID = TO_NUMBER(?)</Parameter>
    <Parameter name="parDateFrom" optional="true" after="AND 2=2"><![CDATA[AND I2.DATEINVOICED >= to_date(?)]]></Parameter>
    <Parameter name="parDateTo" optional="true" after="AND 2=2"><![CDATA[AND I2.DATEINVOICED <= to_date(?)]]></Parameter>
    <Parameter name="parDocNo" optional="true" after="AND 2=2">AND I2.DOCUMENTNO = ?</Parameter>
    <Parameter name="sales" optional="true" type="none" after="2=2" text="AND O.ISSOTRX = 'Y'"/>
    <Parameter name="purchase" optional="true" type="none" after="2=2" text="AND O.ISSOTRX = 'N'"/>
  </SqlMethod>
  <SqlMethod name="set" type="constant" return="multiple">
      <SqlMethodComment></SqlMethodComment>
      <Sql></Sql>
  </SqlMethod>
  <SqlMethod name="bPartnerDescription" type="preparedStatement" return="String" default="">
    <SqlMethodComment></SqlMethodComment>
    <Sql>
    SELECT NAME FROM C_BPARTNER 
    WHERE C_BPARTNER_ID = TO_NUMBER(?)
    </Sql>
    <Parameter name="cBpartnerId"/>
  </SqlMethod>
  <SqlMethod name="mProductDescription" type="preparedStatement" return="String" default="">
    <SqlMethodComment></SqlMethodComment>
    <Sql>
    SELECT NAME FROM M_PRODUCT
    WHERE M_PRODUCT_ID = TO_NUMBER(?)
    </Sql>
    <Parameter name="mProductId"/>
  </SqlMethod>
</SqlClass>