src/org/openbravo/erpCommon/ad_forms/RemittanceCancel_data.xsql
author Iván Perdomo <ivan.perdomo@openbravo.com>
Thu, 24 Apr 2008 17:12:02 +0000
changeset 770 8850d5956eba
parent 423 ecf368072c48
child 1601 2e879205773a
permissions -rw-r--r--
Bug fix [0000111]. Modified mapping name used on manual code.
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="RemittanceCancelData" package="org.openbravo.erpCommon.ad_forms">
carlos@0
    26
  <SqlClassComment>Clase MaterialReceiptPendingLinesData</SqlClassComment>
carlos@0
    27
  <SqlMethod name="select" type="preparedStatement" return="multiple">
carlos@0
    28
    <SqlMethodComment>Select for relation</SqlMethodComment>
carlos@0
    29
    <Sql>
carlos@0
    30
    <![CDATA[
carlos@0
    31
        select rl.C_RemittanceLine_ID,
carlos@0
    32
               dp.C_Debt_Payment_ID,ad_column_identifier('C_Debt_Payment',to_char(dp.C_Debt_Payment_ID),?) AS DPIdentifier,
carlos@0
    33
               rl.C_Remittance_Id,  ad_column_identifier('C_Remittance',to_char(rl.C_Remittance_Id),?) AS RIdentifier,
carlos@0
    34
               r.duedate, '' as line
carlos@0
    35
          from c_debt_payment    dp,
carlos@0
    36
               c_remittanceLine  rl,
carlos@0
    37
               c_Remittance			 r
carlos@0
    38
         where rl.c_debt_payment_id = dp.c_debt_payment_id
carlos@0
    39
           and coalesce(rl.returned,'N') = 'N'
carlos@0
    40
           and dp.C_SETTLEMENT_CANCEL_ID is null
carlos@0
    41
           and r.processed = 'Y'
carlos@0
    42
           and r.C_Remittance_ID    = rl.C_Remittance_ID
carlos@0
    43
           AND r.AD_CLIENT_ID IN ('1') 
carlos@0
    44
           AND r.AD_ORG_ID IN ('1') 
carlos@0
    45
           AND 1=1 
carlos@0
    46
           order by r.DOCUMENTNO, r.duedate
carlos@0
    47
      ]]></Sql>
carlos@0
    48
      <Field name="rownum" value="count"/>
carlos@0
    49
      <Parameter name="adLanguage"/>
carlos@0
    50
      <Parameter name="adLanguage"/>
carlos@0
    51
      <Parameter name="userClient" optional="true" type="replace" after="AND r.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
    52
      <Parameter name="userOrg" optional="true" type="replace" after="AND r.AD_ORG_ID IN (" text="'1'"/>
carlos@423
    53
      <Parameter name="cRemittanceId" optional="true" after="AND 1=1 " text=" and r.C_Remittance_ID = TO_NUMBER(?) "/> 
carlos@0
    54
      <Parameter name="from" optional="true" after="AND 1=1 "><![CDATA[ and r.duedate >= TO_DATE(?) ]]></Parameter>
carlos@0
    55
      <Parameter name="to" optional="true" after="AND 1=1 "><![CDATA[ and r.duedate <= TO_DATE(?) ]]></Parameter>
carlos@0
    56
  </SqlMethod>
carlos@0
    57
carlos@0
    58
 <SqlMethod name="set" type="constant" return="multiple">
carlos@0
    59
  <SqlMethodComment>Create a registry</SqlMethodComment>
carlos@0
    60
  <Sql></Sql> 
carlos@0
    61
  </SqlMethod>
carlos@0
    62
carlos@0
    63
  <SqlMethod name="insertSettlement" connection="true" type="preparedStatement" return="rowCount">
carlos@0
    64
    <SqlMethodComment>Principal select</SqlMethodComment>
carlos@0
    65
    <Sql>
carlos@0
    66
    <![CDATA[
carlos@0
    67
        INSERT INTO C_SETTLEMENT (C_SETTLEMENT_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY,
carlos@0
    68
           DOCUMENTNO, DATETRX, DATEACCT, SETTLEMENTTYPE, C_DOCTYPE_ID, C_Currency_ID,
carlos@0
    69
           description,IsGenerated)
carlos@0
    70
           values
carlos@0
    71
           (?, ?, ?, 'Y', now(), ?, now(), ?, 
carlos@0
    72
           '*RT*'||?,?, ?,'C', Ad_Get_DocType(?, ?, 'STT'),  (select c_currency_id
carlos@0
    73
                                       from  c_remittanceLine rl,
carlos@0
    74
                                             c_debt_payment   dp
carlos@423
    75
                                      where c_RemittanceLine_ID = TO_NUMBER(?)
carlos@0
    76
                                        and dp.c_debt_payment_id = rl.c_debt_payment_id),
carlos@0
    77
           '*RT* Cancel','Y')
carlos@0
    78
      ]]></Sql>
