[Home] [Help]
PACKAGE BODY: APPS.AP_APPPST_PKG
Source
1 PACKAGE BODY AP_APPPST_PKG AS
2 /* $Header: appstfxb.pls 120.3 2004/10/28 23:28:52 pjena noship $ */
3 --
4 function Ap_Get_GL_Interface_Amount
5 (EnteredAmount IN NUMBER
6 ,BaseAmount IN NUMBER
7 ,AccountType IN VARCHAR2
8 ,ResultColumn IN VARCHAR2)
9 return NUMBER
10 is
11 --
12 tmpForSwap NUMBER;
13 Entered_DR NUMBER;
14 Entered_CR NUMBER;
15 Accounted_DR NUMBER;
16 Accounted_CR NUMBER;
17 --
18 BEGIN
19 --
20 -- In the following if-else-endif, construct, we are doing everything assuming
21 -- that we are operating on a Debit account.
22 --
23 if ( (SIGN(EnteredAmount) = -1) OR
24 ((EnteredAmount = 0) AND (SIGN(NVL(BaseAmount, EnteredAmount)) = -1))
25 ) then
26 --
27 -- Special cases (where a debit account should be credited)
28 --
29 Entered_DR := NULL;
30 Entered_CR := 0 - EnteredAmount;
31 Accounted_DR := NULL;
32 Accounted_CR := 0 - NVL(BaseAmount, EnteredAmount);
33 --
34 else
35 --
36 -- Normal cases (where debit accounts should be debited)
37 --
38 Entered_DR := EnteredAmount;
39 Entered_CR := NULL;
40 Accounted_DR := NVL(BaseAmount, EnteredAmount);
41 Accounted_CR := NULL;
42 --
43 end if;
44 --
45 -- For Credit accounts, correct (swap) the entries because they
46 -- were created assuming Debit Accounts.
47 --
48 if (AccountType = 'CR') then
49 --
50 -- swap Entered_DR and Entered_CR
51 tmpForSwap := Entered_DR;
52 Entered_Dr := Entered_CR;
53 Entered_CR := tmpForSwap;
54 --
55 -- swap Accounted_DR and Accounted_CR
56 tmpForSwap := Accounted_DR;
57 Accounted_Dr := Accounted_CR;
58 Accounted_CR := tmpForSwap;
59 --
60 end if;
61 --
62 select decode(UPPER(ResultColumn), 'ENTERED_DR' , Entered_DR
63 , 'ENTERED_CR' , Entered_CR
64 , 'ACCOUNTED_DR', Accounted_DR
65 , Accounted_CR)
66 into tmpForSwap from dual;
67 --
68 return tmpForSwap;
69 --
70 END AP_Get_GL_Interface_Amount;
71 --
72 --
73 function Ap_apppst_Round_Currency
74 (P_Amount IN number
75 ,P_Currency_Code IN varchar2)
76 return number is
77 l_rounded_amount number;
78 begin
79 --
80 select decode(FC.minimum_accountable_unit,
81 null, round(P_Amount, FC.precision),
82 round(P_Amount/FC.minimum_accountable_unit) *
83 FC.minimum_accountable_unit)
84 into l_rounded_amount
85 from fnd_currencies FC
86 where FC.currency_code = P_Currency_Code;
87 --
88 return(l_rounded_amount);
89 --
90 EXCEPTION
91
92 WHEN NO_DATA_FOUND THEN
93
94 return (null);
95 --
96 end AP_APPPST_ROUND_CURRENCY;
97 --
98
99 END AP_APPPST_PKG;