src/org/openbravo/erpCommon/ad_forms/DocPayment_data.xsql
author David Alsasua <david.alsasua@openbravo.com>
Tue, 20 Jul 2010 13:41:49 +0200
changeset 7934 840c40e82c78
parent 7758 f4c105a71ad6
permissions -rw-r--r--
Fixes issue 13654
Added coalesce to avoid unwanted document cancellations
carlos@0
     1
<?xml version="1.0" encoding="UTF-8" ?>
carlos@0
     2
<!--
asier@799
     3
 *************************************************************************
asier@799
     4
 * The contents of this file are subject to the Openbravo  Public  License
asier@799
     5
 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
asier@799
     6
 * Version 1.1  with a permitted attribution clause; you may not  use this
asier@799
     7
 * file except in compliance with the License. You  may  obtain  a copy of
eduardo@4231
     8
 * the License at http://www.openbravo.com/legal/license.html
asier@799
     9
 * Software distributed under the License  is  distributed  on  an "AS IS"
asier@799
    10
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
asier@799
    11
 * License for the specific  language  governing  rights  and  limitations
eduardo@4231
    12
 * under the License.
eduardo@4231
    13
 * The Original Code is Openbravo ERP.
ggi@6702
    14
 * The Initial Developer of the Original Code is Openbravo SLU
ggi@6702
    15
 * All portions are Copyright (C) 2001-2008 Openbravo SLU
eduardo@4231
    16
 * All Rights Reserved.
asier@799
    17
 * Contributor(s):  ______________________________________.
asier@799
    18
 ************************************************************************
carlos@0
    19
-->
carlos@0
    20
<SqlClass name="DocPaymentData" package="org.openbravo.erpCommon.ad_forms">
carlos@0
    21
  <SqlClassComment></SqlClassComment>
carlos@0
    22
  <SqlMethod name="select" type="preparedStatement" return="multiple">
carlos@0
    23
    <SqlMethodComment></SqlMethodComment>
carlos@0
    24
    <Sql>
carlos@0
    25
      <![CDATA[
carlos@0
    26
        SELECT now() AS SYSDATE1, '' AS account_ID, '' AS C_SETTLEMENT_ID, '' AS AD_CLIENT_ID, '' AS AD_ORG_ID, '' AS ISACTIVE,
carlos@0
    27
        '' AS CREATED, '' AS CREATEDBY, '' AS UPDATED, '' AS UPDATEDBY, '' AS DOCUMENTNO, '' AS DATETRX, '' AS C_DOCTYPE_ID,
carlos@0
    28
        '' AS PROCESSING, '' AS PROCESSED, '' AS POSTED, '' AS C_PROJECT_ID, '' AS C_CAMPAIGN_ID, '' AS C_ACTIVITY_ID,
carlos@0
    29
        '' AS USER1_ID, '' AS USER2_ID, '' AS CREATEFROM, '' AS C_CURRENCY_ID, '' AS CANCELEDNOTCHARGEAMT, '' AS GENERATEDAMT,
carlos@0
    30
        '' AS CHARGEDAMT, '' AS DESCRIPTION, '' AS CREATEFILE, '' AS DATEACCT, '' AS SETTLEMENTTYPE, '' AS CREDIT_ACCT, '' AS DEBIT_ACCT,
david@7758
    31
        '' AS AMOUNTDEBIT, '' AS AMOUNTCREDIT, '' AS AMOUNT, '' AS C_TAX_ID, '' AS C_WITHHOLDING_ID, '' AS ISDIRECTPOSTING, '' AS ISMANUAL
carlos@0
    32
        FROM DUAL
carlos@0
    33
     ]]>
carlos@0
    34
     </Sql>
carlos@0
    35
   </SqlMethod>
carlos@0
    36
  <SqlMethod name="selectRegistro" type="preparedStatement" return="multiple">
carlos@0
    37
    <SqlMethodComment></SqlMethodComment>
carlos@0
    38
    <Sql>
carlos@0
    39
      <![CDATA[
carlos@0
    40
        SELECT S.AD_CLIENT_ID, S.AD_ORG_ID, S.C_PROJECT_ID, S.C_CAMPAIGN_ID, S.C_ACTIVITY_ID,
carlos@0
    41
        S.USER1_ID, S.USER2_ID, S.DOCUMENTNO, S.DATEACCT, S.C_CURRENCY_ID, S.C_DOCTYPE_ID,
carlos@0
    42
        S.CHARGEDAMT, S.POSTED, S.DATETRX, S.SETTLEMENTTYPE
carlos@0
    43
        FROM C_SETTLEMENT S
eduardo@4231
    44
        WHERE AD_Client_ID=?
juanpablo@1605
    45
        AND C_SETTLEMENT_ID=?
carlos@0
    46
     ]]>
