DBA Data[Home] [Help]

PACKAGE BODY: APPS.AST_RATES_PKG

Source


1 PACKAGE BODY AST_RATES_PKG AS
2  /* $Header: astrtrtb.pls 115.9 2003/09/09 03:38:27 sssomesw ship $ */
3 ----------------------------------------------------------------------------
4 --    Purpose: To convert from one currency to another
5 -- Parameters: From Currency
6 --             To Currency,
7 --             Conversion Date
8 --             Amount to be converted
9 --    Returns: Converted Amount
10 --    Pre-req: The user has to make sure the following profiles are defined
11 --             correctly
12 --             AS_DEFAULT_PERIOD_TYPE
13 --             AS_FORECAST_CALENDAR
14 --  Created By     Date         Comments
15 --  sesundar       29-AUG-01    Initial version
16 --                              if the conversion status flag returns 1,it
17 --                              means that the conversion rate is not
18 --                              defined properly
19 ----------------------------------------------------------------------------
20 
21 FUNCTION CONVERT_AMOUNT( x_from_currency VARCHAR2,
22 					x_to_currency VARCHAR2,
23 					x_conversion_date DATE,
24 					x_amount NUMBER) return NUMBER IS
25 
26 l_period_type      VARCHAR2(100);
27 l_period_set_name  VARCHAR2(100);
28 l_converted_amount NUMBER;
29 l_converted_status NUMBER;
30 
31 BEGIN
32 
33 l_period_type:=nvl(fnd_profile.value('AS_DEFAULT_PERIOD_TYPE'),'Month');
34 l_period_set_name:=nvl(fnd_profile.value('AS_FORECAST_CALENDAR'),'Accounting');
35 
36 	 begin
37 
38 
39 	   select round((x_amount/rate.denominator_rate)*rate.numerator_rate,2),
40 			rate.conversion_status_flag
41 			into
42 			l_converted_amount,
43 			l_converted_status
44         from   as_period_rates rate,
45 			as_period_days day
46         where  rate.from_currency=x_from_currency
47 	   and    rate.to_currency=x_to_currency
48 	   and    day.period_name=rate.period_name
49 	   and    day.period_set_name=l_period_set_name
50 	   and    day.period_type=l_period_type
51 	   and    day.period_day=trunc(x_conversion_date);
52 
53 
54 	 exception
55 		 when others then
56 		   return null; /* 3133848 x_amount; */
57 
58 	 end;
59 
60 	 if l_converted_status=0 then
61 	    return l_converted_amount;
62       else
63 		   return null; /* 3133848 x_amount; */
64       end if;
65 
66 END CONVERT_AMOUNT;
67 
68 END;