carlos@0
    79
    <Parameter name="cSettlementID"/>
carlos@0
    80
    <Parameter name="client"/>
carlos@0
    81
    <Parameter name="org"/>
carlos@0
    82
    <Parameter name="user"/>
carlos@0
    83
    <Parameter name="user"/>
carlos@0
    84
    <Parameter name="docNo"/>
carlos@0
    85
    <Parameter name="dateacct"/>
carlos@0
    86
    <Parameter name="dateacct"/>
carlos@0
    87
    <Parameter name="client"/>
carlos@0
    88
    <Parameter name="org"/>
carlos@0
    89
    <Parameter name="rl"/> 
carlos@0
    90
  </SqlMethod>
carlos@0
    91
carlos@0
    92
carlos@0
    93
    <SqlMethod name="insertDPManagement" connection="true" type="preparedStatement" return="rowCount">
carlos@0
    94
    <SqlMethodComment>Principal select</SqlMethodComment>
carlos@0
    95
    <Sql>
carlos@0
    96
    <![CDATA[
carlos@0
    97
       insert into C_DP_Management
carlos@0
    98
       (C_DP_MANAGEMENT_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, 
carlos@0
    99
       DOCUMENTNO, DATETRX, C_DOCTYPE_ID,  DATEACCT,C_Currency_ID)
carlos@0
   100
     values
carlos@0
   101
       (?, ?, ?, 'Y', now(), ?, now(), ?, 
carlos@0
   102
        ?, ?, Ad_Get_DocType(?, ?, 'DPM'), ?, (select c_currency_id
carlos@0
   103
                                 from  c_remittanceLine rl,
carlos@0
   104
                                       c_debt_payment   dp
carlos@423
   105
                                where c_RemittanceLine_ID = TO_NUMBER(?)
carlos@0
   106
                                  and dp.c_debt_payment_id = rl.c_debt_payment_id))
carlos@0
   107
      ]]></Sql>
carlos@0
   108
    <Parameter name="CDPID"/>
carlos@0
   109
    <Parameter name="client"/>
carlos@0
   110
    <Parameter name="org"/>
carlos@0
   111
    <Parameter name="user"/>
carlos@0
   112
    <Parameter name="user"/>
carlos@0
   113
    <Parameter name="docNo"/>
carlos@0
   114
    <Parameter name="dateacct"/>
carlos@0
   115
    <Parameter name="client"/>
carlos@0
   116
    <Parameter name="org"/>
carlos@0
   117
    <Parameter name="dateacct"/>
carlos@0
   118
    <Parameter name="rl"/> 
carlos@0
   119
  </SqlMethod>
carlos@0
   120
    <SqlMethod name="selectOrg" type="preparedStatement" return="String">
carlos@0
   121
    <SqlMethodComment></SqlMethodComment>
carlos@0
   122
    <Sql>
carlos@0
   123
    <![CDATA[
carlos@0
   124
      SELECT C_REMITTANCE.AD_ORG_ID FROM C_REMITTANCE, C_REMITTANCELINE
carlos@0
   125
      WHERE C_REMITTANCE.C_REMITTANCE_ID =  C_REMITTANCELINE.C_REMITTANCE_ID
carlos@423
   126
      AND C_REMITTANCELINE_ID = TO_NUMBER(?)
carlos@0
   127
      ]]></Sql>
carlos@0
   128
    <Parameter name="line"/>
carlos@0
   129
  </SqlMethod>
carlos@0
   130
  <SqlMethod name="cancel" connection="true" type="preparedStatement" return="rowCount">
carlos@0
   131
    <SqlMethodComment>Principal select</SqlMethodComment>
carlos@0
   132
    <Sql>
carlos@0
   133
    <![CDATA[
carlos@0
   134
        update c_debt_payment
carlos@423
   135
           set c_Settlement_Cancel_ID = TO_NUMBER(?)
carlos@0
   136
        where c_debt_payment_id in (select c_debt_payment_cancelled
carlos@0
   137
                                      from c_remittanceLine 
carlos@423
   138
                                     where c_RemittanceLine_ID = TO_NUMBER(?)
carlos@0
   139
                                     union
carlos@0
   140
                                    select c_debt_payment_id
carlos@0
   141
                                      from c_remittanceLine 
carlos@423
   142
                                     where c_RemittanceLine_ID = TO_NUMBER(?))
carlos@0
   143
      ]]></Sql>
