src/org/openbravo/erpCommon/ad_reports/ReportDebtPayment_data.xsql
author David Baz Fayos <david.baz@openbravo.com>
Tue, 27 May 2008 15:26:10 +0000
changeset 1044 8691bbc94032
parent 711 4e8209a9d749
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="ReportDebtPaymentData" 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 (CASE WHEN I.C_INVOICE_ID IS NULL THEN 0 ELSE I.C_INVOICE_ID END) AS C_INVOICE_ID, (CASE WHEN DP.C_DEBT_PAYMENT_ID IS NULL THEN 0 ELSE DP.C_DEBT_PAYMENT_ID END) AS C_DEBT_PAYMENT_ID, B.NAME AS BPARTNER, (CASE WHEN I.DOCUMENTNO IS NOT NULL THEN I.DOCUMENTNO||' ('||I.DATEINVOICED||')' END) AS INVOICE, DP.DATEPLANNED,
carlos@0
    32
      DP.AMOUNT, DP.WRITEOFFAMT, C.ISO_CODE AS CURRENCY,
carlos@0
    33
      (CASE WHEN S1.DOCUMENTNO IS NOT NULL THEN S1.DOCUMENTNO||' ('||S1.DATETRX||')' END) AS DEBTCANCEL, (CASE WHEN S2.DOCUMENTNO IS NOT NULL THEN S2.DOCUMENTNO||' ('||S2.DATETRX||')' END) AS DEBTGENERATE, COALESCE(RLT.NAME, RL.NAME) AS PAYMENTRULE,
carlos@0
    34
      (CASE C_DEBT_PAYMENT_STATUS(DP.C_Settlement_Cancel_ID, DP.CANCEL_PROCESSED, DP.GENERATE_PROCESSED, DP.ISPAID, DP.ISVALID, 
carlos@0
    35
      DP.C_CASHLINE_ID, DP.C_BANKSTATEMENTLINE_ID) WHEN 'I' THEN AD_MESSAGE_GET2('DPR_INVALID',?) WHEN 'C' THEN AD_MESSAGE_GET2('DPR_CONCILIATED',?) WHEN 'W' THEN AD_MESSAGE_GET2('DPR_CANCELLED',?) WHEN 'A' THEN AD_MESSAGE_GET2('DPR_SETTLE',?) WHEN 
carlos@0
    36
      'P' THEN AD_MESSAGE_GET2('DPR_PENDING',?) END) AS STATUS,
carlos@0
    37
      DP.DESCRIPTION, AD_MESSAGE_GET2(DP.ISPAID, ?) AS ISPAID, 
carlos@0
    38
      (CASE DP.ISRECEIPT WHEN 'Y' THEN 'SalesInvoice' ELSE 'PurchaseInvoice' END) AS INVOICE_TYPE, 
carlos@0
    39
      (CASE s2.SETTLEMENTTYPE WHEN 'I' THEN '../ManualSettlement/CreatePayment_Relation.html' ELSE '../Settlement/CreatedPayments_Relation.html' END) AS PATH, COALESCE(RLT2.NAME, RL2.NAME) AS DPSTATUS
carlos@0
    40
      FROM C_DEBT_PAYMENT DP left join C_SETTLEMENT S1 on DP.C_SETTLEMENT_CANCEL_ID = S1.C_SETTLEMENT_ID
carlos@0
    41
                             left join C_SETTLEMENT S2 on DP.C_SETTLEMENT_GENERATE_ID = S2.C_SETTLEMENT_ID
carlos@0
    42
                             left join C_BPARTNER B    on DP.C_BPARTNER_ID = B.C_BPARTNER_ID
carlos@0
    43
                             left join C_INVOICE I     on DP.C_INVOICE_ID = I.C_INVOICE_ID,
carlos@0
    44
           AD_REF_LIST RL    left join AD_REF_LIST_TRL RLT on RL.AD_REF_LIST_ID = RLT.AD_REF_LIST_ID
carlos@0
    45
                                                              AND RLT.AD_LANGUAGE = ?,
