database/model/functions/M_GET_OFFER_PRICE.xml
author Carlos Romero <carlos.romero@openbravo.com>
Tue, 06 Nov 2007 08:33:31 +0000
changeset 0 0247c26f10c6
child 94 4e7ba7b8a4ad
permissions -rw-r--r--
Modified PostgreSQL post script in order to include C_DEBT_PAYMENT_GENERATE modification tules
carlos@0
     1
<?xml version="1.0"?>
carlos@0
     2
<database name="FUNCTION M_GET_OFFER_PRICE">
carlos@0
     3
<function name="M_GET_OFFER_PRICE" type="NUMERIC">
carlos@0
     4
<parameter name="p_Offer_ID" type="NUMERIC" mode="in"/>
carlos@0
     5
<parameter name="p_PriceStd" type="NUMERIC" mode="in"/>
carlos@0
     6
<body><![CDATA[
carlos@0
     7
/*************************************************************************
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
/*
carlos@0
    24
DEPRECATED!
carlos@0
    25
This function should not be used. Use instead M_Get_Offers_Price.
carlos@0
    26
*/
carlos@0
    27
  v_Price    NUMBER;
carlos@0
    28
  v_Fixed    NUMBER;
carlos@0
    29
  v_AddAmt   NUMBER;
carlos@0
    30
  v_Discount NUMBER;
carlos@0
    31
BEGIN
carlos@0
    32
  v_Price := p_PriceStd;
carlos@0
    33
  IF v_Price IS NULL THEN
carlos@0
    34
    v_Price := 0;
carlos@0
    35
  END IF;
carlos@0
    36
  IF p_Offer_ID IS NOT NULL THEN
carlos@0
    37
    SELECT FIXED,
carlos@0
    38
      COALESCE(ADDAMT, 0),
carlos@0
    39
      COALESCE(DISCOUNT, 0)
carlos@0
    40
    INTO  v_Fixed,
carlos@0
    41
      v_AddAmt,
carlos@0
    42
      v_Discount
carlos@0
    43
    FROM M_OFFER
carlos@0
    44
    WHERE M_OFFER_ID = p_Offer_ID;
carlos@0
    45
    IF v_Fixed IS NOT NULL THEN
carlos@0
    46
      v_Price := v_Fixed;
carlos@0
    47
    ELSE
carlos@0
    48
      v_Price :=(p_PriceStd - v_AddAmt) *(1 - v_Discount/100) ;
carlos@0
    49
    END IF;
carlos@0
    50
  END IF;
carlos@0
    51
  RETURN v_Price;
carlos@0
    52
EXCEPTION
carlos@0
    53
WHEN OTHERS THEN
carlos@0
    54
  RETURN NULL;
carlos@0
    55
END M_Get_Offer_Price ]]></body>
carlos@0
    56
</function> 
carlos@0
    57
</database>