carlos@0
    47
     </Sql>
carlos@0
    48
     <Parameter name="client"/>
carlos@0
    49
     <Parameter name="id"/>
carlos@0
    50
   </SqlMethod>
carlos@0
    51
  <SqlMethod name="selectBPartnerCustomerAcct" type="preparedStatement" return="multiple">
carlos@0
    52
    <SqlMethodComment></SqlMethodComment>
carlos@0
    53
    <Sql>
carlos@0
    54
      <![CDATA[
carlos@0
    55
        SELECT COALESCE(
eduardo@4231
    56
          (SELECT C_RECEIVABLE_ACCT
carlos@0
    57
          FROM C_BP_CUSTOMER_ACCT
juanpablo@1605
    58
          WHERE C_BPARTNER_ID = ?
juanpablo@1605
    59
          AND C_ACCTSCHEMA_ID = ?
carlos@0
    60
          AND STATUS = ?),
eduardo@4231
    61
          (SELECT C_RECEIVABLE_ACCT
carlos@0
    62
          FROM C_BP_CUSTOMER_ACCT
juanpablo@1605
    63
          WHERE C_BPARTNER_ID = ?
juanpablo@1605
    64
          AND C_ACCTSCHEMA_ID = ?
carlos@0
    65
          AND STATUS IS NULL)) AS ACCOUNT_ID FROM DUAL
carlos@0
    66
carlos@0
    67
     ]]>
carlos@0
    68
     </Sql>
carlos@0
    69
     <Parameter name="C_BPARTNER_ID"/>
eduardo@4231
    70
     <Parameter name="C_ACCTSCHEMA_ID"/>
carlos@0
    71
     <Parameter name="STATUS"/>
carlos@0
    72
     <Parameter name="C_BPARTNER_ID"/>
carlos@0
    73
     <Parameter name="C_ACCTSCHEMA_ID"/>
carlos@0
    74
   </SqlMethod>
carlos@0
    75
  <SqlMethod name="selectBPartnerVendorAcct" type="preparedStatement" return="multiple">
carlos@0
    76
    <SqlMethodComment></SqlMethodComment>
carlos@0
    77
    <Sql>
carlos@0
    78
      <![CDATA[
carlos@0
    79
        SELECT COALESCE(
eduardo@4231
    80
          (SELECT V_LIABILITY_ACCT
carlos@0
    81
          FROM C_BP_VENDOR_ACCT
juanpablo@1605
    82
          WHERE C_BPARTNER_ID = ?
juanpablo@1605
    83
          AND C_ACCTSCHEMA_ID = ?
carlos@0
    84
          AND STATUS = ?),
carlos@0
    85
          (SELECT V_LIABILITY_ACCT
carlos@0
    86
          FROM C_BP_VENDOR_ACCT
juanpablo@1605
    87
          WHERE C_BPARTNER_ID = ?
juanpablo@1605
    88
          AND C_ACCTSCHEMA_ID = ?
carlos@0
    89
          AND STATUS IS NULL)) AS ACCOUNT_ID FROM DUAL
carlos@0
    90
     ]]>
carlos@0
    91
     </Sql>
carlos@0
    92
     <Parameter name="C_BPARTNER_ID"/>
eduardo@4231
    93
     <Parameter name="C_ACCTSCHEMA_ID"/>
carlos@0
    94
     <Parameter name="STATUS"/>
carlos@0
    95
     <Parameter name="C_BPARTNER_ID"/>
eduardo@4231
    96
     <Parameter name="C_ACCTSCHEMA_ID"/>
carlos@0
    97
   </SqlMethod>
asier@1929
    98
  <SqlMethod name="selectBankStatementLineAcct" type="preparedStatement" return="multiple">
asier@1929
    99
    <SqlMethodComment></SqlMethodComment>
asier@1929
   100
    <Sql>
