[Home] [Help]
PACKAGE BODY: APPS.INL_TAX_PVT
Source
1 PACKAGE BODY INL_TAX_PVT AS
2 /* $Header: INLVTAXB.pls 120.25 2010/09/23 14:09:57 ebarbosa ship $ */
3
4 -- Utl name : Delete_PreviousTaxLines
5 -- Type : Private
6 -- Function : Delete previous Tax Lines
7 -- Pre-reqs : None
8 -- Parameters :
9 -- IN : p_ship_header_id IN NUMBER,
10 --
11 -- OUT : x_return_status OUT NOCOPY VARCHAR2
12 --
13 -- Version : Current version 1.0
14 --
15 -- Notes :
16 PROCEDURE Delete_PreviousTaxLines (
17 p_ship_header_id IN NUMBER,
18 x_return_status OUT NOCOPY VARCHAR2
19 ) IS
20 l_proc_name CONSTANT VARCHAR2(100) := 'Delete_PreviousTaxLines';
21 l_debug_info VARCHAR2(240);
22 l_return_status VARCHAR2(1);
23 BEGIN
24
25 -- Standard Beginning of Procedure/Function Logging
26 INL_LOGGING_PVT.Log_BeginProc (
27 p_module_name => g_module_name,
28 p_procedure_name => l_proc_name
29 );
30
31 -- Initialize API return status to success
32 x_return_status := FND_API.G_RET_STS_SUCCESS;
33
34 --Deleting all Tax records
35 l_debug_info := 'Deleting Tax records.';
36 INL_LOGGING_PVT.Log_Statement (
37 p_module_name => g_module_name,
38 p_procedure_name => l_proc_name,
39 p_debug_info => l_debug_info
40 );
41
42 DELETE FROM inl_tax_lines tl
43 WHERE tl.ship_header_id = P_ship_Header_Id
44 OR (tl.ship_header_id is null
45 AND EXISTS (SELECT 1
46 FROM inl_associations assoc
47 WHERE assoc.ship_header_id = P_ship_Header_Id
48 AND assoc.from_parent_table_name = 'INL_TAX_LINES'
49 AND assoc.from_parent_table_id = tl.tax_line_id)
50 AND NOT EXISTS (SELECT 1
51 FROM inl_associations assoc, inl_ship_headers sh
52 WHERE assoc.ship_header_id <> P_ship_Header_Id
53 AND assoc.ship_header_id = sh.ship_header_id
54 AND sh.ship_status_code = 'COMPLETED'
55 AND from_parent_table_name = 'INL_TAX_LINES'
56 AND from_parent_table_id = tl.tax_line_id))
57 ;
58
59 --Deleting all association records from Taxes
60 l_debug_info := 'Deleting association records.';
61 INL_LOGGING_PVT.Log_Statement (
62 p_module_name => g_module_name,
63 p_procedure_name => l_proc_name,
64 p_debug_info => l_debug_info
65 );
66
67 DELETE FROM inl_associations assoc
68 WHERE assoc.from_parent_table_name = 'INL_TAX_LINES'
69 AND NOT EXISTS (SELECT 1
70 FROM inl_tax_lines tl
71 WHERE assoc.from_parent_table_id = tl.tax_line_id)
72 ;
73 -- Standard End of Procedure/Function Logging
74 INL_LOGGING_PVT.Log_EndProc (
75 p_module_name => g_module_name,
76 p_procedure_name => l_proc_name
77 );
78
79 EXCEPTION
80 WHEN FND_API.G_EXC_ERROR THEN
81 -- Standard Expected Error Logging
82 INL_LOGGING_PVT.Log_ExpecError (p_module_name => g_module_name,
83 p_procedure_name => l_proc_name);
84 x_return_status := FND_API.G_RET_STS_ERROR;
85 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
86 -- Standard Unexpected Error Logging
87 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
88 p_procedure_name => l_proc_name);
89 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
90 WHEN OTHERS THEN
91 -- Standard Unexpected Error Logging
92 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
93 p_procedure_name => l_proc_name);
94 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
95 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
96 FND_MSG_PUB.Add_Exc_Msg(g_pkg_name,l_proc_name);
97 END IF;
98 END Delete_PreviousTaxLines;
99
100
101
102 -- Utl name : Prorate_TaxValues
103 -- Type : Private
104 -- Function : Import Tax Lines from PO
105 -- Pre-reqs : None
106 -- Parameters :
107 -- IN : p_po_line_location_id IN NUMBER
108 -- p_sl_currency_code IN VARCHAR2
109 -- p_sl_currency_conversion_type IN VARCHAR2
110 -- p_sl_currency_conversion_date IN DATE
111 -- p_sl_currency_conversion_rate IN NUMBER
112 -- p_sl_txn_qty IN NUMBER
113 -- p_sl_txn_unit_price IN NUMBER
114 --
115 -- OUT : x_tax_amt IN OUT NOCOPY NUMBER
116 -- x_rec_tax_amt IN OUT NOCOPY NUMBER
117 -- x_return_status OUT NOCOPY VARCHAR2
118 --
119 -- Version : Current version 1.0
120 --
121 -- Notes :
122 PROCEDURE Prorate_TaxValues (
123 p_po_line_location_id IN NUMBER,
124 p_sl_currency_code IN VARCHAR2,
125 p_sl_currency_conversion_type IN VARCHAR2,
126 p_sl_currency_conversion_date IN DATE,
127 p_sl_txn_qty IN NUMBER,
128 p_sl_txn_unit_price IN NUMBER,
129 x_tax_amt IN OUT NOCOPY NUMBER,
130 x_rec_tax_amt IN OUT NOCOPY NUMBER,
131 x_return_status OUT NOCOPY VARCHAR2
132 ) IS
133 l_proc_name CONSTANT VARCHAR2(100) := 'Prorate_TaxValues';
134 l_debug_info VARCHAR2(240);
135 l_return_status VARCHAR2(1);
136
137 l_qty NUMBER;
138 l_amt NUMBER;
139 l_po_curr_code VARCHAR2(15);
140 l_po_curr_rate_type VARCHAR2(30);
141 l_po_curr_rate_date DATE;
142 l_proration_rate NUMBER;
143 BEGIN
144
145 -- Standard Beginning of Procedure/Function Logging
146 INL_LOGGING_PVT.Log_BeginProc (
147 p_module_name => g_module_name,
148 p_procedure_name => l_proc_name
149 );
150
151 -- Initialize API return status to success
152 x_return_status := FND_API.G_RET_STS_SUCCESS;
153
154 --Getting PO_LINE_LOCATION data
155 l_debug_info := 'Getting PO_LINE_LOCATION data';
156 INL_LOGGING_PVT.Log_Statement (
157 p_module_name => g_module_name,
158 p_procedure_name => l_proc_name,
159 p_debug_info => l_debug_info
160 );
161
162 SELECT pll.quantity,
163 (pll.quantity * pL.unit_price) amount,
164 pH.currency_code,
165 pH.rate_type,
166 pH.rate_date
167 INTO l_qty,
168 l_amt,
169 l_po_curr_code,
170 l_po_curr_rate_type,
171 l_po_curr_rate_date
172 FROM po_line_locations pll,
173 po_lines_all pL,
174 po_headers pH
175 WHERE pll.line_location_id = p_po_line_location_id
176 AND pll.po_line_id = pL.po_line_id
177 AND pll.po_header_id = pH.po_header_id
178 ;
179
180 -- Bug #10129922
181 IF l_amt = 0 THEN
182 RETURN;
183 END IF;
184
185 --Verify if currency convertion is required
186 l_debug_info := 'Verify if currency convertion is required';
187 INL_LOGGING_PVT.Log_Statement (
188 p_module_name => g_module_name,
189 p_procedure_name => l_proc_name,
190 p_debug_info => l_debug_info
191 );
192 IF p_sl_currency_code <> l_po_curr_code THEN
193 --Use LCM INL_LANDEDCOST_PVT.Converted_Amt to get the converted amount
194 l_debug_info := 'Use LCM INL_LANDEDCOST_PVT.Converted_Amt to get the converted amount';
195 INL_LOGGING_PVT.Log_Statement (
196 p_module_name => g_module_name,
197 p_procedure_name => l_proc_name,
198 p_debug_info => l_debug_info
199 );
200 l_debug_info := 'l_amt';
201 INL_LOGGING_PVT.Log_Variable (
202 p_module_name => g_module_name,
203 p_procedure_name => l_proc_name,
204 p_var_name => l_debug_info,
205 p_var_value => l_amt
206 );
207 l_debug_info := 'l_po_curr_code';
208 INL_LOGGING_PVT.Log_Variable (
209 p_module_name => g_module_name,
210 p_procedure_name => l_proc_name,
211 p_var_name => l_debug_info,
212 p_var_value => l_po_curr_code
213 );
214 l_debug_info := 'p_sl_currency_code';
215 INL_LOGGING_PVT.Log_Variable (
216 p_module_name => g_module_name,
217 p_procedure_name => l_proc_name,
218 p_var_name => l_debug_info,
219 p_var_value => p_sl_currency_code
220 );
221 l_debug_info := 'nvl(l_po_curr_rate_type, p_sl_currency_conversion_type)';
222 INL_LOGGING_PVT.Log_Variable (
223 p_module_name => g_module_name,
224 p_procedure_name => l_proc_name,
225 p_var_name => l_debug_info,
226 p_var_value => nvl(l_po_curr_rate_type, p_sl_currency_conversion_type)
227 );
228 l_debug_info := 'nvl(l_po_curr_rate_date, p_sl_currency_conversion_date)';
229 INL_LOGGING_PVT.Log_Variable (
230 p_module_name => g_module_name,
231 p_procedure_name => l_proc_name,
232 p_var_name => l_debug_info,
233 p_var_value => nvl(l_po_curr_rate_date, p_sl_currency_conversion_date)
234 );
235 l_amt := INL_LANDEDCOST_PVT.Converted_Amt(
236 p_amt => l_amt,
237 p_from_currency_code => l_po_curr_code,
238 p_to_currency_code => p_sl_currency_code,
239 p_currency_conversion_type => nvl(l_po_curr_rate_type, p_sl_currency_conversion_type),
240 p_currency_conversion_date => nvl(l_po_curr_rate_date, p_sl_currency_conversion_date)
241 )
242 ;
243 l_debug_info := 'l_amt';
244 INL_LOGGING_PVT.Log_Variable (
245 p_module_name => g_module_name,
246 p_procedure_name => l_proc_name,
247 p_var_name => l_debug_info,
248 p_var_value => l_amt
249 );
250
251 END IF;
252 --Calculates the proration rate
253 l_debug_info := 'Calculates the proration rate';
254 INL_LOGGING_PVT.Log_Statement (
255 p_module_name => g_module_name,
256 p_procedure_name => l_proc_name,
257 p_debug_info => l_debug_info
258 );
259 l_proration_rate := (p_sl_txn_unit_price*p_sl_txn_qty) / l_amt;
260
261 --Calculates the proration of tax
262 l_debug_info := 'Calculates the proration of tax (proration_rate= '||l_proration_rate||')';
263 INL_LOGGING_PVT.Log_Statement (
264 p_module_name => g_module_name,
265 p_procedure_name => l_proc_name,
266 p_debug_info => l_debug_info
267 );
268
269 x_rec_tax_amt := x_rec_tax_amt * l_proration_rate;
270 l_debug_info := 'x_rec_tax_amt';
271 INL_LOGGING_PVT.Log_Variable (
272 p_module_name => g_module_name,
273 p_procedure_name => l_proc_name,
274 p_var_name => l_debug_info,
275 p_var_value => x_rec_tax_amt
276 );
277
278 x_tax_amt := x_tax_amt * l_proration_rate;
279 l_debug_info := 'x_tax_amt';
280 INL_LOGGING_PVT.Log_Variable (
281 p_module_name => g_module_name,
282 p_procedure_name => l_proc_name,
283 p_var_name => l_debug_info,
284 p_var_value => x_tax_amt
285 );
286
287 -- Standard End of Procedure/Function Logging
288 INL_LOGGING_PVT.Log_EndProc (
289 p_module_name => g_module_name,
290 p_procedure_name => l_proc_name
291 );
292
293 EXCEPTION
294 WHEN FND_API.G_EXC_ERROR THEN
295 -- Standard Expected Error Logging
296 INL_LOGGING_PVT.Log_ExpecError (p_module_name => g_module_name,
297 p_procedure_name => l_proc_name);
298 x_return_status := FND_API.G_RET_STS_ERROR;
299 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
300 -- Standard Unexpected Error Logging
301 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
302 p_procedure_name => l_proc_name);
303 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
304 WHEN OTHERS THEN
305 -- Standard Unexpected Error Logging
306 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
307 p_procedure_name => l_proc_name);
308 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
309 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
310 FND_MSG_PUB.Add_Exc_Msg(g_pkg_name,l_proc_name);
311 END IF;
312 END Prorate_TaxValues;
313
314 -- API name : Generate_TaxesFromPO
315 -- Type : Private
316 -- Function : Import Tax Lines from PO
317 -- Pre-reqs : None
318 -- Parameters :
319 -- IN : p_ship_header_id IN NUMBER Required
320 --
321 -- OUT p_tax_ln_tbl OUT tax_ln_tbl,
322 -- x_return_status OUT NOCOPY VARCHAR2
323 --
324 -- Version : Current version 1.0
325 --
326 -- Notes :
327 PROCEDURE Generate_TaxesFromPO (
328 p_ship_header_id IN NUMBER,
329 p_tax_ln_tbl OUT NOCOPY INL_TAX_PVT.tax_ln_tbl,
330 x_return_status OUT NOCOPY VARCHAR2
331 ) IS
332 l_proc_name CONSTANT VARCHAR2(100) := 'Generate_TaxesFromPO';
333 l_debug_info VARCHAR2(240);
334 l_return_status VARCHAR2(1);
335
336 CURSOR zlines is
337 SELECT
338 sl_zx.tax,
339 sl_zx.tax_line_id,
340 nvl(sl_zx.tax_amt_tax_curr,0) tax_amt_tax_curr, --BUG#8307904
341 nvl(sl_zx.rec_tax_amt_tax_curr,0) rec_tax_amt_tax_curr, --BUG#8307904
342 sl_zx.tax_currency_code,
343 sl_zx.tax_currency_conversion_type,
344 sl_zx.tax_currency_conversion_date,
345 sl_zx.tax_amt_included_flag,
346 nvl(sl_zx.trx_line_quantity,0) trx_line_quantity, --BUG#8307904
347 nvl(sl_zx.line_amt,0) line_amt, --BUG#8307904
348 sl_zx.trx_currency_code,
349 sl_zx.ship_line_id,
350 sl_zx.po_line_location_id,
351 sl_zx.sl_currency_code,
352 sl_zx.sl_currency_conversion_type,
353 sl_zx.sl_currency_conversion_date,
354 nvl(sl_zx.sl_txn_qty,0) sl_txn_qty, --BUG#8307904
355 nvl(sl_zx.sl_txn_unit_price,0) sl_txn_unit_price, --BUG#8307904
356 tl_assoc.inl_tax_line_id,
357 tl_assoc.inl_tax_line_num
358 FROM (SELECT
359 zl.tax,
360 zl.tax_line_id,
361 zl.tax_amt_tax_curr,
362 zl.rec_tax_amt_tax_curr,
363 zl.tax_currency_code,
364 zl.tax_currency_conversion_type,
365 zl.tax_currency_conversion_date,
366 zl.tax_amt_included_flag,
367 zl.trx_line_quantity,
368 zl.line_amt,
369 zl.trx_currency_code,
370 sl.ship_header_id,
371 sl.ship_line_source_id po_line_location_id,
372 sl.currency_code sl_currency_code,
373 sl.currency_conversion_type sl_currency_conversion_type,
374 sl.currency_conversion_date sl_currency_conversion_date,
375 sl.txn_qty sl_txn_qty,
376 sl.txn_unit_price sl_txn_unit_price,
377 sl.ship_line_id
378 FROM
379 inl_ship_lines sl,
380 zx_lines zl
381 WHERE sl.ship_header_id = p_ship_header_id
382 AND sl.ship_line_src_type_code = 'PO'
383 AND sl.ship_line_source_id = zl.trx_line_id
384 AND zl.application_id = 201
385 ) sl_zx
386 ,(SELECT
387 tl.tax_line_num inl_tax_line_num,
388 tl.tax_line_id inl_tax_line_id,
389 assoc.to_parent_table_id,
390 tl.source_parent_table_id
391 FROM inl_adj_tax_lines_v tl,
392 inl_associations assoc
393 WHERE assoc.from_parent_table_name = 'INL_TAX_LINES'
394 AND assoc.from_parent_table_id = tl.tax_line_id
395 AND assoc.to_parent_table_name = 'INL_SHIP_LINES'
396 AND tl.ship_header_id = p_ship_header_id
397 AND tl.source_parent_table_name = 'ZX_LINES'
398 ) tl_assoc
399 WHERE tl_assoc.source_parent_table_id(+) = sl_zx.tax_line_id
400 AND tl_assoc.to_parent_table_id(+) = sl_zx.ship_line_id
401 ;
402 zlines_rec zlines%ROWTYPE;
403 TYPE zlines_tbl_tp IS TABLE OF zlines%ROWTYPE INDEX BY BINARY_INTEGER;
404 zlines_tbl zlines_tbl_tp;
405 l_tax_amt_prorated NUMBER;
406 l_rec_tax_amt_prorated NUMBER;
407 BEGIN
408 -- Standard Beginning of Procedure/Function Logging
409 INL_LOGGING_PVT.Log_BeginProc (
410 p_module_name => g_module_name,
411 p_procedure_name => l_proc_name
412 );
413
414 -- Initialize API return status to success
415 x_return_status := FND_API.G_RET_STS_SUCCESS;
416
417 --Uses the zlines cursor
418 l_debug_info := 'Uses the zlines cursor ';
419 INL_LOGGING_PVT.Log_Statement (
420 p_module_name => g_module_name,
421 p_procedure_name => l_proc_name,
422 p_debug_info => l_debug_info
423 );
424
425 OPEN zlines;
426 FETCH zlines
427 BULK COLLECT INTO zlines_tbl;
428 CLOSE zlines;
429
430 IF ( NVL(zlines_tbl.COUNT,0) > 0) THEN
431 -- loop in all taxes of current shipment
432 FOR i IN zlines_tbl.FIRST..zlines_tbl.LAST LOOP
433 -- when eBTax recalculates the taxes the tax_line_id in zx_lines remains the same
434
435 p_tax_ln_tbl(i).tax_code := zlines_tbl(i).tax;
436 p_tax_ln_tbl(i).ship_header_id := p_ship_header_id;
437 p_tax_ln_tbl(i).source_parent_table_name := 'ZX_LINES';
438 p_tax_ln_tbl(i).source_parent_table_id := zlines_tbl(i).tax_line_id;
439 p_tax_ln_tbl(i).to_parent_table_name := 'INL_SHIP_LINES';
440 p_tax_ln_tbl(i).to_parent_table_id := zlines_tbl(i).ship_line_id;
441 p_tax_ln_tbl(i).currency_code := zlines_tbl(i).tax_currency_code;
442 p_tax_ln_tbl(i).currency_conversion_type := zlines_tbl(i).tax_currency_conversion_type;
443 p_tax_ln_tbl(i).currency_conversion_date := zlines_tbl(i).tax_currency_conversion_date;
444 p_tax_ln_tbl(i).tax_amt_included_flag := zlines_tbl(i).tax_amt_included_flag;
445
446 -- sometimes the shipment line doesn't receive a whole PO Line
447 -- in these cases a proration is necessary
448
449 l_tax_amt_prorated := zlines_tbl(i).tax_amt_tax_curr;
450 l_rec_tax_amt_prorated := zlines_tbl(i).rec_tax_amt_tax_curr;
451
452 l_debug_info := 'l_tax_amt_prorated';
453 INL_LOGGING_PVT.Log_Variable (
454 p_module_name => g_module_name,
455 p_procedure_name => l_proc_name,
456 p_var_name => l_debug_info,
457 p_var_value => l_tax_amt_prorated
458 );
459
460 l_debug_info := 'l_rec_tax_amt_prorated';
461 INL_LOGGING_PVT.Log_Variable (
462 p_module_name => g_module_name,
463 p_procedure_name => l_proc_name,
464 p_var_name => l_debug_info,
465 p_var_value => l_rec_tax_amt_prorated
466 );
467
468 prorate_TaxValues(
469 p_po_line_location_id => zlines_tbl(i).po_line_location_id,
470 p_sl_currency_code => zlines_tbl(i).sl_currency_code,
471 p_sl_currency_conversion_type => zlines_tbl(i).sl_currency_conversion_type,
472 p_sl_currency_conversion_date => zlines_tbl(i).sl_currency_conversion_date,
473 p_sl_txn_qty => zlines_tbl(i).sl_txn_qty,
474 p_sl_txn_unit_price => zlines_tbl(i).sl_txn_unit_price,
475 x_tax_amt => l_tax_amt_prorated,
476 x_rec_tax_amt => l_rec_tax_amt_prorated,
477 x_return_status => l_return_status
478 );
479 -- If any errors happen abort the process.
480 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
481 RAISE FND_API.G_EXC_ERROR;
482 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
483 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
484 END IF;
485
486
487 l_debug_info := 'l_tax_amt_prorated';
488 INL_LOGGING_PVT.Log_Variable (
489 p_module_name => g_module_name,
490 p_procedure_name => l_proc_name,
491 p_var_name => l_debug_info,
492 p_var_value => l_tax_amt_prorated
493 );
494
495 l_debug_info := 'l_rec_tax_amt_prorated';
496 INL_LOGGING_PVT.Log_Variable (
497 p_module_name => g_module_name,
498 p_procedure_name => l_proc_name,
499 p_var_name => l_debug_info,
500 p_var_value => l_rec_tax_amt_prorated
501 );
502
503 p_tax_ln_tbl(i).tax_amt := l_tax_amt_prorated;
504 p_tax_ln_tbl(i).nrec_tax_amt := l_tax_amt_prorated - l_rec_tax_amt_prorated;
505
506 END LOOP;
507 END IF;
508
509 -- Standard End of Procedure/Function Logging
510 INL_LOGGING_PVT.Log_EndProc (p_module_name => g_module_name,
511 p_procedure_name => l_proc_name);
512
513
514 EXCEPTION
515 WHEN FND_API.G_EXC_ERROR THEN
516 -- Standard Expected Error Logging
517 INL_LOGGING_PVT.Log_ExpecError (p_module_name => g_module_name,
518 p_procedure_name => l_proc_name);
519 x_return_status := FND_API.G_RET_STS_ERROR;
520 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
521 -- Standard Unexpected Error Logging
522 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
523 p_procedure_name => l_proc_name);
524 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
525 WHEN OTHERS THEN
526 -- Standard Unexpected Error Logging
527 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
528 p_procedure_name => l_proc_name);
529 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
530 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
531 FND_MSG_PUB.Add_Exc_Msg(g_pkg_name,l_proc_name);
532 END IF;
533 END Generate_TaxesFromPO;
534
535 -- API name : Generate_Taxes
536 -- Type : Private
537 -- Function : Generate Tax Lines automatically from a source for now
538 -- can be the PO or any other logic defined inside the Taxes Hook.
539 -- Pre-reqs : None
540 -- Parameters :
541 -- IN : p_api_version IN NUMBER Required
542 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API.G_FALSE
543 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
544 -- p_ship_header_id IN NUMBER Required
545 -- p_source IN VARCHAR2 Optional Default = FND_API.G_FALSE
546 --
547 -- OUT x_return_status OUT NOCOPY VARCHAR2
548 -- x_msg_count OUT NOCOPY NUMBER
549 -- x_msg_data OUT NOCOPY VARCHAR2
550 --
551 -- Version : Current version 1.0
552 --
553 -- Notes :
554 PROCEDURE Generate_Taxes(
555 p_api_version IN NUMBER,
556 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
557 p_commit IN VARCHAR2 := FND_API.G_FALSE,
558 p_ship_header_id IN NUMBER,
559 p_source IN VARCHAR2 := 'PO',
560 x_return_status OUT NOCOPY VARCHAR2,
561 x_msg_count OUT NOCOPY NUMBER,
562 x_msg_data OUT NOCOPY VARCHAR2
563 ) IS
564
565 l_api_name CONSTANT VARCHAR2(30) := 'Generate_Taxes';
566 l_api_version CONSTANT NUMBER := 1.0;
567 l_debug_info VARCHAR2(240);
568 l_return_status VARCHAR2(1);
569 l_override_default_processing BOOLEAN;
570 l_tax_line_id NUMBER;
571 l_tax_line_num NUMBER;
572
573 l_tax_ln_tbl INL_TAX_PVT.tax_ln_tbl;
574
575 -- group ln
576 l_ship_groups_tbl INL_TAX_PVT.sh_group_ln_tbl_tp;
577
578 -- ship ln
579 l_ship_lines_tbl INL_TAX_PVT.ship_ln_tbl_tp;
580
581 -- charge ln
582 l_charge_lines_tbl INL_TAX_PVT.charge_ln_tbl_tp;
583
584 BEGIN
585
586 -- Standard Beginning of Procedure/Function Logging
587 INL_LOGGING_PVT.Log_BeginProc (
588 p_module_name => g_module_name,
589 p_procedure_name => l_api_name
590 );
591
592 -- Standard Start of API savepoint
593 SAVEPOINT Generate_Taxes_PVT;
594
595 -- Initialize message list if p_init_msg_list is set to TRUE.
596 IF FND_API.to_Boolean( p_init_msg_list ) THEN
597 FND_MSG_PUB.initialize;
598 END IF;
599
600 -- Check for call compatibility.
601 IF NOT FND_API.Compatible_API_Call (
602 p_current_version_number => l_api_version,
603 p_caller_version_number => p_api_version,
604 p_api_name => l_api_name,
605 p_pkg_name => g_pkg_name)
606 THEN
607 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
608 END IF;
609
610 -- Initialize API return status to success
611 x_return_status := FND_API.G_RET_STS_SUCCESS;
612
613 l_debug_info := 'Step 1a: Delete data from previous tax Generation/Calculation';
614 -- logging message
615 INL_LOGGING_PVT.Log_Statement (
616 p_module_name => g_module_name,
617 p_procedure_name => l_api_name,
618 p_debug_info => l_debug_info
619 );
620 Delete_PreviousTaxLines (
621 p_ship_header_id => p_ship_header_id,
622 x_return_status => l_return_status
623 );
624 -- If any errors happen abort API.
625 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
626 RAISE FND_API.G_EXC_ERROR;
627 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
628 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
629 END IF;
630
631 -- Getting all Shipment Information to send to Hook
632 l_debug_info := 'Getting all Shipment Information to send to Hook';
633 INL_LOGGING_PVT.Log_Statement (
634 p_module_name => g_module_name,
635 p_procedure_name => l_api_name,
636 p_debug_info => l_debug_info);
637
638
639 l_debug_info := 'Getting Shipment Header Information.';
640 INL_LOGGING_PVT.Log_Statement (
641 p_module_name => g_module_name,
642 p_procedure_name => l_api_name,
643 p_debug_info => l_debug_info
644 );
645
646 OPEN Shipment_Header(p_ship_header_id);
647 FETCH Shipment_Header INTO l_ship_header_rec;
648 CLOSE Shipment_Header;
649
650 --Getting Shipment Line Group Information
651 l_debug_info := 'Getting Shipment Line Group Information.';
652 INL_LOGGING_PVT.Log_Statement (
653 p_module_name => g_module_name,
654 p_procedure_name => l_api_name,
655 p_debug_info => l_debug_info
656 );
657
658 SELECT *
659 BULK COLLECT INTO l_ship_groups_tbl
660 FROM inl_ship_line_groups lg
661 WHERE lg.ship_header_id = p_ship_header_id
662 order by ship_line_group_id;
663
664 l_debug_info := sql%rowcount||' records have been retrieved.';
665 INL_LOGGING_PVT.Log_Statement (
666 p_module_name => g_module_name,
667 p_procedure_name => l_api_name,
668 p_debug_info => l_debug_info
669 );
670
671 --Getting Shipment Line Information
672 l_debug_info := 'Getting Shipment Line Information.';
673 INL_LOGGING_PVT.Log_Statement (
674 p_module_name => g_module_name,
675 p_procedure_name => l_api_name,
676 p_debug_info => l_debug_info
677 );
678
679 SELECT *
680 BULK COLLECT INTO l_ship_lines_tbl
681 FROM inl_adj_ship_lines_v sl
682 WHERE sl.ship_header_id = p_ship_header_id
683 order by sl.ship_line_group_id, sl.ship_line_id;
684
685 l_debug_info := sql%rowcount||' records have been retrieved.';
686 INL_LOGGING_PVT.Log_Statement (
687 p_module_name => g_module_name,
688 p_procedure_name => l_api_name,
689 p_debug_info => l_debug_info
690 );
691
692 --Getting Charge Line Information
693 l_debug_info := 'Getting Charge Line Information.';
694 INL_LOGGING_PVT.Log_Statement (
695 p_module_name => g_module_name,
696 p_procedure_name => l_api_name,
697 p_debug_info => l_debug_info
698 );
699
700 OPEN charge_ln(p_ship_header_id);
701 FETCH charge_ln
702 BULK COLLECT INTO l_charge_lines_tbl
703 ;
704 CLOSE charge_ln;
705
706 l_debug_info := sql%rowcount||' records have been retrieved.';
707 INL_LOGGING_PVT.Log_Statement (
708 p_module_name => g_module_name,
709 p_procedure_name => l_api_name,
710 p_debug_info => l_debug_info
711 );
712
713 l_debug_info := ' Generating taxes from hook (inl_custom_pub.Get_Taxes).';
714 INL_LOGGING_PVT.Log_Statement (
715 p_module_name => g_module_name,
716 p_procedure_name => l_api_name,
717 p_debug_info => l_debug_info
718 );
719
720 inl_custom_pub.Get_Taxes(
721 p_ship_header_rec => l_ship_header_rec,
722 p_ship_ln_groups_tbl => l_ship_groups_tbl,
723 p_ship_lines_tbl => l_ship_lines_tbl,
724 p_charge_lines_tbl => l_charge_lines_tbl,
725 x_tax_ln_tbl => l_tax_ln_tbl,
726 x_override_default_processing => l_override_default_processing,
727 x_return_status => l_return_status
728 );
729
730 -- If any errors happen abort the process.
731 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
732 RAISE FND_API.G_EXC_ERROR;
733 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
734 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
735 END IF;
736
737 IF NOT (l_override_default_processing) THEN
738 l_debug_info := 'Calls the rotine to generate tax according parameter: ';
739 INL_LOGGING_PVT.Log_Statement (
740 p_module_name => g_module_name,
741 p_procedure_name=> l_api_name,
742 p_debug_info => l_debug_info
743 );
744 IF p_source = 'PO' THEN
745 Generate_TaxesFromPO(
746 p_ship_header_id => p_ship_header_id,
747 p_tax_ln_tbl => l_tax_ln_tbl,
748 x_return_status => l_return_status
749 );
750 -- If any errors happen abort the process.
751 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
752 RAISE FND_API.G_EXC_ERROR;
753 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
754 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
755 END IF;
756 END IF;
757 END IF;
758
759 IF ( NVL(l_tax_ln_tbl.COUNT,0) > 0) THEN
760 -- Persists the generated taxes
761 l_debug_info := 'Persists the generated taxes';
762 INL_LOGGING_PVT.Log_Statement (
763 p_module_name => g_module_name,
764 p_procedure_name => l_api_name,
765 p_debug_info => l_debug_info
766 );
767
768 FOR i IN l_tax_ln_tbl.FIRST..l_tax_ln_tbl.LAST LOOP
769 --Insert IN INL_TAX_LINES getting ID from sequence
770 l_debug_info := 'Insert IN INL_TAX_LINES getting ID from sequence';
771 INL_LOGGING_PVT.Log_Statement (
772 p_module_name => g_module_name,
773 p_procedure_name => l_api_name,
774 p_debug_info => l_debug_info
775 );
776
777 SELECT inl_tax_lines_s.NEXTVAL
778 INTO l_tax_line_id
779 FROM DUAL;
780
781 SELECT NVL(MAX(tl.tax_line_num),0)+1
782 INTO l_tax_line_num
783 FROM inl_tax_lines tl
784 WHERE tl.ship_header_id = l_tax_ln_tbl(i).ship_header_id
785 ;
786
787 --Inserting record in INL_TAX_LINES
788 l_debug_info := 'Inserting record in INL_TAX_LINES';
789 INL_LOGGING_PVT.Log_Statement (
790 p_module_name => g_module_name,
791 p_procedure_name => l_api_name,
792 p_debug_info => l_debug_info
793 );
794
795 INSERT
796 INTO inl_tax_lines (
797 tax_line_id , /* 01 */
798 tax_line_num , /* 02 */
799 tax_code , /* 03 */
800 ship_header_id , /* 04 */
801 adjustment_num , /* 06 */
802 source_parent_table_name, /* 08 */
803 source_parent_table_id , /* 09 */
804 tax_amt , /* 10 */
805 nrec_tax_amt , /* 11 */
806 currency_code , /* 12 */
807 currency_conversion_type, /* 13 */
808 currency_conversion_date, /* 14 */
809 currency_conversion_rate, /* 15 */
810 tax_amt_included_flag , /* 16 */
811 created_by , /* 17 */
812 creation_date , /* 18 */
813 last_updated_by , /* 19 */
814 last_update_date , /* 20 */
815 last_update_login /* 21 */
816 )
817 VALUES (
818 l_tax_line_id , /* 01 */
819 l_tax_line_num , /* 02 */
820 l_tax_ln_tbl(i).tax_code , /* 03 */
821 l_tax_ln_tbl(i).ship_header_id , /* 04 */
822 0 , /* 06 */
823 l_tax_ln_tbl(i).source_parent_table_name, /* 08 */
824 l_tax_ln_tbl(i).source_parent_table_id , /* 09 */
825 l_tax_ln_tbl(i).tax_amt , /* 10 */
826 l_tax_ln_tbl(i).nrec_tax_amt , /* 11 */
827 l_tax_ln_tbl(i).currency_code , /* 12 */
828 l_tax_ln_tbl(i).currency_conversion_type, /* 13 */
829 l_tax_ln_tbl(i).currency_conversion_date, /* 14 */
830 l_tax_ln_tbl(i).currency_conversion_rate, /* 15 */
831 l_tax_ln_tbl(i).tax_amt_included_flag , /* 16 */
832 fnd_global.user_id , /* 17 */
833 SYSDATE , /* 18 */
834 fnd_global.user_id , /* 19 */
835 SYSDATE , /* 20 */
836 fnd_global.login_id /* 21 */
837 );
838 --Inserting record in INL_ASSOCIATIONS
839 l_debug_info := 'Inserting record in INL_ASSOCIATIONS';
840 INL_LOGGING_PVT.Log_Statement (
841 p_module_name => g_module_name,
842 p_procedure_name => l_api_name,
843 p_debug_info => l_debug_info
844 );
845
846 INSERT
847 INTO inl_associations (
848 association_id , /* 01 */
849 ship_header_id , /* 02 */
850 from_parent_table_name , /* 03 */
851 from_parent_table_id , /* 04 */
852 to_parent_table_name , /* 05 */
853 to_parent_table_id , /* 06 */
854 allocation_basis , /* 07 */
855 allocation_uom_code , /* 08 */
856 created_by , /* 09 */
857 creation_date , /* 10 */
858 last_updated_by , /* 11 */
859 last_update_date , /* 12 */
860 last_update_login /* 13 */
861 )
862 VALUES (
863 inl_associations_s.NEXTVAL , /* 01 */
864 l_tax_ln_tbl(i).ship_header_id , /* 02 */
865 'INL_TAX_LINES' , /* 03 */
866 l_tax_line_id , /* 04 */
867 l_tax_ln_tbl(i).to_parent_table_name , /* 05 */
868 l_tax_ln_tbl(i).to_parent_table_id , /* 06 */
869 'VALUE' , /* 07 */
870 null , /* 08 */
871 fnd_global.user_id , /* 09 */
872 SYSDATE , /* 10 */
873 fnd_global.user_id , /* 11 */
874 SYSDATE , /* 12 */
875 fnd_global.login_id /* 13 */
876 );
877 END LOOP;
878 END IF;
879
880 -- Standard check of p_commit.
881 IF FND_API.To_Boolean( p_commit ) THEN
882 COMMIT WORK;
883 END IF;
884
885 -- Standard call to get message count and if count is 1, get message info.
886 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.g_false,
887 p_count => x_msg_count,
888 p_data => x_msg_data);
889
890 -- Standard End of Procedure/Function Logging
891 INL_LOGGING_PVT.Log_EndProc (p_module_name => g_module_name,
892 p_procedure_name => l_api_name);
893
894 EXCEPTION
895 WHEN FND_API.G_EXC_ERROR THEN
896 -- Standard Expected Error Logging
897 INL_LOGGING_PVT.Log_ExpecError (p_module_name => g_module_name,
898 p_procedure_name => l_api_name);
899 ROLLBACK TO Generate_Taxes_PVT;
900 x_return_status := FND_API.G_RET_STS_ERROR;
901 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.g_false,
902 p_count => x_msg_count,
903 p_data => x_msg_data);
904 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
905 -- Standard Unexpected Error Logging
906 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
907 p_procedure_name => l_api_name);
908 ROLLBACK TO Generate_Taxes_PVT;
909 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
910 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.g_false,
911 p_count => x_msg_count,
912 p_data => x_msg_data);
913 WHEN OTHERS THEN
914 -- Standard Unexpected Error Logging
915 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
916 p_procedure_name => l_api_name);
917 ROLLBACK TO Generate_Taxes_PVT;
918 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
919 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
920 THEN
921 FND_MSG_PUB.Add_Exc_Msg(p_pkg_name => g_pkg_name,
922 p_procedure_name => l_api_name);
923 END IF;
924 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.g_false,
925 p_count => x_msg_count,
926 p_data => x_msg_data);
927 END Generate_Taxes;
928
929 --==============================================================================
930 --==============================================================================
931 --==============================================================================
932 -- Utility name: Get_Event_Class_Code
933 --
934 -- Type : Private
935 --
936 -- Function : It will get the event class code required to call
937 -- the eTax services based on the category code of the shipment type.
938 -- These event class code is LCM specific.
939 -- eTax will convert this event class code to the tax class
940 -- code used by eTax.
941 --
942 -- Pre-reqs : None
943 --
944 -- Parameters :
945 -- IN : p_ship_type_id IN NUMBER,
946 --
947 -- OUT : x_return_status OUT NOCOPY VARCHAR2,
948 -- x_event_class_code OUT NOCOPY VARCHAR2)
949 --
950 -- Version : Current version 1.0
951 --
952 -- Notes :
953 PROCEDURE Get_Event_Class_Code(p_ship_type_id IN NUMBER,
954 x_return_status OUT NOCOPY VARCHAR2,
955 x_event_class_code OUT NOCOPY VARCHAR2)
956 IS
957 l_function_name CONSTANT VARCHAR2(100) := 'Get_Event_Class_Code ';
958 l_debug_info VARCHAR2(240);
959 l_category_code VARCHAR2(100);
960
961 BEGIN
962 -- logging message
963 INL_LOGGING_PVT.Log_BeginProc (p_module_name => g_module_name,
964 p_procedure_name => l_function_name);
965
966 x_return_status := FND_API.G_RET_STS_SUCCESS;
967
968 -- get category to derivate Event_Class_Code
969 x_Event_Class_Code := 'ARRIVALS';
970 -- logging message
971 INL_LOGGING_PVT.Log_EndProc (p_module_name => g_module_name,
972 p_procedure_name => l_function_name);
973 EXCEPTION
974 WHEN FND_API.G_EXC_ERROR THEN
975 -- logging message
976 INL_LOGGING_PVT.Log_ExpecError (p_module_name => g_module_name,
977 p_procedure_name => l_function_name);
978 x_return_status := FND_API.G_RET_STS_ERROR;
979 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
980 -- logging message
981 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
982 p_procedure_name => l_function_name);
983 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
984 WHEN OTHERS THEN
985 -- logging message
986 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
987 p_procedure_name => l_function_name);
988 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
989 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
990 THEN
991 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,l_function_name);
992 END IF;
993 END Get_Event_Class_Code;
994
995
996 -- Utility name: Get_Po_Info
997 --
998 -- Type : Private
999 --
1000 -- Function : It get the Po Info.
1001 --
1002 -- Pre-reqs : None
1003 --
1004 -- Parameters :
1005 -- IN : p_po_line_location_id IN NUMBER,
1006 --
1007 -- OUT : x_return_status OUT NOCOPY VARCHAR2,
1008 -- x_po_header_id OUT NOCOPY NUMBER,
1009 -- x_po_header_curr_conv_rate OUT NOCOPY NUMBER
1010 --
1011 -- Version : Current version 1.0
1012 --
1013 -- Notes :
1014
1015 PROCEDURE Get_Po_Info(p_po_line_location_id IN NUMBER,
1016 x_return_status OUT NOCOPY VARCHAR2,
1017 x_po_header_id OUT NOCOPY NUMBER,
1018 x_po_header_curr_conv_rate OUT NOCOPY NUMBER) IS
1019 l_debug_info VARCHAR2(240);
1020 l_function_name CONSTANT VARCHAR2(100) := 'Get_Po_Info ';
1021 BEGIN
1022 -- logging message
1023 INL_LOGGING_PVT.Log_BeginProc (p_module_name => g_module_name,
1024 p_procedure_name => l_function_name);
1025
1026 x_return_status := FND_API.G_RET_STS_SUCCESS;
1027 -- get PO_Header_id
1028 SELECT pll.po_header_id, nvl(ph.rate ,1)
1029 INTO x_po_header_id, x_po_header_curr_conv_rate
1030 FROM po_line_locations pll, po_headers ph
1031 WHERE pll.line_location_id = P_Po_Line_Location_Id
1032 AND pll.po_header_id = ph.po_header_id
1033 AND rownum = 1;
1034
1035 -- logging message
1036 INL_LOGGING_PVT.Log_EndProc (p_module_name => g_module_name,
1037 p_procedure_name => l_function_name);
1038
1039 EXCEPTION
1040 WHEN FND_API.G_EXC_ERROR THEN
1041 -- logging message
1042 INL_LOGGING_PVT.Log_ExpecError (p_module_name => g_module_name,
1043 p_procedure_name => l_function_name);
1044 x_return_status := FND_API.G_RET_STS_ERROR;
1045 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1046 -- logging message
1047 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
1048 p_procedure_name => l_function_name);
1049 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1050 WHEN OTHERS THEN
1051 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
1052 p_procedure_name => l_function_name);
1053 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1054 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1055 THEN
1056 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,l_function_name);
1057 END IF;
1058 END Get_Po_Info;
1059
1060 -- Utility name: Populate_Headers_GT
1061 --
1062 -- Type : Private
1063 --
1064 -- Function : It populate the temporary zx table: zx_trx_headers_gt
1065 -- but it remove any record of the same ship_Header_id before
1066 --
1067 -- Pre-reqs : None
1068 --
1069 -- Parameters :
1070 -- IN : p_etax_already_called_flag IN VARCHAR2
1071 -- p_event_class_code IN VARCHAR2
1072 --
1073 -- OUT x_event_type_code OUT NOCOPY VARCHAR2,
1074 -- x_return_status OUT NOCOPY VARCHAR2
1075 --
1076 -- Version : Current version 1.0
1077 --
1078 -- Notes :
1079 PROCEDURE Populate_Headers_GT(p_etax_already_called_flag IN VARCHAR2,
1080 p_event_class_code IN VARCHAR2,
1081 x_event_type_code OUT NOCOPY VARCHAR2,
1082 x_return_status OUT NOCOPY VARCHAR2)IS
1083
1084 l_function_name CONSTANT VARCHAR2(100) := 'Populate_Headers_GT ';
1085 l_debug_info VARCHAR2(240);
1086 l_application_id NUMBER;
1087
1088 -- This flag is always N except when the calculate service is called for
1089 -- quote for the recurring invoices and distributions sets.
1090 l_quote_flag VARCHAR2(1);
1091
1092 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
1093 l_ship_to_organization_id NUMBER;
1094 l_ledger_id NUMBER;
1095 l_tax_event_type_code VARCHAR2(30);
1096 l_doc_level_recalc_flag VARCHAR2(1):='Y';
1097 l_step VARCHAR2(10);
1098 BEGIN
1099 -- logging message
1100 INL_LOGGING_PVT.Log_BeginProc (p_module_name => g_module_name,
1101 p_procedure_name => l_function_name);
1102
1103 x_return_status := FND_API.G_RET_STS_SUCCESS;
1104
1105 -------------------------------------------------------------------
1106 l_debug_info := 'Step 3: Populate product specific attributes';
1107 -------------------------------------------------------------------
1108 l_application_id := 9004; -- Landed Cost Management
1109 -------------------------------------------------------------------
1110 l_debug_info := 'Step 6: Get Ship to party id';
1111 -------------------------------------------------------------------
1112 -- logging message
1113 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1114 p_procedure_name => l_function_name,
1115 p_debug_info => l_debug_info);
1116
1117 l_ship_to_organization_id := l_ship_header_rec.organization_id;
1118
1119 -------------------------------------------------------------------
1120 l_debug_info := 'Step 7: Get ledger_id. l_ship_header_rec.inv_org_id: '||l_ship_header_rec.organization_id;
1121 -------------------------------------------------------------------
1122 -- logging message
1123 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1124 p_procedure_name => l_function_name,
1125 p_debug_info => l_debug_info);
1126 l_step:='02';
1127 SELECT ood.set_of_books_id
1128 INTO l_ledger_id
1129 FROM org_organization_definitions ood
1130 WHERE ood.organization_id = l_ship_header_rec.organization_id
1131 AND rownum = 1;
1132 l_step:='02a';
1133 -------------------------------------------------------------------
1134 l_debug_info := 'Step 7a: Get tax_event_type_code';
1135 -- logging message
1136 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1137 p_procedure_name => l_function_name,
1138 p_debug_info => l_debug_info);
1139 -------------------------------------------------------------------
1140 IF p_etax_already_called_flag = 'Y' THEN
1141 l_tax_event_type_code := 'UPDATE';
1142 x_event_type_code := 'ARRIVAL UPDATED';
1143 ELSE
1144 l_tax_event_type_code := 'CREATE';
1145 x_event_type_code := 'ARRIVAL CREATED';
1146 END IF;
1147 l_step:='03';
1148 -------------------------------------------------------------------
1149 l_debug_info := 'Step 8: Populate zx_trx_headers_gt';
1150 -------------------------------------------------------------------
1151 IF (l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1152 -- logging message
1153 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1154 p_procedure_name => l_function_name,
1155 p_debug_info => l_debug_info);
1156 -- Delete records of the current shipment
1157 DELETE FROM zx_trx_headers_gt
1158 WHERE trx_id=l_ship_header_rec.ship_header_id;
1159 -- Insert records
1160 l_step:='04';
1161
1162 INSERT INTO zx_trx_headers_gt(
1163 /*01*/ internal_organization_id,
1164 /*02*/ internal_org_location_id,
1165 /*03*/ application_id,
1166 /*04*/ entity_code,
1167 /*05*/ event_class_code,
1168 /*06*/ event_type_code,
1169 /*07*/ trx_id,
1170 /*08*/ hdr_trx_user_key1,
1171 /*09*/ hdr_trx_user_key2,
1172 /*10*/ hdr_trx_user_key3,
1173 /*11*/ hdr_trx_user_key4,
1174 /*12*/ hdr_trx_user_key5,
1175 /*13*/ hdr_trx_user_key6,
1176 /*14*/ trx_date,
1177 /*15*/ trx_doc_revision,
1178 /*16*/ ledger_id,
1179 /*17*/ trx_currency_code,
1180 /*18*/ currency_conversion_date,
1181 /*19*/ currency_conversion_rate,
1182 /*20*/ currency_conversion_type,
1183 /*21*/ minimum_accountable_unit,
1184 /*22*/ precision,
1185 /*23*/ legal_entity_id,
1186 /*24*/ rounding_ship_to_party_id,
1187 /*25*/ rounding_ship_from_party_id,
1188 /*26*/ rounding_bill_to_party_id,
1189 /*27*/ rounding_bill_from_party_id,
1190 /*28*/ rndg_ship_to_party_site_id,
1191 /*29*/ rndg_ship_from_party_site_id,
1192 /*30*/ rndg_bill_to_party_site_id,
1193 /*31*/ rndg_bill_from_party_site_id,
1194 /*32*/ establishment_id,
1195 /*33*/ receivables_trx_type_id,
1196 /*34*/ related_doc_application_id,
1197 /*35*/ related_doc_entity_code,
1198 /*36*/ related_doc_event_class_code,
1199 /*37*/ related_doc_trx_id,
1200 /*38*/ rel_doc_hdr_trx_user_key1,
1201 /*39*/ rel_doc_hdr_trx_user_key2,
1202 /*40*/ rel_doc_hdr_trx_user_key3,
1203 /*41*/ rel_doc_hdr_trx_user_key4,
1204 /*42*/ rel_doc_hdr_trx_user_key5,
1205 /*43*/ rel_doc_hdr_trx_user_key6,
1206 /*44*/ related_doc_number,
1207 /*45*/ related_doc_date,
1208 /*46*/ default_taxation_country,
1209 /*47*/ quote_flag,
1210 /*48*/ ctrl_total_hdr_tx_amt,
1211 /*49*/ trx_number,
1212 /*50*/ trx_description,
1213 /*51*/ trx_communicated_date,
1214 /*52*/ batch_source_id,
1215 /*53*/ batch_source_name,
1216 /*54*/ doc_seq_id,
1217 /*55*/ doc_seq_name,
1218 /*56*/ doc_seq_value,
1219 /*57*/ trx_due_date,
1220 /*58*/ trx_type_description,
1221 /*59*/ document_sub_type,
1222 /*60*/ supplier_tax_invoice_number,
1223 /*61*/ supplier_tax_invoice_date ,
1224 /*62*/ supplier_exchange_rate,
1225 /*63*/ tax_invoice_date,
1226 /*64*/ tax_invoice_number,
1227 /*65*/ tax_event_class_code,
1228 /*66*/ tax_event_type_code,
1229 /*67*/ doc_event_status,
1230 /*68*/ rdng_ship_to_pty_tx_prof_id,
1231 /*69*/ rdng_ship_from_pty_tx_prof_id,
1232 /*70*/ rdng_bill_to_pty_tx_prof_id,
1233 /*71*/ rdng_bill_from_pty_tx_prof_id,
1234 /*72*/ rdng_ship_to_pty_tx_p_st_id,
1235 /*73*/ rdng_ship_from_pty_tx_p_st_id,
1236 /*74*/ rdng_bill_to_pty_tx_p_st_id,
1237 /*75*/ rdng_bill_from_pty_tx_p_st_id,
1238 /*76*/ bill_third_pty_acct_id,
1239 /*77*/ bill_third_pty_acct_site_id,
1240 /*78*/ ship_third_pty_acct_id,
1241 /*79*/ ship_third_pty_acct_site_id,
1242 /*80*/ doc_level_recalc_flag
1243 )
1244 VALUES (
1245 /*01*/ l_ship_header_rec.organization_id, --internal_organization_id
1246 /*02*/ l_ship_header_rec.location_id, --internal_org_location_id
1247 /*03*/ l_application_id, --application_id
1248 /*04*/ G_ENTITY_CODE, --entity_code
1249 /*05*/ p_event_class_code, --event_class_code
1250 /*06*/ x_event_type_code, --event_type_code
1251 /*07*/ l_ship_header_rec.ship_header_id, --trx_id
1252 /*08*/ NULL, --hdr_trx_user_key1
1253 /*09*/ NULL, --hdr_trx_user_key2
1254 /*10*/ NULL, --hdr_trx_user_key3
1255 /*11*/ NULL, --hdr_trx_user_key4
1256 /*12*/ NULL, --hdr_trx_user_key5
1257 /*13*/ NULL , --hdr_trx_user_key6
1258 /*14*/ l_ship_header_rec.ship_date, --trx_date
1259 /*15*/ NULL, --trx_doc_revision
1260 /*16*/ l_ledger_id, --ledger_id
1261 /*17*/ null, -- 07/2007 Currency columns was transfer to lines l_ship_header_rec.CURRENCY_CODE,
1262 /*18*/ null, -- l_ship_header_rec.CURRENCY_CONVERSION_DATE,
1263 /*19*/ null, -- l_ship_header_rec.CURRENCY_CONVERSION_RATE,
1264 /*20*/ null, -- l_ship_header_rec.CURRENCY_CONVERSION_TYPE,
1265 /*21*/ null, -- l_minimum_accountable_unit,
1266 /*22*/ null, -- l_precision,
1267 /*23*/ l_ship_header_rec.legal_entity_id, --legal_entity_id
1268 /*24*/ l_ship_to_organization_id, --rounding_ship_to_party_id
1269 /*25*/ NULL, --rounding_ship_from_party_id
1270 /*26*/ NULL, --rounding_bill_to_party_id
1271 /*27*/ NULL, --rounding_bill_from_party_id
1272 /*28*/ NULL, --rndg_ship_to_party_site_id
1273 /*29*/ NULL, --rndg_ship_from_party_site_id
1274 /*30*/ NULL, --rndg_bill_to_party_site_id
1275 /*31*/ NULL, --rndg_bill_from_party_site_id
1276 /*32*/ NULL, --establishment_id
1277 /*33*/ NULL, --receivables_trx_type_id
1278 /*34*/ NULL, --related_doc_application_id
1279 /*35*/ NULL, --related_doc_entity_code
1280 /*36*/ NULL, --related_doc_event_class_code
1281 /*37*/ NULL, --related_doc_trx_id
1282 /*38*/ NULL, --rel_doc_hdr_trx_user_key1
1283 /*39*/ NULL, --rel_doc_hdr_trx_user_key2
1284 /*40*/ NULL, --rel_doc_hdr_trx_user_key3
1285 /*41*/ NULL, --rel_doc_hdr_trx_user_key4
1286 /*42*/ NULL, --rel_doc_hdr_trx_user_key5
1287 /*43*/ NULL, --rel_doc_hdr_trx_user_key6
1288 /*44*/ NULL, --related_doc_number
1289 /*45*/ NULL, --related_doc_date
1290 /*46*/ l_ship_header_rec.taxation_country, --default_taxation_country
1291 /*47*/ l_quote_flag, --quote_flag
1292 /*48*/ NULL, --ctrl_total_hdr_tx_amt
1293 /*49*/ l_ship_header_rec.ship_num, --trx_number
1294 /*50*/ NULL, --'INL_SHIPMENT', --trx_description
1295 /*51*/ NULL, --trx_communicated_date
1296 /*52*/ NULL, --batch_source_id
1297 /*53*/ NULL, --batch_source_name
1298 /*54*/ NULL, --doc_seq_id
1299 /*55*/ NULL, --doc_seq_name
1300 /*56*/ NULL, --doc_seq_value
1301 /*57*/ NULL, --trx_due_date
1302 /*58*/ NULL, --trx_type_description
1303 /*59*/ l_ship_header_rec.document_sub_type, --document_sub_type
1304 /*60*/ NULL, --supplier_tax_invoice_number
1305 /*61*/ NULL, --supplier_tax_invoice_date
1306 /*62*/ NULL, --supplier_exchange_rate
1307 /*63*/ NULL, --tax_invoice_date
1308 /*64*/ NULL, --tax_invoice_number
1309 /*65*/ NULL, --tax_event_class_code
1310 /*66*/ l_tax_event_type_code, --tax_event_type_code
1311 /*67*/ NULL, --doc_event_status
1312 /*68*/ NULL, --rdng_ship_to_pty_tx_prof_id
1313 /*69*/ NULL, --rdng_ship_from_pty_tx_prof_id
1314 /*70*/ NULL, --rdng_bill_to_pty_tx_prof_id
1315 /*71*/ NULL, --rdng_bill_from_pty_tx_prof_id
1316 /*72*/ NULL, --rdng_ship_to_pty_tx_p_st_id
1317 /*73*/ NULL, --rdng_ship_from_pty_tx_p_st_id
1318 /*74*/ NULL, --rdng_bill_to_pty_tx_p_st_id
1319 /*75*/ NULL, --rdng_bill_from_pty_tx_p_st_id
1320 /*76*/ NULL, --bill_third_pty_acct_id
1321 /*77*/ NULL, --bill_third_pty_acct_site_id
1322 /*78*/ NULL, --ship_third_pty_acct_id
1323 /*79*/ NULL, --ship_third_pty_acct_site_id
1324 /*80*/ l_doc_level_recalc_flag
1325 );
1326 l_step:='05';
1327 END IF;
1328 -- logging message
1329 INL_LOGGING_PVT.Log_EndProc (p_module_name => g_module_name,
1330 p_procedure_name => l_function_name);
1331
1332 EXCEPTION
1333 WHEN FND_API.G_EXC_ERROR THEN
1334 -- logging message
1335 INL_LOGGING_PVT.Log_ExpecError (p_module_name => g_module_name,
1336 p_procedure_name => l_function_name||l_step);
1337 x_return_status := FND_API.G_RET_STS_ERROR;
1338 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1339 -- logging message
1340 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
1341 p_procedure_name => l_function_name||l_step);
1342 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1343 WHEN OTHERS THEN
1344 -- logging message
1345 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
1346 p_procedure_name => l_function_name||l_step);
1347 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1348 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1349 THEN
1350 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,l_function_name);
1351 END IF;
1352
1353 END Populate_Headers_GT;
1354
1355 -- Utility name: Populate_Lines_GT
1356 --
1357 -- Type : Private
1358 --
1359 -- Function : It populate zx_transaction_lines_gt. The records of this table will be processed for
1360 -- zx_api_pub.calculate_tax procedure to generate taxes (zx_lines)
1361 --
1362 -- Pre-reqs : None
1363 --
1364 -- Parameters :
1365 -- IN : p_event_class_code IN VARCHAR2,
1366 -- p_line_number IN NUMBER DEFAULT NULL,
1367 --
1368 -- OUT : x_return_status OUT NOCOPY VARCHAR2
1369 --
1370 -- Version : Current version 1.0
1371 --
1372 -- Notes :
1373 PROCEDURE Populate_Lines_GT(p_event_class_code IN VARCHAR2,
1374 p_line_number IN NUMBER DEFAULT NULL,
1375 x_return_status OUT NOCOPY VARCHAR2)
1376 IS
1377 l_function_name CONSTANT VARCHAR2(100) := 'Populate_Lines_GT ';
1378 l_debug_info VARCHAR2(240);
1379
1380 -- This structure to populate all the lines information previous to insert
1381 -- in eTax global temporary table.
1382 TYPE Trans_Lines_Tab_Type IS TABLE OF zx_transaction_lines_gt%ROWTYPE;
1383 trans_lines Trans_Lines_Tab_Type := Trans_Lines_Tab_Type();
1384 l_ctrl_hdr_tx_appl_flag VARCHAR2(1);
1385 l_line_level_action VARCHAR2(30);
1386 l_line_class VARCHAR2(30);
1387 l_product_org_id NUMBER :=l_ship_header_rec.organization_id;
1388 l_bill_to_location_id NUMBER;
1389 -- This variables for PO doc info
1390 l_ref_doc_application_id NUMBER;
1391 l_ref_doc_entity_code VARCHAR2(30);
1392 l_ref_doc_event_class_code VARCHAR2(30);
1393 l_ref_doc_line_quantity NUMBER;
1394 l_po_header_curr_conv_rate NUMBER;
1395 l_ref_doc_trx_level_type VARCHAR2(30);
1396 l_ref_doc_line_id NUMBER;
1397 l_ref_doc_trx_id NUMBER;
1398 l_line_amt_includes_tax_flag VARCHAR2(1);
1399 l_line_amount NUMBER;
1400 l_fob_point VARCHAR2(30);
1401 l_ship_from_location_id NUMBER;
1402 l_dflt_tax_class_code VARCHAR2(30);
1403 l_allow_tax_code_override VARCHAR2(10);
1404 l_ship_line_type_code VARCHAR2(30);
1405 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
1406 l_to_parent_table_name VARCHAR2(30);
1407 l_to_parent_table_id NUMBER;
1408 l_precision NUMBER(1);
1409 l_minimum_accountable_unit NUMBER;
1410
1411 BEGIN
1412 -- logging message
1413 INL_LOGGING_PVT.Log_BeginProc (p_module_name => g_module_name,
1414 p_procedure_name => l_function_name);
1415
1416 x_return_status := FND_API.G_RET_STS_SUCCESS;
1417 -----------------------------------------------------------------
1418 l_debug_info := 'IN Populating shipment lines collection';
1419 -- logging message
1420 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1421 p_procedure_name => l_function_name,
1422 p_debug_info => l_debug_info);
1423 -----------------------------------------------------------------
1424 l_debug_info := 'Step 1: Get l_bill_to_location_id for org_id';
1425 -- logging message
1426 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1427 p_procedure_name => l_function_name,
1428 p_debug_info => l_debug_info);
1429 ----------------------------------------------------------------------
1430 -- if is a dispatch the location is the same from ship from in a Arrival
1431 -- else it is null
1432 ----------------------------------------------------------------------
1433 l_debug_info := 'Step 2: Go through taxable lines'||' l_ship_line_list.COUNT: '||l_ship_line_list.COUNT;
1434 -- logging message
1435 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1436 p_procedure_name => l_function_name,
1437 p_debug_info => l_debug_info);
1438 ----------------------------------------------------------------------
1439 IF ( l_ship_line_list.COUNT > 0) THEN
1440 -- For non-tax only lines
1441 trans_lines.EXTEND(l_ship_line_list.COUNT);
1442
1443 -- loop in all lines of current shipment
1444 FOR i IN l_ship_line_list.FIRST..l_ship_line_list.LAST LOOP
1445 /* 10/07/07 Currency columns was transfer to lines */
1446 -------------------------------------------------------------------
1447 l_debug_info := 'Step 3: Get transaction line currency details';
1448 -------------------------------------------------------------------
1449 IF (l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1450 BEGIN
1451 SELECT NVL(precision, 0), NVL(minimum_accountable_unit,(1/power(10,precision)))
1452 INTO l_precision, l_minimum_accountable_unit
1453 FROM fnd_currencies
1454 WHERE currency_code = l_ship_line_list(i).currency_code;
1455 EXCEPTION
1456 WHEN OTHERS THEN
1457 IF (SQLCODE <> -20001) THEN
1458 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1459 -- logging message
1460 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
1461 p_procedure_name => l_function_name);
1462 END IF;
1463 APP_EXCEPTION.RAISE_EXCEPTION;
1464 END;
1465 END IF;
1466 -- For now only ARRIVALS are treaded
1467 IF P_Event_Class_Code = 'ARRIVALS'
1468 then
1469
1470 IF l_ship_line_list(i).ship_to_organization_id IS NULL THEN
1471 trans_lines(i).ship_to_party_id := l_ship_header_rec.organization_id;
1472 ELSE
1473 trans_lines(i).ship_to_party_id := l_ship_line_list(i).ship_to_organization_id;
1474 END IF;
1475
1476 IF l_ship_line_list(i).ship_from_party_id IS NULL THEN
1477 trans_lines(i).ship_from_party_id := l_ship_line_list(i).party_id;
1478 ELSE
1479 trans_lines(i).ship_from_party_id := l_ship_line_list(i).ship_from_party_id;
1480 END IF;
1481 IF l_ship_line_list(i).ship_from_party_site_id IS NULL THEN
1482 trans_lines(i).ship_from_party_site_id := l_ship_line_list(i).party_site_id;
1483 ELSE
1484 trans_lines(i).ship_from_party_site_id := l_ship_line_list(i).ship_from_party_site_id;
1485 END IF;
1486 IF l_ship_line_list(i).ship_to_location_id IS NULL THEN
1487 trans_lines(i).ship_to_location_id := l_ship_header_rec.location_id;
1488 ELSE
1489 trans_lines(i).ship_to_location_id := l_ship_line_list(i).ship_to_location_id;
1490 END IF;
1491 trans_lines(i).ship_from_location_id := l_ship_from_location_id;
1492 ELSE
1493 trans_lines(i).ship_to_party_id := l_ship_line_list(i).ship_to_organization_id;
1494 trans_lines(i).ship_from_party_id := l_ship_line_list(i).ship_from_party_id;
1495 trans_lines(i).ship_from_party_site_id := l_ship_line_list(i).ship_from_party_site_id;
1496 trans_lines(i).ship_to_location_id := l_ship_line_list(i).ship_to_location_id;
1497 END IF;
1498 ----------------------------------------------------------------------
1499 l_debug_info := 'Step 6: Get fob_lookup_code from po_vendor_sites';
1500 -- logging message
1501 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1502 p_procedure_name => l_function_name,
1503 p_debug_info => l_debug_info);
1504 ----------------------------------------------------------------------
1505 BEGIN
1506 SELECT fob_lookup_code -- From lookup FOB
1507 INTO l_fob_point
1508 FROM po_vendor_sites
1509 WHERE party_site_id = l_ship_line_list(i).party_site_id
1510 AND rownum = 1;
1511 EXCEPTION
1512 WHEN no_data_found THEN
1513 l_fob_point := null;
1514 END;
1515 -------------------------------------------------------------------
1516 l_debug_info := 'Step 7: Get ship_line_type_code and default Fiscal Classifications for line number:'||
1517 l_ship_line_list(i).ship_line_num;
1518 -- logging message
1519 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1520 p_procedure_name => l_function_name,
1521 p_debug_info => l_debug_info);
1522 -------------------------------------------------------------------
1523 IF l_ship_line_list(i).source = 'CHARGE' THEN
1524 l_ship_line_type_code := 'MISC';
1525 ELSE
1526 l_ship_line_type_code := 'ITEM';
1527 END IF;
1528 -------------------------------------------------------------------
1529 l_debug_info := 'Step 8: Get line_level_action for line number:'
1530 || l_ship_line_list(i).ship_line_num
1531 ||'l_ship_line_list(i).tax_already_calculated_flag'|| l_ship_line_list(i).tax_already_calculated_flag
1532 ;
1533
1534 -- logging message
1535 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1536 p_procedure_name => l_function_name,
1537 p_debug_info => l_debug_info);
1538 -------------------------------------------------------------------
1539 IF nvl(l_ship_line_list(i).tax_already_calculated_flag,'N') = 'Y' THEN
1540 l_line_level_action := 'UPDATE';
1541 ELSE
1542 l_line_level_action := 'CREATE';
1543 END IF;
1544 ------------------------------------------------------------------
1545 l_debug_info := 'Step 9: Get Additional PO matched info (l_line_level_action = '||l_line_level_action||')';
1546 -- logging message
1547 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1548 p_procedure_name => l_function_name,
1549 p_debug_info => l_debug_info);
1550 ------------------------------------------------------------------
1551 -- For now src_type_code can be PO = PO Shipment, RMA = Return Material Authorization Line OR IR = Internal Requisition
1552 IF l_ship_line_list(i).src_type_code IS NOT NULL THEN
1553
1554 IF l_ship_line_list(i).src_type_code='PO' AND l_ship_line_list(i).src_id IS NOT NULL THEN
1555 Get_PO_Info(
1556 p_po_line_location_id => l_ship_line_list(i).src_id,
1557 x_po_header_id => l_ref_doc_trx_id,
1558 x_po_header_curr_conv_rate => l_po_header_curr_conv_rate,
1559 x_return_status => l_return_status);
1560
1561 -- If any errors happen abort API.
1562 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1563 RAISE FND_API.G_EXC_ERROR;
1564 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1565 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1566 END IF;
1567
1568 l_ref_doc_trx_level_type := 'SHIPMENT';
1569 l_ref_doc_line_id := l_ship_line_list(i).src_id;
1570 ELSE
1571 l_ref_doc_application_id := Null;
1572 l_ref_doc_entity_code := Null;
1573 l_ref_doc_event_class_code := Null;
1574 l_ref_doc_line_quantity := Null;
1575 l_product_org_id := Null;
1576 l_ref_doc_trx_id := Null;
1577 l_ref_doc_trx_level_type := Null;
1578 l_ref_doc_line_id := Null;
1579 END IF;
1580 ELSE
1581 l_ref_doc_application_id := Null;
1582 l_ref_doc_entity_code := Null;
1583 l_ref_doc_event_class_code := Null;
1584 l_ref_doc_line_quantity := Null;
1585 l_product_org_id := Null;
1586 l_ref_doc_trx_id := Null;
1587 l_ref_doc_trx_level_type := Null;
1588 l_ref_doc_line_id := Null;
1589 END IF;
1590 ------------------------------------------------------------------
1591 l_debug_info := 'Step 9: Get line_amt_includes_tax_flag';
1592 -- logging message
1593 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1594 p_procedure_name => l_function_name,
1595 p_debug_info => l_debug_info);
1596 ------------------------------------------------------------------
1597 l_line_amt_includes_tax_flag := 'S';
1598 ------------------------------------------------------------------
1599 l_debug_info := 'Step 10: Get ctrl_hdr_tx_appl_flag';
1600 ------------------------------------------------------------------
1601 l_ctrl_hdr_tx_appl_flag := 'N';
1602 ------------------------------------------------------------------
1603 l_line_amount := nvl(l_ship_line_list(i).unit_price * l_ship_line_list(i).line_qty,0);
1604 ------------------------------------------------------------------
1605 l_debug_info := 'Step 10.1: Get line_class';
1606 -- logging message
1607 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1608 p_procedure_name => l_function_name,
1609 p_debug_info => l_debug_info);
1610 ------------------------------------------------------------------
1611 l_line_Class := 'STANDARD'; -- Possible values are 'STANDARD', 'ADJUSTMENT', 'APPLICATION', 'UNAPPLICATION', 'AMOUNT_MATCHED'
1612 ------------------------------------------------------------------
1613 l_debug_info := 'Step 12: Populate pl/sql table';
1614 -- logging message
1615 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1616 p_procedure_name => l_function_name,
1617 p_debug_info => l_debug_info);
1618 ------------------------------------------------------------------
1619 -- Will populate a dinamic table to include in zx_transaction_lines_gt
1620 IF (l_return_status = FND_API.G_RET_STS_SUCCESS ) THEN
1621 trans_lines(i).application_id := 9004;
1622 trans_lines(i).entity_code := G_ENTITY_CODE;
1623 trans_lines(i).event_class_code := p_event_class_code;
1624 trans_lines(i).trx_line_precision := l_precision;
1625 trans_lines(i).trx_line_mau := l_minimum_accountable_unit;
1626 trans_lines(i).trx_line_currency_code := l_ship_line_list(i).currency_code ;
1627 trans_lines(i).trx_line_currency_conv_rate := l_ship_line_list(i).currency_conversion_rate ;
1628 trans_lines(i).trx_line_currency_conv_date := l_ship_line_list(i).currency_conversion_date;
1629 trans_lines(i).trx_line_currency_conv_type := l_ship_line_list(i).currency_conversion_type;
1630 trans_lines(i).trx_id := l_ship_line_list(i).ship_header_id;
1631 trans_lines(i).trx_level_type := l_ship_line_list(i).SOURCE;
1632 trans_lines(i).trx_line_id := l_ship_line_list(i).ship_line_id;
1633 trans_lines(i).line_level_action := l_line_level_action;
1634 trans_lines(i).line_class := l_line_class;
1635 trans_lines(i).trx_receipt_date := l_ship_header_rec.ship_date;
1636 trans_lines(i).trx_line_type := l_ship_line_type_code;
1637 trans_lines(i).trx_line_date := l_ship_header_rec.ship_date;
1638 trans_lines(i).trx_business_category := l_ship_line_list(i).trx_business_category;
1639 trans_lines(i).line_intended_use := l_ship_line_list(i).intended_use;
1640 trans_lines(i).user_defined_fisc_class := l_ship_line_list(i).user_def_fiscal_class;
1641 trans_lines(i).product_category := l_ship_line_list(i).product_category;
1642 trans_lines(i).product_fisc_classification := l_ship_line_list(i).product_fiscal_class;
1643 trans_lines(i).assessable_value := 0; -- l_line_amount; --updated above
1644 trans_lines(i).line_amt := l_line_amount;
1645 trans_lines(i).trx_line_quantity := l_ship_line_list(i).line_qty;
1646 trans_lines(i).unit_price := l_ship_line_list(i).unit_price;
1647 trans_lines(i).product_id := l_ship_line_list(i).inventory_item_id;
1648 trans_lines(i).product_org_id := nvl(l_product_org_id,l_ship_header_rec.organization_id);
1649 trans_lines(i).uom_code := l_ship_line_list(i).uom_code;
1650 trans_lines(i).product_type := l_ship_line_list(i).product_type;
1651 trans_lines(i).fob_point := l_fob_point;
1652 trans_lines(i).bill_from_party_id := l_ship_line_list(i).bill_from_party_id ;
1653 trans_lines(i).bill_from_party_site_id := l_ship_line_list(i).bill_from_party_site_id;
1654 trans_lines(i).bill_to_party_id := l_ship_line_list(i).bill_to_organization_id ;
1655 trans_lines(i).bill_to_location_id := l_ship_line_list(i).bill_to_location_id ;
1656 trans_lines(i).poa_party_id := l_ship_line_list(i).poa_party_id ;
1657 trans_lines(i).poa_party_site_id := l_ship_line_list(i).poa_party_site_id ;
1658 trans_lines(i).poo_party_id := l_ship_line_list(i).poo_organization_id ;
1659 trans_lines(i).poo_location_id := l_ship_line_list(i).poo_location_id ;
1660 trans_lines(i).ref_doc_application_id := l_ref_doc_application_id;
1661 trans_lines(i).ref_doc_entity_code := l_ref_doc_entity_code;
1662 trans_lines(i).ref_doc_event_class_code := l_ref_doc_event_class_code;
1663 trans_lines(i).ref_doc_trx_id := l_ref_doc_trx_id;
1664 trans_lines(i).ref_doc_trx_level_type := l_ref_doc_trx_level_type;
1665 trans_lines(i).ref_doc_line_quantity := l_ref_doc_line_quantity;
1666 trans_lines(i).ref_doc_line_id := l_ref_doc_line_id;
1667 trans_lines(i).trx_line_number := l_ship_line_list(i).ship_line_num;
1668 trans_lines(i).trx_line_description := NULL; --'INL_SHIPMENT_LINE';
1669 trans_lines(i).trx_line_gl_date := SYSDATE;
1670 trans_lines(i).product_description := l_ship_line_list(i).inventory_item_id;--to report only
1671 trans_lines(i).line_amt_includes_tax_flag := l_line_amt_includes_tax_flag;
1672 trans_lines(i).historical_flag := 'N'; -- NVL(l_ship_header_rec.historical_flag, 'N');
1673 trans_lines(i).ctrl_hdr_tx_appl_flag := l_ctrl_hdr_tx_appl_flag;
1674 trans_lines(i).ctrl_total_line_tx_amt := NULL;
1675 trans_lines(i).source_application_id := NULL;
1676 trans_lines(i).source_entity_code := NULL;
1677 trans_lines(i).source_event_class_code := NULL;
1678 trans_lines(i).source_trx_id := NULL;
1679 trans_lines(i).source_line_id := NULL;
1680 trans_lines(i).source_trx_level_type := NULL;
1681 trans_lines(i).input_tax_classification_code := l_ship_line_list(i).tax_classification_code;
1682 ------------------------------------------------------------------
1683 l_debug_info := 'Step 14: Populate pl/sql table: trans_lines(i).trx_line_id='||trans_lines(i).trx_line_id;
1684 -- logging message
1685 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1686 p_procedure_name => l_function_name,
1687 p_debug_info => l_debug_info);
1688 ------------------------------------------------------------------
1689 END IF;
1690 END LOOP;
1691 END IF;
1692 IF ( l_return_status = FND_API.G_RET_STS_SUCCESS ) THEN
1693 -- if exist any row from this shipment it will be removed
1694 DELETE FROM zx_transaction_lines_gt
1695 WHERE trx_id= l_ship_header_rec.ship_header_id;
1696 -------------------------------------------------------------------
1697 l_debug_info := 'Step 15: Bulk Insert into global temp table';
1698 -------------------------------------------------------------------
1699 -- logging message
1700 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1701 p_procedure_name => l_function_name,
1702 p_debug_info => l_debug_info);
1703 -- populate the table
1704 FORALL m IN trans_lines.FIRST..trans_lines.LAST
1705 INSERT INTO zx_transaction_lines_gt
1706 VALUES trans_lines(m);
1707 -------------------------------------------------------------------
1708
1709 l_debug_info := 'Step 15: Populate pl/sql table inserted: '||sql%rowcount||' line(s)';
1710 -- logging message
1711 INL_LOGGING_PVT.Log_Statement (p_module_name => g_module_name,
1712 p_procedure_name => l_function_name,
1713 p_debug_info => l_debug_info);
1714 -------------------------------------------------------------------
1715 END IF;
1716 -- logging message
1717 INL_LOGGING_PVT.Log_EndProc (p_module_name => g_module_name,
1718 p_procedure_name => l_function_name);
1719
1720 EXCEPTION
1721 WHEN FND_API.G_EXC_ERROR THEN
1722 -- logging message
1723 INL_LOGGING_PVT.Log_ExpecError (p_module_name => g_module_name,
1724 p_procedure_name => l_function_name);
1725 x_return_status := FND_API.G_RET_STS_ERROR;
1726 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1727 -- logging message
1728 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
1729 p_procedure_name => l_function_name);
1730 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1731 WHEN OTHERS THEN
1732 -- logging message
1733 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
1734 p_procedure_name => l_function_name);
1735 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1736 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1737 THEN
1738 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,l_function_name);
1739 END IF;
1740
1741 END Populate_Lines_GT;
1742
1743 -- Utility name: Adjust_Tax_Lines
1744 --
1745 -- Type : Private
1746 --
1747 -- Function : It makes adjusts (Insert, Delete or Both) in tax_line table.
1748 -- For a given Ship_Header_Id DEL will remove all rows from this shipment of the
1749 -- INL_tax_lines and from INL_associations
1750 -- INS will insert in INL_tax_lines all lines from zx_lines
1751 -- If the zx_line has recover amount two lines will be generated in INL_tax_lines.
1752 --
1753 -- Pre-reqs : None
1754 --
1755 -- Parameters :
1756 -- IN : p_ship_header_id IN NUMBER
1757 --
1758 -- OUT : x_return_status OUT NOCOPY VARCHAR2
1759 --
1760 -- Version : Current version 1.0
1761 --
1762 -- Notes :
1763 PROCEDURE Adjust_Tax_Lines(
1764 p_ship_header_id IN NUMBER,
1765 x_return_status OUT NOCOPY VARCHAR2
1766 ) IS
1767 l_procedure_name CONSTANT VARCHAR2(100) := 'Adjust_Tax_Lines ';
1768 l_debug_info VARCHAR2(240);
1769 l_tax_line_id NUMBER;
1770 l_allocation_basis VARCHAR2(30) := 'VALUE';
1771 l_allocation_uom_code VARCHAR2(30) := NULL;
1772 l_proc VARCHAR2(1):='N';
1773 BEGIN
1774 -- logging message
1775 INL_LOGGING_PVT.Log_BeginProc (
1776 p_module_name => g_module_name,
1777 p_procedure_name => l_procedure_name
1778 );
1779
1780 x_return_status := FND_API.G_RET_STS_SUCCESS;
1781 FOR curTax in (SELECT zl.tax_line_id
1782 ,zl.tax_line_number
1783 ,zl.tax_code
1784 ,zl.trx_id
1785 ,zl.trx_line_id
1786 ,zl.tax_amt
1787 ,nvl(zl.Nrec_tax_amt,0) Nrec_tax_amt
1788 ,zl.tax_amt_included_flag
1789 ,zl.tax_currency_code
1790 ,zl.tax_currency_conversion_type
1791 ,zl.tax_currency_conversion_date
1792 ,zl.tax_currency_conversion_rate
1793 ,zl.created_by
1794 ,zl.creation_date
1795 ,zl.last_updated_by
1796 ,zl.last_update_date
1797 ,zl.last_update_login
1798 ,DECODE(lv.source, 'SHIP_LINE' ,'INL_SHIP_LINES'
1799 , 'CHARGE' ,'INL_CHARGE_LINES') source
1800 ,oh.ship_TYPE_ID
1801 ,inl_tax_lines_s.NEXTVAL tax_line_id_s
1802 FROM zx_lines zl
1803 ,inl_ebtax_lines_v lv
1804 ,inl_ship_headers oh
1805 WHERE zl.application_id = 9004
1806 AND zl.trx_id = P_ship_Header_Id
1807 AND oh.ship_Header_Id = P_ship_Header_Id
1808 AND lv.ship_line_id = zl.trx_line_id
1809 AND lv.ship_header_id = P_ship_Header_Id)
1810 LOOP
1811 IF l_proc = 'N' THEN
1812 l_proc := 'Y';
1813 -- logging message
1814 l_debug_info := 'It will mark the calculated line: curTax';
1815 INL_LOGGING_PVT.Log_Statement (
1816 p_module_name => g_module_name,
1817 p_procedure_name => l_procedure_name,
1818 p_debug_info => l_debug_info
1819 );
1820 END IF;
1821 -----------------------------------------------------------------
1822 l_debug_info := 'Step 6a: Persisting zl.tax_code: '||curTax.tax_code||' zl.tax_line_id:'||curTax.tax_line_id;
1823 -- logging message
1824 INL_LOGGING_PVT.Log_Statement (
1825 p_module_name => g_module_name,
1826 p_procedure_name => l_procedure_name,
1827 p_debug_info => l_debug_info
1828 );
1829 -----------------------------------------------------------------
1830 -----------------------------------------------------------------
1831 l_debug_info := ' P_Ship_Header_Id: '||p_ship_Header_Id
1832 ||' zl.tax_line_id: '||curTax.tax_line_id
1833 ;
1834 -- logging message
1835 INL_LOGGING_PVT.Log_Statement (
1836 p_module_name => g_module_name,
1837 p_procedure_name => l_procedure_name,
1838 p_debug_info => l_debug_info
1839 );
1840 -----------------------------------------------------------------
1841 -- It will insert in LCM tax Table the information from eBTax tax Table
1842 INSERT INTO inl_tax_lines (
1843 tax_line_id
1844 ,tax_line_num
1845 ,tax_code
1846 ,ship_header_id
1847 ,adjustment_num
1848 ,source_parent_table_name
1849 ,source_parent_table_id
1850 ,tax_amt
1851 ,nrec_tax_amt
1852 ,currency_code
1853 ,currency_conversion_type
1854 ,currency_conversion_date
1855 ,currency_conversion_rate
1856 ,tax_amt_included_flag
1857 ,created_by
1858 ,creation_date
1859 ,last_updated_by
1860 ,last_update_date
1861 ,last_update_login)
1862 VALUES(
1863 curTax.tax_line_id_s
1864 ,curTax.tax_line_number
1865 ,curTax.tax_code
1866 ,curTax.trx_id
1867 ,0
1868 ,'ZX_LINES'
1869 ,curTax.tax_line_id
1870 ,curTax.tax_amt
1871 ,curTax.nrec_tax_amt
1872 ,curTax.tax_currency_code
1873 ,curTax.tax_currency_conversion_type
1874 ,curTax.tax_currency_conversion_date
1875 ,curTax.tax_currency_conversion_rate
1876 ,curTax.tax_amt_included_flag
1877 ,fnd_global.user_id
1878 ,SYSDATE
1879 ,fnd_global.user_id
1880 ,SYSDATE
1881 ,fnd_global.login_id
1882 );
1883 -----------------------------------------------------------------
1884 l_debug_info := 'Step 6b: Persisting zl.tax_code(Associations): '||curTax.tax_code||' zl.tax_line_id:'||curTax.tax_line_id;
1885 -- logging message
1886 INL_LOGGING_PVT.Log_Statement (
1887 p_module_name => g_module_name,
1888 p_procedure_name => l_procedure_name,
1889 p_debug_info => l_debug_info
1890 );
1891 -----------------------------------------------------------------
1892 -- It will create the association of new tax line with the correspondent component
1893 INSERT INTO inl_associations (
1894 association_id /* 01 */
1895 ,ship_header_id /* 02 */
1896 ,from_parent_table_name /* 03 */
1897 ,from_parent_table_id /* 04 */
1898 ,to_parent_table_name /* 05 */
1899 ,to_parent_table_id /* 06 */
1900 ,allocation_basis /* 07 */
1901 ,allocation_uom_code /* 08 */
1902 ,created_by /* 09 */
1903 ,creation_date /* 10 */
1904 ,last_updated_by /* 11 */
1905 ,last_update_date /* 12 */
1906 ,last_update_login) /* 13 */
1907 VALUES(
1908 inl_associations_s.NEXTVAL /* 01 */
1909 ,curTax.trx_id /* 02 */
1910 ,'INL_TAX_LINES' /* 03 */
1911 ,curTax.tax_line_id_s /* 04 */
1912 ,curTax.source /* 05 */
1913 ,curTax.trx_line_id /* 06 */
1914 ,l_allocation_basis /* 07 */
1915 ,l_allocation_uom_code /* 08 */
1916 ,fnd_global.user_id /* 09 */
1917 ,SYSDATE /* 10 */
1918 ,fnd_global.user_id /* 11 */
1919 ,SYSDATE /* 12 */
1920 ,fnd_global.login_id); /* 13 */
1921 END LOOP;
1922 UPDATE inl_ship_lines
1923 SET tax_already_calculated_flag = 'Y',
1924 last_updated_by = fnd_global.user_id,
1925 last_update_date = SYSDATE
1926 WHERE ship_header_id = p_ship_header_Id;
1927
1928 UPDATE inl_charge_lines
1929 SET tax_already_calculated_flag = 'Y',
1930 last_updated_by = fnd_global.user_id,
1931 last_update_date = SYSDATE
1932 WHERE NVL(parent_charge_line_id,charge_line_id) IN (SELECT assoc.from_parent_table_id
1933 FROM inl_associations assoc
1934 WHERE assoc.from_parent_table_name = 'INL_CHARGE_LINES'
1935 AND assoc.ship_header_id = p_ship_header_id);
1936 -- logging message
1937 INL_LOGGING_PVT.Log_EndProc (
1938 p_module_name => g_module_name,
1939 p_procedure_name => l_procedure_name
1940 );
1941
1942 EXCEPTION
1943 WHEN FND_API.G_EXC_ERROR THEN
1944 -- logging message
1945 INL_LOGGING_PVT.Log_ExpecError (
1946 p_module_name => g_module_name,
1947 p_procedure_name => l_procedure_name
1948 );
1949 x_return_status := FND_API.G_RET_STS_ERROR;
1950 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1951 -- logging message
1952 INL_LOGGING_PVT.Log_UnexpecError (
1953 p_module_name => g_module_name,
1954 p_procedure_name => l_procedure_name
1955 );
1956 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1957 WHEN OTHERS THEN
1958 -- logging message
1959 INL_LOGGING_PVT.Log_UnexpecError (
1960 p_module_name => g_module_name,
1961 p_procedure_name => l_procedure_name
1962 );
1963 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1964 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1965 THEN
1966 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,l_procedure_name);
1967 END IF;
1968
1969 END Adjust_Tax_Lines;
1970
1971 -- API name : Calculate_Tax
1972 -- Type : Private
1973 -- Function : It populate the ZX temporary GT tables and then call eBTax Calculate Tax for a given LCM Shipment.
1974 -- Pre-reqs : None
1975 -- Parameters :
1976 -- IN : p_api_version IN NUMBER,
1977 -- p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
1978 -- p_commit IN VARCHAR2 := FND_API.G_FALSE,
1979 -- p_ship_header_id IN NUMBER,
1980 --
1981 -- OUT : x_return_status OUT NOCOPY VARCHAR2
1982 -- x_msg_count OUT NOCOPY NUMBER
1983 -- x_msg_data OUT NOCOPY VARCHAR2
1984 --
1985 -- Version : Current version 1.0
1986 --
1987 -- Notes :
1988
1989 PROCEDURE Calculate_Tax(
1990 p_api_version IN NUMBER,
1991 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
1992 p_commit IN VARCHAR2 := FND_API.G_FALSE,
1993 p_ship_header_id IN NUMBER,
1994 x_return_status OUT NOCOPY VARCHAR2,
1995 x_msg_count OUT NOCOPY NUMBER,
1996 x_msg_data OUT NOCOPY VARCHAR2
1997 ) IS
1998
1999 l_api_name CONSTANT VARCHAR2(30) := 'Calculate_Tax';
2000 l_api_version CONSTANT NUMBER := 1.0;
2001
2002 l_debug_info VARCHAR2(240);
2003
2004 l_event_class_code VARCHAR2(30);
2005 l_event_type_code VARCHAR2(30);
2006 l_tax_already_calculated VARCHAR2(1);
2007
2008 l_msg_count NUMBER;
2009 l_msg_data VARCHAR2(4000);
2010 l_msg VARCHAR2(4000);
2011 l_error_code VARCHAR2(30);
2012
2013 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
2014 l_no_tax_lines VARCHAR2(1) := 'N';
2015 l_inv_rcv_matched VARCHAR2(1) := 'N';
2016
2017 l_ledger_list GL_MC_INFO.r_sob_list;
2018 l_denominator_rate NUMBER;
2019 l_numerator_rate NUMBER;
2020
2021
2022 BEGIN
2023 -- logging message
2024 INL_LOGGING_PVT.Log_BeginProc (
2025 p_module_name => g_module_name,
2026 p_procedure_name => l_api_name
2027 );
2028
2029 -- Standard Start of API savepoint
2030 SAVEPOINT Calculate_Tax_PVT;
2031
2032 -- Initialize message list if p_init_msg_list is set to TRUE.
2033 IF FND_API.to_Boolean( p_init_msg_list ) THEN
2034 FND_MSG_PUB.initialize;
2035 END IF;
2036
2037 -------------------------------------------------------------------
2038 l_debug_info := 'FND_API.Compatible_API_Call';
2039 -------------------------------------------------------------------
2040 -- logging message
2041 INL_LOGGING_PVT.Log_Statement (
2042 p_module_name => g_module_name,
2043 p_procedure_name => l_api_name,
2044 p_debug_info => l_debug_info
2045 );
2046 -- Check for call compatibility.
2047 IF NOT FND_API.Compatible_API_Call (
2048 l_api_version,
2049 p_api_version,
2050 l_api_name,
2051 G_PKG_NAME)
2052 THEN
2053 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2054 END IF;
2055
2056 -- Initialize API return status to success
2057 x_return_status := FND_API.G_RET_STS_SUCCESS;
2058
2059
2060
2061 --- VPILAN 11-Jun-2008
2062 --- This RETURN is due to the fact we don't have EBTAX events model yet.
2063 RETURN;
2064
2065
2066 -------------------------------------------------------------------
2067 l_debug_info := 'Step 0: Get Entity Code mapping on eBTax';
2068 -------------------------------------------------------------------
2069 -- logging message
2070 INL_LOGGING_PVT.Log_Statement (
2071 p_module_name => g_module_name,
2072 p_procedure_name => l_api_name,
2073 p_debug_info => l_debug_info
2074 );
2075
2076 SELECT entity_code INTO G_ENTITY_CODE
2077 FROM zx_evnt_cls_mappings
2078 WHERE application_id = 9004
2079 AND ROWNUM = 1;
2080 -----------------------------------------------------------------
2081 l_debug_info := 'Step 1: call LCM Calculation for all types of lines';
2082 -- logging message
2083 INL_LOGGING_PVT.Log_Statement (
2084 p_module_name => g_module_name,
2085 p_procedure_name => l_api_name,
2086 p_debug_info => l_debug_info
2087 );
2088 -----------------------------------------------------------------
2089 IF ( l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2090 l_debug_info := 'Step 1a: Delete data from previous tax Generation/Calculation';
2091 -- logging message
2092 INL_LOGGING_PVT.Log_Statement (
2093 p_module_name => g_module_name,
2094 p_procedure_name => l_api_name,
2095 p_debug_info => l_debug_info
2096 );
2097 Delete_PreviousTaxLines (
2098 p_ship_header_id => p_ship_header_id,
2099 x_return_status => l_return_status
2100 );
2101 -- If any errors happen abort API.
2102 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2103 RAISE FND_API.G_EXC_ERROR;
2104 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2105 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2106 END IF;
2107 -----------------------------------------------------------------
2108 l_debug_info := 'Step 2: Populating shipment header local record';
2109 INL_LOGGING_PVT.Log_Statement (
2110 p_module_name => g_module_name,
2111 p_procedure_name => l_api_name,
2112 p_debug_info => l_debug_info
2113 );
2114 -----------------------------------------------------------------
2115
2116 BEGIN
2117 OPEN Shipment_Header(p_ship_header_id);
2118 FETCH Shipment_Header INTO l_ship_header_rec;
2119 CLOSE Shipment_Header;
2120 END;
2121 -----------------------------------------------------------------
2122 l_debug_info := 'Step 2a: Populating shipment lines collection';
2123 -- logging message
2124 INL_LOGGING_PVT.Log_Statement (
2125 p_module_name => g_module_name,
2126 p_procedure_name => l_api_name,
2127 p_debug_info => l_debug_info
2128 );
2129 -----------------------------------------------------------------
2130 -- Collect INL_eBTax_Line_v lines in l_ship_line_list dinamic table
2131 -- The view INL_eBTax_Line_v has Shipment_Lines and Charge_Lines froma given shipment
2132 BEGIN
2133 OPEN Shipment_Lines(p_ship_header_id);
2134 FETCH Shipment_Lines
2135 BULK COLLECT INTO l_ship_line_list;
2136 CLOSE Shipment_Lines;
2137 EXCEPTION WHEN NO_DATA_FOUND THEN NULL;
2138 END;
2139 -- The eTax_Already_called_flag is in lines
2140 -- adjustments generate version of lines and charge lines
2141 -- to decide the value of flag we are seeing zx table
2142
2143 -------------------------------------------------------------------
2144 l_debug_info := 'Step 2b: Get event class code';
2145 -------------------------------------------------------------------
2146
2147 Get_Event_Class_Code(
2148 p_ship_type_id => l_ship_header_rec.ship_type_id,
2149 x_event_class_code => l_event_class_code,
2150 x_return_status => l_return_status
2151 );
2152 -- If any errors happen abort API.
2153 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2154 RAISE FND_API.G_EXC_ERROR;
2155 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2156 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2157 END IF;
2158
2159 -----------------------------------------------------------------
2160 l_debug_info := 'Step 2c: Getting l_tax_already_calculated. trx_id= '||l_ship_header_rec.ship_header_id
2161 ||' application_id: 9004'
2162 ||' event_class_code: '||l_event_class_code
2163 ||' entity_code: '||G_ENTITY_CODE;
2164 -- logging message
2165 INL_LOGGING_PVT.Log_Statement (
2166 p_module_name => g_module_name,
2167 p_procedure_name => l_api_name,
2168 p_debug_info => l_debug_info
2169 );
2170 -----------------------------------------------------------------
2171 BEGIN
2172 SELECT 'Y'
2173 INTO l_tax_already_calculated
2174 FROM zx_lines_det_factors
2175 WHERE trx_id = l_ship_header_rec.ship_header_id
2176 AND application_id = 9004
2177 AND entity_code = G_ENTITY_CODE
2178 AND event_class_code = l_event_class_code
2179 AND ROWNUM < 2;
2180 EXCEPTION
2181 WHEN OTHERS THEN l_tax_already_calculated := 'N';
2182 END;
2183 -----------------------------------------------------------------
2184 l_debug_info := 'Step 3: Populate Header';
2185 -- logging message
2186 INL_LOGGING_PVT.Log_Statement (
2187 p_module_name => g_module_name,
2188 p_procedure_name => l_api_name,
2189 p_debug_info => l_debug_info
2190 );
2191 -----------------------------------------------------------------
2192
2193 -- Populate eBTax temporary table (Header)
2194 INL_TAX_PVT.Populate_Headers_GT(
2195 p_etax_already_called_flag => l_tax_already_calculated,
2196 p_event_class_code => l_event_class_code,
2197 x_event_type_code => l_event_type_code,
2198 x_return_status => l_return_status
2199 );
2200
2201 -- If any errors happen abort API.
2202 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2203 RAISE FND_API.G_EXC_ERROR;
2204 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2205 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2206 END IF;
2207 -----------------------------------------------------------------
2208 l_debug_info := 'Step 4: Populate TRX lines';
2209 -- logging message
2210 INL_LOGGING_PVT.Log_Statement (
2211 p_module_name => g_module_name,
2212 p_procedure_name => l_api_name,
2213 p_debug_info => l_debug_info
2214 );
2215 -----------------------------------------------------------------
2216 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
2217 -- Populate eBTax temporary table (Lines)
2218
2219 INL_TAX_PVT.Populate_Lines_GT(
2220 P_Event_Class_Code => l_event_class_code,
2221 P_Line_Number => 1,
2222 x_return_status => l_return_status
2223 );
2224 -- If any errors happen abort API.
2225 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2226 RAISE FND_API.G_EXC_ERROR;
2227 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2228 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2229 END IF;
2230
2231
2232 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
2233 -- logging message
2234 INL_LOGGING_PVT.Log_APICallIn (
2235 p_module_name => g_module_name,
2236 p_procedure_name => l_api_name,
2237 p_call_api_name => 'ZX_API_PUB.Calculate_Tax',
2238 p_in_param_name1 => 'p_api_version',
2239 p_in_param_value1 => 1.0,
2240 p_in_param_name2 => 'p_init_msg_list',
2241 p_in_param_value2 => FND_API.G_TRUE,
2242 p_in_param_name3 => 'p_commit',
2243 p_in_param_value3 => FND_API.G_FALSE,
2244 p_in_param_name4 => 'p_validation_level',
2245 p_in_param_value4 => FND_API.G_VALID_LEVEL_FULL
2246 );
2247 --- It will run the calculate_tax procedure from eBTax
2248 --- This procedure will calculate the tax from the current transaction
2249 --- and populate zx_lines
2250
2251 /*
2252 FROM ZX_TRANSACTION_LINES_GT
2253 WHERE TRX_ID = l_ship_header_rec.ship_header_id
2254 */
2255 zx_api_pub.calculate_tax(
2256 p_api_version => 1.0,
2257 p_init_msg_list => FND_API.G_FALSE,
2258 p_commit => FND_API.G_FALSE,
2259 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
2260 x_return_status => l_return_status,
2261 x_msg_count => l_msg_count,
2262 x_msg_data => l_msg_data
2263 );
2264
2265 -- logging message
2266 INL_LOGGING_PVT.Log_APICallOut (
2267 p_module_name => g_module_name,
2268 p_procedure_name => l_api_name,
2269 p_call_api_name => 'ZX_API_PUB.Calculate_Tax',
2270 p_out_param_name1 => 'l_return_status',
2271 p_out_param_value1 => l_return_status,
2272 p_out_param_name2 => 'l_msg_count',
2273 p_out_param_value2 => l_msg_count,
2274 p_out_param_name3 => 'l_msg_data',
2275 p_out_param_value3 => l_msg_data);
2276
2277 -- If any errors happen abort API.
2278 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2279 RAISE FND_API.G_EXC_ERROR;
2280 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2281 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2282 END IF;
2283
2284 -----------------------------------------------------------------
2285 l_debug_info := 'Step 6: Adjust_Tax_Lines to Persist tax records in INL_ASSOCIATIONS and INL_TAX_LINES';
2286 -- logging message
2287 INL_LOGGING_PVT.Log_Statement (
2288 p_module_name => g_module_name,
2289 p_procedure_name => l_api_name,
2290 p_debug_info => l_debug_info);
2291 -----------------------------------------------------------------
2292 -- It will answer the updates done in zx_lines in INL_tax_lines
2293 Adjust_Tax_Lines(p_ship_header_id, l_return_status);
2294 -- If any errors happen abort API.
2295 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2296 RAISE FND_API.G_EXC_ERROR;
2297 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2298 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2299 END IF;
2300
2301 -----------------------------------------------------------------
2302 l_debug_info := 'Step 7: call LCM Calculation for tax lines';
2303 -- logging message
2304 INL_LOGGING_PVT.Log_Statement (
2305 p_module_name => g_module_name,
2306 p_procedure_name => l_api_name,
2307 p_debug_info => l_debug_info
2308 );
2309 -----------------------------------------------------------------
2310 END IF;
2311 END IF;
2312 END IF;
2313 -- If any errors happen abort API.
2314 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2315 RAISE FND_API.G_EXC_ERROR;
2316 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2317 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2318 END IF;
2319
2320 -- Standard check of p_commit.
2321 IF FND_API.To_Boolean( p_commit ) THEN
2322 COMMIT WORK;
2323 END IF;
2324
2325 -- Standard call to get message count and if count is 1, get message info.
2326 FND_MSG_PUB.Count_And_Get(
2327 p_encoded => FND_API.g_false,
2328 p_count => x_msg_count,
2329 p_data => x_msg_data);
2330
2331 INL_LOGGING_PVT.Log_EndProc (
2332 p_module_name => g_module_name,
2333 p_procedure_name => l_api_name);
2334 EXCEPTION
2335 WHEN FND_API.G_EXC_ERROR THEN
2336 INL_LOGGING_PVT.Log_ExpecError (
2337 p_module_name => g_module_name,
2338 p_procedure_name => l_api_name);
2339 ROLLBACK TO Calculate_Tax_PVT;
2340 x_return_status := FND_API.G_RET_STS_ERROR;
2341 FND_MSG_PUB.Count_And_Get(
2342 p_encoded => FND_API.g_false,
2343 p_count => x_msg_count,
2344 p_data => x_msg_data);
2345 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2346 INL_LOGGING_PVT.Log_UnexpecError (
2347 p_module_name => g_module_name,
2348 p_procedure_name => l_api_name);
2349 ROLLBACK TO Calculate_Tax_PVT;
2350 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2351 FND_MSG_PUB.Count_And_Get(
2352 p_encoded => FND_API.g_false,
2353 p_count => x_msg_count,
2354 p_data => x_msg_data);
2355 WHEN OTHERS THEN
2356 -- logging message
2357 INL_LOGGING_PVT.Log_UnexpecError (
2358 p_module_name => g_module_name,
2359 p_procedure_name => l_api_name);
2360 ROLLBACK TO Calculate_Tax_PVT;
2361 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2362 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2363 THEN
2364 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,l_api_name);
2365 END IF;
2366 FND_MSG_PUB.Count_And_Get(
2367 p_encoded => FND_API.g_false,
2368 p_count => x_msg_count,
2369 p_data => x_msg_data);
2370 END Calculate_Tax;
2371
2372 -- API name : Get_DefaultTaxDetAttribs
2373 -- Type : Private
2374 -- Function : Get default tax attributes
2375 -- Pre-reqs : None
2376 -- Parameters :
2377 -- IN : p_api_version IN NUMBER,
2378 -- p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
2379 -- p_commit IN VARCHAR2 := FND_API.G_FALSE,
2380 -- p_application_id IN NUMBER,
2381 -- p_entity_code IN VARCHAR2,
2382 -- p_event_class_code IN VARCHAR2,
2383 -- p_org_id IN VARCHAR2,
2384 -- p_item_id IN NUMBER,
2385 -- p_country_code IN VARCHAR2,
2386 -- p_effective_date IN DATE,
2387 -- p_source_type_code IN VARCHAR2,
2388 -- p_po_line_location_id IN NUMBER,
2389 --
2390 -- OUT x_return_status OUT NOCOPY VARCHAR2
2391 -- x_msg_count OUT NOCOPY NUMBER
2392 -- x_msg_data OUT NOCOPY VARCHAR2
2393 -- x_trx_biz_category OUT NOCOPY VARCHAR2,
2394 -- x_intended_use OUT NOCOPY VARCHAR2,
2395 -- x_prod_category OUT NOCOPY VARCHAR2,
2396 -- x_prod_fisc_class_code OUT NOCOPY VARCHAR2,
2397 -- x_product_type OUT NOCOPY VARCHAR2
2398 -- Version : Current version 1.0
2399 --
2400 -- Notes :
2401 PROCEDURE Get_DefaultTaxDetAttribs(p_api_version IN NUMBER,
2402 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
2403 p_commit IN VARCHAR2 := FND_API.G_FALSE,
2404 p_application_id IN NUMBER,
2405 p_entity_code IN VARCHAR2,
2406 p_event_class_code IN VARCHAR2,
2407 p_org_id IN VARCHAR2,
2408 p_item_id IN NUMBER,
2409 p_country_code IN VARCHAR2,
2410 p_effective_date IN DATE,
2411 p_source_type_code IN VARCHAR2,
2412 p_po_line_location_id IN NUMBER,
2413 x_return_status OUT NOCOPY VARCHAR2,
2414 x_msg_count OUT NOCOPY NUMBER,
2415 x_msg_data OUT NOCOPY VARCHAR2,
2416 x_trx_biz_category OUT NOCOPY VARCHAR2,
2417 x_intended_use OUT NOCOPY VARCHAR2,
2418 x_prod_category OUT NOCOPY VARCHAR2,
2419 x_prod_fisc_class_code OUT NOCOPY VARCHAR2,
2420 x_product_type OUT NOCOPY VARCHAR2) IS
2421
2422 l_api_name CONSTANT VARCHAR2(30) := 'Get_DefaultTaxDetAttribs';
2423 l_api_version CONSTANT NUMBER := 1.0;
2424
2425 l_return_status VARCHAR2(1);
2426 l_msg_count NUMBER;
2427 l_msg_data VARCHAR2(2000);
2428 l_debug_info VARCHAR2(200);
2429 l_po_country_code VARCHAR2(20);
2430 BEGIN
2431
2432 -- Standard Beginning of Procedure/Function Logging
2433 INL_LOGGING_PVT.Log_BeginProc (p_module_name => g_module_name,
2434 p_procedure_name => l_api_name);
2435
2436 -- Standard Start of API savepoint
2437 SAVEPOINT Get_DefaultTaxDetAttribs_PVT;
2438
2439 -- Initialize message list if p_init_msg_list is set to TRUE.
2440 IF FND_API.to_Boolean( p_init_msg_list ) THEN
2441 FND_MSG_PUB.initialize;
2442 END IF;
2443
2444 -- Check for call compatibility.
2445 IF NOT FND_API.Compatible_API_Call (l_api_version,
2446 p_api_version,
2447 l_api_name,
2448 g_pkg_name)
2449 THEN
2450 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2451 END IF;
2452
2453 -- Initialize API return status to success
2454 x_return_status := FND_API.G_RET_STS_SUCCESS;
2455
2456 -- API Body
2457 BEGIN
2458
2459 l_debug_info := 'p_source_type_code: ' || p_source_type_code;
2460 -- logging message
2461 INL_LOGGING_PVT.Log_Statement (
2462 p_module_name => g_module_name,
2463 p_procedure_name => l_api_name,
2464 p_debug_info => l_debug_info);
2465
2466 IF(p_source_type_code = 'PO') THEN
2467 BEGIN
2468 SELECT zx.default_taxation_country,
2469 zx.trx_business_category,
2470 zx.product_fisc_classification,
2471 zx.product_category,
2472 zx.line_intended_use,
2473 zx.product_type
2474 INTO l_po_country_code,
2475 x_trx_biz_category,
2476 x_prod_fisc_class_code,
2477 x_prod_category,
2478 x_intended_use,
2479 x_product_type
2480 FROM zx_lines_det_factors zx,
2481 po_line_locations pll
2482 WHERE zx.application_id = 201
2483 AND zx.event_class_code = 'PO_PA'
2484 AND zx.entity_code = 'PURCHASE_ORDER'
2485 AND zx.trx_id = pll.po_header_id
2486 AND zx.trx_line_id = pll.line_location_id
2487 AND zx.trx_level_type = 'SHIPMENT'
2488 AND trx_line_id = p_po_line_location_id;
2489 EXCEPTION
2490 WHEN NO_DATA_FOUND THEN
2491 l_po_country_code := NULL;
2492 END;
2493
2494 l_debug_info := 'l_po_country_code: ' || l_po_country_code;
2495 -- logging message
2496 INL_LOGGING_PVT.Log_Statement (
2497 p_module_name => g_module_name,
2498 p_procedure_name => l_api_name,
2499 p_debug_info => l_debug_info);
2500
2501 l_debug_info := 'p_country_code: ' || p_country_code;
2502 -- logging message
2503 INL_LOGGING_PVT.Log_Statement (
2504 p_module_name => g_module_name,
2505 p_procedure_name => l_api_name,
2506 p_debug_info => l_debug_info);
2507
2508 IF(l_po_country_code IS NULL OR l_po_country_code <> p_country_code) THEN
2509
2510 ZX_API_PUB.get_default_tax_det_attribs(p_api_version => 1.0,
2511 p_init_msg_list => FND_API.G_FALSE,
2512 p_commit => FND_API.G_FALSE,
2513 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
2514 x_return_status => l_return_status,
2515 x_msg_count => l_msg_count,
2516 x_msg_data => l_msg_data,
2517 p_application_id => p_application_id,
2518 p_entity_code => p_entity_code,
2519 p_event_class_code => p_event_class_code,
2520 p_org_id => p_org_id,
2521 p_item_id => p_item_id,
2522 p_country_code => p_country_code,
2523 p_effective_date => p_effective_date,
2524 p_source_event_class_code => NULL,
2525 x_trx_biz_category => x_trx_biz_category,
2526 x_intended_use => x_intended_use,
2527 x_prod_category => x_prod_category,
2528 x_prod_fisc_class_code => x_prod_fisc_class_code,
2529 x_product_type => x_product_type);
2530 -- If any errors happen abort API.
2531 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2532 RAISE FND_API.G_EXC_ERROR;
2533 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2534 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2535 END IF;
2536 END IF;
2537 ELSE
2538
2539 ZX_API_PUB.get_default_tax_det_attribs(p_api_version => 1.0,
2540 p_init_msg_list => FND_API.G_FALSE,
2541 p_commit => FND_API.G_FALSE,
2542 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
2543 x_return_status => l_return_status,
2544 x_msg_count => l_msg_count,
2545 x_msg_data => l_msg_data ,
2546 p_application_id => p_application_id,
2547 p_entity_code => p_entity_code,
2548 p_event_class_code => p_event_class_code,
2549 p_org_id => p_org_id,
2550 p_item_id => p_item_id,
2551 p_country_code => p_country_code,
2552 p_effective_date => p_effective_date,
2553 p_source_event_class_code => NULL,
2554 x_trx_biz_category => x_trx_biz_category,
2555 x_intended_use => x_intended_use,
2556 x_prod_category => x_prod_category,
2557 x_prod_fisc_class_code => x_prod_fisc_class_code,
2558 x_product_type => x_product_type);
2559
2560 -- If any errors happen abort API.
2561 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2562 RAISE FND_API.G_EXC_ERROR;
2563 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2564 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2565 END IF;
2566 END IF;
2567 END;
2568
2569 -- Standard check of p_commit.
2570 IF FND_API.To_Boolean( p_commit ) THEN
2571 COMMIT WORK;
2572 END IF;
2573
2574 -- Standard call to get message count and if count is 1, get message info.
2575 FND_MSG_PUB.Count_And_Get
2576 (p_encoded => FND_API.g_false,
2577 p_count => x_msg_count,
2578 p_data => x_msg_data);
2579
2580 -- Standard End of Procedure/Function Logging
2581 INL_LOGGING_PVT.Log_EndProc (p_module_name => g_module_name,
2582 p_procedure_name => l_api_name);
2583
2584
2585 EXCEPTION
2586 WHEN FND_API.G_EXC_ERROR THEN
2587 -- Standard Expected Error Logging
2588 INL_LOGGING_PVT.Log_ExpecError (p_module_name => g_module_name,
2589 p_procedure_name => l_api_name);
2590 ROLLBACK TO Get_DefaultTaxDetAttribs_PVT;
2591 x_return_status := FND_API.G_RET_STS_ERROR;
2592 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.g_false,
2593 p_count => x_msg_count,
2594 p_data => x_msg_data);
2595 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2596 -- Standard Unexpected Error Logging
2597 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
2598 p_procedure_name => l_api_name);
2599 ROLLBACK TO Get_DefaultTaxDetAttribs_PVT;
2600 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2601 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.g_false,
2602 p_count => x_msg_count,
2603 p_data => x_msg_data);
2604 WHEN OTHERS THEN
2605 -- Standard Unexpected Error Logging
2606 INL_LOGGING_PVT.Log_UnexpecError (p_module_name => g_module_name,
2607 p_procedure_name => l_api_name);
2608 ROLLBACK TO Get_DefaultTaxDetAttribs_PVT;
2609 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2610 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2611 THEN
2612 FND_MSG_PUB.Add_Exc_Msg(g_pkg_name,l_api_name);
2613 END IF;
2614 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.g_false,
2615 p_count => x_msg_count,
2616 p_data => x_msg_data);
2617 END Get_DefaultTaxDetAttribs;
2618
2619 END INL_TAX_PVT;