carlos@0
    46
           AD_REF_LIST RL2    left join AD_REF_LIST_TRL RLT2 on RL2.AD_REF_LIST_ID = RLT2.AD_REF_LIST_ID
carlos@0
    47
                                                              AND RLT2.AD_LANGUAGE = ?,
carlos@0
    48
           C_CURRENCY C    
carlos@0
    49
      WHERE DP.C_CURRENCY_ID = C.C_CURRENCY_ID 
carlos@0
    50
      AND DP.PAYMENTRULE = RL.VALUE
carlos@0
    51
      AND RL.AD_REFERENCE_ID = 195
carlos@0
    52
      AND DP.STATUS = RL2.VALUE
carlos@0
    53
      AND RL2.AD_REFERENCE_ID = 800070
carlos@0
    54
      AND DP.AD_Client_ID IN ('1') 
carlos@0
    55
      AND DP.AD_Org_ID IN ('1') 
carlos@0
    56
      AND DP.IsActive='Y'
carlos@0
    57
      AND DP.IsValid='Y'
carlos@0
    58
      GROUP BY (CASE WHEN I.C_INVOICE_ID IS NULL THEN 0 ELSE I.C_INVOICE_ID END), (CASE WHEN DP.C_DEBT_PAYMENT_ID IS NULL THEN 0 ELSE DP.C_DEBT_PAYMENT_ID END), B.NAME, (CASE WHEN I.DOCUMENTNO IS NOT NULL THEN I.DOCUMENTNO||' ('||I.DATEINVOICED||')' END), DP.DATEPLANNED, DP.AMOUNT,
carlos@0
    59
      DP.WRITEOFFAMT, C.ISO_CODE, (CASE WHEN S1.DOCUMENTNO IS NOT NULL THEN S1.DOCUMENTNO||' ('||S1.DATETRX||')' END), (CASE WHEN S2.DOCUMENTNO IS NOT NULL THEN S2.DOCUMENTNO||' ('||S2.DATETRX||')' END), RLT.NAME, RL.NAME, RLT2.NAME, RL2.NAME, DP.C_Settlement_Cancel_ID,
carlos@0
    60
      DP.CANCEL_PROCESSED, DP.GENERATE_PROCESSED, DP.ISPAID, DP.ISVALID, DP.C_CASHLINE_ID, DP.C_BANKSTATEMENTLINE_ID, DP.DESCRIPTION, (CASE DP.ISRECEIPT WHEN 'Y' THEN 'SalesInvoice' ELSE 'PurchaseInvoice' END),s2.SETTLEMENTTYPE, DP.STATUS
carlos@0
    61
      ORDER BY BPARTNER, STATUS, DP.DATEPLANNED
carlos@0
    62
     ]]></Sql>
carlos@0
    63
      <Field name="rownum" value="count"/>
carlos@0
    64
      <Parameter name="adLanguage"/>
carlos@0
    65
      <Parameter name="adLanguage"/>
carlos@0
    66
      <Parameter name="adLanguage"/>
carlos@0
    67
      <Parameter name="adLanguage"/>
carlos@0
    68
      <Parameter name="adLanguage"/>
carlos@0
    69
      <Parameter name="adLanguage"/>
carlos@0
    70
      <Parameter name="adLanguage"/>
carlos@0
    71
      <Parameter name="adLanguage"/>
carlos@0
    72
      <Parameter name="adUserClient" type="replace" optional="true" after="DP.AD_Client_ID IN (" text="'1'"/>
carlos@0
    73
      <Parameter name="adUserOrg" type="replace" optional="true" after="DP.AD_Org_ID IN (" text="'1'"/>
pablo@711
    74
      <Parameter name="cBpartnerId" optional="true" type="argument" after="AND DP.IsValid='Y'"><![CDATA[ AND dp.C_BPARTNER_ID IN ]]></Parameter>
pablo@711
    75
      <!-- <Parameter name="businesPartner" optional="true" after="AND DP.IsValid='Y'"><![CDATA[ AND b.C_BPartner_ID = TO_NUMBER(?) ]]></Parameter>  -->