asier@1929
   101
      <![CDATA[
asier@1929
   102
		SELECT B_INTRANSIT_ACCT  AS ACCOUNT_ID
asier@1929
   103
		FROM C_BANKSTATEMENTLINE, C_BANKSTATEMENT, C_BANKACCOUNT, C_BANKACCOUNT_ACCT
asier@1929
   104
		WHERE C_BANKSTATEMENTLINE.C_BANKSTATEMENT_ID = C_BANKSTATEMENT.C_BANKSTATEMENT_ID
asier@1929
   105
		AND C_BANKSTATEMENT.C_BANKACCOUNT_ID = C_BANKACCOUNT.C_BANKACCOUNT_ID
asier@1929
   106
		AND C_BANKACCOUNT.C_BANKACCOUNT_ID = C_BANKACCOUNT_ACCT.C_BANKACCOUNT_ID
asier@1929
   107
		AND C_BANKSTATEMENTLINE_ID = ?
asier@1929
   108
		AND C_BANKACCOUNT_ACCT.C_ACCTSCHEMA_ID = ?
asier@1929
   109
     ]]>
asier@1929
   110
     </Sql>
asier@1929
   111
     <Parameter name="C_BANKSTATEMENTLINE_ID"/>
eduardo@4231
   112
     <Parameter name="C_ACCTSCHEMA_ID"/>
asier@1929
   113
   </SqlMethod>
asier@1929
   114
  <SqlMethod name="selectCashLineAcct" type="preparedStatement" return="multiple">
asier@1929
   115
    <SqlMethodComment></SqlMethodComment>
asier@1929
   116
    <Sql>
asier@1929
   117
      <![CDATA[
asier@1929
   118
		SELECT CB_RECEIPT_ACCT  AS ACCOUNT_ID
asier@1929
   119
		FROM C_CASHLINE, C_CASH, C_CASHBOOK, C_CASHBOOK_ACCT
asier@1929
   120
		WHERE C_CASHLINE.C_CASH_ID = C_CASH.C_CASH_ID
asier@1929
   121
		AND C_CASH.C_CASHBOOK_ID = C_CASHBOOK.C_CASHBOOK_ID
asier@1929
   122
		AND C_CASHBOOK.C_CASHBOOK_ID = C_CASHBOOK_ACCT.C_CASHBOOK_ID
asier@1929
   123
		AND C_CASHLINE_ID = ?
asier@1929
   124
		AND C_CASHBOOK_ACCT.C_ACCTSCHEMA_ID = ?
asier@1929
   125
     ]]>
asier@1929
   126
     </Sql>
asier@1929
   127
     <Parameter name="C_CASHLINE_ID"/>
eduardo@4231
   128
     <Parameter name="C_ACCTSCHEMA_ID"/>
asier@1929
   129
   </SqlMethod>
carlos@0
   130
  <SqlMethod name="selectCancelManual" type="preparedStatement" return="multiple">
carlos@0
   131
    <SqlMethodComment></SqlMethodComment>
carlos@0
   132
    <Sql>
carlos@0
   133
      <![CDATA[
carlos@0
   134
        SELECT B.AMOUNTCREDIT AS AMOUNTCREDIT, B.AMOUNTDEBIT AS AMOUNTDEBIT, GA.GLITEM_CREDIT_ACCT AS CREDIT_ACCT, GA.GLITEM_DEBIT_ACCT AS DEBIT_ACCT
carlos@0
   135
        FROM C_DEBT_PAYMENT D, C_DEBT_PAYMENT_BALANCING B, C_GLITEM G, C_GLITEM_ACCT GA
carlos@0
   136
        WHERE D.C_DEBT_PAYMENT_ID = B.C_DEBT_PAYMENT_ID
carlos@0
   137
        AND B.C_GLITEM_ID = G.C_GLITEM_ID
carlos@0
   138
        AND G.C_GLITEM_ID = GA.C_GLITEM_ID
juanpablo@1605
   139
        AND GA.C_ACCTSCHEMA_ID = ?
juanpablo@1605
   140
        AND B.C_DEBT_PAYMENT_ID = (SELECT C_DEBT_PAYMENT_ID FROM C_DEBT_PAYMENT WHERE C_SETTLEMENT_CANCEL_ID = ?)
carlos@0
   141
     ]]>
carlos@0
   142
     </Sql>
carlos@0
   143
     <Parameter name="C_ACCTSCHEMA_ID"/>
carlos@0
   144
     <Parameter name="C_SETTLEMENT_ID"/>
carlos@0
   145
   </SqlMethod>
