DBA Data[Home] [Help]

PACKAGE BODY: APPS.JA_KR_AP_SPECIAL_WH_PKG

Source


1 PACKAGE BODY JA_KR_AP_SPECIAL_WH_PKG AS
2 /* $Header: jakrpwhb.pls 115.5 2002/11/12 22:13:24 thwon ship $ */
3 
4 
5 /**************************************************************************
6  *                                                                        *
7  * Name       : rounding_units                                            *
8  * Purpose    : This function returns rounded amount to the down unit     *
9  *                                                                        *
10  **************************************************************************/
11 
12 FUNCTION rounding_units
13 		(P_Withheld_Amount	IN   Number,
14 		 P_Calling_Sequence	IN   Varchar2) RETURN Number
15 IS
16    -------------------------------
17    -- Local Variables Definition
18    -------------------------------
19    Rounded Number;
20    debug_info                     Varchar2(500);
21    current_calling_sequence       Varchar2(2000);
22 
23 BEGIN
24    current_calling_sequence := 'JA_KR_AP_SPECIAL_WH_PKG.<- rounding_units ' ||
25                                 P_Calling_Sequence;
26    rounded := nvl(P_Withheld_Amount,0) - (nvl(P_Withheld_Amount,0) mod 10);
27    RETURN nvl(rounded,P_Withheld_Amount);
28 
29 EXCEPTION
30    WHEN others THEN
31            IF (SQLCODE <> -20001) THEN
32               FND_MESSAGE.SET_NAME('SQLAP','JA_KR_AP_DEBUG');
33               FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
34               FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',current_calling_sequence);
35               FND_MESSAGE.SET_TOKEN('PARAMETERS',
36                       'P_Withheld_Amount1 = ' || to_char(P_Withheld_Amount));
37               FND_MESSAGE.SET_TOKEN('DEBUG_INFO',debug_info);
38            END IF;
39            APP_EXCEPTION.RAISE_EXCEPTION;
40 
41 END rounding_units;
42 
43 /**************************************************************************
44  *                                                                        *
45  * Name       : Minimum_Withheld_Amt                                      *
46  * Purpose    : This function returns the value stoted in Global          *
47  *              Attribute13 from ap_tax_codes                              *
48  *                                                                        *
49  **************************************************************************/
50 
51 FUNCTION Minimum_Withheld_Amt
52                 (P_Tax_Name             IN     Varchar2,
53                  P_Calling_Sequence     IN     Varchar2) RETURN NUMBER
54 IS
55    -------------------------------
56    -- Local Variables Definition
57    -------------------------------
58    Min_Wh                         Number := 0;
59    debug_info                     Varchar2(500);
60    current_calling_sequence       Varchar2(2000);
61    CURSOR C_Minimum IS
62       SELECT to_number(global_attribute13) Minimum
63         FROM AP_Tax_Codes
64        WHERE name = P_Tax_Name;
65 
66 BEGIN
67    current_calling_sequence := 'JA_KR_AP_SPECIAL_WH_PKG.<- Minimum_Withheld_Amt ' ||
68                                 P_Calling_Sequence;
69    FOR db_reg IN C_Minimum LOOP
70        Min_Wh := nvl(db_reg.Minimum,0);
71        RETURN (Min_Wh);
72    END LOOP;
73    RETURN (Min_Wh);
74 
75 EXCEPTION
76    WHEN others THEN
77            IF (SQLCODE <> -20001) THEN
78               FND_MESSAGE.SET_NAME('SQLAP','JA_KR_AP_DEBUG');
79               FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
80               FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',current_calling_sequence);
81               FND_MESSAGE.SET_TOKEN('PARAMETERS',
82                       'P_Tax_Name = ' || P_Tax_Name);
83               FND_MESSAGE.SET_TOKEN('DEBUG_INFO',debug_info);
84            END IF;
85            APP_EXCEPTION.RAISE_EXCEPTION;
86 
87 END Minimum_Withheld_Amt;
88 
89 
90 Procedure Ja_Special_Withheld_Amt
91                 (
92                  P_Withheld_Amount        IN OUT NOCOPY Number
93                 ,P_Base_WT_amount         IN OUT NOCOPY Number
94                 ,P_CurrCode               IN Varchar2
95                 ,P_BaseCurrCode           IN Varchar2
96                 ,P_Invoice_exchange_rate  IN Number
97                 ,P_Tax_Name               IN Varchar2
98                 ,P_Calling_sequence       IN Varchar2
99                  )
100 
101 IS
102    -------------------------------
103    -- Local Variables Definition
104    -------------------------------
105    Rounded                     Number;
106    Min_Wh                      Number := 0;
107    debug_info                  Varchar2(500);
108    current_calling_sequence    Varchar2(2000);
109 
110 BEGIN
111 
112    current_calling_sequence := 'JA_KR_AP_SPECIAL_WH_PKG.<- Ja_Special_Withheld_Amt ' ||
113                                 P_Calling_Sequence;
114 
115    IF (P_CurrCode = P_BaseCurrCode) THEN
116 
117       P_Base_WT_Amount  := Rounding_Units
118                              (P_Base_WT_Amount
119                              ,P_calling_sequence);
120 
121       P_Withheld_Amount := Rounding_Units
122                              (P_Withheld_Amount
123                              ,P_calling_sequence);
124 
125    ELSE
126       IF (P_Invoice_Exchange_Rate is null) THEN
127         P_Base_WT_Amount := 0;
128         P_Withheld_Amount := Rounding_Units
129                                 (P_Withheld_Amount
130                                 ,P_calling_sequence);
131       ELSE
132         P_Base_WT_Amount := Rounding_Units
133                                 (P_Base_WT_Amount
134                                 ,P_calling_sequence);
135         P_Withheld_Amount := P_Base_Wt_Amount * P_Invoice_Exchange_Rate;
136       END IF;
137    END IF;
138 
139   /*****************************************************************
140     Check for Minimum Withheld Amount
141    *****************************************************************/
142    Min_Wh := Minimum_Withheld_Amt(P_Tax_Name
143                               ,P_calling_sequence);
144 
145    IF  Min_Wh > P_Base_WT_Amount THEN
146        P_Base_WT_Amount  := 0;
147        P_Withheld_Amount := 0;
148    END IF;
149 
150 EXCEPTION
151    WHEN others THEN IF (SQLCODE <> -20001) THEN
152               FND_MESSAGE.SET_NAME('SQLAP','JA_KR_AP_DEBUG');
153               FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
154               FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',current_calling_sequence);
155               FND_MESSAGE.SET_TOKEN('PARAMETERS',
156                       ' P_Withheld_Amount = ' || to_char(P_Withheld_Amount)||
157                       ', P_Base_WT_Amount = ' || to_char(Min_Wh));
158               FND_MESSAGE.SET_TOKEN('DEBUG_INFO',debug_info);
159            END IF;
160            APP_EXCEPTION.RAISE_EXCEPTION;
161 
162 END Ja_Special_Withheld_Amt;
163 
164 END JA_KR_AP_SPECIAL_WH_PKG;