carlos@0
    76
      <Parameter name="dateFrom" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND dp.Dateplanned >= to_date(?) ]]></Parameter>
carlos@0
    77
      <Parameter name="dateTo" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND dp.Dateplanned < to_date(?) ]]></Parameter>
carlos@0
    78
      <Parameter name="AmountFrom" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND dp.amount >= ? ]]></Parameter>
carlos@0
    79
      <Parameter name="AmountTo" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND dp.amount <= ? ]]></Parameter>
carlos@0
    80
      <Parameter name="paymentRule" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND dp.paymentrule = ? ]]></Parameter>
carlos@0
    81
      <Parameter name="isReceipt" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND dp.isreceipt=? ]]></Parameter>
carlos@0
    82
      <Parameter name="status" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND dp.status=? ]]></Parameter>
carlos@0
    83
      <Parameter name="isSettle" optional="true" type="argument" after="DP.IsValid='Y'" text="AND C_DEBT_PAYMENT_STATUS(DP.C_Settlement_Cancel_ID, DP.CANCEL_PROCESSED, DP.GENERATE_PROCESSED, DP.ISPAID, DP.ISVALID, 
carlos@0
    84
      DP.C_CASHLINE_ID, DP.C_BANKSTATEMENTLINE_ID) IN"/>
carlos@423
    85
      <Parameter name="cbankaccount" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND DP.C_BANKACCOUNT_ID = TO_NUMBER(?) ]]></Parameter>
carlos@0
    86
  </SqlMethod>
carlos@0
    87
  <SqlMethod name="selectNoBpartner" type="preparedStatement" return="multiple">
carlos@0
    88
    <SqlMethodComment></SqlMethodComment>
carlos@0
    89
    <Sql>
