src-db/database/model/functions/C_BP_SOCREDITUSED_REFRESH.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Wed, 03 Sep 2008 17:55:37 +0000
changeset 1605 8a0fe0193bef
parent 756 ae11e4610537
child 4019 bf2ae654c0cc
permissions -rw-r--r--
Merge r2.5x intro trunk
carlos@0
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="FUNCTION C_BP_SOCREDITUSED_REFRESH">
adrian@94
     3
    <function name="C_BP_SOCREDITUSED_REFRESH" type="NULL">
juanpablo@1605
     4
      <parameter name="p_bpartner_id" type="VARCHAR" mode="in">
antonio@735
     5
        <default/>
antonio@735
     6
      </parameter>
gorkaion@239
     7
      <body><![CDATA[/*************************************************************************
carlos@0
     8
* The contents of this file are subject to the Openbravo  Public  License
carlos@0
     9
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
carlos@0
    10
* Version 1.1  with a permitted attribution clause; you may not  use this
carlos@0
    11
* file except in compliance with the License. You  may  obtain  a copy of
carlos@0
    12
* the License at http://www.openbravo.com/legal/license.html
carlos@0
    13
* Software distributed under the License  is  distributed  on  an "AS IS"
carlos@0
    14
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
carlos@0
    15
* License for the specific  language  governing  rights  and  limitations
carlos@0
    16
* under the License.
carlos@0
    17
* The Original Code is Openbravo ERP.
carlos@0
    18
* The Initial Developer of the Original Code is Openbravo SL
carlos@0
    19
* All portions are Copyright (C) 2001-2006 Openbravo SL
carlos@0
    20
* All Rights Reserved.
carlos@0
    21
* Contributor(s):  ______________________________________.
carlos@0
    22
************************************************************************/
carlos@0
    23
BEGIN
carlos@0
    24
  UPDATE C_BPARTNER
carlos@0
    25
    SET SO_CreditUsed=
carlos@0
    26
    (SELECT  COALESCE(SUM(C_Base_Convert((Amount - WriteOffAmt), C_Currency_ID, AD_Client_ID, DatePlanned, AD_Org_ID)), 0) AS TOTAL
carlos@0
    27
    FROM C_DEBT_PAYMENT_V
carlos@0
    28
    WHERE C_BPartner_ID=p_BPartner_ID
carlos@0
    29
      AND C_DEBT_PAYMENT_STATUS(C_SETTLEMENT_CANCEL_ID, Cancel_Processed, Generate_Processed, IsPaid, IsValid, C_CashLine_ID, C_BankStatementLine_ID)='P'
carlos@0
    30
    )
carlos@0
    31
  WHERE C_BPartner_ID=p_BPartner_ID;
adrian@94
    32
END C_BP_SOCREDITUSED_REFRESH
gorkaion@239
    33
]]></body>
adrian@94
    34
    </function>
adrian@94
    35
  </database>