[Home] [Help]
PACKAGE BODY: APPS.PA_OUTPUT_TAX
Source
1 PACKAGE BODY PA_OUTPUT_TAX as
2 /* $Header: PAXOTAXB.pls 120.12.12010000.4 2008/11/28 10:17:38 rmandali ship $ */
3
4 g1_debug_mode varchar2(1) := NVL(FND_PROFILE.value('PA_DEBUG_MODE'), 'N');
5
6 /*Added the two parameters bill_to_customer_id and ship_to_customer_id
7 for customer account relation enhancement bug no 2760630*/
8
9 PROCEDURE GET_DEFAULT_TAX_INFO
10 ( P_Project_Id IN NUMBER ,
11 P_Draft_Inv_Num IN NUMBER ,
12 P_Customer_Id IN NUMBER ,
13 P_Bill_to_site_use_id IN NUMBER ,
14 P_Ship_to_site_use_id IN NUMBER ,
15 P_Sets_of_books_id IN NUMBER ,
16 P_Event_id IN NUMBER ,
17 P_Expenditure_item_id IN NUMBER ,
18 P_User_Id IN NUMBER ,
19 P_Request_id IN NUMBER ,
20 X_Output_tax_exempt_flag OUT NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
21 X_Output_tax_exempt_number OUT NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
22 X_Output_exempt_reason_code OUT NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
23 X_Output_tax_code OUT NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
24 Pbill_to_customer_id IN NUMBER,
25 Pship_to_customer_id IN NUMBER,
26 P_draft_inv_num_credited IN NUMBER DEFAULT NULL,
27 P_invoice_date IN DATE DEFAULT SYSDATE) /* bug 5484859 */
28
29 IS
30 l_tax_code Varchar2(30);
31 l_line_type Varchar2(20);
32 l_vat_tax_id Number;
33 l_reason_code Varchar2(80);
34 l_certificate_no Varchar2(80);
35 l_exemption_id Number;
36 l_percent_exempt Number;
37 l_inserted_flag Varchar2(1);
38 l_exemption_type Varchar2(100);
39
40 l_transaction_type_id NUMBER;
41 l_batch_source_id NUMBER;
42 l_legal_entity_id NUMBER;
43
44 l_return_status VARCHAR2(30);
45
46 l_bill_to_party_id NUMBER;
47 l_bill_to_party_site_id NUMBER;
48 l_ship_to_party_id NUMBER;
49 l_ship_to_party_site_id NUMBER;
50
51 l_bill_to_address_id number;
52 l_ship_to_address_id number;
53
54
55 l_org_id NUMBER; --eTax changes
56
57 l1_exemption_rec_tbl ZX_TCM_GET_DEF_EXEMPTION.exemption_rec_tbl_type;
58
59 --eTax changes
60 CURSOR get_org_id(c_project_id NUMBER) IS
61 select org_id from pa_projects_all
62 where project_id = c_project_id;
63
64 BEGIN
65 -- Determine the invoice line type
66
67 If nvl(P_Event_id,0)=0 -- Event id is null
68 and nvl(P_Expenditure_item_id,0) = 0 -- Expenditure Item id is NULL
69 Then
70 l_line_type := 'RETENTION';
71 Elsif nvl(P_Event_id,0)<> 0
72 and nvl(P_Expenditure_item_id,0) =0
73 Then
74 l_line_type := 'EVENT';
75 Elsif nvl(P_Event_id,0)=0
76 and nvl(P_Expenditure_item_id,0)<> 0
77 Then
78 l_line_type := 'EXPENDITURE';
79 End If;
80
81 -- Set the draft Invoice Number for Client Extension Validation
82 PA_Tax_Client_Extn_Drv.G_Draft_Invoice_Num := P_Draft_Inv_Num ;
83
84 /* Added for Bug 6524843 */
85 PA_Tax_Client_Extn_Drv.G_Invoice_Date := P_invoice_date ;
86
87 -- Call Default Tax API
88 /*Changed the parameter p_customer_id p_primary_customer_id
89 and added two_new parameters pbill_to_customer_id and pship_to_customer_id
90 for customer account relation enhancement*/
91
92 --etax changes
93 Open get_org_id(p_project_id);
94 Fetch get_org_id into l_org_id;
95 Close get_org_id;
96
97 IF g1_debug_mode = 'Y' THEN
98 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' get_pa_default_classification: Org_id: '||l_org_id);
99 END IF;
100
101 IF g1_debug_mode = 'Y' THEN
102 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' calling ZX_AR_TAX_CLASSIFICATN_DEF_PKG' );
103 PA_MCB_INVOICE_PKG.log_message('p_project_id : ' || P_Project_Id );
104 PA_MCB_INVOICE_PKG.log_message('p_bill_to_site_use_id : ' || P_Bill_to_site_use_id );
105 PA_MCB_INVOICE_PKG.log_message('p_ship_to_site_use_id : ' || P_Ship_to_site_use_id );
106 PA_MCB_INVOICE_PKG.log_message('p_project_customer_id : ' || P_Customer_Id );
107 PA_MCB_INVOICE_PKG.log_message('p_set_of_books_id : ' || P_Sets_of_books_id );
108 PA_MCB_INVOICE_PKG.log_message('p_expenditure_item_id : ' || P_Expenditure_item_id );
109 PA_MCB_INVOICE_PKG.log_message('p_trx_date : ' || trunc(sysdate) );
110 PA_MCB_INVOICE_PKG.log_message('p_event_id : ' || P_Event_id );
111 PA_MCB_INVOICE_PKG.log_message('p_line_type : ' || l_line_type );
112 PA_MCB_INVOICE_PKG.log_message('p_request_id : ' || P_Request_id );
113 PA_MCB_INVOICE_PKG.log_message('p_user_id : ' || P_User_Id );
114 PA_MCB_INVOICE_PKG.log_message('p_tax_classification_code : ' || l_tax_code );
115 PA_MCB_INVOICE_PKG.log_message('p_bill_to_customer_id : ' || Pbill_to_customer_id );
116 PA_MCB_INVOICE_PKG.log_message('p_ship_to_customer_id : ' || Pship_to_customer_id );
117 PA_MCB_INVOICE_PKG.log_message('p_application_id : ' || 275 );
118 PA_MCB_INVOICE_PKG.log_message('p_internal_organization_id: ' || l_org_id );
119 PA_MCB_INVOICE_PKG.log_message('p_draft_inv_num_credited : ' || p_draft_inv_num_credited );
120
121 END IF;
122
123 ZX_AR_TAX_CLASSIFICATN_DEF_PKG.get_pa_default_classification
124 (
125 p_project_id => P_Project_Id,
126 p_bill_to_site_use_id => P_Bill_to_site_use_id,
127 p_ship_to_site_use_id => P_Ship_to_site_use_id,
128 p_project_customer_id => P_Customer_Id,
129 p_set_of_books_id => P_Sets_of_books_id,
130 p_expenditure_item_id => P_Expenditure_item_id,
131 /*p_trx_date => trunc(sysdate), */
132 p_trx_date => trunc(P_invoice_date), /* Sending trx_date as inv_date for bug 5484859 */
133 p_event_id => P_Event_id,
134 p_line_type => l_line_type,
135 p_request_id => P_Request_id,
136 p_user_id => P_User_Id,
137 p_tax_classification_code => l_tax_code,
138 p_bill_to_customer_id => Pbill_to_customer_id,
139 p_ship_to_customer_id => Pship_to_customer_id,
140 p_application_id => 275,
141 p_internal_organization_id => l_org_id
142 );
143
144 IF g1_debug_mode = 'Y' THEN
145 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' done ZX_AR_TAX_CLASSIFICATN_DEF_PKG' );
146 PA_MCB_INVOICE_PKG.log_message('p_tax_classification_code : ' || l_tax_code );
147 END IF;
148 -- If Tax_code is null , Return from the procedure
149 X_Output_tax_exempt_flag := 'S'; /* added this for bug 7229135*/
150 If l_tax_code IS NULL
151 Then
152 -- X_Output_vat_tax_id := NULL; --commented by hsiu
153 -- X_Output_tax_exempt_flag := 'S'; commented this for bug 7229135
154 X_Output_tax_exempt_number := NULL;
155 X_Output_exempt_reason_code := NULL;
156 Return;
157 ELSE
158 x_output_tax_code := l_tax_code;
159 End If;
160
161 -- Call Exemption API to get the exemption information
162
163 /*Added the two parameters bill_to_customer_id and ship_to_customer_id
164 for customer account relation enhancement bug no 2760630*/
165 /*
166 IF g1_debug_mode = 'Y' THEN
167 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' calling ARP_STAX' );
168 END IF;
169
170
171
172 ARP_STAX.find_tax_exemption_id
173 (
174 bill_to_customer_id => Pbill_to_customer_id,
175 ship_to_customer_id => Pship_to_customer_id,
176 ship_to_site_id => P_Ship_to_site_use_id,
177 tax_code => l_tax_code,
178 inventory_item_id => NULL,
179 tax_exempt_flag => 'S',
180 trx_date => trunc(sysdate),
181 reason_code => l_reason_code,
182 certificate => l_certificate_no,
183 percent_exempt => l_percent_exempt,
184 inserted_flag => l_inserted_flag,
185 exemption_type => l_exemption_type,
186 tax_exemption_id => l_exemption_id);
187 */
188
189 IF g1_debug_mode = 'Y' THEN
190 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' getting bill party info' );
191 END IF;
192
193 select hz_c.party_id, hz_cs.party_site_id, pc.bill_to_address_id
194 into l_bill_to_party_id, l_bill_to_party_site_id, l_bill_to_address_id
195 from hz_cust_accounts hz_c, hz_cust_acct_sites hz_cs, pa_project_customers pc
196 where pc.project_id = p_project_id
197 and pc.customer_id = p_customer_id
198 and hz_cs.cust_acct_site_id = pc.bill_to_address_id
199 and hz_c.cust_account_id = p_customer_id;
200
201 IF g1_debug_mode = 'Y' THEN
202 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || 'bill partyid :' ||
203 l_bill_to_party_id || ';bill party site id :' ||
204 l_bill_to_party_site_id || ';bill address id :' || l_bill_to_address_id);
205
206 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' getting ship party info' );
207 END IF;
208
209 select hz_c.party_id, hz_cs.party_site_id, pc.ship_to_address_id
210 into l_ship_to_party_id, l_ship_to_party_site_id, l_ship_to_address_id
211 from hz_cust_accounts hz_c, hz_cust_acct_sites hz_cs, pa_project_customers pc
212 where pc.project_id = p_project_id
213 and pc.customer_id = p_customer_id
214 and hz_cs.cust_acct_site_id = pc.ship_to_address_id
215 and hz_c.cust_account_id = p_customer_id;
216
217 IF g1_debug_mode = 'Y' THEN
218 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || 'ship partyid :' ||
219 l_ship_to_party_id || ';ship party site id :' ||
220 l_ship_to_party_site_id || ';ship address id :' || l_ship_to_address_id);
221 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' calling get_btch_src_trans_type' );
222 END IF;
223
224 get_btch_src_trans_type ( p_project_id => p_project_id,
225 p_draft_invoice_num => p_draft_inv_num,
226 p_draft_inv_num_credited => p_draft_inv_num_credited,
227 x_transaction_type_id => l_transaction_type_id,
228 x_batch_source_id => l_batch_source_id,
229 x_return_status => l_return_status);
230
231 IF g1_debug_mode = 'Y' THEN
232
233 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' done get_btch_src_trans_type' );
234 PA_MCB_INVOICE_PKG.log_message('return status : ' || l_return_status );
235
236 END IF;
237
238 get_legal_entity_id (p_customer_id => nvl(Pbill_to_customer_id, p_customer_id),
239 p_org_id => l_org_id,
240 p_transaction_type_id => l_transaction_type_id,
241 p_batch_source_id => l_batch_source_id,
242 x_legal_entity_id => l_legal_entity_id,
243 x_return_status => l_return_status);
244
245 IF g1_debug_mode = 'Y' THEN
246
247 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' done get_legal_entity_id' );
248 PA_MCB_INVOICE_PKG.log_message('return status : ' || l_return_status );
249
250 END IF;
251
252 IF g1_debug_mode = 'Y' THEN
253
254 PA_MCB_INVOICE_PKG.log_message('=====Parameters for get_default_exemptions====' );
255 PA_MCB_INVOICE_PKG.log_message('p_bill_to_cust_acct_id' || Pbill_to_customer_id );
256 PA_MCB_INVOICE_PKG.log_message('p_ship_to_cust_acct_id' || Pship_to_customer_id );
257 PA_MCB_INVOICE_PKG.log_message('p_ship_to_site_use_id' || P_ship_to_site_use_id );
258 PA_MCB_INVOICE_PKG.log_message('p_bill_to_site_use_id' || P_bill_to_site_use_id );
259 PA_MCB_INVOICE_PKG.log_message('p_bill_to_party_id' || l_bill_to_party_id );
260 PA_MCB_INVOICE_PKG.log_message('p_bill_to_party_site_id' || l_bill_to_party_site_id );
261 PA_MCB_INVOICE_PKG.log_message('p_ship_to_party_site_id' || l_ship_to_party_site_id );
262 PA_MCB_INVOICE_PKG.log_message('p_legal_entity_id' || l_legal_entity_id );
263 PA_MCB_INVOICE_PKG.log_message('p_org_id' || l_org_id );
264 PA_MCB_INVOICE_PKG.log_message('p_trx_date' || trunc(sysdate) );
265 PA_MCB_INVOICE_PKG.log_message('p_exempt_certificate_number' || l_certificate_no );
266 PA_MCB_INVOICE_PKG.log_message('p_reason_code' || l_reason_code );
267
268
269 END IF;
270
271 /* Commenting for bug 7187173 as PA only deals with PRIMARY exemptions (p_exempt_control_flag='S')
272 All other cases of exepmtions will be handled by the ETax code while deriving Tax information
273 in Receivables.
274
275 ZX_TCM_GET_DEF_EXEMPTION.get_default_exemptions
276 (p_bill_to_cust_acct_id => Pbill_to_customer_id,
277 p_ship_to_cust_acct_id => Pship_to_customer_id,
278 p_ship_to_site_use_id => p_ship_to_site_use_id,
279 p_bill_to_site_use_id => p_bill_to_site_use_id,
280 p_bill_to_party_id => l_bill_to_party_id,
281 p_bill_to_party_site_id => l_bill_to_party_site_id,
282 p_ship_to_party_site_id => l_ship_to_party_site_id,
283 p_legal_entity_id => l_legal_entity_id,
284 p_org_id => l_org_id,
285 p_trx_date => trunc(sysdate),
286 p_exempt_certificate_number => l_certificate_no,
287 p_reason_code => l_reason_code,
288 p_exempt_control_flag => 'S',
289 p_inventory_org_id => NULL,
290 p_inventory_item_id => NULL ,
291 x_return_status => l_return_status ,
292 x_exemption_rec_tbl => l1_exemption_rec_tbl);
293
294 IF g1_debug_mode = 'Y' THEN
295
296 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' done get_default_exemptions' );
297 PA_MCB_INVOICE_PKG.log_message('return status : ' || l_return_status );
298 PA_MCB_INVOICE_PKG.log_message('exemption_rec_tbl count:' || l1_exemption_rec_tbl.COUNT );
299
300 END IF;
301
302 IF l1_exemption_rec_tbl.COUNT > 0 THEN
303
304 IF g1_debug_mode = 'Y' THEN
305
306 PA_MCB_INVOICE_PKG.log_message('tax exempt id :' || l1_exemption_rec_tbl(1).tax_exemption_id);
307 PA_MCB_INVOICE_PKG.log_message('exmpt cert no :' || l1_exemption_rec_tbl(1).exempt_certificate_number );
308 PA_MCB_INVOICE_PKG.log_message('exmpt reason code :' || l1_exemption_rec_tbl(1).exempt_reason_code );
309
310 END IF;
311 l_exemption_id := l1_exemption_rec_tbl(1).tax_exemption_id;
312 l_certificate_no := l1_exemption_rec_tbl(1).exempt_certificate_number;
313 l_reason_code := l1_exemption_rec_tbl(1).exempt_reason_code;
314
315 ELSE
316
317 l_exemption_id := NULL;
318
319 END IF;
320 -- Assign Tax Code to output
321
322 -- X_Output_vat_tax_id := l_vat_tax_id; --commented by hsiu
323
324 -- If No exemption exist
325 If l_exemption_id IS NULL
326 Then
327 X_Output_tax_exempt_flag := 'S';
328 X_Output_tax_exempt_number := NULL;
329 X_Output_exempt_reason_code := NULL;
330 Else
331 -- If Exemption exists
332 X_Output_tax_exempt_flag := 'E';
333 X_Output_tax_exempt_number := l_certificate_no;
334 X_Output_exempt_reason_code := l_reason_code;
335 End If;
336 end Commenting for bug 7187173 */
337
338 EXCEPTION
339 When OTHERS Then
340 X_Output_tax_exempt_flag := NULL; --NOCOPY
341 X_Output_tax_exempt_number := NULL; --NOCOPY
342 X_Output_exempt_reason_code := NULL; --NOCOPY
343 X_Output_tax_code := NULL; --NOCOPY
344 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || SQLERRM );
345 Raise;
346 END GET_DEFAULT_TAX_INFO;
347
348 /* Overloaded procedure added for Customer Relationship Management enhancement */
349 PROCEDURE GET_DEFAULT_TAX_INFO
350 ( P_Project_Id IN NUMBER ,
351 P_Draft_Inv_Num IN NUMBER ,
352 P_Customer_Id IN NUMBER ,
353 P_Bill_to_site_use_id IN NUMBER ,
354 P_Ship_to_site_use_id IN NUMBER ,
355 P_Sets_of_books_id IN NUMBER ,
356 P_Event_id IN NUMBER ,
357 P_Expenditure_item_id IN NUMBER ,
358 P_User_Id IN NUMBER ,
359 P_Request_id IN NUMBER ,
360 X_Output_tax_exempt_flag OUT NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
361 X_Output_tax_exempt_number OUT NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
362 X_Output_exempt_reason_code OUT NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
363 X_Output_Tax_code OUT NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
364 P_invoice_date IN DATE default SYSDATE) /* bug 5484859 */
365 Is
366 new_excp exception;
367 Begin
368
369 Raise new_excp;
370
371 End GET_DEFAULT_TAX_INFO;
372
373 /*ADDED OVERLOADED PROCEDURE*/
374
375 PROCEDURE MARK_CUST_REV_DIST_LINES (
376 P_Project_Id IN NUMBER ,
377 P_Draft_Inv_Num IN NUMBER ,
378 P_Customer_Id IN NUMBER ,
379 P_agreement_id IN NUMBER ,
380 P_Bill_to_site_use_id IN NUMBER ,
381 P_Ship_to_site_use_id IN NUMBER ,
382 P_Sets_of_books_id IN NUMBER ,
383 P_Expenditure_item_id IN PA_PLSQL_DATATYPES.IdTabTyp,
384 P_Line_num IN PA_PLSQL_DATATYPES.IdTabTyp,
385 P_User_Id IN NUMBER ,
386 P_Request_id IN NUMBER ,
387 P_No_of_rec IN NUMBER ,
388 X_Rec_upd OUT NOCOPY NUMBER, --File.Sql.39 bug 4440895
389 P_bill_trans_currency_code IN PA_PLSQL_DATATYPES.Char30TabTyp,
390 P_bill_trans_invoice_amount IN PA_PLSQL_DATATYPES.Char30TabTyp,
391 P_bill_trans_bill_amount IN PA_PLSQL_DATATYPES.Char30TabTyp,
392 P_invproc_invoice_amount IN OUT NOCOPY PA_PLSQL_DATATYPES.Char30TabTyp,
393 P_invproc_bill_amount IN OUT NOCOPY PA_PLSQL_DATATYPES.Char30TabTyp,
394 p_retention_percentage IN VARCHAR2,
395 P_status_code IN OUT NOCOPY PA_PLSQL_DATATYPES.Char30TabTyp,
396 P_invoice_date IN VARCHAR2,
397 x_return_status IN OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
398 )
399 IS
400 new_excp exception;
401 Begin
402
403 Raise new_excp;
404
405 END MARK_CUST_REV_DIST_LINES;
406 /*END OF OVERLOADED PROCEDURE*/
407 /*Added the two parameters bill_to_customer_id and ship_to_customer_id
408 for customer account relation enhancement bug no 2760630*/
409 PROCEDURE MARK_CUST_REV_DIST_LINES (
410 P_Project_Id IN NUMBER ,
411 P_Draft_Inv_Num IN NUMBER ,
412 P_Customer_Id IN NUMBER ,
413 P_agreement_id IN NUMBER ,
414 P_Bill_to_site_use_id IN NUMBER ,
415 P_Ship_to_site_use_id IN NUMBER ,
416 P_Sets_of_books_id IN NUMBER ,
417 P_Expenditure_item_id IN PA_PLSQL_DATATYPES.IdTabTyp,
418 P_Line_num IN PA_PLSQL_DATATYPES.IdTabTyp,
419 P_User_Id IN NUMBER ,
420 P_Request_id IN NUMBER ,
421 P_No_of_rec IN NUMBER ,
422 X_Rec_upd OUT NOCOPY NUMBER, --File.Sql.39 bug 4440895
423 P_bill_trans_currency_code IN PA_PLSQL_DATATYPES.Char30TabTyp,
424 P_bill_trans_invoice_amount IN PA_PLSQL_DATATYPES.Char30TabTyp,
425 P_bill_trans_bill_amount IN PA_PLSQL_DATATYPES.Char30TabTyp,
426 P_invproc_invoice_amount IN OUT NOCOPY PA_PLSQL_DATATYPES.Char30TabTyp,
427 P_invproc_bill_amount IN OUT NOCOPY PA_PLSQL_DATATYPES.Char30TabTyp,
428 p_retention_percentage IN VARCHAR2,
429 P_status_code IN OUT NOCOPY PA_PLSQL_DATATYPES.Char30TabTyp,
430 P_invoice_date IN VARCHAR2,
431 Pbill_to_customer_id IN NUMBER,
432 Pship_to_customer_id IN NUMBER,
433 P_shared_funds_consumption IN NUMBER, /* Federal */
434 P_expenditure_item_date IN PA_PLSQL_DATATYPES.Char30TabTyp, /* Federal */
435 x_return_status IN OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
436 )
437 IS
438 loop_index NUMBER;
439 l_count NUMBER := 0;
440 l_Output_vat_tax_id NUMBER;
441 l_output_tax_code VARCHAR2(30); --added by hsiu for eTax changes
442 l_Output_tax_exempt_flag VARCHAR2(1);
443 --Modified for Bug3128094
444 l_Output_tax_exempt_number VARCHAR2(80);
445 l_Output_exempt_reason_code VARCHAR2(30);
446 --till here for Bug3128094
447
448 -- MCB Related Variables
449
450 l_multi_currency_billing_flag VARCHAR2(1);
451 l_baseline_funding_flag VARCHAR2(1);
452 l_revproc_currency_code VARCHAR2(30);
453 l_invproc_currency_code VARCHAR2(30);
454 l_project_currency_code VARCHAR2(30);
455 l_project_rate_date_code VARCHAR2(30);
456 l_project_rate_type VARCHAR2(30);
457 l_project_rate_date DATE;
458 l_project_exchange_rate NUMBER;
459 l_projfunc_currency_code VARCHAR2(30);
460 l_projfunc_rate_date_code VARCHAR2(30);
461 l_projfunc_rate_type VARCHAR2(30);
462 l_projfunc_rate_date DATE;
463 l_projfunc_exchange_rate NUMBER;
464 l_funding_rate_date_code VARCHAR2(30);
465 l_funding_rate_type VARCHAR2(30);
466 l_funding_rate_date DATE;
467 l_funding_exchange_rate NUMBER;
468 l_funding_currency_code VARCHAR2(30);
469 l_return_status VARCHAR2(30);
470 l_msg_count NUMBER;
471 l_msg_data VARCHAR2(240);
472
473
474 tmp_denominator_tab PA_PLSQL_DATATYPES.NumTabTyp;
475 tmp_numerator_tab PA_PLSQL_DATATYPES.NumTabTyp;
476 tmp_rate_tab PA_PLSQL_DATATYPES.NumTabTyp;
477 tmp_user_validate_flag_tab PA_PLSQL_DATATYPES.Char30TabTyp;
478
479 tmp_status_project_tab PA_PLSQL_DATATYPES.Char30TabTyp;
480 tmp_status_projfunc_tab PA_PLSQL_DATATYPES.Char30TabTyp;
481 tmp_status_funding_tab PA_PLSQL_DATATYPES.Char30TabTyp;
482 tmp_status_tab PA_PLSQL_DATATYPES.Char30TabTyp;
483
484 tmp_project_bill_amount PA_PLSQL_DATATYPES.NumTabTyp;
485 tmp_projfunc_bill_amount PA_PLSQL_DATATYPES.NumTabTyp;
486 tmp_funding_bill_amount PA_PLSQL_DATATYPES.NumTabTyp;
487 tmp_invproc_bill_amount PA_PLSQL_DATATYPES.NumTabTyp;
488 tmp_bill_trans_bill_amount PA_PLSQL_DATATYPES.NumTabTyp;
489
490 tmp_project_exchange_rate PA_PLSQL_DATATYPES.NumTabTyp;
491 tmp_projfunc_exchange_rate PA_PLSQL_DATATYPES.NumTabTyp;
492 tmp_funding_exchange_rate PA_PLSQL_DATATYPES.NumTabTyp;
493 tmp_invproc_exchange_rate PA_PLSQL_DATATYPES.NumTabTyp;
494
495 tmp_project_rate_type PA_PLSQL_DATATYPES.Char30TabTyp;
496 tmp_projfunc_rate_type PA_PLSQL_DATATYPES.Char30TabTyp;
497 tmp_invproc_rate_type PA_PLSQL_DATATYPES.Char30TabTyp;
498 tmp_funding_rate_type PA_PLSQL_DATATYPES.Char30TabTyp;
499
500 tmp_project_rate_date PA_PLSQL_DATATYPES.DateTabTyp;
501 tmp_projfunc_rate_date PA_PLSQL_DATATYPES.DateTabTyp;
502 tmp_funding_rate_date PA_PLSQL_DATATYPES.DateTabTyp;
503 tmp_invproc_rate_date PA_PLSQL_DATATYPES.DateTabTyp;
504
505 tmp_project_currency_code PA_PLSQL_DATATYPES.Char30TabTyp;
506 tmp_funding_currency_code PA_PLSQL_DATATYPES.Char30TabTyp;
507 tmp_projfunc_currency_code PA_PLSQL_DATATYPES.Char30TabTyp;
508 tmp_invproc_currency_code PA_PLSQL_DATATYPES.Char30TabTyp;
509 tmp_invproc_currency_type VARCHAR2(30);
510
511 tmp_invoice_eligible_flag VARCHAR2(1) :='Y';
512
513 l_request_id NUMBER:= fnd_global.conc_request_id;
514 l_program_id NUMBER:= fnd_global.conc_program_id;
515 l_program_application_id NUMBER:= fnd_global.prog_appl_id;
516 l_program_update_date DATE := sysdate;
517 l_retention_percentage NUMBER:= NVL(TO_NUMBER(p_retention_percentage),0);
518 l_err_count NUMBER := 0;
519
520
521 /* Federal Changes */
522
523 l_agreement_start_date DATE;
524 l_agreement_exp_date DATE;
525 tmp_expenditure_item_date PA_PLSQL_DATATYPES.DateTabTyp;
526
527 BEGIN
528
529 -- Multicurrency Related Changes
530 -- Convert the Bill Transaction Curreny to IPC
531
532 -- Get the Project level defaults
533 IF g1_debug_mode = 'Y' THEN
534 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' Inside MARK_CUST_REV_DIST_LINES');
535 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' Call PA_MULTI_CURRENCY_BILLING.get_project_defaults');
536 END IF;
537
538 PA_MULTI_CURRENCY_BILLING.get_project_defaults (
539 p_project_id => p_project_id,
540 x_multi_currency_billing_flag => l_multi_currency_billing_flag,
541 x_baseline_funding_flag => l_baseline_funding_flag,
542 x_revproc_currency_code => l_revproc_currency_code,
543 x_invproc_currency_type => tmp_invproc_currency_type,
544 x_invproc_currency_code => l_invproc_currency_code,
545 x_project_currency_code => l_project_currency_code,
546 x_project_bil_rate_date_code => l_project_rate_date_code,
547 x_project_bil_rate_type => l_project_rate_type,
548 x_project_bil_rate_date => l_project_rate_date,
549 x_project_bil_exchange_rate => l_project_exchange_rate,
550 x_projfunc_currency_code => l_projfunc_currency_code,
551 x_projfunc_bil_rate_date_code => l_projfunc_rate_date_code,
552 x_projfunc_bil_rate_type => l_projfunc_rate_type,
553 x_projfunc_bil_rate_date => l_projfunc_rate_date,
554 x_projfunc_bil_exchange_rate => l_projfunc_exchange_rate,
555 x_funding_rate_date_code => l_funding_rate_date_code,
556 x_funding_rate_type => l_funding_rate_type,
557 x_funding_rate_date => l_funding_rate_date,
558 x_funding_exchange_rate => l_funding_exchange_rate,
559 x_return_status => l_return_status,
560 x_msg_count => l_msg_count,
561 x_msg_data => l_msg_data);
562
563 IF l_funding_currency_code IS NULL THEN
564
565 IF g1_debug_mode = 'Y' THEN
566 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' Get Funding Currency Code ');
567 END IF;
568
569 BEGIN
570
571
572 /* Federal Changes : Added start date and expiry date */
573
574 SELECT agreement_currency_code,
575 nvl(start_date,to_date('01/01/1952', 'DD/MM/YYYY')),
576 nvl(expiration_date,sysdate)
577 INTO l_funding_currency_code,
578 l_agreement_start_date, l_agreement_exp_date
579 FROM PA_AGREEMENTS_ALL
580 WHERE agreement_id = p_agreement_id;
581
582 IF g1_debug_mode = 'Y' THEN
583 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || 'Funding Currency Code : ' || l_funding_currency_code);
584 END IF;
585
586 EXCEPTION
587
588 WHEN NO_DATA_FOUND THEN
589 IF g1_debug_mode = 'Y' THEN
590 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' Oracle Error NO DATA FOUND');
591 END IF;
592 RAISE ;
593 END ;
594
595 END IF;
596
597
598 IF g1_debug_mode = 'Y' THEN
599 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' Loop Begins for ' || P_No_of_rec);
600 END IF;
601
602 FOR loop_index in 1..P_No_of_rec LOOP
603
604 tmp_project_currency_code(loop_index) := l_project_currency_code;
605 tmp_project_rate_type(loop_index) := l_project_rate_type;
606 tmp_project_exchange_rate(loop_index) := l_project_exchange_rate;
607
608 IF l_project_rate_date_code ='FIXED' THEN
609 tmp_project_rate_date(loop_index) := l_project_rate_date;
610 ELSE
611 if l_project_rate_date IS NULL THEN
612 tmp_project_rate_date(loop_index) := TO_DATE(p_invoice_date,'YYYY/MM/DD');
613 else
614 tmp_project_rate_date(loop_index) := l_project_rate_date;
615 end if;
616 END IF;
617
618
619 tmp_projfunc_currency_code(loop_index) := l_projfunc_currency_code;
620 tmp_projfunc_rate_type(loop_index) := l_projfunc_rate_type;
621 tmp_projfunc_exchange_rate(loop_index) := l_projfunc_exchange_rate;
622
623 IF l_projfunc_rate_date_code ='FIXED' THEN
624 tmp_projfunc_rate_date(loop_index) := l_projfunc_rate_date;
625 ELSE
626 if l_projfunc_rate_date IS NULL THEN
627 tmp_projfunc_rate_date(loop_index) := TO_DATE(p_invoice_date,'YYYY/MM/DD');
628 else
629 tmp_projfunc_rate_date(loop_index) := l_projfunc_rate_date;
630 end if;
631 END IF;
632
633
634 tmp_funding_currency_code(loop_index) := l_funding_currency_code;
635 tmp_funding_rate_type(loop_index) := l_funding_rate_type;
636 tmp_funding_exchange_rate(loop_index) := l_funding_exchange_rate;
637
638 IF l_funding_rate_date_code ='FIXED' THEN
639 tmp_funding_rate_date(loop_index) := l_funding_rate_date;
640 ELSE
641 if l_funding_rate_date IS NULL THEN
642 tmp_funding_rate_date(loop_index) := TO_DATE(p_invoice_date,'YYYY/MM/DD');
643 else
644 tmp_funding_rate_date(loop_index) := l_funding_rate_date;
645 end if;
646 END IF;
647
648
649 tmp_denominator_tab(loop_index) :=0;
650 tmp_numerator_tab(loop_index) :=0;
651 tmp_rate_tab(loop_index) :=0;
652 tmp_user_validate_flag_tab(loop_index):='N';
653 tmp_status_project_tab(loop_index) :='N';
654 tmp_status_projfunc_tab(loop_index) :='N';
655 tmp_status_funding_tab(loop_index) := 'N';
656 tmp_status_tab(loop_index) := 'N';
657
658 tmp_project_bill_amount(loop_index) :=0;
659 tmp_projfunc_bill_amount(loop_index) :=0;
660 tmp_invproc_bill_amount(loop_index) :=0;
661 tmp_funding_bill_amount(loop_index) :=0;
662 tmp_bill_trans_bill_amount(loop_index):= TO_NUMBER(p_bill_trans_invoice_amount(loop_index));
663 tmp_expenditure_item_date(loop_index) := TO_DATE(p_expenditure_item_date(loop_index),'YYYY/MM/DD'); /* Federal Changes */
664
665
666 IF tmp_invproc_currency_type = 'FUNDING_CURRENCY' THEN
667 tmp_invproc_rate_type(loop_index) := tmp_funding_rate_type(loop_index);
668 tmp_invproc_rate_date(loop_index) := tmp_funding_rate_date(loop_index);
669 tmp_invproc_exchange_rate(loop_index) := tmp_funding_exchange_rate(loop_index);
670 tmp_invproc_currency_code(loop_index) := tmp_funding_currency_code(loop_index);
671 ELSIF tmp_invproc_currency_type = 'PROJECT_CURRENCY' THEN
672 tmp_invproc_rate_type(loop_index) := tmp_project_rate_type(loop_index);
673 tmp_invproc_rate_date(loop_index) := tmp_project_rate_date(loop_index);
674 tmp_invproc_exchange_rate(loop_index) := tmp_project_exchange_rate(loop_index);
675 tmp_invproc_currency_code(loop_index) := tmp_project_currency_code(loop_index);
676 ELSIF tmp_invproc_currency_type = 'PROJFUNC_CURRENCY' THEN
677 tmp_invproc_rate_type(loop_index) := tmp_projfunc_rate_type(loop_index);
678 tmp_invproc_rate_date(loop_index) := tmp_projfunc_rate_date(loop_index);
679 tmp_invproc_exchange_rate(loop_index) := tmp_projfunc_exchange_rate(loop_index);
680 tmp_invproc_currency_code(loop_index) := tmp_projfunc_currency_code(loop_index);
681 END IF;
682
683
684 END LOOP;
685
686 IF p_bill_trans_currency_code.COUNT <> 0 THEN
687
688 -- Convert the bill transaction currecy to PFC
689 IF g1_debug_mode = 'Y' THEN
690 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' Conversion CALL for BTC to PF ');
691 END IF;
692
693 PA_MULTI_CURRENCY_BILLING.convert_amount_bulk (
694 p_from_currency_tab => p_bill_trans_currency_code,
695 p_to_currency_tab => tmp_projfunc_currency_code,
696 p_conversion_date_tab => tmp_projfunc_rate_date,
697 p_conversion_type_tab => tmp_projfunc_rate_type,
698 p_amount_tab => tmp_bill_trans_bill_amount,
699 p_user_validate_flag_tab => tmp_user_validate_flag_tab,
700 p_converted_amount_tab => tmp_projfunc_bill_amount,
701 p_denominator_tab => tmp_denominator_tab,
702 p_numerator_tab => tmp_numerator_tab,
703 p_rate_tab => tmp_projfunc_exchange_rate,
704 x_status_tab => tmp_status_projfunc_tab,
705 p_conversion_between => 'BTC_PF',
706 p_cache_flag =>'Y');
707
708 IF l_project_currency_code = l_projfunc_currency_code then
709
710 IF g1_debug_mode = 'Y' THEN
711 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || 'Proj curr = Proj func currency ..Copy ' );
712 END IF;
713
714 FOR i IN tmp_status_projfunc_tab.FIRST..tmp_status_projfunc_tab.LAST LOOP
715
716 tmp_project_rate_date(i) := tmp_projfunc_rate_date(i);
717 tmp_project_rate_type(i) := tmp_projfunc_rate_type(i);
718 tmp_project_bill_amount(i) := tmp_projfunc_bill_amount(i);
719 tmp_project_exchange_rate(i) := tmp_projfunc_exchange_rate(i);
720 tmp_status_project_tab(i) := tmp_status_projfunc_tab(i);
721
722 END LOOP;
723
724 else
725
726 -- Convert the bill transaction currecy to PC
727 IF g1_debug_mode = 'Y' THEN
728 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' Conversion CALL for BTC to PC ');
729 END IF;
730
731 PA_MULTI_CURRENCY_BILLING.convert_amount_bulk(
732 p_from_currency_tab => p_bill_trans_currency_code,
733 p_to_currency_tab => tmp_project_currency_code,
734 p_conversion_date_tab => tmp_project_rate_date,
735 p_conversion_type_tab => tmp_project_rate_type,
736 p_amount_tab => tmp_bill_trans_bill_amount,
737 p_user_validate_flag_tab => tmp_user_validate_flag_tab,
738 p_converted_amount_tab => tmp_project_bill_amount,
739 p_denominator_tab => tmp_denominator_tab,
740 p_numerator_tab => tmp_numerator_tab,
741 p_rate_tab => tmp_project_exchange_rate,
742 x_status_tab => tmp_status_project_tab,
743 p_conversion_between => 'BTC_PC',
744 p_cache_flag =>'Y');
745 end if;
746
747 IF l_funding_currency_code = l_projfunc_currency_code then
748
749 IF g1_debug_mode = 'Y' THEN
750 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || 'Fund curr = Proj func currency ..Copy ' );
751 END IF;
752
753 FOR i IN tmp_status_projfunc_tab.FIRST..tmp_status_projfunc_tab.LAST LOOP
754
755 tmp_funding_rate_date(i) := tmp_projfunc_rate_date(i);
756 tmp_funding_rate_type(i) := tmp_projfunc_rate_type(i);
757 tmp_funding_bill_amount(i) := tmp_projfunc_bill_amount(i);
758 tmp_funding_exchange_rate(i) := tmp_projfunc_exchange_rate(i);
759 tmp_status_funding_tab(i) := tmp_status_projfunc_tab(i);
760
761 END LOOP;
762
763 elsif l_funding_currency_code = l_project_currency_code then
764
765 IF g1_debug_mode = 'Y' THEN
766 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || 'funding curr = Proj currency ..Copy ' );
767 END IF;
768
769 FOR i IN tmp_status_project_tab.FIRST..tmp_status_project_tab.LAST LOOP
770
771 tmp_funding_rate_date(i) := tmp_project_rate_date(i);
772 tmp_funding_rate_type(i) := tmp_project_rate_type(i);
773 tmp_funding_bill_amount(i) := tmp_project_bill_amount(i);
774 tmp_funding_exchange_rate(i) := tmp_project_exchange_rate(i);
775 tmp_status_funding_tab(i) := tmp_status_project_tab(i);
776
777 END LOOP;
778
779 else
780
781 IF g1_debug_mode = 'Y' THEN
782 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' Conversion CALL for BTC to FC ');
783 END IF;
784
785 PA_MULTI_CURRENCY_BILLING.convert_amount_bulk (
786 p_from_currency_tab => p_bill_trans_currency_code,
787 p_to_currency_tab => tmp_funding_currency_code,
788 p_conversion_date_tab => tmp_funding_rate_date,
789 p_conversion_type_tab => tmp_funding_rate_type,
790 p_amount_tab => tmp_bill_trans_bill_amount,
791 p_user_validate_flag_tab => tmp_user_validate_flag_tab,
792 p_converted_amount_tab => tmp_funding_bill_amount,
793 p_denominator_tab => tmp_denominator_tab,
794 p_numerator_tab => tmp_numerator_tab,
795 p_rate_tab => tmp_funding_exchange_rate,
796 x_status_tab => tmp_status_funding_tab,
797 p_conversion_between => 'BTC_FC',
798 p_cache_flag =>'Y');
799
800 tmp_denominator_tab.delete;
801 tmp_numerator_tab.delete;
802 end if;
803
804 /* Set the Invoice Processing Currency */
805
806 IF tmp_invproc_currency_type = 'FUNDING_CURRENCY' THEN
807
808
809 IF g1_debug_mode = 'Y' THEN
810 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' invcurr = fund curr');
811 END IF;
812 FOR i IN 1..tmp_status_project_tab.COUNT LOOP
813
814 tmp_invproc_bill_amount(i) := tmp_funding_bill_amount(i);
815 tmp_invproc_exchange_rate(i) := tmp_funding_exchange_rate(i);
816 tmp_invproc_rate_date(i) := tmp_funding_rate_date(i);
817 tmp_invproc_rate_type(i) := tmp_funding_rate_type(i);
818 tmp_invproc_currency_code(i) := tmp_funding_currency_code(i);
819
820 END LOOP;
821
822 ELSIF tmp_invproc_currency_type = 'PROJECT_CURRENCY' THEN
823
824 -- Invoice Processing is PC
825 -- Move the Project Currency Amount and attributes to Invoice Processing
826
827 IF g1_debug_mode = 'Y' THEN
828 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' invcurr = proj curr');
829 END IF;
830 FOR i IN 1..tmp_status_project_tab.COUNT LOOP
831
832 tmp_invproc_bill_amount(i) := tmp_project_bill_amount(i);
833 tmp_invproc_exchange_rate(i) := tmp_project_exchange_rate(i);
834 tmp_invproc_rate_date(i) := tmp_project_rate_date(i);
835 tmp_invproc_rate_type(i) := tmp_project_rate_type(i);
836 tmp_invproc_currency_code(i) := tmp_project_currency_code(i);
837
838 END LOOP;
839
840 ELSIF tmp_invproc_currency_type = 'PROJFUNC_CURRENCY' THEN
841
842 -- Invoice Processing is PFC
843 -- Move the Project Functional Currency Amount and attributes to Invoice Processing
844
845 IF g1_debug_mode = 'Y' THEN
846 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' invcurr = projfunc curr');
847 END IF;
848 FOR i IN 1..tmp_status_project_tab.COUNT LOOP
849
850 tmp_invproc_bill_amount(i) := tmp_projfunc_bill_amount(i);
851 tmp_invproc_exchange_rate(i) := tmp_projfunc_exchange_rate(i);
852 tmp_invproc_rate_date(i) := tmp_projfunc_rate_date(i);
853 tmp_invproc_rate_type(i) := tmp_projfunc_rate_type(i);
854 tmp_invproc_currency_code(i) := tmp_projfunc_currency_code(i);
855
856 END LOOP;
857
858 END IF;
859
860 -- Set the Status code array
861
862 IF g1_debug_mode = 'Y' THEN
863 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' setting status tab');
864 END IF;
865 FOR i IN 1..tmp_status_project_tab.COUNT LOOP
866
867 tmp_status_tab(i) := 'N';
868 /*
869 IF NVL(tmp_status_project_tab(i),'N') <> 'N' THEN
870 tmp_status_tab(i):= 'BTC_PROJ'|| tmp_status_project_tab(i);
871 ELSIF NVL(tmp_status_projfunc_tab(i),'N') <> 'N' THEN
872 tmp_status_tab(i):= 'BTC_PROJFUNC_'|| tmp_status_projfunc_tab(i);
873 ELSIF NVL(tmp_status_funding_tab(i),'N') <> 'N' THEN
874 tmp_status_tab(i):= 'BTC_FUNDING'|| tmp_status_funding_tab(i);
875 END IF;
876 */
877 IF g1_debug_mode = 'Y' THEN
878 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || 'proj' || tmp_status_project_tab(i));
879 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || 'projfunc' || tmp_status_projfunc_tab(i));
880 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || 'funding' || tmp_status_funding_tab(i));
881 END IF;
882
883
884 /* Federal changes : begin */
885 IF ((p_shared_funds_consumption = 1) AND
886 (( tmp_expenditure_item_date(i) < l_agreement_start_date) OR
887 ( tmp_expenditure_item_date(i) > l_agreement_exp_date))) THEN
888 tmp_status_tab(i):= 'PA_EI_AGR_DATE_MISMATCH';
889 l_err_count := l_err_count + 1;
890 /* Federal Changes : End */
891 ELSIF NVL(tmp_status_project_tab(i),'N') <> 'N' THEN
892 tmp_status_tab(i):= tmp_status_project_tab(i);
893 l_err_count := l_err_count + 1;
894 ELSIF NVL(tmp_status_projfunc_tab(i),'N') <> 'N' THEN
895 tmp_status_tab(i):= tmp_status_projfunc_tab(i);
896 l_err_count := l_err_count + 1;
897 ELSIF NVL(tmp_status_funding_tab(i),'N') <> 'N' THEN
898 tmp_status_tab(i):= tmp_status_funding_tab(i);
899 l_err_count := l_err_count + 1;
900 END IF;
901
902 END LOOP;
903
904 END IF; /* Process only if the array has records */
905
906 -- End of MCB changes
907
908 IF g1_debug_mode = 'Y' THEN
909 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' calling get default tax info ');
910 END IF;
911 FOR loop_index in 1..P_No_of_rec LOOP
912
913 -- Call Tax API to get the tax Id and Related attribute
914
915 /*Added the two parameters bill_to_customer_id and ship_to_customer_id
916 for customer account relation enhancement bug no 2760630*/
917
918 PA_OUTPUT_TAX.GET_DEFAULT_TAX_INFO
919 ( P_Project_Id => P_Project_Id ,
920 P_Draft_Inv_Num => P_Draft_Inv_Num ,
921 P_Customer_Id => P_Customer_Id,
922 P_Bill_to_site_use_id => P_Bill_to_site_use_id,
923 P_Ship_to_site_use_id => P_Ship_to_site_use_id,
924 P_Sets_of_books_id => P_Sets_of_books_id,
925 P_Event_id => NULL,
926 P_Expenditure_item_id => P_Expenditure_item_id(loop_index),
927 P_User_Id => P_User_Id,
928 P_Request_id => P_Request_id,
929 -- X_Output_vat_tax_id => l_Output_vat_tax_id, --commented by hsiu
930 X_output_tax_code => l_output_tax_code,
931 X_Output_tax_exempt_flag => l_Output_tax_exempt_flag,
932 X_Output_tax_exempt_number => l_Output_tax_exempt_number,
933 X_Output_exempt_reason_code => l_Output_exempt_reason_code,
934 Pbill_to_customer_id => Pbill_to_customer_id,
935 Pship_to_customer_id => Pship_to_customer_id,
936 P_invoice_date => to_date(P_invoice_date,'YYYY/MM/DD')); /* passing invoice date for bug 5484859 */
937
938
939 tmp_invoice_eligible_flag :='Y';
940
941 IF tmp_status_tab(loop_index) <> 'N' THEN
942
943 tmp_invoice_eligible_flag := 'N';
944
945 END IF;
946
947 -- Update the expenditure items
948
949 IF g1_debug_mode = 'Y' THEN
950 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || 'Update RDL and EI');
951 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || 'Expenditure Item ID : ' || P_Expenditure_item_id(loop_index) );
952 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' Funding Amount : ' || tmp_funding_bill_amount(loop_index) );
953 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' Project Amount : ' || tmp_project_bill_amount(loop_index) );
954 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' ProjFunc Amount : ' || tmp_projfunc_bill_amount(loop_index) );
955 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' Status Code : ' || tmp_status_tab(loop_index) );
956 END IF;
957
958 Update PA_CUST_REV_DIST_LINES_ALL
959 Set
960 -- invoice_eligible_flag = tmp_invoice_eligible_flag, for bug 2649243, 2645634
961 -- output_vat_tax_id = l_Output_vat_tax_id, --commented by hsiu
962 output_tax_classification_code = l_output_tax_code,
963 output_tax_exempt_flag = l_Output_tax_exempt_flag,
964 output_tax_exempt_reason_code = l_Output_exempt_reason_code,
965 output_tax_exempt_number = l_Output_tax_exempt_number,
966 project_inv_rate_type =
967 DECODE(tmp_status_tab(loop_index),'N',
968 tmp_project_rate_type(loop_index), NULL),
969 project_inv_rate_date =
970 DECODE(tmp_status_tab(loop_index),'N',
971 --tmp_project_rate_date(loop_index), NULL), --Modified for Bug 3137196
972 decode(tmp_project_rate_type(loop_index), 'User', null, tmp_project_rate_date(loop_index)), NULL),
973 project_inv_exchange_rate =
974 DECODE(tmp_status_tab(loop_index),'N',
975 tmp_project_exchange_rate(loop_index), NULL),
976 project_bill_amount =
977 DECODE(tmp_status_tab(loop_index),'N',
978 tmp_project_bill_amount(loop_index), NULL),
979 projfunc_inv_rate_type =
980 DECODE(tmp_status_tab(loop_index),'N',
981 tmp_projfunc_rate_type(loop_index), NULL),
982 projfunc_inv_rate_date =
983 DECODE(tmp_status_tab(loop_index),'N',
984 --tmp_projfunc_rate_date(loop_index), NULL), --Modified for Bug 3137196
985 decode(tmp_projfunc_rate_type(loop_index), 'User', null, tmp_projfunc_rate_date(loop_index)), NULL),
986 projfunc_inv_exchange_rate =
987 DECODE(tmp_status_tab(loop_index),'N',
988 tmp_projfunc_exchange_rate(loop_index), NULL),
989 projfunc_bill_amount =
990 DECODE(tmp_status_tab(loop_index),'N',
991 tmp_projfunc_bill_amount(loop_index), NULL),
992 invproc_rate_type =
993 DECODE(tmp_status_tab(loop_index),'N',
994 tmp_invproc_rate_type(loop_index), NULL),
995 invproc_rate_date =
996 DECODE(tmp_status_tab(loop_index),'N',
997 --tmp_invproc_rate_date(loop_index), NULL), --Modified for Bug 3137196
998 decode(tmp_invproc_rate_type(loop_index), 'User', null, tmp_invproc_rate_date(loop_index)), NULL),
999 invproc_exchange_rate =
1000 DECODE(tmp_status_tab(loop_index),'N',
1001 tmp_invproc_exchange_rate(loop_index), NULL),
1002 bill_amount =
1003 DECODE(tmp_status_tab(loop_index),'N',
1004 tmp_invproc_bill_amount(loop_index), NULL),
1005 funding_inv_rate_type =
1006 DECODE(tmp_status_tab(loop_index),'N',
1007 tmp_funding_rate_type(loop_index), NULL),
1008 funding_inv_rate_date =
1009 DECODE(tmp_status_tab(loop_index),'N',
1010 --tmp_funding_rate_date(loop_index), NULL), --Modified for Bug 3137196
1011 decode(tmp_funding_rate_type(loop_index), 'User', null, tmp_funding_rate_date(loop_index)), NULL),
1012 funding_inv_exchange_rate =
1013 DECODE(tmp_status_tab(loop_index),'N',
1014 tmp_funding_exchange_rate(loop_index), NULL),
1015 project_currency_code =
1016 DECODE(tmp_status_tab(loop_index),'N',
1017 tmp_project_currency_code(loop_index), NULL),
1018 projfunc_currency_code =
1019 DECODE(tmp_status_tab(loop_index),'N',
1020 tmp_projfunc_currency_code(loop_index), NULL),
1021 invproc_currency_code =
1022 DECODE(tmp_status_tab(loop_index),'N',
1023 tmp_invproc_currency_code(loop_index), NULL),
1024 funding_currency_code =
1025 DECODE(tmp_status_tab(loop_index),'N',
1026 tmp_funding_currency_code(loop_index), NULL),
1027 funding_bill_amount =
1028 DECODE(tmp_status_tab(loop_index),'N',
1029 tmp_funding_bill_amount(loop_index), NULL),
1030 inv_gen_rejection_code = tmp_status_tab(loop_index),
1031 request_id = P_Request_id,
1032 program_id = l_program_id,
1033 program_application_id = l_program_application_id,
1034 program_update_date = l_program_update_date
1035 Where expenditure_item_id = P_Expenditure_item_id(loop_index)
1036 and line_num = P_Line_num(loop_index);
1037
1038 -- Update the update_counter
1039
1040 l_count := l_count + 1;
1041 -- Update the EIs
1042 IF g1_debug_mode = 'Y' THEN
1043 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' updateing ei ');
1044 END IF;
1045 Update PA_EXPENDITURE_ITEMS_ALL
1046 Set
1047 invproc_rate_type =
1048 DECODE(tmp_status_tab(loop_index),'N',
1049 tmp_invproc_rate_type(loop_index), NULL),
1050 invproc_rate_date =
1051 DECODE(tmp_status_tab(loop_index),'N',
1052 --tmp_invproc_rate_date(loop_index), NULL), --Modified for Bug 3137196
1053 decode(tmp_invproc_rate_type(loop_index), 'User', null, tmp_invproc_rate_date(loop_index)), NULL),
1054 invproc_exchange_rate =
1055 DECODE(tmp_status_tab(loop_index),'N',
1056 tmp_invproc_exchange_rate(loop_index), NULL),
1057 bill_amount =
1058 DECODE(tmp_status_tab(loop_index),'N',NVL(bill_amount,0) +
1059 tmp_invproc_bill_amount(loop_index), NULL), --for bug#2251021,
1060 invproc_currency_code =
1061 DECODE(tmp_status_tab(loop_index),'N',
1062 tmp_invproc_currency_code(loop_index), NULL),
1063 projfunc_inv_rate_type =
1064 DECODE(tmp_status_tab(loop_index),'N',
1065 tmp_projfunc_rate_type(loop_index), NULL),
1066 projfunc_inv_rate_date =
1067 DECODE(tmp_status_tab(loop_index),'N',
1068 --tmp_projfunc_rate_date(loop_index), NULL), --Modified for Bug 3137196
1069 decode(tmp_projfunc_rate_type(loop_index), 'User', null, tmp_projfunc_rate_date(loop_index)), NULL),
1070 projfunc_inv_exchange_rate =
1071 DECODE(tmp_status_tab(loop_index),'N',
1072 tmp_projfunc_exchange_rate(loop_index), NULL),
1073 projfunc_bill_amount =
1074 DECODE(tmp_status_tab(loop_index),'N',NVL(projfunc_bill_amount,0) +
1075 tmp_projfunc_bill_amount(loop_index), NULL), --bug2251021
1076 projfunc_currency_code =
1077 DECODE(tmp_status_tab(loop_index),'N',
1078 tmp_projfunc_currency_code(loop_index), NULL),
1079 project_inv_rate_type =
1080 DECODE(tmp_status_tab(loop_index),'N',
1081 tmp_project_rate_type(loop_index), NULL),
1082 project_inv_rate_date =
1083 DECODE(tmp_status_tab(loop_index),'N',
1084 --tmp_project_rate_date(loop_index), NULL), --Modified for Bug 3137196
1085 decode(tmp_project_rate_type(loop_index), 'User', null, tmp_project_rate_date(loop_index)), NULL),
1086 project_inv_exchange_rate =
1087 DECODE(tmp_status_tab(loop_index),'N',
1088 tmp_project_exchange_rate(loop_index), NULL),
1089 project_bill_amount =
1090 DECODE(tmp_status_tab(loop_index),'N',NVL(project_bill_amount,0) +
1091 tmp_project_bill_amount(loop_index), NULL), --bug2251021
1092 inv_gen_rejection_code = tmp_status_tab(loop_index),
1093 request_id = P_Request_id,
1094 program_id = l_program_id,
1095 program_application_id = l_program_application_id,
1096 program_update_date = l_program_update_date
1097 Where expenditure_item_id = P_Expenditure_item_id(loop_index);
1098
1099 End Loop;
1100
1101 IF g1_debug_mode = 'Y' THEN
1102 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || ' equating invproc amounts ');
1103 END IF;
1104
1105
1106
1107 FOR loop_index in 1..P_No_of_rec
1108 LOOP
1109 p_invproc_invoice_amount(loop_index) := TO_CHAR(tmp_invproc_bill_amount(loop_index));
1110
1111 /* Bug 2645634, 2649243 Retention amount should be calculated correctly
1112 This was causing funding */
1113
1114 p_invproc_bill_amount(loop_index) := TO_CHAR(tmp_invproc_bill_amount(loop_index) *
1115 (1- NVL(TO_NUMBER(l_retention_percentage),0)) );
1116 p_status_code(loop_index) := tmp_status_tab(loop_index);
1117
1118 END LOOP;
1119
1120 -- Assign the output value
1121 X_Rec_upd := l_count;
1122 if l_err_count = P_No_of_rec then
1123 x_return_status := 'ALL'; -- All records have errored out b'cos of conversion rate
1124 end if;
1125
1126 EXCEPTION
1127 When Others
1128 Then
1129 IF g1_debug_mode = 'Y' THEN
1130 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || 'Error in MARK_CUST_REV_DIST_LINES ' || sqlerrm);
1131 END IF;
1132
1133 x_return_status := sqlerrm( sqlcode );
1134 IF g1_debug_mode = 'Y' THEN
1135 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: ' || x_return_status);
1136 END IF;
1137
1138 --Raise;
1139
1140 END MARK_CUST_REV_DIST_LINES;
1141
1142 Function IS_AR_INSTALLED( P_Check_prod_installed in varchar2 ,
1143 P_Check_org_installed in varchar2 )
1144 return Varchar2
1145 IS
1146 l_count NUMBER;
1147 l_status VARCHAR2(1);
1148 l_industry VARCHAR2(100);
1149 l_schema VARCHAR2(100);
1150 l_overrid_status VARCHAR2(1);
1151 BEGIN
1152
1153 -- Call AOL API to extract installation information
1154
1155 If NOT FND_INSTALLATION.GET_APP_INFO
1156 ( APPLICATION_SHORT_NAME => 'AR',
1157 STATUS => l_status,
1158 INDUSTRY => l_industry,
1159 ORACLE_SCHEMA => l_schema )
1160 Then
1161 Return('N');
1162 End If;
1163
1164 l_overrid_status := l_status;
1165
1166 -- Bug # 956364 begin
1167
1168 -- Calling Client Extension driver package to get the override installation mode
1169
1170 pa_ar_inst_client_extn.client_extn_driver(l_status,l_overrid_status);
1171
1172 -- Bug 956364 end
1173
1174 --
1175
1176 -- Return the status if only product installion info is required
1177
1178 If (P_Check_prod_installed = 'Y'
1179 and P_Check_org_installed <> 'Y')
1180 Then
1181 If l_status = 'I'
1182 Then
1183 Return('Y');
1184 Else
1185 Return('N');
1186 End If;
1187 End If;
1188
1189 -- Check the product installtion for the current organization setup
1190
1191 If P_Check_org_installed = 'Y'
1192 Then
1193
1194 Select count(*)
1195 Into l_count
1196 From AR_SYSTEM_PARAMETERS;
1197
1198 If l_count = 0
1199 Then
1200 Return('N');
1201 Else
1202 Return('Y');
1203 End If;
1204
1205 End If;
1206
1207 EXCEPTION
1208 When Others
1209 Then
1210 Raise;
1211
1212 END IS_AR_INSTALLED;
1213
1214 -- Function : GET_DRAFT_INVOICE_TAX_AMT
1215 -- Usage : This function will return 0 if invoice is not inter
1216 -- faced to AR, otherwise return tax amount for that
1217 -- invoice.
1218 -- Parameter :
1219 -- P_Trx_Id -Customer Transaction Identifier
1220
1221 Function GET_DRAFT_INVOICE_TAX_AMT( P_Trx_Id in NUMBER )
1222 return Number
1223 AS
1224 l_tax_amout NUMBER;
1225 BEGIN
1226 Select sum(TRX_LINE.EXTENDED_AMOUNT)
1227 Into l_tax_amout
1228 From RA_Customer_Trx_Lines TRX_LINE
1229 Where TRX_LINE.Customer_Trx_Id = P_Trx_Id
1230 And TRX_LINE.Line_Type = 'TAX'
1231 And TRX_LINE.LINK_TO_CUST_TRX_LINE_ID Is Not Null;
1232
1233 Return(l_tax_amout);
1234
1235 EXCEPTION
1236 When Others
1237 Then
1238 Raise;
1239
1240 END GET_DRAFT_INVOICE_TAX_AMT;
1241
1242 /*Added the two parameters bill_to_customer_id and ship_to_customer_id
1243 for customer account relation enhancement bug no 2760630*/
1244
1245 /* For Intercompany Invoice Tax calculation, The following package is
1246 created */
1247
1248 PROCEDURE GET_DEFAULT_TAX_INFO_ARR
1249 ( P_Project_Id IN number ,
1250 P_Customer_Id IN number ,
1251 P_Bill_to_site_use_id IN number ,
1252 P_Ship_to_site_use_id IN number ,
1253 P_Set_of_books_id IN number ,
1254 P_Expenditure_item_id IN PA_PLSQL_DATATYPES.IdTabTyp ,
1255 P_User_Id IN NUMBER ,
1256 P_Request_id IN NUMBER ,
1257 P_No_of_records IN NUMBER ,
1258 P_Compute_flag IN OUT NOCOPY PA_PLSQL_DATATYPES.Char1TabTyp,
1259 P_Error_Code IN OUT NOCOPY PA_PLSQL_DATATYPES.Char30TabTyp,
1260 X_Output_tax_code OUT NOCOPY PA_PLSQL_DATATYPES.Char30TabTyp,
1261 X_Output_tax_exempt_flag OUT NOCOPY PA_PLSQL_DATATYPES.Char1TabTyp,
1262 X_Output_tax_exempt_number OUT NOCOPY PA_PLSQL_DATATYPES.Char30TabTyp,
1263 X_Output_exempt_reason_code OUT NOCOPY PA_PLSQL_DATATYPES.Char80TabTyp,
1264 Pbill_to_customer_id IN NUMBER,
1265 Pship_to_customer_id IN NUMBER)
1266 IS
1267 BEGIN
1268
1269 -- Process for each element of the array for which computation
1270 -- flag is set to Y.
1271
1272 FOR I IN 1..P_No_of_records
1273 LOOP
1274 If P_Compute_flag(I) = 'Y'
1275 Then
1276
1277 -- Call the tax and its attribute determination API for each element
1278 -- of input expenditure array.
1279
1280 /*Added the two parameters bill_to_customer_id and ship_to_customer_id
1281 for customer account relation enhancement bug no 2760630*/
1282
1283 GET_DEFAULT_TAX_INFO
1284 ( P_Project_Id => P_Project_Id,
1285 P_Draft_Inv_Num => NULL,
1286 P_Customer_Id => P_Customer_Id,
1287 P_Bill_to_site_use_id => P_Bill_to_site_use_id,
1288 P_Ship_to_site_use_id => P_Ship_to_site_use_id,
1289 P_Sets_of_books_id => P_Set_of_books_id,
1290 P_Expenditure_item_id => P_Expenditure_item_id(I),
1291 P_User_Id => P_User_Id,
1292 P_Request_id => P_Request_id,
1293 -- X_Output_vat_tax_id => X_Output_vat_tax_id(I), --commented by hsiu
1294 X_output_tax_code => X_output_tax_code(I),
1295 X_Output_tax_exempt_flag => X_Output_tax_exempt_flag(I),
1296 X_Output_tax_exempt_number => X_Output_tax_exempt_number(I),
1297 X_Output_exempt_reason_code=> X_Output_exempt_reason_code(I),
1298 Pbill_to_customer_id => Pbill_to_customer_id,
1299 Pship_to_customer_id => Pship_to_customer_id);
1300
1301 -- If Tax API returns error, set the output error code and set computation
1302 -- flag to 'N'
1303 If pa_tax_client_extn_drv.G_error_Code Is not NULL
1304 Then
1305 P_Error_Code(I) := pa_tax_client_extn_drv.G_error_Code;
1306 P_Compute_flag(I):= 'N';
1307 End if;
1308 End if;
1309 End loop;
1310
1311 Exception
1312
1313 When Others
1314 Then
1315 Raise;
1316
1317 END GET_DEFAULT_TAX_INFO_ARR;
1318
1319 FUNCTION TAXID_2_CODE_CONV (p_org_id in number,
1320 p_tax_id in number)
1321 return varchar2 is
1322
1323 l_tax_code varchar2(50);
1324
1325 begin
1326
1327 select rtrim(tax_classification_code)
1328 into l_tax_code
1329 from zx_id_tcc_mapping_all
1330 where tax_rate_code_id = p_tax_id
1331 and org_id = p_org_id
1332 and tax_class = 'OUTPUT'; -- added for bug 5061887
1333
1334 return l_tax_code;
1335
1336 exception
1337
1338 when others then
1339 l_tax_code := NULL;
1340 return l_tax_code;
1341
1342
1343 end TAXID_2_CODE_CONV;
1344
1345 procedure get_legal_entity_id (p_customer_id IN NUMBER,
1346 p_org_id IN NUMBER,
1347 p_transaction_type_id IN NUMBER,
1348 p_batch_source_id IN NUMBER,
1349 x_legal_entity_id OUT NOCOPY NUMBER,
1350 x_return_status OUT NOCOPY VARCHAR2)
1351 is
1352
1353
1354 l_msg_data varchar2(250);
1355 l_return_status varchar2(30);
1356 l_otoc_le_info xle_businessinfo_grp.otoc_le_rec;
1357
1358 begin
1359
1360 IF g1_debug_mode = 'Y' THEN
1361
1362 PA_MCB_INVOICE_PKG.log_message('GET_DEFAULT_TAX_INFO: in get_legal_entity_id' );
1363 PA_MCB_INVOICE_PKG.log_message('p_customer_id : ' || P_customer_id );
1364 PA_MCB_INVOICE_PKG.log_message('p_org_id : ' || p_org_id );
1365 PA_MCB_INVOICE_PKG.log_message('p_transaction_type_id : ' || P_transaction_type_id );
1366 PA_MCB_INVOICE_PKG.log_message('p_batch_source_id : ' || P_batch_source_id );
1367
1368 PA_MCB_INVOICE_PKG.log_message('calling XLE_BUSINESSINFO_GRP.Get_OrdertoCash_Info ');
1369 END IF;
1370
1371 XLE_BUSINESSINFO_GRP.Get_OrdertoCash_Info(
1372 x_return_status => l_return_status,
1373 x_msg_data => l_msg_data,
1374 P_customer_type => 'BILL_TO',
1375 P_customer_id => p_customer_id,
1376 P_transaction_type_id => p_transaction_type_id,
1377 P_batch_source_id => p_batch_source_id,
1378 P_operating_unit_id => p_org_id,
1379 x_otoc_Le_info => l_otoc_le_info) ;
1380
1381 IF g1_debug_mode = 'Y' THEN
1382
1383 PA_MCB_INVOICE_PKG.log_message('after calling XLE_BUSINESSINFO_GRP.Get_OrdertoCash_Info ');
1384 PA_MCB_INVOICE_PKG.log_message('legal_entity_id : ' || l_otoc_le_info.legal_entity_id );
1385 PA_MCB_INVOICE_PKG.log_message('return status : ' || l_return_status);
1386
1387 PA_MCB_INVOICE_PKG.log_message('msg data : ' || l_msg_data);
1388
1389 END IF;
1390
1391 x_legal_entity_id := l_otoc_le_info.legal_entity_id;
1392 x_return_status := l_return_status;
1393
1394
1395 end get_legal_entity_id;
1396
1397 procedure get_btch_src_trans_type ( p_project_id IN NUMBER,
1398 p_draft_invoice_num IN NUMBER,
1399 p_draft_inv_num_credited IN NUMBER,
1400 x_transaction_type_id out NOCOPY number,
1401 x_batch_source_id out NOCOPY number,
1402 x_return_status OUT NOCOPY varchar2) is
1403
1404 l_business_grp_id number;
1405 l_carry_out_org_id number;
1406 l_org_struct_ver_id number;
1407 l_basic_language_code varchar2(4);
1408 l_p_trx_type_id number;
1409 l_cm_trx_type_id number;
1410 l_error_status number;
1411 l_error_message varchar2(250);
1412 l_p_trx_type varchar2(30);
1413 l_cm_trx_type varchar2(30);
1414 l_batch_source_id number;
1415
1416
1417 l_draft_inv_num_credited number;
1418
1419
1420 begin
1421
1422 IF g1_debug_mode = 'Y' THEN
1423
1424 PA_MCB_INVOICE_PKG.log_message('in get_btch_src_trans_type');
1425 PA_MCB_INVOICE_PKG.log_message('project_id : ' || p_project_id);
1426 PA_MCB_INVOICE_PKG.log_message('draft_invoice_num :' || p_draft_invoice_num );
1427
1428 END IF;
1429
1430 SELECT business_group_id,
1431 proj_org_structure_version_id,
1432 invoice_batch_source_id
1433 INTO l_business_grp_id,
1434 l_org_struct_ver_id,
1435 l_batch_source_id
1436 FROM pa_implementations;
1437
1438
1439 IF g1_debug_mode = 'Y' THEN
1440
1441 PA_MCB_INVOICE_PKG.log_message('business group id : ' || l_business_grp_id);
1442 PA_MCB_INVOICE_PKG.log_message('proj org str vers id :' || l_org_struct_ver_id );
1443 PA_MCB_INVOICE_PKG.log_message('inv btch src id :' || l_batch_source_id );
1444
1445 END IF;
1446
1447 SELECT PROJ.Carrying_Out_Organization_ID
1448 INTO l_carry_out_org_id
1449 FROM pa_projects proj
1450 WHERE project_id = p_project_id;
1451
1452
1453 SELECT language_code
1454 INTO l_basic_language_code
1455 FROM fnd_languages
1456 WHERE installed_flag = 'B';
1457
1458
1459 IF g1_debug_mode = 'Y' THEN
1460
1461 PA_MCB_INVOICE_PKG.log_message('carrying out org id : ' || l_carry_out_org_id);
1462 PA_MCB_INVOICE_PKG.log_message('basic lang code :' || l_basic_language_code );
1463 PA_MCB_INVOICE_PKG.log_message('calling get_trx_crmemo types');
1464
1465 END IF;
1466
1467 pa_invoice_xfer.get_trx_crmemo_types(
1468 P_business_group_id => l_business_grp_id ,
1469 P_carrying_out_org_id => l_carry_out_org_id ,
1470 P_proj_org_struct_version_id => l_org_struct_ver_id ,
1471 p_basic_language => l_basic_language_code ,
1472 P_trans_type => l_p_trx_type ,
1473 P_crmo_trx_type => l_cm_trx_type ,
1474 P_error_status => l_error_status ,
1475 P_error_message => l_error_message);
1476
1477 IF g1_debug_mode = 'Y' THEN
1478
1479 PA_MCB_INVOICE_PKG.log_message('trans type : ' || l_p_trx_type);
1480 PA_MCB_INVOICE_PKG.log_message('crmo trx type:' || l_cm_trx_type );
1481
1482 END IF;
1483
1484 IF nvl(p_draft_inv_num_credited,0) = 0 THEN
1485
1486 x_transaction_type_id := to_number(l_p_trx_type);
1487
1488 ELSE
1489
1490 x_transaction_type_id := to_number(l_cm_trx_type);
1491
1492 END IF;
1493 x_batch_source_id := l_batch_source_id;
1494
1495 end get_btch_src_trans_type;
1496
1497 END PA_OUTPUT_TAX;