carlos@0
    90
    <![CDATA[
carlos@0
    91
      SELECT (CASE WHEN I.C_INVOICE_ID IS NULL THEN 0 ELSE I.C_INVOICE_ID END) AS C_INVOICE_ID, (CASE WHEN DP.C_DEBT_PAYMENT_ID IS NULL THEN 0 ELSE DP.C_DEBT_PAYMENT_ID END) AS C_DEBT_PAYMENT_ID, B.NAME AS BPARTNER, (CASE WHEN I.DOCUMENTNO IS NOT NULL THEN I.DOCUMENTNO||' ('||I.DATEINVOICED||')' END) AS INVOICE, DP.DATEPLANNED,
carlos@0
    92
      DP.AMOUNT, DP.WRITEOFFAMT, C.ISO_CODE AS CURRENCY,
carlos@0
    93
      (CASE WHEN S1.DOCUMENTNO IS NOT NULL THEN S1.DOCUMENTNO||' ('||S1.DATETRX||')' END) AS DEBTCANCEL, (CASE WHEN S2.DOCUMENTNO IS NOT NULL THEN S2.DOCUMENTNO||' ('||S2.DATETRX||')' END) AS DEBTGENERATE, COALESCE(RLT.NAME, RL.NAME) AS PAYMENTRULE,
carlos@0
    94
      (CASE C_DEBT_PAYMENT_STATUS(DP.C_Settlement_Cancel_ID, DP.CANCEL_PROCESSED, DP.GENERATE_PROCESSED, DP.ISPAID, DP.ISVALID, 
carlos@0
    95
      DP.C_CASHLINE_ID, DP.C_BANKSTATEMENTLINE_ID) WHEN 'I' THEN AD_MESSAGE_GET2('DPR_INVALID',?) WHEN 'C' THEN AD_MESSAGE_GET2('DPR_CONCILIATED',?) WHEN 'W' THEN AD_MESSAGE_GET2('DPR_CANCELLED',?) WHEN 'A' THEN AD_MESSAGE_GET2('DPR_SETTLE',?) WHEN 
carlos@0
    96
      'P' THEN AD_MESSAGE_GET2('DPR_PENDING',?) END) AS STATUS,
carlos@0
    97
      DP.DESCRIPTION, AD_MESSAGE_GET2(DP.ISPAID, ?) AS ISPAID, 
carlos@0
    98
      (CASE DP.ISRECEIPT WHEN 'Y' THEN 'SalesInvoice' ELSE 'PurchaseInvoice' END) AS INVOICE_TYPE, 
carlos@0
    99
      (CASE s2.SETTLEMENTTYPE WHEN 'I' THEN '../ManualSettlement/CreatePayment_Relation.html' ELSE '../Settlement/CreatedPayments_Relation.html' END) AS PATH, COALESCE(RLT2.NAME, RL2.NAME) AS DPSTATUS
carlos@0
   100
      FROM C_DEBT_PAYMENT DP left join C_SETTLEMENT S1 on DP.C_SETTLEMENT_CANCEL_ID = S1.C_SETTLEMENT_ID
carlos@0
   101
                             left join C_SETTLEMENT S2 on DP.C_SETTLEMENT_GENERATE_ID = S2.C_SETTLEMENT_ID
carlos@0
   102
                             left join C_BPARTNER B    on DP.C_BPARTNER_ID = B.C_BPARTNER_ID
carlos@0
   103
                             left join C_INVOICE I     on DP.C_INVOICE_ID = I.C_INVOICE_ID,
carlos@0
   104
           AD_REF_LIST RL    left join AD_REF_LIST_TRL RLT on RL.AD_REF_LIST_ID = RLT.AD_REF_LIST_ID
carlos@0
   105
                                                              AND RLT.AD_LANGUAGE = ?,
carlos@0
   106
           AD_REF_LIST RL2    left join AD_REF_LIST_TRL RLT2 on RL2.AD_REF_LIST_ID = RLT2.AD_REF_LIST_ID
carlos@0
   107
                                                              AND RLT2.AD_LANGUAGE = ?,
carlos@0
   108
           C_CURRENCY C    
carlos@0
   109
      WHERE DP.C_CURRENCY_ID = C.C_CURRENCY_ID 
carlos@0
   110
      AND DP.PAYMENTRULE = RL.VALUE
carlos@0
   111
      AND RL.AD_REFERENCE_ID = 195
carlos@0
   112
      AND DP.STATUS = RL2.VALUE
carlos@0
   113
      AND RL2.AD_REFERENCE_ID = 800070
carlos@0
   114
      AND DP.AD_Client_ID IN ('1') 
carlos@0
   115
      AND DP.AD_Org_ID IN ('1') 
carlos@0
   116
      AND DP.IsActive='Y'
carlos@0
   117
      AND DP.IsValid='Y'
carlos@0
   118
      GROUP BY (CASE WHEN I.C_INVOICE_ID IS NULL THEN 0 ELSE I.C_INVOICE_ID END), (CASE WHEN DP.C_DEBT_PAYMENT_ID IS NULL THEN 0 ELSE DP.C_DEBT_PAYMENT_ID END), B.NAME, (CASE WHEN I.DOCUMENTNO IS NOT NULL THEN I.DOCUMENTNO||' ('||I.DATEINVOICED||')' END), DP.DATEPLANNED, DP.AMOUNT,
carlos@0
   119
      DP.WRITEOFFAMT, C.ISO_CODE, (CASE WHEN S1.DOCUMENTNO IS NOT NULL THEN S1.DOCUMENTNO||' ('||S1.DATETRX||')' END), (CASE WHEN S2.DOCUMENTNO IS NOT NULL THEN S2.DOCUMENTNO||' ('||S2.DATETRX||')' END), RLT.NAME, RL.NAME, RLT2.NAME, RL2.NAME, DP.C_Settlement_Cancel_ID,
carlos@0
   120
      DP.CANCEL_PROCESSED, DP.GENERATE_PROCESSED, DP.ISPAID, DP.ISVALID, DP.C_CASHLINE_ID, DP.C_BANKSTATEMENTLINE_ID, DP.DESCRIPTION, (CASE DP.ISRECEIPT WHEN 'Y' THEN 'SalesInvoice' ELSE 'PurchaseInvoice' END),s2.SETTLEMENTTYPE, DP.STATUS
carlos@0
   121
      ORDER BY STATUS, DP.DATEPLANNED, BPARTNER
carlos@0
   122
     ]]></Sql>