carlos@0
   144
    <Parameter name="cSettlementID"/>
carlos@0
   145
    <Parameter name="cRemittanceLine"/>
carlos@0
   146
    <Parameter name="cRemittanceLine"/>
carlos@0
   147
  </SqlMethod>
carlos@0
   148
carlos@0
   149
carlos@0
   150
  <SqlMethod name="returnDPOriginal" connection="true" type="preparedStatement" return="rowCount">
carlos@0
   151
    <SqlMethodComment>Principal select</SqlMethodComment>
carlos@0
   152
    <Sql>
carlos@0
   153
    <![CDATA[
carlos@0
   154
         insert into C_DP_ManagementLine
carlos@0
   155
           (C_DP_MANAGEMENTLINE_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, 
carlos@0
   156
            C_DP_MANAGEMENT_ID, STATUS_FROM, STATUS_TO, C_DEBT_PAYMENT_ID, LINE)
carlos@0
   157
         values
carlos@0
   158
           (?,?, ?, 'Y', now(), ?, now(), ?, 
carlos@0
   159
            ?, (select dp.status
carlos@0
   160
                        from c_debt_payment dp,
carlos@0
   161
                             c_remittanceLine rl
carlos@423
   162
                       where c_RemittanceLine_ID = TO_NUMBER(?)
carlos@0
   163
                         and dp.c_debt_payment_id = rl.c_debt_payment_id), 
carlos@0
   164
                     (select STATUS_RETURNED
carlos@0
   165
                        from c_remittanceLine rl,
carlos@0
   166
                             c_remittance r,
carlos@0
   167
                             c_remittance_type rt
carlos@0
   168
                       where rl.c_remittance_id = r.c_remittance_id
carlos@0
   169
                         and r.c_remittance_type_id  = rt.c_remittance_type_id
carlos@423
   170
                         and rl.c_RemittanceLine_ID = TO_NUMBER(?)),
carlos@0
   171
                     (select c_debt_payment_id
carlos@0
   172
                        from c_remittanceLine rl
carlos@423
   173
                       where c_RemittanceLine_ID = TO_NUMBER(?)), ?)
carlos@0
   174
      ]]></Sql>
carlos@0
   175
    <Parameter name="LID"/>
carlos@0
   176
    <Parameter name="client"/>
carlos@0
   177
    <Parameter name="org"/>
carlos@0
   178
    <Parameter name="user"/>
carlos@0
   179
    <Parameter name="user"/>
carlos@0
   180
    <Parameter name="DPMId"/>
carlos@0
   181
    <Parameter name="cRemittanceLine"/>
carlos@0
   182
    <Parameter name="cRemittanceLine"/>
carlos@0
   183
    <Parameter name="cRemittanceLine"/>
carlos@0
   184
	<Parameter name="line"/>
carlos@0
   185
  </SqlMethod>
carlos@0
   186
carlos@0
   187
    <SqlMethod name="returnDPGenerated" connection="true" type="preparedStatement" return="rowCount">
carlos@0
   188
    <SqlMethodComment>Principal select</SqlMethodComment>
carlos@0
   189
    <Sql>
carlos@0
   190
    <![CDATA[
carlos@0
   191
         insert into C_DP_ManagementLine
carlos@0
   192
           (C_DP_MANAGEMENTLINE_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, 
carlos@0
   193
            C_DP_MANAGEMENT_ID, STATUS_FROM, STATUS_TO, C_DEBT_PAYMENT_ID, LINE)
carlos@0
   194
         values
carlos@0
   195
           (?,?, ?, 'Y', now(), ?, now(), ?, 
carlos@0
   196
            ?, (select dp.status
carlos@0
   197
                        from c_debt_payment dp,
carlos@0
   198
                             c_remittanceLine rl
carlos@423
   199
                       where c_RemittanceLine_ID = TO_NUMBER(?)
carlos@0
   200
                         and dp.c_debt_payment_id = rl.C_DEBT_PAYMENT_CANCELLED), 
carlos@0
   201
                     (select STATUS_RETURNED
carlos@0
   202
                        from c_remittanceLine rl,
carlos@0
   203
                             c_remittance r,
carlos@0
   204
                             c_remittance_type rt
carlos@0
   205
                       where rl.c_remittance_id = r.c_remittance_id
carlos@0
   206
                         and r.c_remittance_type_id  = rt.c_remittance_type_id
carlos@423
   207
                         and rl.c_RemittanceLine_ID = TO_NUMBER(?)),
carlos@0
   208
                     (select C_DEBT_PAYMENT_CANCELLED
carlos@0
   209
                        from c_remittanceLine rl
carlos@423
   210
                       where c_RemittanceLine_ID = TO_NUMBER(?)), ?)
carlos@0
   211
      ]]></Sql>