carlos@0
   146
  <SqlMethod name="selectManual" type="preparedStatement" return="multiple">
carlos@0
   147
    <SqlMethodComment></SqlMethodComment>
carlos@0
   148
    <Sql>
carlos@0
   149
      <![CDATA[
eduardo@4231
   150
        SELECT B.AMOUNTCREDIT AS AMOUNTCREDIT, B.AMOUNTDEBIT AS AMOUNTDEBIT, GA.Glitem_Credit_Acct AS CREDIT_ACCT, GA.Glitem_Debit_Acct AS DEBIT_ACCT,
david@7758
   151
        G.C_TAX_ID, G.C_WITHHOLDING_ID
carlos@0
   152
        FROM C_DEBT_PAYMENT D, C_DEBT_PAYMENT_BALANCING B, C_GLITEM G, C_Glitem_Acct GA
carlos@0
   153
        WHERE D.C_DEBT_PAYMENT_ID = B.C_DEBT_PAYMENT_ID
carlos@0
   154
        AND B.C_GLITEM_ID = G.C_GLITEM_ID
carlos@0
   155
        AND G.C_GLITEM_ID = GA.C_GLITEM_ID
juanpablo@1605
   156
        AND GA.C_ACCTSCHEMA_ID = ?
juanpablo@1605
   157
        AND D.C_DEBT_PAYMENT_ID = ?
carlos@0
   158
     ]]>
carlos@0
   159
     </Sql>
carlos@0
   160
     <Parameter name="C_ACCTSCHEMA_ID"/>
carlos@0
   161
     <Parameter name="C_DEBT_PAYMENT_ID"/>
carlos@0
   162
   </SqlMethod>
carlos@0
   163
  <SqlMethod name="selectDirectManual" type="preparedStatement" return="multiple">
carlos@0
   164
    <SqlMethodComment></SqlMethodComment>
carlos@0
   165
    <Sql>
carlos@0
   166
      <![CDATA[
carlos@0
   167
        SELECT C_GLITEM_ACCT.GLITEM_CREDIT_ACCT AS CREDIT_ACCT,
eduardo@4231
   168
        C_GLITEM_ACCT.GLITEM_DEBIT_ACCT AS DEBIT_ACCT, C_DEBT_PAYMENT.AMOUNT AS AMOUNT,
eduardo@4231
   169
        G.C_TAX_ID, G.C_WITHHOLDING_ID
eduardo@4231
   170
        FROM C_DEBT_PAYMENT, C_GLITEM G, C_GLITEM_ACCT
eduardo@4231
   171
        WHERE G.C_GLITEM_ID = C_GLITEM_ACCT.C_GLITEM_ID
eduardo@4231
   172
        AND G.C_GLITEM_ID = C_DEBT_PAYMENT.C_GLITEM_ID
juanpablo@1605
   173
        AND C_GLITEM_ACCT.C_ACCTSCHEMA_ID = ?
juanpablo@1605
   174
        AND C_DEBT_PAYMENT.C_DEBT_PAYMENT_ID = ?
carlos@0
   175
     ]]>
carlos@0
   176
     </Sql>
carlos@0
   177
     <Parameter name="C_ACCTSCHEMA_ID"/>
carlos@0
   178
     <Parameter name="C_DEBT_PAYMENT_ID"/>
carlos@0
   179
   </SqlMethod>
david@7758
   180
   
david@7758
   181
   <SqlMethod name="paymentsInformation" type="preparedStatement" return="multiple">
david@7758
   182
    <SqlMethodComment></SqlMethodComment>
david@7758
   183
    <Sql>
david@7758
   184
      <![CDATA[
david@7934
   185
        SELECT COALESCE(DP.ISMANUAL,'N') AS ISMANUAL, COALESCE(DP.ISDIRECTPOSTING,'N') AS ISDIRECTPOSTING
david@7758
   186
        FROM C_SETTLEMENT S LEFT JOIN C_DEBT_PAYMENT DP
david@7758
   187
          ON DP.C_SETTLEMENT_GENERATE_ID = S.C_SETTLEMENT_ID
david@7758
   188
        WHERE S.C_SETTLEMENT_ID = ?
david@7758
   189
     ]]>
david@7758
   190
     </Sql>
david@7758
   191
     <Parameter name="settlementID"/>
david@7758
   192
   </SqlMethod>
carlos@0
   193
</SqlClass>