DBA Data[Home] [Help]

PACKAGE BODY: APPS.AP_TAX_ENGINE_PKG

Source


1 package body AP_TAX_ENGINE_PKG as
2 /* $Header: aptxengb.pls 120.3 2005/10/06 18:13:53 hongliu noship $ */
3 
4 g_current_runtime_level    NUMBER;
5 g_level_procedure          CONSTANT  NUMBER   := FND_LOG.LEVEL_PROCEDURE;
6 
7 
8 -----------------------------------------------------------------------
9 --  PUBLIC PROCEDURE
10 --     calculate_tax
11 --
12 --  DESCRIPTION
13 --     This procedure provides an API for calculating tax for a document
14 --     in Oracle Payables and Oracle Purchasing.
15 --     This procedure returns calculated tax information including
16 --     non-recoverable and recoverable tax for a document when
17 --     a view name and the document header ID or line ID or shipment ID
18 --     are passed .
19 --     Used by Oracle Payables and Oracle Purchasing.
20 --
21 --     If the Trx Line ID is passed, then Trx Line ID is used ignoring the
22 --     Trx Header ID passed.
23 --
24 --  PARAMETERS
25 --     p_viewname                   IN  VARCHAR2,
26 --     p_trx_header_id              IN  NUMBER,
27 --     p_trx_line_id                IN  NUMBER,
28 --     p_trx_shipment_id            IN  NUMBER,
29 --     p_calling_sequence           IN  VARCHAR2,
30 --     p_tax_info_tbl               IN OUT NOCOPY  AP_TAX_ENGINE_PKG.tax_info_rec_tbl_type
31 --
32 --  RETURNS
33 --     A local tax_info_tbl is returned for Purchasing's  requirement.  Also a global
34 --     PL/SQL table g_tax_info_tbl stores all the tax information.
35 --
36 --  HISTORY
37 --     Fiona Purves       22-OCT-98  Created
38 --
39 --     Wei Feng           22-MAR-99  Enhanced
40 --
41 --
42 --     Wei Feng           19-JUL-1999  Fixed bug 927073
43 --
44 --        Tax on requisitions should be calculated initially using the
45 --        transaction currency, using the rounding options, convert into
46 --        functional currency using the Euro APIs, then store the tax
47 --        amounts in functional currency.  A new column has been added
48 --        to the requisition view to show transaction unit price for
49 --        this purpose.
50 --
51 --    Debasis Choudhuri   01-DEC-99 BugFix 1064036
52 --                                 Using native dynamic SQL.
53 --    Debasis Choudhuri   02-09-2000 Implement Tax_group and Bug Fix 1076352.
54 -----------------------------------------------------------------------
55 
56 
57 PROCEDURE calculate_tax
58           (p_viewname             IN  VARCHAR2,
59            p_trx_header_id        IN  NUMBER,
60            p_trx_line_id          IN  NUMBER,
61            p_trx_shipment_id      IN  NUMBER,
62            p_calling_sequence     IN  VARCHAR2,
63            p_tax_info_tbl         IN OUT NOCOPY tax_info_rec_tbl_type
64 ) IS
65 
66 BEGIN
67   g_current_runtime_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
68   IF (g_level_procedure >= g_current_runtime_level ) THEN
69     FND_LOG.STRING(g_level_procedure,
70            'AP.PLSQL.AP_TAX_ENGINE_PKG.calculate_tax',
71            'Warning - obsolete code being referenced: AP_TAX_ENGINE_PKG.calculate_tax)');
72   END IF;
73 END calculate_tax;
74 
75 
76 -----------------------------------------------------------------------
77 --  PUBLIC PROCEDURE
78 --     calculate_tax  overloaded
79 --
80 --  DESCRIPTION
81 --     This procedure provides an API for calculating tax for a document
82 --     in Oracle Payables and Oracle Purchasing.
83 --     This procedure returns calculated tax information including
84 --     non-recoverable and recoverable tax for a document when
85 --     a PL/SQL table and the application name are passed as input
86 --     parameters.
87 --     Used by Oracle Payables and Oracle Purchasing.
88 --
89 --
90 --  PARAMETERS
91 --     p_pdt_tax_info_tbl           IN AP_TAX_ENGINE_PKG.tax_info_rec_tbl_type
92 --     p_application_name           IN VARCHAR2
93 --     p_tax_info_tbl               IN OUT NOCOPY  AP_TAX_ENGINE_PKG.tax_info_rec_tbl_type
94 --
95 --  RETURNS
96 --     A local tax_info_tbl is returned for Purchasing's  requirement.  Also a global
97 --     PL/SQL table g_tax_info_tbl stores all the tax information.
98 --
99 --  HISTORY
100 --     Prabha Seshadri       15-NOV-02  Created
101 -----------------------------------------------------------------------
102 PROCEDURE calculate_tax
103           ( p_pdt_tax_info_tbl           IN  AP_TAX_ENGINE_PKG.tax_info_rec_tbl_type
104           , p_application_name           IN  VARCHAR2
105           , p_tax_info_tbl               IN OUT NOCOPY AP_TAX_ENGINE_PKG.tax_info_rec_tbl_type
106            )
107 IS
108 BEGIN
109   g_current_runtime_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
110   IF (g_level_procedure >= g_current_runtime_level ) THEN
111     FND_LOG.STRING(g_level_procedure,
112            'AP.PLSQL.AP_TAX_ENGINE_PKG.calculate_tax',
113            'Warning - obsolete code being referenced: AP_TAX_ENGINE_PKG.calculate_tax)');
114   END IF;
115 END calculate_tax;
116 
117 
118 -----------------------------------------------------------------------
119 --  PUBLIC PROCEDURE
120 --     copy_record
121 --
122 --  DESCRIPTION
123 --     This procedure is called by calculate_ap_tax, calculate_po_tax,
124 --     summarize_tax. It copys the passed in PL/SQL record information
125 --     into PL/SQL tax table.
126 --
127 --  PARAMETERS
128 --     p_tax_info_rec                IN tax_info_rec_type
129 --     p_calling_sequence            IN  VARCHAR2
130 --
131 --  RETURNS
132 --     None
133 --
134 --  HISTORY
135 --     Fiona Purves, Wei Feng        22-MAR-99  Created
136 --
137 --
138 -----------------------------------------------------------------------
139 
140 PROCEDURE copy_record ( p_calling_sequence          IN VARCHAR2,
141                         p_tax_info_rec              IN tax_info_rec_type
142                        ) IS
143 
144 BEGIN
145   g_current_runtime_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
146   IF (g_level_procedure >= g_current_runtime_level ) THEN
147     FND_LOG.STRING(g_level_procedure,
148            'AP.PLSQL.AP_TAX_ENGINE_PKG.copy_record',
149            'Warning - obsolete code being referenced: AP_TAX_ENGINE_PKG.copy_record)');
150   END IF;
151 END copy_record;
152 
153 
154 -----------------------------------------------------------------------
155 --  PUBLIC PROCEDURE
156 --     initialize_g_tax_info_rec
157 --
158 --  DESCRIPTION
159 --     This procedure is called by calculate_tax.  It initializes each
160 --     column in g_tax_info_rec to NULL.
161 --
162 --  PARAMETERS
163 --     p_calling_sequence            IN  VARCHAR2
164 --
165 --  RETURNS
166 --     None
167 --
168 --  HISTORY
169 --     Wei Feng                      22-MAR-99  Created
170 --
171 --
172 -----------------------------------------------------------------------
173 
174 PROCEDURE initialize_g_tax_info_rec ( p_calling_sequence   IN VARCHAR2) IS
175 
176 BEGIN
177   g_current_runtime_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
178   IF (g_level_procedure >= g_current_runtime_level ) THEN
179     FND_LOG.STRING(g_level_procedure,
180            'AP.PLSQL.AP_TAX_ENGINE_PKG.initialize_g_tax_info_rec',
181            'Warning - obsolete code being referenced: AP_TAX_ENGINE_PKG.initialize_g_tax_info_rec)');
182   END IF;
183 END initialize_g_tax_info_rec;
184 
185 ----------------------------------------------------------------------
186 --  PUBLIC FUNCTION
187 --     sum_tax_group_rate
188 --
189 --  DESCRIPTION
190 --     This function is to accumulate the total tax rate and offset tax
191 --     rate of a tax group.
192 --
193 --     This function is called by AP_TAX_LINES_SUMMARY_V in order to
194 --     provide a solution for multiple taxes inclusive calculation.
195 --     (bug 989021  and bug 1084978).
196 --
197 --     The formula used in the view as follows:
198 --
199 --     (dist_amount - dist_amount * sum_tax_group_rate / (sum_tax_group_rate + 100))
200 --      * (tax_rate/100 +1)
201 --
202 --  PARAMETERS
203 --     p_tax_group_id             IN  NUMBER
204 --     p_trx_date                 IN  DATE
205 --     p_vendor_site_id           IN  NUMBER
206 --
207 --  RETURNS
208 --     NUMBER
209 --
210 --  HISTORY
211 --     Wei Feng                      22-NOV-99  Created
212 --     Wei Feng                      22-NOV-99  Modified
213 --           Added sel_tax_group_offset_rate to fix bug 1084978:
214 --           Inclusive multiple tax calculation for offset tax.
215 --
216 --
217 -----------------------------------------------------------------------
218 
219 FUNCTION sum_tax_group_rate
220    (p_tax_group_id     IN  ar_tax_group_codes_all.tax_group_id%TYPE,
221     p_trx_date         IN  ap_invoices_all.invoice_date%TYPE,
222     p_vendor_site_id   IN  po_vendor_sites_all.vendor_site_id%TYPE
223    ) return NUMBER IS
224 
225 BEGIN
226   g_current_runtime_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
227   IF (g_level_procedure >= g_current_runtime_level ) THEN
228     FND_LOG.STRING(g_level_procedure,
229            'AP.PLSQL.AP_TAX_ENGINE_PKG.sum_tax_group_rate',
230            'Warning - obsolete code being referenced: AP_TAX_ENGINE_PKG.sum_tax_group_rate)');
231   END IF;
232 END sum_tax_group_rate;
233 
234 -----------------------------------------------------------------------
235 --  PUBLIC FUNCTION
236 --     offset_factor
237 --
238 --  DESCRIPTION
239 --     This function is to calculate the unit price factor due to offset and inclusive
240 --
241 --     This function is called by AP_TAX_LINES_SUMMARY_V in order to
242 --     provide a solution for inclusive tax calculation for tax with offset.
243 --
244 --     The formula used in the view as follows:
245 --
246 --     dist_amount * factor
247 --
248 --  PARAMETERS
249 --  p_offset_tax_flag	     	IN VARCHAR2,
250 --  p_amount_includes_tax_flag 	IN VARCHAR2,
251 --  p_tax_rate			IN NUMBER,
252 --  p_offset_tax_code_id     	IN NUMBER,
253 --  p_trx_date         		IN DATE
254 --
255 --  RETURNS
256 --     NUMBER
257 --
258 --  HISTORY
259 --     Helen Si                     18-AUG-04   Created
260 --
261 -----------------------------------------------------------------------
262 
263 FUNCTION offset_factor
264    (p_offset_tax_flag	     IN  ap_supplier_sites_all.offset_tax_flag%TYPE,
265     p_amount_includes_tax_flag IN ap_invoice_distributions_all.amount_includes_tax_flag%TYPE,
266     p_tax_rate		IN ap_tax_codes_all.tax_rate%TYPE,
267     p_offset_tax_code_id     IN  ap_tax_codes_all.offset_tax_code_id%TYPE,
268     p_trx_date         IN  ap_invoices_all.invoice_date%TYPE
269    ) return NUMBER IS
270 
271 BEGIN
272   g_current_runtime_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
273   IF (g_level_procedure >= g_current_runtime_level ) THEN
274     FND_LOG.STRING(g_level_procedure,
275            'AP.PLSQL.AP_TAX_ENGINE_PKG.offset_factor',
276            'Warning - obsolete code being referenced: AP_TAX_ENGINE_PKG.offset_factor)');
277   END IF;
278 END offset_factor;
279 
280 -------------------------------------------------------------------------------
281 --
282 --   get_amount
283 --
284 --   HISTORY
285 --     Surekha Myadam                 12-DEC-2001       Created
286 -------------------------------------------------------------------------------
287 
288 FUNCTION get_amount( p_invoice_distribution_id     NUMBER,
289                      p_line_type_lookup_code       VARCHAR2,
290                      p_amount_includes_tax_flag    VARCHAR2,
291                      p_amount                      NUMBER ) RETURN NUMBER IS
292 
293 BEGIN
294   g_current_runtime_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
295   IF (g_level_procedure >= g_current_runtime_level ) THEN
296     FND_LOG.STRING(g_level_procedure,
297            'AP.PLSQL.AP_TAX_ENGINE_PKG.get_amount',
298            'Warning - obsolete code being referenced: AP_TAX_ENGINE_PKG.get_amount)');
299   END IF;
300 END get_amount;
301 
302 -------------------------------------------------------------------------------
303 --
304 --   get_system_tax_defaults
305 --
306 -------------------------------------------------------------------------------
307 BEGIN
308 
309   NULL;
310 
311 END AP_TAX_ENGINE_PKG;