src-util/modulescript/src/org/openbravo/modulescript/UpdateBpPaymentLine_data.xsql
author Sandra Huguet <sandra.huguet@openbravo.com>
Thu, 29 Jan 2015 17:22:12 +0100
changeset 25772 5ef45cfcb9a5
parent 25593 f5b23fe2295b
child 26141 b9fc7e8e60ae
permissions -rw-r--r--
Fixed bug 27570 updateBpPaymentLineInvoice is not correct for all scenarios
fernando@25593
     1
<?xml version="1.0" encoding="UTF-8" ?>
fernando@25593
     2
<!--
fernando@25593
     3
 *************************************************************************
fernando@25593
     4
 * The contents of this file are subject to the Openbravo  Public  License
fernando@25593
     5
 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
fernando@25593
     6
 * Version 1.1  with a permitted attribution clause; you may not  use this
fernando@25593
     7
 * file except in compliance with the License. You  may  obtain  a copy of
fernando@25593
     8
 * the License at http://www.openbravo.com/legal/license.html
fernando@25593
     9
 * Software distributed under the License  is  distributed  on  an "AS IS"
fernando@25593
    10
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
fernando@25593
    11
 * License for the specific  language  governing  rights  and  limitations
fernando@25593
    12
 * under the License.
fernando@25593
    13
 * The Original Code is Openbravo ERP.
fernando@25593
    14
 * The Initial Developer of the Original Code is Openbravo SLU
sandra@25772
    15
 * All portions are Copyright (C) 2014-2015 Openbravo SLU
fernando@25593
    16
 * All Rights Reserved.
fernando@25593
    17
 * Contributor(s):  ______________________________________.
fernando@25593
    18
 ************************************************************************
fernando@25593
    19
-->
fernando@25593
    20
<SqlClass name="UpdateBpPaymentLineData" package="org.openbravo.modulescript">
fernando@25593
    21
   <SqlClassComment></SqlClassComment>
fernando@25593
    22
  <SqlMethod name="select" type="preparedStatement" return="multiple">
fernando@25593
    23
    <SqlMethodComment></SqlMethodComment>
fernando@25593
    24
    <Sql><![CDATA[
fernando@25593
    25
      SELECT '' as exist FROM DUAL
fernando@25593
    26
      ]]>
fernando@25593
    27
    </Sql>
fernando@25593
    28
  </SqlMethod>
fernando@25593
    29
  <SqlMethod name="updateBpPaymentLineInvoice" type="preparedStatement" return="rowcount">
fernando@25593
    30
    <SqlMethodComment></SqlMethodComment>
fernando@25593
    31
    <Sql>
fernando@25593
    32
      <![CDATA[
fernando@25593
    33
				update fin_payment_scheduledetail psd
fernando@25593
    34
				set c_bpartner_id = (select c_bpartner_id from c_invoice i, fin_payment_schedule ps
fernando@25593
    35
				                     where ps.fin_payment_schedule_id = fin_payment_schedule_invoice 
fernando@25593
    36
				                     and ps.c_invoice_id = i.c_invoice_id)
fernando@25593
    37
				where c_bpartner_id is null and fin_payment_schedule_invoice is not null 
fernando@25593
    38
      ]]>
fernando@25593
    39
    </Sql>
fernando@25593
    40
  </SqlMethod>
fernando@25593
    41
  <SqlMethod name="updateBpPaymentLineOrder" type="preparedStatement" return="rowcount">
fernando@25593
    42
    <SqlMethodComment></SqlMethodComment>
fernando@25593
    43
    <Sql>
fernando@25593
    44
      <![CDATA[
fernando@25593
    45
				update fin_payment_scheduledetail psd
fernando@25593
    46
				set c_bpartner_id = (select c_bpartner_id from c_order o, fin_payment_schedule ps
fernando@25593
    47
				                     where ps.fin_payment_schedule_id = fin_payment_schedule_order 
fernando@25593
    48
				                     and ps.c_order_id = o.c_order_id)
fernando@25593
    49
				where c_bpartner_id is null and fin_payment_schedule_order is not null
fernando@25593
    50
					and fin_payment_schedule_invoice is null
fernando@25593
    51
      ]]>
fernando@25593
    52
    </Sql>
fernando@25593
    53
  </SqlMethod>
fernando@25593
    54
   <SqlMethod name="isModuleScriptExecuted" type="preparedStatement" return="boolean">
fernando@25593
    55
    <SqlMethodComment></SqlMethodComment>
fernando@25593
    56
    <Sql>
fernando@25593
    57
      <![CDATA[
fernando@25593
    58
    SELECT count(*) as exist
fernando@25593
    59
    FROM ad_preference
sandra@25772
    60
    WHERE attribute = 'UpdateBpPaymentLine2' and isactive = 'Y'
fernando@25593
    61
      ]]>
fernando@25593
    62
    </Sql>
fernando@25593
    63
  </SqlMethod>
fernando@25593
    64
   <SqlMethod name="createPreference" type="preparedStatement" return="rowcount">
fernando@25593
    65
    <SqlMethodComment></SqlMethodComment>
fernando@25593
    66
    <Sql>
fernando@25593
    67
      <![CDATA[
fernando@25593
    68
    INSERT INTO ad_preference (
fernando@25593
    69
    ad_preference_id, ad_client_id, ad_org_id, isactive,
fernando@25593
    70
    createdby, created, updatedby, updated, attribute
fernando@25593
    71
    ) VALUES (
fernando@25593
    72
    get_uuid(), '0', '0', 'Y', 
sandra@25772
    73
    '0', NOW(), '0', NOW(), 'UpdateBpPaymentLine2')
fernando@25593
    74
      ]]>
fernando@25593
    75
    </Sql>
fernando@25593
    76
  </SqlMethod>
fernando@25593
    77
</SqlClass>