carlos@0
   123
      <Field name="rownum" value="count"/>
carlos@0
   124
      <Parameter name="adLanguage"/>
carlos@0
   125
      <Parameter name="adLanguage"/>
carlos@0
   126
      <Parameter name="adLanguage"/>
carlos@0
   127
      <Parameter name="adLanguage"/>
carlos@0
   128
      <Parameter name="adLanguage"/>
carlos@0
   129
      <Parameter name="adLanguage"/>
carlos@0
   130
      <Parameter name="adLanguage"/>
carlos@0
   131
      <Parameter name="adLanguage"/>
carlos@0
   132
      <Parameter name="adUserClient" type="replace" optional="true" after="DP.AD_Client_ID IN (" text="'1'"/>
carlos@0
   133
      <Parameter name="adUserOrg" type="replace" optional="true" after="DP.AD_Org_ID IN (" text="'1'"/>
pablo@711
   134
      <Parameter name="cBpartnerId" optional="true" type="argument" after="AND DP.IsValid='Y'"><![CDATA[ AND dp.C_BPARTNER_ID IN ]]></Parameter>
pablo@711
   135
      <!-- <Parameter name="businesPartner" optional="true" after="AND DP.IsValid='Y'"><![CDATA[ AND b.C_BPartner_ID = TO_NUMBER(?) ]]></Parameter>  -->
carlos@0
   136
      <Parameter name="dateFrom" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND dp.Dateplanned >= to_date(?) ]]></Parameter>
carlos@0
   137
      <Parameter name="dateTo" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND dp.Dateplanned < to_date(?) ]]></Parameter>
carlos@0
   138
      <Parameter name="AmountFrom" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND dp.amount >= ? ]]></Parameter>
carlos@0
   139
      <Parameter name="AmountTo" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND dp.amount <= ? ]]></Parameter>
carlos@0
   140
      <Parameter name="paymentRule" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND dp.paymentrule = ? ]]></Parameter>
carlos@0
   141
      <Parameter name="isReceipt" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND dp.isreceipt=? ]]></Parameter>
carlos@0
   142
      <Parameter name="status" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND dp.status=? ]]></Parameter>
carlos@0
   143
      <Parameter name="isSettle" optional="true" type="argument" after="DP.IsValid='Y'" text="AND C_DEBT_PAYMENT_STATUS(DP.C_Settlement_Cancel_ID, DP.CANCEL_PROCESSED, DP.GENERATE_PROCESSED, DP.ISPAID, DP.ISVALID, 
carlos@0
   144
      DP.C_CASHLINE_ID, DP.C_BANKSTATEMENTLINE_ID) IN"/>
carlos@423
   145
      <Parameter name="cbankaccount" optional="true" after="DP.IsValid='Y'"><![CDATA[ AND DP.C_BANKACCOUNT_ID = TO_NUMBER(?) ]]></Parameter>
carlos@0
   146
  </SqlMethod>
carlos@0
   147
  <SqlMethod name="set" type="constant" return="multiple">
carlos@0
   148
      <SqlMethodComment></SqlMethodComment>
carlos@0
   149
      <Sql></Sql>
carlos@0
   150
  </SqlMethod>
carlos@0
   151
  <SqlMethod name="bPartnerDescription" type="preparedStatement" return="String" default="">
carlos@0
   152
    <SqlMethodComment></SqlMethodComment>
carlos@0
   153
    <Sql>
carlos@0
   154
    SELECT NAME FROM C_BPARTNER 
carlos@423
   155
    WHERE C_BPARTNER_ID = TO_NUMBER(?)
carlos@0
   156
    </Sql>
carlos@0
   157
    <Parameter name="cBpartnerId"/>
carlos@0
   158
  </SqlMethod>
juanpablo@152
   159
</SqlClass>