database/model/functions/M_GET_OFFER_PRICE.xml
author Adrián Romero <adrian.romero@openbravo.com>
Wed, 05 Dec 2007 20:43:45 +0000
changeset 170 4b5493776a7f
parent 132 33c5ca45fcff
child 239 a30acae847e1
permissions -rw-r--r--
Bug fixed: [ 1845110 ] Database model not in sync with database created
carlos@0
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="FUNCTION M_GET_OFFER_PRICE">
adrian@94
     3
    <function name="M_GET_OFFER_PRICE" type="NUMERIC">
adrian@94
     4
      <parameter name="p_Offer_ID" type="NUMERIC" mode="in"/>
adrian@94
     5
      <parameter name="p_PriceStd" type="NUMERIC" mode="in"/>
adrian@170
     6
      <body>/*************************************************************************
carlos@0
     7
* The contents of this file are subject to the Openbravo  Public  License
carlos@0
     8
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
carlos@0
     9
* Version 1.1  with a permitted attribution clause; you may not  use this
carlos@0
    10
* file except in compliance with the License. You  may  obtain  a copy of
carlos@0
    11
* the License at http://www.openbravo.com/legal/license.html
carlos@0
    12
* Software distributed under the License  is  distributed  on  an "AS IS"
carlos@0
    13
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
carlos@0
    14
* License for the specific  language  governing  rights  and  limitations
carlos@0
    15
* under the License.
carlos@0
    16
* The Original Code is Openbravo ERP.
carlos@0
    17
* The Initial Developer of the Original Code is Openbravo SL
carlos@0
    18
* All portions are Copyright (C) 2001-2006 Openbravo SL
carlos@0
    19
* All Rights Reserved.
carlos@0
    20
* Contributor(s):  ______________________________________.
carlos@0
    21
************************************************************************/
carlos@0
    22
/*
carlos@0
    23
DEPRECATED!
carlos@0
    24
This function should not be used. Use instead M_Get_Offers_Price.
carlos@0
    25
*/
carlos@0
    26
  v_Price    NUMBER;
carlos@0
    27
  v_Fixed    NUMBER;
carlos@0
    28
  v_AddAmt   NUMBER;
carlos@0
    29
  v_Discount NUMBER;
carlos@0
    30
BEGIN
carlos@0
    31
  v_Price := p_PriceStd;
carlos@0
    32
  IF v_Price IS NULL THEN
carlos@0
    33
    v_Price := 0;
carlos@0
    34
  END IF;
carlos@0
    35
  IF p_Offer_ID IS NOT NULL THEN
carlos@0
    36
    SELECT FIXED,
carlos@0
    37
      COALESCE(ADDAMT, 0),
carlos@0
    38
      COALESCE(DISCOUNT, 0)
carlos@0
    39
    INTO  v_Fixed,
carlos@0
    40
      v_AddAmt,
carlos@0
    41
      v_Discount
carlos@0
    42
    FROM M_OFFER
carlos@0
    43
    WHERE M_OFFER_ID = p_Offer_ID;
carlos@0
    44
    IF v_Fixed IS NOT NULL THEN
carlos@0
    45
      v_Price := v_Fixed;
carlos@0
    46
    ELSE
carlos@0
    47
      v_Price :=(p_PriceStd - v_AddAmt) *(1 - v_Discount/100) ;
carlos@0
    48
    END IF;
carlos@0
    49
  END IF;
carlos@0
    50
  RETURN v_Price;
carlos@0
    51
EXCEPTION
carlos@0
    52
WHEN OTHERS THEN
carlos@0
    53
  RETURN NULL;
adrian@170
    54
END M_Get_Offer_Price 
adrian@170
    55
</body>
adrian@94
    56
    </function>
adrian@94
    57
  </database>