carlos@0
   212
    <Parameter name="LID"/>
carlos@0
   213
    <Parameter name="client"/>
carlos@0
   214
    <Parameter name="org"/>
carlos@0
   215
    <Parameter name="user"/>
carlos@0
   216
    <Parameter name="user"/>
carlos@0
   217
    <Parameter name="DPMId"/>
carlos@0
   218
    <Parameter name="cRemittanceLine"/>
carlos@0
   219
    <Parameter name="cRemittanceLine"/>
carlos@0
   220
    <Parameter name="cRemittanceLine"/>
carlos@0
   221
    <Parameter name="line"/>
carlos@0
   222
  </SqlMethod>
carlos@0
   223
carlos@0
   224
  <SqlMethod name="selectLineNo" type="preparedStatement" return="rowCount">
carlos@0
   225
    <Sql>
carlos@0
   226
      <![CDATA[
carlos@0
   227
          SELECT COALESCE(MAX(LINE),0) AS LINE
carlos@0
   228
            FROM C_REMITTANCELINE 
carlos@423
   229
           WHERE C_REMITTANCE_ID = TO_NUMBER(?)
carlos@0
   230
        ]]>
carlos@0
   231
    </Sql>
carlos@0
   232
    <Parameter name="remittaceID"/>
carlos@0
   233
   </SqlMethod>
carlos@0
   234
carlos@0
   235
carlos@0
   236
  <SqlMethod name="setReturned" connection="true" type="preparedStatement" return="rowCount">
carlos@0
   237
    <SqlMethodComment>Principal select</SqlMethodComment>
carlos@0
   238
    <Sql>
carlos@0
   239
    <![CDATA[
carlos@0
   240
        update c_RemittanceLine
carlos@0
   241
           set returned = 'Y'
carlos@423
   242
         where c_RemittanceLine_ID = TO_NUMBER(?)
carlos@0
   243
      ]]></Sql>
carlos@0
   244
    <Parameter name="cRemittanceLineID"/>
carlos@0
   245
  </SqlMethod>
carlos@0
   246
carlos@0
   247
carlos@0
   248
  <SqlMethod name="process800140" connection="true" type="callableStatement" return="object" object="RemittanceCancelData">
carlos@0
   249
      <SqlMethodComment>procedure C_DP_Management_Post</SqlMethodComment>
carlos@0
   250
      <Sql><![CDATA[
carlos@0
   251
        CALL C_DP_Management_Post(TO_NUMBER(?), NULL)
carlos@0
   252
      ]]></Sql>
carlos@0
   253
      <Parameter name="adPinstanceId"></Parameter>
carlos@0
   254
   </SqlMethod>
carlos@0
   255
carlos@0
   256
   <SqlMethod name="process800025" connection="true" type="callableStatement" return="object" object="RemittanceCancelData">
carlos@0
   257
      <SqlMethodComment>procedure C_Settlement_Post0</SqlMethodComment>
carlos@0
   258
      <Sql><![CDATA[
carlos@0
   259
        CALL C_Settlement_Post(NULL, TO_NUMBER(?))
carlos@0
   260
      ]]></Sql>
carlos@0
   261
      <Parameter name="cSettlementId"></Parameter>
carlos@0
   262
   </SqlMethod>
carlos@0
   263
carlos@0
   264
    <SqlMethod name="getLineDPM" type="preparedStatement" return="String">
carlos@0
   265
    <SqlMethodComment></SqlMethodComment>
carlos@0
   266
    <Sql>
carlos@0
   267
      <![CDATA[
carlos@0
   268
	    SELECT COALESCE(MAX(LINE),0) AS LINE
carlos@0
   269
		  FROM C_DP_ManagementLine
carlos@423
   270
		 WHERE C_DP_MANAGEMENT_ID = TO_NUMBER(?)
carlos@0
   271
      ]]>
carlos@0
   272
    </Sql>
carlos@0
   273
    <Parameter name="dpmId"/>
carlos@0
   274
  </SqlMethod>
carlos@0
   275
carlos@0
   276
</SqlClass>