[Home] [Help]
PACKAGE BODY: APPS.PA_ADJUSTMENTS
Source
1 PACKAGE BODY PA_ADJUSTMENTS AS
2 /* $Header: PAXTADJB.pls 120.107.12020000.6 2013/04/18 13:47:56 rboyalap ship $ */
3
4 RESOURCE_BUSY EXCEPTION;
5 PRAGMA EXCEPTION_INIT( RESOURCE_BUSY, -0054 );
6
7 ExpOrganizationTab PA_PLSQL_DATATYPES.IdTabTyp;
8 ExpOrgTab PA_PLSQL_DATATYPES.IdTabTyp;
9 TaskIdTab PA_PLSQL_DATATYPES.IdTabTyp;
10 ExpItemDateTab PA_PLSQL_DATATYPES.DateTabTyp;
11 ExpTypeTab PA_PLSQL_DATATYPES.Char30TabTyp ;
12 IncurredByPersonIdTab PA_PLSQL_DATATYPES.IdTabTyp;
13 TrxSourceTab PA_PLSQL_DATATYPES.Char30TabTyp ;
14 NlrOrganizationIdTab PA_PLSQL_DATATYPES.IdTabTyp;
15 SysLinkageTab PA_PLSQL_DATATYPES.Char30TabTyp;
16 CrossChargeCodeTab PA_PLSQL_DATATYPES.Char1TabTyp;
17 DenomTpCurrCodeTab PA_PLSQL_DATATYPES.Char15TabTyp ;
18 P_DEBUG_MODE BOOLEAN := pa_cc_utils.g_debug_mode;
19
20 /* R12 Changes Start */
21 TYPE METHODS IS RECORD ( ORG_ID NUMBER
22 , METHOD VARCHAR2(25));
23 TYPE METHODS_TAB IS TABLE OF METHODS INDEX BY BINARY_INTEGER;
24 G_AUTOMATIC_OFFSET_METHOD METHODS_TAB;
25
26 G_VENDOR_ID NUMBER;
27 G_ORG_ID NUMBER;
28 G_SET_OF_BOOKS_ID NUMBER;
29 G_GL_DATE DATE;
30 G_COA_ID NUMBER;
31 G_EMP_ID NUMBER;
32 G_EMP_CCID NUMBER;
33 G_INVOICE_DISTRIBUTION_ID NUMBER;
34 G_EXPENSE_TYPE NUMBER;
35 G_EXP_ITEM_ID NUMBER;
36 G_OLD_CCID NUMBER;
37 G_NEW_CCID NUMBER;
38 /* R12 Changes End */
39
40 /* R12 Changes Start */
41 G_PO_HEADER_ID NUMBER;
42 G_PO_NUM VARCHAR2(20);
43 G_PO_DATE DATE;
44 G_PO_LINE_NUM NUMBER;
45 G_PO_DIST_NUM NUMBER;
46 G_PO_DIST_ID NUMBER;
47
48 G_INV_TYPE_CODE VARCHAR2(30);
49 G_INV_TYPE VARCHAR2(80);
50 G_INV_LINE_TYPE_CODE VARCHAR2(30);
51 G_INV_LINE_TYPE VARCHAR2(80);
52 G_INV_DIST_TYPE_CODE VARCHAR2(30);
53 G_INV_DIST_TYPE VARCHAR2(80);
54 G_PAYMENT_TYPE_CODE VARCHAR2(30); /* 4914048 */
55 G_PAYMENT_TYPE VARCHAR2(80); /* 4914048 */
56 G_PO_DIST_TYPE_CODE VARCHAR2(30);
57 G_PO_DIST_TYPE VARCHAR2(80);
58 G_RCV_TXN_TYPE_CODE VARCHAR2(30);
59 G_RCV_TXN_TYPE VARCHAR2(80);
60
61 G_RCV_TXN_ID NUMBER;
62 G_RCV_NUM VARCHAR2(30);
63 G_RCV_DATE DATE;
64
65 G_INV_ID NUMBER;
66 G_INV_NUM VARCHAR2(50);
67 G_INV_DATE DATE;
68 /* R12 Changes End */
69
70 /* Bug 5235354 - Start */
71 TYPE LEDGER_CNT IS RECORD ( ORG_ID NUMBER
72 , CNT NUMBER);
73 TYPE LEDGER_CNT_TAB IS TABLE OF LEDGER_CNT INDEX BY BINARY_INTEGER;
74 G_LEDGER_CNT LEDGER_CNT_TAB;
75 /* Bug 5235354 - End */
76
77
78 /*Bug# 5874347 - Start*/
79 Function getprojburdenflag(p_project_id in number) return varchar2
80 IS
81 X_proj_bcost_flag VARCHAR2(10) DEFAULT 'N';
82 BEGIN
83 SELECT nvl(burden_cost_flag,'N')
84 INTO X_proj_bcost_flag
85 FROM pa_projects_all proj,
86 pa_project_types_all ptype
87 WHERE proj.project_type = ptype.project_type
88 AND nvl(proj.org_id, -99) = nvl(ptype.org_id,-99)
89 AND project_id = p_Project_id ;
90 return(X_proj_bcost_flag);
91 Exception
92 WHEN NO_DATA_FOUND THEN
93 X_proj_bcost_flag :='N';
94 return(X_proj_bcost_flag);
95 END getprojburdenflag;
96 /*Bug# 5874347 - End */
97
98 -- ========================================================================
99 -- PROCEDURE CheckStatus
100 -- ========================================================================
101
102 PROCEDURE CheckStatus( status_indicator IN OUT NOCOPY NUMBER )
103 IS
104 BEGIN
105
106 IF ( status_indicator <> 0 ) THEN
107 RAISE SUBROUTINE_ERROR;
108 ELSIF ( status_indicator = 0 ) THEN
109 status_indicator := NULL;
110 END IF;
111
112 END CheckStatus;
113
114
115 --=========================================================================
116 -- PROCEDURE print_message
117 --========================================================================
118 PROCEDURE print_message(p_msg_token1 IN varchar2) IS
119 --,p_msg_token2 IN varchar2 ) IS
120
121
122 BEGIN
123 If p_msg_token1 is not null --or p_msg_token2 is not null
124 then
125 --dbms_output.put_line('LOG: '||p_msg_token1);
126 --r_debug.r_msg(p_msg =>'LOG: '||p_msg_token1);
127 pa_cc_utils.log_message('get_denom_curr_code: ' || substr(p_msg_token1,1,250), 0 );
128 null;
129 End If;
130
131 Return;
132
133 END print_message;
134
135 FUNCTION is_proj_billable(p_task_id IN number) return varchar2 IS
136
137 l_billable varchar2(1) := 'N';
138
139 BEGIN
140
141 SELECT 'Y'
142 INTO l_billable
143 FROM pa_projects_all pp,
144 pa_tasks t,
145 pa_project_types_all pt /** Bug fix 2262118 **/
146 WHERE t.task_id = p_task_id
147 AND pp.project_id = t.project_id
148 AND pp.project_type = pt.project_type
149 AND pt.PROJECT_TYPE_CLASS_CODE in ('CAPITAL','CONTRACT')
150 -- start 12i MOAC changes
151 -- AND nvl(pp.org_id ,-99) = nvl(pt.org_id ,-99) ;
152 AND pp.org_id = pt.org_id ;
153
154 return l_billable;
155
156 EXCEPTION
157
158 WHEN NO_DATA_FOUND then
159 return 'N';
160
161 WHEN OTHERS THEN
162 return 'N';
163
164 END is_proj_billable ;
165
166 -- ========================================================================
167 -- FUNCTION VerifyOrigItem
168 -- ========================================================================
169
170 FUNCTION VerifyOrigItem ( X_person_id IN NUMBER
171 , X_org_id IN NUMBER
172 , X_item_date IN DATE
173 , X_task_id IN NUMBER
174 , X_exp_type IN VARCHAR2
175 , X_system_linkage_function IN VARCHAR2
176 , X_nl_org_id IN NUMBER
177 , X_nl_resource IN VARCHAR2
178 , X_quantity IN NUMBER
179 , X_denom_raw_cost IN NUMBER
180 , X_trx_source IN VARCHAR2
181 , X_denom_currency_code IN VARCHAR2
182 , X_acct_raw_cost IN NUMBER
183 -- SST Change
184 , X_reversed_orig_txn_reference IN OUT NOCOPY VARCHAR2
185 , X_cbs_element_id IN NUMBER -- Added for CBS Enhancement Bug 16220146
186 ) RETURN NUMBER
187 IS
188 orig_item_id NUMBER DEFAULT NULL;
189 /*Performance Issue Bug 13946863 :: Re-Arranged Where Conditions and Added Hint to improve the Performance*/
190 CURSOR cur_origtxn IS
191 SELECT
192 /*+ index(I PA_EXPENDITURE_ITEMS_N9) */
193 MIN(i.expenditure_item_id),
194 -- SST Change: If X_reversed_orig_txn_reference is not NULL
195 -- then we already have the reversing item's
196 -- orig_transaction_reference, otherwise get the
197 -- reversing item's orig_transaction_reference
198 DECODE(X_reversed_orig_txn_reference,NULL, i.orig_transaction_reference, X_reversed_orig_txn_reference) orig_txn_reference
199 FROM pa_transaction_sources ts ,
200 pa_expenditure_items i ,
201 pa_expenditures e
202 WHERE i.expenditure_item_date = X_item_date
203 AND i.task_id = X_task_id
204 AND i.expenditure_type ||'' = X_exp_type
205 AND i.system_linkage_function ||'' = X_system_linkage_function
206 AND NVL( i.organization_id, -1 ) = NVL( X_nl_org_id, -1 )
207 AND ( i.quantity * -1 ) = X_quantity
208 AND i.transaction_source||'' = X_trx_source
209 AND NVL( i.non_labor_resource, 'DUMMY' ) = NVL( X_nl_resource, 'DUMMY' )
210 AND NVL( i.net_zero_adjustment_flag, 'N' ) = 'N'
211 AND i.transaction_source = ts.transaction_source
212 AND (i.orig_transaction_reference = X_reversed_orig_txn_reference
213 OR X_reversed_orig_txn_reference IS NULL)
214 AND pa_adjustments.ei_adjusted_in_cache(i.expenditure_item_id) = 'N'
215 AND i.expenditure_id = e.expenditure_id
216 AND ( ( ts.costed_flag = 'Y'
217 AND ( i.denom_raw_cost * -1) = pa_currency.round_trans_currency_amt(X_denom_raw_cost,X_denom_currency_code))
218 OR ( ts.costed_flag = 'N' ) )
219 AND ( ( ts.gl_accounted_flag = 'Y'
220 AND ( i.acct_raw_cost * -1) = pa_currency.round_currency_amt(X_acct_raw_cost))
221 OR ( ts.gl_accounted_flag = 'N' ) )
222 AND ( ( e.incurred_by_person_id = X_person_id )
223 OR ( ( e.incurred_by_person_id IS NULL )
224 AND ( e.incurred_by_organization_id = X_org_id ) ) )
225 AND NVL(i.cbs_element_id, -1) = NVL(X_cbs_element_id, -1) -- Added for CBS Enhancement Bug 16220146
226 -- SSt changes: If we have the orig_txn_ref of the reversing item,
227 -- then the item we find must have the matching orig_txn_reference.
228 -- If we don't have the orig_txn_reference of the reversing item,
229 -- then the item we find does not need to satisfy the following
230 -- condition
231 GROUP BY DECODE(X_reversed_orig_txn_reference,NULL, i.orig_transaction_reference, X_reversed_orig_txn_reference);
232
233 BEGIN
234
235 OPEN cur_origtxn;
236 FETCH cur_origtxn INTO orig_item_id,X_reversed_orig_txn_reference;
237 CLOSE cur_origtxn;
238
239 RETURN ( orig_item_id );
240
241 EXCEPTION
242 WHEN NO_DATA_FOUND THEN
243 RETURN ( NULL );
244
245 END VerifyOrigItem;
246
247
248
249 -- ========================================================================
250 -- PROCEDURE CommentChange
251 -- ========================================================================
252
253 PROCEDURE CommentChange( X_exp_item_id IN NUMBER
254 , X_new_comment IN VARCHAR2
255 , X_user IN NUMBER
256 , X_login IN NUMBER
257 , X_status OUT NOCOPY NUMBER )
258 IS
259 dummy NUMBER;
260 temp_status NUMBER DEFAULT NULL;
261
262 -- ------------------------------------------------------------------
263 -- PROCEDURE CommentChange.DelComment
264 -- ------------------------------------------------------------------
265
266 PROCEDURE DelComment( X_exp_item_id IN NUMBER
267 , X_status OUT NOCOPY NUMBER )
268 IS
269 BEGIN
270 DELETE FROM pa_expenditure_comments
271 WHERE
272 expenditure_item_id = X_exp_item_id;
273
274 X_status := 0;
275
276 EXCEPTION
277 WHEN OTHERS THEN
278 X_status := SQLCODE;
279 RAISE;
280
281 END DelComment;
282
283
284 -- ------------------------------------------------------------------
285 -- PROCEDURE CommentChange.UpdComment
286 -- ------------------------------------------------------------------
287
288 PROCEDURE UpdComment( X_exp_item_id IN NUMBER
289 , X_new_comment IN VARCHAR2
290 , X_user IN NUMBER
291 , X_login IN NUMBER
292 , X_status OUT NOCOPY NUMBER )
293 IS
294 BEGIN
295
296 UPDATE pa_expenditure_comments
297 SET
298 expenditure_comment = X_new_comment
299 , last_update_date = sysdate
300 , last_updated_by = X_user
301 , last_update_login = X_login
302 WHERE
303 expenditure_item_id = X_exp_item_id;
304
305 X_status := 0;
306
307 EXCEPTION
308 WHEN OTHERS THEN
309 X_status := SQLCODE;
310 RAISE;
311
312 END UpdComment;
313
314 BEGIN
315
316 SELECT count(*)
317 INTO dummy
318 FROM sys.dual
319 WHERE EXISTS
320 ( SELECT NULL
321 FROM pa_expenditure_comments
322 WHERE expenditure_item_id = X_exp_item_id);
323
324 IF( dummy = 0 ) THEN
325
326 pa_transactions.InsItemComment( X_exp_item_id
327 , X_new_comment
328 , X_user
329 , X_login
330 , temp_status );
331 CheckStatus( temp_status );
332
333 ELSIF( dummy <> 0
334 AND X_new_comment IS NOT NULL ) THEN
335
336 UpdComment( X_exp_item_id
337 , X_new_comment
338 , X_user
339 , X_login
340 , temp_status );
341 CheckStatus( temp_status );
342
343 ELSIF( dummy <> 0
344 AND X_new_comment IS NULL ) THEN
345
346 DelComment( X_exp_item_id
347 , temp_status );
348
349 END IF;
350
351 X_status := 0;
352
353 EXCEPTION
354 WHEN OTHERS THEN
355 X_status := SQLCODE;
356 RAISE;
357
358 END CommentChange;
359
360
361
362 -- ========================================================================
363 -- PROCEDURE InsAuditRec
364 -- ========================================================================
365
366
367 PROCEDURE InsAuditRec( X_exp_item_id IN NUMBER
368 , X_adj_activity IN VARCHAR2
369 , X_module IN VARCHAR2
370 , X_user IN NUMBER
371 , X_login IN NUMBER
372 , X_status OUT NOCOPY NUMBER
373 , X_who_req_id IN NUMBER
374 , X_who_prog_id IN NUMBER
375 , X_who_prog_app_id IN NUMBER
376 , X_who_prog_upd_date IN DATE
377 , X_rejection_code IN VARCHAR2 )
378 IS
379 BEGIN
380 INSERT INTO pa_expend_item_adj_activities (
381 expenditure_item_id
382 , last_update_date
383 , last_updated_by
384 , creation_date
385 , created_by
386 , last_update_login
387 , activity_date
388 , exception_activity_code
389 , module_code
390 , request_id
391 , program_application_id
392 , program_id
393 , program_update_date
394 , rejection_code)
395 VALUES (
396 X_exp_item_id -- expenditure_item_id
397 , sysdate -- last_update_date
398 , X_user -- last_updated_by
399 , sysdate -- creation_date
400 , X_user -- created_by
401 , X_login -- last_update_login
402 , sysdate -- activity_date
403 , X_adj_activity -- exception_activity_code
404 , X_module -- module_code
405 , X_who_req_id -- request_id
406 , X_who_prog_app_id -- program_application_id
407 , X_who_prog_id -- program_id
408 , X_who_prog_upd_date -- program_update_date
409 , X_rejection_code ); -- rejection_code
410
411 X_status := 0;
412
413 EXCEPTION
414 WHEN OTHERS THEN
415 X_status := SQLCODE;
416 RAISE;
417
418 END InsAuditRec;
419
420
421 -- ========================================================================
422 -- PROCEDURE SetNetZero
423 -- ========================================================================
424
425 PROCEDURE SetNetZero( X_exp_item_id IN NUMBER
426 , X_user IN NUMBER
427 , X_login IN NUMBER
428 , X_status OUT NOCOPY NUMBER )
429 IS
430 BEGIN
431 UPDATE pa_expenditure_items_all ei
432 SET
433 ei.net_zero_adjustment_flag = 'Y'
434 , ei.last_update_date = sysdate
435 , ei.last_updated_by = X_user
436 , ei.last_update_login = X_login
437 WHERE
438 ei.expenditure_item_id = X_exp_item_id;
439
440 X_status := 0;
441
442 EXCEPTION
443 WHEN OTHERS THEN
444 X_status := SQLCODE;
445 RAISE;
446
447 END SetNetZero;
448
449
450 -- ========================================================================
451 -- PROCEDURE BackoutItem
452 -- ========================================================================
453
454 PROCEDURE BackoutItem( X_exp_item_id IN NUMBER
455 , X_expenditure_id IN NUMBER
456 , X_adj_activity IN VARCHAR2
457 , X_module IN VARCHAR2
458 , X_user IN NUMBER
459 , X_login IN NUMBER
460 , X_status OUT NOCOPY NUMBER )
461 IS
462 X_backout_id NUMBER(15);
463 temp_status NUMBER DEFAULT NULL;
464 item_comment VARCHAR2(240);
465
466 BEGIN
467
468 X_backout_id := pa_utils.GetNextEiId;
469 /*12.2 Payroll Integration changes*/
470 IF X_module = 'PAXREVTXN' THEN
471 G_REQUEST_ID := FND_GLOBAL.CONC_REQUEST_ID;
472 G_PROGRAM_ID := FND_GLOBAL.CONC_PROGRAM_ID;
473 G_PROG_APPL_ID := FND_GLOBAL.PROG_APPL_ID;
474 END IF;
475 /*End of 12.2 Payroll Integration changes*/
476
477 INSERT INTO pa_expenditure_items_all(
478 expenditure_item_id
479 , task_id
480 , expenditure_type
481 , system_linkage_function
482 , expenditure_item_date
483 , expenditure_id
484 , override_to_organization_id
485 , last_update_date
486 , last_updated_by
487 , creation_date
488 , created_by
489 , last_update_login
490 , quantity
491 , revenue_distributed_flag
492 , bill_hold_flag
493 , billable_flag
494 , bill_rate_multiplier
495 , cost_distributed_flag
496 , raw_cost
497 , raw_cost_rate
498 , burden_cost
499 , burden_cost_rate
500 , cost_ind_compiled_set_id
501 , non_labor_resource
502 , organization_id
503 , adjusted_expenditure_item_id
504 , net_zero_adjustment_flag
505 , attribute_category
506 , attribute1
507 , attribute2
508 , attribute3
509 , attribute4
510 , attribute5
511 , attribute6
512 , attribute7
513 , attribute8
514 , attribute9
515 , attribute10
516 , transferred_from_exp_item_id
517 , transaction_source
518 , orig_transaction_reference
519 , source_expenditure_item_id
520 , job_id
521 , org_id
522 , labor_cost_multiplier_name
523 , receipt_currency_amount
524 , receipt_currency_code
525 , receipt_exchange_rate
526 , denom_currency_code
527 , denom_raw_cost
528 , denom_burdened_cost
529 , acct_currency_code
530 , acct_rate_date
531 , acct_rate_type
532 , acct_exchange_rate
533 , acct_raw_cost
534 , acct_burdened_cost
535 , acct_exchange_rounding_limit
536 , project_currency_code
537 , project_rate_date
538 , project_rate_type
539 , project_exchange_rate
540 , cc_cross_charge_code
541 , cc_prvdr_organization_id
542 , cc_recvr_organization_id
543 , cc_rejection_code
544 , denom_tp_currency_code
545 , denom_transfer_price
546 , acct_tp_rate_type
547 , acct_tp_rate_date
548 , acct_tp_exchange_rate
549 , acct_transfer_price
550 , projacct_transfer_price
551 , cc_markup_base_code
552 , tp_base_amount
553 , cc_cross_charge_type
554 , recvr_org_id
555 , cc_bl_distributed_code
556 , cc_ic_processed_code
557 , tp_ind_compiled_set_id
558 , tp_bill_rate
559 , tp_bill_markup_percentage
560 , tp_schedule_line_percentage
561 , tp_rule_percentage
562 , cost_job_id
563 , tp_job_id
564 , prov_proj_bill_job_id
565 , assignment_id
566 , work_type_id
567 , projfunc_currency_code
568 , projfunc_cost_rate_date
569 , projfunc_cost_rate_type
570 , projfunc_cost_exchange_rate
571 , project_raw_cost
572 , project_burdened_cost
573 , project_id
574 , project_tp_rate_date
575 , project_tp_rate_type
576 , project_tp_exchange_rate
577 , project_transfer_price
578 , tp_amt_type_code
579 /* inserting cost_burden_distributed_flag for 2661921 */
580 , cost_burden_distributed_flag
581 , capital_event_id
582 , wip_resource_id
583 , inventory_item_id
584 , unit_of_measure
585 /* R12 Changes - Start */
586 , document_header_id
587 , document_distribution_id
588 , document_line_number
589 , document_payment_id
590 , vendor_id
591 , document_type
592 , document_distribution_type
593 , po_line_id -- Bug 14699953
594 /* 12.2 payroll intg enhancement changes */
595 , location_id
596 , pay_element_type_id
597 , rate_source_code
598 , costing_method
599 ,PAYROLL_ACCRUAL_FLAG
600 ,RBC_ELEMENT_TYPE_ID
601 ,INTERFACE_RUN_ID
602 ,request_id
603 ,program_application_id
604 ,program_id
605 ,cbs_element_id) -- Added as part of Bug 16220146
606 /* R12 Changes - End */
607 SELECT
608 X_backout_id -- expenditure_item_id
609 , ei.task_id -- task_id
610 , ei.expenditure_type -- expenditure_type
611 , ei.system_linkage_function -- system_linkage_function
612 , ei.expenditure_item_date -- expenditure_item_date
613 , nvl( X_expenditure_id,
614 ei.expenditure_id ) -- expenditure_id
615 , ei.override_to_organization_id -- override exp organization
616 , sysdate -- last_update_date
617 , X_user -- last_updated_by
618 , sysdate -- creation_date
619 , X_user -- created_by
620 , X_login -- last_update_login
621 , (0 - ei.quantity) -- quantity
622 , 'N' -- revenue_distributed_flag
623 , ei.bill_hold_flag -- bill_hold_flag
624 , ei.billable_flag -- billable_flag
625 , ei.bill_rate_multiplier -- bill_rate_multiplier
626 , 'N' -- cost_distributed_flag
627 , (0 - ei.raw_cost) -- raw_cost
628 , ei.raw_cost_rate -- raw_cost_rate
629 , (0 - ei.burden_cost) -- raw_cost
630 , ei.burden_cost_rate -- raw_cost_rate
631 , ei.cost_ind_compiled_set_id -- cost_ind_compiled_set_id
632 , ei.non_labor_resource -- non_labor_resource
633 , ei.organization_id -- organization_id
634 , ei.expenditure_item_id -- adjusted_expenditure_item_id
635 , 'Y' -- net_zero_adjustment_flag
636 , ei.attribute_category -- attribute_category
637 , ei.attribute1 -- attribute1
638 , ei.attribute2 -- attribute2
639 , ei.attribute3 -- attribute3
640 , ei.attribute4 -- attribute4
641 , ei.attribute5 -- attribute5
642 , ei.attribute6 -- attribute6
643 , ei.attribute7 -- attribute7
644 , ei.attribute8 -- attribute8
645 , ei.attribute9 -- attribute9
646 , ei.attribute10 -- attribute10
647 , ei.transferred_from_exp_item_id -- tfr from exp item id
648 , ei.transaction_source -- transaction_source
649 , decode(ei.transaction_source,'PTE TIME',NULL,
650 decode(ei.transaction_source,'PTE EXPENSE',NULL,
651 decode(ei.transaction_source,'ORACLE TIME AND LABOR',NULL,
652 decode(ei.transaction_source,'Oracle Self Service Time',NULL,
653 ei.orig_transaction_reference)))) -- orig_transaction_reference
654 , ei.source_expenditure_item_id -- source_expenditure_item_id
655 , ei.job_id -- job_id
656 , ei.org_id -- org_id
657 , ei.labor_cost_multiplier_name -- labor_cost_multiplier_name
658 , (0 - ei.receipt_currency_amount) -- receipt_currency_amount
659 , ei.receipt_currency_code -- receipt_currency_code
660 , ei.receipt_exchange_rate -- receipt_exchange_rate
661 , ei.denom_currency_code -- denom_currency_code
662 , (0 - ei.denom_raw_cost) -- denom_raw_cost
663 , (0 - ei.denom_burdened_cost) -- denom_burdened_cost
664 , ei.acct_currency_code -- acct_currency_code
665 , ei.acct_rate_date -- acct_rate_date
666 , ei.acct_rate_type -- acct_rate_type
667 , ei.acct_exchange_rate -- acct_exchange_rate
668 , (0 - ei.acct_raw_cost) -- acct_raw_cost
669 , (0 - ei.acct_burdened_cost) -- acct_burdened_cost
670 , ei.acct_exchange_rounding_limit -- acct_exchange_rounding_limit
671 , ei.project_currency_code -- project_currency_code
672 , ei.project_rate_date -- project_rate_date
673 , ei.project_rate_type -- project_rate_type
674 , ei.project_exchange_rate -- project_exchange_rate
675 , ei.cc_cross_charge_code -- cc_cross_charge_code
676 , ei.cc_prvdr_organization_id -- cc_prvdr_organization_id
677 , ei.cc_recvr_organization_id -- cc_recvr_organization_id
678 , ei.cc_rejection_code -- cc_rejection_code
679 , ei.denom_tp_currency_code -- denom_tp_currency_code
680 , (0 - ei.denom_transfer_price) -- denom_transfer_price
681 , ei.acct_tp_rate_type -- acct_tp_rate_type
682 , ei.acct_tp_rate_date -- acct_tp_rate_date
683 , ei.acct_tp_exchange_rate -- acct_tp_exchange_rate
684 , (0 - ei.acct_transfer_price) -- acct_transfer_price
685 , (0 - ei.projacct_transfer_price) -- projacct_transfer_price
686 , ei.cc_markup_base_code -- cc_markup_base_code
687 , (0 - ei.tp_base_amount) -- tp_base_amount
688 , ei.cc_cross_charge_type -- cc_cross_charge_type
689 , ei.recvr_org_id -- recvr_org_id
690 , decode(ei.cc_bl_distributed_code,'X','X','N') -- cc_bl_distributed_code /* Modified for bug 12983087*/
691 , decode(ei.cc_ic_processed_code,'X','X','N') -- cc_ic_processed_code/*Bug 12930866*/
692 , ei.tp_ind_compiled_set_id -- tp_ind_compiled_set_id
693 , ei.tp_bill_rate -- tp_bill_rate
694 , ei.tp_bill_markup_percentage -- tp_bill_markup_percentage
695 , ei.tp_schedule_line_percentage -- tp_schedule_line_percentage
696 , ei.tp_rule_percentage -- tp_rule_percentage
697 , ei.cost_job_id -- cost_job_id
698 , ei.tp_job_id -- tp_job_id
699 , ei.prov_proj_bill_job_id -- prov_proj_bill_job_id
700 , ei.assignment_id
701 , ei.work_type_id
702 , ei.projfunc_currency_code
703 , ei.projfunc_cost_rate_date
704 , ei.projfunc_cost_rate_type
705 , ei.projfunc_cost_exchange_rate
706 , (0 - ei.project_raw_cost) -- project raw cost
707 , (0 - ei.project_burdened_cost) -- project burended cost
708 , ei.project_id
709 , ei.project_tp_rate_date
710 , ei.project_tp_rate_type
711 , ei.project_tp_exchange_rate
712 , (0 - ei.project_transfer_price)
713 , ei.tp_amt_type_code
714 /* inserting cost_burden_distributed_flag for 2661921 */
715 , decode(ei.cost_ind_compiled_set_id,null,'X','N')
716 , capital_event_id
717 , wip_resource_id
718 , inventory_item_id
719 , unit_of_measure
720 /* R12 Changes - Start */
721 , ei.document_header_id
722 , ei.document_distribution_id
723 , ei.document_line_number
724 , ei.document_payment_id
725 , ei.vendor_id ei_vendor_id
726 , ei.document_type
727 , ei.document_distribution_type
728 , ei.po_line_id --Bug 14699953
729 /* R12 Changes - End */
730 /* 12.2 payroll intg enhancement */
731 , ei.location_id
732 , ei.pay_element_type_id
733 , ei.rate_source_code
734 , ei.costing_method
735 ,ei.PAYROLL_ACCRUAL_FLAG
736 ,ei.RBC_ELEMENT_TYPE_ID
737 ,ei.INTERFACE_RUN_ID
738 ,G_REQUEST_ID
739 ,G_PROGRAM_ID
740 ,G_PROG_APPL_ID
741 ,ei.cbs_element_id -- Added as part of Bug 16220146
742 FROM
743 pa_expenditure_items_all ei
744 WHERE
745 ei.expenditure_item_id = X_exp_item_id;
746
747 /* Fix for Bug 3684711 */
748 /* Adding grants integrations to support entry of automatically reversing batches. */
749 IF ( pa_gms_api.vert_install and x_adj_activity = 'PERIOD-END ACCRUAL REVERSAL' ) THEN
750 /*
751 ** The purpose of the following packet is to create award distribution lines for the
752 ** reversal expenditure item.
753 */
754 gms_awards_dist_pkg.copy_exp_adls( p_exp_item_id => x_exp_item_id,
755 p_backout_item_id => x_backout_id,
756 p_adj_activity => x_adj_activity,
757 p_module => x_module,
758 p_user => x_user,
759 p_login => x_login,
760 x_status => temp_status ) ;
761
762 CheckStatus( status_indicator => temp_status );
763
764 END IF ;
765
766 /* Fix for bug 2211472 */
767 /* Adding the comment of original expenditure_item to the reversed expenditure item
768 and storing it in pa_expenditure_comments table */
769 BEGIN
770 SELECT
771 ec.expenditure_comment
772 INTO
773 item_comment
774 FROM
775 pa_expenditure_comments ec
776 WHERE
777 ec.expenditure_item_id = X_exp_item_id;
778 EXCEPTION
779 WHEN NO_DATA_FOUND THEN
780 NULL;
781 END;
782
783
784 IF ( item_comment IS NOT NULL ) THEN
785
786 pa_transactions.InsItemComment( X_ei_id => X_backout_id
787 , X_ei_comment => item_comment
788 , X_user => X_user
789 , X_login => X_login
790 , X_status => temp_status );
791
792 CheckStatus( status_indicator => temp_status );
793
794 END IF;
795 /* End of Fix for bug 2211472 */
796 /*
797 Project Summarization changes:
798 Store the backout_id in the global variable
799 */
800 Pa_Adjustments.BackOutId := X_backout_id;
801
802 SetNetZero( X_exp_item_id
803 , X_user
804 , X_login
805 , temp_status );
806 CheckStatus( temp_status );
807
808 InsAuditRec( X_backout_id
809 , X_adj_activity
810 , X_module
811 , X_user
812 , X_login
813 , temp_status
814 /* R12 Changes Start */
815 , G_REQUEST_ID
816 , G_PROGRAM_ID
817 , G_PROG_APPL_ID
818 , sysdate );
819 /* R12 Changes End */
820 CheckStatus( temp_status );
821
822 /* -- MRC Elimination
823 IF ( G_update_mrc_data = 'Y' ) THEN
824
825 BackOutMrcItem(X_exp_item_id =>X_exp_item_id,
826 X_backout_id => X_backout_id,
827 X_adj_activity => X_adj_activity,
828 X_module => X_module,
829 X_user => X_user,
830 X_login => X_login,
831 X_status => temp_status);
832 CheckStatus(temp_status);
833 END IF;
834 */
835
836 X_status := 0;
837
838 EXCEPTION
839 WHEN OTHERS THEN
840 X_status := SQLCODE;
841 RAISE;
842
843 END BackoutItem;
844
845 -- ========================================================================
846 -- PROCEDURE BackoutMrcItem
847 -- ========================================================================
848 /* MRC Elimination
849 PROCEDURE BackoutMrcItem( X_exp_item_id IN NUMBER
850 , X_backout_id IN NUMBER
851 , X_adj_activity IN VARCHAR2
852 , X_module IN VARCHAR2
853 , X_user IN NUMBER
854 , X_login IN NUMBER
855 , X_status OUT NOCOPY NUMBER )
856 IS
857 temp_status NUMBER DEFAULT NULL;
858
859 BEGIN
860
861
862 INSERT into pa_mc_exp_items_all(
863 SET_OF_BOOKS_ID,
864 EXPENDITURE_ITEM_ID,
865 RAW_COST,
866 RAW_COST_RATE,
867 BURDEN_COST,
868 BURDEN_COST_RATE,
869 NET_ZERO_ADJUSTMENT_FLAG,
870 TRANSFERRED_FROM_EXP_ITEM_ID,
871 PRC_ASSIGNMENT_ID,
872 CURRENCY_CODE,
873 COST_EXCHANGE_RATE,
874 COST_CONVERSION_DATE,
875 COST_RATE_TYPE,
876 TRANSFER_PRICE,
877 TP_EXCHANGE_RATE,
878 TP_CONVERSION_DATE,
879 TP_RATE_TYPE)
880
881 SELECT SET_OF_BOOKS_ID,
882 X_backout_id,
883 -1*RAW_COST,
884 RAW_COST_RATE,
885 -1*BURDEN_COST,
886 BURDEN_COST_RATE,
887 'Y', -- net_zero_adjustment_flag
888 NULL,-- Transferred_from_expenditure_item_id
889 PRC_ASSIGNMENT_ID,
890 CURRENCY_CODE,
891 COST_EXCHANGE_RATE,
892 COST_CONVERSION_DATE,
893 COST_RATE_TYPE,
894 -1*TRANSFER_PRICE,
895 TP_EXCHANGE_RATE,
896 TP_CONVERSION_DATE,
897 TP_RATE_TYPE
898 FROM pa_mc_exp_items_all
899 WHERE expenditure_item_id = X_exp_item_id;
900
901 EXCEPTION
902 WHEN OTHERS THEN
903 X_status := SQLCODE;
904 RAISE;
905 END BackoutMrcItem;
906 */
907 -- ========================================================================
908 -- PROCEDURE ReverseRelatedItems
909 -- ========================================================================
910
911 PROCEDURE ReverseRelatedItems( X_source_exp_item_id IN NUMBER
912 , X_expenditure_id IN NUMBER
913 , X_module IN VARCHAR2
914 , X_user IN NUMBER
915 , X_login IN NUMBER
916 , X_status OUT NOCOPY NUMBER )
917 IS
918
919 temp_status NUMBER DEFAULT NULL;
920
921 CURSOR GetRelatedItems IS
922 SELECT
923 ei.expenditure_item_id
924 FROM
925 pa_expenditure_items_all ei
926 WHERE
927 ei.source_expenditure_item_id = X_source_exp_item_id
928 AND nvl(ei.net_zero_adjustment_flag, 'N') <> 'Y';
929
930 BEGIN
931
932 FOR eachRec IN GetRelatedItems LOOP
933
934 InsAuditRec( eachRec.expenditure_item_id
935 , 'RELATED ITEM ORIGINATING'
936 , X_module
937 , X_user
938 , X_login
939 , temp_status
940 /* R12 Changes Start */
941 , G_REQUEST_ID
942 , G_PROGRAM_ID
943 , G_PROG_APPL_ID
944 , sysdate );
945 /* R12 Changes End */
946 CheckStatus( temp_status );
947
948
949 BackoutItem( eachRec.expenditure_item_id
950 , X_expenditure_id
951 , 'RELATED ITEM BACK-OUT'
952 , X_module
953 , X_user
954 , X_login
955 , temp_status );
956 CheckStatus( temp_status );
957
958 -- ---------------------------------------------------------------------------
959 -- Fix for bug 429816. What was happening is :
960 -- ExpItm AdjEI TfrEI SrcEI Qty Raw_Cost
961 -- ------- ------ ------ ------ ----- --------
962 -- 1 5 100
963 -- 2 1 0 20
964 -- 3 1 -5 -100
965 -- 4 2 1* 0 -20
966 --
967 -- The problem is that the reversing related item (4) was showing the Original
968 -- item(1) as its SourceEI and not the reversing item(3) as its SourceEI
969 -- ---------------------------------------------------------------------------
970 -- Fix for bug 604023. What was happening is :
971 -- ExpItm AdjEI TfrEI SrcEI Qty Raw_Cost
972 -- ------- ------ ------ ------ ----- --------
973 -- 1 5 100
974 -- 2 1 0 20
975 -- (After the 1st transfer)
976 -- 3 1 -5 -100
977 -- 4 2 3 0 -20
978 -- 5 1 5 100
979 -- 6 5 0 20 (After Distribute Labor)
980 -- (After the 2nd transfer)
981 -- 7 3 -5 -100
982 -- 8 4 NULL* 0 -20
983 -- 9 5 5 100
984 -- This NULL is populated because the sub-query in the following update checks
985 -- for 'transferred_from _exp_item_id is null'. As a part of the fix removed the
986 -- condition 'ei1.transferred_from_exp_item_id is null' from the where clause
987 -- in the sub-query.
988 --------------------------------------------------------------------------------
989
990
991 Update pa_expenditure_items_all ei
992 set ei.source_expenditure_item_id =
993 (select ei1.expenditure_item_id
994 from pa_expenditure_items_all ei1
995 where ei1.adjusted_expenditure_item_id =
996 X_source_exp_item_id)
997 where ei.adjusted_expenditure_item_id = eachRec.expenditure_item_id;
998
999 -- End Fix--------------------------------------------------------------------
1000
1001 END LOOP;
1002
1003 X_status := 0;
1004
1005 EXCEPTION
1006 WHEN OTHERS THEN
1007 X_status := SQLCODE;
1008 RAISE;
1009
1010 END ReverseRelatedItems;
1011
1012 -- ========================================================================
1013 -- PROCEDURE RecalcRelatedItems
1014 -- ========================================================================
1015 -- This procedure has been created for Bug # 720199. This will be called by the
1016 -- RecalcRev procedure to ensure that the related item also has the revenue distributed
1017 -- flag set to 'N' when a relcalc revenue adjustment is done
1018 -- Since, the related item adjustment is always done in the background, the number of
1019 -- items adjusted is shown as 1 even though in the background, 2 items are adjusted
1020 -- the source and the related item.As the user sees only 1 item being adjusted, we
1021 -- display the num adjusted successfully as 1
1022
1023 -- bug # 900114. Removed code which sets raw cost and cost rate to null
1024 -- in this procedure
1025
1026 PROCEDURE RecalcRelatedItems( X_expenditure_item_id IN NUMBER
1027 , X_user IN NUMBER
1028 , X_login IN NUMBER
1029 , X_module IN VARCHAR2
1030 , X_status OUT NOCOPY NUMBER )
1031 IS
1032
1033 temp_status NUMBER DEFAULT NULL;
1034
1035 CURSOR GetRelatedItems IS
1036 SELECT
1037 expenditure_item_id
1038 FROM
1039 pa_expenditure_items_all
1040 WHERE
1041 source_expenditure_item_id = X_expenditure_item_id;
1042 BEGIN
1043
1044 FOR eachRec IN GetRelatedItems LOOP
1045
1046 UPDATE pa_expenditure_items_all
1047 SET
1048 revenue_distributed_flag = 'N'
1049 , rev_dist_rejection_code = NULL /*Added for bug 9367103*/
1050 , last_updated_by = X_user
1051 , last_update_date = sysdate
1052 , last_update_login = X_login
1053 WHERE
1054 expenditure_item_id = eachRec.expenditure_item_id;
1055
1056
1057 pa_adjustments.InsAuditRec( eachRec.expenditure_item_id
1058 , 'REVENUE RECALC'
1059 , X_module
1060 , X_user
1061 , X_login
1062 , temp_status
1063 /* R12 Changes Start */
1064 , G_REQUEST_ID
1065 , G_PROGRAM_ID
1066 , G_PROG_APPL_ID
1067 , sysdate );
1068 /* R12 Changes End */
1069 CheckStatus( temp_status );
1070
1071 END LOOP;
1072
1073 X_status := 0;
1074
1075 EXCEPTION
1076 WHEN OTHERS THEN
1077 X_status := SQLCODE;
1078 RAISE;
1079
1080 END RecalcRelatedItems;
1081
1082
1083 -- ========================================================================
1084 -- PROCEDURE RecalcRev
1085 -- ========================================================================
1086
1087 PROCEDURE RecalcRev( ItemsIdTab IN pa_utils.IdTabTyp
1088 , AdjustsIdTab IN pa_utils.IdTabTyp
1089 , X_user IN NUMBER
1090 , X_login IN NUMBER
1091 , X_module IN VARCHAR2
1092 , rows IN NUMBER
1093 , X_status OUT NOCOPY NUMBER )
1094 IS
1095 temp_status NUMBER DEFAULT NULL;
1096 BEGIN
1097 FOR i IN 1..rows LOOP
1098
1099 UPDATE pa_expenditure_items_all ei
1100 SET
1101 ei.revenue_distributed_flag = 'N'
1102 , ei.rev_dist_rejection_code = NULL /*Added for bug 9367103*/
1103 , ei.last_update_date = sysdate
1104 , ei.last_updated_by = X_user
1105 , ei.last_update_login = X_login
1106 WHERE
1107 ei.expenditure_item_id = ItemsIdTab(i);
1108
1109 InsAuditRec( ItemsIdTab(i)
1110 , 'REVENUE RECALC'
1111 , X_module
1112 , X_user
1113 , X_login
1114 , temp_status
1115 /* R12 Changes Start */
1116 , G_REQUEST_ID
1117 , G_PROGRAM_ID
1118 , G_PROG_APPL_ID
1119 , sysdate );
1120 /* R12 Changes End */
1121 CheckStatus( temp_status );
1122
1123 IF ( AdjustsIdTab(i) IS NOT NULL ) THEN
1124
1125 UPDATE pa_expenditure_items_all eia
1126 SET
1127 eia.revenue_distributed_flag = 'N'
1128 , eia.rev_dist_rejection_code = NULL /*Added for bug 9367103*/
1129 , eia.last_update_date = sysdate
1130 , eia.last_updated_by = X_user
1131 , eia.last_update_login = X_login
1132 WHERE
1133 eia.expenditure_item_id = AdjustsIdTab(i);
1134
1135 InsAuditRec( AdjustsIdTab(i)
1136 , 'REVENUE RECALC'
1137 , X_module
1138 , X_user
1139 , X_login
1140 , temp_status
1141 /* R12 Changes Start */
1142 , G_REQUEST_ID
1143 , G_PROGRAM_ID
1144 , G_PROG_APPL_ID
1145 , sysdate );
1146 /* R12 Changes End */
1147 CheckStatus( temp_status );
1148
1149 END IF;
1150 -- This part has been added for Bug # 720199. Calls the newly created procedure
1151 -- to set revenue distributed flag to 'N' for related items as well.
1152
1153 RecalcRelatedItems( ItemsIdTab(i)
1154 , X_user
1155 , X_login
1156 , X_module
1157 , temp_status );
1158 CheckStatus( temp_status );
1159 END LOOP;
1160
1161 X_status := 0;
1162
1163 EXCEPTION
1164 WHEN OTHERS THEN
1165 X_status := SQLCODE;
1166 RAISE;
1167
1168 END RecalcRev;
1169
1170
1171
1172 -- ========================================================================
1173 -- PROCEDURE RecalcCostRev
1174 -- ========================================================================
1175
1176 PROCEDURE RecalcCostRev( ItemsIdTab IN pa_utils.IdTabTyp
1177 , AdjustsIdTab IN pa_utils.IdTabTyp
1178 , X_user IN NUMBER
1179 , X_login IN NUMBER
1180 , X_module IN VARCHAR2
1181 , rows IN NUMBER
1182 , X_num_processed OUT NOCOPY NUMBER
1183 , X_status OUT NOCOPY NUMBER )
1184 IS
1185 temp_status NUMBER DEFAULT NULL;
1186 item_count NUMBER := 0;
1187 trx_source_costed VARCHAR2(1) DEFAULT 'N';
1188 trx_source_accounted VARCHAr2(1) DEFAULT 'N';
1189 trx_source_burden VARCHAR2(1) DEFAULT 'N';
1190 system_linkage VARCHAR2(30);
1191
1192 PROCEDURE RecalcRelatedItems( X_expenditure_item_id IN NUMBER
1193 , X_user IN NUMBER
1194 , X_login IN NUMBER
1195 , X_module IN VARCHAR2
1196 , X_status OUT NOCOPY NUMBER )
1197 IS
1198 CURSOR GetRelatedItems IS
1199 SELECT
1200 expenditure_item_id
1201 FROM
1202 pa_expenditure_items_all
1203 WHERE
1204 source_expenditure_item_id = X_expenditure_item_id;
1205
1206 l_transaction_source VARCHAR2(30); --Bug 12816655
1207
1208 BEGIN
1209
1210 SELECT NVL(transaction_source, NULL)
1211 INTO l_transaction_source FROM pa_expenditure_items_all
1212 WHERE expenditure_item_id = X_expenditure_item_id; --Bug 12816655
1213
1214 FOR eachRec IN GetRelatedItems LOOP
1215
1216 UPDATE pa_expenditure_items_all ei
1217 SET
1218 cost_distributed_flag = 'N'
1219 , revenue_distributed_flag = 'N'
1220 , rev_dist_rejection_code = NULL /*Added for bug 9367103*/
1221 , denom_raw_cost = NULL
1222 , raw_cost_rate = NULL
1223 , acct_raw_cost = NULL
1224 , raw_cost = NULL
1225 /* Added denom_currency_code for Bug#2291180 */
1226 , denom_currency_code = pa_adjustments.get_denom_curr_code(l_transaction_source,expenditure_type,denom_currency_code,acct_currency_code,system_linkage_function) --Bug 12816655
1227 , denom_burdened_cost = NULL
1228 , acct_burdened_cost = NULL
1229 , burden_cost_rate = NULL
1230 , burden_cost = NULL
1231 /* Begin Burdening Changes - PA.L */
1232 , adjustment_type = 'RECALC_RAW'
1233 /* End Burdening Changes - PA.L */
1234 , project_raw_cost = NULL
1235 , project_burdened_cost = NULL
1236 , labor_cost_multiplier_name = (select labor_cost_multiplier_name from pa_tasks t where t.task_id = ei.task_id) /* Bug 9670726 */
1237 , last_updated_by = X_user
1238 , last_update_date = sysdate
1239 , last_update_login = X_login
1240 WHERE
1241 expenditure_item_id = eachRec.expenditure_item_id;
1242
1243 item_count := item_count + 1;
1244
1245 pa_adjustments.InsAuditRec( eachRec.expenditure_item_id
1246 , 'COST AND REV RECALC'
1247 , X_module
1248 , X_user
1249 , X_login
1250 , temp_status
1251 /* R12 Changes Start */
1252 , G_REQUEST_ID
1253 , G_PROGRAM_ID
1254 , G_PROG_APPL_ID
1255 , sysdate );
1256 /* R12 Changes End */
1257 CheckStatus( temp_status );
1258
1259 END LOOP;
1260
1261 X_status := 0;
1262
1263 EXCEPTION
1264 WHEN OTHERS THEN
1265 X_status := SQLCODE;
1266 RAISE;
1267
1268 END RecalcRelatedItems;
1269
1270
1271 BEGIN
1272 FOR i IN 1..rows LOOP
1273
1274 SELECT
1275 nvl( txs.costed_flag, 'N' )
1276 , nvl(txs.gl_accounted_flag,'N')
1277 , nvl(txs.allow_burden_flag, 'N')
1278 , ei.system_linkage_function INTO
1279 trx_source_costed
1280 , trx_source_accounted
1281 , trx_source_burden
1282 , system_linkage
1283 FROM
1284 pa_expenditure_items_all ei
1285 , pa_transaction_sources txs
1286 WHERE
1287 ei.transaction_source = txs.transaction_source(+)
1288 AND ei.expenditure_item_id = ItemsIdTab(i);
1289
1290 /* R12 Changes - Added system linkage ER in addition to VI. In R12, users
1291 cannot create Expense Reports in Projects. The following change
1292 will prohibit the user from recalculating cost for historical
1293 Expense Reports created in Projects */
1294 UPDATE pa_expenditure_items_all ei
1295 SET
1296 ei.cost_distributed_flag = 'N'
1297 /* Reverted: Added for bug #2027985
1298 decode( system_linkage, 'VI', ei.cost_distributed_flag,
1299 'ER', ei.cost_distributed_flag,
1300 decode( trx_source_costed, 'N', 'N', ei.cost_distributed_flag ) )
1301 End of fix for #2027985 */
1302 , ei.revenue_distributed_flag = 'N'
1303 , ei.rev_dist_rejection_code = NULL /*Added for bug 9367103*/
1304 , ei.denom_raw_cost =
1305 decode( system_linkage, 'VI', ei.denom_raw_cost,
1306 'ER', ei.denom_raw_cost,
1307 decode( trx_source_costed, 'N', NULL, ei.denom_raw_cost ) )
1308 , ei.raw_cost_rate =
1309 decode( system_linkage, 'VI', ei.raw_cost_rate,
1310 'ER', ei.raw_cost_rate,
1311 decode( trx_source_costed, 'N', NULL, ei.raw_cost_rate ) )
1312 , ei.acct_raw_cost =
1313 decode( system_linkage, 'VI', ei.acct_raw_cost,
1314 'ER', ei.acct_raw_cost, /* Bug 5191357 */
1315 decode( trx_source_accounted, 'N', NULL, ei.acct_raw_cost) )
1316 , ei.raw_cost = NULL
1317 , ei.denom_burdened_cost = decode( trx_source_burden, 'N',
1318 decode(system_linkage, 'BTC', ei.denom_burdened_cost, NULL),decode(getprojburdenflag(ei.project_id),'N',NULL,ei.denom_burdened_cost) ) /*Added for bug:7157616*/
1319 /* Added denom_currency_code for Bug#2291180 */
1320 , ei.denom_currency_code = pa_adjustments.get_denom_curr_code(ei.transaction_source,ei.expenditure_type, ei.denom_currency_code, ei.acct_currency_code, ei.system_linkage_function)
1321 , ei.acct_burdened_cost = NULL
1322 , ei.burden_cost_rate = NULL
1323 , ei.burden_cost = NULL
1324 /* Begin Burdening Changes - PA.L */
1325 , ei.adjustment_type = 'RECALC_RAW'
1326 /* End Burdening Changes - PA.L */
1327 , ei.project_raw_cost = NULL
1328 , ei.project_burdened_cost = NULL
1329 , ei.labor_cost_multiplier_name =(select labor_cost_multiplier_name from pa_tasks t where t.task_id = ei.task_id) /* Bug 9670726 */
1330 , ei.last_update_date = sysdate
1331 , ei.last_updated_by = X_user
1332 , ei.last_update_login = X_login
1333 WHERE
1334 ei.expenditure_item_id = ItemsIdTab(i);
1335
1336 item_count := item_count + 1;
1337
1338 InsAuditRec( ItemsIdTab(i)
1339 , 'COST AND REV RECALC'
1340 , X_module
1341 , X_user
1342 , X_login
1343 , temp_status
1344 /* R12 Changes Start */
1345 , G_REQUEST_ID
1346 , G_PROGRAM_ID
1347 , G_PROG_APPL_ID
1348 , sysdate );
1349 /* R12 Changes End */
1350 CheckStatus( temp_status );
1351
1352 IF ( AdjustsIdTab(i) IS NOT NULL ) THEN
1353
1354 UPDATE pa_expenditure_items_all ei
1355 SET
1356 ei.cost_distributed_flag = 'N'
1357 /* Reverted : Added for bug #2027985
1358 decode( system_linkage, 'VI', ei.cost_distributed_flag,
1359 'ER', ei.cost_distributed_flag,
1360 decode( trx_source_costed, 'N', 'N', ei.cost_distributed_flag ) )
1361 End of fix for #2027985 */
1362 , ei.revenue_distributed_flag = 'N'
1363 , ei.rev_dist_rejection_code = NULL /*Added for bug 9367103*/
1364 , ei.denom_raw_cost =
1365 decode( system_linkage, 'VI', ei.denom_raw_cost,
1366 'ER', ei.denom_raw_cost,
1367 decode( trx_source_costed, 'N', NULL, ei.denom_raw_cost ) )
1368 , ei.raw_cost_rate =
1369 decode( system_linkage, 'VI', ei.raw_cost_rate,
1370 'ER', ei.raw_cost_rate,
1371 decode( trx_source_costed, 'N', NULL, ei.raw_cost_rate ) )
1372 , ei.acct_raw_cost =
1373 decode( system_linkage, 'VI', ei.acct_raw_cost,
1374 'ER', ei.acct_raw_cost,
1375 decode( trx_source_accounted, 'N', NULL, ei.acct_raw_cost ) )
1376 , ei.raw_cost = NULL
1377 , ei.denom_burdened_cost =
1378 decode( trx_source_burden, 'N', NULL, decode(getprojburdenflag(ei.project_id),'N',NULL,ei.denom_burdened_cost) ) /*Added for bug:7157616*/
1379 /* Added denom_currency_code for Bug#2291180 */
1380 , ei.denom_currency_code = pa_adjustments.get_denom_curr_code(ei.transaction_source,ei.expenditure_type, ei.denom_currency_code, ei.acct_currency_code, ei.system_linkage_function)
1381 , ei.acct_burdened_cost = NULL
1382 , ei.burden_cost_rate = NULL
1383 , ei.burden_cost = NULL
1384 , ei.project_burdened_cost = NULL
1385 , ei.project_raw_cost = NULL
1386 , ei.last_update_date = sysdate
1387 , ei.last_updated_by = X_user
1388 , ei.last_update_login = X_login
1389 WHERE
1390 ei.expenditure_item_id = AdjustsIdTab(i);
1391
1392 item_count := item_count + 1;
1393
1394 InsAuditRec( AdjustsIdTab(i)
1395 , 'COST AND REV RECALC'
1396 , X_module
1397 , X_user
1398 , X_login
1399 , temp_status
1400 /* R12 Changes Start */
1401 , G_REQUEST_ID
1402 , G_PROGRAM_ID
1403 , G_PROG_APPL_ID
1404 , sysdate );
1405 /* R12 Changes End */
1406 CheckStatus( temp_status );
1407
1408 END IF;
1409
1410 RecalcRelatedItems( ItemsIdTab(i)
1411 , X_user
1412 , X_login
1413 , X_module
1414 , temp_status );
1415 CheckStatus( temp_status );
1416
1417 END LOOP;
1418
1419 X_status := 0;
1420 X_num_processed := item_count;
1421 EXCEPTION
1422 WHEN OTHERS THEN
1423 X_status := SQLCODE;
1424 RAISE;
1425
1426 END RecalcCostRev;
1427
1428
1429
1430 -- ========================================================================
1431 -- PROCEDURE RecalcIndCost
1432 -- ========================================================================
1433
1434 PROCEDURE RecalcIndCost( ItemsIdTab IN pa_utils.IdTabTyp
1435 , AdjustsIdTab IN pa_utils.IdTabTyp
1436 , X_user IN NUMBER
1437 , X_login IN NUMBER
1438 , X_module IN VARCHAR2
1439 , rows IN BINARY_INTEGER
1440 , X_status OUT NOCOPY NUMBER )
1441 IS
1442 temp_status NUMBER DEFAULT NULL;
1443 trx_source_burden VARCHAR2(1) DEFAULT 'N';
1444 system_linkage VARCHAR2(30);
1445
1446 BEGIN
1447 FOR i IN 1..rows LOOP
1448
1449 SELECT
1450 nvl(txs.allow_burden_flag, 'N'),
1451 ei.system_linkage_function
1452 INTO
1453 trx_source_burden,
1454 system_linkage
1455 FROM
1456 pa_expenditure_items_all ei
1457 , pa_transaction_sources txs
1458 WHERE
1459 ei.transaction_source = txs.transaction_source(+)
1460 AND ei.expenditure_item_id = ItemsIdTab(i);
1461
1462 -- Added the Decode function for the acct_burdened_cost,burden_cost_rate,burden_cost
1463 -- to fix the bug fix : 1490316
1464
1465 UPDATE pa_expenditure_items_all ei
1466 SET
1467 ei.cost_distributed_flag = 'N'
1468 , ei.denom_burdened_cost =
1469 decode( trx_source_burden, 'N',
1470 decode(system_linkage, 'BTC', ei.denom_burdened_cost, NULL), ei.denom_burdened_cost )
1471 , ei.acct_burdened_cost =
1472 decode( trx_source_burden, 'N',
1473 decode(system_linkage, 'BTC', ei.acct_burdened_cost ,NULL),ei.acct_burdened_cost)
1474 , ei.burden_cost_rate =
1475 decode( trx_source_burden, 'N',
1476 decode(system_linkage, 'BTC',ei.burden_cost_rate ,NULL),ei.burden_cost_rate)
1477 , ei.burden_cost =
1478 decode( trx_source_burden, 'N',
1479 decode(system_linkage, 'BTC',ei.burden_cost,NULL),ei.burden_cost)
1480 , ei.project_burdened_cost =
1481 decode( trx_source_burden, 'N',
1482 decode(system_linkage, 'BTC',ei.project_burdened_cost,NULL),ei.project_burdened_cost)
1483 /* Begin Burdening Changes - PA.L */
1484 , ei.adjustment_type = decode(ei.adjustment_type, 'RECALC_RAW', ei.adjustment_type
1485 , decode(ei.system_linkage_function, 'BTC', 'RECALC_RAW', 'RECALC_BURDEN'))
1486 /* End Burdening Changes - PA.L */
1487 , ei.last_update_date = sysdate
1488 , ei.last_updated_by = X_user
1489 , ei.last_update_login = X_login
1490 WHERE
1491 ei.expenditure_item_id = ItemsIdTab(i);
1492
1493 InsAuditRec( ItemsIdTab(i)
1494 , 'INDIRECT COST RECALC'
1495 , X_module
1496 , X_user
1497 , X_login
1498 , temp_status
1499 /* R12 Changes Start */
1500 , G_REQUEST_ID
1501 , G_PROGRAM_ID
1502 , G_PROG_APPL_ID
1503 , sysdate );
1504 /* R12 Changes End */
1505 CheckStatus( temp_status );
1506
1507 IF ( AdjustsIdTab(i) IS NOT NULL ) THEN
1508
1509 UPDATE pa_expenditure_items_all eia
1510 SET
1511 eia.cost_distributed_flag = 'N'
1512 , eia.denom_burdened_cost =
1513 decode( trx_source_burden, 'N', NULL, eia.denom_burdened_cost )
1514 , eia.acct_burdened_cost = NULL
1515 , eia.burden_cost_rate = NULL
1516 , eia.burden_cost = NULL
1517 , eia.project_burdened_cost = NULL
1518 , eia.last_update_date = sysdate
1519 , eia.last_updated_by = X_user
1520 , eia.last_update_login = X_login
1521 WHERE
1522 eia.expenditure_item_id = AdjustsIdTab(i);
1523
1524 InsAuditRec( AdjustsIdTab(i)
1525 , 'INDIRECT COST RECALC'
1526 , X_module
1527 , X_user
1528 , X_login
1529 , temp_status
1530 /* R12 Changes Start */
1531 , G_REQUEST_ID
1532 , G_PROGRAM_ID
1533 , G_PROG_APPL_ID
1534 , sysdate );
1535 /* R12 Changes End */
1536 CheckStatus( temp_status );
1537
1538 END IF;
1539 END LOOP;
1540
1541 X_status := 0;
1542
1543 EXCEPTION
1544 WHEN OTHERS THEN
1545 X_status := SQLCODE;
1546 RAISE;
1547
1548 END RecalcIndCost;
1549
1550
1551 -- ========================================================================
1552 -- PROCEDURE RecalcRawCost
1553 -- ========================================================================
1554
1555 -- This is the exact same procedure as RecalcCostRev, except it
1556 -- inserts the action 'RAW COST RECALC' into the adjustment activity
1557 -- table, instead of 'COST AND REV RECALC'. Used for indirect and
1558 -- capital (v4.0) projects, where the latter action would not make sense.
1559
1560 PROCEDURE RecalcRawCost( ItemsIdTab IN pa_utils.IdTabTyp
1561 , AdjustsIdTab IN pa_utils.IdTabTyp
1562 , X_user IN NUMBER
1563 , X_login IN NUMBER
1564 , X_module IN VARCHAR2
1565 , rows IN NUMBER
1566 , X_num_processed OUT NOCOPY NUMBER
1567 , X_status OUT NOCOPY NUMBER )
1568 IS
1569 temp_status NUMBER DEFAULT NULL;
1570 item_count NUMBER := 0;
1571 trx_source_costed VARCHAR2(1) DEFAULT 'N';
1572 trx_source_accounted VARCHAR2(1) DEFAULT 'N';
1573 trx_source_burden VARCHAR2(1) DEFAULT 'N';
1574 system_linkage VARCHAR2(30);
1575
1576 PROCEDURE RecalcRelatedItems( X_expenditure_item_id IN NUMBER
1577 , X_user IN NUMBER
1578 , X_login IN NUMBER
1579 , X_module IN VARCHAR2
1580 , X_status OUT NOCOPY NUMBER )
1581 IS
1582 CURSOR GetRelatedItems IS
1583 SELECT
1584 expenditure_item_id
1585 FROM
1586 pa_expenditure_items_all
1587 WHERE
1588 source_expenditure_item_id = X_expenditure_item_id;
1589
1590 l_transaction_source VARCHAR2(30); --Bug 12816655
1591
1592 BEGIN
1593
1594 SELECT NVL(transaction_source, NULL)
1595 INTO l_transaction_source FROM pa_expenditure_items_all
1596 WHERE expenditure_item_id = X_expenditure_item_id; --Bug 12816655
1597
1598 FOR eachRec IN GetRelatedItems LOOP
1599
1600 UPDATE pa_expenditure_items_all ei
1601 SET
1602 cost_distributed_flag = 'N'
1603 , revenue_distributed_flag = 'N'
1604 , rev_dist_rejection_code = NULL /*Added for bug 9304451*/
1605 , denom_raw_cost = NULL
1606 , acct_raw_cost = NULL
1607 , raw_cost = NULL
1608 , raw_cost_rate = NULL
1609 /* Added denom_currency_code for Bug#2291180 */
1610 , denom_currency_code = pa_adjustments.get_denom_curr_code(l_transaction_source,expenditure_type,denom_currency_code,acct_currency_code,system_linkage_function) --Bug 12816655
1611 , denom_burdened_cost = NULL
1612 , acct_burdened_cost = NULL
1613 , burden_cost_rate = NULL
1614 , burden_cost = NULL
1615 /* Begin Burdening Changes - PA.L */
1616 , adjustment_type = 'RECALC_RAW'
1617 /* End Burdening Changes - PA.L */
1618 , project_raw_cost = NULL
1619 , project_burdened_cost = NULL
1620 , labor_cost_multiplier_name = (select labor_cost_multiplier_name from pa_tasks t where t.task_id = ei.task_id) /* Bug 9670726 */
1621 , last_updated_by = X_user
1622 , last_update_date = sysdate
1623 , last_update_login = X_login
1624 WHERE
1625 expenditure_item_id = eachRec.expenditure_item_id;
1626
1627 item_count := item_count + 1;
1628
1629 pa_adjustments.InsAuditRec( eachRec.expenditure_item_id
1630 , 'RAW COST RECALC'
1631 , X_module
1632 , X_user
1633 , X_login
1634 , temp_status
1635 /* R12 Changes Start */
1636 , G_REQUEST_ID
1637 , G_PROGRAM_ID
1638 , G_PROG_APPL_ID
1639 , sysdate );
1640 /* R12 Changes End */
1641 CheckStatus( temp_status );
1642
1643 END LOOP;
1644
1645 X_status := 0;
1646
1647 EXCEPTION
1648 WHEN OTHERS THEN
1649 X_status := SQLCODE;
1650 RAISE;
1651
1652 END RecalcRelatedItems;
1653
1654
1655 BEGIN
1656 FOR i IN 1..rows LOOP
1657
1658 SELECT
1659 nvl( txs.costed_flag, 'N' )
1660 , nvl(txs.gl_accounted_flag,'N')
1661 , nvl(txs.allow_burden_flag, 'N')
1662 , ei.system_linkage_function
1663 INTO
1664 trx_source_costed
1665 , trx_source_accounted
1666 , trx_source_burden
1667 , system_linkage
1668 FROM
1669 pa_expenditure_items_all ei
1670 , pa_transaction_sources txs
1671 WHERE
1672 ei.transaction_source = txs.transaction_source(+)
1673 AND ei.expenditure_item_id = ItemsIdTab(i);
1674
1675 /* R12 Changes - Added system linkage ER in addition to VI. In R12, users
1676 cannot create Expense Reports in Projects. The following change
1677 will prohibit the user from recalculating cost for historical
1678 Expense Reports created in Projects */
1679 UPDATE pa_expenditure_items_all ei
1680 SET
1681 ei.cost_distributed_flag = 'N'
1682 /* Reverted: Added for bug #2027985
1683 decode( system_linkage, 'VI', ei.cost_distributed_flag,
1684 'ER', ei.cost_distributed_flag,
1685 decode( trx_source_costed, 'N', 'N', ei.cost_distributed_flag ) )
1686 End of fix for #2027985 */
1687 , ei.revenue_distributed_flag = 'N'
1688 , ei.rev_dist_rejection_code = NULL /*Added for bug 9304451*/
1689 , ei.denom_raw_cost =
1690 decode( system_linkage, 'VI', ei.denom_raw_cost,
1691 'ER', ei.denom_raw_cost,
1692 decode( trx_source_costed, 'N', NULL, ei.denom_raw_cost ) )
1693 , ei.raw_cost_rate =
1694 decode( system_linkage, 'VI', ei.raw_cost_rate,
1695 'ER', ei.raw_cost_rate,
1696 decode( trx_source_costed, 'N', NULL, ei.raw_cost_rate ) )
1697 , ei.acct_raw_cost =
1698 decode( system_linkage, 'VI', ei.acct_raw_cost,
1699 'ER', ei.acct_raw_cost,
1700 decode( trx_source_accounted, 'N', NULL, ei.acct_raw_cost ) )
1701 , ei.raw_cost = NULL
1702 , ei.denom_burdened_cost =decode( trx_source_burden, 'N',
1703 decode(system_linkage, 'BTC', ei.denom_burdened_cost, NULL)
1704 ,decode(getprojburdenflag(ei.project_id),'N',NULL,ei.denom_burdened_cost)) /*added for bug:7157616*/
1705 /* Added denom_currency_code for Bug#2291180 */
1706 , ei.denom_currency_code = pa_adjustments.get_denom_curr_code(ei.transaction_source,ei.expenditure_type, ei.denom_currency_code, ei.acct_currency_code, ei.system_linkage_function)
1707 , ei.acct_burdened_cost = NULL
1708 , ei.burden_cost_rate = NULL
1709 , ei.burden_cost = NULL
1710 /* Begin Burdening Changes - PA.L */
1711 , ei.adjustment_type = 'RECALC_RAW'
1712 /* End Burdening Changes - PA.L */
1713 , ei.project_raw_cost = null
1714 , ei.project_burdened_cost = null
1715 , ei.labor_cost_multiplier_name = (select labor_cost_multiplier_name from pa_tasks t where t.task_id = ei.task_id) /* Bug 9670726 */
1716 , ei.last_update_date = sysdate
1717 , ei.last_updated_by = X_user
1718 , ei.last_update_login = X_login
1719 WHERE
1720 ei.expenditure_item_id = ItemsIdTab(i);
1721
1722 item_count := item_count + 1;
1723
1724 InsAuditRec( ItemsIdTab(i)
1725 , 'RAW COST RECALC'
1726 , X_module
1727 , X_user
1728 , X_login
1729 , temp_status
1730 /* R12 Changes Start */
1731 , G_REQUEST_ID
1732 , G_PROGRAM_ID
1733 , G_PROG_APPL_ID
1734 , sysdate );
1735 /* R12 Changes End */
1736 CheckStatus( temp_status );
1737
1738 IF ( AdjustsIdTab(i) IS NOT NULL ) THEN
1739
1740 UPDATE pa_expenditure_items_all ei
1741 SET
1742 ei.cost_distributed_flag ='N'
1743 /* Reverted: Added for bug #2027985
1744 decode( system_linkage, 'VI', ei.cost_distributed_flag,
1745 'ER', ei.cost_distributed_flag,
1746 decode( trx_source_costed, 'N', 'N', ei.cost_distributed_flag ) )
1747 End of fix for #2027985 */
1748 , ei.revenue_distributed_flag = 'N'
1749 , ei.rev_dist_rejection_code = NULL /*Added for bug 9304451*/
1750 , ei.denom_raw_cost =
1751 decode( system_linkage, 'VI', ei.denom_raw_cost,
1752 'ER', ei.denom_raw_cost,
1753 decode( trx_source_costed, 'N', NULL, ei.denom_raw_cost ) )
1754 , ei.raw_cost_rate =
1755 decode( system_linkage, 'VI', ei.raw_cost_rate,
1756 'ER', ei.raw_cost_rate,
1757 decode( trx_source_costed, 'N', NULL, ei.raw_cost_rate ) )
1758 , ei.acct_raw_cost =
1759 decode( system_linkage, 'VI', ei.acct_raw_cost,
1760 'ER', ei.acct_raw_cost,
1761 decode( trx_source_accounted, 'N', NULL, ei.acct_raw_cost ) )
1762 , ei.denom_burdened_cost =
1763 decode( trx_source_burden, 'N', NULL, decode(getprojburdenflag(ei.project_id),'N',NULL,ei.denom_burdened_cost) ) /*added for bug:7157616*/
1764 /* Added denom_currency_code for Bug#2291180 */
1765 , ei.denom_currency_code = pa_adjustments.get_denom_curr_code(ei.transaction_source,ei.expenditure_type, ei.denom_currency_code, ei.acct_currency_code, ei.system_linkage_function)
1766 , ei.acct_burdened_cost = NULL
1767 , ei.burden_cost_rate = NULL
1768 , ei.burden_cost = NULL
1769 , ei.raw_cost = NULL
1770 , ei.project_burdened_cost = null
1771 , ei.project_raw_cost = null
1772 , ei.last_update_date = sysdate
1773 , ei.last_updated_by = X_user
1774 , ei.last_update_login = X_login
1775 WHERE
1776 ei.expenditure_item_id = AdjustsIdTab(i);
1777
1778 item_count := item_count + 1;
1779
1780 InsAuditRec( AdjustsIdTab(i)
1781 , 'RAW COST RECALC'
1782 , X_module
1783 , X_user
1784 , X_login
1785 , temp_status
1786 /* R12 Changes Start */
1787 , G_REQUEST_ID
1788 , G_PROGRAM_ID
1789 , G_PROG_APPL_ID
1790 , sysdate );
1791 /* R12 Changes End */
1792 CheckStatus( temp_status );
1793
1794 END IF;
1795
1796 RecalcRelatedItems( ItemsIdTab(i)
1797 , X_user
1798 , X_login
1799 , X_module
1800 , temp_status );
1801 CheckStatus( temp_status );
1802
1803 END LOOP;
1804
1805 X_status := 0;
1806 X_num_processed := item_count;
1807
1808 EXCEPTION
1809 WHEN OTHERS THEN
1810 X_status := SQLCODE;
1811 RAISE;
1812
1813 END RecalcRawCost;
1814
1815
1816 -- ========================================================================
1817 -- PROCEDURE RecalcCapCost
1818 -- ========================================================================
1819
1820 -- This is the exact same as RecalcIndCost, except it also sets the
1821 -- revenue_distributed_flag to 'N'. Used for expenditure items
1822 -- belonging to CAPITAL projects (v4.0).
1823
1824 PROCEDURE RecalcCapCost( ItemsIdTab IN pa_utils.IdTabTyp
1825 , AdjustsIdTab IN pa_utils.IdTabTyp
1826 , X_user IN NUMBER
1827 , X_login IN NUMBER
1828 , X_module IN VARCHAR2
1829 , rows IN BINARY_INTEGER
1830 , X_status OUT NOCOPY NUMBER )
1831 IS
1832 temp_status NUMBER DEFAULT NULL;
1833 trx_source_burden VARCHAR2(1) DEFAULT 'N';
1834 system_linkage VARCHAR2(30);
1835
1836 BEGIN
1837 FOR i IN 1..rows LOOP
1838
1839 SELECT
1840 nvl(txs.allow_burden_flag, 'N'),
1841 ei.system_linkage_function
1842 INTO
1843 trx_source_burden,
1844 system_linkage
1845 FROM
1846 pa_expenditure_items_all ei
1847 , pa_transaction_sources txs
1848 WHERE
1849 ei.transaction_source = txs.transaction_source(+)
1850 AND ei.expenditure_item_id = ItemsIdTab(i);
1851
1852 --- Added the decode function for the following columns acct_burdened_cost,burden_cost_rate,
1853 --- burden_cost as a bug fix : 1490316, it enables to recalc BTC ei only for the accounting
1854 --- purpose.
1855
1856 UPDATE pa_expenditure_items_all ei
1857 SET
1858 ei.cost_distributed_flag = 'N'
1859 , ei.revenue_distributed_flag = 'N'
1860 , ei.rev_dist_rejection_code = NULL /*Added for bug:9367103 */
1861 , ei.denom_burdened_cost =
1862 decode( trx_source_burden, 'N',
1863 decode(system_linkage, 'BTC', ei.denom_burdened_cost, NULL), ei.denom_burdened_cost )
1864 , ei.acct_burdened_cost =
1865 decode( trx_source_burden, 'N',
1866 decode(system_linkage, 'BTC', ei.acct_burdened_cost,NULL), ei.acct_burdened_cost )
1867 , ei.burden_cost_rate =
1868 decode( trx_source_burden, 'N',
1869 decode(system_linkage, 'BTC', ei.burden_cost_rate , NULL), ei.burden_cost_rate )
1870 , ei.burden_cost =
1871 decode( trx_source_burden, 'N',
1872 decode(system_linkage, 'BTC',ei.burden_cost , NULL ),ei.burden_cost )
1873 , ei.project_burdened_cost =
1874 decode( trx_source_burden, 'N',
1875 decode(system_linkage, 'BTC',ei.project_burdened_cost , NULL ),ei.project_burdened_cost )
1876 /* Begin Burdening Changes - PA.L */
1877 , ei.adjustment_type = decode(ei.adjustment_type, 'RECALC_RAW', ei.adjustment_type
1878 , decode(ei.system_linkage_function, 'BTC', 'RECALC_BURDEN', NVL(ei.adjustment_type,'RECALC_BURDEN'))) -- Added for bug 12905612
1879 /* End Burdening Changes - PA.L */
1880 , ei.last_update_date = sysdate
1881 , ei.last_updated_by = X_user
1882 , ei.last_update_login = X_login
1883 WHERE
1884 ei.expenditure_item_id = ItemsIdTab(i);
1885
1886 InsAuditRec( ItemsIdTab(i)
1887 , 'INDIRECT COST RECALC'
1888 , X_module
1889 , X_user
1890 , X_login
1891 , temp_status
1892 /* R12 Changes Start */
1893 , G_REQUEST_ID
1894 , G_PROGRAM_ID
1895 , G_PROG_APPL_ID
1896 , sysdate );
1897 /* R12 Changes End */
1898 CheckStatus( temp_status );
1899
1900 IF ( AdjustsIdTab(i) IS NOT NULL ) THEN
1901
1902 UPDATE pa_expenditure_items_all eia
1903 SET
1904 eia.cost_distributed_flag = 'N'
1905 , eia.denom_burdened_cost =
1906 decode( trx_source_burden, 'N', NULL, eia.denom_burdened_cost )
1907 , eia.acct_burdened_cost = NULL
1908 , eia.burden_cost_rate = NULL
1909 , eia.burden_cost = NULL
1910 , eia.project_burdened_cost = NULL
1911 , eia.last_update_date = sysdate
1912 , eia.last_updated_by = X_user
1913 , eia.last_update_login = X_login
1914 WHERE
1915 eia.expenditure_item_id = AdjustsIdTab(i);
1916
1917 InsAuditRec( AdjustsIdTab(i)
1918 , 'INDIRECT COST RECALC'
1919 , X_module
1920 , X_user
1921 , X_login
1922 , temp_status
1923 /* R12 Changes Start */
1924 , G_REQUEST_ID
1925 , G_PROGRAM_ID
1926 , G_PROG_APPL_ID
1927 , sysdate );
1928 /* R12 Changes End */
1929 CheckStatus( temp_status );
1930
1931 END IF;
1932 END LOOP;
1933
1934 X_status := 0;
1935
1936 EXCEPTION
1937 WHEN OTHERS THEN
1938 X_status := SQLCODE;
1939 RAISE;
1940
1941 END RecalcCapCost;
1942
1943
1944 -- Fix for Bug # 553129. dhituval on 27-APR
1945 --====================================================================
1946 -- Function GetInvId
1947 --====================================================================
1948
1949 FUNCTION GetInvId(X_expenditure_item_id NUMBER) return VARCHAR2 is
1950
1951 v_system_reference2 VARCHAR2(30);
1952 v_exp_item_id NUMBER;
1953
1954 CURSOR c2 is
1955
1956 select expenditure_item_id
1957 from pa_expenditure_items_all peia
1958 where exists( select null
1959 from pa_cost_distribution_lines_all cdl
1960 where cdl.expenditure_item_id = peia.expenditure_item_id)
1961 start with expenditure_item_id = X_expenditure_item_id
1962 connect by prior transferred_from_exp_item_id = expenditure_item_id ;
1963
1964 BEGIN
1965
1966 for rec in c2 LOOP
1967
1968 select system_reference2 into v_system_reference2
1969 from pa_cost_distribution_lines_all
1970 where expenditure_item_id = rec.expenditure_item_id
1971 and line_num_reversed is null
1972 and reversed_flag is null
1973 and line_type = 'R';
1974
1975 END LOOP;
1976
1977 return v_system_reference2;
1978
1979 end GetInvId;
1980
1981
1982 --=======================================================================
1983 -- Function InvStatus
1984 --=======================================================================
1985 /* R12 changes */
1986 FUNCTION InvStatus( X_system_reference2 VARCHAR2
1987 , X_system_linkage_function VARCHAR2)
1988 return VARCHAR2 is
1989
1990 -- to check if invoice is cancelled or paid
1991 CURSOR check_inv_cur(p_invoice_id NUMBER) is
1992 SELECT CANCELLED_DATE,
1993 CANCELLED_BY
1994 FROM ap_invoices_all
1995 WHERE invoice_id = p_invoice_id
1996 FOR UPDATE OF INVOICE_ID NOWAIT;
1997 -- to lock the invoice during validation
1998
1999 l_cancelled_date DATE;
2000 l_cancelled_by NUMBER;
2001
2002 X_error_code VARCHAR2(30);
2003
2004 Resource_busy EXCEPTION ;
2005 PRAGMA EXCEPTION_INIT(Resource_busy,-00054) ;
2006
2007 BEGIN
2008
2009 X_error_code := 'N';
2010
2011 SAVEPOINT AP_PA_REL_LOCK;
2012 OPEN check_inv_cur(X_system_reference2);
2013 FETCH check_inv_cur
2014 INTO l_cancelled_date
2015 ,l_cancelled_by;
2016 CLOSE check_inv_cur;
2017
2018 /* check if invoice is cancelled (l_cancelled_date or l_cancelled_by is NOT NULL),
2019 this check will not be done if the adjustment action is BILLABLE/NON-BILLABLE */
2020 IF (l_cancelled_date IS NOT NULL
2021 OR l_cancelled_by IS NOT NULL) THEN
2022 X_Error_code := 'PA_INV_CANCELLED';
2023 END IF;
2024
2025 /* Release lock if adjustment is not allowed on expenditure item for this invoice */
2026 IF X_error_code <> 'N' THEN
2027 ROLLBACK to AP_PA_REL_LOCK;
2028 END IF;
2029 RETURN X_error_code;
2030
2031 EXCEPTION
2032 when Resource_busy then
2033 IF x_system_linkage_function = 'VI' THEN
2034 X_error_code := 'PA_ADJ_INV_OPEN_IN_AP';
2035 ELSE /* must be ER */
2036 X_error_code := 'PA_ADJ_ER_OPEN_IN_AP';
2037 END IF;
2038 RETURN X_error_code ;
2039 RAISE ;
2040 when others then
2041 RAISE;
2042
2043 END InvStatus;
2044
2045
2046 -- ========================================================================
2047 -- PROCEDURE Hold
2048 -- ========================================================================
2049
2050 PROCEDURE Hold( ItemsIdTab IN pa_utils.IdTabTyp
2051 , AdjustsIdTab IN pa_utils.IdTabTyp
2052 , X_hold IN VARCHAR2
2053 , X_adj_activity IN VARCHAR2
2054 , X_user IN NUMBER
2055 , X_login IN NUMBER
2056 , X_module IN VARCHAR2
2057 , rows IN BINARY_INTEGER
2058 , X_status OUT NOCOPY NUMBER )
2059 IS
2060 temp_status NUMBER DEFAULT NULL;
2061 BEGIN
2062
2063 FOR i IN 1..rows LOOP
2064
2065 UPDATE pa_expenditure_items_all ei
2066 SET
2067 ei.bill_hold_flag = X_hold
2068 , ei.last_updated_by = X_user
2069 , ei.last_update_date = sysdate
2070 , ei.last_update_login = X_login
2071 WHERE
2072 ei.expenditure_item_id = ItemsIdTab(i);
2073
2074 InsAuditRec( ItemsIdTab(i)
2075 , X_adj_activity
2076 , X_module
2077 , X_user
2078 , X_login
2079 , temp_status
2080 /* R12 Changes Start */
2081 , G_REQUEST_ID
2082 , G_PROGRAM_ID
2083 , G_PROG_APPL_ID
2084 , sysdate );
2085 /* R12 Changes End */
2086 CheckStatus( temp_status );
2087
2088 IF ( AdjustsIdTab(i) IS NOT NULL ) THEN
2089
2090 UPDATE pa_expenditure_items_all eia
2091 SET
2092 eia.bill_hold_flag = X_hold
2093 , eia.last_updated_by = X_user
2094 , eia.last_update_date = sysdate
2095 , eia.last_update_login = X_login
2096 WHERE
2097 eia.expenditure_item_id = AdjustsIdTab(i);
2098
2099 InsAuditRec( AdjustsIdTab(i)
2100 , X_adj_activity
2101 , X_module
2102 , X_user
2103 , X_login
2104 , temp_status
2105 /* R12 Changes Start */
2106 , G_REQUEST_ID
2107 , G_PROGRAM_ID
2108 , G_PROG_APPL_ID
2109 , sysdate );
2110 /* R12 Changes End */
2111 CheckStatus( temp_status );
2112
2113 END IF;
2114
2115 END LOOP;
2116
2117 X_status := 0;
2118
2119 EXCEPTION
2120 WHEN OTHERS THEN
2121 X_status := SQLCODE;
2122 RAISE;
2123
2124 END Hold;
2125
2126 -- ========================================================================
2127 -- Start of work type adjustments
2128 -- ========================================================================
2129 /** Logic:
2130 * If PA: Transaction Billability derived from Work Type = YES
2131 * and change in work type results in change in the billablity
2132 * then update EI with cost_distributed_flag = 'N' so that
2133 * costing process will generate reverse and new cdls
2134 * IF change in work type NOT results in chagne in billablity
2135 * then create new and reverse cdls with transfer status_code = 'G'
2136 * and Util summarize_flag = 'N' and update EI with cost_distributed_flag = 'Y'
2137 * so that the cdls are not picked up by summarized programm
2138 * If PA: Transaction Billability derived from Work Type = NO
2139 * work type and Billabiltiy are two independent process so
2140 * then create new and reverse cdls with transfer status_code = 'G'
2141 * and Util summarize_flag = 'N'
2142 * To change the billability of the transaction user has to run the
2143 * Reclass Billable / Non Billable adjustments seperately
2144 **/
2145 PROCEDURE work_type_adjustment
2146 ( ItemsIdTab IN pa_utils.IdTabTyp
2147 --, AdjustsIdTab IN pa_utils.IdTabTyp
2148 , p_billable IN VARCHAR2
2149 , p_work_type_id IN NUMBER
2150 , p_adj_activity IN VARCHAR2
2151 , p_user IN NUMBER
2152 , p_login IN NUMBER
2153 , p_module IN VARCHAR2
2154 , p_rows IN BINARY_INTEGER
2155 , p_TpAmtTypCodeTab IN pa_utils.Char30TabTyp
2156 , p_dest_tp_amt_type_code IN VARCHAR2
2157 , x_status OUT NOCOPY NUMBER )
2158 IS
2159 l_temp_status NUMBER DEFAULT NULL;
2160 l_err_code NUMBER ;
2161 l_err_stage VARCHAR2(2000);
2162 l_err_stack VARCHAR2(255) ;
2163
2164 l_new_billability VARCHAR2(10);
2165 l_old_billability VARCHAR2(10);
2166 l_old_work_type_id NUMBER ;
2167 l_profile_option VARCHAR2(1);
2168 l_change_in_billable VARCHAR2(1);
2169 l_gl_accounted_flag VARCHAR2(1);
2170 l_proj_type_class_code VARCHAR2(80);
2171 l_billable_cap_flag VARCHAR2(15);
2172 l_reverse_cdl_status varchar2(1) :='S' ;
2173
2174 FUNCTION cdl_creation
2175 ( p_exp_item_id IN NUMBER
2176 , p_billable IN VARCHAR2
2177 , p_work_type_id IN NUMBER
2178 , p_adj_activity IN VARCHAR2
2179 , p_user IN NUMBER
2180 , p_login IN NUMBER
2181 , p_module IN VARCHAR2
2182 , p_mode IN VARCHAR2
2183 , x_status OUT NOCOPY NUMBER
2184 , p_billable_change IN VARCHAR2
2185 , p_tp_amt_type_code IN VARCHAR2
2186 , p_dest_tp_amt_type_code IN VARCHAR2) return varchar2 IS
2187
2188 l_transaction_source VARCHAR2(30);
2189 l_gl_accounted_flag VARCHAR2(1);
2190 l_denom_currency_code VARCHAR2(15);
2191 l_acct_currency_code VARCHAR2(15);
2192 l_acct_rate_date DATE;
2193 l_acct_rate_type VARCHAR2(30);
2194 l_acct_exchange_rate NUMBER;
2195 l_project_currency_code VARCHAR2(15);
2196 l_project_rate_date DATE;
2197 l_project_rate_type VARCHAR2(30);
2198 l_project_exchange_rate NUMBER;
2199 l_system_linkage_function VARCHAR2(30);
2200 l_projfunc_currency_code VARCHAR2(15);
2201 l_projfunc_cost_rate_date DATE;
2202 l_projfunc_cost_rate_type VARCHAR2(30);
2203 l_projfunc_cost_exchg_rate NUMBER;
2204 l_work_type_id NUMBER;
2205 l_reverse_cdl_status varchar2(1) :='S' ;
2206
2207 BEGIN
2208
2209 BEGIN
2210 IF P_DEBUG_MODE THEN
2211 print_message('get_denom_curr_code: ' || 'inside cdl_creation api before SELECT ');
2212 END IF;
2213 SELECT
2214 ei.transaction_source,
2215 tr.gl_accounted_flag,
2216 ei.denom_currency_code,
2217 ei.acct_currency_code,
2218 ei.acct_rate_date,
2219 ei.acct_rate_type,
2220 ei.acct_exchange_rate,
2221 ei.project_currency_code,
2222 ei.project_rate_date,
2223 ei.project_rate_type,
2224 ei.project_exchange_rate,
2225 tr.system_linkage_function,
2226 ei.projfunc_currency_code,
2227 ei.projfunc_cost_rate_date,
2228 ei.projfunc_cost_rate_type,
2229 ei.projfunc_cost_exchange_rate,
2230 ei.work_type_id
2231 INTO
2232 l_transaction_source,
2233 l_gl_accounted_flag,
2234 l_denom_currency_code,
2235 l_acct_currency_code,
2236 l_acct_rate_date,
2237 l_acct_rate_type,
2238 l_acct_exchange_rate,
2239 l_project_currency_code,
2240 l_project_rate_date,
2241 l_project_rate_type,
2242 l_project_exchange_rate,
2243 l_system_linkage_function,
2244 l_projfunc_currency_code,
2245 l_projfunc_cost_rate_date,
2246 l_projfunc_cost_rate_type,
2247 l_projfunc_cost_exchg_rate,
2248 l_work_type_id
2249 FROM pa_expenditure_items_all ei,
2250 pa_transaction_sources tr
2251 WHERE tr.transaction_source(+) = ei.transaction_source
2252 AND expenditure_item_id = p_exp_item_id;
2253
2254 IF P_DEBUG_MODE THEN
2255 print_message('get_denom_curr_code: ' || 'inside cdl_creation api after SELECT ');
2256 END IF;
2257
2258
2259 IF ( l_gl_accounted_flag = 'Y' and l_system_linkage_function <> 'VI' )
2260 OR ( p_billable_change = 'N') then
2261
2262 IF P_DEBUG_MODE THEN
2263 print_message('get_denom_curr_code: ' || 'calling pa_costing reversecdl api from work type adjustment api');
2264 END IF;
2265 Pa_Costing.ReverseCdl
2266 ( X_expenditure_item_id => p_exp_item_id
2267 , X_billable_flag => p_billable
2268 , X_amount => NULL
2269 , X_quantity => NULL
2270 , X_burdened_cost => NULL
2271 , X_dr_ccid => NULL
2272 , X_cr_ccid => NULL
2273 , X_tr_source_accounted => 'Y'
2274 , X_line_type => 'R'
2275 , X_user => p_user
2276 , X_denom_currency_code => l_denom_currency_code
2277 , X_denom_raw_cost => NULL
2278 , X_denom_burden_cost => NULL
2279 , X_acct_currency_code => l_acct_currency_code
2280 , X_acct_rate_date => l_acct_rate_date
2281 , X_acct_rate_type => l_acct_rate_type
2282 , X_acct_exchange_rate => l_acct_exchange_rate
2283 , X_acct_raw_cost => NULL
2284 , X_acct_burdened_cost => NULL
2285 , X_project_currency_code => l_project_currency_code
2286 , X_project_rate_date => l_project_rate_date
2287 , X_project_rate_type => l_project_rate_type
2288 , X_project_exchange_rate => l_project_exchange_rate
2289 , X_err_code => l_err_code
2290 , X_err_stage => l_err_stage
2291 , X_err_stack => l_err_stack
2292 , P_Projfunc_currency_code => l_projfunc_currency_code
2293 , P_Projfunc_cost_rate_date => l_projfunc_cost_rate_date
2294 , P_Projfunc_cost_rate_type => l_projfunc_cost_rate_type
2295 , P_Projfunc_cost_exchange_rate => l_projfunc_cost_exchg_rate
2296 , P_project_raw_cost => null
2297 , P_project_burdened_cost => null
2298 , P_Work_Type_Id => p_work_type_id
2299 , p_mode => p_mode
2300 );
2301 IF P_DEBUG_MODE THEN
2302 print_message('get_denom_curr_code: ' || 'end of reverse cdl api');
2303 END IF;
2304 l_reverse_cdl_status := 'S';
2305
2306 ELSE
2307 l_reverse_cdl_status := 'E';
2308
2309 END IF;
2310
2311 EXCEPTION
2312 WHEN NO_DATA_FOUND THEN
2313 IF P_DEBUG_MODE THEN
2314 print_message('get_denom_curr_code: ' || 'no data found in cdl creation api');
2315 END IF;
2316 l_reverse_cdl_status := 'E';
2317 NULL;
2318
2319 WHEN OTHERS then
2320 l_reverse_cdl_status := 'U';
2321 RAISE;
2322 NULL;
2323 END ;
2324
2325 RETURN l_reverse_cdl_status;
2326
2327
2328 EXCEPTION
2329 WHEN NO_DATA_FOUND THEN
2330 IF P_DEBUG_MODE THEN
2331 print_message('get_denom_curr_code: ' || 'no data found in cdl creation api');
2332 END IF;
2333 RETURN l_reverse_cdl_status;
2334 NULL ;
2335 WHEN OTHERS THEN
2336 IF P_DEBUG_MODE THEN
2337 print_message('get_denom_curr_code: ' || 'others in cdl creation ='||sqlcode);
2338 END IF;
2339 x_status := sqlcode;
2340 RAISE ;
2341
2342 END cdl_creation;
2343
2344 BEGIN
2345
2346
2347 IF P_DEBUG_MODE THEN
2348 print_message('get_denom_curr_code: ' || 'inside work type adjustment api before loop');
2349 END IF;
2350
2351 FOR i IN 1..p_rows LOOP
2352
2353 IF P_DEBUG_MODE THEN
2354 print_message ('get_denom_curr_code: ' || 'before select exp_item ='||ItemsIdTab(i));
2355 END IF;
2356 /** check the change in work type results in change in billabity **/
2357 SELECT EI.work_type_id
2358 ,nvl(tr.gl_accounted_flag,'N')
2359 ,pt.PROJECT_TYPE_CLASS_CODE
2360 ,nvl(ei.billable_flag ,'N')
2361 INTO l_old_work_type_id
2362 ,l_gl_accounted_flag
2363 ,l_proj_type_class_code
2364 ,l_old_billability
2365 FROM pa_expenditure_items_all EI
2366 ,pa_transaction_sources tr
2367 ,pa_project_types_all pt /** Bug fix 2262118 **/
2368 ,pa_projects_all pp
2369 -- ,pa_tasks t /* Bug 3457922 */
2370 WHERE tr.transaction_source(+) = ei.transaction_source
2371 AND ei.expenditure_item_id = ItemsIdTab(i)
2372 -- AND t.task_id = ei.task_id /* Bug 3457922 */
2373 -- AND pp.project_id = t.project_id /* Bug 3457922 */
2374 AND pp.project_id = ei.project_id /* Added : Bug 3457922 */
2375 AND pp.project_type = pt.project_type
2376 -- start 12i MOAC changes
2377 -- AND nvl(pp.org_id ,-99) = nvl(pt.org_id ,-99) ;
2378 AND pp.org_id = pt.org_id;
2379 -- end 12i MAOC changes
2380
2381 /** we are not supposed to change the work type and billable flag
2382 * if the destination work type results in billable for the project_type
2383 * is INDIRECT we should not process . this check is already placed
2384 * forms LOV to pick only non billable work types for indirect project
2385 * at the item level addjustments , the same is not possible for
2386 * massadjust. SO if this api is called from massadjust . we should return
2387 * without processing
2388 **/
2389
2390 IF (l_proj_type_class_code = 'INDIRECT') then
2391 SELECT nvl(BILLABLE_CAPITALIZABLE_FLAG,'N')
2392 INTO l_billable_cap_flag
2393 FROM pa_work_types_b -- bug 4668802 changed from pa_work_types_v to pa_work_types_b
2394 WHERE work_type_id = p_work_type_id
2395 AND trunc(sysdate) between start_date_active and
2396 nvl(end_date_active,sysdate);
2397
2398 If l_billable_cap_flag = 'Y' then
2399 RETURN;
2400 End if;
2401
2402 END IF;
2403
2404 IF P_DEBUG_MODE THEN
2405 print_message ('get_denom_curr_code: ' || 'after select l_old_work_type_id ['||l_old_work_type_id||
2406 ']l_gl_accounted_flag['||l_gl_accounted_flag||']l_old_billability['||l_old_billability||']' );
2407 END IF;
2408
2409 l_profile_option := pa_utils4.IS_WORKTYPE_BILLABLE_ENABLED ;
2410
2411 If l_profile_option = 'Y' and l_proj_type_class_code in ('CAPITAL','CONTRACT') then
2412
2413
2414 l_new_billability := PA_UTILS4.get_trxn_work_billabilty
2415 (p_work_type_id => p_work_type_id
2416 ,p_tc_extn_bill_flag => NULL );
2417
2418 /*** Commented out this portion due to following issue
2419 ** Initially set the work type profile to 'N' and transaction is entered with billability = 'Y'
2420 ** Now set the work type profile to 'Y', As the old and new worktype results no change in billability
2421 ** then EI will never be updated with the billablity change . in order to fix this
2422 ** donot derive old billabity based on worktype
2423 l_old_billability := PA_UTILS4.get_trxn_work_billabilty
2424 (p_work_type_id => l_old_work_type_id
2425 ,p_tc_extn_bill_flag => NULL );
2426 **/
2427
2428 IF l_new_billability <> l_old_billability then
2429
2430 l_change_in_billable := 'Y';
2431 Else
2432 l_change_in_billable := 'N';
2433 End if;
2434
2435 Else
2436
2437 l_change_in_billable := 'N';
2438
2439 End if;
2440
2441 --l_profile_option := pa_utils4.IS_WORKTYPE_BILLABLE_ENABLED ;
2442
2443 IF P_DEBUG_MODE THEN
2444 print_message('get_denom_curr_code: ' || 'l_old_billability['||l_old_billability||
2445 ']l_new_billability['||l_new_billability||
2446 ']p_oldTpAMTcode['||p_TpAmtTypCodeTab(i)||']p_newTpAMTcode['||p_dest_tp_amt_type_code||
2447 ']l_old_work_type_id['||l_old_work_type_id||']l_new_work_type_id['||p_work_type_id||
2448 ']l_profile_option ['||l_profile_option||']l_change_in_billable['||l_change_in_billable||
2449 ']l_gl_accounted_flag['||l_gl_accounted_flag||']' );
2450 END IF;
2451
2452 IF l_change_in_billable = 'Y' AND l_gl_accounted_flag = 'Y' THEN
2453 /** create reverse and new cdls with transfer status code = 'P'
2454 ** and pass new billable flag to create cdl api **/
2455 IF P_DEBUG_MODE THEN
2456 print_message('get_denom_curr_code: ' || 'calling cdl_creation api');
2457 END IF;
2458 l_reverse_cdl_status := cdl_creation
2459 ( p_exp_item_id => ItemsIdTab(i)
2460 , p_billable => l_new_billability
2461 , p_work_type_id => p_work_type_id
2462 , p_adj_activity => p_adj_activity
2463 , p_user => p_user
2464 , p_login => p_login
2465 , p_module => p_module
2466 , p_mode => 'WORK_TYP_ADJ' -- passing 'WORK_TYP_ADJ', bug 3357936
2467 , x_status => x_status
2468 , p_billable_change => l_change_in_billable
2469 , p_tp_amt_type_code => p_TpAmtTypCodeTab(i)
2470 , p_dest_tp_amt_type_code => p_dest_tp_amt_type_code
2471 );
2472 IF P_DEBUG_MODE THEN
2473 print_message('get_denom_curr_code: ' || 'after cdl_creating api');
2474 END IF;
2475
2476 Elsif l_change_in_billable = 'N' then
2477 /** create reverse and new cdls with transfer status code = 'G' **/
2478 IF P_DEBUG_MODE THEN
2479 print_message('get_denom_curr_code: ' || 'calling cdl_creation api');
2480 END IF;
2481 l_reverse_cdl_status := cdl_creation
2482 ( p_exp_item_id => ItemsIdTab(i)
2483 , p_billable => null
2484 , p_work_type_id => p_work_type_id
2485 , p_adj_activity => p_adj_activity
2486 , p_user => p_user
2487 , p_login => p_login
2488 , p_module => p_module
2489 , p_mode => 'WORK_TYP_ADJ' -- Bug 5561542
2490 , x_status => x_status
2491 , p_billable_change => l_change_in_billable
2492 , p_tp_amt_type_code => p_TpAmtTypCodeTab(i)
2493 , p_dest_tp_amt_type_code => p_dest_tp_amt_type_code
2494 );
2495 IF P_DEBUG_MODE THEN
2496 print_message('get_denom_curr_code: ' || 'after cdl_creating api');
2497 END IF;
2498
2499 END IF; -- end of change_in_billable
2500
2501 /**
2502 *Project summarization changes Mark ei as cost distributed if cdls are created
2503 * mark cost distributed flag to 'Y' else mark it as 'N'
2504 **/
2505 IF P_DEBUG_MODE THEN
2506 print_message('get_denom_curr_code: ' || 'calling update of EI');
2507 END IF;
2508 /**
2509 Burdening changes (PA.L)
2510 Work type adjusment API is modified, If the transaction is already
2511 adjusted by burdening or other adjustment process, this API should
2512 NOT set the cost distributed flag to 'Y'
2513 Matrx for updating the cost dist flag
2514 OrgCostDist BillablityChange GlAccted CdlCreation UpdCostDist
2515 ------------------------------------------------------------------
2516 Y Y Y success Y
2517 N Y Y success N
2518 Y/N Y Y No cdls N
2519 Y/N Y N --- N
2520 Y N - success Y
2521 Y/N N - No cdls N
2522 Solution: added decode(nvl(ei.cost_distributed_flag,'N'),'Y','Y','N')
2523 **/
2524 UPDATE pa_expenditure_items_all ei
2525 SET ei.work_type_id = p_work_type_id
2526 ,ei.cost_distributed_flag =
2527 decode(l_change_in_billable,
2528 'Y', decode(l_gl_accounted_flag,
2529 'N','N',
2530 'Y',decode(l_reverse_cdl_status
2531 ,'S',decode(nvl(ei.cost_distributed_flag,'N'),'Y','Y','N')
2532 ,'N')
2533 ),
2534 'N',decode(l_reverse_cdl_status,'S',
2535 decode(nvl(ei.cost_distributed_flag,'N'),'Y','Y','N'),'N'))
2536 ,ei.revenue_distributed_flag = 'N'
2537 ,ei.rev_dist_rejection_code = NULL /*Added for bug:9367103 */
2538 ,ei.billable_flag = decode(l_change_in_billable,'Y',l_new_billability,ei.billable_flag)
2539 ,ei.last_updated_by = p_user
2540 ,ei.last_update_date = sysdate
2541 ,ei.last_update_login = p_login
2542 ,ei.tp_amt_type_code = PA_UTILS4.get_tp_amt_type_code
2543 (p_work_type_id)
2544 ,cc_bl_distributed_code = DECODE(p_dest_tp_amt_type_code, p_TpAmtTypCodeTab(i),
2545 cc_bl_distributed_code,
2546 decode(cc_bl_distributed_code,'X','X','N'))
2547 ,cc_ic_processed_code = DECODE(p_dest_tp_amt_type_code, p_TpAmtTypCodeTab(i),
2548 cc_ic_processed_code,
2549 decode(cc_ic_processed_code,'X','X','N'))
2550 /* Begin Burdening Changes - PA.L */
2551 ,ei.adjustment_type = NULL
2552 /* End Burdening Changes - PA.L */
2553 WHERE
2554 ei.expenditure_item_id = ItemsIdTab(i);
2555
2556 IF P_DEBUG_MODE THEN
2557 print_message('get_denom_curr_code: ' || 'Num of rows updated ['||sql%rowcount||
2558 ']with work type ['||p_work_type_id||']' );
2559 END IF;
2560
2561 InsAuditRec( X_exp_item_id => ItemsIdTab(i)
2562 , X_adj_activity => p_adj_activity
2563 , X_module => p_module
2564 , X_user => p_user
2565 , X_login => p_login
2566 , X_status => l_temp_status
2567 /* R12 Changes Start */
2568 , X_who_req_id => G_REQUEST_ID
2569 , X_who_prog_id => G_PROGRAM_ID
2570 , X_who_prog_app_id => G_PROG_APPL_ID
2571 , X_who_prog_upd_date => sysdate);
2572 /* R12 Changes End */
2573
2574 CheckStatus( status_indicator => l_temp_status );
2575
2576
2577 END LOOP;
2578
2579 X_status := 0;
2580
2581 EXCEPTION
2582 WHEN OTHERS THEN
2583 IF P_DEBUG_MODE THEN
2584 print_message('get_denom_curr_code: ' || ' others exection in work type adjustments api');
2585 END IF;
2586 X_status := SQLCODE;
2587 RAISE;
2588
2589 END work_type_adjustment;
2590 --===========================================================================
2591 -- End of work type adjustments
2592 --===========================================================================
2593
2594
2595 -- ========================================================================
2596 -- PROCEDURE Reclass
2597 -- ========================================================================
2598
2599 PROCEDURE Reclass( ItemsIdTab IN pa_utils.IdTabTyp
2600 , AdjustsIdTab IN pa_utils.IdTabTyp
2601 , X_billable IN VARCHAR2
2602 , X_adj_activity IN VARCHAR2
2603 , X_user IN NUMBER
2604 , X_login IN NUMBER
2605 , X_module IN VARCHAR2
2606 , rows IN BINARY_INTEGER
2607 , X_status OUT NOCOPY NUMBER )
2608 IS
2609 temp_status NUMBER DEFAULT NULL;
2610 err_code NUMBER ;
2611 err_stage VARCHAR2(2000);
2612 err_stack VARCHAR2(255) ;
2613 BEGIN
2614
2615 FOR i IN 1..rows LOOP
2616
2617 UPDATE pa_expenditure_items_all ei
2618 SET ei.billable_flag = X_billable
2619 , ei.revenue_distributed_flag = 'N'
2620 , ei.rev_dist_rejection_code = NULL /*Added for bug 9304451*/
2621 , ei.cost_distributed_flag = 'N'
2622 /* Begin Burdening Changes - PA.L */
2623 , ei.adjustment_type = NULL
2624 /* End Burdening Changes - PA.L */
2625 , ei.last_updated_by = X_user
2626 , ei.last_update_date = sysdate
2627 , ei.last_update_login = X_login
2628 WHERE
2629 ei.expenditure_item_id = ItemsIdTab(i);
2630
2631 DECLARE
2632 p_transaction_source VARCHAR2(30);
2633 p_gl_accounted_flag VARCHAR2(1);
2634 p_denom_currency_code VARCHAR2(15);
2635 p_acct_currency_code VARCHAR2(15);
2636 p_acct_rate_date DATE;
2637 p_acct_rate_type VARCHAR2(30);
2638 p_acct_exchange_rate NUMBER;
2639 p_project_currency_code VARCHAR2(15);
2640 p_project_rate_date DATE;
2641 p_project_rate_type VARCHAR2(30);
2642 p_project_exchange_rate NUMBER;
2643 p_system_linkage_function VARCHAR2(30);
2644 l_projfunc_currency_code VARCHAR2(15);
2645 l_projfunc_cost_rate_date DATE;
2646 l_projfunc_cost_rate_type VARCHAR2(30);
2647 l_projfunc_cost_exchg_rate NUMBER;
2648 l_work_type_id NUMBER;
2649
2650 BEGIN
2651 SELECT ei.transaction_source,
2652 tr.gl_accounted_flag,
2653 ei.denom_currency_code,
2654 ei.acct_currency_code,
2655 ei.acct_rate_date,
2656 ei.acct_rate_type,
2657 ei.acct_exchange_rate,
2658 ei.project_currency_code,
2659 ei.project_rate_date,
2660 ei.project_rate_type,
2661 ei.project_exchange_rate,
2662 tr.system_linkage_function,
2663 ei.projfunc_currency_code,
2664 ei.projfunc_cost_rate_date,
2665 ei.projfunc_cost_rate_type,
2666 ei.projfunc_cost_exchange_rate,
2667 ei.work_type_id
2668 INTO p_transaction_source,
2669 p_gl_accounted_flag,
2670 p_denom_currency_code,
2671 p_acct_currency_code,
2672 p_acct_rate_date,
2673 p_acct_rate_type,
2674 p_acct_exchange_rate,
2675 p_project_currency_code,
2676 p_project_rate_date,
2677 p_project_rate_type,
2678 p_project_exchange_rate,
2679 p_system_linkage_function,
2680 l_projfunc_currency_code,
2681 l_projfunc_cost_rate_date,
2682 l_projfunc_cost_rate_type,
2683 l_projfunc_cost_exchg_rate,
2684 l_work_type_id
2685 FROM pa_expenditure_items_all ei,
2686 pa_transaction_sources tr
2687 WHERE tr.transaction_source = ei.transaction_source
2688 AND expenditure_item_id = ItemsIdTab(i) ;
2689
2690 -- Added to IF condition below: p_system_linkage_function <> 'VI' to resolve bug # 1764279
2691 -- Added to IF condition below: p_transaction_source <> 'AP EXPENSE' to resolve bug# 2323103
2692 -- Modified IF condition below:
2693 -- ((p_system_linkage_function <> 'VI') or
2694 -- (p_system_linkage_function = 'VI' and p_transaction_source = 'PO RECEIPT '))
2695 -- to resolve bug# 2853597
2696 -- Removed AP INVOICE transaction source to resolve the bug#3162892.
2697 /* Added sys link <> INV for Bug#3693497*/
2698 /* Bug 4610677 - Reversal CDL will not be created for GL Accounted VI and ER transactions */
2699 IF p_gl_accounted_flag = 'Y' and
2700 p_system_linkage_function NOT IN ('VI','ER','INV') THEN
2701
2702 Pa_Costing.ReverseCdl( X_expenditure_item_id => ItemsIdTab(i)
2703 , X_billable_flag => X_billable
2704 , X_amount => NULL
2705 , X_quantity => NULL
2706 , X_burdened_cost => NULL
2707 , X_dr_ccid => NULL
2708 , X_cr_ccid => NULL
2709 , X_tr_source_accounted => 'Y'
2710 , X_line_type => 'R'
2711 , X_user => X_user
2712 , X_denom_currency_code => p_denom_currency_code
2713 , X_denom_raw_cost => NULL
2714 , X_denom_burden_cost => NULL
2715 , X_acct_currency_code => p_acct_currency_code
2716 , X_acct_rate_date => p_acct_rate_date
2717 , X_acct_rate_type => p_acct_rate_type
2718 , X_acct_exchange_rate => p_acct_exchange_rate
2719 , X_acct_raw_cost => NULL
2720 , X_acct_burdened_cost => NULL
2721 , X_project_currency_code => p_project_currency_code
2722 , X_project_rate_date => p_project_rate_date
2723 , X_project_rate_type => p_project_rate_type
2724 , X_project_exchange_rate => p_project_exchange_rate
2725 , X_err_code => err_code
2726 , X_err_stage => err_stage
2727 , X_err_stack => err_stack
2728 , P_Projfunc_currency_code => l_projfunc_currency_code
2729 , P_Projfunc_cost_rate_date => l_projfunc_cost_rate_date
2730 , P_Projfunc_cost_rate_type => l_projfunc_cost_rate_type
2731 , P_Projfunc_cost_exchange_rate => l_projfunc_cost_exchg_rate
2732 , P_project_raw_cost => null
2733 , P_project_burdened_cost => null
2734 , P_Work_Type_Id => l_work_type_id
2735 , p_mode => 'RECLASS'); -- passed reclass BUG 3357936
2736
2737 /*
2738 Project summarization changes
2739 Mark ei as cost distributed
2740 */
2741 -- start 12i MOAC changes
2742 -- UPDATE pa_expenditure_items
2743 UPDATE pa_expenditure_items_all
2744 -- end 12i MOAC changes
2745 SET cost_distributed_flag = 'Y'
2746 WHERE expenditure_item_id = ItemsIdTab(i);
2747
2748 END IF;
2749 EXCEPTION
2750 WHEN NO_DATA_FOUND THEN
2751 NULL ;
2752 WHEN OTHERS THEN
2753 RAISE ;
2754 END ;
2755
2756 InsAuditRec( X_exp_item_id => ItemsIdTab(i)
2757 , X_adj_activity => X_adj_activity
2758 , X_module => X_module
2759 , X_user => X_user
2760 , X_login => X_login
2761 , X_status => temp_status
2762 /* R12 Changes Start */
2763 , X_who_req_id => G_REQUEST_ID
2764 , X_who_prog_id => G_PROGRAM_ID
2765 , X_who_prog_app_id => G_PROG_APPL_ID
2766 , X_who_prog_upd_date => sysdate);
2767 /* R12 Changes End */
2768 CheckStatus( status_indicator => temp_status );
2769
2770 IF ( AdjustsIdTab(i) IS NOT NULL ) THEN
2771
2772
2773 UPDATE pa_expenditure_items_all eia
2774 SET
2775 eia.billable_flag = X_billable
2776 , eia.revenue_distributed_flag = 'N'
2777 , eia.rev_dist_rejection_code = NULL /*Added for bug:9367103 */
2778 , eia.cost_distributed_flag = 'N'
2779 , eia.last_updated_by = X_user
2780 , eia.last_update_date = sysdate
2781 , eia.last_update_login = X_login
2782 WHERE
2783 eia.expenditure_item_id = AdjustsIdTab(i);
2784
2785 DECLARE
2786
2787 p_transaction_source VARCHAR2(30);
2788 p_gl_accounted_flag VARCHAR2(1);
2789 p_denom_currency_code VARCHAR2(15);
2790 p_acct_currency_code VARCHAR2(15);
2791 p_acct_rate_date DATE;
2792 p_acct_rate_type VARCHAR2(30);
2793 p_acct_exchange_rate NUMBER;
2794 p_project_currency_code VARCHAR2(15);
2795 p_project_rate_date DATE;
2796 p_project_rate_type VARCHAR2(30);
2797 p_project_exchange_rate NUMBER;
2798 l_projfunc_currency_code VARCHAR2(15);
2799 l_projfunc_cost_rate_date DATE;
2800 l_projfunc_cost_rate_type VARCHAR2(30);
2801 l_projfunc_cost_exchg_rate NUMBER;
2802 l_work_type_id NUMBER;
2803
2804 BEGIN
2805
2806 SELECT ei.transaction_source,
2807 tr.gl_accounted_flag,
2808 ei.denom_currency_code,
2809 ei.acct_currency_code,
2810 ei.acct_rate_date,
2811 ei.acct_rate_type,
2812 ei.acct_exchange_rate,
2813 ei.project_currency_code,
2814 ei.project_rate_date,
2815 ei.project_rate_type,
2816 ei.project_exchange_rate,
2817 ei.projfunc_currency_code,
2818 ei.projfunc_cost_rate_date,
2819 ei.projfunc_cost_rate_type,
2820 ei.projfunc_cost_exchange_rate,
2821 ei.work_type_id
2822 INTO p_transaction_source,
2823 p_gl_accounted_flag,
2824 p_denom_currency_code,
2825 p_acct_currency_code,
2826 p_acct_rate_date,
2827 p_acct_rate_type,
2828 p_acct_exchange_rate,
2829 p_project_currency_code,
2830 p_project_rate_date,
2831 p_project_rate_type,
2832 p_project_exchange_rate,
2833 l_projfunc_currency_code,
2834 l_projfunc_cost_rate_date,
2835 l_projfunc_cost_rate_type,
2836 l_projfunc_cost_exchg_rate,
2837 l_work_type_id
2838 FROM pa_expenditure_items_all ei,
2839 pa_transaction_sources tr
2840 WHERE tr.transaction_source = ei.transaction_source
2841 AND expenditure_item_id = AdjustsIdTab(i) ;
2842
2843 IF p_gl_accounted_flag = 'Y' THEN
2844
2845 Pa_Costing.ReverseCdl( X_expenditure_item_id => AdjustsIdTab(i)
2846 , X_billable_flag => X_billable
2847 , X_amount => NULL
2848 , X_quantity => NULL
2849 , X_burdened_cost => NULL
2850 , X_dr_ccid => NULL
2851 , X_cr_ccid => NULL
2852 , X_tr_source_accounted => 'Y'
2853 , X_line_type => 'R'
2854 , X_user => X_user
2855 , X_denom_currency_code => p_denom_currency_code
2856 , X_denom_raw_cost => NULL
2857 , X_denom_burden_cost => NULL
2858 , X_acct_currency_code => p_acct_currency_code
2859 , X_acct_rate_date => p_acct_rate_date
2860 , X_acct_rate_type => p_acct_rate_type
2861 , X_acct_exchange_rate => p_acct_exchange_rate
2862 , X_acct_raw_cost => NULL
2863 , X_acct_burdened_cost => NULL
2864 , X_project_currency_code => p_project_currency_code
2865 , X_project_rate_date => p_project_rate_date
2866 , X_project_rate_type => p_project_rate_type
2867 , X_project_exchange_rate => p_project_exchange_rate
2868 , X_err_code => err_code
2869 , X_err_stage => err_stage
2870 , X_err_stack => err_stack
2871 , P_Projfunc_currency_code => l_projfunc_currency_code
2872 , P_Projfunc_cost_rate_date => l_projfunc_cost_rate_date
2873 , P_Projfunc_cost_rate_type => l_projfunc_cost_rate_type
2874 , P_Projfunc_cost_exchange_rate => l_projfunc_cost_exchg_rate
2875 , P_project_raw_cost => null
2876 , P_project_burdened_cost => null
2877 , P_Work_Type_Id => l_work_type_id
2878 , p_mode => 'RECLASS'); -- passing reclass, bug 3357936
2879 /*
2880 Project summarization changes
2881 Mark ei as cost distributed
2882 */
2883 -- start 12i MOAC changes
2884 -- UPDATE pa_expenditure_items
2885 UPDATE pa_expenditure_items_all
2886 -- end 12i MOAC changes
2887 SET cost_distributed_flag = 'Y'
2888 WHERE expenditure_item_id = AdjustsIdTab(i);
2889
2890 END IF ;
2891
2892 EXCEPTION
2893 WHEN NO_DATA_FOUND THEN
2894 NULL ;
2895 WHEN OTHERS THEN
2896 RAISE ;
2897 END ;
2898
2899 InsAuditRec( X_exp_item_id => AdjustsIdTab(i)
2900 , X_adj_activity => X_adj_activity
2901 , X_module => X_module
2902 , X_user => X_user
2903 , X_login => X_login
2904 , X_status => temp_status
2905 /* R12 Changes Start */
2906 , X_who_req_id => G_REQUEST_ID
2907 , X_who_prog_id => G_PROGRAM_ID
2908 , X_who_prog_app_id => G_PROG_APPL_ID
2909 , X_who_prog_upd_date => sysdate);
2910 /* R12 Changes End */
2911
2912 CheckStatus( status_indicator => temp_status );
2913
2914 END IF;
2915
2916 END LOOP;
2917
2918 X_status := 0;
2919
2920 EXCEPTION
2921 WHEN OTHERS THEN
2922 X_status := SQLCODE;
2923 RAISE;
2924
2925 END Reclass;
2926
2927
2928 -- ========================================================================
2929 -- PROCEDURE Split
2930 -- ========================================================================
2931
2932 PROCEDURE Split( X_exp_item_id IN NUMBER
2933 , X_item1_qty IN NUMBER
2934 , X_item1_raw_cost IN NUMBER
2935 , X_item1_burden_cost IN NUMBER
2936 , X_item1_bill_flag IN VARCHAR2
2937 , X_item1_hold_flag IN VARCHAR2
2938 , X_item2_qty IN NUMBER
2939 , X_item2_raw_cost IN NUMBER
2940 , X_item2_burden_cost IN NUMBER
2941 , X_item1_receipt_curr_amt IN NUMBER
2942 , X_item2_receipt_curr_amt IN NUMBER
2943 , X_item1_denom_raw_cost IN NUMBER
2944 , X_item2_denom_raw_cost IN NUMBER
2945 , X_item1_denom_burdened_cost IN NUMBER
2946 , X_item2_denom_burdened_cost IN NUMBER
2947 , X_Item1_acct_raw_cost IN NUMBER
2948 , X_item2_acct_raw_cost IN NUMBER
2949 , X_item1_acct_burdened_cost IN NUMBER
2950 , X_item2_acct_burdened_cost IN NUMBER
2951 , X_item2_bill_flag IN VARCHAR2
2952 , X_item2_hold_flag IN VARCHAR2
2953 , X_user IN NUMBER
2954 , X_login IN NUMBER
2955 , X_module IN VARCHAR2
2956 , X_status OUT NOCOPY NUMBER
2957 , p_item1_project_raw_cost IN NUMBER -- project raw
2958 , p_item1_project_burden_cost IN NUMBER -- project burden
2959 , p_item2_project_raw_cost IN NUMBER -- project raw
2960 , p_item2_project_burden_cost IN NUMBER -- project burden
2961 )
2962 IS
2963
2964 item_qty NUMBER;
2965 item_raw_cost NUMBER;
2966 item_burden_cost NUMBER ;
2967 item_receipt_curr_amt NUMBER;
2968 item_denom_raw_cost NUMBER;
2969 item_denom_burdened_cost NUMBER;
2970 item_acct_raw_cost NUMBER;
2971 item_acct_burdened_cost NUMBER;
2972 item_bill_flag VARCHAR2(1);
2973 item_hold_flag VARCHAR2(1);
2974 new_item_id NUMBER(15);
2975 item_comment VARCHAR2(240);
2976 temp_status NUMBER DEFAULT NULL;
2977 item_project_raw_cost NUMBER;
2978 item_project_burdened_cost NUMBER ;
2979
2980 /* EFC bug2259454 changes */
2981 l_denom_currency_code VARCHAR2(30);
2982 l_exp_type VARCHAR2(30);
2983 l_denom_cur_code VARCHAR2(30);
2984 l_acct_cur_code VARCHAR2(30);
2985 l_sys_link_func VARCHAR2(3);
2986 l_denom_raw_cost NUMBER := NULL;
2987 l_transaction_source pa_expenditure_items_all.transaction_source%type;
2988 l_expenditure_id pa_expenditure_items_all.expenditure_id%type;
2989 l_person_id pa_expenditures_all.incurred_by_person_id%type;
2990 l_expenditure_item_date Date;
2991
2992 /* Commented the following code as part of Bug#2291180 -- Start */
2993 /* Bug#2291180
2994 function get_denom_curr_code (l_exp_type in varchar2,
2995 l_denom_currency_code in varchar2,
2996 l_acct_currency_code in varchar2,
2997 l_system_linkage_function in varchar2,
2998 l_denom_raw_cost in number) return varchar2 is
2999
3000 l_cost_rate_flag varchar2(30);
3001 l_return varchar2(30);
3002
3003 Begin
3004
3005 If l_denom_raw_cost is null Then
3006 If l_system_linkage_function in ('ST','OT') Then
3007 If l_acct_currency_code = l_denom_currency_code Then
3008 l_return := l_denom_currency_code;
3009 Else
3010 l_return := pa_currency.get_currency_code;
3011 End If;
3012 Else
3013 select cost_rate_flag
3014 into l_cost_rate_flag
3015 from pa_expenditure_types
3016 where expenditure_type = l_exp_type;
3017
3018 If l_cost_rate_flag = 'Y' Then
3019 If l_acct_currency_code = l_denom_currency_code Then
3020 l_return := l_denom_currency_code;
3021 Else
3022 l_return := pa_currency.get_currency_code;
3023 End If;
3024 Else
3025 l_return := l_denom_currency_code;
3026 End If;
3027 End If;
3028 Else
3029 l_return := l_denom_currency_code;
3030 End if;
3031
3032 return l_return;
3033
3034 End get_denom_curr_code;
3035 Bug#2291180 */
3036 /* End EFC bug2259454 changes */
3037 /* Commented the above code as part of Bug#2291180 -- End */
3038
3039 BEGIN
3040
3041 IF P_DEBUG_MODE THEN
3042 print_message('get_denom_curr_code: ' || 'Inside split server side api calling insaudit rec api');
3043 END IF;
3044 InsAuditRec( X_exp_item_id => X_exp_item_id
3045 , X_adj_activity => 'SPLIT ORIGINATING'
3046 , X_module => X_module
3047 , X_user => X_user
3048 , X_login => X_login
3049 , X_status => temp_status );
3050
3051 CheckStatus( status_indicator => temp_status );
3052 IF P_DEBUG_MODE THEN
3053 print_message('get_denom_curr_code: ' || 'caling back out api');
3054 END IF;
3055
3056 BackoutItem( X_exp_item_id => X_exp_item_id
3057 , X_expenditure_id => NULL
3058 , X_adj_activity => 'SPLIT BACK-OUT'
3059 , X_module => X_module
3060 , X_user => X_user
3061 , X_login => X_login
3062 , X_status => temp_status );
3063
3064 CheckStatus( status_indicator => temp_status );
3065
3066 /*
3067 Project Summarization changes
3068 Call procedure to create CDL for the backout item (if necessary)
3069 */
3070
3071 IF P_DEBUG_MODE THEN
3072 print_message('get_denom_curr_code: ' || 'calling Pa_Costing.CreateReverseCdl api');
3073 END IF;
3074
3075 Pa_Costing.CreateReverseCdl( X_exp_item_id => X_exp_item_id,
3076 X_backout_id => Pa_Adjustments.BackOutId,
3077 X_user => X_user,
3078 X_status => temp_status);
3079
3080 CheckStatus( status_indicator => temp_status );
3081
3082 IF P_DEBUG_MODE THEN
3083 print_message('get_denom_curr_code: ' || 'calling ReverseRelatedItems api');
3084 END IF;
3085
3086 ReverseRelatedItems( X_source_exp_item_id => X_exp_item_id
3087 , X_expenditure_id => NULL
3088 , X_module => X_module
3089 , X_user => X_user
3090 , X_login => X_login
3091 , X_status => temp_status );
3092
3093 CheckStatus( status_indicator => temp_status );
3094
3095 BEGIN
3096
3097 SELECT
3098 ec.expenditure_comment
3099 INTO
3100 item_comment
3101 FROM
3102 pa_expenditure_comments ec
3103 WHERE
3104 ec.expenditure_item_id = X_exp_item_id;
3105
3106 EXCEPTION
3107 WHEN NO_DATA_FOUND THEN
3108 NULL;
3109 END;
3110
3111 /* Begin EFC bug2259454 changes */
3112 select
3113 transaction_source,
3114 expenditure_type,
3115 denom_currency_code,
3116 acct_currency_code,
3117 system_linkage_function,
3118 denom_raw_cost,
3119 expenditure_id ,
3120 expenditure_item_date
3121 into
3122 l_transaction_source,
3123 l_exp_type,
3124 l_denom_cur_code,
3125 l_acct_cur_code,
3126 l_sys_link_func,
3127 l_denom_raw_cost,
3128 l_expenditure_id,
3129 l_expenditure_item_date
3130 from
3131 pa_expenditure_items_all
3132 where
3133 expenditure_item_id = X_exp_item_id;
3134
3135 /* bug fix: 2798742 */
3136 select
3137 Incurred_by_person_id
3138 into
3139 l_person_id
3140 from
3141 pa_expenditures_all
3142 where expenditure_id = l_expenditure_id;
3143 /* end of bug fix:2798742 */
3144
3145 l_denom_currency_code := get_denom_curr_code(l_transaction_source,
3146 l_exp_type,
3147 l_denom_cur_code,
3148 l_acct_cur_code,
3149 l_sys_link_func,
3150 'SPLIT' /* bug fix: 2798742 */
3151 ,l_person_id
3152 ,l_expenditure_item_date);
3153
3154 /* End EFC bug2259454 changes */
3155
3156 FOR i IN 1..2 LOOP
3157
3158 IF ( i = 1 ) THEN
3159
3160 item_qty := X_item1_qty ;
3161 item_raw_cost := X_item1_raw_cost;
3162 item_burden_cost := X_item1_burden_cost;
3163 item_bill_flag := X_item1_bill_flag;
3164 item_hold_flag := X_item1_hold_flag;
3165 item_receipt_curr_amt := X_item1_receipt_curr_amt ;
3166 item_denom_raw_cost := X_item1_denom_raw_cost ;
3167 item_denom_burdened_cost := X_item1_denom_burdened_cost;
3168 item_acct_raw_cost := X_item1_acct_raw_cost;
3169 item_acct_burdened_cost := X_item1_acct_burdened_cost;
3170 item_project_raw_cost := p_item1_project_raw_cost;
3171 item_project_burdened_cost := p_item1_project_burden_cost;
3172
3173 ELSE
3174
3175 item_qty := X_item2_qty ;
3176 item_raw_cost := X_item2_raw_cost;
3177 item_burden_cost := X_item2_burden_cost;
3178 item_bill_flag := X_item2_bill_flag;
3179 item_hold_flag := X_item2_hold_flag;
3180 item_receipt_curr_amt := X_item2_receipt_curr_amt ;
3181 item_denom_raw_cost := X_item2_denom_raw_cost ;
3182 item_denom_burdened_cost := X_item2_denom_burdened_cost;
3183 item_acct_raw_cost := X_item2_acct_raw_cost;
3184 item_acct_burdened_cost := X_item2_acct_burdened_cost;
3185 item_project_raw_cost := p_item2_project_raw_cost;
3186 item_project_burdened_cost := p_item2_project_burden_cost;
3187
3188 END IF;
3189
3190 new_item_id := pa_utils.GetNextEiId;
3191
3192 IF P_DEBUG_MODE THEN
3193 print_message('get_denom_curr_code: ' || 'calling insert into EI');
3194 END IF;
3195
3196 INSERT INTO pa_expenditure_items_all(
3197 expenditure_item_id
3198 , task_id
3199 , expenditure_type
3200 , system_linkage_function
3201 , expenditure_item_date
3202 , expenditure_id
3203 , override_to_organization_id
3204 , last_update_date
3205 , last_updated_by
3206 , creation_date
3207 , created_by
3208 , last_update_login
3209 , quantity
3210 , revenue_distributed_flag
3211 , bill_hold_flag
3212 , billable_flag
3213 , bill_rate_multiplier
3214 , cost_distributed_flag
3215 , raw_cost
3216 , raw_cost_rate
3217 , burden_cost
3218 , burden_cost_rate /*1765164*/
3219 , non_labor_resource
3220 , organization_id
3221 , transferred_from_exp_item_id
3222 , attribute_category
3223 , attribute1
3224 , attribute2
3225 , attribute3
3226 , attribute4
3227 , attribute5
3228 , attribute6
3229 , attribute7
3230 , attribute8
3231 , attribute9
3232 , attribute10
3233 , transaction_source
3234 , orig_transaction_reference /* Bug 2373450 */
3235 , job_id
3236 , org_id
3237 , labor_cost_multiplier_name
3238 , receipt_currency_amount
3239 , receipt_currency_code
3240 , receipt_exchange_rate
3241 , denom_currency_code
3242 , denom_raw_cost
3243 , denom_burdened_cost
3244 , acct_currency_code
3245 , acct_rate_date
3246 , acct_rate_type
3247 , acct_exchange_rate
3248 , acct_raw_cost
3249 , acct_burdened_cost
3250 , acct_exchange_rounding_limit
3251 , project_currency_code
3252 , project_rate_type
3253 , project_rate_date
3254 , project_exchange_rate
3255 , cost_ind_compiled_set_id /* added for bug 1765164 */
3256 /* For split, all the CC attributes are calculated again, following the
3257 revenue/billing model */
3258 /* , cc_cross_charge_code
3259 , cc_prvdr_organization_id
3260 , cc_recvr_organization_id
3261 , cc_rejection_code
3262 , denom_tp_currency_code
3263 , denom_transfer_price
3264 , acct_tp_rate_type
3265 , acct_tp_rate_date
3266 , acct_tp_exchange_rate
3267 , acct_transfer_price
3268 , projacct_transfer_price
3269 , cc_markup_base_code
3270 , tp_base_amount
3271 , cc_cross_charge_type
3272 , recvr_org_id
3273 , cc_bl_distributed_code
3274 , cc_ic_processed_code
3275 , tp_ind_compiled_set_id
3276 , tp_bill_rate
3277 , tp_bill_markup_percentage
3278 , tp_schedule_line_percentage
3279 , tp_rule_percentage */
3280 , recvr_org_id /*Bug# 2028917*/
3281 , assignment_id
3282 , work_type_id
3283 , projfunc_currency_code
3284 , projfunc_cost_rate_type
3285 , projfunc_cost_rate_date
3286 , projfunc_cost_exchange_rate
3287 , project_raw_cost
3288 , project_burdened_cost
3289 /** , project_tp_rate_type
3290 , project_tp_rate_date
3291 , project_tp_exchange_rate
3292 , project_transfer_price **/
3293 , project_id
3294 , tp_amt_type_code /** added for bug 3117718 **/
3295 , inventory_item_id -- Bug 4320459
3296 , unit_of_measure -- Bug 4320459
3297 , Po_Line_Id /* for bug 9939183 */
3298 , Po_Price_Type /* for bug 9939183 */
3299 /* R12 Changes - Start */
3300 , document_header_id
3301 , document_distribution_id
3302 , document_line_number
3303 , document_payment_id
3304 , vendor_id
3305 , document_type
3306 , document_distribution_type
3307 /* R12 Changes - End */
3308 /* 12.2 changes for payroll intg .. start */
3309 , location_id
3310 , pay_element_type_id
3311 , rate_source_code
3312 , costing_method
3313 , payroll_accrual_flag -- bug 12541898
3314 , interface_run_id -- bug 12541898
3315 /* 12.2 changes for payroll intg .. end */
3316 , cbs_element_id -- Added for CBS Enhancement Bug 16220146
3317 )
3318 SELECT
3319 new_item_id -- expenditure_item_id
3320 , ei.task_id -- task_id
3321 , ei.expenditure_type -- expenditure_type
3322 , ei.system_linkage_function -- system_linkage_function
3323 , ei.expenditure_item_date -- expenditure_item_date
3324 , ei.expenditure_id -- expenditure_id
3325 , ei.override_to_organization_id -- override_to_organization_id
3326 , sysdate -- last_update_date
3327 , X_user -- last_updated_by
3328 , sysdate -- creation_date
3329 , X_user -- created_by
3330 , X_login -- last_update_login
3331 , item_qty -- quantity
3332 , 'N' -- revenue_distributed_flag
3333 , item_hold_flag -- bill_hold_flag
3334 , item_bill_flag -- billable_flag
3335 , ei.bill_rate_multiplier -- bill_rate_multiplier
3336 , 'N' -- cost_distributed_flag
3337 , item_raw_cost -- raw_cost
3338 , ei.raw_cost_rate -- raw_cost_rate
3339 , item_burden_cost -- burden_cost
3340 , ei.burden_cost_rate -- burden_cost_rate /*1765164*/
3341 , ei.non_labor_resource -- non_labor_resource
3342 , ei.organization_id -- organization_id
3343 , ei.expenditure_item_id -- adjusted_expenditure_item_id
3344 , ei.attribute_category -- attribute_category
3345 , ei.attribute1 -- attribute1
3346 , ei.attribute2 -- attribute2
3347 , ei.attribute3 -- attribute3
3348 , ei.attribute4 -- attribute4
3349 , ei.attribute5 -- attribute5
3350 , ei.attribute6 -- attribute6
3351 , ei.attribute7 -- attribute7
3352 , ei.attribute8 -- attribute8
3353 , ei.attribute9 -- attribute9
3354 , ei.attribute10 -- attribute10
3355 , ei.transaction_source -- transaction_source
3356 , decode(ei.transaction_source,'PTE TIME',NULL,
3357 decode(ei.transaction_source,'PTE EXPENSE',NULL,
3358 decode(ei.transaction_source,'ORACLE TIME AND LABOR',NULL,
3359 decode(ei.transaction_source,'Oracle Self Service Time',NULL,
3360 ei.orig_transaction_reference)))) orig_transaction_reference /* Bug2373450 */
3361 , ei.job_id -- job_id
3362 , ei.org_id -- org_id
3363 , ei.labor_cost_multiplier_name -- labor_cost_multiplier_name
3364 , item_receipt_curr_amt -- receipt currency amount
3365 , ei.receipt_currency_code -- receipt currency code
3366 , ei.receipt_exchange_rate -- receipt exchange rate
3367 /***, ei.denom_currency_code -- denomination currency code **/
3368 , l_denom_currency_code -- denomiation currency code EFC bug2259454 changes
3369 , item_denom_raw_cost -- denomination raw cost
3370 , item_denom_burdened_cost -- denomination burdened cost
3371 , ei.acct_currency_code -- accounting currency code
3372 , ei.acct_rate_date -- accounting rate date
3373 , ei.acct_rate_type -- accounting rate type
3374 , ei.acct_exchange_rate -- accounting exchange rate
3375 , item_acct_raw_cost -- accounting raw cost
3376 , item_acct_burdened_cost -- accounting burdened cost
3377 , ei.acct_exchange_rounding_limit -- accounting exchange rounding limit
3378 , ei.project_currency_code -- project currency code
3379 , ei.project_rate_type -- project rate type
3380 , ei.project_rate_date -- project rate date
3381 , ei.project_exchange_rate -- accounting exchange rate
3382 , ei.cost_ind_compiled_set_id -- cost compiled set id added for 1765164
3383 /* , ei.cc_cross_charge_code -- cc_cross_charge_code
3384 , ei.cc_prvdr_organization_id -- cc_prvdr_organization_id
3385 , ei.cc_recvr_organization_id -- cc_recvr_organization_id
3386 , ei.cc_rejection_code -- cc_rejection_code
3387 , ei.denom_tp_currency_code -- denom_tp_currency_code
3388 , ei.denom_transfer_price -- denom_transfer_price
3389 , ei.acct_tp_rate_type -- acct_tp_rate_type
3390 , ei.acct_tp_rate_date -- acct_tp_rate_date
3391 , ei.acct_tp_exchange_rate -- acct_tp_exchange_rate
3392 , ei.acct_transfer_price -- acct_transfer_price
3393 , ei.projacct_transfer_price -- projacct_transfer_price
3394 , ei.cc_markup_base_code -- cc_markup_base_code
3395 , ei.tp_base_amount -- tp_base_amount
3396 , ei.cc_cross_charge_type -- cc_cross_charge_type
3397 , ei.recvr_org_id -- recvr_org_id
3398 , ei.cc_bl_distributed_code -- cc_bl_distributed_code
3399 , ei.cc_ic_processed_code -- cc_ic_processed_code
3400 , ei.tp_ind_compiled_set_id -- tp_ind_compiled_set_id
3401 , ei.tp_bill_rate -- tp_bill_rate
3402 , ei.tp_bill_markup_percentage -- tp_bill_markup_percentage
3403 , ei.tp_schedule_line_percentage -- tp_schedule_line_percentage
3404 , ei.tp_rule_percentage -- tp_rule_percentage */
3405 , ei.recvr_org_id -- recvr_org_id /*Bug# 2028917*/
3406 , assignment_id
3407 , work_type_id
3408 , projfunc_currency_code
3409 , projfunc_cost_rate_type
3410 , projfunc_cost_rate_date
3411 , projfunc_cost_exchange_rate
3412 , item_project_raw_cost
3413 , item_project_burdened_cost
3414 /* , project_tp_rate_type
3415 , project_tp_rate_date
3416 , project_tp_exchange_rate
3417 , project_transfer_price **/
3418 , project_id
3419 , ei.tp_amt_type_code /** added for bug 3117718 **/
3420 , ei.inventory_item_id -- Bug 4320459
3421 , ei.unit_of_measure -- Bug 4320459
3422 , Po_Line_Id /* for bug 9939183 */
3423 , Po_Price_Type /* for bug 9939183 */
3424 /* R12 Changes - Start */
3425 , ei.document_header_id
3426 , ei.document_distribution_id
3427 , ei.document_line_number
3428 , ei.document_payment_id
3429 , ei.vendor_id
3430 , ei.document_type
3431 , ei.document_distribution_type
3432 /* R12 Changes - End */
3433 /* 12.2 changes for payroll intg .. start */
3434 , ei.location_id
3435 , ei.pay_element_type_id
3436 , ei.rate_source_code
3437 , ei.costing_method
3438 , NULL /*ei.payroll_accrual_flag -- bug 12541898 Commented for bug 12925334 */
3439 , ei.interface_run_id -- bug 12541898
3440 /* 12.2 changes for payroll intg .. end */
3441 , ei.cbs_element_id -- Added for CBS Enhancement Bug 16220146
3442 FROM
3443 pa_expenditure_items_all ei
3444 WHERE
3445 ei.expenditure_item_id = X_exp_item_id;
3446
3447 IF P_DEBUG_MODE THEN
3448 print_message('get_denom_curr_code: ' || 'Num of rows inserted in split['||sql%rowcount||']' );
3449 END IF;
3450
3451 IF ( item_comment IS NOT NULL ) THEN
3452
3453 pa_transactions.InsItemComment(
3454 X_ei_id => new_item_id
3455 , X_ei_comment => item_comment
3456 , X_user => X_user
3457 , X_login => X_login
3458 , X_status => temp_status );
3459
3460 CheckStatus( status_indicator => temp_status );
3461
3462 END IF;
3463
3464 InsAuditRec(
3465 X_exp_item_id => new_item_id
3466 , X_adj_activity => 'SPLIT DESTINATION'
3467 , X_module => X_module
3468 , X_user => X_user
3469 , X_login => X_login
3470 , X_status => temp_status );
3471
3472 CheckStatus( status_indicator => temp_status );
3473
3474 END LOOP;
3475
3476 IF P_DEBUG_MODE THEN
3477 print_message('get_denom_curr_code: ' || 'end of split api');
3478 END IF;
3479
3480 X_status := 0;
3481
3482 EXCEPTION
3483 WHEN OTHERS THEN
3484 X_status := SQLCODE;
3485 IF P_DEBUG_MODE THEN
3486 print_message('get_denom_curr_code: ' || 'status ='||X_status);
3487 END IF;
3488 RAISE;
3489
3490 END Split;
3491
3492
3493 -- ========================================================================
3494 -- PROCEDURE Transfer
3495 -- ========================================================================
3496
3497 PROCEDURE Transfer ( ItemsIdTab IN pa_utils.IdTabTyp
3498 , X_dest_prj_id IN NUMBER
3499 , X_dest_task_id IN NUMBER
3500 , X_project_currency_code IN VARCHAR2
3501 , X_project_rate_type IN VARCHAR2
3502 , X_project_rate_date IN DATE
3503 , X_project_exchange_rate IN NUMBER
3504 , X_user IN NUMBER
3505 , X_login IN NUMBER
3506 , X_module IN VARCHAR2
3507 , X_adjust_level IN VARCHAR2
3508 , rows IN BINARY_INTEGER
3509 , X_num_processed OUT NOCOPY NUMBER
3510 , X_num_rejected OUT NOCOPY NUMBER
3511 , X_outcome OUT NOCOPY VARCHAR2
3512 , X_msg_application OUT NOCOPY VARCHAR2
3513 , X_msg_type OUT NOCOPY VARCHAR2
3514 , X_msg_token1 OUT NOCOPY VARCHAR2
3515 , X_msg_token2 OUT NOCOPY VARCHAR2
3516 , X_msg_token3 OUT NOCOPY VARCHAR2
3517 , X_msg_count OUT NOCOPY Number
3518 , p_projfunc_currency_code IN VARCHAR2
3519 , p_projfunc_cost_rate_type IN VARCHAR2
3520 , p_projfunc_cost_rate_date IN DATE
3521 , p_projfunc_cost_exchg_rate IN NUMBER
3522 , p_assignment_id IN NUMBER
3523 , p_work_type_id IN NUMBER
3524 , p_cbs_element_id IN NUMBER -- Added for CBS Enhancement Bug 16220146
3525 -- , p_dest_cbs_element_id IN NUMBER -- Added for CBS Enhancement Bug 16220146
3526 -- commented the above line as part of bug 16686195
3527 ) IS
3528
3529 dummy NUMBER DEFAULT 0;
3530 temp_num_processed NUMBER DEFAULT 0;
3531 temp_num_rejected NUMBER DEFAULT 0;
3532 temp_status NUMBER DEFAULT NULL;
3533 temp_outcome VARCHAR2(30) DEFAULT NULL;
3534 temp_stage NUMBER;
3535 temp_msg_application VARCHAR2(30) :='PA';
3536 temp_msg_type VARCHAR2(1) :='E';
3537 temp_msg_token1 VARCHAR2(240) :='';
3538 temp_msg_token2 VARCHAR2(240) :='';
3539 temp_msg_token3 VARCHAR2(240) :='';
3540 temp_msg_count NUMBER ;
3541
3542 l_project_rate_date DATE := X_project_rate_date;
3543 l_project_rate_type VARCHAR2(30) := X_project_rate_type;
3544 l_project_exchange_rate NUMBER := X_project_exchange_rate;
3545
3546 l_projfunc_cost_rate_date DATE := p_projfunc_cost_rate_date;
3547 l_projfunc_cost_rate_type VARCHAR2(30) := p_projfunc_cost_rate_type;
3548 l_projfunc_cost_exchg_rate NUMBER := p_projfunc_cost_exchg_rate;
3549 l_denom_currency_code VARCHAR2(30) := NULL;
3550
3551 l_assignment_id NUMBER;
3552 l_assignment_name VARCHAR2(80);
3553 l_work_type_id NUMBER;
3554 l_work_type_name VARCHAR2(80);
3555 l_tp_amt_type_code VARCHAR2(80);
3556 l_error_status VARCHAR2(80);
3557 l_error_message_code VARCHAR2(800);
3558 l_dest_lcm VARCHAR2(20) DEFAULT NULL;
3559 l_acct_rate_date date;
3560 l_acct_rate_type varchar2(100);
3561 l_acct_exchange_rate number;
3562 l_project_currency_code varchar2(100) := x_project_currency_code;
3563 l_denom_burdened_cost NUMBER; --Added for bug 6031129
3564
3565
3566 /* changing the cursor select below for the raw_cost and burden_cost
3567 to make it null always. The costing program would fill in the raw cost
3568 with the acct_raw_cost for VI and ER when the curr codes are same */
3569
3570 CURSOR Items ( X_expenditure_item_id IN NUMBER ) IS
3571 SELECT
3572 ei.billable_flag
3573 , ei.bill_hold_flag
3574 , NULL raw_cost
3575 , decode(ei.system_linkage_function, 'VI',
3576 ei2.raw_cost_rate,
3577 decode(ts.costed_flag,
3578 'Y', ei2.raw_cost_rate,
3579 NULL)) raw_cost_rate
3580 , NULL burden_cost
3581 /*, decode( ei.system_linkage_function, 'VI',
3582 ei.override_to_organization_id, NULL ) override_to_org */
3583 /* Modified For Bug2235662 */
3584 , decode(ei.system_linkage_function,
3585 'VI',ei.override_to_organization_id,
3586 'ER',decode(ei.transaction_source,
3587 null,null,
3588 ei.override_to_organization_id),
3589 null) override_to_org
3590 , ei.organization_id nl_resource_org_id
3591 , ei.transaction_source
3592 , ei.vendor_id vendor_id /* R12 Changes - removed reference to cdl.system_reference1 */
3593 , ei.attribute_category
3594 , ei.attribute1
3595 , ei.attribute2
3596 , ei.attribute3
3597 , ei.attribute4
3598 , ei.attribute5
3599 , ei.attribute6
3600 , ei.attribute7
3601 , ei.attribute8
3602 , ei.attribute9
3603 , ei.attribute10
3604 , ec.expenditure_comment
3605 , decode(ei.system_linkage_function, 'VI',
3606 NVL(ei.override_to_organization_id,e.incurred_by_organization_id), /*Modified for bug 7422380*/
3607 e.incurred_by_organization_id ) inc_by_org_id
3608 , e.incurred_by_person_id inc_by_person_id
3609 , ei.expenditure_item_date
3610 , decode(ei.transaction_source,'PTE TIME',NULL,
3611 decode(ei.transaction_source,'PTE EXPENSE',NULL,
3612 decode(ei.transaction_source,'ORACLE TIME AND LABOR',NULL,
3613 decode(ei.transaction_source,'Oracle Self Service Time',NULL,
3614 ei.orig_transaction_reference)))) orig_transaction_reference
3615 , ei.expenditure_type
3616 , ei.system_linkage_function
3617 , ei.non_labor_resource
3618 , ei.quantity
3619 , e.expenditure_id
3620 , ei.expenditure_item_id transferred_from_exp_item_id
3621 , ei.adjusted_expenditure_item_id expenditure_item_id
3622 , ei.job_id
3623 , ei.org_id
3624 , ei.burden_sum_dest_run_id
3625 , ei.receipt_currency_amount
3626 , ei.receipt_currency_code
3627 , ei.receipt_exchange_rate
3628 , ei.denom_currency_code
3629 , decode(ei.system_linkage_function, 'VI', ei2.denom_raw_cost,
3630 'ER', ei2.denom_raw_cost,decode( ts.costed_flag, 'Y',
3631 ei2.denom_raw_cost, NULL)) denom_raw_cost
3632 , decode(ei.system_linkage_function ,'BTC',ei.denom_burdened_cost,
3633 decode( ts.allow_burden_flag, 'Y',decode(getprojburdenflag(ei.project_id),'N',NULL,
3634 ei2.denom_burdened_cost), NULL)) denom_burdened_cost /*Bug# 5874347*/ /*Bug 8371013: */
3635 , ei.acct_currency_code
3636 , decode(ei.system_linkage_function,'VI',ei2.acct_rate_date,
3637 'ER',ei2.acct_rate_date, decode(ts.gl_accounted_flag,'Y',
3638 ei2.acct_rate_date,decode(ei.acct_rate_type,'User',ei.acct_rate_date,NULL))) acct_rate_date --Bug#3787213
3639 , decode(ei.system_linkage_function,'VI',ei2.acct_rate_type,
3640 'ER',ei2.acct_rate_type, decode(ts.gl_accounted_flag,'Y',
3641 ei2.acct_rate_type,decode(ei.acct_rate_type,'User',ei.acct_rate_type,NULL))) acct_rate_type --Bug#3787213
3642 , decode(ei.system_linkage_function,'VI',ei2.acct_exchange_rate,
3643 'ER',ei2.acct_exchange_rate, decode(ts.gl_accounted_flag,'Y',
3644 ei2.acct_exchange_rate,decode(ei.acct_rate_type,'User',ei.acct_exchange_rate,NULL))) acct_exchange_rate --Bug#3787213
3645 , decode(ei.system_linkage_function, 'VI', ei2.acct_raw_cost,
3646 'ER', ei2.acct_raw_cost, decode( ts.gl_accounted_flag, 'Y',
3647 ei2.acct_raw_cost, NULL)) acct_raw_cost
3648 , ei.acct_exchange_rounding_limit
3649 , decode(ei.system_linkage_function, 'VI','Y', 'ER','Y',
3650 nvl(ts.gl_accounted_flag,'N')) gl_accounted_flag
3651 /* , ei.cc_cross_charge_code -- cc_cross_charge_code
3652 , ei.cc_prvdr_organization_id -- cc_prvdr_organization_id
3653 , ei.cc_recvr_organization_id -- cc_recvr_organization_id
3654 , ei.cc_rejection_code -- cc_rejection_code
3655 , ei.denom_tp_currency_code -- denom_tp_currency_code
3656 , ei.denom_transfer_price -- denom_transfer_price
3657 , ei.acct_tp_rate_type -- acct_tp_rate_type
3658 , ei.acct_tp_rate_date -- acct_tp_rate_date
3659 , ei.acct_tp_exchange_rate -- acct_tp_exchange_rate
3660 , ei.acct_transfer_price -- acct_transfer_price
3661 , ei.projacct_transfer_price -- projacct_transfer_price
3662 , ei.cc_markup_base_code -- cc_markup_base_code
3663 , ei.tp_base_amount -- tp_base_amount
3664 , ei.cc_cross_charge_type -- cc_cross_charge_type
3665 , ei.recvr_org_id -- recvr_org_id
3666 , ei.cc_bl_distributed_code -- cc_bl_distributed_code
3667 , ei.cc_ic_processed_code -- cc_ic_processed_code
3668 , ei.tp_ind_compiled_set_id -- tp_ind_compiled_set_id
3669 , ei.tp_bill_rate -- tp_bill_rate
3670 , ei.tp_bill_markup_percentage -- tp_bill_markup_percentage
3671 , ei.tp_schedule_line_percentage -- tp_schedule_line_percentage
3672 , ei.tp_rule_percentage -- tp_rule_percentage
3673 */
3674 , NULL project_raw_cost
3675 , NULL project_burdened_cost
3676 , ei.assignment_id
3677 , ei.work_type_id
3678 , ei.project_rate_type
3679 , ei.project_rate_date
3680 , ei.project_exchange_rate
3681 , e.person_type -- Fix for bug : 3681318
3682 , decode(ei.system_linkage_function,'BTC',ei.acct_burdened_cost,null) acct_burdened_cost /* bug 3669152 */
3683 , ei.project_currency_code --Start of Bug#3787213. 5 Columns added
3684 , ei.projfunc_currency_code
3685 , ei.projfunc_cost_rate_type
3686 , ei.projfunc_cost_rate_date
3687 , ei.projfunc_cost_exchange_rate --End of Bug#3787213.
3688 , ei.inventory_item_id -- Bug 4320459
3689 , ei.unit_of_measure -- Bug 4320459
3690 /* R12 Changes -Start */
3691 , ei.document_header_id
3692 , ei.document_distribution_id
3693 , ei.document_line_number
3694 , ei.document_payment_id
3695 , ei.vendor_id ei_vendor_id
3696 , ei.document_type
3697 , ei.document_distribution_type
3698 /* R12 Changes - End */
3699 , ei.po_line_id /* for bug 9939183*/
3700 , ei.po_price_type /* for bug 9939183*/
3701 /* added for 12.2 payroll intg */
3702 , ei.location_id
3703 , ei.pay_element_type_id
3704 , ei.rate_source_code
3705 , ei.costing_method
3706 , ei.payroll_accrual_flag -- bug 12541898
3707 , ei.interface_run_id -- bug 12541898
3708 FROM
3709 pa_expenditures_all e
3710 , pa_expenditure_items_all ei
3711 , pa_expenditure_items_all ei2
3712 , pa_transaction_sources ts
3713 , pa_expenditure_comments ec
3714 /* R12 changes - Removed table pa_cost_distribution_lines */
3715 WHERE
3716 e.expenditure_id = ei.expenditure_id
3717 AND ei.expenditure_item_id = ei2.expenditure_item_id
3718 /* R12 Changes - Removed join conditions for pa_cost_distribution_lines table */
3719 AND ei2.transaction_source = ts.transaction_source (+)
3720 AND ei.expenditure_item_id = X_expenditure_item_id
3721 AND ec.expenditure_item_id (+)= ei.expenditure_item_id ;
3722
3723 /* Commented the following code as part of Bug#2291180 -- Start
3724 -- EFC bug2259454 changes
3725 Function get_denom_curr_code2 (l_exp_type in varchar2,
3726 l_denom_currency_code in varchar2,
3727 l_acct_currency_code in varchar2,
3728 l_system_linkage_function in varchar2) return varchar2 is
3729
3730 l_cost_rate_flag varchar2(30);
3731 l_return varchar2(30);
3732
3733 Begin
3734
3735 If l_system_linkage_function in ('ST','OT') Then
3736 If l_acct_currency_code = l_denom_currency_code Then
3737 l_return := l_denom_currency_code;
3738 Else
3739 l_return := pa_currency.get_currency_code;
3740 End If;
3741 Else
3742 select cost_rate_flag
3743 into l_cost_rate_flag
3744 from pa_expenditure_types
3745 where expenditure_type = l_exp_type;
3746
3747 If l_cost_rate_flag = 'Y' Then
3748 If l_acct_currency_code = l_denom_currency_code Then
3749 l_return := l_denom_currency_code;
3750 Else
3751 l_return := pa_currency.get_currency_code;
3752 End If;
3753 Else
3754 l_return := l_denom_currency_code;
3755 End If;
3756 End If;
3757
3758 return l_return;
3759
3760 End get_denom_curr_code2;
3761 Commented the above code as part of Bug#2291180 -- End */
3762
3763 -- Start of Transfer main PL/SQL block
3764
3765 BEGIN
3766
3767 IF P_DEBUG_MODE THEN
3768 print_message('get_denom_curr_code: ' || 'inside Transfer api');
3769 END IF;
3770 l_dest_lcm := pa_utils2.GetLaborCostMultiplier(X_dest_task_id);
3771 FOR i IN 1..rows LOOP
3772
3773 FOR EiRec IN Items( ItemsIdTab(i) ) LOOP
3774
3775 /** derive the destination project currency code based on destination task and destination project **/
3776 --IF X_project_currency_code is NULL then
3777 BEGIN
3778 SELECT decode(project_currency_code,NULL,projfunc_currency_code,project_currency_code)
3779 INTO l_project_currency_code
3780 FROM pa_projects_all
3781 WHERE project_id = x_dest_prj_id;
3782 EXCEPTION
3783 WHEN NO_DATA_FOUND then
3784 Raise;
3785
3786 WHEN OTHERS then
3787 Raise;
3788 END;
3789
3790 --End if;
3791
3792 /* BEGIN
3793 --Added this block for bug 5759574
3794 --Reverted this check for bug 7454045
3795
3796 SELECT w.name
3797 INTO l_work_type_name
3798 FROM pa_work_types_v w
3799 WHERE w.work_type_id = eirec.work_type_id;
3800
3801 EXCEPTION
3802 WHEN others THEN
3803 NULL;
3804 END; */
3805
3806 IF P_DEBUG_MODE THEN
3807 print_message('get_denom_curr_code: ' || 'calling get work type assignment api');
3808 END IF;
3809 /** derive work type and assignment for the destination task , project **/
3810 Pa_Utils4.Get_Work_Assignment (
3811 p_person_id => EiRec.inc_by_person_id
3812 ,p_project_id => X_dest_prj_id
3813 ,p_task_id => X_dest_task_id
3814 ,p_ei_date => EiRec.expenditure_item_date
3815 ,p_system_linkage => EiRec.system_linkage_function
3816 ,x_assignment_id => l_assignment_id
3817 ,x_assignment_name => l_assignment_name
3818 ,x_work_type_id => l_work_type_id
3819 ,x_work_type_name => l_work_type_name
3820 ,x_tp_amt_type_code => l_tp_amt_type_code
3821 ,x_return_status => l_error_status
3822 ,x_error_message_code => l_error_message_code);
3823
3824 -- EFC bug2259454 change
3825 l_denom_currency_code := get_denom_curr_code (EiRec.transaction_source,
3826 EiRec.expenditure_type,
3827 EiRec.denom_currency_code,
3828 EiRec.acct_currency_code,
3829 EiRec.system_linkage_function);
3830
3831 IF P_DEBUG_MODE THEN
3832 print_message('get_denom_curr_code: ' || 'after get work assign l_assignment_id['||l_assignment_id||
3833 ']l_assignment_name['||l_assignment_name||']l_work_type_id ['||l_work_type_id||
3834 ']l_work_type_name['||l_work_type_name||']x_tp_amt_type_code['||l_tp_amt_type_code|| ']' );
3835 END IF;
3836 l_acct_rate_date := EiRec.acct_rate_date;
3837 l_acct_rate_type := EiRec.acct_rate_type;
3838 l_acct_exchange_rate := EiRec.acct_exchange_rate;
3839 /*Bug#3787213. Added if condition for validating the source and destination currency code for rate type 'User'
3840 If source and destination currencies are same for User rate_type then we are copying the rate_type,
3841 rate_date, and exchange_rate.
3842 */
3843 IF EiRec.project_currency_code = l_project_currency_code
3844 and EiRec.projfunc_currency_code = p_projfunc_currency_code
3845 and l_acct_rate_type = 'User' THEN
3846
3847 l_project_rate_type := EiRec.project_rate_type;
3848 l_project_rate_date := EiRec.project_rate_date;
3849 l_project_exchange_rate := EiRec.project_exchange_rate;
3850 l_projfunc_cost_rate_type := EiRec.projfunc_cost_rate_type;
3851 l_projfunc_cost_rate_date := EiRec.projfunc_cost_rate_date;
3852 l_projfunc_cost_exchg_rate := EiRec.projfunc_cost_exchange_rate;
3853
3854 ELSE
3855
3856 pa_multi_currency_txn.get_currency_attributes (
3857 P_TASK_ID => X_dest_task_id,
3858 P_EI_DATE => Eirec.expenditure_item_date,
3859 P_CALLING_MODULE => 'TRANSFER',
3860 -- P_DENOM_CURR_CODE => EiRec.denom_currency_code,
3861 P_DENOM_CURR_CODE => l_denom_currency_code, -- EFC bug2259454 change
3862 P_ACCT_CURR_CODE => EiRec.acct_currency_code,
3863 P_ACCOUNTED_FLAG => EiRec.gl_accounted_flag,
3864 x_ACCT_RATE_DATE => l_acct_rate_date,
3865 x_ACCT_RATE_TYPE => l_acct_rate_type,
3866 x_ACCT_EXCH_RATE => l_acct_exchange_rate,
3867 P_project_curr_code => l_project_currency_code,
3868 x_project_rate_type => l_project_rate_type,
3869 x_project_rate_date => l_project_rate_date,
3870 x_project_exch_rate => l_project_exchange_rate,
3871 P_PROJFUNC_CURR_CODE => p_projfunc_currency_code,
3872 x_PROJFUNC_COST_RATE_TYPE => l_projfunc_cost_rate_type,
3873 x_PROJFUNC_COST_RATE_DATE => l_projfunc_cost_rate_date,
3874 x_PROJFUNC_COST_EXCH_RATE => l_projfunc_cost_exchg_rate,
3875 P_SYSTEM_LINKAGE => EiRec.system_linkage_function,
3876 x_status => temp_outcome,
3877 x_stage => temp_stage);
3878 END IF;
3879
3880 IF P_DEBUG_MODE THEN
3881 print_message('get_denom_curr_code: ' || 'after multi currency p_projfunc_currency_code['||p_projfunc_currency_code||
3882 ']l_projfunc_cost_rate_type['||l_projfunc_cost_rate_type||
3883 ']l_projfunc_cost_rate_date['||l_projfunc_cost_rate_date||
3884 ']l_projfunc_cost_exchg_rate['||l_projfunc_cost_exchg_rate||
3885 ']l_project_currency_code['||l_project_currency_code||
3886 ']l_project_rate_type ['||l_project_rate_type||']l_project_rate_date ['||l_project_rate_date||
3887 ']l_project_exchange_rate['||l_project_exchange_rate||']' );
3888 END IF;
3889
3890
3891 IF ( temp_outcome IS NOT NULL ) THEN
3892
3893 IF ( X_adjust_level = 'I' ) THEN
3894 X_outcome := temp_outcome;
3895 RETURN;
3896 ELSE
3897 temp_num_rejected := temp_num_rejected + 1;
3898 /* R12 Changes Start */
3899 InsAuditRec( ItemsIdTab(i)
3900 , 'TRANSFER DESTINATION'
3901 , X_module
3902 , X_user
3903 , X_login
3904 , temp_status
3905 , G_REQUEST_ID
3906 , G_PROGRAM_ID
3907 , G_PROG_APPL_ID
3908 , sysdate
3909 , temp_outcome);
3910 CheckStatus(temp_status);
3911 /* R12 Changes End */
3912 temp_outcome := NULL;
3913 END IF;
3914
3915 ELSE
3916
3917 EiRec.expenditure_item_id := pa_utils.GetNextEiId;
3918 pa_transactions_pub.validate_transaction(
3919 X_project_id => X_dest_prj_id
3920 , X_task_id => X_dest_task_id
3921 , X_ei_date => EiRec.expenditure_item_date
3922 , X_expenditure_type => EiRec.expenditure_type
3923 , X_non_labor_resource => EiRec.non_labor_resource
3924 , X_person_id => EiRec.inc_by_person_id
3925 , X_quantity => EiRec.quantity
3926 -- , X_denom_currency_code => EiRec.denom_currency_code
3927 , X_denom_currency_code => l_denom_currency_code -- EFC bug2259454 change
3928 , X_acct_currency_code => EiRec.Acct_currency_code
3929 , X_denom_raw_cost => EiRec.denom_raw_cost
3930 , X_acct_raw_cost => EiRec.acct_raw_cost
3931 , X_acct_rate_type => l_acct_rate_type --Bug#3787213. Eirec.acct_rate_type
3932 , X_acct_rate_date => l_acct_rate_date --Bug#3787213. Eirec.acct_rate_date
3933 , X_acct_exchange_rate => l_acct_exchange_rate --Bug#3787213. Eirec.acct_exchange_rate
3934 , X_transfer_ei => EiRec.transferred_from_exp_item_id
3935 , X_incurred_by_org_id => EiRec.inc_by_org_id
3936 , X_nl_resource_org_id => EiRec.nl_resource_org_id
3937 , X_transaction_source => EiRec.transaction_source
3938 , X_calling_module => X_module
3939 , X_vendor_id => EiRec.vendor_id
3940 , X_entered_by_user_id => X_user
3941 , X_attribute_category => EiRec.attribute_category
3942 , X_attribute1 => EiRec.attribute1
3943 , X_attribute2 => EiRec.attribute2
3944 , X_attribute3 => EiRec.attribute3
3945 , X_attribute4 => EiRec.attribute4
3946 , X_attribute5 => EiRec.attribute5
3947 , X_attribute6 => EiRec.attribute6
3948 , X_attribute7 => EiRec.attribute7
3949 , X_attribute8 => EiRec.attribute8
3950 , X_attribute9 => EiRec.attribute9
3951 , X_attribute10 => EiRec.attribute10
3952 , X_attribute11 => ''
3953 , X_attribute12 => ''
3954 , X_attribute13 => ''
3955 , X_attribute14 => ''
3956 , X_attribute15 => ''
3957 , X_msg_application => temp_msg_application
3958 , X_msg_type => temp_msg_type
3959 , X_msg_token1 => temp_msg_token1
3960 , X_msg_token2 => temp_msg_token2
3961 , X_msg_token3 => temp_msg_token3
3962 , X_msg_count => temp_msg_count
3963 , X_msg_data => temp_outcome
3964 , X_billable_flag => EiRec.billable_flag
3965 , p_projfunc_currency_code => p_projfunc_currency_code
3966 , p_projfunc_cost_rate_type => l_projfunc_cost_rate_type
3967 , p_projfunc_cost_rate_date => l_projfunc_cost_rate_date
3968 , p_projfunc_cost_exchg_rate =>l_projfunc_cost_exchg_rate
3969 , p_assignment_id => l_assignment_id
3970 , p_work_type_id => l_work_type_id
3971 , p_sys_link_function => EiRec.system_linkage_function
3972 , p_person_type => EiRec.person_type ); -- Fix for bug : 3681318
3973
3974 /* Start of Bug 2648550 */
3975 l_assignment_id := PATC.G_OVERIDE_ASSIGNMENT_ID;
3976 l_work_type_id := PATC.G_OVERIDE_WORK_TYPE_ID;
3977 l_tp_amt_type_code := PATC.G_OVERIDE_TP_AMT_TYPE_CODE;
3978 /* End of Bug 2648550 */
3979
3980 IF ( temp_outcome IS NOT NULL AND ( temp_msg_type = 'E' ) ) THEN /* Added msg_type check for Bug 4906816 */
3981 /*Changes for 7371988 Starts here*/
3982
3983 IF ( X_adjust_level = 'I' ) THEN
3984 X_outcome := temp_outcome;
3985 X_msg_application := temp_msg_application;
3986 X_msg_type := temp_msg_type;
3987 X_msg_token1 := temp_msg_token1;
3988 X_msg_token2 := temp_msg_token2;
3989 X_msg_token3 := temp_msg_token3;
3990 X_msg_count := temp_msg_count;
3991 RETURN;
3992 ELSE
3993 temp_num_rejected := temp_num_rejected + 1;
3994 temp_outcome := NULL;
3995 END IF;
3996
3997 ELSE
3998
3999 /* Added for Bug 4906816 */
4000 IF ( ( temp_outcome IS NOT NULL ) AND ( temp_msg_type = 'W' ) ) THEN
4001 IF ( X_adjust_level = 'I' ) THEN
4002 X_outcome := temp_outcome;
4003 X_msg_application := temp_msg_application;
4004 X_msg_type := temp_msg_type;
4005 X_msg_token1 := temp_msg_token1;
4006 X_msg_token2 := temp_msg_token2;
4007 X_msg_token3 := temp_msg_token3;
4008 X_msg_count := temp_msg_count;
4009 END IF;
4010 END IF;
4011
4012 --temp_num_rejected := temp_num_rejected + 1;
4013 /* R12 Changes Start */
4014 InsAuditRec( ItemsIdTab(i)
4015 , 'TRANSFER DESTINATION'
4016 , X_module
4017 , X_user
4018 , X_login
4019 , temp_status
4020 , G_REQUEST_ID
4021 , G_PROGRAM_ID
4022 , G_PROG_APPL_ID
4023 , sysdate
4024 , temp_outcome);
4025 CheckStatus(temp_status);
4026 /* R12 Changes End */
4027 temp_outcome := NULL;
4028
4029 --END IF;
4030
4031 --ELSE
4032 /*Changes for 7371988 ends here*/
4033 temp_num_processed := temp_num_processed + 1;
4034
4035 if ( EiRec.transferred_from_exp_item_id is not null and
4036 EiRec.system_linkage_function ='BTC' ) then /* Bug 8372560 */
4037
4038 l_denom_burdened_cost := EiRec.denom_burdened_cost;
4039 else
4040
4041 select decode(getprojburdenflag(X_dest_prj_id), -- Bug#Bug6031129
4042 'N',null,EiRec.denom_burdened_cost)
4043 into l_denom_burdened_cost
4044 from dual;
4045 end if;
4046
4047 /* NO IC Changes required. A transfer is considered a new txn
4048 For new txns the Cross Charge attributes are populated by
4049 IC processes.
4050 */
4051 pa_transactions.LoadEi(
4052 X_expenditure_item_id => EiRec.expenditure_item_id
4053 ,X_expenditure_id => EiRec.expenditure_id
4054 ,X_expenditure_item_date => EiRec.expenditure_item_date
4055 ,X_project_id => X_dest_prj_id --NULL
4056 ,X_task_id => X_dest_task_id
4057 ,X_expenditure_type => EiRec.expenditure_type
4058 ,X_non_labor_resource => EiRec.non_labor_resource
4059 ,X_nl_resource_org_id => EiRec.nl_resource_org_id
4060 ,X_quantity => EiRec.quantity
4061 ,X_raw_cost => EiRec.raw_cost
4062 ,X_raw_cost_rate => EiRec.raw_cost_rate
4063 ,X_override_to_org_id => EiRec.override_to_org
4064 ,X_billable_flag => EiRec.billable_flag
4065 ,X_bill_hold_flag => EiRec.bill_hold_flag
4066 ,X_orig_transaction_ref => EiRec.orig_transaction_reference
4067 ,X_transferred_from_ei => EiRec.transferred_from_exp_item_id
4068 ,X_adj_expend_item_id => to_number( NULL )
4069 ,X_attribute_category => EiRec.attribute_category
4070 ,X_attribute1 => EiRec.attribute1
4071 ,X_attribute2 => EiRec.attribute2
4072 ,X_attribute3 => EiRec.attribute3
4073 ,X_attribute4 => EiRec.attribute4
4074 ,X_attribute5 => EiRec.attribute5
4075 ,X_attribute6 => EiRec.attribute6
4076 ,X_attribute7 => EiRec.attribute7
4077 ,X_attribute8 => EiRec.attribute8
4078 ,X_attribute9 => EiRec.attribute9
4079 ,X_attribute10 => EiRec.attribute10
4080 ,X_ei_comment => EiRec.expenditure_comment
4081 ,X_transaction_source => EiRec.transaction_source
4082 ,X_source_exp_item_id => to_number( NULL )
4083 ,i => temp_num_processed
4084 ,X_job_id => EiRec.job_id
4085 ,X_org_id => EiRec.org_id
4086 ,X_labor_cost_multiplier_name => l_dest_lcm
4087 ,X_drccid => NULL
4088 ,X_crccid => NULL
4089 ,X_cdlsr1 => NULL
4090 ,X_cdlsr2 => NULL
4091 ,X_cdlsr3 => NULL
4092 ,X_gldate => NULL
4093 ,X_bcost => NULL /* Bug#1263399 */
4094 ,X_bcostrate => NULL
4095 ,X_etypeclass => EiRec.system_linkage_function
4096 ,X_burden_sum_dest_run_id => EiRec.burden_sum_dest_run_id
4097 ,X_burden_compile_set_id => NULL
4098 ,X_receipt_currency_amount => EiRec.receipt_currency_amount
4099 ,X_receipt_currency_code => EiRec.receipt_currency_code
4100 ,X_receipt_exchange_rate => EiRec.receipt_exchange_rate
4101 -- ,X_denom_currency_code => EiRec.denom_currency_code
4102 ,X_denom_currency_code => l_denom_currency_code -- EFC bug2259454 change
4103 ,X_denom_raw_cost => EiRec.denom_raw_cost
4104 ,X_denom_burdened_cost => l_denom_burdened_cost -- Bug#6031129
4105 ,X_acct_currency_code => EiRec.acct_currency_code
4106 ,X_acct_rate_date => l_acct_rate_date --Bug#3787213. Eirec.acct_rate_date
4107 ,X_acct_rate_type => l_acct_rate_type --Bug#3787213. Eirec.acct_rate_type
4108 ,X_acct_exchange_rate => l_acct_exchange_rate --Bug#3787213. Eirec.acct_exchange_rate
4109 ,X_acct_raw_cost => EiRec.acct_raw_cost
4110 ,X_acct_burdened_cost => EiRec.acct_burdened_cost /* bug 3669152 */
4111 ,X_acct_exchange_rounding_limit => EiRec.acct_exchange_rounding_limit
4112 ,X_project_currency_code => l_project_currency_code
4113 ,X_project_rate_date => l_project_rate_date
4114 ,X_project_rate_type => l_project_rate_type
4115 ,X_project_exchange_rate => l_project_exchange_rate
4116 , p_assignment_id => l_assignment_id
4117 , p_work_type_id => l_work_type_id
4118 , p_projfunc_currency_code => p_projfunc_currency_code
4119 , p_projfunc_cost_rate_date => l_projfunc_cost_rate_date
4120 , p_projfunc_cost_rate_type => l_projfunc_cost_rate_type
4121 , p_projfunc_cost_exchange_rate => l_projfunc_cost_exchg_rate
4122 , p_project_raw_cost => EiRec.project_raw_cost
4123 , p_project_burdened_cost => EiRec.project_burdened_cost
4124 , p_tp_amt_type_code => l_tp_amt_type_code
4125 , p_Inventory_Item_Id => EiRec.inventory_item_id -- Bug 4320459
4126 , p_Unit_Of_Measure => EiRec.unit_of_measure -- Bug 4320459
4127 , p_Po_Line_Id => EiRec.po_line_id /* for bug 9939183*/
4128 , p_Po_Price_Type => EiRec.po_price_type /* for bug 9939183*/
4129 /* R12 Changes - Start */
4130 , p_document_header_id => EiRec.document_header_id
4131 , p_document_distribution_id => EiRec.document_distribution_id
4132 , p_document_line_number => EiRec.document_line_number
4133 , p_document_payment_id => EiRec.document_payment_id
4134 , p_vendor_id => EiRec.vendor_id
4135 , p_document_type => EiRec.document_type
4136 , p_document_distribution_type => EiRec.document_distribution_type
4137 /* R12 Changes - End */
4138 /* added for 12.2 payroll intg */
4139 , p_location_id => EiRec.location_id
4140 , p_pay_element_type_id => EiRec.pay_element_type_id
4141 , p_rate_source_code => EiRec.rate_source_code
4142 , p_costing_method => EiRec.costing_method
4143 , p_cbs_element_id => p_cbs_element_id -- Added for CBS Enhancement Bug 16220146
4144 ) ;
4145
4146 END IF; -- End temp_outcome is not null for get_status
4147
4148 END IF; -- End temp_outcome is not null for get_currency_attributes
4149
4150 END LOOP;
4151
4152 END LOOP;
4153
4154 pa_transactions.InsItems( X_user => X_user
4155 , X_login => X_login
4156 , X_module => X_module
4157 , X_calling_process => 'TRANSFER'
4158 , Rows => temp_num_processed
4159 , X_status => temp_status
4160 , X_gl_flag => NULL );
4161
4162 -- -------------------------------------------------------------------------
4163 -- OGM_0.0 : OGM needs to create additional details for each expenditure
4164 -- item created here. VERT_ADJUST_ITEMS does that for vertical applications.
4165 -- If temp_status is not null it does nothing else process the additional
4166 -- details and set temp_status in case of system exceptions.
4167 -- --------------------------------------------------------------------------
4168 PA_GMS_API.VERT_ADJUST_ITEMS( 'TRANSFER', temp_num_processed, temp_status ) ;
4169
4170 CheckStatus( status_indicator => temp_status );
4171
4172 X_num_processed := temp_num_processed;
4173 X_num_rejected := temp_num_rejected;
4174 /* X_outcome := NULL; Bug 4906816 - Commented to carry forward warnings also */
4175
4176 EXCEPTION
4177 WHEN OTHERS THEN
4178 X_outcome := SQLCODE;
4179 RAISE;
4180
4181 END Transfer;
4182
4183
4184 -- ========================================================================
4185 -- PROCEDURE Adjust
4186 -- ========================================================================
4187 -- Added new parameters acct rate attributes for the new rate adjustments
4188
4189 PROCEDURE Adjust( X_adj_action IN VARCHAR2
4190 , X_module IN VARCHAR2
4191 , X_user IN NUMBER
4192 , X_login IN NUMBER
4193 , X_project_id IN NUMBER
4194 , X_adjust_level IN VARCHAR2
4195 , X_expenditure_item_id IN NUMBER
4196 , X_dest_prj_id IN NUMBER
4197 , X_dest_task_id IN NUMBER
4198 , X_project_currency_code IN VARCHAR2
4199 , X_project_rate_type IN VARCHAR2
4200 , X_project_rate_date IN DATE
4201 , X_project_exchange_rate IN NUMBER
4202 , X_acct_rate_type IN VARCHAR2
4203 , X_acct_rate_date IN DATE
4204 , X_acct_exchange_rate IN NUMBER
4205 , X_task_id IN NUMBER
4206 , X_inc_by_person_id IN NUMBER
4207 , X_inc_by_org_id IN NUMBER
4208 , X_ei_date_low IN DATE
4209 , X_ei_date_high IN DATE
4210 , X_system_linkage IN VARCHAR2
4211 , X_expenditure_type IN VARCHAR2
4212 , X_vendor_id IN NUMBER
4213 , X_nl_resource_org_id IN NUMBER
4214 , X_nl_resource IN VARCHAR2
4215 , X_bill_status IN VARCHAR2
4216 , X_hold_flag IN VARCHAR2
4217 , X_expenditure_comment IN VARCHAR2
4218 , X_inv_num IN NUMBER
4219 , X_inv_line_num IN NUMBER
4220 , X_cc_code IN VARCHAR2
4221 , X_cc_type IN VARCHAR2
4222 , X_bl_dist_code IN VARCHAR2
4223 , X_ic_proc_code IN VARCHAR2
4224 , X_prvdr_orgnzn_id IN NUMBER
4225 , X_recvr_orgnzn_id IN NUMBER
4226 , X_outcome OUT NOCOPY VARCHAR2
4227 , X_num_processed OUT NOCOPY NUMBER
4228 , X_num_rejected OUT NOCOPY NUMBER
4229 , X_msg_application OUT NOCOPY VARCHAR2
4230 , X_msg_type OUT NOCOPY VARCHAR2
4231 , X_msg_token1 OUT NOCOPY VARCHAR2
4232 , X_msg_token2 OUT NOCOPY VARCHAR2
4233 , X_msg_token3 OUT NOCOPY VARCHAR2
4234 , X_msg_count OUT NOCOPY Number
4235 /* added for proj currency and additional EI attributes **/
4236 , p_assignment_id IN NUMBER
4237 , p_work_type_id IN NUMBER
4238 , p_projfunc_currency_code IN varchar2
4239 , p_projfunc_cost_rate_date IN date
4240 , p_projfunc_cost_rate_type IN varchar2
4241 , p_projfunc_cost_exchange_rate IN number
4242 , p_project_raw_cost IN number
4243 , p_project_burdened_cost IN number
4244 , p_project_tp_currency_code IN varchar2
4245 , p_project_tp_cost_rate_date IN date
4246 , p_project_tp_cost_rate_type IN varchar2
4247 , p_project_tp_cost_exchg_rate IN number
4248 , p_project_transfer_price IN number
4249 , p_dest_work_type_id IN NUMBER
4250 , p_tp_amt_type_code IN varchar2
4251 , p_dest_tp_amt_type_code IN varchar2
4252 /** end of proj currency and additional EI attributes **/
4253 , p_cbs_element_id IN number -- Added for CBS Enhancement Bug 16220146
4254 ) IS
4255
4256 ItemsIdTab pa_utils.IdTabTyp;
4257 AdjustsIdTab pa_utils.IdTabTyp;
4258 DenomCurrCodeTab pa_utils.Char15TabTyp;
4259 ProjCurrCodeTab pa_utils.Char15TabTyp;
4260 ProjFuncCurrCodeTab pa_utils.Char15TabTyp;
4261
4262 TpAmtTypCodeTab pa_utils.Char30TabTyp;
4263
4264 dummy NUMBER;
4265 temp_outcome VARCHAR2(30) DEFAULT NULL;
4266 temp_status NUMBER DEFAULT NULL;
4267 temp_num_processed NUMBER DEFAULT 0;
4268 temp_num_rejected NUMBER DEFAULT 0;
4269 temp_msg_application VARCHAR2(30) :='PA';
4270 temp_msg_type VARCHAR2(1) := 'E';
4271 temp_msg_token1 Varchar2(240) := '';
4272 temp_msg_token2 Varchar2(240) :='';
4273 temp_msg_token3 Varchar2(240) :='';
4274 temp_msg_count Number ;
4275 i BINARY_INTEGER := 0;
4276 adj_ei number;
4277 RelLockStatus number := 0; /* Bug#3598333 */
4278
4279
4280 CURSOR GetPrjExpSummary IS
4281 SELECT
4282 ei.expenditure_item_id
4283 , eia.expenditure_item_id adj_expenditure_item_id
4284 FROM
4285 pa_expenditures_all e
4286 , pa_expenditure_items_all ei
4287 , pa_expenditure_items_all eia
4288 WHERE
4289 ei.expenditure_item_id = eia.adjusted_expenditure_item_id (+)
4290 AND ei.expenditure_id = e.expenditure_id
4291 AND ei.task_id IN
4292
4293 ( SELECT
4294 t.task_id
4295 FROM
4296 pa_tasks t
4297 WHERE
4298 t.project_id = X_project_id
4299 AND t.task_id = nvl( X_task_id, t.task_id )
4300 )
4301
4302 AND ( X_inc_by_person_id IS NULL
4303 OR e.incurred_by_person_id = X_inc_by_person_id )
4304 AND ( X_inc_by_org_id IS NULL
4305 OR e.incurred_by_organization_id = X_inc_by_org_id
4306 OR ( e.incurred_by_organization_id IS NULL
4307 AND ei.override_to_organization_id = X_inc_by_org_id ))
4308 AND ( X_vendor_id IS NULL
4309 OR X_vendor_id = ei.vendor_id) /* R12 changes - Removed reference t ocdl.system_reference1 */
4310 AND ( X_system_linkage IS NULL
4311 OR ei.system_linkage_function = X_system_linkage )
4312 /* commented the following lines for mfg changes and added the one line above
4313 OR EXISTS
4314 ( SELECT NULL
4315 FROM
4316 pa_expenditure_types et
4317 WHERE
4318 et.expenditure_type = ei.expenditure_type
4319 AND ei.system_linkage_function = X_system_linkage ))
4320 */
4321 AND ei.expenditure_type =
4322 nvl( X_expenditure_type, ei.expenditure_type )
4323 AND ( X_nl_resource_org_id IS NULL
4324 OR ei.organization_id = X_nl_resource_org_id )
4325 AND ( X_nl_resource IS NULL
4326 OR ei.non_labor_resource = X_nl_resource )
4327 AND ( X_hold_flag IS NULL
4328 OR ei.bill_hold_flag = decode( X_hold_flag, 'B',
4329 decode( ei.bill_hold_flag, 'N', 'Z', ei.bill_hold_flag ),
4330 ei.bill_hold_flag ) )
4331 AND ei.expenditure_item_date BETWEEN
4332 nvl( X_ei_date_low, ei.expenditure_item_date )
4333 AND nvl( X_ei_date_high, ei.expenditure_item_date )
4334 AND ei.adjusted_expenditure_item_id IS NULL
4335 AND ( X_bill_status IS NULL
4336 OR
4337 ( X_bill_status = 'U'
4338 AND ei.project_id IS NULL
4339 AND NOT EXISTS (
4340 SELECT NULL
4341 FROM
4342 pa_proj_invoice_details_view idv
4343 WHERE
4344 idv.project_id+0 = X_project_id
4345 AND idv.expenditure_item_id =
4346 ei.expenditure_item_id ) )
4347 OR
4348 ( X_bill_status IN ( 'P', 'R', 'B' )
4349 AND EXISTS (
4350 SELECT
4351 NULL
4352 FROM
4353 pa_draft_invoices i
4354 , pa_draft_invoice_items ii
4355 WHERE
4356 i.project_id+0 = X_project_id
4357 AND i.project_id = ii.project_id
4358 AND i.draft_invoice_num = ii.draft_invoice_num
4359 AND nvl(ii.event_task_id, -1) =
4360 nvl(ei.event_task_id, -1)
4361 AND ii.project_id = ei.project_id
4362 AND ii.event_num = ei.event_num
4363 AND nvl( i.released_by_person_id, -1 ) =
4364 decode( X_bill_status, 'P', -1,
4365 'R', i.released_by_person_id,
4366 'B', nvl( i.released_by_person_id, -1), -2)))
4367 )
4368 AND ( 1 = 2
4369 OR ( X_adj_action = 'CHANGE WORK TYPE ATTRIBUTE' /** proj currency changes **/
4370 AND nvl( ei.net_zero_adjustment_flag, 'N' ) <> 'Y'
4371 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4372 AND ei.work_type_id <> p_dest_work_type_id
4373 AND e.expenditure_status_code = 'APPROVED'
4374 )
4375 OR
4376 ( X_adj_action = 'PROJECT OR TASK CHANGE'
4377 AND nvl( ei.net_zero_adjustment_flag, 'N' ) <> 'Y'
4378 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4379 AND ei.task_id <> X_dest_task_id
4380 AND e.expenditure_status_code = 'APPROVED'
4381 AND ei.source_expenditure_item_id IS NULL
4382 )
4383 OR
4384 ( X_adj_action = 'BILLING HOLD'
4385 AND ei.bill_hold_flag in ( 'N', 'O' ) )
4386 OR
4387 ( X_adj_action = 'BILLING HOLD RELEASE'
4388 AND ei.bill_hold_flag in ( 'Y', 'O' ) )
4389 OR
4390 ( X_adj_action = 'BILLABLE RECLASS'
4391 AND ei.billable_flag <> 'Y'
4392 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4393 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4394 )
4395 OR
4396 ( X_adj_action = 'NON-BILLABLE RECLASS'
4397 AND ei.billable_flag = 'Y'
4398 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4399 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4400 )
4401 OR
4402 ( X_adj_action = 'CAPITALIZABLE RECLASS'
4403 AND ei.billable_flag <> 'Y'
4404 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4405 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4406 AND exists (select 1
4407 From pa_tasks t
4408 Where t.task_id = ei.task_id
4409 And t.retirement_cost_flag = 'N')
4410
4411 )
4412 OR
4413 ( X_adj_action = 'NON-CAPITALIZABLE RECLASS'
4414 AND ei.billable_flag = 'Y'
4415 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4416 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4417 AND exists (select 1
4418 From pa_tasks t
4419 Where t.task_id = ei.task_id
4420 And t.retirement_cost_flag = 'N')
4421 )
4422 OR
4423 ( X_adj_action = 'REVENUE RECALC'
4424 AND ei.revenue_distributed_flag||'' IN ( 'Y', 'P' )
4425 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4426 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4427 )
4428 OR
4429 ( X_adj_action = 'ONE-TIME BILLING HOLD'
4430 AND ei.bill_hold_flag IN ( 'N', 'Y' ) )
4431 OR
4432 ( X_adj_action = 'COST AND REV RECALC'
4433 AND ( ei.revenue_distributed_flag||'' IN ( 'Y', 'P' )
4434 OR ( ei.cost_distributed_flag||'' = 'Y'
4435 OR ei.denom_raw_cost IS NOT NULL ) )
4436 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4437 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4438 AND ei.source_expenditure_item_id IS NULL
4439 AND nvl( ei.net_zero_adjustment_flag, 'N' ) <> 'Y'
4440 )
4441 OR
4442 ( X_adj_action = 'CAPITAL COST RECALC'
4443 AND ei.cost_distributed_flag||'' = 'Y' )
4444 OR
4445 ( X_adj_action = 'RAW COST RECALC'
4446 AND ei.cost_distributed_flag||'' = 'Y' )
4447 OR
4448 ( X_adj_action = 'INDIRECT COST RECALC'
4449 AND ei.cost_distributed_flag||'' = 'Y' ) )
4450 FOR UPDATE OF ei.expenditure_item_id, eia.expenditure_item_id NOWAIT;
4451
4452
4453 CURSOR GetPrjExpItem
4454 IS
4455 SELECT
4456 ei.expenditure_item_id
4457 , eia.expenditure_item_id adj_expenditure_item_id
4458 FROM
4459 pa_expenditures_all e
4460 , pa_expenditure_items_all ei
4461 , pa_expenditure_items_all eia
4462 WHERE
4463 ei.expenditure_item_id = eia.adjusted_expenditure_item_id (+)
4464 AND ei.expenditure_id = e.expenditure_id
4465 AND ei.expenditure_item_id = X_expenditure_item_id
4466 AND ( 1 = 2
4467 OR X_adj_action = 'EXP COMMENT CHANGE'
4468 OR (X_adj_action = 'CHANGE WORK TYPE ATTRIBUTE' /** proj currency changes **/
4469 AND nvl( ei.net_zero_adjustment_flag, 'N' ) <> 'Y'
4470 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4471 AND ei.work_type_id <> p_dest_work_type_id
4472 AND e.expenditure_status_code = 'APPROVED'
4473 )
4474 OR
4475 ( X_adj_action = 'PROJECT OR TASK CHANGE'
4476 AND nvl( ei.net_zero_adjustment_flag, 'N' ) <> 'Y'
4477 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4478 AND ei.task_id <> X_dest_task_id
4479 AND e.expenditure_status_code = 'APPROVED'
4480 AND ei.source_expenditure_item_id IS NULL
4481 )
4482 OR
4483 ( X_adj_action = 'BILLING HOLD'
4484 AND ei.bill_hold_flag in ( 'N', 'O' ) )
4485 OR
4486 ( X_adj_action = 'BILLING HOLD RELEASE'
4487 AND ei.bill_hold_flag in ( 'Y', 'O' ) )
4488 OR
4489 ( X_adj_action = 'BILLABLE RECLASS'
4490 AND ei.billable_flag <> 'Y'
4491 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4492 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4493 )
4494 OR
4495 ( X_adj_action = 'NON-BILLABLE RECLASS'
4496 AND ei.billable_flag = 'Y'
4497 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4498 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4499 )
4500 OR
4501 ( X_adj_action = 'CAPITALIZABLE RECLASS'
4502 AND ei.billable_flag <> 'Y'
4503 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4504 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4505 AND exists (select 1
4506 From pa_tasks t
4507 Where t.task_id = ei.task_id
4508 And t.retirement_cost_flag = 'N')
4509 )
4510 OR
4511 ( X_adj_action = 'NON-CAPITALIZABLE RECLASS'
4512 AND ei.billable_flag = 'Y'
4513 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4514 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4515 AND exists (select 1
4516 From pa_tasks t
4517 Where t.task_id = ei.task_id
4518 And t.retirement_cost_flag = 'N')
4519 )
4520 OR
4521 ( X_adj_action = 'REVENUE RECALC'
4522 AND ei.revenue_distributed_flag||'' IN ( 'Y', 'P' )
4523 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4524 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4525 )
4526 OR
4527 ( X_adj_action = 'ONE-TIME BILLING HOLD'
4528 AND ei.bill_hold_flag IN ( 'N', 'Y' ) )
4529 OR
4530 ( X_adj_action = 'COST AND REV RECALC'
4531 AND ( ei.revenue_distributed_flag||'' IN ( 'Y', 'P' )
4532 OR ( ei.cost_distributed_flag||'' = 'Y'
4533 OR ei.denom_raw_cost IS NOT NULL ) )
4534 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4535 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4536 AND ei.source_expenditure_item_id IS NULL
4537 AND nvl( ei.net_zero_adjustment_flag, 'N' ) <> 'Y'
4538 )
4539 OR
4540 ( X_adj_action = 'CAPITAL COST RECALC'
4541 AND ei.cost_distributed_flag||'' = 'Y' )
4542 OR
4543 ( X_adj_action = 'RAW COST RECALC'
4544 AND ei.cost_distributed_flag||'' = 'Y' )
4545 OR
4546 ( X_adj_action = 'INDIRECT COST RECALC'
4547 AND ei.cost_distributed_flag||'' = 'Y' ) )
4548 FOR UPDATE OF ei.expenditure_item_id, eia.expenditure_item_id NOWAIT;
4549
4550
4551 CURSOR GetInvExpSummary
4552 IS
4553 SELECT
4554 ei.expenditure_item_id
4555 , eia.expenditure_item_id adj_expenditure_item_id
4556 FROM
4557 pa_cust_rev_dist_lines r
4558 , pa_expenditure_items_all ei
4559 , pa_expenditure_items_all eia
4560 WHERE
4561 ei.expenditure_item_id = eia.adjusted_expenditure_item_id (+)
4562 AND ei.adjusted_expenditure_item_id IS NULL
4563 AND r.project_id = X_project_id
4564 AND r.draft_invoice_num = X_inv_num
4565 AND r.draft_invoice_item_line_num =
4566 nvl( X_inv_line_num, r.draft_invoice_item_line_num )
4567 AND r.expenditure_item_id = ei.expenditure_item_id
4568 AND ( 1 = 2
4569 OR ( X_adj_action = 'CHANGE WORK TYPE ATTRIBUTE' /** proj currency changes **/
4570 AND nvl( ei.net_zero_adjustment_flag, 'N' ) <> 'Y'
4571 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4572 AND ei.work_type_id <> p_dest_work_type_id
4573 )
4574
4575 OR
4576 ( X_adj_action = 'PROJECT OR TASK CHANGE'
4577 AND nvl( ei.net_zero_adjustment_flag, 'N' ) <> 'Y'
4578 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4579 AND ei.task_id <> X_dest_task_id
4580 AND ei.source_expenditure_item_id IS NULL
4581 )
4582 OR
4583 ( X_adj_action = 'BILLING HOLD'
4584 AND ei.bill_hold_flag IN ( 'N', 'O' ) )
4585 OR
4586 ( X_adj_action = 'BILLING HOLD RELEASE'
4587 AND ei.bill_hold_flag IN ( 'Y', 'O' ) )
4588 OR
4589 ( X_adj_action = 'NON-BILLABLE RECLASS'
4590 AND ei.billable_flag = 'Y'
4591 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4592 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4593 )
4594 OR
4595 ( X_adj_action = 'REVENUE RECALC'
4596 AND ei.revenue_distributed_flag||'' IN ( 'Y', 'P' )
4597 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4598 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4599 )
4600 OR
4601 ( X_adj_action = 'ONE-TIME BILLING HOLD'
4602 AND ei.bill_hold_flag IN ( 'N', 'Y' ) )
4603 OR
4604 ( X_adj_action = 'COST AND REV RECALC'
4605 AND ( ei.revenue_distributed_flag||'' IN ( 'Y', 'P' )
4606 OR ( ei.cost_distributed_flag||'' = 'Y'
4607 OR ei.denom_raw_cost IS NOT NULL ) )
4608 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4609 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4610 AND ei.source_expenditure_item_id IS NULL
4611 AND nvl( ei.net_zero_adjustment_flag, 'N' ) <> 'Y'
4612 ) )
4613 FOR UPDATE OF ei.expenditure_item_id, eia.expenditure_item_id NOWAIT;
4614
4615
4616
4617 CURSOR GetInvExpSummary2
4618 IS
4619 SELECT
4620 ei.expenditure_item_id
4621 , eia.expenditure_item_id adj_expenditure_item_id
4622 FROM
4623 pa_draft_invoice_items ii
4624 , pa_expenditure_items_all ei
4625 , pa_expenditure_items_all eia
4626 WHERE
4627 /* Bug # 3457873
4628 ei.task_id IN (
4629 SELECT task_id
4630 FROM pa_tasks
4631 WHERE project_id = X_project_id )
4632 */
4633 ei.project_id = X_project_id /* Bug # 3457873 */
4634 AND ei.expenditure_item_id = eia.adjusted_expenditure_item_id (+)
4635 AND ei.adjusted_expenditure_item_id IS NULL
4636 AND ii.project_id = X_project_id
4637 AND ii.draft_invoice_num = X_inv_num
4638 AND ii.line_num = nvl( X_inv_line_num, ii.line_num )
4639 AND ii.project_id = ei.project_id
4640 AND nvl( ii.event_task_id, -1 ) = nvl( ei.event_task_id, -1 )
4641 AND ii.event_num = ei.event_num
4642 AND ( 1 = 2
4643 OR ( X_adj_action = 'CHANGE WORK TYPE ATTRIBUTE' /** proj currency changes **/
4644 AND nvl( ei.net_zero_adjustment_flag, 'N' ) <> 'Y'
4645 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4646 AND ei.work_type_id <> p_dest_work_type_id
4647 )
4648 OR
4649 ( X_adj_action = 'BILLING HOLD'
4650 AND ei.bill_hold_flag IN ( 'N', 'O' ) )
4651 OR
4652 ( X_adj_action = 'BILLING HOLD RELEASE'
4653 AND ei.bill_hold_flag IN ( 'Y', 'O' ) )
4654 OR
4655 ( X_adj_action = 'NON-BILLABLE RECLASS'
4656 AND ei.billable_flag = 'Y'
4657 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4658 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4659 )
4660 OR
4661 ( X_adj_action = 'REVENUE RECALC'
4662 AND ei.revenue_distributed_flag||'' IN ( 'Y', 'P' )
4663 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4664 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4665 )
4666 OR
4667 ( X_adj_action = 'ONE-TIME BILLING HOLD'
4668 AND ei.bill_hold_flag IN ( 'N', 'Y' ) )
4669 OR
4670 ( X_adj_action = 'COST AND REV RECALC'
4671 AND ( ei.revenue_distributed_flag||'' IN ( 'Y', 'P' )
4672 OR ( ei.cost_distributed_flag||'' = 'Y'
4673 OR ei.denom_raw_cost IS NOT NULL ) )
4674 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4675 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4676 AND ei.source_expenditure_item_id IS NULL
4677 AND nvl( ei.net_zero_adjustment_flag, 'N' ) <> 'N'
4678 )
4679 OR
4680 ( X_adj_action = 'PROJECT OR TASK CHANGE'
4681 AND nvl( ei.net_zero_adjustment_flag, 'N' ) <> 'Y'
4682 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4683 AND ei.task_id <> X_dest_task_id
4684 AND ei.source_expenditure_item_id IS NULL
4685 ) )
4686 FOR UPDATE OF ei.expenditure_item_id, eia.expenditure_item_id NOWAIT;
4687
4688
4689 CURSOR GetInvExpItem
4690 IS
4691 SELECT
4692 ei.expenditure_item_id
4693 , eia.expenditure_item_id adj_expenditure_item_id
4694 FROM
4695 pa_expenditure_items_all ei
4696 , pa_expenditure_items_all eia
4697 WHERE
4698 ei.expenditure_item_id = eia.adjusted_expenditure_item_id (+)
4699 AND ei.expenditure_item_id = X_expenditure_item_id
4700 AND ( 1 = 2
4701 OR X_adj_action = 'EXP COMMENT CHANGE'
4702 OR ( X_adj_action = 'CHANGE WORK TYPE ATTRIBUTE' /** proj currency changes **/
4703 AND nvl( ei.net_zero_adjustment_flag, 'N' ) <> 'Y'
4704 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4705 AND ei.work_type_id <> p_dest_work_type_id
4706 )
4707 OR
4708 ( X_adj_action = 'BILLING HOLD'
4709 AND ei.bill_hold_flag IN ( 'N', 'O' ) )
4710 OR
4711 ( X_adj_action = 'BILLING HOLD RELEASE'
4712 AND ei.bill_hold_flag IN ( 'Y', 'O' ) )
4713 OR
4714 ( X_adj_action = 'NON-BILLABLE RECLASS'
4715 AND ei.billable_flag = 'Y'
4716 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4717 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4718 )
4719 OR
4720 ( X_adj_action = 'REVENUE RECALC'
4721 AND ei.revenue_distributed_flag||'' IN ( 'Y', 'P' )
4722 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4723 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4724 )
4725 OR
4726 ( X_adj_action = 'ONE-TIME BILLING HOLD'
4727 AND ei.bill_hold_flag IN ( 'N', 'Y' ) )
4728 OR
4729 ( X_adj_action = 'COST AND REV RECALC'
4730 AND ( ei.revenue_distributed_flag||'' IN ( 'Y', 'P' )
4731 OR ( ei.cost_distributed_flag||'' = 'Y'
4732 OR ei.denom_raw_cost IS NOT NULL ) )
4733 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4734 AND nvl( eia.converted_flag, 'N' ) <> 'Y'
4735 AND ei.source_expenditure_item_id IS NULL
4736 AND nvl( ei.net_zero_adjustment_flag, 'N') <> 'Y'
4737 )
4738 OR
4739 ( X_adj_action = 'PROJECT OR TASK CHANGE'
4740 AND nvl( ei.net_zero_adjustment_flag, 'N' ) <> 'Y'
4741 AND nvl( ei.converted_flag, 'N' ) <> 'Y'
4742 AND ei.task_id <> X_dest_task_id
4743 AND ei.source_expenditure_item_id IS NULL
4744 ) )
4745 FOR UPDATE OF ei.expenditure_item_id, eia.expenditure_item_id NOWAIT;
4746
4747
4748 BEGIN
4749
4750 IF P_DEBUG_MODE THEN
4751 print_message('get_denom_curr_code: ' || 'Inside the pa_adjustment pkg IN PARAMS x_module ['||X_module||']X_adjust_level ['||X_adjust_level||
4752 ']X_adj_action['||X_adj_action||']p_work_type_id ['||p_work_type_id||']p_dest_work_type_id['||p_dest_work_type_id||
4753 ']expenditure_item_id['||x_expenditure_item_id||']p_projfunc_currency_code['||p_projfunc_currency_code||
4754 ']p_projfunc_cost_rate_date ['||p_projfunc_cost_rate_date||']p_projfunc_cost_rate_type['
4755 ||p_projfunc_cost_rate_type||']p_projfunc_cost_exchange_rate['||p_projfunc_cost_exchange_rate||
4756 ']p_project_raw_cost['||p_project_raw_cost||']p_project_burdened_cost['||p_project_burdened_cost||
4757 ']X_project_currency_code['||X_project_currency_code||']X_project_rate_type['||X_project_rate_type||
4758 ']X_project_rate_date['||X_project_rate_date||']X_project_exchange_rate ['||X_project_exchange_rate||
4759 ']X_acct_rate_type['||X_acct_rate_type||'] X_acct_rate_date['||X_acct_rate_date||
4760 ']X_acct_exchange_rate['||X_acct_exchange_rate||']p_cbs_elment_id ['||p_cbs_element_id||']'); -- Added p_cbs_element_id for CBS Enhancement Bug 16220146
4761 END IF;
4762
4763 i := 0;
4764
4765 -- PAXPRRPE - This is called from GUI EI Adjustment form (PAXTRAPE.fmb).
4766 -- PAXINADI - This is called from GUI Invoice Reveiew form (PAXINRVW.fmb).
4767 -- The Name PAXPRRPE/PAXINADI has not been changed because this is being
4768 -- used by the client as this is what gets passed to transaction
4769 -- control extension.
4770 -- Adjust_level will always be at the Item(I) level from V4 onwards,
4771 -- Summary ('S') adjust level has been kept for compatiblity purposes
4772 -- for X_modules PAXPRRPE and PAXINADI
4773 IF ( X_module = 'PAXPRRPE' ) THEN
4774
4775 IF ( X_adjust_level = 'S' ) THEN
4776
4777 FOR EachRec IN GetPrjExpSummary LOOP
4778 i := i + 1;
4779 ItemsIdTab(i) := EachRec.expenditure_item_id;
4780 AdjustsIdTab(i) := EachRec.adj_expenditure_item_id;
4781 END LOOP;
4782
4783 ELSIF ( X_adjust_level = 'I' ) THEN
4784
4785 -- FOR EachRec IN GetPrjExpItem LOOP
4786 -- i := i + 1;
4787 -- ItemsIdTab(i) := EachRec.expenditure_item_id;
4788 -- AdjustsIdTab(i) := EachRec.adj_expenditure_item_id;
4789 -- END LOOP;
4790
4791 i := 1;
4792 ItemsIdTab(i) := X_expenditure_item_id;
4793 DenomCurrCodeTab(i) := NULL ;
4794 ProjCurrCodeTab(i) := X_project_currency_code ;
4795 ProjFuncCurrCodeTab(i) := p_projfunc_currency_code;
4796 TpAmtTypCodeTab(i) := p_tp_amt_type_code;
4797
4798 IF ( X_adj_action in ('PROJECT OR TASK CHANGE', 'RAW COST RECALC' ,
4799 'CAPITAL COST RECALC', 'INDIRECT COST RECALC',
4800 'REVENUE RECALC', 'COST AND REV RECALC')
4801 ) THEN
4802 AdjustsIdTab(i) := NULL;
4803 ELSE
4804 BEGIN
4805 -- get the adjusted ei also
4806 SELECT expenditure_item_id adj
4807 INTO adj_ei
4808 FROM pa_expenditure_items_all
4809 WHERE adjusted_expenditure_item_id = X_expenditure_item_id;
4810
4811 AdjustsIdTab(i) := adj_ei;
4812 EXCEPTION
4813 WHEN NO_DATA_FOUND then
4814 AdjustsIdTab(i) := NULL;
4815 WHEN others then
4816 raise;
4817 END;
4818 END IF;
4819
4820
4821 END IF;
4822
4823 IF ( i = 0 ) THEN
4824 X_outcome := 'PA_PR_NO_ITEMS_PROC';
4825 X_num_processed := 0;
4826 X_num_rejected := 0;
4827 RETURN;
4828 END IF;
4829
4830 ELSIF ( X_module = 'PAXINADI' ) THEN
4831
4832 IF ( X_adjust_level = 'S' ) THEN
4833
4834 FOR EachRec IN GetInvExpSummary LOOP
4835 i := i + 1;
4836 ItemsIdTab(i) := EachRec.expenditure_item_id;
4837 AdjustsIdTab(i) := EachRec.adj_expenditure_item_id;
4838 END LOOP;
4839
4840 FOR EachRec IN GetInvExpSummary2 LOOP
4841 i := i + 1;
4842 ItemsIdTab(i) := EachRec.expenditure_item_id;
4843 AdjustsIdTab(i) := EachRec.adj_expenditure_item_id;
4844 END LOOP;
4845
4846 ELSIF ( X_adjust_level = 'I' ) THEN
4847
4848 -- FOR EachRec IN GetInvExpItem LOOP
4849 -- i := i + 1;
4850 -- ItemsIdTab(i) := EachRec.expenditure_item_id;
4851 -- AdjustsIdTab(i) := EachRec.adj_expenditure_item_id;
4852 -- END LOOP;
4853
4854 i := 1;
4855 ItemsIdTab(i) := X_expenditure_item_id;
4856
4857 /*Bug # 2249022 Added as it is missing */
4858 DenomCurrCodeTab(i) := NULL ;
4859 ProjCurrCodeTab(i) := X_project_currency_code ;
4860 ProjFuncCurrCodeTab(i) := p_projfunc_currency_code;
4861 TpAmtTypCodeTab(i) := p_tp_amt_type_code;
4862 /*Bug # 2249022 End */
4863
4864 IF ( X_adj_action in ('PROJECT OR TASK CHANGE', 'RAW COST RECALC' ,
4865 'CAPITAL COST RECALC', 'INDIRECT COST RECALC',
4866 'REVENUE RECALC', 'COST AND REV RECALC')
4867 ) THEN
4868 AdjustsIdTab(i) := NULL;
4869 ELSE
4870 BEGIN
4871 -- get the adjusted ei also
4872 SELECT expenditure_item_id adj
4873 INTO adj_ei
4874 FROM pa_expenditure_items_all
4875 WHERE adjusted_expenditure_item_id = X_expenditure_item_id;
4876
4877 AdjustsIdTab(i) := adj_ei;
4878 EXCEPTION
4879 WHEN NO_DATA_FOUND then
4880 AdjustsIdTab(i) := NULL;
4881 WHEN others then
4882 raise;
4883 END;
4884 END IF;
4885
4886
4887 END IF;
4888
4889 IF ( i = 0 ) THEN
4890 X_outcome := 'PA_PR_NO_ITEMS_PROC';
4891 X_num_processed := 0;
4892 X_num_rejected := 0;
4893 RETURN;
4894 END IF;
4895
4896 END IF;
4897
4898
4899
4900 IF ( X_adj_action = 'BILLABLE RECLASS' ) THEN
4901
4902 Reclass( ItemsIdTab
4903 , AdjustsIdTab
4904 , 'Y'
4905 , X_adj_action
4906 , X_user
4907 , X_login
4908 , X_module
4909 , i
4910 , temp_status );
4911 CheckStatus( temp_status );
4912
4913 ELSIF ( X_adj_action = 'NON-BILLABLE RECLASS' ) THEN
4914
4915 Reclass( ItemsIdTab
4916 , AdjustsIdTab
4917 , 'N'
4918 , X_adj_action
4919 , X_user
4920 , X_login
4921 , X_module
4922 , i
4923 , temp_status );
4924 CheckStatus( temp_status );
4925
4926 ELSIF ( X_adj_action = 'CAPITALIZABLE RECLASS' ) THEN
4927
4928 Reclass( ItemsIdTab
4929 , AdjustsIdTab
4930 , 'Y'
4931 , X_adj_action
4932 , X_user
4933 , X_login
4934 , X_module
4935 , i
4936 , temp_status );
4937 CheckStatus( temp_status );
4938
4939 ELSIF ( X_adj_action = 'NON-CAPITALIZABLE RECLASS' ) THEN
4940
4941 Reclass( ItemsIdTab
4942 , AdjustsIdTab
4943 , 'N'
4944 , X_adj_action
4945 , X_user
4946 , X_login
4947 , X_module
4948 , i
4949 , temp_status );
4950 CheckStatus( temp_status );
4951
4952 ELSIF ( X_adj_action = 'BILLING HOLD' ) THEN
4953
4954 Hold( ItemsIdTab
4955 , AdjustsIdTab
4956 , 'Y'
4957 , X_adj_action
4958 , X_user
4959 , X_login
4960 , X_module
4961 , i
4962 , temp_status );
4963 CheckStatus( temp_status );
4964
4965 ELSIF ( X_adj_action = 'BILLING HOLD RELEASE' ) THEN
4966
4967 Hold( ItemsIdTab
4968 , AdjustsIdTab
4969 , 'N'
4970 , X_adj_action
4971 , X_user
4972 , X_login
4973 , X_module
4974 , i
4975 , temp_status );
4976 CheckStatus( temp_status );
4977
4978 ELSIF ( X_adj_action = 'ONE-TIME BILLING HOLD' ) THEN
4979
4980 Hold( ItemsIdTab
4981 , AdjustsIdTab
4982 , 'O'
4983 , X_adj_action
4984 , X_user
4985 , X_login
4986 , X_module
4987 , i
4988 , temp_status );
4989 CheckStatus( temp_status );
4990
4991 ELSIF ( X_adj_action = 'INDIRECT COST RECALC' ) THEN
4992
4993 RecalcIndCost( ItemsIdTab
4994 , AdjustsIdTab
4995 , X_user
4996 , X_login
4997 , X_module
4998 , i
4999 , temp_status );
5000 CheckStatus( temp_status );
5001
5002 ELSIF ( X_adj_action = 'COST AND REV RECALC' ) THEN
5003
5004 RecalcCostRev( ItemsIdTab
5005 , AdjustsIdTab
5006 , X_user
5007 , X_login
5008 , X_module
5009 , i
5010 , temp_num_processed
5011 , temp_status );
5012 CheckStatus( temp_status );
5013
5014 ELSIF ( X_adj_action = 'REVENUE RECALC' ) THEN
5015
5016 RecalcRev( ItemsIdTab
5017 , AdjustsIdTab
5018 , X_user
5019 , X_login
5020 , X_module
5021 , i
5022 , temp_status );
5023 CheckStatus( temp_status );
5024
5025 ELSIF ( X_adj_action = 'CAPITAL COST RECALC' ) THEN
5026
5027 RecalcCapCost( ItemsIdTab
5028 , AdjustsIdTab
5029 , X_user
5030 , X_login
5031 , X_module
5032 , i
5033 , temp_status );
5034 CheckStatus( temp_status );
5035
5036 ELSIF ( X_adj_action = 'RAW COST RECALC' ) THEN
5037
5038 RecalcRawCost( ItemsIdTab
5039 , AdjustsIdTab
5040 , X_user
5041 , X_login
5042 , X_module
5043 , i
5044 , temp_num_processed
5045 , temp_status );
5046 CheckStatus( temp_status );
5047
5048 -- call to the new rate attribute adjustment procedures
5049 ELSIF ( X_adj_action = 'CHANGE FUNC ATTRIBUTE' ) THEN
5050
5051 ChangeFuncAttributes(ItemsIdTab
5052 , X_adjust_level
5053 , X_user
5054 , X_login
5055 , X_module
5056 , X_acct_rate_type
5057 , X_acct_rate_date
5058 , X_acct_exchange_rate
5059 , DenomCurrCodeTab
5060 , ProjCurrCodeTab
5061 , i
5062 , temp_num_processed
5063 , temp_num_rejected
5064 , temp_status
5065 , ProjFuncCurrCodeTab) ;
5066 CheckStatus( temp_status );
5067
5068 -- call to the new rate attribute adjustment procedures for project currency
5069 ELSIF ( X_adj_action = 'CHANGE PROJ ATTRIBUTE' ) THEN
5070
5071 ChangeProjAttributes(ItemsIdTab
5072 , X_adjust_level
5073 , X_user
5074 , X_login
5075 , X_module
5076 , X_project_rate_type
5077 , X_project_rate_date
5078 , X_project_exchange_rate
5079 , DenomCurrCodeTab
5080 , ProjCurrCodeTab
5081 , i
5082 , temp_num_processed
5083 , temp_num_rejected
5084 , temp_status ) ;
5085 CheckStatus( temp_status );
5086
5087 -- call to the new rate attribute adjustment procedures for project functional currency
5088 ELSIF ( X_adj_action = 'CHANGE PROJ FUNC ATTRIBUTE' ) THEN
5089
5090 ChangeProjFuncAttributes(ItemsIdTab
5091 , X_adjust_level
5092 , X_user
5093 , X_login
5094 , X_module
5095 , p_projfunc_cost_rate_type
5096 , p_projfunc_cost_rate_date
5097 , p_projfunc_cost_exchange_rate
5098 , DenomCurrCodeTab
5099 , ProjFuncCurrCodeTab
5100 , i
5101 , temp_num_processed
5102 , temp_num_rejected
5103 , temp_status ) ;
5104 CheckStatus( temp_status );
5105
5106
5107 -- Call to the 3 new Cross Charge Adjustment routines
5108
5109 ELSIF ( X_adj_action = 'REPROCESS CROSS CHARGE' ) THEN
5110
5111 ReprocessCrossCharge(ItemsIdTab
5112 , X_adjust_level
5113 , X_user
5114 , X_login
5115 , X_module
5116 , X_cc_code
5117 , X_cc_type
5118 , X_bl_dist_code
5119 , X_ic_proc_code
5120 , X_prvdr_orgnzn_id
5121 , X_recvr_orgnzn_id
5122 , i
5123 , temp_num_processed
5124 , temp_status );
5125
5126 CheckStatus( temp_status );
5127
5128 ELSIF ( X_adj_action = 'MARK NO CC PROCESS' ) THEN
5129
5130 MarkNoCCProcess (ItemsIdTab
5131 , X_adjust_level
5132 , X_user
5133 , X_login
5134 , X_module
5135 , X_bl_dist_code
5136 , X_ic_proc_code
5137 , i
5138 , temp_num_processed
5139 , temp_status ) ;
5140
5141 CheckStatus( temp_status );
5142
5143 ELSIF ( X_adj_action = 'CHANGE TP ATTRIBUTE' ) THEN
5144
5145 ChangeTPAttributes(ItemsIdTab
5146 , X_adjust_level
5147 , X_user
5148 , X_login
5149 , X_module
5150 , X_acct_rate_type
5151 , X_acct_rate_date
5152 , X_acct_exchange_rate
5153 , X_bl_dist_code
5154 , X_ic_proc_code
5155 , DenomCurrCodeTab
5156 , i
5157 , temp_num_processed
5158 , temp_num_rejected
5159 , temp_status
5160 , p_PROJECT_TP_COST_RATE_DATE
5161 , p_PROJECT_TP_COST_RATE_TYPE
5162 , p_PROJECT_TP_COST_EXCHG_RATE ) ;
5163
5164 CheckStatus( temp_status );
5165
5166
5167 ELSIF ( X_adj_action = 'PROJECT OR TASK CHANGE' ) THEN
5168
5169 /* Bug#3598333 */
5170 FOR j in 1..i LOOP
5171 If pa_debug.Acquire_user_lock( 'PA_EI_ADJUST_'||to_char( ItemsIdTab(i)))<>0 then
5172 FND_MESSAGE.SET_NAME('FND','FORM_RECORD_CHANGED');
5173 APP_EXCEPTION.RAISE_EXCEPTION; /* AcquireLock */
5174 end if;
5175 END LOOP;
5176 /* Bug#3598333 */
5177
5178 Transfer( ItemsIdTab
5179 , X_dest_prj_id
5180 , X_dest_task_id
5181 , X_project_currency_code
5182 , X_project_rate_type
5183 , X_project_rate_date
5184 , X_project_exchange_rate
5185 , X_user
5186 , X_login
5187 , X_module
5188 , X_adjust_level
5189 , i
5190 , temp_num_processed
5191 , temp_num_rejected
5192 , temp_outcome
5193 , temp_msg_application
5194 , temp_msg_type
5195 , temp_msg_token1
5196 , temp_msg_token2
5197 , temp_msg_token3
5198 , temp_msg_count
5199 , p_projfunc_currency_code
5200 , p_projfunc_cost_rate_type
5201 , p_projfunc_cost_rate_date
5202 , p_projfunc_cost_exchange_rate
5203 , p_assignment_id
5204 , p_work_type_id
5205 , p_cbs_element_id -- Added for CBS Enhancement Bug 16220146
5206 );
5207
5208 /* Bug#3598333 */
5209 /*Changes for 7371988 Starts here -- We will release the lock, hence issuing a commit in PAXEIADJ.pld now, instead of here for messages seeded in Client Extension*/
5210 IF ( temp_msg_type not in ('E','W')) then
5211 FOR j in 1..i LOOP
5212 If pa_debug.release_user_lock( 'PA_EI_ADJUST_'||to_char( ItemsIdTab(i)))<>0 then
5213 FND_MESSAGE.SET_NAME('PA','PA_CAP_CANNOT_RELS_LOCK');
5214 APP_EXCEPTION.RAISE_EXCEPTION; /* AcquireLock */
5215 end if;
5216 /*Changes for 7371988 end here -- We will release the lock, hence issuing a commit in PAXEIADJ.pld now, instead of here for messages seeded in Client Extension*/
5217 END LOOP;
5218 /* Bug#3598333 */
5219 END IF;
5220
5221 IF ( temp_outcome IS NOT NULL AND ( temp_msg_type = 'E' ) ) THEN /* Added msg_type check for Bug 4906816 */
5222 /* Bug#3598333 */
5223 FOR j in 1..i LOOP
5224 RelLockStatus := pa_debug.release_user_lock( 'PA_EI_ADJUST_'||to_char( ItemsIdTab(i)));
5225 END LOOP;
5226 /* Bug#3598333 */
5227 RAISE INVALID_ITEM;
5228 END IF;
5229
5230 ELSIF ( X_adj_action = 'EXP COMMENT CHANGE' ) THEN
5231
5232 CommentChange( ItemsIdTab(i)
5233 , X_expenditure_comment
5234 , X_user
5235 , X_login
5236 , temp_status );
5237 CheckStatus( temp_status );
5238
5239 /** start proj currency changes **/
5240 ELSIF ( X_adj_action = 'CHANGE WORK TYPE ATTRIBUTE' ) THEN
5241
5242 IF P_DEBUG_MODE THEN
5243 print_message('get_denom_curr_code: ' || 'calling work_type_adjustment api from adjust pkg');
5244 END IF;
5245
5246
5247 work_type_adjustment
5248 ( ItemsIdTab => ItemsIdTab
5249 --, AdjustsIdTab => AdjustsIdTab
5250 , p_billable => NULL
5251 , p_work_type_id =>p_dest_work_type_id
5252 , p_adj_activity =>X_adjust_level
5253 , p_user =>X_user
5254 , p_login =>X_login
5255 , p_module =>X_module
5256 , p_rows => i
5257 , p_TpAmtTypCodeTab => TpAmtTypCodeTab
5258 , p_dest_tp_amt_type_code => p_dest_tp_amt_type_code
5259 , x_status => temp_status);
5260 IF P_DEBUG_MODE THEN
5261 print_message('get_denom_curr_code: ' || 'end of work_type_adjustment api from adjust pkg x_status ='||temp_status);
5262 END IF;
5263
5264 CheckStatus( temp_status );
5265 IF P_DEBUG_MODE THEN
5266 print_message('get_denom_curr_code: ' || 'after checkstatus api');
5267 END IF;
5268
5269 /** end proj currency changes **/
5270 END IF;
5271
5272 X_num_processed := temp_num_processed;
5273 X_num_rejected := temp_num_rejected;
5274 /*X_outcome := NULL;
5275 Added for Bug 4906816 */
5276 X_outcome := temp_outcome;
5277 X_msg_application := temp_msg_application;
5278 X_msg_type := temp_msg_type;
5279 X_msg_token1 := temp_msg_token1;
5280 X_msg_token2 := temp_msg_token2;
5281 X_msg_token3 := temp_msg_token3;
5282 X_msg_count := temp_msg_count;
5283
5284 EXCEPTION
5285 WHEN INVALID_ITEM THEN
5286 IF P_DEBUG_MODE THEN
5287 print_message('get_denom_curr_code: ' || 'INVALID_ITEM in adjust api X_outcome ='||temp_outcome);
5288 END IF;
5289 X_outcome := temp_outcome;
5290 X_msg_application := temp_msg_application;
5291 X_msg_type := temp_msg_type;
5292 X_msg_token1 := temp_msg_token1;
5293 X_msg_token2 := temp_msg_token2;
5294 X_msg_token3 := temp_msg_token3;
5295 X_msg_count := temp_msg_count;
5296 WHEN RESOURCE_BUSY THEN
5297 X_outcome := 'PA_ALL_COULD_NOT_LOCK';
5298 IF P_DEBUG_MODE THEN
5299 print_message('get_denom_curr_code: ' || 'RESOURCE_BUSY in adjust api X_outcome ='||X_outcome);
5300 END IF;
5301 WHEN OTHERS THEN
5302 X_outcome := SQLCODE;
5303 IF P_DEBUG_MODE THEN
5304 print_message('get_denom_curr_code: ' || 'OTHERS in adjust api X_outcome ='||X_outcome);
5305 END IF;
5306 RAISE;
5307
5308 END Adjust;
5309
5310 -- ========================================================================
5311 -- PROCEDURE MassAdjust
5312 -- ========================================================================
5313
5314 -- This package was created to improve the performance allowing multiple
5315 -- items to be submitted for adjustments together
5316
5317 /*
5318 * IC related changes:
5319 * New parameter added
5320 */
5321
5322 PROCEDURE MassAdjust(
5323 X_adj_action IN VARCHAR2
5324 , X_module IN VARCHAR2
5325 , X_user IN NUMBER
5326 , X_login IN NUMBER
5327 , X_project_id IN NUMBER
5328 , X_dest_prj_id IN NUMBER
5329 , X_dest_task_id IN NUMBER
5330 , X_project_currency_code IN VARCHAR2
5331 , X_project_rate_type IN VARCHAR2
5332 , X_project_rate_date IN DATE
5333 , X_project_exchange_rate IN NUMBER
5334 , X_acct_rate_type IN VARCHAR2
5335 , X_acct_rate_date IN DATE
5336 , X_acct_exchange_rate IN NUMBER
5337 , X_task_id IN NUMBER
5338 , X_inc_by_person_id IN NUMBER
5339 , X_inc_by_org_id IN NUMBER
5340 , X_ei_date_low IN DATE
5341 , X_ei_date_high IN DATE
5342 , X_ex_end_date_low IN DATE
5343 , X_ex_end_date_high IN DATE
5344 , X_system_linkage IN VARCHAR2
5345 , X_expenditure_type IN VARCHAR2
5346 , X_expenditure_catg IN VARCHAR2
5347 , X_expenditure_group IN VARCHAR2
5348 , X_vendor_id IN NUMBER
5349 , X_job_id IN NUMBER
5350 , X_nl_resource_org_id IN NUMBER
5351 , X_nl_resource IN VARCHAR2
5352 , X_transaction_source IN VARCHAR2
5353 , X_cost_distributed_flag IN VARCHAR2
5354 , X_revenue_distributed_flag IN VARCHAR2
5355 , X_grouped_cip_flag IN VARCHAR2
5356 , X_bill_status IN VARCHAR2
5357 , X_hold_flag IN VARCHAR2
5358 , X_billable_flag IN VARCHAR2
5359 , X_capitalizable_flag IN VARCHAR2
5360 , X_net_zero_adjust_flag IN VARCHAR2
5361 , X_inv_num IN NUMBER
5362 , X_inv_line_num IN NUMBER
5363 , X_cc_code_to_be_determined IN VARCHAR2
5364 , X_cc_code_not_crosscharged IN VARCHAR2
5365 , X_cc_code_intra_ou IN VARCHAR2
5366 , X_cc_code_inter_ou IN VARCHAR2
5367 , X_cc_code_intercompany IN VARCHAR2
5368 , X_cc_type_no_processing IN VARCHAR2
5369 , X_cc_type_b_and_l IN VARCHAR2
5370 , X_cc_type_ic_billing IN VARCHAR2
5371 , X_cc_prvdr_organization_id IN NUMBER
5372 , X_cc_prvdr_ou IN NUMBER
5373 , X_cc_recvr_organization_id IN NUMBER
5374 , X_cc_recvr_ou IN NUMBER
5375 , X_cc_bl_distributed_code IN VARCHAR2
5376 , X_cc_ic_processed_code IN VARCHAR2
5377 , X_expenditure_item_id IN NUMBER
5378 , X_outcome OUT NOCOPY VARCHAR2
5379 , X_num_processed OUT NOCOPY NUMBER
5380 , X_num_rejected OUT NOCOPY NUMBER
5381 /* added for proj currency and additional EI attributes **/
5382 , p_assignment_id IN NUMBER
5383 , p_work_type_id IN NUMBER
5384 , p_projfunc_currency_code IN varchar2
5385 , p_projfunc_cost_rate_date IN date
5386 , p_projfunc_cost_rate_type IN varchar2
5387 , p_projfunc_cost_exchange_rate IN number
5388 , p_project_raw_cost IN number
5389 , p_project_burdened_cost IN number
5390 , p_project_tp_currency_code IN varchar2
5391 , p_project_tp_cost_rate_date IN date
5392 , p_project_tp_cost_rate_type IN varchar2
5393 , p_project_tp_cost_exchg_rate IN number
5394 , p_project_transfer_price IN number
5395 , p_dest_work_type_id IN NUMBER
5396 , p_dest_tp_amt_type_code IN varchar2
5397 , p_dest_wt_start_date IN date
5398 , p_dest_wt_end_date IN date
5399 -- Additional attributes added for FP 'L'
5400 , p_grouped_rwip_flag IN varchar2
5401 , p_capital_event_number IN number
5402 , p_start_gl_date IN date
5403 , p_end_gl_date IN date
5404 , p_start_pa_date IN date
5405 , p_end_pa_date IN date
5406 , p_recvr_start_gl_date IN date
5407 , p_recvr_end_gl_date IN date
5408 , p_recvr_start_pa_date IN date
5409 , p_recvr_end_pa_date IN date
5410 /* R12 Changes - Start */
5411 , p_invoice_id IN NUMBER
5412 , p_invoice_line_number IN NUMBER
5413 , p_include_related_tax_lines IN VARCHAR2
5414 , p_receipt_number IN VARCHAR2
5415 , p_check_id IN NUMBER /* 4914048 */
5416 , p_org_id IN NUMBER
5417 , p_dest_award_id IN NUMBER
5418 , p_rev_exp_items_req_adjust IN VARCHAR2
5419 , p_award_id IN NUMBER /* 5194785 */
5420 , p_expensed_flag IN VARCHAR2
5421 , p_wip_resource_id IN NUMBER
5422 , p_inventory_item_id IN NUMBER
5423 /* R12 Changes - End */
5424 , p_cbs_element_id IN NUMBER -- Added for CBS Enhancement Bug 16220146
5425 , p_dest_cbs_element_id IN NUMBER -- Added for bug 16446988
5426 ) IS
5427 ItemsIdTab pa_utils.IdTabTyp;
5428 AdjustsIdTab pa_utils.IdTabTyp;
5429 ItemsIdCapTab pa_utils.IdTabTyp;
5430 AdjustsIdCapTab pa_utils.IdTabTyp;
5431 ItemsIdNCapTab pa_utils.IdTabTyp;
5432 AdjustsIdNCapTab pa_utils.IdTabTyp;
5433 DenomCurrCodeTab pa_utils.Char15TabTyp;
5434 ProjCurrCodeTab pa_utils.Char15TabTyp;
5435 ProjFuncCurrCodeTab pa_utils.Char15TabTyp;
5436 ProjTpCurrCodeTab pa_utils.Char15TabTyp;
5437
5438 TpAmtTypCodeTab pa_utils.Char30TabTyp;
5439
5440 dummy NUMBER;
5441 l_project_start_date DATE;
5442 l_project_completion_date DATE;
5443 l_task_start_date DATE;
5444 l_task_completion_date DATE;
5445 temp_outcome VARCHAR2(30) DEFAULT NULL;
5446 temp_status NUMBER DEFAULT NULL;
5447 temp_num_processed NUMBER DEFAULT 0;
5448 temp_num_rejected NUMBER DEFAULT 0;
5449 num_processed NUMBER DEFAULT 0;
5450 num_rejected NUMBER DEFAULT 0;
5451 i BINARY_INTEGER := 0;
5452 j BINARY_INTEGER := 0;
5453 k BINARY_INTEGER := 0;
5454 l BINARY_INTEGER := 0;
5455 adj_ei number;
5456
5457 /* R12 Changes Start - Changed size to 32000 */
5458 l_query_string VARCHAR2(32000);
5459 /* R12 Changes End */
5460 v_reserve_rec VARCHAR2(2000);
5461 select_clause VARCHAR2(2000);
5462 reprocess_cc_select VARCHAR2(2000);
5463 v_sql_stm1 VARCHAR2(2000);
5464 v_sql_stm2 VARCHAR2(2000);
5465 v_sql_stm3 VARCHAR2(2000);
5466 v_sql_stm4 VARCHAR2(2000);
5467 v_transfer VARCHAR2(2000);
5468 v_bill_hld VARCHAR2(2000);
5469 v_bill_hold_rel VARCHAR2(2000);
5470 v_bill_reclass VARCHAR2(2000);
5471 v_non_bill_reclass VARCHAR2(2000);
5472 v_capital_reclass VARCHAR2(2000);
5473 v_non_capital_reclass VARCHAR2(2000);
5474 v_revenue_recalc VARCHAR2(2000);
5475 v_bill_hold_once VARCHAR2(2000);
5476 v_cst_rev_recalc VARCHAR2(2000);
5477 v_cst_recalc VARCHAR2(2000);
5478 v_ind_cst_recalc VARCHAR2(2000);
5479 v_rev_dist_flag VARCHAR2(2000);
5480 v_grpd_cip_flag VARCHAR2(2000);
5481 v_grpd_rwip_flag VARCHAR2(2000);
5482 /* R12 Changes Start - Changed size to 32000 */
5483 where_clause VARCHAR2(32000);
5484 /* R12 Changes End */
5485 from_clause VARCHAR2(2000);
5486 v_condition1 VARCHAR2(2000);
5487 v_condition2 VARCHAR2(2000);
5488 v_condition3 VARCHAR2(2000);
5489 v_condition4 VARCHAR2(2000);
5490 /*
5491 * IC related changes
5492 * new variable added to append the query criteria
5493 */
5494 v_condition5 VARCHAR2(2000);
5495 v_system_linkage VARCHAR2(30);
5496 v_invoice_id NUMBER;
5497 v_allow_adjustments VARCHAR2(30):='N';
5498
5499 v_cursor_adj_id INTEGER ;
5500 v_open_cursor INTEGER ;
5501
5502 v_expenditure_item_id NUMBER(15);
5503 v_adj_expenditure_item_id NUMBER(15);
5504 v_project_type_class_code VARCHAR2(30);
5505 v_denom_currency_code VARCHAR2(15);
5506 v_project_currency_code VARCHAR2(15);
5507 v_denom_tp_currency_code VARCHAR2(15);
5508 v_func_attr VARCHAR2(2000);
5509 v_proj_attr VARCHAR2(2000);
5510 v_projfunc_attr VARCHAR2(2000);
5511 l_dummy1 NUMBER ;
5512 l_dummy2 NUMBER ;
5513 l_dummy3 NUMBER ;
5514 l_rate_date_code VARCHAR2(1) ;
5515 v_reprocess_cc VARCHAR2(2000);
5516 v_no_cc_process VARCHAR2(2000);
5517 v_change_tp_attr VARCHAR2(2000);
5518 v_cc_code VARCHAR2(1) ;
5519 v_exp_organization_id NUMBER ;
5520 v_exp_org_id NUMBER ;
5521 v_exp_item_date DATE;
5522 v_task_id NUMBER ;
5523 v_exp_type VARCHAR2(30);
5524 v_incurred_by_person_id NUMBER ;
5525 v_trx_source VARCHAR2(30);
5526 v_nlr_organization_id NUMBER ;
5527
5528 /** proj currency and EI attrib related chagnes **/
5529
5530 l_projfunc_currency_code varchar2(15);
5531 l_projfunc_cost_rate_date date;
5532 l_projfunc_cost_rate_type varchar2(30);
5533 l_projfunc_cost_exchange_rate number;
5534 l_project_tp_currency_code varchar2(15);
5535 l_assignment_id number;
5536 l_work_type_id number;
5537 l_condition6 varchar2(2000);
5538 l_work_type_change varchar2(2000);
5539 l_tp_amt_type_code varchar2(30);
5540 l_transaction_source varchar2(30); /* Bug 3951679 : Added */
5541 l_capital_event_id number;
5542 /* R12 Changes - Start */
5543 l_project_id number;
5544 l_old_org_id number := -99;
5545 l_billable_flag varchar2(1);
5546 l_document_header_id number;
5547 l_document_line_number number;
5548 l_document_distribution_id number;
5549 l_document_type varchar2(30);
5550 l_vendor_id number;
5551 l_gl_accounted varchar2(1);
5552 l_document_payment_id PA_EXPENDITURE_ITEMS_ALL.DOCUMENT_PAYMENT_ID%TYPE; /* Bug 5006835 */
5553 l_encoded_error_message varchar2(2000);
5554 l_error_message_name varchar2(30);
5555 l_application_short_name varchar2(30);
5556 l_net_zero_adjustment_flag PA_EXPENDITURE_ITEMS_ALL.NET_ZERO_ADJUSTMENT_FLAG%TYPE;
5557 l_converted_flag PA_EXPENDITURE_ITEMS_ALL.CONVERTED_FLAG%TYPE;
5558 l_expenditure_status_code PA_EXPENDITURES_ALL.EXPENDITURE_STATUS_CODE%TYPE;
5559 l_allow_adjustments_flag PA_TRANSACTION_SOURCES.ALLOW_ADJUSTMENTS_FLAG%TYPE;
5560 l_burden_sum_dest_run_id PA_EXPENDITURE_ITEMS_ALL.BURDEN_SUM_DEST_RUN_ID%TYPE;
5561 l_document_distribution_type PA_EXPENDITURE_ITEMS_ALL.DOCUMENT_DISTRIBUTION_TYPE%TYPE;
5562 l_source_expenditure_item_id PA_EXPENDITURE_ITEMS_ALL.SOURCE_EXPENDITURE_ITEM_ID%TYPE;
5563 l_acct_currency_code PA_EXPENDITURE_ITEMS_ALL.ACCT_CURRENCY_CODE%TYPE;
5564 l_adjusted_expenditure_item_id PA_EXPENDITURE_ITEMS_ALL.ADJUSTED_EXPENDITURE_ITEM_ID%TYPE;
5565 l_orig_transaction_reference PA_EXPENDITURE_ITEMS_ALL.ORIG_TRANSACTION_REFERENCE%TYPE;
5566 l_project_status_code PA_PROJECTS_ALL.PROJECT_STATUS_CODE%TYPE;
5567 l_adjust_allowed BOOLEAN := TRUE;
5568 l_award_id GMS_AWARDS_ALL.AWARD_ID%TYPE; /* Bug 5436420 */
5569 l_project_id_cache PA_PROJECTS_ALL.PROJECT_ID%TYPE := -1; /* Bug 5441891 */
5570 l_transaction_source_cache PA_TRANSACTION_SOURCES.TRANSACTION_SOURCE%TYPE := 'NULL'; /* Bug 5441891 */
5571 l_commit_count NUMBER := 0; /* Bug 5501593 */
5572 /* R12 Changes - End */
5573
5574 /*rkuttiya added for 12.2 Payroll Integration Expenditure Adjustments */
5575 l_prev_costing_method VARCHAR2(30);
5576 l_prev_rate_source_code VARCHAR2(30);
5577 l_prev_accrual_flag VARCHAR2(30);
5578 l_curr_costing_mthd VARCHAR2(30);
5579 l_curr_rate_source_code VARCHAR2(30);
5580 l_curr_accrual_flag VARCHAR2(30);
5581 /* rkuttiya end */
5582 l_cbs_element_id NUMBER; -- Added for CBS Enhancement Bug 16220146
5583
5584 BEGIN
5585 /* R12 Changes - Start */
5586
5587 IF X_module = 'PATXMAS' THEN
5588 G_REQUEST_ID := FND_GLOBAL.CONC_REQUEST_ID;
5589 G_PROGRAM_ID := FND_GLOBAL.CONC_PROGRAM_ID;
5590 G_PROG_APPL_ID := FND_GLOBAL.PROG_APPL_ID;
5591 END IF;
5592
5593 IF p_org_id IS NOT NULL THEN
5594 pa_multi_currency.init ;
5595 END IF;
5596
5597
5598 /* *** Opens a cursor for processing ********************************************************* */
5599
5600 v_cursor_adj_id := dbms_sql.open_cursor ;
5601
5602 /* ******************************************************************************************* */
5603
5604
5605 /* ** The following section constructs character strings that are used to create a query ***** */
5606
5607 select_clause := 'SELECT'
5608 || ' ei.expenditure_item_id'
5609 || ',ei.org_id'
5610 || ',ei.project_id'
5611 || ',ei.net_zero_adjustment_flag'
5612 || ',ei.converted_flag'
5613 || ',e.expenditure_status_code'
5614 || ',ei.burden_sum_dest_run_id'
5615 || ',ei.document_header_id'
5616 || ',ei.transaction_source'
5617 || ',ei.document_type'
5618 || ',ei.document_distribution_type'
5619 || ',ei.document_payment_id'
5620 || ',ei.source_expenditure_item_id'
5621 || ',ei.system_linkage_function'
5622 || ',ei.acct_currency_code'
5623 || ',ei.denom_currency_code'
5624 || ',ei.denom_tp_currency_code'
5625 || ',ei.projfunc_currency_code'
5626 || ',ei.cc_cross_charge_code'
5627 || ',ei.adjusted_expenditure_item_id'
5628 || ',ei.orig_transaction_reference'
5629 || ',ei.expenditure_item_date'
5630 || ',ei.billable_flag'
5631 || ',ei.task_id'
5632 || ',ei.expenditure_type'
5633 || ',ei.vendor_id'
5634 || ',nvl(ei.override_to_organization_id, e.incurred_by_organization_id)'
5635 || ',e.incurred_by_person_id'
5636 || ',ei.document_line_number'
5637 || ',ei.document_distribution_id'
5638 || ',ei.project_currency_code'
5639 || ',ei.tp_amt_type_code'
5640 || ',ei.organization_id'
5641 --added by rkuttiya for 12.2 Projects Payroll
5642 || ',ei.costing_method'
5643 || ',ei.rate_source_code'
5644 || ',ei.payroll_accrual_flag'
5645 || ',ei.cbs_element_id'; -- Added for CBS Enhancement Bug 16220146
5646
5647 from_clause := ' FROM'
5648 || ' pa_expenditure_items_all ei'
5649 || ',pa_expenditures_all e';
5650
5651 where_clause := ' WHERE ei.expenditure_id = e.expenditure_id';
5652
5653 if p_org_id is not null then
5654 where_clause := where_clause || ' AND ei.org_id = :org_id';
5655 end if;
5656
5657 if x_project_id is not null then
5658 where_clause := where_clause || ' AND ei.project_id = :project_id';
5659 if x_task_id is not null then
5660 where_clause := where_clause || ' AND ei.task_id = :task_id';
5661 end if;
5662 if p_award_id is not null then
5663 where_clause := where_clause
5664 || ' AND ei.expenditure_item_id in ('
5665 || ' SELECT adl.expenditure_item_id'
5666 || ' FROM gms_award_distributions adl'
5667 || ' WHERE adl.adl_line_num = 1'
5668 || ' AND adl.document_type = ''EXP'''
5669 || ' AND adl.adl_status = ''A'''
5670 || ' AND adl.project_id = :project_id'
5671 || ' AND adl.award_id = :award_id )';
5672 end if;
5673 end if;
5674
5675 if x_expenditure_item_id is not null then
5676 where_clause := where_clause || ' AND ei.expenditure_item_id = :expenditure_item_id';
5677 end if;
5678
5679 if x_inc_by_org_id is not null then
5680 where_clause := where_clause || ' AND (e.incurred_by_organization_id = :inc_by_org_id' ||
5681 ' OR (e.incurred_by_organization_id is NULL' ||
5682 ' AND ei.override_to_organization_id = :inc_by_org_id ))';
5683 end if ;
5684
5685 if x_system_linkage is not null then
5686 where_clause := where_clause || ' AND ei.system_linkage_function = :system_linkage';
5687 end if;
5688
5689 if x_expenditure_type is not null then
5690 where_clause := where_clause || ' AND ei.expenditure_type = :expenditure_type';
5691 end if;
5692
5693 if x_ei_date_low is not null then
5694 where_clause := where_clause || ' AND ei.expenditure_item_date >= trunc(:ei_date_low)';
5695 end if;
5696
5697 if x_ei_date_high is not null then
5698 where_clause := where_clause || ' AND ei.expenditure_item_date <= trunc(:ei_date_high)';
5699 end if;
5700
5701 if x_expenditure_catg is not null then
5702 where_clause := where_clause || ' AND 1 = (SELECT 1'
5703 || ' FROM pa_expenditure_types et'
5704 || ' WHERE et.expenditure_type = ei.expenditure_type'
5705 || ' AND et.expenditure_category = :expenditure_catg)';
5706 end if;
5707
5708 if x_ex_end_date_low is not null then
5709 where_clause := where_clause || ' AND e.expenditure_ending_date >= trunc(pa_utils.getweekending(:ex_end_date_low) - 6)';
5710 end if;
5711
5712 if x_ex_end_date_high is not null then
5713 where_clause := where_clause || ' AND e.expenditure_ending_date <= trunc(pa_utils.getweekending(:ex_end_date_high))';
5714 end if;
5715
5716 if x_expenditure_group is not null then
5717 where_clause := where_clause || ' AND e.expenditure_group = :expenditure_group';
5718 end if;
5719
5720 if x_transaction_source is not NULL then
5721 where_clause := where_clause || ' AND ei.transaction_source = :transaction_source';
5722 end if;
5723
5724 if p_work_type_id is not null then
5725 where_clause := where_clause || ' AND ei.work_type_id = :work_type_id';
5726 end If;
5727
5728 if x_cost_distributed_flag is not null then
5729 where_clause := where_clause || ' AND ei.cost_distributed_flag = :cost_distributed_flag';
5730 end if;
5731
5732 if x_billable_flag is not null then
5733 where_clause := where_clause || ' AND 1 = (SELECT 1'
5734 || ' FROM pa_project_types_all pt'
5735 || ' , pa_projects_all p'
5736 || ' WHERE p.project_type = pt.project_type'
5737 || ' AND p.org_id = pt.org_id'
5738 || ' AND p.project_id = ei.project_id'
5739 || ' AND pt.project_type_class_code <> ''CAPITAL'')'
5740 || ' AND ei.billable_flag = :billable_flag';
5741 end if;
5742
5743 if x_hold_flag is not null then
5744 if x_hold_flag = 'B' then
5745 where_clause := where_clause || ' AND ei.bill_hold_flag in ( ''Y'', ''O'')';
5746 else
5747 where_clause := where_clause || ' and ei.bill_hold_flag = :hold_flag';
5748 end if;
5749 end if;
5750
5751 if x_bill_status is not null then
5752 if x_bill_status = 'Y' then
5753 where_clause := where_clause || ' AND (ei.event_num is not null'
5754 || ' OR EXISTS (SELECT 1'
5755 || ' FROM pa_cust_rev_dist_lines_all r'
5756 || ' WHERE r.expenditure_item_id = ei.expenditure_item_id'
5757 || ' AND r.draft_invoice_num is not null'
5758 || ' HAVING sum(nvl(r.bill_trans_bill_amount, 0)) <> 0'
5759 || ' GROUP BY r.expenditure_item_id))';
5760 elsif x_bill_status = 'N' then
5761 where_clause := where_clause || ' AND (ei.event_num is null' --Bug 12709649
5762 || ' AND NOT EXISTS (SELECT 1'
5763 || ' FROM pa_cust_rev_dist_lines_all r'
5764 || ' WHERE r.expenditure_item_id = ei.expenditure_item_id'
5765 || ' AND r.draft_invoice_num is not null'
5766 || ' HAVING sum(nvl(r.bill_trans_bill_amount, 0)) <> 0'
5767 || ' GROUP BY r.expenditure_item_id))';
5768 end if;
5769 end if;
5770
5771 if x_revenue_distributed_flag is not null then
5772 where_clause := where_clause || ' AND 1 = (SELECT 1'
5773 || ' FROM pa_project_types_all pt'
5774 || ' , pa_projects_all p'
5775 || ' WHERE p.project_type = pt.project_type'
5776 || ' AND p.org_id = pt.org_id'
5777 || ' AND p.project_id = ei.project_id'
5778 || ' AND pt.project_type_class_code <> ''CAPITAL'')'
5779 || ' AND ei.revenue_distributed_flag = :revenue_distributed_flag';
5780 end if;
5781
5782 if X_inc_by_person_id is not null then
5783 where_clause := where_clause || ' AND e.incurred_by_person_id = :incurred_by_person_id';
5784 end if ;
5785
5786 if X_job_id is not null then
5787 where_clause := where_clause || ' AND ei.job_id = :job_id';
5788 end if;
5789
5790 if p_assignment_id is not null then
5791 where_clause := where_clause ||' AND ei.assignment_id = :assignment_id';
5792 end if;
5793
5794 if X_nl_resource_org_id is not null then
5795 where_clause := where_clause || ' AND ei.organization_id = :nl_resource_org_id';
5796 end if;
5797
5798 if p_wip_resource_id is not null then
5799 where_clause := where_clause || ' AND ei.wip_resource_id = :wip_resource_id';
5800 end if;
5801
5802 if p_inventory_item_id is not null then
5803 where_clause := where_clause || ' AND ei.inventory_item_id = :inventory_item_id';
5804 end if;
5805
5806 if x_vendor_id is not null then
5807 where_clause := where_clause || ' and e.vendor_id = :vendor_id';
5808 end if;
5809
5810 IF p_invoice_id IS NOT NULL THEN
5811 IF x_transaction_source IS NULL THEN
5812 where_clause := where_clause ||
5813 ' and ei.transaction_source in ' ||
5814 ' (''AP INVOICE'',''INTERPROJECT_AP_INVOICES'',''AP VARIANCE'',''AP NRTAX'',''AP DISCOUNTS''' ||
5815 ' ,''AP EXPENSE'',''CSE_IPV_ADJUSTMENT'',''CSE_IPV_ADJUSTMENT_DEPR'',''AP ERV'') ';
5816 END IF;
5817 where_clause := where_clause || ' AND ei.document_header_id = :invoice_id ';
5818
5819 IF p_include_related_tax_lines = 'Y' THEN
5820 where_clause := where_clause ||
5821 ' and ei.document_distribution_id in' ||
5822 ' ( select apdist.invoice_distribution_id' ||
5823 ' from ap_invoice_distributions_all apdist' ||
5824 ' where apdist.invoice_id = :invoice_id' ||
5825 ' and apdist.invoice_line_number = :invoice_line_number' ||
5826 ' union all' ||
5827 ' select apdist1.invoice_distribution_id' ||
5828 ' from ap_invoice_distributions_all apdist1' ||
5829 ' where apdist1.charge_Applicable_to_dist_id in' ||
5830 ' ( select apdist2.invoice_distribution_id' ||
5831 ' from ap_invoice_distributions_all apdist2' ||
5832 ' where apdist2.invoice_id = :invoice_id' ||
5833 ' and apdist2.invoice_line_number = :invoice_line_number)' ||
5834 ' and apdist1.line_type_lookup_code in (''NONREC_TAX'', ''TIPV'', ''TERV'', ''TRV'')' ||
5835 ' union all'||
5836 ' select apdist.invoice_distribution_id' || /*Self Assessed Tax Changes*/
5837 ' from ap_self_assessed_tax_dist_all apdist' ||
5838 ' where apdist.invoice_id = :invoice_id' ||
5839 ' and apdist.invoice_line_number = :invoice_line_number' ||
5840 ' union all' ||
5841 ' select apdist1.invoice_distribution_id' ||
5842 ' from ap_self_assessed_tax_dist_all apdist1' ||
5843 ' where apdist1.charge_Applicable_to_dist_id in' ||
5844 ' ( select apdist2.invoice_distribution_id' ||
5845 ' from ap_self_assessed_tax_dist_all apdist2' ||
5846 ' where apdist2.invoice_id = :invoice_id' ||
5847 ' and apdist2.invoice_line_number = :invoice_line_number)' ||
5848 ' and apdist1.line_type_lookup_code in (''NONREC_TAX''))'; /* Bug 5403294 */
5849 ELSIF p_invoice_line_number IS NOT NULL THEN
5850 where_clause := where_clause || ' and ei.document_line_number = :invoice_line_number';
5851 END IF;
5852 END IF;
5853
5854 IF p_receipt_number IS NOT NULL THEN
5855 IF x_transaction_source IS NULL THEN
5856 where_clause := where_clause ||
5857 ' and ei.transaction_source in ' ||
5858 ' (''PO RECEIPT'',''PO RECEIPT NRTAX'',''PO RECEIPT NRTAX PRICE ADJ'',''PO RECEIPT PRICE ADJ''' ||
5859 ' ,''CSE_PO_RECEIPT'',''CSE_PO_RECEIPT_DEPR'') ';
5860 END IF;
5861 where_clause := where_clause ||
5862 ' and ei.document_distribution_id in' ||
5863 ' (select rcvtxn.transaction_id' ||
5864 ' from rcv_shipment_headers rcvhead' ||
5865 ' , rcv_transactions rcvtxn' ||
5866 ' where rcvhead.shipment_header_id =' ||
5867 ' rcvtxn.shipment_header_id' ||
5868 ' and rcvhead.receipt_num = :receipt_number)';
5869 END IF;
5870
5871 IF p_check_id IS NOT NULL THEN
5872 where_clause := where_clause ||
5873 ' and ei.document_payment_id in' ||
5874 ' (select invoice_payment_id' ||
5875 ' from ap_invoice_payments_all' ||
5876 ' where check_id = :check_id) ';
5877 END IF;
5878
5879 IF p_rev_exp_items_req_adjust = 'Y' THEN
5880 where_clause := where_clause
5881 || ' AND ei.transaction_source IN (''AP VARIANCE'',''AP INVOICE'',''AP NRTAX'',''AP DISCOUNTS'',''AP ERV'''
5882 || ' ,''INTERCOMPANY_AP_INVOICES'',''INTERPROJECT_AP_INVOICES'',''AP EXPENSE'''
5883 || ' ,''PO RECEIPT'',''PO RECEIPT NRTAX'''
5884 || ' ,''PO RECEIPT NRTAX PRICE ADJ'''
5885 || ' ,''PO RECEIPT PRICE ADJ'')'
5886 || ' AND EXISTS (select NULL'
5887 || ' from pa_cost_distribution_lines cdl1'
5888 || ' where cdl1.expenditure_item_id = ei.expenditure_item_id'
5889 || ' and cdl1.line_num = 1'
5890 || ' and NVL(cdl1.reversed_flag,''N'') <> ''Y'')'
5891 || ' AND ei.net_zero_adjustment_flag = ''N'''
5892 || ' AND ei.transferred_from_exp_item_id IS NULL'
5893 || ' AND pa_adjustments.is_orphaned_src_sys_reversal(ei.document_distribution_id,ei.transaction_source) = ''Y'''; /* 4901129 */
5894 END IF;
5895
5896 if X_cc_code_to_be_determined <> 'N'
5897 or X_cc_code_not_crosscharged <> 'XX'
5898 or X_cc_code_intra_ou <> 'XX'
5899 or X_cc_code_inter_ou <> 'XX'
5900 or X_cc_code_intercompany <> 'XX' then
5901 where_clause := where_clause ||
5902 ' AND ei.cc_cross_charge_type IN (:cc_code_not_crosscharged, :cc_code_intra_ou,' ||
5903 ' :cc_code_inter_ou, :cc_code_intercompany)';
5904 if X_cc_code_to_be_determined = 'Y' then
5905 where_clause := where_clause || ' OR ei.cc_cross_charge_type IS NULL';
5906 end if;
5907 end if;
5908
5909 if X_cc_type_no_processing <> 'Z'
5910 or X_cc_type_b_and_l <> 'Z'
5911 or X_cc_type_ic_billing <> 'Z' then
5912 where_clause := where_clause
5913 || ' AND ei.cc_cross_charge_code IN'
5914 || ' (:cc_type_no_processing, :cc_type_b_and_l, :cc_type_ic_billing)';
5915 end if;
5916
5917 if X_cc_bl_distributed_code is not null then
5918 where_clause := where_clause || ' AND ei.cc_bl_distributed_code = :cc_bl_distributed_code';
5919 end if;
5920
5921 if X_cc_ic_processed_code is not null then
5922 where_clause := where_clause || ' AND ei.cc_ic_processed_code = :cc_ic_processed_code';
5923 end if;
5924
5925 if X_cc_prvdr_organization_id is not null then
5926 where_clause := where_clause || ' AND ei.cc_prvdr_organization_id = :cc_prvdr_organization_id';
5927 end if;
5928
5929 if X_cc_prvdr_ou is not null then
5930 where_clause := where_clause || ' AND ei.org_id = :cc_prvdr_ou';
5931 end if;
5932
5933 if p_start_gl_date is not null
5934 and p_end_gl_date is not null then
5935 where_clause := where_clause
5936 || ' AND pa_expenditures_utils.Get_Latest_GL_Date(ei.expenditure_item_id)'
5937 || ' BETWEEN trunc(:start_gl_date) AND trunc(:end_gl_date)';
5938 elsif p_start_gl_date is not null then
5939 where_clause := where_clause
5940 || ' AND pa_expenditures_utils.Get_Latest_GL_Date(ei.expenditure_item_id) >= trunc(:start_gl_date)';
5941 elsif p_end_gl_date is not null then
5942 where_clause := where_clause
5943 || ' AND pa_expenditures_utils.Get_Latest_GL_Date(ei.expenditure_item_id) >= trunc(:end_gl_date)';
5944 end if ;
5945
5946 if p_start_pa_date is not null
5947 and p_end_pa_date is not null then
5948 where_clause := where_clause
5949 || ' AND pa_expenditures_utils.Get_Latest_PA_Date(ei.expenditure_item_id)'
5950 || ' BETWEEN trunc(:start_pa_date) AND trunc(:end_pa_date)';
5951 elsif p_start_pa_date is not null then
5952 where_clause := where_clause
5953 || ' AND pa_expenditures_utils.Get_Latest_PA_Date(ei.expenditure_item_id) >= trunc(:start_pa_date)';
5954 elsif p_end_pa_date is not null then
5955 where_clause := where_clause
5956 || ' AND pa_expenditures_utils.Get_Latest_PA_Date(ei.expenditure_item_id) >= trunc(:end_pa_date)';
5957 end if ;
5958
5959 if X_cc_recvr_organization_id is not null then
5960 where_clause := where_clause || ' AND ei.cc_recvr_organization_id = :cc_recvr_organization_id';
5961 end if;
5962
5963 if X_cc_recvr_ou is not null then
5964 where_clause := where_clause || ' AND ei.recvr_org_id = :cc_recvr_ou';
5965 end if;
5966
5967 if p_recvr_start_gl_date is not null
5968 and p_recvr_end_gl_date is not null then
5969 where_clause := where_clause
5970 || ' AND pa_expenditures_utils.Get_Latest_GL_Date(ei.expenditure_item_id)'
5971 || ' BETWEEN trunc(:recvr_start_gl_date) AND trunc(:recvr_end_gl_date)';
5972 elsif p_recvr_start_gl_date is not null then
5973 where_clause := where_clause
5974 || ' AND pa_expenditures_utils.Get_Latest_GL_Date(ei.expenditure_item_id) >= trunc(:recvr_start_gl_date)';
5975 elsif p_recvr_end_gl_date is not null then
5976 where_clause := where_clause
5977 || ' AND pa_expenditures_utils.Get_Latest_GL_Date(ei.expenditure_item_id) >= trunc(:recvr_end_gl_date)';
5978 end if ;
5979
5980 if p_recvr_start_pa_date is not null
5981 and p_recvr_end_pa_date is not null then
5982 where_clause := where_clause
5983 || ' AND pa_expenditures_utils.Get_Latest_PA_Date(ei.expenditure_item_id)'
5984 || ' BETWEEN trunc(:recvr_start_pa_date) AND trunc(:recvr_end_pa_date)';
5985 elsif p_recvr_start_pa_date is not null then
5986 where_clause := where_clause
5987 || ' AND pa_expenditures_utils.Get_Latest_PA_Date(ei.expenditure_item_id) >= trunc(:recvr_start_pa_date)';
5988 elsif p_recvr_end_pa_date is not null then
5989 where_clause := where_clause
5990 || ' AND pa_expenditures_utils.Get_Latest_PA_Date(ei.expenditure_item_id) >= trunc(:recvr_end_pa_date)';
5991 end if ;
5992
5993 if x_capitalizable_flag is not null then
5994 where_clause := where_clause || ' AND 1 = (SELECT 1'
5995 || ' FROM pa_project_types_all pt'
5996 || ' , pa_projects_all p'
5997 || ' WHERE p.project_type = pt.project_type'
5998 || ' AND p.org_id = pt.org_id'
5999 || ' AND p.project_id = ei.project_id'
6000 || ' AND pt.project_type_class_code = ''CAPITAL'')'
6001 || ' AND ei.billable_flag = :capitalizable_flag';
6002 end if;
6003
6004 if x_grouped_cip_flag is not null then
6005 where_clause := where_clause || ' AND 1 = (SELECT 1'
6006 || ' FROM pa_project_types_all pt'
6007 || ' , pa_projects_all p'
6008 || ' WHERE p.project_type = pt.project_type'
6009 || ' AND p.org_id = pt.org_id'
6010 || ' AND p.project_id = ei.project_id'
6011 || ' AND pt.project_type_class_code = ''CAPITAL'')'
6012 || ' AND 1 = (SELECT 1'
6013 || ' FROM pa_tasks t'
6014 || ' WHERE t.task_id = ei.task_id'
6015 || ' AND t.retirement_cost_flag = ''N'')'
6016 || ' AND ei.revenue_distributed_flag = :grouped_cip_flag';
6017 end if;
6018
6019 if p_grouped_rwip_flag is not null then
6020 where_clause := where_clause || ' AND 1 = (SELECT 1'
6021 || ' FROM pa_project_types_all pt'
6022 || ' , pa_projects_all p'
6023 || ' WHERE p.project_type = pt.project_type'
6024 || ' AND p.org_id = pt.org_id'
6025 || ' AND p.project_id = ei.project_id'
6026 || ' AND pt.project_type_class_code = ''CAPITAL'')'
6027 || ' AND 1 = (SELECT 1'
6028 || ' FROM pa_tasks t'
6029 || ' WHERE t.task_id = ei.task_id'
6030 || ' AND t.retirement_cost_flag = ''Y'')'
6031 || ' AND ei.revenue_distributed_flag = :grouped_rwip_flag';
6032 end if;
6033
6034 if p_expensed_flag = 'Y' then /* Bug 5393328 */
6035 where_clause := where_clause || ' AND 1 = (SELECT 1'
6036 || ' FROM pa_project_types_all pt'
6037 || ' , pa_projects_all p'
6038 || ' WHERE p.project_type = pt.project_type'
6039 || ' AND p.org_id = pt.org_id'
6040 || ' AND p.project_id = ei.project_id'
6041 || ' AND pt.project_type_class_code = ''CAPITAL'')'
6042 || ' AND 1 = (SELECT 1'
6043 || ' FROM pa_tasks t'
6044 || ' WHERE t.task_id = ei.task_id'
6045 || ' AND t.billable_flag = ''N'''
6046 || ' AND t.retirement_cost_flag = ''N'')';
6047 end if;
6048
6049 if p_capital_event_number = -1 then
6050 where_clause := where_clause || ' AND ei.capital_event_id = -1';
6051 elsif p_capital_event_number is not null then
6052 where_clause := where_clause || ' AND EXISTS ('
6053 || ' SELECT null'
6054 || ' FROM pa_capital_events'
6055 || ' WHERE capital_event_number = :capital_event_number'
6056 || ' AND project_id = :project_id';
6057 end if;
6058
6059 if x_net_zero_adjust_flag = 'Y' then
6060 where_clause := where_clause || ' AND NVL(ei.net_zero_adjustment_flag, ''N'') <> ''Y''';
6061 end if;
6062
6063 /* Start: Added for bug 16446988 */
6064 if p_cbs_element_id is not null then
6065 where_clause := where_clause || ' AND ei.cbs_element_id = :cbs_element_id';
6066 end if;
6067 /* End: Added for bug 16446988 */
6068
6069 v_reserve_rec := ' FOR UPDATE OF ei.expenditure_item_id NOWAIT';
6070
6071
6072 dbms_sql.parse( v_cursor_adj_id
6073 , select_clause || from_clause || where_clause -- || v_reserve_rec - Commenting for bug 5501593
6074 , dbms_sql.v7);
6075
6076
6077 if p_org_id is not null then
6078 dbms_sql.bind_variable(v_cursor_adj_id, ':org_id', p_org_id);
6079 end if;
6080
6081 if x_project_id is not null then
6082 dbms_sql.bind_variable(v_cursor_adj_id, ':project_id', x_project_id);
6083 if x_task_id is not null then
6084 dbms_sql.bind_variable(v_cursor_adj_id, ':task_id', x_task_id);
6085 end if;
6086 if p_award_id is not null then
6087 dbms_sql.bind_variable(v_cursor_adj_id,':award_id', p_award_id);
6088 end if;
6089 end if;
6090
6091 if x_expenditure_item_id is not null then
6092 dbms_sql.bind_variable(v_cursor_adj_id, ':expenditure_item_id', x_expenditure_item_id);
6093 end if;
6094
6095 if x_inc_by_org_id is not null then
6096 dbms_sql.bind_variable(v_cursor_adj_id, ':inc_by_org_id', x_inc_by_org_id);
6097 end if ;
6098
6099 if x_system_linkage is not null then
6100 dbms_sql.bind_variable(v_cursor_adj_id, ':system_linkage', x_system_linkage);
6101 end if;
6102
6103 if x_expenditure_type is not null then
6104 dbms_sql.bind_variable(v_cursor_adj_id, ':expenditure_type', x_expenditure_type);
6105 end if;
6106
6107 if x_ei_date_low is not null then
6108 dbms_sql.bind_variable(v_cursor_adj_id, ':ei_date_low', x_ei_date_low);
6109 end if;
6110
6111 if x_ei_date_high is not null then
6112 dbms_sql.bind_variable(v_cursor_adj_id, ':ei_date_high', x_ei_date_high);
6113 end if;
6114
6115 if x_expenditure_catg is not null then
6116 dbms_sql.bind_variable(v_cursor_adj_id, ':expenditure_catg', x_expenditure_catg);
6117 end if;
6118
6119 if x_ex_end_date_low is not null then
6120 dbms_sql.bind_variable(v_cursor_adj_id, ':ex_end_date_low', x_ex_end_date_low);
6121 end if;
6122
6123 if x_ex_end_date_high is not null then
6124 dbms_sql.bind_variable(v_cursor_adj_id, ':ex_end_date_high', x_ex_end_date_high);
6125 end if;
6126
6127 if x_expenditure_group is not null then
6128 dbms_sql.bind_variable(v_cursor_adj_id, ':expenditure_group', x_expenditure_group);
6129 end if;
6130
6131 if x_transaction_source is not NULL then
6132 dbms_sql.bind_variable(v_cursor_adj_id, ':transaction_source', x_transaction_source);
6133 end if;
6134
6135 if p_work_type_id is not null then
6136 dbms_sql.bind_variable(v_cursor_adj_id, ':work_type_id', p_work_type_id);
6137 end If;
6138
6139 if x_cost_distributed_flag is not null then
6140 dbms_sql.bind_variable(v_cursor_adj_id, ':cost_distributed_flag', x_cost_distributed_flag);
6141 end if;
6142
6143 if x_billable_flag is not null then
6144 dbms_sql.bind_variable(v_cursor_adj_id, ':billable_flag', x_billable_flag);
6145 end if;
6146
6147 if x_hold_flag is not null then
6148 if x_hold_flag <> 'B' then
6149 dbms_sql.bind_variable(v_cursor_adj_id, ':hold_flag', x_hold_flag);
6150 end if;
6151 end if;
6152
6153 if x_revenue_distributed_flag is not null then
6154 dbms_sql.bind_variable(v_cursor_adj_id, ':revenue_distributed_flag', x_revenue_distributed_flag);
6155 end if;
6156
6157 if X_inc_by_person_id is not null then
6158 dbms_sql.bind_variable(v_cursor_adj_id, ':incurred_by_person_id', X_inc_by_person_id);
6159 end if ;
6160
6161 if X_job_id is not null then
6162 dbms_sql.bind_variable(v_cursor_adj_id, ':job_id', X_job_id);
6163 end if;
6164
6165 if p_assignment_id is not null then
6166 dbms_sql.bind_variable(v_cursor_adj_id, ':assignment_id', p_assignment_id);
6167 end if;
6168
6169 if X_nl_resource_org_id is not null then
6170 dbms_sql.bind_variable(v_cursor_adj_id, ':nl_resource_org_id', X_nl_resource_org_id);
6171 end if;
6172
6173 if p_wip_resource_id is not null then
6174 dbms_sql.bind_variable(v_cursor_adj_id, ':wip_resource_id', p_wip_resource_id);
6175 end if;
6176
6177 if p_inventory_item_id is not null then
6178 dbms_sql.bind_variable(v_cursor_adj_id, ':inventory_item_id', p_inventory_item_id);
6179 end if;
6180
6181 if x_vendor_id is not null then
6182 dbms_sql.bind_variable(v_cursor_adj_id, ':vendor_id', x_vendor_id);
6183 end if;
6184
6185 IF p_invoice_id IS NOT NULL THEN
6186 dbms_sql.bind_variable(v_cursor_adj_id, ':invoice_id', p_invoice_id);
6187 IF p_invoice_line_number IS NOT NULL THEN
6188 dbms_sql.bind_variable(v_cursor_adj_id, ':invoice_line_number', p_invoice_line_number);
6189 END IF;
6190 END IF;
6191
6192 IF p_receipt_number IS NOT NULL THEN
6193 dbms_sql.bind_variable(v_cursor_adj_id, ':receipt_number', p_receipt_number);
6194 END IF;
6195
6196 IF p_check_id IS NOT NULL THEN
6197 dbms_sql.bind_variable(v_cursor_adj_id, ':check_id', p_check_id);
6198 END IF;
6199
6200 if X_cc_code_to_be_determined <> 'N'
6201 or X_cc_code_not_crosscharged <> 'XX'
6202 or X_cc_code_intra_ou <> 'XX'
6203 or X_cc_code_inter_ou <> 'XX'
6204 or X_cc_code_intercompany <> 'XX' then
6205 dbms_sql.bind_variable(v_cursor_adj_id, ':cc_code_not_crosscharged', X_cc_code_not_crosscharged);
6206 dbms_sql.bind_variable(v_cursor_adj_id, ':cc_code_intra_ou', X_cc_code_intra_ou);
6207 dbms_sql.bind_variable(v_cursor_adj_id, ':cc_code_inter_ou', X_cc_code_inter_ou);
6208 dbms_sql.bind_variable(v_cursor_adj_id, ':cc_code_intercompany', X_cc_code_intercompany);
6209 end if;
6210
6211 if X_cc_type_no_processing <> 'Z'
6212 or X_cc_type_b_and_l <> 'Z'
6213 or X_cc_type_ic_billing <> 'Z' then
6214 dbms_sql.bind_variable(v_cursor_adj_id, ':cc_type_no_processing', X_cc_type_no_processing);
6215 dbms_sql.bind_variable(v_cursor_adj_id, ':cc_type_b_and_l', X_cc_type_b_and_l);
6216 dbms_sql.bind_variable(v_cursor_adj_id, ':cc_type_ic_billing', X_cc_type_ic_billing);
6217 end if;
6218
6219 if X_cc_bl_distributed_code is not null then
6220 dbms_sql.bind_variable(v_cursor_adj_id, ':cc_bl_distributed_code', X_cc_bl_distributed_code);
6221 end if;
6222
6223 if X_cc_ic_processed_code is not null then
6224 dbms_sql.bind_variable(v_cursor_adj_id, ':cc_ic_processed_code', X_cc_ic_processed_code);
6225 end if;
6226
6227 if X_cc_prvdr_organization_id is not null then
6228 dbms_sql.bind_variable(v_cursor_adj_id, ':cc_prvdr_organization_id', X_cc_prvdr_organization_id);
6229 end if;
6230
6231 if X_cc_prvdr_ou is not null then
6232 dbms_sql.bind_variable(v_cursor_adj_id, ':cc_prvdr_ou', X_cc_prvdr_ou);
6233 end if;
6234
6235 if p_start_gl_date is not null then
6236 dbms_sql.bind_variable(v_cursor_adj_id, ':start_gl_date', p_start_gl_date);
6237 end if;
6238
6239 if p_end_gl_date is not null then
6240 dbms_sql.bind_variable(v_cursor_adj_id, ':end_gl_date', p_end_gl_date);
6241 end if ;
6242
6243 if p_start_pa_date is not null then
6244 dbms_sql.bind_variable(v_cursor_adj_id, ':start_pa_date', p_start_pa_date);
6245 end if;
6246
6247 if p_end_pa_date is not null then
6248 dbms_sql.bind_variable(v_cursor_adj_id, ':end_pa_date', p_end_pa_date);
6249 end if ;
6250
6251 if X_cc_recvr_organization_id is not null then
6252 dbms_sql.bind_variable(v_cursor_adj_id, ':cc_recvr_organization_id', X_cc_recvr_organization_id);
6253 end if;
6254
6255 if X_cc_recvr_ou is not null then
6256 dbms_sql.bind_variable(v_cursor_adj_id, ':cc_recvr_ou', X_cc_recvr_ou);
6257 end if;
6258
6259 if p_recvr_start_gl_date is not null then
6260 dbms_sql.bind_variable(v_cursor_adj_id, ':recvr_start_gl_date', p_recvr_start_gl_date);
6261 end if;
6262
6263 if p_recvr_end_gl_date is not null then
6264 dbms_sql.bind_variable(v_cursor_adj_id, ':recvr_end_gl_date', p_recvr_end_gl_date);
6265 end if ;
6266
6267 if p_recvr_start_pa_date is not null then
6268 dbms_sql.bind_variable(v_cursor_adj_id, ':recvr_start_pa_date', p_recvr_start_pa_date);
6269 end if;
6270
6271 if p_recvr_end_pa_date is not null then
6272 dbms_sql.bind_variable(v_cursor_adj_id, ':recvr_end_pa_date', p_recvr_end_pa_date);
6273 end if ;
6274
6275 if x_capitalizable_flag is not null then
6276 dbms_sql.bind_variable(v_cursor_adj_id, ':capitalizable_flag', x_capitalizable_flag);
6277 end if;
6278
6279 if x_grouped_cip_flag is not null then
6280 dbms_sql.bind_variable(v_cursor_adj_id, ':grouped_cip_flag', x_grouped_cip_flag);
6281 end if;
6282
6283 if p_grouped_rwip_flag is not null then
6284 dbms_sql.bind_variable(v_cursor_adj_id, ':grouped_rwip_flag', p_grouped_rwip_flag);
6285 end if;
6286
6287 if p_capital_event_number is not null then
6288 if p_capital_event_number <> -1 then
6289 dbms_sql.bind_variable(v_cursor_adj_id, ':capital_event_number', p_capital_event_number);
6290 end if;
6291 end if;
6292
6293 /* Start: Added for bug 16446988 */
6294 if p_cbs_element_id is not null then
6295 dbms_sql.bind_variable(v_cursor_adj_id, ':cbs_element_id', p_cbs_element_id);
6296 end if;
6297 /* End: Added for bug 16446988 */
6298
6299 dbms_sql.define_column(v_cursor_adj_id, 1, v_expenditure_item_id);
6300 dbms_sql.define_column(v_cursor_adj_id, 2, v_exp_org_id);
6301 dbms_sql.define_column(v_cursor_adj_id, 3, l_project_id);
6302 dbms_sql.define_column(v_cursor_adj_id, 4, l_net_zero_adjustment_flag, 1);
6303 dbms_sql.define_column(v_cursor_adj_id, 5, l_converted_flag, 1);
6304 dbms_sql.define_column(v_cursor_adj_id, 6, l_expenditure_status_code, 30);
6305 dbms_sql.define_column(v_cursor_adj_id, 7, l_burden_sum_dest_run_id);
6306 dbms_sql.define_column(v_cursor_adj_id, 8, l_document_header_id);
6307 dbms_sql.define_column(v_cursor_adj_id, 9, l_transaction_source, 30);
6308 dbms_sql.define_column(v_cursor_adj_id, 10, l_document_type, 30);
6309 dbms_sql.define_column(v_cursor_adj_id, 11, l_document_distribution_type, 30);
6310 dbms_sql.define_column(v_cursor_adj_id, 12, l_document_payment_id);
6311 dbms_sql.define_column(v_cursor_adj_id, 13, l_source_expenditure_item_id);
6312 dbms_sql.define_column(v_cursor_adj_id, 14, v_system_linkage, 30);
6313 dbms_sql.define_column(v_cursor_adj_id, 15, l_acct_currency_code, 15);
6314 dbms_sql.define_column(v_cursor_adj_id, 16, v_denom_currency_code, 15);
6315 dbms_sql.define_column(v_cursor_adj_id, 17, v_denom_tp_currency_code, 15);
6316 dbms_sql.define_column(v_cursor_adj_id, 18, l_projfunc_currency_code, 15);
6317 dbms_sql.define_column(v_cursor_adj_id, 19, v_cc_code, 1);
6318 dbms_sql.define_column(v_cursor_adj_id, 20, l_adjusted_expenditure_item_id);
6319 dbms_sql.define_column(v_cursor_adj_id, 21, l_orig_transaction_reference, 30);
6320 dbms_sql.define_column(v_cursor_adj_id, 22, v_exp_item_date);
6321 dbms_sql.define_column(v_cursor_adj_id, 23, l_billable_flag, 1);
6322 dbms_sql.define_column(v_cursor_adj_id, 24, v_task_id);
6323 dbms_sql.define_column(v_cursor_adj_id, 25, v_exp_type, 30);
6324 dbms_sql.define_column(v_cursor_adj_id, 26, l_vendor_id);
6325 dbms_sql.define_column(v_cursor_adj_id, 27, v_exp_organization_id);
6326 dbms_sql.define_column(v_cursor_adj_id, 28, v_incurred_by_person_id);
6327 dbms_sql.define_column(v_cursor_adj_id, 29, l_document_line_number);
6328 dbms_sql.define_column(v_cursor_adj_id, 30, l_document_distribution_id);
6329 dbms_sql.define_column(v_cursor_adj_id, 31, v_project_currency_code, 15);
6330 dbms_sql.define_column(v_cursor_adj_id, 32, l_tp_amt_type_code, 30);
6331 dbms_sql.define_column(v_cursor_adj_id, 33, v_nlr_organization_id);
6332 --rkuttiya added for 12.2 Projects Payroll Integration
6333 dbms_sql.define_column(v_cursor_adj_id,34,l_prev_costing_method, 30);
6334 dbms_sql.define_column(v_cursor_adj_id,35,l_prev_rate_source_code, 30);
6335 dbms_sql.define_column(v_cursor_adj_id,36,l_prev_accrual_flag, 30);
6336 dbms_sql.define_column(v_cursor_adj_id,37,l_cbs_element_id); -- Added for CBS Enhancement Bug 16220146
6337
6338
6339
6340
6341
6342
6343 IF ( X_module IN ( 'PAXPRRPE','PAXPREPR','PAXBAUPD','PATXMAS') ) THEN
6344 v_open_cursor := dbms_sql.execute(v_cursor_adj_id);
6345 LOOP
6346 /* Fetch the rows into the buffer ************************* */
6347 IF P_DEBUG_MODE THEN
6348 print_message('get_denom_curr_code: ' || 'Fetch the rows into the buffer');
6349 END IF;
6350
6351 If dbms_sql.fetch_rows(v_cursor_adj_id) = 0 then
6352 --Exit the loop once all the records are fetched
6353
6354 exit ;
6355 end if ;
6356
6357 /*** Retrieve the rows from the buffer into PLSQL variables ****/
6358 dbms_sql.column_value(v_cursor_adj_id, 1, v_expenditure_item_id);
6359 dbms_sql.column_value(v_cursor_adj_id, 2, v_exp_org_id);
6360 dbms_sql.column_value(v_cursor_adj_id, 3, l_project_id);
6361 dbms_sql.column_value(v_cursor_adj_id, 4, l_net_zero_adjustment_flag);
6362 dbms_sql.column_value(v_cursor_adj_id, 5, l_converted_flag);
6363 dbms_sql.column_value(v_cursor_adj_id, 6, l_expenditure_status_code);
6364 dbms_sql.column_value(v_cursor_adj_id, 7, l_burden_sum_dest_run_id);
6365 dbms_sql.column_value(v_cursor_adj_id, 8, l_document_header_id);
6366 dbms_sql.column_value(v_cursor_adj_id, 9, l_transaction_source);
6367 dbms_sql.column_value(v_cursor_adj_id, 10, l_document_type);
6368 dbms_sql.column_value(v_cursor_adj_id, 11, l_document_distribution_type);
6369 dbms_sql.column_value(v_cursor_adj_id, 12, l_document_payment_id);
6370 dbms_sql.column_value(v_cursor_adj_id, 13, l_source_expenditure_item_id);
6371 dbms_sql.column_value(v_cursor_adj_id, 14, v_system_linkage);
6372 dbms_sql.column_value(v_cursor_adj_id, 15, l_acct_currency_code);
6373 dbms_sql.column_value(v_cursor_adj_id, 16, v_denom_currency_code);
6374 dbms_sql.column_value(v_cursor_adj_id, 17, v_denom_tp_currency_code);
6375 dbms_sql.column_value(v_cursor_adj_id, 18, l_projfunc_currency_code);
6376 dbms_sql.column_value(v_cursor_adj_id, 19, v_cc_code);
6377 dbms_sql.column_value(v_cursor_adj_id, 20, l_adjusted_expenditure_item_id);
6378 dbms_sql.column_value(v_cursor_adj_id, 21, l_orig_transaction_reference);
6379 dbms_sql.column_value(v_cursor_adj_id, 22, v_exp_item_date);
6380 dbms_sql.column_value(v_cursor_adj_id, 23, l_billable_flag);
6381 dbms_sql.column_value(v_cursor_adj_id, 24, v_task_id);
6382 dbms_sql.column_value(v_cursor_adj_id, 25, v_exp_type);
6383 dbms_sql.column_value(v_cursor_adj_id, 26, l_vendor_id);
6384 dbms_sql.column_value(v_cursor_adj_id, 27, v_exp_organization_id);
6385 dbms_sql.column_value(v_cursor_adj_id, 28, v_incurred_by_person_id);
6386 dbms_sql.column_value(v_cursor_adj_id, 29, l_document_line_number);
6387 dbms_sql.column_value(v_cursor_adj_id, 30, l_document_distribution_id);
6388 dbms_sql.column_value(v_cursor_adj_id, 31, v_project_currency_code);
6389 dbms_sql.column_value(v_cursor_adj_id, 32, l_tp_amt_type_code);
6390 dbms_sql.column_value(v_cursor_adj_id, 33, v_nlr_organization_id);
6391 --rkuttiya added for 12.2 Projects Payroll Integration
6392 dbms_sql.column_value(v_cursor_adj_id,34,l_prev_costing_method);
6393 dbms_sql.column_value(v_cursor_adj_id,35,l_prev_rate_source_code);
6394 dbms_sql.column_value(v_cursor_adj_id,36,l_prev_accrual_flag);
6395 dbms_sql.column_value(v_cursor_adj_id,37,l_cbs_element_id); -- Added for CBS Enhancement Bug 16220146
6396
6397 /* Bug 5441891 - Start */
6398 IF l_project_id <> l_project_id_cache THEN
6399 SELECT pt.project_type_class_code
6400 , p.project_status_code
6401 INTO v_project_type_class_code
6402 , l_project_status_code
6403 FROM pa_project_types_all pt
6404 , pa_projects_all p
6405 WHERE p.project_type = pt.project_type
6406 AND p.org_id = pt.org_id
6407 AND p.project_id = l_project_id;
6408 l_project_id_cache := l_project_id;
6409 END IF;
6410
6411 IF l_transaction_source IS NULL THEN
6412 l_allow_adjustments_flag := NULL;
6413 l_gl_accounted := NULL;
6414 ELSE
6415 IF l_transaction_source <> l_transaction_source_cache THEN
6416 SELECT tr.allow_adjustments_flag
6417 , tr.gl_accounted_flag
6418 INTO l_allow_adjustments_flag
6419 , l_gl_accounted
6420 FROM pa_transaction_sources tr
6421 WHERE tr.transaction_source = l_transaction_source;
6422 l_transaction_source_cache := l_transaction_source;
6423 END IF;
6424 END IF;
6425 /* Bug 5441891 - End */
6426
6427 /* R12 Changes Start - Set org context if not already set */
6428 IF p_org_id IS NULL THEN
6429 IF v_exp_org_id <> l_old_org_id THEN
6430 PA_MOAC_UTILS.SET_POLICY_CONTEXT('S',v_exp_org_id);
6431 l_old_org_id := v_exp_org_id;
6432 END IF;
6433 pa_multi_currency.init;
6434 END IF;
6435 /* R12 Changes End */
6436
6437 v_allow_adjustments := 'N';
6438
6439 /* Bug 5501593 - Checking if the expenditure can be locked for update or not */
6440 DECLARE
6441 l_dummy VARCHAR2(1);
6442 row_locked EXCEPTION;
6443 PRAGMA EXCEPTION_INIT(row_locked, -54);
6444 BEGIN
6445 SELECT NULL
6446 INTO l_dummy
6447 FROM pa_expenditure_items_all
6448 WHERE expenditure_item_id = v_expenditure_item_id
6449 FOR UPDATE OF expenditure_item_id NOWAIT;
6450 EXCEPTION
6451 WHEN row_locked THEN
6452 v_allow_adjustments := 'PA_ADJ_EXP_ITEMS_LOCKED';
6453 END;
6454 /* Bug 5501593 - End */
6455
6456 if v_allow_adjustments = 'N'
6457 and x_adj_action in ( 'BILLABLE RECLASS'
6458 , 'NON-BILLABLE RECLASS'
6459 , 'BILLING HOLD'
6460 , 'ONE-TIME BILLING HOLD'
6461 , 'BILLING HOLD RELEASE'
6462 /*, 'COST AND REV RECALC' for bug 8282579 */
6463 , 'REVENUE RECALC')
6464 and v_project_type_class_code = 'CAPITAL' then
6465 v_allow_adjustments := 'PA_TR_APE_ITEM_IN_CAP_PROJ';
6466 end if;
6467
6468 if v_allow_adjustments = 'N'
6469 and x_adj_action in ( 'BILLABLE RECLASS'
6470 , 'NON-BILLABLE RECLASS'
6471 , 'BILLING HOLD'
6472 , 'ONE-TIME BILLING HOLD'
6473 , 'BILLING HOLD RELEASE'
6474 /*, 'COST AND REV RECALC' for bug 8282579 */
6475 , 'REVENUE RECALC')
6476 and v_project_type_class_code = 'INDIRECT'
6477 and not pa_gms_api.is_sponsored_project(l_project_id) then
6478 v_allow_adjustments := 'PA_TR_APE_ITEM_IN_IND_PROJ';
6479 end if;
6480
6481 if v_allow_adjustments = 'N'
6482 and x_adj_action in ( 'CAPITALIZABLE RECLASS'
6483 , 'NON-CAPITALIZABLE RECLASS')
6484 and v_project_type_class_code <> 'CAPITAL' then
6485 v_allow_adjustments := 'PA_TR_APE_ITEM_NOT_IN_CAP_PROJ';
6486 end if;
6487
6488 if v_allow_adjustments = 'N'
6489 and x_adj_action in ( 'BILLABLE RECLASS'
6490 , 'NON-BILLABLE RECLASS'
6491 , 'BILLING HOLD'
6492 , 'ONE-TIME BILLING HOLD'
6493 , 'BILLING HOLD RELEASE'
6494 , 'CAPITALIZABLE RECLASS'
6495 , 'NON-CAPITALIZABLE RECLASS'
6496 , 'REPROCESS CROSS CHARGE'
6497 , 'CHANGE FUNC ATTRIBUTE'
6498 , 'CHANGE PROJ FUNC ATTRIBUTE'
6499 , 'CHANGE TP ATTRIBUTE'
6500 , 'CHANGE WORK TYPE ATTRIBUTE'
6501 , 'MARK NO CC PROCESS'
6502 , 'RAW COST RECALC'
6503 , 'INDIRECT COST RECALC'
6504 , 'COST AND REV RECALC'
6505 , 'REVENUE RECALC'
6506 , 'PROJECT OR TASK CHANGE')
6507 and l_net_zero_adjustment_flag = 'Y' then
6508 v_allow_adjustments := 'PA_TR_APE_CANT_ADJ_NET_ZERO';
6509 end if;
6510
6511 if v_allow_adjustments = 'N'
6512 and x_adj_action in ( 'BILLABLE RECLASS'
6513 , 'NON-BILLABLE RECLASS'
6514 , 'CAPITALIZABLE RECLASS'
6515 , 'NON-CAPITALIZABLE RECLASS'
6516 , 'REPROCESS CROSS CHARGE'
6517 , 'CHANGE FUNC ATTRIBUTE'
6518 , 'CHANGE PROJ FUNC ATTRIBUTE'
6519 , 'CHANGE TP ATTRIBUTE'
6520 , 'CHANGE WORK TYPE ATTRIBUTE'
6521 , 'MARK NO CC PROCESS'
6522 , 'RAW COST RECALC'
6523 , 'INDIRECT COST RECALC'
6524 , 'COST AND REV RECALC'
6525 , 'REVENUE RECALC'
6526 , 'PROJECT OR TASK CHANGE')
6527 and l_converted_flag = 'Y' then
6528 v_allow_adjustments := 'PA_TR_APE_CANT_ADJ_CONV';
6529 end if;
6530
6531 if v_allow_adjustments = 'N'
6532 and x_adj_action in ( 'BILLABLE RECLASS'
6533 , 'NON-BILLABLE RECLASS'
6534 , 'CAPITALIZABLE RECLASS'
6535 , 'NON-CAPITALIZABLE RECLASS'
6536 , 'REPROCESS CROSS CHARGE'
6537 , 'CHANGE FUNC ATTRIBUTE'
6538 , 'CHANGE PROJ FUNC ATTRIBUTE'
6539 , 'CHANGE TP ATTRIBUTE'
6540 , 'CHANGE WORK TYPE ATTRIBUTE'
6541 , 'MARK NO CC PROCESS'
6542 , 'RAW COST RECALC'
6543 , 'INDIRECT COST RECALC'
6544 , 'COST AND REV RECALC'
6545 , 'REVENUE RECALC'
6546 , 'PROJECT OR TASK CHANGE')
6547 and l_expenditure_status_code <> 'APPROVED' then
6548 v_allow_adjustments := 'PA_TR_APE_CANT_ADJ_NON_APPR';
6549 end if;
6550
6551 if v_allow_adjustments = 'N'
6552 and x_adj_action in ( 'BILLABLE RECLASS'
6553 , 'NON-BILLABLE RECLASS'
6554 , 'CAPITALIZABLE RECLASS'
6555 , 'NON-CAPITALIZABLE RECLASS'
6556 , 'REPROCESS CROSS CHARGE'
6557 , 'CHANGE FUNC ATTRIBUTE'
6558 , 'RAW COST RECALC'
6559 , 'INDIRECT COST RECALC'
6560 , 'COST AND REV RECALC'
6561 , 'PROJECT OR TASK CHANGE')
6562 and l_allow_adjustments_flag = 'N' then
6563 v_allow_adjustments := 'PA_TR_APE_NO_ADJUST';
6564 end if;
6565
6566 /* Bug 5364389 - Start */
6567 if v_allow_adjustments = 'N'
6568 and x_adj_action in ( 'CHANGE WORK TYPE ATTRIBUTE')
6569 and l_allow_adjustments_flag = 'N'
6570 and NVL(PA_UTILS4.get_trxn_work_billabilty(p_dest_work_type_id, NULL),l_billable_flag) <> l_billable_flag then
6571 v_allow_adjustments := 'PA_TR_APE_NO_ADJUST';
6572 end if;
6573 /* Bug 5364389 - End */
6574
6575 /* Bug 5579712 - Start */
6576 if v_allow_adjustments = 'N'
6577 and x_adj_action in ( 'CHANGE WORK TYPE ATTRIBUTE')
6578 and v_project_type_class_code = 'INDIRECT' then
6579 declare
6580 l_billable_capitalizable_flag pa_work_types_b.billable_capitalizable_flag%TYPE;
6581 begin
6582 select billable_capitalizable_flag
6583 into l_billable_capitalizable_flag
6584 from pa_work_types_b
6585 where work_type_id = p_dest_work_type_id;
6586 if l_billable_capitalizable_flag = 'Y' then
6587 v_allow_adjustments := 'PA_ADJ_WT_IND_PRJ_NOT_ALLOW';
6588 end if;
6589 end;
6590 end if;
6591 /* Bug 5579712 - End */
6592
6593 if v_allow_adjustments = 'N'
6594 and x_adj_action in ( 'BILLABLE RECLASS'
6595 , 'NON-BILLABLE RECLASS'
6596 , 'BILLING HOLD'
6597 , 'ONE-TIME BILLING HOLD'
6598 , 'BILLING HOLD RELEASE'
6599 , 'CAPITALIZABLE RECLASS'
6600 , 'NON-CAPITALIZABLE RECLASS'
6601 , 'REPROCESS CROSS CHARGE'
6602 , 'CHANGE FUNC ATTRIBUTE'
6603 , 'CHANGE PROJ FUNC ATTRIBUTE'
6604 , 'CHANGE TP ATTRIBUTE'
6605 , 'CHANGE WORK TYPE ATTRIBUTE'
6606 , 'MARK NO CC PROCESS'
6607 , 'RAW COST RECALC'
6608 , 'INDIRECT COST RECALC'
6609 , 'COST AND REV RECALC'
6610 , 'REVENUE RECALC'
6611 , 'PROJECT OR TASK CHANGE')
6612 and pa_project_utils.check_prj_stus_action_allowed(l_project_status_code,'ADJUST_TXNS') <> 'Y' then
6613 v_allow_adjustments := 'PA_TR_APE_PRJ_STS_NO_ADJUST';
6614 end if;
6615
6616 /*Bug 11819325 Removed/excluded check for 'BILLABLE RECLASS','NON-BILLABLE RECLASS',
6617 'CAPITALIZABLE RECLASS','NON-CAPITALIZABLE RECLASS' for allowing
6618 these adjustments on BTC EIs */
6619
6620 if v_allow_adjustments = 'N'
6621 and x_adj_action in ( 'REPROCESS CROSS CHARGE'
6622 , 'CHANGE FUNC ATTRIBUTE'
6623 , 'CHANGE PROJ FUNC ATTRIBUTE'
6624 , 'CHANGE TP ATTRIBUTE'
6625 , 'CHANGE WORK TYPE ATTRIBUTE'
6626 , 'MARK NO CC PROCESS'
6627 , 'RAW COST RECALC'
6628 , 'COST AND REV RECALC'
6629 , 'PROJECT OR TASK CHANGE')
6630 and l_burden_sum_dest_run_id IS NOT NULL then
6631 v_allow_adjustments := 'PA_TR_APE_BURDEN_COST_TR';
6632 end if;
6633
6634 if v_allow_adjustments = 'N'
6635 and x_adj_action in ( 'BILLABLE RECLASS'
6636 , 'NON-BILLABLE RECLASS'
6637 , 'BILLING HOLD'
6638 , 'ONE-TIME BILLING HOLD'
6639 , 'BILLING HOLD RELEASE'
6640 , 'CAPITALIZABLE RECLASS'
6641 , 'NON-CAPITALIZABLE RECLASS'
6642 , 'REPROCESS CROSS CHARGE'
6643 , 'CHANGE PROJ FUNC ATTRIBUTE'
6644 , 'CHANGE TP ATTRIBUTE'
6645 , 'CHANGE WORK TYPE ATTRIBUTE'
6646 , 'MARK NO CC PROCESS'
6647 , 'RAW COST RECALC'
6648 , 'INDIRECT COST RECALC'
6649 , 'COST AND REV RECALC'
6650 , 'REVENUE RECALC'
6651 , 'PROJECT OR TASK CHANGE')
6652 and l_transaction_source in ( 'AP INVOICE'
6653 , 'INTERPROJECT_AP_INVOICES'
6654 , 'AP VARIANCE'
6655 , 'AP NRTAX'
6656 , 'AP DISCOUNTS'
6657 , 'AP EXPENSE'
6658 , 'PO RECEIPT'
6659 , 'PO RECEIPT NRTAX'
6660 , 'PO RECEIPT NRTAX PRICE ADJ'
6661 , 'PO RECEIPT PRICE ADJ')
6662 and l_document_header_id is NULL then
6663 v_allow_adjustments := 'PA_SI_ADJ_NOT_UPGRADED_TO_R12';
6664 end if;
6665
6666 if v_allow_adjustments = 'N'
6667 and x_adj_action in ( 'BILLABLE RECLASS'
6668 , 'NON-BILLABLE RECLASS'
6669 , 'BILLING HOLD'
6670 , 'ONE-TIME BILLING HOLD'
6671 , 'BILLING HOLD RELEASE'
6672 , 'CAPITALIZABLE RECLASS'
6673 , 'NON-CAPITALIZABLE RECLASS'
6674 , 'REPROCESS CROSS CHARGE'
6675 , 'CHANGE PROJ FUNC ATTRIBUTE'
6676 , 'CHANGE TP ATTRIBUTE'
6677 , 'CHANGE WORK TYPE ATTRIBUTE'
6678 , 'MARK NO CC PROCESS'
6679 , 'RAW COST RECALC'
6680 , 'INDIRECT COST RECALC'
6681 , 'COST AND REV RECALC'
6682 , 'REVENUE RECALC'
6683 , 'PROJECT OR TASK CHANGE')
6684 and l_transaction_source in ('AP INVOICE','AP EXPENSE','INTERPROJECT_AP_INVOICES','AP VARIANCE','AP NRTAX')
6685 and l_document_type = 'PREPAYMENT' then
6686 v_allow_adjustments := 'PA_SI_ADJ_PREPAY_NOT_ALLOW';
6687 end if;
6688
6689 if v_allow_adjustments = 'N'
6690 and x_adj_action in ( 'BILLABLE RECLASS'
6691 , 'NON-BILLABLE RECLASS'
6692 , 'BILLING HOLD'
6693 , 'ONE-TIME BILLING HOLD'
6694 , 'BILLING HOLD RELEASE'
6695 , 'CAPITALIZABLE RECLASS'
6696 , 'NON-CAPITALIZABLE RECLASS'
6697 , 'REPROCESS CROSS CHARGE'
6698 , 'CHANGE PROJ FUNC ATTRIBUTE'
6699 , 'CHANGE TP ATTRIBUTE'
6700 , 'CHANGE WORK TYPE ATTRIBUTE'
6701 , 'MARK NO CC PROCESS'
6702 , 'RAW COST RECALC'
6703 , 'INDIRECT COST RECALC'
6704 , 'COST AND REV RECALC'
6705 , 'REVENUE RECALC'
6706 , 'PROJECT OR TASK CHANGE')
6707 and l_transaction_source in ('AP DISCOUNTS')
6708 and l_document_type = 'PREPAYMENT' then
6709 v_allow_adjustments := 'PA_SI_ADJ_PREPAY_DIS_NOT_ALLOW';
6710 end if;
6711
6712 if v_allow_adjustments = 'N'
6713 and x_adj_action in ( 'BILLABLE RECLASS'
6714 , 'NON-BILLABLE RECLASS'
6715 , 'BILLING HOLD'
6716 , 'ONE-TIME BILLING HOLD'
6717 , 'BILLING HOLD RELEASE'
6718 , 'CAPITALIZABLE RECLASS'
6719 , 'NON-CAPITALIZABLE RECLASS'
6720 , 'REPROCESS CROSS CHARGE'
6721 , 'CHANGE FUNC ATTRIBUTE'
6722 , 'CHANGE PROJ FUNC ATTRIBUTE'
6723 , 'CHANGE TP ATTRIBUTE'
6724 , 'CHANGE WORK TYPE ATTRIBUTE'
6725 , 'MARK NO CC PROCESS'
6726 , 'RAW COST RECALC'
6727 , 'INDIRECT COST RECALC'
6728 , 'COST AND REV RECALC'
6729 , 'REVENUE RECALC'
6730 , 'PROJECT OR TASK CHANGE')
6731 and l_transaction_source in ('AP INVOICE','AP EXPENSE','INTERPROJECT_AP_INVOICES','AP VARIANCE','AP NRTAX')
6732 and ( l_document_distribution_type = 'PREPAY'
6733 or IsRelatedToPrepayApp(l_document_distribution_id,l_document_distribution_type)) /*Self Assessed Tax Changes*/
6734 and l_document_payment_id is NULL then
6735 v_allow_adjustments := 'PA_SI_ADJ_PREPAY_APP_NOT_ALLOW';
6736 end if;
6737
6738 if v_allow_adjustments = 'N'
6739 and x_adj_action in ( 'REPROCESS CROSS CHARGE'
6740 , 'CHANGE FUNC ATTRIBUTE'
6741 , 'CHANGE PROJ FUNC ATTRIBUTE'
6742 , 'CHANGE TP ATTRIBUTE'
6743 , 'MARK NO CC PROCESS'
6744 , 'RAW COST RECALC'
6745 , 'INDIRECT COST RECALC'
6746 , 'COST AND REV RECALC'
6747 , 'PROJECT OR TASK CHANGE')
6748 and l_source_expenditure_item_id is not null then
6749 v_allow_adjustments := 'PA_TR_APE_CANT_ADJ_REL';
6750 end if;
6751
6752 if v_allow_adjustments = 'N'
6753 and x_adj_action in ( 'CHANGE FUNC ATTRIBUTE')
6754 and v_system_linkage in ('VI', 'ER') then
6755 v_allow_adjustments := 'PA_TR_APE_CANT_ADJ_ER_VI';
6756 end if;
6757
6758 if v_allow_adjustments = 'N'
6759 and x_adj_action in ( 'CHANGE FUNC ATTRIBUTE')
6760 and l_acct_currency_code = v_denom_currency_code then
6761 v_allow_adjustments := 'PA_TR_APE_ACCT_DENOM_CURR_SAME';
6762 end if;
6763
6764 if v_allow_adjustments = 'N'
6765 and x_adj_action in ( 'CHANGE TP ATTRIBUTE')
6766 and l_acct_currency_code = v_denom_tp_currency_code then
6767 v_allow_adjustments := 'PA_TR_APE_ACCT_DENOM_CURR_SAME';
6768 end if;
6769
6770 if v_allow_adjustments = 'N'
6771 and x_adj_action in ( 'CHANGE PROJ FUNC ATTRIBUTE')
6772 and l_projfunc_currency_code = v_denom_currency_code then
6773 v_allow_adjustments := 'PA_TR_APE_PRJ_DENOM_CURR_SAME';
6774 end if;
6775
6776 if v_allow_adjustments = 'N'
6777 and x_adj_action in ( 'CHANGE TP ATTRIBUTE')
6778 and v_cc_code in ( 'N', 'X') then
6779 v_allow_adjustments := 'PA_TR_APE_CC_CODE_NO_ADJUST';
6780 end if;
6781
6782 if v_allow_adjustments = 'N'
6783 and x_adj_action in ( 'CHANGE WORK TYPE ATTRIBUTE'
6784 , 'PROJECT OR TASK CHANGE')
6785 and l_adjusted_expenditure_item_id is not null then
6786 v_allow_adjustments := 'PA_TR_APE_CANT_ADJ_ADJ';
6787 end if;
6788
6789 if v_allow_adjustments = 'N'
6790 and x_adj_action in ( 'MARK NO CC PROCESS')
6791 and v_cc_code = 'N' then
6792 v_allow_adjustments := 'PA_TR_APE_MARK_NO_CC_PROC';
6793 end if;
6794
6795 if v_allow_adjustments = 'N'
6796 and x_adj_action in ( 'MARK NO CC PROCESS')
6797 and v_cc_code = 'X' then
6798 v_allow_adjustments := 'PA_TR_CC_SET_NA';
6799 end if;
6800
6801 if v_allow_adjustments = 'N'
6802 and x_adj_action in ( 'RAW COST RECALC')
6803 and v_project_type_class_code = 'CONTRACT' then
6804 v_allow_adjustments := 'PA_TR_APE_ITEM_IN_CON_PROJ';
6805 end if;
6806
6807 if v_allow_adjustments = 'N'
6808 and x_adj_action in ( 'PROJECT OR TASK CHANGE')
6809 and l_transaction_source = 'ORACLE TIME AND LABOR' then
6810 Pa_Otc_Api.AdjustAllowedToOTCItem(l_orig_transaction_reference,l_adjust_allowed);
6811 if not l_adjust_allowed then
6812 v_allow_adjustments := 'PA_CANT_TRAN_OTC_ITEM';
6813 end if;
6814 end if;
6815
6816 if v_allow_adjustments = 'N'
6817 and x_adj_action in ( 'PROJECT OR TASK CHANGE') then
6818 declare
6819 l_start_date DATE;
6820 l_end_date DATE;
6821 cursor proj_start_end_date is
6822 select start_date, completion_date
6823 from pa_projects_all
6824 where project_id = X_dest_prj_id;
6825 begin
6826 open proj_start_end_date;
6827 fetch proj_start_end_date into l_start_date, l_end_date;
6828 close proj_start_end_date;
6829 if not (v_exp_item_date between l_start_date and nvl(l_end_date, v_exp_item_date)) then
6830 v_allow_adjustments := 'PA_EX_PROJECT_DATE';
6831 end if;
6832 end;
6833 end if;
6834
6835 if v_allow_adjustments = 'N'
6836 and x_adj_action in ( 'PROJECT OR TASK CHANGE') then
6837 declare
6838 l_start_date DATE;
6839 l_end_date DATE;
6840 cursor task_start_end_date is
6841 select start_date, completion_date
6842 from pa_tasks
6843 where task_id = X_dest_task_id;
6844 begin
6845 open task_start_end_date;
6846 fetch task_start_end_date into l_start_date, l_end_date;
6847 close task_start_end_date;
6848 if not (v_exp_item_date between l_start_date and nvl(l_end_date, v_exp_item_date)) then
6849 v_allow_adjustments := 'PA_EXP_TASK_EFF';
6850 end if;
6851 end;
6852 end if;
6853
6854 if v_allow_adjustments = 'N'
6855 and ((v_system_linkage = 'VI'
6856 and l_transaction_source in ('AP INVOICE', 'INTERCOMPANY_AP_INVOICES', 'AP ERV', /* Bug 5235354 */
6857 'INTERPROJECT_AP_INVOICES', 'AP VARIANCE' , 'AP NRTAX' , 'AP DISCOUNTS'))
6858 or (v_system_linkage = 'ER' and l_transaction_source = 'AP EXPENSE')) then
6859 /* R12 Changes Start */
6860 IF X_adj_action not in ('BILLABLE RECLASS','NON-BILLABLE RECLASS') THEN
6861 v_allow_adjustments := InvStatus(X_system_reference2 => l_document_header_id
6862 ,X_system_linkage_function => v_system_linkage);
6863 END IF;
6864 end if;
6865
6866 /* Bug 5235354 - Start */
6867 IF v_allow_adjustments = 'N'
6868 AND l_transaction_source IN ( 'AP ERV', 'PO RECEIPT', 'PO RECEIPT NRTAX'
6869 , 'PO RECEIPT NRTAX PRICE ADJ', 'PO RECEIPT PRICE ADJ')
6870 AND ( X_adj_action IN ( 'PROJECT OR TASK CHANGE'
6871 , 'BILLABLE RECLASS'
6872 , 'NON-BILLABLE RECLASS'
6873 , 'CAPITALIZABLE RECLASS'
6874 , 'NON-CAPITALIZABLE RECLASS'
6875 , 'RAW COST RECALC'
6876 , 'COST AND REV RECALC')
6877 OR ( X_adj_action = 'CHANGE WORK TYPE ATTRIBUTE'
6878 AND NVL(PA_UTILS4.get_trxn_work_billabilty(p_dest_work_type_id, NULL),l_billable_flag) <> l_billable_flag)) THEN
6879
6880 IF NVL(FND_PROFILE.VALUE('PA_ALLOW_RCV_ERV_ADJ_WHEN_JOURNAL_CONVERT'), 'N') = 'N'
6881 AND RepCurrOrSecLedgerDiffCurr(v_exp_org_id) THEN
6882
6883 IF l_transaction_source = 'AP ERV'
6884 AND not PA_Adjustments.IsPeriodEndAccrual(l_document_distribution_id) THEN /* Bug 5381260 */
6885 v_allow_adjustments := 'PA_ERV_PROF_SET_TO_NO';
6886 END IF;
6887 IF l_transaction_source IN ( 'PO RECEIPT', 'PO RECEIPT NRTAX'
6888 , 'PO RECEIPT NRTAX PRICE ADJ', 'PO RECEIPT PRICE ADJ') THEN
6889 v_allow_adjustments := 'PA_RCV_PROF_SET_TO_NO';
6890 END IF;
6891
6892 END IF;
6893
6894 END IF;
6895 /* Bug 5235354 - End */
6896
6897 IF v_allow_adjustments = 'N'
6898 AND l_transaction_source IN ( 'AP INVOICE', 'INTERCOMPANY_AP_INVOICES', 'INTERPROJECT_AP_INVOICES', 'AP ERV' /* Bug 5235354 */
6899 , 'AP VARIANCE', 'AP NRTAX', 'AP DISCOUNTS', 'AP EXPENSE', 'PO RECEIPT'
6900 , 'PO RECEIPT NRTAX', 'PO RECEIPT NRTAX PRICE ADJ', 'PO RECEIPT PRICE ADJ')
6901 AND ( X_adj_action IN ( 'PROJECT OR TASK CHANGE'
6902 , 'BILLABLE RECLASS'
6903 , 'NON-BILLABLE RECLASS'
6904 , 'CAPITALIZABLE RECLASS'
6905 , 'NON-CAPITALIZABLE RECLASS'
6906 , 'RAW COST RECALC'
6907 , 'COST AND REV RECALC')
6908 OR ( X_adj_action = 'CHANGE WORK TYPE ATTRIBUTE'
6909 AND NVL(PA_UTILS4.get_trxn_work_billabilty(p_dest_work_type_id, NULL),l_billable_flag) <> l_billable_flag)) THEN
6910
6911 IF pa_adjustments.is_recoverability_affected
6912 (p_expenditure_item_id => v_expenditure_item_id
6913 ,p_org_id => v_exp_org_id
6914 ,p_system_linkage_function => v_system_linkage
6915 ,p_transaction_source => l_transaction_source
6916 ,p_action => X_adj_action
6917 ,p_project_id => NVL(x_dest_prj_id,l_project_id)
6918 ,p_task_id => NVL(x_dest_task_id,v_task_id)
6919 ,p_expenditure_type => v_exp_type
6920 ,p_vendor_id => l_vendor_id
6921 ,p_expenditure_organization_id => v_exp_organization_id
6922 ,p_expenditure_item_date => v_exp_item_date
6923 ,p_emp_id => v_incurred_by_person_id
6924 ,p_document_header_id => l_document_header_id
6925 ,p_document_line_number => l_document_line_number
6926 ,p_document_distribution_id => l_document_distribution_id
6927 ,p_document_distribution_type => l_document_distribution_type /*Self Assessed Tax Changes*/
6928 ,p_document_type => l_document_type
6929 ,p_award_id => NVL(p_dest_award_id,PA_GMS_API.VERT_GET_EI_AWARD_ID(v_expenditure_item_id))
6930 ,p_billable_flag1 => l_billable_flag
6931 ,x_error_message_name => l_error_message_name /* Bug 4997739 */
6932 ,x_encoded_error_message => l_encoded_error_message) THEN /* Bug 4997739 */
6933
6934 /* Bug 4997739 - Trap exceptions from workflow or eBTax API */
6935 IF l_encoded_error_message IS NOT NULL THEN
6936 fnd_message.parse_encoded(l_encoded_error_message,l_application_short_name,l_error_message_name);
6937 v_allow_adjustments := l_error_message_name;
6938 ELSE
6939 v_allow_adjustments := l_error_message_name;
6940 END IF;
6941 END IF;
6942
6943 END IF;
6944
6945 IF v_allow_adjustments = 'N'
6946 AND v_system_linkage IN ('VI','ER')
6947 AND l_gl_accounted = 'Y'
6948 AND ( X_adj_action IN ( 'PROJECT OR TASK CHANGE'
6949 , 'BILLABLE RECLASS'
6950 , 'NON-BILLABLE RECLASS'
6951 , 'CAPITALIZABLE RECLASS'
6952 , 'NON-CAPITALIZABLE RECLASS'
6953 , 'RAW COST RECALC'
6954 , 'COST AND REV RECALC')
6955 OR ( X_adj_action = 'CHANGE WORK TYPE ATTRIBUTE'
6956 AND NVL(PA_UTILS4.get_trxn_work_billabilty(p_dest_work_type_id, NULL),l_billable_flag) <> l_billable_flag)) THEN
6957
6958 IF NOT pa_adjustments.Allow_Adjust_with_Auto_Offset
6959 (p_expenditure_item_id => v_expenditure_item_id
6960 ,p_org_id => v_exp_org_id
6961 ,p_system_linkage_function => v_system_linkage
6962 ,p_transaction_source => l_transaction_source
6963 ,p_action => X_adj_action
6964 ,p_project_id => NVL(x_dest_prj_id,l_project_id)
6965 ,p_task_id => NVL(x_dest_task_id,v_task_id)
6966 ,p_expenditure_type => v_exp_type
6967 ,p_vendor_id => l_vendor_id
6968 ,p_expenditure_organization_id => v_exp_organization_id
6969 ,p_expenditure_item_date => v_exp_item_date
6970 ,p_emp_id => v_incurred_by_person_id
6971 ,p_invoice_distribution_id => l_document_distribution_id
6972 ,p_invoice_payment_id => l_document_payment_id /* Bug 5006835 */
6973 ,p_award_id => NVL(p_dest_award_id,PA_GMS_API.VERT_GET_EI_AWARD_ID(v_expenditure_item_id))
6974 ,p_billable_flag1 => l_billable_flag
6975 ,x_encoded_error_message => l_encoded_error_message) THEN /* Bug 4997739 */
6976
6977 /* Bug 4997739 - Trap exceptions from workflow */
6978 IF l_encoded_error_message IS NOT NULL THEN
6979 fnd_message.parse_encoded(l_encoded_error_message,l_application_short_name,l_error_message_name);
6980 v_allow_adjustments := l_error_message_name;
6981 ELSE
6982 v_allow_adjustments := 'PA_SI_ADJ_LB_ACC_CHG_NOT_ALLOW';
6983 END IF;
6984
6985 END IF;
6986
6987 END IF;
6988
6989 /* Bug 5436420 - PA_GMS_API.VERT_TRANSFER will verify for award dates and statuses and the
6990 expenditure type. Added the adjustment actions Capitalizable, Non-Capitalizable,
6991 Recalculate Raw Cost, Recalculate Burden Cost, Billable, Non-Billable, Bill Hold,
6992 Once-Time Hold, Release Hold, Recalculate Revenue, Recalculate Cost/Revenue */
6993 IF v_allow_adjustments = 'N'
6994 AND X_adj_action IN ( 'BILLABLE RECLASS'
6995 , 'NON-BILLABLE RECLASS'
6996 , 'BILLING HOLD'
6997 , 'ONE-TIME BILLING HOLD'
6998 , 'BILLING HOLD RELEASE'
6999 , 'CAPITALIZABLE RECLASS'
7000 , 'NON-CAPITALIZABLE RECLASS'
7001 , 'RAW COST RECALC'
7002 , 'INDIRECT COST RECALC'
7003 , 'COST AND REV RECALC'
7004 , 'REVENUE RECALC'
7005 , 'PROJECT OR TASK CHANGE')
7006 AND NOT PA_GMS_API.VERT_TRANSFER(v_expenditure_item_id,v_allow_adjustments) THEN
7007
7008 NULL;
7009
7010 END IF;
7011
7012 /* Bug 5436420 - 1) For Non-Sponsored projects, adjustment should be disllowed if the source
7013 and destination tasks are same.
7014 2) For Sponsored Projects, adjustment should allowed if the source task,
7015 award are both equal to the destination task,award respectively. */
7016 if v_allow_adjustments = 'N'
7017 and x_Adj_action in ( 'PROJECT OR TASK CHANGE')
7018 and v_task_id = x_dest_task_id
7019 and (p_dest_cbs_element_id is null or (l_cbs_element_id = p_dest_cbs_element_id)) then -- Added for CBS Enhancement Bug 16220146
7020 l_award_id := PA_GMS_API.VERT_GET_EI_AWARD_ID(v_expenditure_item_id);
7021 if l_award_id is null
7022 and p_dest_award_id is null then
7023 v_allow_adjustments := 'PA_TR_APE_CANT_XFER_TO_SELF';
7024 elsif l_award_id = p_dest_award_id then
7025 v_allow_adjustments := 'GMS_TR_SOURCE_DEST_AWARDS_SAME';
7026 end if;
7027 end if;
7028 /* R12 Changes End */
7029
7030 --rkuttiya added for 12.2 Projects Payroll Integration
7031 --Expenditure Adjustments
7032
7033 IF v_allow_adjustments = 'N'
7034 and x_adj_action IN ('COST AND REV RECALC', 'RAW COST RECALC','TRANSFER') THEN
7035 pa_utils.get_rate_source_cost_method(v_expenditure_item_id,v_exp_item_date,l_curr_rate_source_code,l_curr_costing_mthd,l_curr_accrual_flag);
7036 IF (l_prev_costing_method = 'STANDARD_COSTING' AND
7037 l_curr_costing_mthd = 'ACTUAL') OR
7038 (l_prev_costing_method = 'ACTUAL' AND
7039 l_curr_costing_mthd = 'STANDARD') THEN
7040 v_allow_adjustments := 'PA_TR_APE_UPDATED_COST_METHOD' ;
7041 ELSIF (l_prev_costing_method = 'ACTUAL' AND l_prev_accrual_flag = 'YES'
7042 AND l_curr_costing_mthd = 'ACTUAL' AND l_prev_accrual_flag = 'NO') OR
7043 (l_prev_costing_method = 'ACTUAL' AND l_prev_accrual_flag = 'NO'
7044 AND l_curr_costing_mthd = 'ACTUAL' AND l_prev_accrual_flag = 'YES') THEN
7045 v_allow_adjustments := 'PA_TR_APE_PREVIOUS_ACTUAL';
7046 END IF;
7047 END IF;
7048
7049 --12.2 Projects Payroll end changes
7050
7051 IF v_allow_adjustments <> 'N' THEN
7052
7053 temp_num_rejected := temp_num_rejected + 1;
7054 /* R12 Changes Start */
7055 InsAuditRec( v_expenditure_item_id
7056 , X_adj_action
7057 , X_module
7058 , X_user
7059 , X_login
7060 , temp_status
7061 , G_REQUEST_ID
7062 , G_PROGRAM_ID
7063 , G_PROG_APPL_ID
7064 , sysdate
7065 , v_allow_adjustments);
7066 CheckStatus(temp_status);
7067 /* R12 changes End */
7068 j := j + 1 ;
7069
7070 else
7071
7072 i := i + 1;
7073
7074 IF X_adj_action <> 'INDIRECT COST RECALC' then
7075 ItemsIdTab(i) := v_expenditure_item_id;
7076 AdjustsIdTab(i) := NULL;
7077 DenomCurrCodeTab(i) := v_denom_currency_code ;
7078 ProjCurrCodeTab(i) := v_project_currency_code ;
7079 SysLinkageTab(i) := v_system_linkage ;
7080 CrossChargeCodeTab(i) := v_cc_code ;
7081 DenomTpCurrCodeTab(i) := v_denom_tp_currency_code ;
7082 ProjFuncCurrCodeTab(i) := l_projfunc_currency_code;
7083
7084 TpAmtTypCodeTab(i) := l_tp_amt_type_code;
7085
7086 IF X_adj_action = 'REPROCESS CROSS CHARGE' then
7087 ExpOrganizationTab(i) := v_exp_organization_id ;
7088 ExpOrgTab(i) := v_exp_org_id ;
7089 TaskIdTab(i) := v_task_id ;
7090 ExpItemDateTab(i) := v_exp_item_date ;
7091 ExpTypeTab(i) := v_exp_type ;
7092 IncurredByPersonIdTab(i) := v_incurred_by_person_id ;
7093 TrxSourceTab(i) := l_transaction_source ;
7094 NlrOrganizationIdTab(i) := v_nlr_organization_id ;
7095 END IF ;
7096
7097 ELSE
7098 IF v_project_type_class_code <> 'CAPITAL' then
7099 k := k + 1;
7100 ItemsIdNCapTab(k) := v_expenditure_item_id;
7101 AdjustsIdNCapTab(k) := NULL;
7102 ELSE
7103 l := l + 1;
7104 ItemsIdCapTab(l) := v_expenditure_item_id;
7105 AdjustsIdCapTab(l) := NULL;
7106 END IF;
7107 END IF;
7108
7109 IF i >= 500 then
7110
7111 IF P_DEBUG_MODE THEN
7112 print_message('get_denom_curr_code: ' || 'calling massaction ');
7113 END IF;
7114 IF X_adj_action <> 'INDIRECT COST RECALC' then
7115 MassAction( ItemsIdTab
7116 , AdjustsIdTab
7117 , X_adj_action
7118 , X_module
7119 , X_user
7120 , X_login
7121 , i
7122 , X_dest_prj_id
7123 , X_dest_task_id
7124 , X_project_currency_code
7125 , X_project_rate_type
7126 , X_project_rate_date
7127 , X_project_exchange_rate
7128 , X_acct_rate_type
7129 , X_acct_rate_date
7130 , X_acct_exchange_rate
7131 , DenomCurrCodeTab
7132 , ProjCurrCodeTab
7133 , temp_status
7134 , num_processed
7135 , num_rejected
7136 , ProjFuncCurrCodeTab
7137 , p_projfunc_cost_rate_type
7138 , p_projfunc_cost_rate_date
7139 , p_projfunc_cost_exchange_rate
7140 , p_project_tp_cost_rate_type
7141 , p_project_tp_cost_rate_date
7142 , p_project_tp_cost_exchg_rate
7143 , p_assignment_id
7144 , p_dest_work_type_id
7145 , p_projfunc_currency_code
7146 , TpAmtTypCodeTab
7147 , p_dest_tp_amt_type_code
7148 -- , p_cbs_element_id -- Added for CBS Enhancement Bug 16220146
7149 -- commented the above line as part of bug 16686195
7150 , p_dest_cbs_element_id -- Modified this parameter for Bug 16446988
7151 );
7152 temp_num_processed := temp_num_processed + num_processed;
7153 temp_num_rejected := temp_num_rejected + num_rejected ;
7154
7155 ELSE
7156
7157 MassAction( ItemsIdNCapTab
7158 , AdjustsIdNCapTab
7159 , 'INDIRECT COST RECALC'
7160 , X_module
7161 , X_user
7162 , X_login
7163 , k
7164 , X_dest_prj_id
7165 , X_dest_task_id
7166 , X_project_currency_code
7167 , X_project_rate_type
7168 , X_project_rate_date
7169 , X_project_exchange_rate
7170 , X_acct_rate_type
7171 , X_acct_rate_date
7172 , X_acct_exchange_rate
7173 , DenomCurrCodeTab
7174 , ProjCurrCodeTab
7175 , temp_status
7176 , num_processed
7177 , num_rejected
7178 , ProjFuncCurrCodeTab
7179 , p_projfunc_cost_rate_type
7180 , p_projfunc_cost_rate_date
7181 , p_projfunc_cost_exchange_rate
7182 , p_project_tp_cost_rate_type
7183 , p_project_tp_cost_rate_date
7184 , p_project_tp_cost_exchg_rate
7185 , p_assignment_id
7186 , p_dest_work_type_id
7187 , p_projfunc_currency_code
7188 , TpAmtTypCodeTab
7189 , p_dest_tp_amt_type_code
7190 -- , p_cbs_element_id -- Added for CBS Enhancement Bug 16220146
7191 -- commented the above line as part of bug 16686195
7192 , p_dest_cbs_element_id -- Modified this parameter for Bug 16446988
7193 );
7194 temp_num_processed := temp_num_processed + num_processed;
7195 temp_num_rejected := temp_num_rejected + num_rejected ;
7196
7197 MassAction( ItemsIdCapTab
7198 , AdjustsIdCapTab
7199 , 'CAPITAL COST RECALC'
7200 , X_module
7201 , X_user
7202 , X_login
7203 , l
7204 , X_dest_prj_id
7205 , X_dest_task_id
7206 , X_project_currency_code
7207 , X_project_rate_type
7208 , X_project_rate_date
7209 , X_project_exchange_rate
7210 , X_acct_rate_type
7211 , X_acct_rate_date
7212 , X_acct_exchange_rate
7213 , DenomCurrCodeTab
7214 , ProjCurrCodeTab
7215 , temp_status
7216 , num_processed
7217 , num_rejected
7218 , ProjFuncCurrCodeTab
7219 , p_projfunc_cost_rate_type
7220 , p_projfunc_cost_rate_date
7221 , p_projfunc_cost_exchange_rate
7222 , p_project_tp_cost_rate_type
7223 , p_project_tp_cost_rate_date
7224 , p_project_tp_cost_exchg_rate
7225 , p_assignment_id
7226 , p_dest_work_type_id
7227 , p_projfunc_currency_code
7228 , TpAmtTypCodeTab
7229 , p_dest_tp_amt_type_code
7230 -- , p_cbs_element_id -- Added for CBS Enhancement Bug 16220146
7231 -- commented the above line as part of bug 16686195
7232 , p_dest_cbs_element_id -- Modified this parameter for Bug 16446988
7233 );
7234 temp_num_processed := temp_num_processed + num_processed;
7235 temp_num_rejected := temp_num_rejected + num_rejected ;
7236 END IF;
7237
7238 j := j + i;
7239 i := 0;
7240 k := 0;
7241 l := 0;
7242
7243 IF ( temp_outcome IS NOT NULL ) THEN
7244 RAISE INVALID_ITEM;
7245 END IF;
7246 IF P_DEBUG_MODE THEN
7247 print_message('get_denom_curr_code: ' || 'after mass action');
7248 END IF;
7249
7250 /* Bug 5501593 - Start */
7251 /* Commit after 5000 transactions have been processed */
7252 l_commit_count := l_commit_count + 500;
7253 IF l_commit_count >= 5000 THEN
7254 commit;
7255 l_commit_count := 0;
7256 END IF;
7257 /* Bug 5501593 - End */
7258
7259 END IF;
7260 END IF;
7261 END LOOP;
7262
7263 -- Added a close cursor since this was causing problems when this
7264 -- procedure was called multiple times. Customer - Oakridge
7265 IF P_DEBUG_MODE THEN
7266 print_message('get_denom_curr_code: ' || 'close the cursor ');
7267 END IF;
7268 dbms_sql.close_cursor(v_cursor_adj_id) ;
7269
7270 IF i >= 1 then
7271 IF X_adj_action <> 'INDIRECT COST RECALC' then
7272 IF P_DEBUG_MODE THEN
7273 print_message('get_denom_curr_code: ' || 'i is ['||i||'] denom_currcode[' ||v_denom_currency_code||']' );
7274 END IF;
7275 MassAction( ItemsIdTab
7276 , AdjustsIdTab
7277 , X_adj_action
7278 , X_module
7279 , X_user
7280 , X_login
7281 , i
7282 , X_dest_prj_id
7283 , X_dest_task_id
7284 , X_project_currency_code
7285 , X_project_rate_type
7286 , X_project_rate_date
7287 , X_project_exchange_rate
7288 , X_acct_rate_type
7289 , X_acct_rate_date
7290 , X_acct_exchange_rate
7291 , DenomCurrCodeTab
7292 , ProjCurrCodeTab
7293 , temp_status
7294 , num_processed
7295 , num_rejected
7296 , ProjFuncCurrCodeTab
7297 , p_projfunc_cost_rate_type
7298 , p_projfunc_cost_rate_date
7299 , p_projfunc_cost_exchange_rate
7300 , p_project_tp_cost_rate_type
7301 , p_project_tp_cost_rate_date
7302 , p_project_tp_cost_exchg_rate
7303 , p_assignment_id
7304 , p_dest_work_type_id
7305 , p_projfunc_currency_code
7306 , TpAmtTypCodeTab
7307 , p_dest_tp_amt_type_code
7308 -- , p_cbs_element_id -- Added for CBS Enhancement Bug 16220146
7309 -- commented the above line as part of bug 16686195
7310 , p_dest_cbs_element_id -- Modified this parameter for Bug 16446988
7311 );
7312 temp_num_processed := temp_num_processed + num_processed;
7313 temp_num_rejected := temp_num_rejected + num_rejected ;
7314 ELSE
7315 MassAction( ItemsIdNCapTab
7316 , AdjustsIdNCapTab
7317 , 'INDIRECT COST RECALC'
7318 , X_module
7319 , X_user
7320 , X_login
7321 , k
7322 , X_dest_prj_id
7323 , X_dest_task_id
7324 , X_project_currency_code
7325 , X_project_rate_type
7326 , X_project_rate_date
7327 , X_project_exchange_rate
7328 , X_acct_rate_type
7329 , X_acct_rate_date
7330 , X_acct_exchange_rate
7331 , DenomCurrCodeTab
7332 , ProjCurrCodeTab
7333 , temp_status
7334 , num_processed
7335 , num_rejected
7336 , ProjFuncCurrCodeTab
7337 , p_projfunc_cost_rate_type
7338 , p_projfunc_cost_rate_date
7339 , p_projfunc_cost_exchange_rate
7340 , p_project_tp_cost_rate_type
7341 , p_project_tp_cost_rate_date
7342 , p_project_tp_cost_exchg_rate
7343 , p_assignment_id
7344 , p_dest_work_type_id
7345 , p_projfunc_currency_code
7346 , TpAmtTypCodeTab
7347 , p_dest_tp_amt_type_code
7348 -- , p_cbs_element_id -- Added for CBS Enhancement Bug 16220146
7349 -- commented the above line as part of bug 16686195
7350 , p_dest_cbs_element_id -- Modified this parameter for Bug 16446988
7351 );
7352 temp_num_processed := temp_num_processed + num_processed;
7353 temp_num_rejected := temp_num_rejected + num_rejected ;
7354
7355 MassAction( ItemsIdCapTab
7356 , AdjustsIdCapTab
7357 , 'CAPITAL COST RECALC'
7358 , X_module
7359 , X_user
7360 , X_login
7361 , l
7362 , X_dest_prj_id
7363 , X_dest_task_id
7364 , X_project_currency_code
7365 , X_project_rate_type
7366 , X_project_rate_date
7367 , X_project_exchange_rate
7368 , X_acct_rate_type
7369 , X_acct_rate_date
7370 , X_acct_exchange_rate
7371 , DenomCurrCodeTab
7372 , ProjCurrCodeTab
7373 , temp_status
7374 , num_processed
7375 , num_rejected
7376 , ProjFuncCurrCodeTab
7377 , p_projfunc_cost_rate_type
7378 , p_projfunc_cost_rate_date
7379 , p_projfunc_cost_exchange_rate
7380 , p_project_tp_cost_rate_type
7381 , p_project_tp_cost_rate_date
7382 , p_project_tp_cost_exchg_rate
7383 , p_assignment_id
7384 , p_dest_work_type_id
7385 , p_projfunc_currency_code
7386 , TpAmtTypCodeTab
7387 , p_dest_tp_amt_type_code
7388 -- , p_cbs_element_id -- Added for CBS Enhancement Bug 16220146
7389 -- commented the above line as part of bug 16686195
7390 , p_dest_cbs_element_id -- Modified this parameter for Bug 16446988
7391 );
7392 temp_num_processed := temp_num_processed + num_processed;
7393 temp_num_rejected := temp_num_rejected + num_rejected ;
7394 END IF;
7395 END IF;
7396
7397 j := j + i ;
7398 i := 0;
7399 k := 0;
7400 l := 0;
7401
7402 IF ( j = 0 ) THEN
7403 X_outcome := 'PA_PR_NO_ITEMS_PROC';
7404 X_num_processed := 0;
7405 X_num_rejected := 0;
7406 RETURN;
7407 END IF;
7408
7409 END IF;
7410 IF P_DEBUG_MODE THEN
7411 print_message('get_denom_curr_code: ' || 'temp num process is[ '||temp_num_processed||']num reject is[ '||temp_num_rejected
7412 ||']End of Mass Adjust api');
7413 END IF;
7414
7415 X_num_processed := temp_num_processed;
7416 X_num_rejected := temp_num_rejected;
7417 X_outcome := NULL;
7418
7419 EXCEPTION
7420 WHEN INVALID_ITEM THEN
7421 IF P_DEBUG_MODE THEN
7422 print_message('get_denom_curr_code: ' || 'execption INVALID_ITEM IN mass adjust');
7423 END IF;
7424 X_outcome := temp_outcome;
7425 WHEN RESOURCE_BUSY THEN
7426 X_outcome := 'PA_ALL_COULD_NOT_LOCK';
7427 IF P_DEBUG_MODE THEN
7428 print_message('get_denom_curr_code: ' || 'execption RESOURCE_BUSY IN mass adjust PA_ALL_COULD_NOT_LOCK');
7429 END IF;
7430 RAISE ;
7431 WHEN OTHERS THEN
7432 IF P_DEBUG_MODE THEN
7433 print_message('get_denom_curr_code: ' || 'execption OTHERS IN mass adjust '||SQLCODE||sqlerrm);
7434 END IF;
7435 X_outcome := SQLCODE;
7436 RAISE;
7437
7438 END MassAdjust;
7439
7440 -- ========================================================================
7441 -- PROCEDURE MassAction
7442 -- ========================================================================
7443
7444 -- This procedure was created to improve the performance allowing multiple
7445
7446 PROCEDURE MassAction(
7447 ItemsIdTab IN pa_utils.IdTabTyp
7448 , AdjustsIdTab IN pa_utils.IdTabTyp
7449 , X_adj_action IN VARCHAR2
7450 , X_module IN VARCHAR2
7451 , X_user IN NUMBER
7452 , X_login IN NUMBER
7453 , X_num_rows IN NUMBER
7454 , X_dest_prj_id IN NUMBER
7455 , X_dest_task_id IN NUMBER
7456 , X_project_currency_code IN VARCHAR2
7457 , X_project_rate_type IN VARCHAR2
7458 , X_project_rate_date IN DATE
7459 , X_project_exchange_rate IN NUMBER
7460 , X_acct_rate_type IN VARCHAR2
7461 , X_acct_rate_date IN DATE
7462 , X_acct_exchange_rate IN NUMBER
7463 , DenomCurrCodeTab IN pa_utils.Char15TabTyp
7464 , ProjCurrCodeTab IN pa_utils.Char15TabTyp
7465 , X_status OUT NOCOPY VARCHAR2
7466 , X_num_processed OUT NOCOPY NUMBER
7467 , X_num_rejected OUT NOCOPY NUMBER
7468 , ProjFuncCurrCodeTab IN pa_utils.Char15TabTyp
7469 , p_projfunc_cost_rate_type IN VARCHAR2
7470 , p_projfunc_cost_rate_date IN date
7471 , p_projfunc_cost_exchange_rate IN NUMBER
7472 , p_project_tp_cost_rate_type IN VARCHAR2
7473 , p_project_tp_cost_rate_date IN DATE
7474 , p_project_tp_cost_exchg_rate IN NUMBER
7475 , p_assignment_id IN NUMBER
7476 , p_work_type_id IN NUMBER
7477 , p_projfunc_currency_code IN VARCHAR2
7478 , p_TpAmtTypCodeTab IN pa_utils.Char30TabTyp
7479 , p_dest_tp_amt_type_code IN VARCHAR2
7480 -- , p_cbs_element_id IN NUMBER -- Added for CBS Enhancement Bug 16220146
7481 -- commented the above line as part of bug 16686195
7482 , p_dest_cbs_element_id IN NUMBER -- Modified this parameter for Bug 16446988
7483 )
7484
7485 IS
7486 dummy NUMBER;
7487 temp_outcome VARCHAR2(30) DEFAULT NULL;
7488 temp_status NUMBER DEFAULT NULL;
7489 temp_num_processed NUMBER DEFAULT 0;
7490 temp_num_rejected NUMBER DEFAULT 0;
7491 temp_msg_application VARCHAR2(30);
7492 temp_msg_type VARCHAR2(1);
7493 temp_msg_token1 VARCHAR2(240);
7494 temp_msg_token2 VARCHAR2(240);
7495 temp_msg_token3 VARCHAR2(240);
7496 temp_msg_count Number;
7497 i BINARY_INTEGER := 0;
7498 j BINARY_INTEGER := 0;
7499 k BINARY_INTEGER := 0;
7500 l BINARY_INTEGER := 0;
7501 adj_ei number;
7502
7503 l_projfunc_currency_code varchar2(15);
7504
7505 BEGIN
7506
7507 IF P_DEBUG_MODE THEN
7508 print_message('get_denom_curr_code: ' || 'Entering MassAction api adjust action ['||X_adj_action||']proj func cur code ['
7509 ||p_projfunc_currency_code||']work type ['||p_work_type_id||']assignment id ['||p_assignment_id||']' );
7510 END IF;
7511
7512 /** commented and passing the IN param to Transfer api
7513 IF ProjFuncCurrCodeTab.EXISTS(1) then
7514 l_projfunc_currency_code := ProjFuncCurrCodeTab(1);
7515 END IF;
7516 **/
7517
7518 l_projfunc_currency_code := p_projfunc_currency_code;
7519
7520
7521 IF ( X_adj_action = 'BILLABLE RECLASS' ) THEN
7522
7523 Reclass( ItemsIdTab
7524 , AdjustsIdTab
7525 , 'Y'
7526 , X_adj_action
7527 , X_user
7528 , X_login
7529 , X_module
7530 , X_num_rows
7531 , temp_status );
7532
7533 CheckStatus( temp_status );
7534 temp_num_processed := X_num_rows ;
7535
7536 ELSIF ( X_adj_action = 'NON-BILLABLE RECLASS' ) THEN
7537
7538 Reclass( ItemsIdTab
7539 , AdjustsIdTab
7540 , 'N'
7541 , X_adj_action
7542 , X_user
7543 , X_login
7544 , X_module
7545 , X_num_rows
7546 , temp_status );
7547 CheckStatus( temp_status );
7548 temp_num_processed := X_num_rows ;
7549
7550 ELSIF ( X_adj_action = 'CAPITALIZABLE RECLASS' ) THEN
7551
7552 Reclass( ItemsIdTab
7553 , AdjustsIdTab
7554 , 'Y'
7555 , X_adj_action
7556 , X_user
7557 , X_login
7558 , X_module
7559 , X_num_rows
7560 , temp_status );
7561 CheckStatus( temp_status );
7562 temp_num_processed := X_num_rows ;
7563
7564 ELSIF ( X_adj_action = 'NON-CAPITALIZABLE RECLASS' ) THEN
7565
7566 Reclass( ItemsIdTab
7567 , AdjustsIdTab
7568 , 'N'
7569 , X_adj_action
7570 , X_user
7571 , X_login
7572 , X_module
7573 , X_num_rows
7574 , temp_status );
7575 CheckStatus( temp_status );
7576 temp_num_processed := X_num_rows ;
7577
7578 ELSIF ( X_adj_action = 'BILLING HOLD' ) THEN
7579
7580 Hold( ItemsIdTab
7581 , AdjustsIdTab
7582 , 'Y'
7583 , X_adj_action
7584 , X_user
7585 , X_login
7586 , X_module
7587 , X_num_rows
7588 , temp_status );
7589 CheckStatus( temp_status );
7590 temp_num_processed := X_num_rows ;
7591
7592 ELSIF ( X_adj_action = 'BILLING HOLD RELEASE' ) THEN
7593
7594 Hold( ItemsIdTab
7595 , AdjustsIdTab
7596 , 'N'
7597 , X_adj_action
7598 , X_user
7599 , X_login
7600 , X_module
7601 , X_num_rows
7602 , temp_status );
7603 CheckStatus( temp_status );
7604 temp_num_processed := X_num_rows ;
7605
7606 ELSIF ( X_adj_action = 'ONE-TIME BILLING HOLD' ) THEN
7607
7608 Hold( ItemsIdTab
7609 , AdjustsIdTab
7610 , 'O'
7611 , X_adj_action
7612 , X_user
7613 , X_login
7614 , X_module
7615 , X_num_rows
7616 , temp_status );
7617 CheckStatus( temp_status );
7618 temp_num_processed := X_num_rows ;
7619
7620 ELSIF ( X_adj_action = 'INDIRECT COST RECALC' ) THEN
7621
7622 RecalcIndCost( ItemsIdTab
7623 , AdjustsIdTab
7624 , X_user
7625 , X_login
7626 , X_module
7627 , X_num_rows
7628 , temp_status );
7629 CheckStatus( temp_status );
7630 temp_num_processed := X_num_rows ;
7631
7632 ELSIF ( X_adj_action = 'COST AND REV RECALC' ) THEN
7633 RecalcCostRev( ItemsIdTab
7634 , AdjustsIdTab
7635 , X_user
7636 , X_login
7637 , X_module
7638 , X_num_rows
7639 , temp_num_processed
7640 , temp_status );
7641 CheckStatus( temp_status );
7642
7643 ELSIF ( X_adj_action = 'REVENUE RECALC' ) THEN
7644
7645 RecalcRev( ItemsIdTab
7646 , AdjustsIdTab
7647 , X_user
7648 , X_login
7649 , X_module
7650 , X_num_rows
7651 , temp_status );
7652 CheckStatus( temp_status );
7653 temp_num_processed := X_num_rows ;
7654
7655 ELSIF ( X_adj_action = 'CAPITAL COST RECALC' ) THEN
7656
7657 RecalcCapCost( ItemsIdTab
7658 , AdjustsIdTab
7659 , X_user
7660 , X_login
7661 , X_module
7662 , X_num_rows
7663 , temp_status );
7664 CheckStatus( temp_status );
7665 temp_num_processed := X_num_rows ;
7666
7667 ELSIF ( X_adj_action = 'RAW COST RECALC' ) THEN
7668
7669 RecalcRawCost( ItemsIdTab
7670 , AdjustsIdTab
7671 , X_user
7672 , X_login
7673 , X_module
7674 , X_num_rows
7675 , temp_num_processed
7676 , temp_status );
7677 CheckStatus( temp_status );
7678
7679 -- call to the new rate attribute adjustment procedures
7680 ELSIF ( X_adj_action = 'CHANGE FUNC ATTRIBUTE' ) THEN
7681 ChangeFuncAttributes(ItemsIdTab
7682 , 'S'
7683 , X_user
7684 , X_login
7685 , X_module
7686 , X_acct_rate_type
7687 , X_acct_rate_date
7688 , X_acct_exchange_rate
7689 , DenomCurrCodeTab
7690 , ProjCurrCodeTab
7691 , X_num_rows
7692 , temp_num_processed
7693 , temp_num_rejected
7694 , temp_status
7695 , ProjFuncCurrCodeTab) ;
7696 CheckStatus( temp_status );
7697
7698 -- call to the new rate attribute adjustment procedures
7699 ELSIF ( X_adj_action = 'CHANGE PROJ ATTRIBUTE' ) THEN
7700
7701 ChangeProjAttributes(ItemsIdTab
7702 , 'S'
7703 , X_user
7704 , X_login
7705 , X_module
7706 , X_project_rate_type
7707 , X_project_rate_date
7708 , X_project_exchange_rate
7709 , DenomCurrCodeTab
7710 , ProjCurrCodeTab
7711 , X_num_rows
7712 , temp_num_processed
7713 , temp_num_rejected
7714 , temp_status ) ;
7715 CheckStatus( temp_status );
7716 -- call to the new project funcational rate attribute adjustment procedures
7717 ELSIF ( X_adj_action = 'CHANGE PROJ FUNC ATTRIBUTE' ) THEN
7718
7719 ChangeProjFuncAttributes(ItemsIdTab
7720 , 'S'
7721 , X_user
7722 , X_login
7723 , X_module
7724 , p_projfunc_cost_rate_type
7725 , p_projfunc_cost_rate_date
7726 , p_projfunc_cost_exchange_rate
7727 , DenomCurrCodeTab
7728 , ProjFuncCurrCodeTab
7729 , X_num_rows
7730 , temp_num_processed
7731 , temp_num_rejected
7732 , temp_status ) ;
7733 CheckStatus( temp_status );
7734
7735 ELSIF ( X_adj_action = 'REPROCESS CROSS CHARGE' ) THEN
7736 ReprocessCrossCharge (ItemsIdTab
7737 , 'S'
7738 , X_user
7739 , X_login
7740 , X_module
7741 , Null
7742 , Null
7743 , Null
7744 , Null
7745 , Null
7746 , Null
7747 , X_num_rows
7748 , temp_num_processed
7749 , temp_status ) ;
7750 CheckStatus( temp_status );
7751 ELSIF ( X_adj_action = 'MARK NO CC PROCESS' ) THEN
7752 MarkNoCCProcess (ItemsIdTab
7753 , 'S'
7754 , X_user
7755 , X_login
7756 , X_module
7757 , Null
7758 , Null
7759 , X_num_rows
7760 , temp_num_processed
7761 , temp_status ) ;
7762 CheckStatus( temp_status );
7763 ELSIF ( X_adj_action = 'CHANGE TP ATTRIBUTE' ) THEN
7764 ChangeTpAttributes(ItemsIdTab
7765 , 'S'
7766 , X_user
7767 , X_login
7768 , X_module
7769 , X_acct_rate_type
7770 , X_acct_rate_date
7771 , X_acct_exchange_rate
7772 , Null
7773 , Null
7774 , DenomCurrCodeTab
7775 , X_num_rows
7776 , temp_num_processed
7777 , temp_num_rejected
7778 , temp_status
7779 , p_PROJECT_TP_COST_RATE_DATE
7780 , p_PROJECT_TP_COST_RATE_TYPE
7781 , p_PROJECT_TP_COST_EXCHG_RATE) ;
7782 CheckStatus( temp_status );
7783 ELSIF ( X_adj_action = 'PROJECT OR TASK CHANGE' ) THEN
7784
7785 Transfer( ItemsIdTab
7786 , X_dest_prj_id
7787 , X_dest_task_id
7788 , X_project_currency_code
7789 , X_project_rate_type
7790 , X_project_rate_date
7791 , X_project_exchange_rate
7792 , X_user
7793 , X_login
7794 , X_module
7795 , 'S'
7796 , X_num_rows
7797 , temp_num_processed
7798 , temp_num_rejected
7799 , temp_outcome
7800 , temp_msg_application
7801 , temp_msg_type
7802 , temp_msg_token1
7803 , temp_msg_token2
7804 , temp_msg_token3
7805 , temp_msg_count
7806 , l_projfunc_currency_code
7807 , p_projfunc_cost_rate_type
7808 , p_projfunc_cost_rate_date
7809 , p_projfunc_cost_exchange_rate
7810 , p_assignment_id
7811 , p_work_type_id
7812 -- , p_cbs_element_id -- Added for CBS Enhancement Bug 16220146
7813 -- commented the above line as part of bug 16686195
7814 , p_dest_cbs_element_id -- Modified this parameter for Bug 16446988
7815 );
7816
7817 IF ( temp_outcome IS NOT NULL AND ( temp_msg_type = 'E' ) ) THEN /* Added msg_type check for Bug 4906816 */
7818 RAISE INVALID_ITEM;
7819 END IF;
7820 /** start proj currency changes **/
7821 ELSIF ( X_adj_action = 'CHANGE WORK TYPE ATTRIBUTE' ) THEN
7822
7823 IF P_DEBUG_MODE THEN
7824 print_message('get_denom_curr_code: ' || 'calling work_type_adjustment api');
7825 END IF;
7826 work_type_adjustment
7827 ( ItemsIdTab => ItemsIdTab
7828 --, AdjustsIdTab => AdjustsIdTab
7829 , p_billable => NULL
7830 , p_work_type_id =>p_work_type_id
7831 , p_adj_activity =>X_adj_action
7832 , p_user =>X_user
7833 , p_login =>X_login
7834 , p_module =>X_module
7835 , p_rows =>X_num_rows
7836 , p_TpAmtTypCodeTab => p_TpAmtTypCodeTab
7837 , p_dest_tp_amt_type_code => p_dest_tp_amt_type_code
7838 , x_status => temp_status);
7839
7840 IF P_DEBUG_MODE THEN
7841 print_message('get_denom_curr_code: ' || 'end of work type adjustment api');
7842 END IF;
7843
7844 CheckStatus( temp_status );
7845 temp_num_processed := X_num_rows ;
7846
7847 /** end proj currency changes **/
7848
7849 END IF;
7850
7851
7852 X_num_processed := temp_num_processed;
7853 X_num_rejected := temp_num_rejected;
7854 X_status := NULL;
7855
7856 EXCEPTION
7857 WHEN INVALID_ITEM THEN
7858 X_status := temp_outcome;
7859 WHEN RESOURCE_BUSY THEN
7860 X_status := 'PA_ALL_COULD_NOT_LOCK';
7861 WHEN OTHERS THEN
7862 X_status := SQLCODE;
7863 RAISE;
7864
7865 END MassAction;
7866
7867
7868 /*----------------------------------------------------------------------------
7869 -- See Package specs for detail comments for this ei_adjusted_in_cache.
7870 ----------------------------------------------------------------------------*/
7871 FUNCTION ei_adjusted_in_cache(X_exp_item_id In Number) RETURN Varchar2
7872 IS
7873 l_exp_item_id Number(15) := NULL;
7874
7875 BEGIN
7876
7877 l_exp_item_id := pa_adjustments.ExpAdjItemTab(X_exp_item_id);
7878 RETURN('Y');
7879
7880 EXCEPTION WHEN NO_DATA_FOUND THEN
7881 RETURN('N');
7882 WHEN OTHERS THEN
7883 raise;
7884 END ei_adjusted_in_cache;
7885
7886
7887 -- Fix for bug # 913353. in the decode for the project attributes
7888 -- replaced acct_rate_type etc with X_acct_rate_type
7889
7890 PROCEDURE ChangeFuncAttributes(ItemsIdTab IN pa_utils.IdTabTyp
7891 , X_adjust_level IN VARCHAR2
7892 , X_user IN NUMBER
7893 , X_login IN NUMBER
7894 , X_module IN VARCHAR2
7895 , X_acct_rate_type IN VARCHAR2
7896 , X_acct_rate_date IN DATE
7897 , X_acct_exchange_rate IN NUMBER
7898 , DenomCurrCodeTab IN pa_utils.Char15TabTyp
7899 , ProjCurrCodeTab IN pa_utils.Char15TabTyp
7900 , rows IN NUMBER
7901 , X_num_processed OUT NOCOPY NUMBER
7902 , X_num_rejected OUT NOCOPY NUMBER
7903 , X_status OUT NOCOPY NUMBER
7904 , ProjfuncCurrCodeTab IN pa_utils.Char15TabTyp ) IS
7905
7906 temp_status NUMBER DEFAULT NULL;
7907 item_count NUMBER := 0;
7908 failed_count NUMBER := 0 ;
7909 l_status VARCHAR2(240)DEFAULT NULL ;
7910 l_acct_exchange_rate NUMBER := X_acct_exchange_rate;
7911 l_acct_rate_type VARCHAR2(30) := X_acct_rate_type ;
7912 l_acct_rate_date DATE := X_acct_rate_date ;
7913 l_dummy1 NUMBER ;
7914 l_dummy2 NUMBER ;
7915 l_dummy3 NUMBER ;
7916
7917 -- pa_multi_currency.init ;
7918
7919 PROCEDURE RecalcRelatedItems( X_expenditure_item_id IN NUMBER
7920 , X_user IN NUMBER
7921 , X_login IN NUMBER
7922 , X_acct_rate_type IN VARCHAR2
7923 , X_acct_rate_date IN DATE
7924 , X_acct_exchange_rate IN NUMBER
7925 , X_project_currency_code IN VARCHAR2
7926 , X_module IN VARCHAR2
7927 , X_status OUT NOCOPY NUMBER
7928 , p_projfunc_currency_code IN VARCHAR2)
7929 IS
7930 CURSOR GetRelatedItems IS
7931 SELECT
7932 expenditure_item_id
7933 FROM
7934 pa_expenditure_items_all
7935 WHERE
7936 source_expenditure_item_id = X_expenditure_item_id;
7937 BEGIN
7938
7939 FOR eachRec IN GetRelatedItems LOOP
7940
7941 UPDATE pa_expenditure_items_all
7942 SET
7943 cost_distributed_flag = 'N'
7944 , revenue_distributed_flag = 'N'
7945 , rev_dist_rejection_code = NULL /*Added for bug:9367103 */
7946 , acct_rate_type = X_acct_rate_type
7947 , acct_rate_date = X_acct_rate_date
7948 , acct_exchange_rate = X_acct_exchange_rate
7949 , project_rate_type = DECODE(X_project_currency_code,
7950 pa_multi_currency.G_accounting_currency_code,
7951 X_acct_rate_type,project_rate_type )
7952 , project_rate_date = DECODE(X_project_currency_code,
7953 pa_multi_currency.G_accounting_currency_code,
7954 X_acct_rate_date, project_rate_date )
7955 , project_exchange_rate = DECODE(X_project_currency_code,
7956 pa_multi_currency.G_accounting_currency_code,
7957 X_acct_exchange_rate,project_exchange_rate )
7958 , acct_raw_cost = NULL
7959 , acct_burdened_cost = NULL
7960 , project_raw_cost = DECODE(X_project_currency_code,
7961 pa_multi_currency.G_accounting_currency_code, NULL, project_raw_cost )
7962 , project_burdened_cost = DECODE(X_project_currency_code,
7963 pa_multi_currency.G_accounting_currency_code, NULL,project_burdened_cost )
7964 , last_updated_by = X_user
7965 , last_update_date = sysdate
7966 , last_update_login = X_login
7967 , projfunc_cost_rate_type = DECODE(p_projfunc_currency_code,
7968 pa_multi_currency.G_accounting_currency_code,
7969 X_acct_rate_type,projfunc_cost_rate_type )
7970 , projfunc_cost_rate_date = DECODE(p_projfunc_currency_code,
7971 pa_multi_currency.G_accounting_currency_code,
7972 X_acct_rate_date, projfunc_cost_rate_date )
7973 , projfunc_cost_exchange_rate = DECODE(p_projfunc_currency_code,
7974 pa_multi_currency.G_accounting_currency_code,
7975 X_acct_exchange_rate,projfunc_cost_exchange_rate )
7976 , raw_cost = DECODE(p_projfunc_currency_code,
7977 pa_multi_currency.G_accounting_currency_code, NULL, raw_cost )
7978 , burden_cost = DECODE(p_projfunc_currency_code,
7979 pa_multi_currency.G_accounting_currency_code, NULL,burden_cost )
7980
7981 WHERE
7982 expenditure_item_id = eachRec.expenditure_item_id;
7983
7984 item_count := item_count + 1;
7985
7986 pa_adjustments.InsAuditRec( eachRec.expenditure_item_id
7987 , 'CHANGE FUNC ATTRIBUTE'
7988 , X_module
7989 , X_user
7990 , X_login
7991 , temp_status
7992 /* R12 Changes Start */
7993 , G_REQUEST_ID
7994 , G_PROGRAM_ID
7995 , G_PROG_APPL_ID
7996 , sysdate );
7997 /* R12 Changes End */
7998 CheckStatus( temp_status );
7999
8000 END LOOP;
8001
8002 X_status := 0;
8003
8004 EXCEPTION
8005 WHEN OTHERS THEN
8006 X_status := SQLCODE;
8007 RAISE;
8008
8009 END RecalcRelatedItems;
8010
8011
8012 BEGIN
8013
8014 IF P_DEBUG_MODE THEN
8015 print_message('get_denom_curr_code: ' || 'inside changefunccurrenc attri api');
8016 END IF;
8017 FOR i IN 1..rows LOOP
8018
8019 IF P_DEBUG_MODE THEN
8020 print_message('get_denom_curr_code: ' || 'DenomCurrCodeTab(i)['||DenomCurrCodeTab(i)||']ProjCurrCodeTab(i)['||ProjCurrCodeTab(i)||
8021 ']ProjfuncCurrCodeTab(i)['||ProjFuncCurrCodeTab(i) || ']' );
8022 END IF;
8023 pa_multi_currency.init ;
8024 IF X_adjust_level = 'S' THEN
8025
8026 IF P_DEBUG_MODE THEN
8027 print_message('get_denom_curr_code: ' || 'calling pa_multi currency api');
8028 END IF;
8029 pa_multi_currency.convert_amount( DenomCurrCodeTab(i)
8030 , pa_multi_currency.G_accounting_currency_code
8031 , l_acct_rate_date
8032 , l_acct_rate_type
8033 , null
8034 , 'Y'
8035 , 'Y'
8036 , l_dummy1
8037 , l_dummy2
8038 , l_dummy3
8039 , l_acct_exchange_rate
8040 , l_status ) ;
8041
8042 IF P_DEBUG_MODE THEN
8043 print_message('get_denom_curr_code: ' || 'l_acct_rate_date['||l_acct_rate_date||']l_acct_rate_type['||l_acct_rate_type
8044 ||']G_accounting_currency_code['||pa_multi_currency.G_accounting_currency_code
8045 ||']l_acct_exchange_rate['||l_acct_exchange_rate||']' );
8046 END IF;
8047 END IF ;
8048
8049 IF l_status is not null then
8050 failed_count := failed_count + 1 ;
8051 /* R12 Changes Start */
8052 InsAuditRec( ItemsIdTab(i)
8053 , 'CHANGE FUNC ATTRIBUTE'
8054 , X_module
8055 , X_user
8056 , X_login
8057 , temp_status
8058 , G_REQUEST_ID
8059 , G_PROGRAM_ID
8060 , G_PROG_APPL_ID
8061 , sysdate
8062 , l_status);
8063 CheckStatus(temp_status);
8064 /* R12 Changes End */
8065
8066 ELSE
8067
8068 UPDATE pa_expenditure_items_all ei
8069 SET
8070 ei.cost_distributed_flag = 'N'
8071 , ei.revenue_distributed_flag = 'N'
8072 , ei.rev_dist_rejection_code = NULL /*Added for bug:9367103 */
8073 , acct_rate_type = X_acct_rate_type
8074 , acct_rate_date = X_acct_rate_date
8075 , acct_exchange_rate = l_acct_exchange_rate
8076 , project_rate_type = DECODE(ProjCurrCodeTab(i),
8077 pa_multi_currency.G_accounting_currency_code,
8078 X_acct_rate_type, project_rate_type )
8079 , project_rate_date = DECODE(ProjCurrCodeTab(i),
8080 pa_multi_currency.G_accounting_currency_code,
8081 X_acct_rate_date, project_rate_date )
8082 , project_exchange_rate = DECODE(ProjCurrCodeTab(i),
8083 pa_multi_currency.G_accounting_currency_code,
8084 X_acct_exchange_rate , project_exchange_rate )
8085 , acct_raw_cost = NULL
8086 , acct_burdened_cost = NULL
8087 , project_raw_cost = DECODE(ProjCurrCodeTab(i),
8088 pa_multi_currency.G_accounting_currency_code, NULL, project_raw_cost )
8089 , project_burdened_cost = DECODE(ProjCurrCodeTab(i),
8090 pa_multi_currency.G_accounting_currency_code, NULL, project_burdened_cost )
8091 , ei.last_update_date = sysdate
8092 , ei.last_updated_by = X_user
8093 , ei.last_update_login = X_login
8094 , projfunc_cost_rate_type = DECODE(ProjFuncCurrCodeTab(i),
8095 pa_multi_currency.G_accounting_currency_code,
8096 X_acct_rate_type,projfunc_cost_rate_type )
8097 , projfunc_cost_rate_date = DECODE(ProjFuncCurrCodeTab(i),
8098 pa_multi_currency.G_accounting_currency_code,
8099 X_acct_rate_date, projfunc_cost_rate_date )
8100 , projfunc_cost_exchange_rate = DECODE(ProjFuncCurrCodeTab(i),
8101 pa_multi_currency.G_accounting_currency_code,
8102 X_acct_exchange_rate,projfunc_cost_exchange_rate )
8103 , raw_cost = DECODE(ProjFuncCurrCodeTab(i),
8104 pa_multi_currency.G_accounting_currency_code, NULL, raw_cost )
8105 , burden_cost = DECODE(ProjFuncCurrCodeTab(i),
8106 pa_multi_currency.G_accounting_currency_code, NULL,burden_cost )
8107 WHERE
8108 ei.expenditure_item_id = ItemsIdTab(i);
8109
8110 item_count := item_count + 1;
8111
8112 InsAuditRec( ItemsIdTab(i)
8113 , 'CHANGE FUNC ATTRIBUTE'
8114 , X_module
8115 , X_user
8116 , X_login
8117 , temp_status
8118 /* R12 Changes Start */
8119 , G_REQUEST_ID
8120 , G_PROGRAM_ID
8121 , G_PROG_APPL_ID
8122 , sysdate );
8123 /* R12 Changes End */
8124 CheckStatus( temp_status );
8125
8126 RecalcRelatedItems( ItemsIdTab(i)
8127 , X_user
8128 , X_login
8129 , X_acct_rate_type
8130 , X_acct_rate_date
8131 , l_acct_exchange_rate
8132 , ProjCurrCodeTab(i)
8133 , X_module
8134 , temp_status
8135 , ProjFuncCurrCodeTab(i));
8136 CheckStatus( temp_status );
8137
8138 END IF ;
8139 END LOOP;
8140
8141 X_status := 0;
8142 X_num_processed := item_count;
8143 X_num_rejected := failed_count ;
8144
8145 EXCEPTION
8146 WHEN OTHERS THEN
8147 X_status := SQLCODE;
8148 RAISE;
8149
8150 END ChangeFuncAttributes;
8151
8152 /** This api is newly added to convert / change the project functional currency attributes
8153 * this is called from EI enquiry form for EI adjustments
8154 */
8155 PROCEDURE ChangeProjFuncAttributes
8156 (ItemsIdTab IN pa_utils.IdTabTyp
8157 , p_adjust_level IN VARCHAR2
8158 , p_user IN NUMBER
8159 , p_login IN NUMBER
8160 , p_module IN VARCHAR2
8161 , p_projfunc_cost_rate_type IN VARCHAR2
8162 , p_projfunc_cost_rate_date IN DATE
8163 , p_projfunc_cost_exchg_rate IN NUMBER
8164 , p_DenomCurrCodeTab IN pa_utils.Char15TabTyp
8165 , p_ProjFuncCurrCodeTab IN pa_utils.Char15TabTyp
8166 , p_rows IN NUMBER
8167 , X_num_processed OUT NOCOPY NUMBER
8168 , X_num_rejected OUT NOCOPY NUMBER
8169 , X_status OUT NOCOPY NUMBER
8170 ) IS
8171
8172 temp_status NUMBER DEFAULT NULL;
8173 item_count NUMBER := 0;
8174 failed_count NUMBER := 0 ;
8175 l_status VARCHAR2(240)DEFAULT NULL ;
8176 l_projfunc_cost_exchg_rate NUMBER := p_projfunc_cost_exchg_rate;
8177 l_projfunc_cost_rate_type VARCHAR2(30) := p_projfunc_cost_rate_type;
8178 l_projfunc_cost_rate_date DATE := p_projfunc_cost_rate_date;
8179 l_dummy1 NUMBER ;
8180 l_dummy2 NUMBER ;
8181 l_dummy3 NUMBER ;
8182 PROCEDURE RecalcRelatedItems( X_expenditure_item_id IN NUMBER
8183 , X_user IN NUMBER
8184 , X_login IN NUMBER
8185 , X_projfunc_cost_rate_type IN VARCHAR2
8186 , X_projfunc_cost_rate_date IN DATE
8187 , X_projfunc_cost_exchg_rate IN NUMBER
8188 , X_projfunc_currency_code IN VARCHAR2
8189 , X_module IN VARCHAR2
8190 , X_status OUT NOCOPY NUMBER
8191 )
8192 IS
8193 CURSOR GetRelatedItems IS
8194 SELECT
8195 expenditure_item_id
8196 FROM
8197 pa_expenditure_items_all
8198 WHERE
8199 source_expenditure_item_id = X_expenditure_item_id;
8200 BEGIN
8201 FOR eachRec IN GetRelatedItems LOOP
8202
8203 UPDATE pa_expenditure_items_all
8204 SET
8205 cost_distributed_flag = 'N'
8206 , revenue_distributed_flag = 'N'
8207 , rev_dist_rejection_code = NULL /*Added for bug:9367103 */
8208 , projfunc_cost_rate_type = X_projfunc_cost_rate_type
8209 , projfunc_cost_rate_date = X_projfunc_cost_rate_date
8210 , projfunc_cost_exchange_rate =X_projfunc_cost_exchg_rate
8211 , raw_cost = NULL
8212 , burden_cost = NULL
8213 , acct_rate_type = DECODE(X_projfunc_currency_code,
8214 pa_multi_currency.G_accounting_currency_code,
8215 X_projfunc_cost_rate_type, acct_rate_type )
8216 , acct_rate_date = DECODE(X_projfunc_currency_code,
8217 pa_multi_currency.G_accounting_currency_code,
8218 X_projfunc_cost_rate_date , acct_rate_date )
8219 , acct_exchange_rate = DECODE(X_projfunc_currency_code,
8220 pa_multi_currency.G_accounting_currency_code,
8221 X_projfunc_cost_exchg_rate , acct_exchange_rate )
8222 , acct_raw_cost = DECODE(X_projfunc_currency_code,
8223 pa_multi_currency.G_accounting_currency_code,
8224 NULL, acct_raw_cost )
8225 , acct_burdened_cost = DECODE(X_projfunc_currency_code,
8226 pa_multi_currency.G_accounting_currency_code,
8227 NULL,acct_burdened_cost )
8228 /** added for project currency changes **/
8229 , project_rate_type = DECODE(x_projfunc_currency_code,project_currency_code,
8230 x_projfunc_cost_rate_type, project_rate_type )
8231 , project_rate_date = DECODE(x_projfunc_currency_code,project_currency_code,
8232 X_projfunc_cost_rate_date , project_rate_date )
8233 , project_exchange_rate = DECODE(x_projfunc_currency_code,project_currency_code,
8234 p_projfunc_cost_exchg_rate , project_exchange_rate )
8235 , project_raw_cost = DECODE(x_projfunc_currency_code,project_currency_code,
8236 NULL ,project_raw_cost)
8237 , project_burdened_cost = DECODE(x_projfunc_currency_code,project_currency_code,
8238 NULL,project_burdened_cost)
8239 /** end of changes **/
8240 , last_updated_by = X_user
8241 , last_update_date = sysdate
8242 , last_update_login = X_login
8243 WHERE
8244 expenditure_item_id = eachRec.expenditure_item_id;
8245
8246 item_count := item_count + 1;
8247
8248 pa_adjustments.InsAuditRec( eachRec.expenditure_item_id
8249 , 'CHANGE PROJ FUNC ATTRIBUTE'
8250 , X_module
8251 , X_user
8252 , X_login
8253 , temp_status
8254 /* R12 Changes Start */
8255 , G_REQUEST_ID
8256 , G_PROGRAM_ID
8257 , G_PROG_APPL_ID
8258 , sysdate );
8259 /* R12 Changes End */
8260 CheckStatus( temp_status );
8261
8262 END LOOP;
8263
8264 X_status := 0;
8265
8266 EXCEPTION
8267 WHEN OTHERS THEN
8268 X_status := SQLCODE;
8269 RAISE;
8270
8271 END RecalcRelatedItems;
8272 BEGIN
8273 FOR i IN 1..p_rows LOOP
8274
8275 IF P_DEBUG_MODE THEN
8276 print_message('get_denom_curr_code: ' || 'Inside the ProjFuncCurrCode api p_DenomCurrCodeTab(i)['||p_DenomCurrCodeTab(i)||
8277 ']p_ProjFuncCurrCodeTab(i)['||p_ProjFuncCurrCodeTab(i)||']l_projfunc_cost_rate_date['
8278 ||l_projfunc_cost_rate_date||']l_projfunc_cost_rate_type['||l_projfunc_cost_rate_type||']' );
8279 END IF;
8280
8281 pa_multi_currency.init ;
8282 IF p_adjust_level = 'S' THEN
8283 IF P_DEBUG_MODE THEN
8284 print_message('get_denom_curr_code: ' || 'calling pa_multi_currency api');
8285 END IF;
8286 pa_multi_currency.convert_amount( p_DenomCurrCodeTab(i)
8287 ,p_ProjFuncCurrCodeTab(i)
8288 , l_projfunc_cost_rate_date
8289 , l_projfunc_cost_rate_type
8290 , null
8291 , 'Y'
8292 , 'Y'
8293 , l_dummy1
8294 , l_dummy2
8295 , l_dummy3
8296 , l_projfunc_cost_exchg_rate
8297 , l_status ) ;
8298
8299 IF P_DEBUG_MODE THEN
8300 print_message('get_denom_curr_code: ' || 'l_projfunc_cost_exchg_rate['||l_projfunc_cost_exchg_rate||']l_projfunc_cost_rate_date['
8301 ||l_projfunc_cost_rate_date||']l_projfunc_cost_rate_type['||l_projfunc_cost_rate_type||']' );
8302 END IF;
8303 END IF ;
8304
8305 IF l_status is not null then
8306 failed_count := failed_count + 1 ;
8307 /* R12 Changes Start */
8308 InsAuditRec( ItemsIdTab(i)
8309 , 'CHANGE FUNC ATTRIBUTE'
8310 , p_module
8311 , p_user
8312 , p_login
8313 , temp_status
8314 , G_REQUEST_ID
8315 , G_PROGRAM_ID
8316 , G_PROG_APPL_ID
8317 , sysdate
8318 , l_status);
8319 CheckStatus(temp_status);
8320 /* R12 Changes End */
8321
8322 ELSE
8323 UPDATE pa_expenditure_items_all ei
8324 SET
8325 ei.cost_distributed_flag = 'N'
8326 , ei.revenue_distributed_flag = 'N'
8327 , ei.rev_dist_rejection_code = NULL /*Added for bug:9367103 */
8328 , projfunc_cost_rate_type = p_projfunc_cost_rate_type
8329 , projfunc_cost_rate_date = p_projfunc_cost_rate_date
8330 , projfunc_cost_exchange_rate = l_projfunc_cost_exchg_rate
8331 , raw_cost = NULL
8332 , burden_cost = NULL
8333 , acct_rate_type = DECODE(p_ProjFuncCurrCodeTab(i),
8334 pa_multi_currency.G_accounting_currency_code,
8335 p_projfunc_cost_rate_type, acct_rate_type )
8336 , acct_rate_date = DECODE(p_ProjFuncCurrCodeTab(i),
8337 pa_multi_currency.G_accounting_currency_code,
8338 p_projfunc_cost_rate_date , acct_rate_date )
8339 , acct_exchange_rate = DECODE(p_ProjFuncCurrCodeTab(i),
8340 pa_multi_currency.G_accounting_currency_code,
8341 l_projfunc_cost_exchg_rate , acct_exchange_rate )
8342 , acct_raw_cost = DECODE(p_ProjFuncCurrCodeTab(i),
8343 pa_multi_currency.G_accounting_currency_code,
8344 NULL, acct_raw_cost )
8345 , acct_burdened_cost = DECODE(p_ProjFuncCurrCodeTab(i),
8346 pa_multi_currency.G_accounting_currency_code,
8347 NULL,acct_burdened_cost )
8348 /** added for project currency changes **/
8349 , project_rate_type = DECODE(p_ProjFuncCurrCodeTab(i), project_currency_code,
8350 p_projfunc_cost_rate_type, project_rate_type )
8351 , project_rate_date = DECODE(p_ProjFuncCurrCodeTab(i), project_currency_code,
8352 p_projfunc_cost_rate_date , project_rate_date )
8353 , project_exchange_rate = DECODE(p_ProjFuncCurrCodeTab(i), project_currency_code,
8354 l_projfunc_cost_exchg_rate , project_exchange_rate )
8355 , project_raw_cost = DECODE(p_ProjFuncCurrCodeTab(i), project_currency_code,
8356 NULL ,project_raw_cost)
8357 , project_burdened_cost = DECODE(p_ProjFuncCurrCodeTab(i), project_currency_code,
8358 NULL,project_burdened_cost)
8359 /** end of changes **/
8360 , ei.last_update_date = sysdate
8361 , ei.last_updated_by = p_user
8362 , ei.last_update_login = p_login
8363 WHERE
8364 ei.expenditure_item_id = ItemsIdTab(i);
8365
8366 IF P_DEBUG_MODE THEN
8367 print_message('get_denom_curr_code: ' || 'Num of rows update for eis ='||sql%rowcount);
8368 END IF;
8369 item_count := item_count + 1;
8370 InsAuditRec( ItemsIdTab(i)
8371 , 'CHANGE PROJ FUNC ATTRIBUTE'
8372 , p_module
8373 , p_user
8374 , p_login
8375 , temp_status
8376 /* R12 Changes Start */
8377 , G_REQUEST_ID
8378 , G_PROGRAM_ID
8379 , G_PROG_APPL_ID
8380 , sysdate);
8381 /* R12 Changes End */
8382 CheckStatus( temp_status );
8383
8384 IF P_DEBUG_MODE THEN
8385 print_message('get_denom_curr_code: ' || 'calling RecalcRelatedItems items ');
8386 END IF;
8387
8388 RecalcRelatedItems( ItemsIdTab(i)
8389 , p_user
8390 , p_login
8391 , p_projfunc_cost_rate_type
8392 , p_projfunc_cost_rate_date
8393 , l_projfunc_cost_exchg_rate
8394 , p_ProjFuncCurrCodeTab(i)
8395 , p_module
8396 , temp_status );
8397 CheckStatus( temp_status );
8398
8399 END IF;
8400 END LOOP;
8401
8402 X_status := 0;
8403 X_num_processed := item_count;
8404 X_num_rejected := failed_count ;
8405
8406 EXCEPTION
8407 WHEN OTHERS THEN
8408 X_status := SQLCODE;
8409 RAISE;
8410
8411 END ChangeProjFuncAttributes;
8412
8413 /** This api update the EI table when project curenncy attributes are changed **/
8414
8415 PROCEDURE ChangeProjAttributes(ItemsIdTab IN pa_utils.IdTabTyp
8416 , X_adjust_level IN VARCHAR2
8417 , X_user IN NUMBER
8418 , X_login IN NUMBER
8419 , X_module IN VARCHAR2
8420 , X_project_rate_type IN VARCHAR2
8421 , X_project_rate_date IN DATE
8422 , X_project_exchange_rate IN NUMBER
8423 , DenomCurrCodeTab IN pa_utils.Char15TabTyp
8424 , ProjCurrCodeTab IN pa_utils.Char15TabTyp
8425 , rows IN NUMBER
8426 , X_num_processed OUT NOCOPY NUMBER
8427 , X_num_rejected OUT NOCOPY NUMBER
8428 , X_status OUT NOCOPY NUMBER ) IS
8429
8430 temp_status NUMBER DEFAULT NULL;
8431 item_count NUMBER := 0;
8432 failed_count NUMBER := 0 ;
8433 l_status VARCHAR2(240)DEFAULT NULL ;
8434 l_project_exchange_rate NUMBER := X_project_exchange_rate;
8435 l_project_rate_type VARCHAR2(30) := X_project_rate_type ;
8436 l_project_rate_date DATE := X_project_rate_date ;
8437 l_dummy1 NUMBER ;
8438 l_dummy2 NUMBER ;
8439 l_dummy3 NUMBER ;
8440
8441 -- pa_multi_currency.init ;
8442
8443 PROCEDURE RecalcRelatedItems( X_expenditure_item_id IN NUMBER
8444 , X_user IN NUMBER
8445 , X_login IN NUMBER
8446 , X_project_rate_type IN VARCHAR2
8447 , X_project_rate_date IN DATE
8448 , X_project_exchange_rate IN NUMBER
8449 , X_project_currency_code IN VARCHAR2
8450 , X_module IN VARCHAR2
8451 , X_status OUT NOCOPY NUMBER )
8452 IS
8453 CURSOR GetRelatedItems IS
8454 SELECT
8455 expenditure_item_id
8456 FROM
8457 pa_expenditure_items_all
8458 WHERE
8459 source_expenditure_item_id = X_expenditure_item_id;
8460 BEGIN
8461
8462 FOR eachRec IN GetRelatedItems LOOP
8463
8464 UPDATE pa_expenditure_items_all
8465 SET
8466 cost_distributed_flag = 'N'
8467 , revenue_distributed_flag = 'N'
8468 , rev_dist_rejection_code = NULL /*Added for bug:9367103 */
8469 , project_rate_type = X_project_rate_type
8470 , project_rate_date = X_project_rate_date
8471 , project_exchange_rate = X_project_exchange_rate
8472 , acct_rate_type = DECODE(X_project_currency_code,
8473 pa_multi_currency.G_accounting_currency_code,
8474 X_project_rate_type, acct_rate_type )
8475 , acct_rate_date = DECODE(X_project_currency_code,
8476 pa_multi_currency.G_accounting_currency_code,
8477 X_project_rate_date, acct_rate_date )
8478 , acct_exchange_rate = DECODE(X_project_currency_code,
8479 pa_multi_currency.G_accounting_currency_code,
8480 X_project_exchange_rate , acct_exchange_rate )
8481 , project_raw_cost = NULL
8482 , project_burdened_cost = NULL
8483 , acct_raw_cost = DECODE(X_project_currency_code,
8484 pa_multi_currency.G_accounting_currency_code,
8485 NULL, acct_raw_cost )
8486 , acct_burdened_cost = DECODE(X_project_currency_code,
8487 pa_multi_currency.G_accounting_currency_code,
8488 NULL,acct_burdened_cost )
8489 , last_updated_by = X_user
8490 , last_update_date = sysdate
8491 , last_update_login = X_login
8492 WHERE
8493 expenditure_item_id = eachRec.expenditure_item_id;
8494
8495 item_count := item_count + 1;
8496
8497 pa_adjustments.InsAuditRec( eachRec.expenditure_item_id
8498 , 'CHANGE PROJ ATTRIBUTE'
8499 , X_module
8500 , X_user
8501 , X_login
8502 , temp_status
8503 /* R12 Changes Start */
8504 , G_REQUEST_ID
8505 , G_PROGRAM_ID
8506 , G_PROG_APPL_ID
8507 , sysdate );
8508 /* R12 Changes End */
8509 CheckStatus( temp_status );
8510
8511 END LOOP;
8512
8513 X_status := 0;
8514
8515 EXCEPTION
8516 WHEN OTHERS THEN
8517 X_status := SQLCODE;
8518 RAISE;
8519
8520 END RecalcRelatedItems;
8521
8522 BEGIN
8523 FOR i IN 1..rows LOOP
8524
8525 pa_multi_currency.init ;
8526 IF X_adjust_level = 'S' THEN
8527 pa_multi_currency.convert_amount( DenomCurrCodeTab(i)
8528 ,ProjCurrCodeTab(i)
8529 , l_project_rate_date
8530 , l_project_rate_type
8531 , null
8532 , 'Y'
8533 , 'Y'
8534 , l_dummy1
8535 , l_dummy2
8536 , l_dummy3
8537 , l_project_exchange_rate
8538 , l_status ) ;
8539 END IF ;
8540
8541 IF l_status is not null then
8542 failed_count := failed_count + 1 ;
8543 /* R12 Changes Start */
8544 InsAuditRec( ItemsIdTab(i)
8545 , 'CHANGE FUNC ATTRIBUTE'
8546 , X_module
8547 , X_user
8548 , X_login
8549 , temp_status
8550 , G_REQUEST_ID
8551 , G_PROGRAM_ID
8552 , G_PROG_APPL_ID
8553 , sysdate
8554 , l_status);
8555 CheckStatus(temp_status);
8556 /* R12 Changes End */
8557 ELSE
8558
8559 UPDATE pa_expenditure_items_all ei
8560 SET
8561 ei.cost_distributed_flag = 'N'
8562 , ei.revenue_distributed_flag = 'N'
8563 , ei.rev_dist_rejection_code = NULL /*Added for bug:9367103 */
8564 , project_rate_type = X_project_rate_type
8565 , project_rate_date = X_project_rate_date
8566 , project_exchange_rate = l_project_exchange_rate
8567 , acct_rate_type = DECODE(ProjCurrCodeTab(i),
8568 pa_multi_currency.G_accounting_currency_code,
8569 X_project_rate_type, acct_rate_type )
8570 , acct_rate_date = DECODE(ProjCurrCodeTab(i),
8571 pa_multi_currency.G_accounting_currency_code,
8572 X_project_rate_date , acct_rate_date )
8573 , acct_exchange_rate = DECODE(ProjCurrCodeTab(i),
8574 pa_multi_currency.G_accounting_currency_code,
8575 X_project_exchange_rate , acct_exchange_rate )
8576 , project_raw_cost = NULL
8577 , project_burdened_cost = NULL
8578 , acct_raw_cost = DECODE(ProjCurrCodeTab(i),
8579 pa_multi_currency.G_accounting_currency_code,
8580 NULL, acct_raw_cost )
8581 , acct_burdened_cost = DECODE(ProjCurrCodeTab(i),
8582 pa_multi_currency.G_accounting_currency_code,
8583 NULL,acct_burdened_cost )
8584 , ei.last_update_date = sysdate
8585 , ei.last_updated_by = X_user
8586 , ei.last_update_login = X_login
8587 WHERE
8588 ei.expenditure_item_id = ItemsIdTab(i);
8589
8590 item_count := item_count + 1;
8591 InsAuditRec( ItemsIdTab(i)
8592 , 'CHANGE PROJ ATTRIBUTE'
8593 , X_module
8594 , X_user
8595 , X_login
8596 , temp_status
8597 /* R12 Changes Start */
8598 , G_REQUEST_ID
8599 , G_PROGRAM_ID
8600 , G_PROG_APPL_ID
8601 , sysdate );
8602 /* R12 Changes End */
8603 CheckStatus( temp_status );
8604
8605 RecalcRelatedItems( ItemsIdTab(i)
8606 , X_user
8607 , X_login
8608 , X_project_rate_type
8609 , X_project_rate_date
8610 , l_project_exchange_rate
8611 , ProjCurrCodeTab(i)
8612 , X_module
8613 , temp_status );
8614 CheckStatus( temp_status );
8615
8616 END IF;
8617 END LOOP;
8618
8619 X_status := 0;
8620 X_num_processed := item_count;
8621 X_num_rejected := failed_count ;
8622
8623 EXCEPTION
8624 WHEN OTHERS THEN
8625 X_status := SQLCODE;
8626 RAISE;
8627
8628 END ChangeProjAttributes;
8629
8630 -- New procedure for the Cross Charge Adjustments
8631
8632 PROCEDURE ReprocessCrossCharge(ItemsIdTab IN pa_utils.IdTabTyp
8633 , X_adjust_level IN VARCHAR2
8634 , X_user IN NUMBER
8635 , X_login IN NUMBER
8636 , X_module IN VARCHAR2
8637 , X_cc_code IN VARCHAR2
8638 , X_cc_type IN VARCHAR2
8639 , X_bl_dist_code IN VARCHAR2
8640 , X_ic_proc_code IN VARCHAR2
8641 , X_prvdr_orgnzn_id IN NUMBER
8642 , X_recvr_orgnzn_id IN NUMBER
8643 , rows IN NUMBER
8644 , X_num_processed OUT NOCOPY NUMBER
8645 , X_status OUT NOCOPY NUMBER ) IS
8646
8647 temp_status NUMBER DEFAULT NULL;
8648 item_count NUMBER := 0;
8649 l_project_id NUMBER;
8650 l_task_id NUMBER;
8651 l_expenditure_item_date DATE;
8652 l_expenditure_type VARCHAR2(30);
8653 l_incurred_by_person_id NUMBER;
8654 l_system_linkage_function VARCHAR2(30);
8655 l_transaction_source VARCHAR2(30);
8656 l_nlr_organization_id NUMBER;
8657 l_cc_code_old VARCHAR2(1):= NULL;
8658 l_cc_code VARCHAR2(1):= NULL;
8659 l_bl_dist_code VARCHAR2(1):= NULL;
8660 l_ic_proc_code VARCHAR2(1):= NULL;
8661 l_Status VARCHAR2(10);
8662 l_cc_Type VARCHAR2(2):= NULL;
8663 l_PrvdrOrganizationId NUMBER := NULL;
8664 l_RecvrOrganizationId NUMBER := NULL;
8665 l_RecvrOrgId NUMBER;
8666 l_Error_Stage VARCHAR2(10);
8667 l_Error_Code NUMBER;
8668 /*bug12983087 */
8669 l_parent_cdf pa_expenditure_items_all.cost_distributed_flag%TYPE;
8670 l_parent_Cc_Code pa_expenditure_items_all.CC_CROSS_CHARGE_CODE%TYPE;
8671 l_parent_CCharge_Type pa_expenditure_items_all.Cc_Cross_Charge_Type%TYPE;
8672 l_parent_Cc_Prvdr_Org_Id pa_expenditure_items_all.Cc_Prvdr_Organization_Id%TYPE;
8673 l_parent_Cc_Recvr_Org_Id pa_expenditure_items_all.Cc_Recvr_Organization_Id%TYPE;
8674 /*bug12983087 */
8675 PROCEDURE RecalcRelatedItems( X_expenditure_item_id IN NUMBER
8676 , X_user IN NUMBER
8677 , X_login IN NUMBER
8678 , X_module IN VARCHAR2
8679 , X_status OUT NOCOPY NUMBER )
8680 IS
8681 l_parent_cdf pa_expenditure_items_all.cost_distributed_flag%TYPE;
8682
8683 CURSOR GetRelatedItems IS
8684 SELECT
8685 expenditure_item_id
8686 FROM
8687 pa_expenditure_items_all
8688 WHERE
8689 source_expenditure_item_id = X_expenditure_item_id;
8690 /* Modified the update statement not to derive cc_* fields if parent Ei is cost distributed bug 12983087 */
8691 BEGIN
8692
8693 FOR eachRec IN GetRelatedItems LOOP
8694
8695 BEGIN
8696 select ei1.cost_distributed_flag,ei1.Cc_Cross_Charge_Type,
8697 ei1.Cc_Prvdr_Organization_Id,ei1.Cc_Recvr_Organization_Id,
8698 ei1.Recvr_Org_Id,ei1.CC_CROSS_CHARGE_CODE
8699 into
8700 l_parent_cdf,l_parent_CCharge_Type,
8701 l_parent_Cc_Prvdr_Org_Id,l_parent_Cc_Recvr_Org_Id,
8702 l_parent_Cc_Recvr_Org_Id,l_parent_Cc_Code
8703 from
8704 pa_expenditure_items_all ei1,pa_expenditure_items_all ei2
8705 where ei1.expenditure_item_id = ei2.adjusted_expenditure_item_id and
8706 ei2.expenditure_item_id = eachRec.expenditure_item_id;
8707 EXCEPTION
8708 WHEN NO_DATA_FOUND THEN
8709 l_parent_cdf := 'N';
8710 WHEN OTHERS THEN
8711 l_parent_cdf := 'N';
8712 end;
8713
8714 UPDATE pa_expenditure_items_all
8715 SET
8716 cc_cross_charge_code =DECODE(l_parent_cdf,'Y',l_parent_Cc_Code,DECODE(X_adjust_level,'I', X_cc_code, l_cc_code))
8717 , cc_cross_charge_type = DECODE(l_parent_cdf,'Y',l_parent_CCharge_Type,DECODE(X_adjust_level,'I',X_cc_type, l_cc_type))
8718 , cc_bl_distributed_code = DECODE(l_parent_cdf,'Y','N',DECODE(X_adjust_level,'I',X_bl_dist_code,l_bl_dist_code))
8719 , cc_ic_processed_code = DECODE(l_parent_cdf,'Y','N',DECODE(X_adjust_level,'I',X_ic_proc_code,l_ic_proc_code))
8720 , cc_prvdr_organization_id = DECODE(l_parent_cdf,'Y',l_parent_Cc_Prvdr_Org_Id,DECODE(X_adjust_level,'I',X_prvdr_orgnzn_id,l_PrvdrOrganizationId))
8721 , cc_recvr_organization_id = DECODE(l_parent_cdf,'Y',l_parent_Cc_Recvr_Org_Id,DECODE(X_adjust_level,'I',X_recvr_orgnzn_id,l_RecvrOrganizationId))
8722 , denom_tp_currency_code = NULL
8723 , acct_tp_rate_type = NULL
8724 , acct_tp_rate_date = NULL
8725 , acct_tp_exchange_rate = NULL
8726 , denom_transfer_price = NULL
8727 , acct_transfer_price = NULL
8728 , projacct_transfer_price = NULL
8729 , cc_markup_base_code= NULL
8730 , tp_base_amount = NULL
8731 , tp_ind_compiled_set_id = NULL
8732 , tp_bill_rate = NULL
8733 , tp_bill_markup_percentage = NULL
8734 , tp_schedule_line_percentage = NULL
8735 , tp_rule_percentage = NULL
8736 , last_updated_by = X_user
8737 , last_update_date = sysdate
8738 , last_update_login = X_login
8739 , PROJECT_TP_RATE_DATE = null
8740 , PROJECT_TP_RATE_TYPE = null
8741 , PROJECT_TP_EXCHANGE_RATE = null
8742 , PROJECT_TRANSFER_PRICE = null
8743 , PROJFUNC_TP_RATE_DATE = null
8744 , PROJFUNC_TP_RATE_TYPE = null
8745 , PROJFUNC_TP_EXCHANGE_RATE = null
8746 , PROJFUNC_TRANSFER_PRICE = null
8747 WHERE
8748 expenditure_item_id = eachRec.expenditure_item_id;
8749
8750 l_parent_CCharge_Type :=NULL;
8751 l_parent_Cc_Prvdr_Org_Id := NULL;l_parent_Cc_Recvr_Org_Id:= NULL;
8752 l_parent_Cc_Code:=NULL;
8753
8754 item_count := item_count + 1;
8755
8756 pa_adjustments.InsAuditRec( eachRec.expenditure_item_id
8757 , 'REPROCESS CROSS CHARGE'
8758 , X_module
8759 , X_user
8760 , X_login
8761 , temp_status
8762 /* R12 Changes Start */
8763 , G_REQUEST_ID
8764 , G_PROGRAM_ID
8765 , G_PROG_APPL_ID
8766 , sysdate );
8767 /* R12 Changes End */
8768 CheckStatus( temp_status );
8769
8770 END LOOP;
8771
8772 X_status := 0;
8773
8774 EXCEPTION
8775 WHEN OTHERS THEN
8776 X_status := SQLCODE;
8777 RAISE;
8778
8779 END RecalcRelatedItems;
8780
8781
8782 BEGIN
8783
8784 FOR i IN 1..rows LOOP
8785 IF X_adjust_level = 'S' THEN
8786
8787 -- Decided to fetch the columns needed for passing to the identification
8788 -- API during the MassAdjust select instead of writing a separate
8789 -- select here for performance reasons. We are storing the values fetched
8790 -- in global variables instead of passing as parameters to this procedure
8791 -- as the code was already complete and decided not to add more parameter
8792 -- which would require re testing
8793
8794 IF P_DEBUG_MODE THEN
8795 print_message('get_denom_curr_code: ' || 'before call to CC API, exp item is ['||to_char(ItemsIdTab(i))||']expdateis[ '
8796 ||to_char(ExpItemDateTab(i))||']exp org['||to_char(ExpOrganizationTab(i))||']OU[ '||to_char(ExpOrgTab(i))
8797 ||']exp type[ '||ExpTypeTab(i)||']' );
8798 END IF;
8799
8800 pa_cc_ident.pa_cc_identify_txn_adj(ExpOrganizationTab(i),
8801 ExpOrgTab(i),
8802 null,
8803 TaskIdTab(i),
8804 ExpItemDateTab(i),
8805 ItemsIdTab(i),
8806 ExpTypeTab(i),
8807 IncurredByPersonIdTab(i),
8808 SysLinkageTab(i),
8809 NULL, -- proj organization id
8810 null, -- PrjOrgId,
8811 TrxSourceTab(i),
8812 NlrOrganizationIdTab(i),
8813 null, -- PrvdrLEId
8814 null, -- RecvrLEId
8815 l_Status,
8816 l_cc_Type,
8817 l_cc_Code,
8818 l_PrvdrOrganizationId,
8819 l_RecvrOrganizationId,
8820 l_RecvrOrgId,
8821 l_Error_Stage,
8822 l_Error_Code,
8823 X_Calling_Module => null /* Modified for 3234973 */);
8824
8825 l_cc_code_old := CrossChargeCodeTab(i) ;
8826
8827 print_message('Before setting l_cc_code_old['||l_cc_code_old||']l_cc_code['||l_cc_code||']');
8828
8829 if l_cc_code_old in ( 'N', 'X', 'P') /* Bug 4732956 */
8830 and l_cc_code = 'I' THEN
8831 l_ic_proc_code := 'N';
8832 l_bl_dist_code := 'X' ;
8833 elsif l_cc_code_old in ( 'N', 'X', 'P') /* Bug 4732956 */
8834 and l_cc_code = 'B' THEN
8835 /* Bug fix: 3065461 setting the bl_dist_code to N instead of X for reprocess CC items
8836 * when adjustment like No Process cross charge done first and then reporcess cross charge is made
8837 --l_ic_proc_code := 'N';
8838 --l_bl_dist_code := 'X' ;
8839 */
8840 l_ic_proc_code := 'X';
8841 l_bl_dist_code := 'N' ;
8842 /* end of bug fix:3065461 */
8843 elsif l_cc_code_old = 'B'
8844 and l_cc_code = 'I' THEN
8845 l_ic_proc_code := 'N';
8846 l_bl_dist_code := 'N' ;
8847 elsif l_cc_code_old = 'B'
8848 and l_cc_code in ( 'N', 'X') THEN
8849 l_ic_proc_code := 'X';
8850 l_bl_dist_code := 'N' ;
8851 elsif l_cc_code_old = 'I'
8852 and l_cc_code in ( 'N', 'X') THEN
8853 l_ic_proc_code := 'N';
8854 l_bl_dist_code := 'X' ;
8855 /* Bug 4732956 - Start */
8856 elsif l_cc_code_old = 'P'
8857 and l_cc_code in ('N','X') THEN
8858 l_ic_proc_code := 'X';
8859 l_bl_dist_code := 'X' ;
8860 /* Bug 4732956 - End */
8861 elsif l_cc_code_old = 'I'
8862 and l_cc_code = 'B' THEN
8863 l_ic_proc_code := 'N';
8864 l_bl_dist_code := 'N' ;
8865 elsif l_cc_code_old = l_cc_code and
8866 l_cc_code_old = 'B' then
8867 -- This means that the cc code and/or the cc type has not changed
8868 -- but the user wants to do a reprocess CC , maybe in order to
8869 -- recalculate the TP amounts again. Hence, in this case, we
8870 -- set the appropriate flag to 'N'
8871 l_ic_proc_code := 'X';
8872 l_bl_dist_code := 'N' ;
8873 elsif l_cc_code_old = l_cc_code and
8874 l_cc_code_old = 'I' then
8875 l_ic_proc_code := 'N';
8876 l_bl_dist_code := 'X' ;
8877 /*** Bug 2215272 change the if condition
8878 *** elsif l_cc_code_old = l_cc_code and **/
8879 elsif l_cc_code in ('N','X') and
8880 l_cc_code_old in ('N', 'X') then
8881 l_ic_proc_code := 'X';
8882 l_bl_dist_code := 'X' ;
8883 end if;
8884 END IF;
8885
8886 print_message('After setting l_ic_proc_code ['||l_ic_proc_code||']l_bl_dist_code['||l_bl_dist_code||
8887 ']X_cc_code['||X_cc_code||']X_cc_type['||X_cc_type||']X_bl_dist_code['||X_bl_dist_code||
8888 ']X_ic_proc_code['||X_ic_proc_code||']X_prvdr_orgnzn_id['||X_prvdr_orgnzn_id||
8889 ']X_recvr_orgnzn_id['||X_recvr_orgnzn_id||']l_PrvdrOrganizationId['||l_PrvdrOrganizationId||
8890 ']l_RecvrOrganizationId['||l_RecvrOrganizationId||']');
8891
8892 /* Modified the update statement not to derive cc_* fields if parent Ei is cost distributed bug 12983087 */
8893
8894 BEGIN
8895 select ei1.cost_distributed_flag,ei1.Cc_Cross_Charge_Type,
8896 ei1.Cc_Prvdr_Organization_Id,ei1.Cc_Recvr_Organization_Id,
8897 ei1.CC_CROSS_CHARGE_CODE
8898 into
8899 l_parent_cdf,l_parent_CCharge_Type,
8900 l_parent_Cc_Prvdr_Org_Id,l_parent_Cc_Recvr_Org_Id,
8901 l_parent_Cc_Code
8902 from
8903 pa_expenditure_items_all ei1,pa_expenditure_items_all ei2
8904 where ei1.expenditure_item_id = ei2.adjusted_expenditure_item_id and
8905 ei2.expenditure_item_id = ItemsIdTab(i);
8906 EXCEPTION
8907 WHEN NO_DATA_FOUND THEN
8908 l_parent_cdf := 'N';
8909 WHEN OTHERS THEN
8910 l_parent_cdf := 'N';
8911 end;
8912
8913 UPDATE pa_expenditure_items_all
8914 SET
8915 cc_cross_charge_code =DECODE(l_parent_cdf,'Y',l_parent_Cc_Code,DECODE(X_adjust_level,'I', X_cc_code, l_cc_code))
8916 , cc_cross_charge_type = DECODE(l_parent_cdf,'Y',l_parent_CCharge_Type,DECODE(X_adjust_level,'I',X_cc_type, l_cc_type))
8917 , cc_bl_distributed_code = DECODE(l_parent_cdf,'Y','N',DECODE(X_adjust_level,'I',X_bl_dist_code,l_bl_dist_code))
8918 , cc_ic_processed_code = DECODE(l_parent_cdf,'Y','N',DECODE(X_adjust_level,'I',X_ic_proc_code,l_ic_proc_code))
8919 , cc_prvdr_organization_id = DECODE(l_parent_cdf,'Y',l_parent_Cc_Prvdr_Org_Id,DECODE(X_adjust_level,'I',X_prvdr_orgnzn_id,l_PrvdrOrganizationId))
8920 , cc_recvr_organization_id = DECODE(l_parent_cdf,'Y',l_parent_Cc_Recvr_Org_Id,DECODE(X_adjust_level,'I',X_recvr_orgnzn_id,l_RecvrOrganizationId))
8921 , denom_tp_currency_code = NULL
8922 , acct_tp_rate_type = NULL
8923 , acct_tp_rate_date = NULL
8924 , acct_tp_exchange_rate = NULL
8925 , denom_transfer_price = NULL
8926 , acct_transfer_price = NULL
8927 , projacct_transfer_price = NULL
8928 , cc_markup_base_code= NULL
8929 , tp_base_amount = NULL
8930 , tp_ind_compiled_set_id = NULL
8931 , tp_bill_rate = NULL
8932 , tp_bill_markup_percentage = NULL
8933 , tp_schedule_line_percentage = NULL
8934 , tp_rule_percentage = NULL
8935 , last_updated_by = X_user
8936 , last_update_date = sysdate
8937 , last_update_login = X_login
8938 , PROJECT_TP_RATE_DATE = null
8939 , PROJECT_TP_RATE_TYPE = null
8940 , PROJECT_TP_EXCHANGE_RATE = null
8941 , PROJECT_TRANSFER_PRICE = null
8942 , PROJFUNC_TP_RATE_DATE = null
8943 , PROJFUNC_TP_RATE_TYPE = null
8944 , PROJFUNC_TP_EXCHANGE_RATE = null
8945 , PROJFUNC_TRANSFER_PRICE = null
8946 WHERE
8947 expenditure_item_id = ItemsIdTab(i);
8948
8949 l_parent_CCharge_Type :=NULL;
8950 l_parent_Cc_Prvdr_Org_Id := NULL;l_parent_Cc_Recvr_Org_Id:= NULL;
8951 l_parent_Cc_Code:=NULL;
8952
8953 item_count := item_count + 1;
8954
8955 InsAuditRec( ItemsIdTab(i)
8956 , 'REPROCESS CROSS CHARGE'
8957 , X_module
8958 , X_user
8959 , X_login
8960 , temp_status
8961 /* R12 Changes Start */
8962 , G_REQUEST_ID
8963 , G_PROGRAM_ID
8964 , G_PROG_APPL_ID
8965 , sysdate );
8966 /* R12 Changes End */
8967 CheckStatus( temp_status );
8968
8969
8970 RecalcRelatedItems( ItemsIdTab(i)
8971 , X_user
8972 , X_login
8973 , X_module
8974 , temp_status );
8975 CheckStatus( temp_status );
8976
8977 END LOOP;
8978
8979 X_status := 0;
8980 X_num_processed := item_count;
8981
8982 EXCEPTION
8983 WHEN OTHERS THEN
8984 X_status := SQLCODE;
8985 RAISE;
8986 END ReprocessCrossCharge ;
8987
8988 PROCEDURE MarkNoCCProcess (ItemsIdTab IN pa_utils.IdTabTyp
8989 , X_adjust_level IN VARCHAR2
8990 , X_user IN NUMBER
8991 , X_login IN NUMBER
8992 , X_module IN VARCHAR2
8993 , X_bl_dist_code IN VARCHAR2
8994 , X_ic_proc_code IN VARCHAR2
8995 , rows IN NUMBER
8996 , X_num_processed OUT NOCOPY NUMBER
8997 , X_status OUT NOCOPY NUMBER ) IS
8998
8999 temp_status NUMBER DEFAULT NULL;
9000 item_count NUMBER := 0;
9001 l_cc_code_old VARCHAR2(1):= NULL;
9002 l_bl_dist_code VARCHAR2(1):= NULL;
9003 l_ic_proc_code VARCHAR2(1):= NULL;
9004
9005 PROCEDURE RecalcRelatedItems( X_expenditure_item_id IN NUMBER
9006 , X_user IN NUMBER
9007 , X_login IN NUMBER
9008 , X_module IN VARCHAR2
9009 , X_status OUT NOCOPY NUMBER )
9010 IS
9011 CURSOR GetRelatedItems IS
9012 SELECT
9013 expenditure_item_id
9014 FROM
9015 pa_expenditure_items_all
9016 WHERE
9017 source_expenditure_item_id = X_expenditure_item_id;
9018 BEGIN
9019 --print_message('in related ei');
9020 FOR eachRec IN GetRelatedItems LOOP
9021 --print_message('in related ei loop');
9022 UPDATE pa_expenditure_items_all
9023 SET
9024 cc_cross_charge_code = 'N'
9025 , cc_bl_distributed_code = DECODE(X_adjust_level,'I',X_bl_dist_code, l_bl_dist_code)
9026 , cc_ic_processed_code = DECODE(X_adjust_level,'I',X_ic_proc_code, l_ic_proc_code)
9027 , denom_tp_currency_code = NULL
9028 , acct_tp_rate_type = NULL
9029 , acct_tp_rate_date = NULL
9030 , acct_tp_exchange_rate = NULL
9031 , denom_transfer_price = NULL
9032 , acct_transfer_price = NULL
9033 , projacct_transfer_price = NULL
9034 , cc_markup_base_code= NULL
9035 , tp_base_amount = NULL
9036 , tp_ind_compiled_set_id = NULL
9037 , tp_bill_rate = NULL
9038 , tp_bill_markup_percentage = NULL
9039 , tp_schedule_line_percentage = NULL
9040 , tp_rule_percentage = NULL
9041 , last_updated_by = X_user
9042 , last_update_date = sysdate
9043 , last_update_login = X_login
9044 , PROJECT_TP_RATE_DATE = null
9045 , PROJECT_TP_RATE_TYPE = null
9046 , PROJECT_TP_EXCHANGE_RATE = null
9047 , PROJECT_TRANSFER_PRICE = null
9048 , PROJFUNC_TP_RATE_DATE = null
9049 , PROJFUNC_TP_RATE_TYPE = null
9050 , PROJFUNC_TP_EXCHANGE_RATE = null
9051 , PROJFUNC_TRANSFER_PRICE = null
9052 WHERE
9053 expenditure_item_id = eachRec.expenditure_item_id;
9054
9055 item_count := item_count + 1;
9056
9057 pa_adjustments.InsAuditRec( eachRec.expenditure_item_id
9058 , 'MARK NO CC PROCESS'
9059 , X_module
9060 , X_user
9061 , X_login
9062 , temp_status
9063 /* R12 Changes Start */
9064 , G_REQUEST_ID
9065 , G_PROGRAM_ID
9066 , G_PROG_APPL_ID
9067 , sysdate );
9068 /* R12 Changes End */
9069 CheckStatus( temp_status );
9070
9071 END LOOP;
9072
9073 X_status := 0;
9074
9075 EXCEPTION
9076 WHEN OTHERS THEN
9077 X_status := SQLCODE;
9078 RAISE;
9079
9080 END RecalcRelatedItems;
9081
9082
9083 BEGIN
9084 FOR i IN 1..rows LOOP
9085 IF X_adjust_level = 'S' THEN
9086 l_cc_code_old := CrossChargeCodeTab(i) ;
9087
9088 if l_cc_code_old = 'B'then
9089 l_ic_proc_code := 'X';
9090 l_bl_dist_code := 'N' ;
9091 elsif l_cc_code_old = 'I'then
9092 l_ic_proc_code := 'N';
9093 l_bl_dist_code := 'X' ;
9094 end if;
9095 END IF;
9096
9097
9098 UPDATE pa_expenditure_items_all
9099 SET
9100 cc_cross_charge_code = 'N'
9101 , cc_bl_distributed_code = DECODE(X_adjust_level,'I',X_bl_dist_code, l_bl_dist_code)
9102 , cc_ic_processed_code = DECODE(X_adjust_level,'I',X_ic_proc_code, l_ic_proc_code)
9103 , denom_tp_currency_code = NULL
9104 , acct_tp_rate_type = NULL
9105 , acct_tp_rate_date = NULL
9106 , acct_tp_exchange_rate = NULL
9107 , denom_transfer_price = NULL
9108 , acct_transfer_price = NULL
9109 , projacct_transfer_price = NULL
9110 , cc_markup_base_code= NULL
9111 , tp_base_amount = NULL
9112 , tp_ind_compiled_set_id = NULL
9113 , tp_bill_rate = NULL
9114 , tp_bill_markup_percentage = NULL
9115 , tp_schedule_line_percentage = NULL
9116 , tp_rule_percentage = NULL
9117 , last_updated_by = X_user
9118 , last_update_date = sysdate
9119 , last_update_login = X_login
9120 , PROJECT_TP_RATE_DATE = null
9121 , PROJECT_TP_RATE_TYPE = null
9122 , PROJECT_TP_EXCHANGE_RATE = null
9123 , PROJECT_TRANSFER_PRICE = null
9124 , PROJFUNC_TP_RATE_DATE = null
9125 , PROJFUNC_TP_RATE_TYPE = null
9126 , PROJFUNC_TP_EXCHANGE_RATE = null
9127 , PROJFUNC_TRANSFER_PRICE = null
9128
9129 WHERE
9130 expenditure_item_id = ItemsIdTab(i);
9131
9132 item_count := item_count + 1;
9133
9134 InsAuditRec( ItemsIdTab(i)
9135 , 'MARK NO CC PROCESS'
9136 , X_module
9137 , X_user
9138 , X_login
9139 , temp_status
9140 /* R12 Changes Start */
9141 , G_REQUEST_ID
9142 , G_PROGRAM_ID
9143 , G_PROG_APPL_ID
9144 , sysdate );
9145 /* R12 Changes End */
9146 CheckStatus( temp_status );
9147
9148 IF P_DEBUG_MODE THEN
9149 print_message('get_denom_curr_code: ' || 'ei is '||to_char(ItemsIdTab(i)));
9150 END IF;
9151 RecalcRelatedItems( ItemsIdTab(i)
9152 , X_user
9153 , X_login
9154 , X_module
9155 , temp_status );
9156 CheckStatus( temp_status );
9157
9158 END LOOP;
9159
9160 X_status := 0; X_status := 0;
9161 X_num_processed := item_count;
9162
9163 EXCEPTION
9164 WHEN OTHERS THEN
9165 X_status := SQLCODE;
9166 RAISE;
9167 END MarkNoCCProcess ;
9168
9169 PROCEDURE ChangeTPAttributes(ItemsIdTab IN pa_utils.IdTabTyp
9170 , X_adjust_level IN VARCHAR2
9171 , X_user IN NUMBER
9172 , X_login IN NUMBER
9173 , X_module IN VARCHAR2
9174 , X_acct_tp_rate_type IN VARCHAR2
9175 , X_acct_tp_rate_date IN DATE
9176 , X_acct_tp_exchange_rate IN NUMBER
9177 , X_bl_dist_code IN VARCHAR2
9178 , X_ic_proc_code IN VARCHAR2
9179 , DenomCurrCodeTab IN pa_utils.Char15TabTyp
9180 , rows IN NUMBER
9181 , X_num_processed OUT NOCOPY NUMBER
9182 , X_num_rejected OUT NOCOPY NUMBER
9183 , X_status OUT NOCOPY NUMBER
9184 , p_PROJECT_TP_COST_RATE_DATE IN DATE
9185 , p_PROJECT_TP_COST_RATE_TYPE IN VARCHAR2
9186 , p_PROJECT_TP_COST_EXCHG_RATE IN NUMBER
9187 ) IS
9188
9189 temp_status NUMBER DEFAULT NULL;
9190 item_count NUMBER := 0;
9191 failed_count NUMBER := 0 ;
9192 l_status VARCHAR2(240)DEFAULT NULL ;
9193 l_acct_exchange_rate NUMBER := X_acct_tp_exchange_rate;
9194 l_acct_rate_type VARCHAR2(30) := X_acct_tp_rate_type ;
9195 l_acct_rate_date DATE := X_acct_tp_rate_date ;
9196 l_dummy1 NUMBER ;
9197 l_dummy2 NUMBER ;
9198 l_dummy3 NUMBER ;
9199 l_cc_code_old VARCHAR2(1):= NULL;
9200 l_bl_dist_code VARCHAR2(1):= NULL;
9201 l_ic_proc_code VARCHAR2(1):= NULL;
9202
9203 PROCEDURE RecalcRelatedItems( X_expenditure_item_id IN NUMBER
9204 , X_user IN NUMBER
9205 , X_login IN NUMBER
9206 , X_acct_tp_rate_type IN VARCHAR2
9207 , X_acct_tp_rate_date IN DATE
9208 , X_acct_tp_exchange_rateIN NUMBER
9209 , X_module IN VARCHAR2
9210 , X_status OUT NOCOPY NUMBER
9211 , p_PROJECT_TP_COST_RATE_DATE IN DATE default null
9212 , p_PROJECT_TP_COST_RATE_TYPE IN VARCHAR2 default null
9213 , p_PROJECT_TP_COST_EXCHG_RATE IN NUMBER default null )
9214 IS
9215 CURSOR GetRelatedItems IS
9216 SELECT
9217 expenditure_item_id
9218 FROM
9219 pa_expenditure_items_all
9220 WHERE
9221 source_expenditure_item_id = X_expenditure_item_id;
9222 BEGIN
9223
9224 FOR eachRec IN GetRelatedItems LOOP
9225
9226 UPDATE pa_expenditure_items_all
9227
9228 SET
9229 cc_bl_distributed_code = DECODE(X_adjust_level,'I',X_bl_dist_code, l_bl_dist_code)
9230 , cc_ic_processed_code = DECODE(X_adjust_level,'I',X_ic_proc_code, l_ic_proc_code)
9231 , acct_tp_rate_type = X_acct_tp_rate_type
9232 , acct_tp_rate_date = X_acct_tp_rate_date
9233 , acct_tp_exchange_rate = l_acct_exchange_rate
9234 --- , PROJECT_TP_RATE_DATE = p_PROJECT_TP_COST_RATE_DATE
9235 --- , PROJECT_TP_RATE_TYPE = p_PROJECT_TP_COST_RATE_TYPE
9236 --- , PROJECT_TP_EXCHANGE_RATE = p_PROJECT_TP_COST_EXCHG_RATE
9237 , PROJECT_TRANSFER_PRICE = NULL
9238 , PROJFUNC_TRANSFER_PRICE = NULL
9239 , denom_transfer_price = NULL
9240 , acct_transfer_price = NULL
9241 , last_updated_by = X_user
9242 , last_update_date = sysdate
9243 , last_update_login = X_login
9244 WHERE
9245 expenditure_item_id = eachRec.expenditure_item_id;
9246
9247 item_count := item_count + 1;
9248
9249 pa_adjustments.InsAuditRec( eachRec.expenditure_item_id
9250 , 'CHANGE TP ATTRIBUTE'
9251 , X_module
9252 , X_user
9253 , X_login
9254 , temp_status
9255 /* R12 Changes Start */
9256 , G_REQUEST_ID
9257 , G_PROGRAM_ID
9258 , G_PROG_APPL_ID
9259 , sysdate );
9260 /* R12 Changes End */
9261 CheckStatus( temp_status );
9262
9263 END LOOP;
9264
9265 X_status := 0;
9266
9267 EXCEPTION
9268 WHEN OTHERS THEN
9269 X_status := SQLCODE;
9270 RAISE;
9271
9272 END RecalcRelatedItems;
9273
9274
9275 BEGIN
9276 FOR i IN 1..rows LOOP
9277 pa_multi_currency.init ;
9278 IF X_adjust_level = 'S' THEN
9279 l_cc_code_old := CrossChargeCodeTab(i);
9280
9281 if l_cc_code_old = 'B' then
9282 l_ic_proc_code := 'X';
9283 l_bl_dist_code := 'N' ;
9284 elsif l_cc_code_old = 'I' then
9285 l_ic_proc_code := 'N';
9286 l_bl_dist_code := 'X' ;
9287 end if;
9288 IF P_DEBUG_MODE THEN
9289 print_message('get_denom_curr_code: ' || 'X rate is['||to_char(X_acct_tp_exchange_rate)||']l rate ['||to_char(l_acct_exchange_rate)||']' );
9290 END IF;
9291
9292 pa_multi_currency.convert_amount( DenomTpCurrCodeTab(i)
9293 , pa_multi_currency.G_accounting_currency_code
9294 , l_acct_rate_date
9295 , l_acct_rate_type
9296 , null
9297 , 'Y'
9298 , 'Y'
9299 , l_dummy1
9300 , l_dummy2
9301 , l_dummy3
9302 , l_acct_exchange_rate
9303 , l_status ) ;
9304 IF P_DEBUG_MODE THEN
9305 print_message('get_denom_curr_code: ' || 'X rate after convert amt ['||to_char(l_acct_exchange_rate)||']status ['||l_status||']' );
9306 END IF;
9307 END IF ;
9308
9309
9310 IF l_status is not null then
9311 failed_count := failed_count + 1 ;
9312 /* R12 Changes Start */
9313 InsAuditRec( ItemsIdTab(i)
9314 , 'CHANGE FUNC ATTRIBUTE'
9315 , X_module
9316 , X_user
9317 , X_login
9318 , temp_status
9319 , G_REQUEST_ID
9320 , G_PROGRAM_ID
9321 , G_PROG_APPL_ID
9322 , sysdate
9323 , l_status);
9324 CheckStatus(temp_status);
9325 /* R12 Changes End */
9326 ELSE
9327
9328 UPDATE pa_expenditure_items_all ei
9329 SET
9330 cc_bl_distributed_code = DECODE(X_adjust_level, 'I', X_bl_dist_code, l_bl_dist_code)
9331 , cc_ic_processed_code = DECODE(X_adjust_level, 'I',X_ic_proc_code, l_ic_proc_code)
9332 , acct_tp_rate_type = X_acct_tp_rate_type
9333 , acct_tp_rate_date = X_acct_tp_rate_date
9334 , acct_tp_exchange_rate = l_acct_exchange_rate
9335 , denom_transfer_price = NULL
9336 , acct_transfer_price = NULL
9337 , last_updated_by = X_user
9338 , last_update_date = sysdate
9339 , last_update_login = X_login
9340 ---, PROJECT_TP_RATE_DATE = p_PROJECT_TP_COST_RATE_DATE
9341 ---, PROJECT_TP_RATE_TYPE = p_PROJECT_TP_COST_RATE_TYPE
9342 ---, PROJECT_TP_EXCHANGE_RATE = p_PROJECT_TP_COST_EXCHG_RATE
9343 , PROJECT_TRANSFER_PRICE = NULL
9344 , PROJFUNC_TRANSFER_PRICE = NULL
9345
9346 WHERE
9347 ei.expenditure_item_id = ItemsIdTab(i);
9348
9349 item_count := item_count + 1;
9350
9351 InsAuditRec( ItemsIdTab(i)
9352 , 'CHANGE TP ATTRIBUTE'
9353 , X_module
9354 , X_user
9355 , X_login
9356 , temp_status
9357 /* R12 Changes Start */
9358 , G_REQUEST_ID
9359 , G_PROGRAM_ID
9360 , G_PROG_APPL_ID
9361 , sysdate );
9362 /* R12 Changes End */
9363 CheckStatus( temp_status );
9364
9365 RecalcRelatedItems( ItemsIdTab(i)
9366 , X_user
9367 , X_login
9368 , X_acct_tp_rate_type
9369 , X_acct_tp_rate_date
9370 , l_acct_exchange_rate
9371 , X_module
9372 , temp_status );
9373 CheckStatus( temp_status );
9374
9375 END IF ;
9376 END LOOP;
9377
9378 X_status := 0;
9379 X_num_processed := item_count;
9380 X_num_rejected := failed_count ;
9381
9382 EXCEPTION
9383 WHEN OTHERS THEN
9384 X_status := SQLCODE;
9385 RAISE;
9386
9387 END ChangeTPAttributes;
9388
9389
9390 PROCEDURE Allow_Adjustment(
9391 p_transaction_source IN VARCHAR2,
9392 p_orig_transaction_reference IN VARCHAR2,
9393 p_expenditure_type_class IN VARCHAR2,
9394 p_expenditure_type IN VARCHAR2,
9395 p_expenditure_item_id IN NUMBER,
9396 p_expenditure_item_date IN DATE,
9397 p_employee_number IN VARCHAR2,
9398 p_expenditure_org_name IN VARCHAR2,
9399 p_project_number IN VARCHAR2,
9400 p_task_number IN VARCHAR2,
9401 p_non_labor_resource IN VARCHAR2,
9402 p_non_labor_resource_org_name IN VARCHAR2,
9403 p_quantity IN NUMBER,
9404 p_raw_cost IN NUMBER,
9405 p_attribute_category IN VARCHAR2,
9406 p_attribute1 IN VARCHAR2,
9407 p_attribute2 IN VARCHAR2,
9408 p_attribute3 IN VARCHAR2,
9409 p_attribute4 IN VARCHAR2,
9410 p_attribute5 IN VARCHAR2,
9411 p_attribute6 IN VARCHAR2,
9412 p_attribute7 IN VARCHAR2,
9413 p_attribute8 IN VARCHAR2,
9414 p_attribute9 IN VARCHAR2,
9415 p_attribute10 IN VARCHAR2,
9416 p_org_id IN NUMBER,
9417 x_allow_adjustment_code OUT NOCOPY VARCHAR2,
9418 x_return_status OUT NOCOPY VARCHAR2,
9419 x_application_code OUT NOCOPY VARCHAR2,
9420 x_message_code OUT NOCOPY VARCHAR2,
9421 x_token_name1 OUT NOCOPY VARCHAR2,
9422 x_token_val1 OUT NOCOPY VARCHAR2,
9423 x_token_name2 OUT NOCOPY VARCHAR2,
9424 x_token_val2 OUT NOCOPY VARCHAR2,
9425 x_token_name3 OUT NOCOPY VARCHAR2,
9426 x_token_val3 OUT NOCOPY VARCHAR2)
9427
9428 IS
9429
9430 TYPE net_zero_ei_date_rec_type IS RECORD (
9431 net_zero_adjustment_flag_1 pa_expenditure_items_all.net_zero_adjustment_flag%TYPE DEFAULT NULL,
9432 expenditure_item_date_1 pa_expenditure_items_all.expenditure_item_date%TYPE DEFAULT NULL,
9433 net_zero_adjustment_flag_2 pa_expenditure_items_all.net_zero_adjustment_flag%TYPE DEFAULT NULL,
9434 expenditure_item_date_2 pa_expenditure_items_all.expenditure_item_date%TYPE DEFAULT NULL,
9435 net_zero_adjustment_flag_3 pa_expenditure_items_all.net_zero_adjustment_flag%TYPE DEFAULT NULL,
9436 expenditure_item_date_3 pa_expenditure_items_all.expenditure_item_date%TYPE DEFAULT NULL,
9437 net_zero_adjustment_flag_4 pa_expenditure_items_all.net_zero_adjustment_flag%TYPE DEFAULT NULL,
9438 expenditure_item_date_4 pa_expenditure_items_all.expenditure_item_date%TYPE DEFAULT NULL,
9439 net_zero_adjustment_flag_5 pa_expenditure_items_all.net_zero_adjustment_flag%TYPE DEFAULT NULL,
9440 expenditure_item_date_5 pa_expenditure_items_all.expenditure_item_date%TYPE DEFAULT NULL,
9441 net_zero_adjustment_flag_6 pa_expenditure_items_all.net_zero_adjustment_flag%TYPE DEFAULT NULL,
9442 expenditure_item_date_6 pa_expenditure_items_all.expenditure_item_date%TYPE DEFAULT NULL,
9443 net_zero_adjustment_flag_7 pa_expenditure_items_all.net_zero_adjustment_flag%TYPE DEFAULT NULL,
9444 expenditure_item_date_7 pa_expenditure_items_all.expenditure_item_date%TYPE DEFAULT NULL);
9445
9446 l_net_zero_ei_date net_zero_ei_date_rec_type;
9447 l_allow_adjustment_flag VARCHAR2(1);
9448 l_predefined_flag VARCHAR2(1);
9449
9450 CURSOR allow_adjustment IS
9451 SELECT allow_adjustments_flag, predefined_flag
9452 FROM pa_transaction_sources
9453 WHERE transaction_source = p_transaction_source;
9454
9455 CURSOR sst_adjustment IS
9456 SELECT net_zero_adjustment_flag_1,
9457 expenditure_item_date_1,
9458 net_zero_adjustment_flag_2,
9459 expenditure_item_date_2,
9460 net_zero_adjustment_flag_3,
9461 expenditure_item_date_3,
9462 net_zero_adjustment_flag_4,
9463 expenditure_item_date_4,
9464 net_zero_adjustment_flag_5,
9465 expenditure_item_date_5,
9466 net_zero_adjustment_flag_6,
9467 expenditure_item_date_6,
9468 net_zero_adjustment_flag_7,
9469 expenditure_item_date_7
9470 FROM PA_EI_DENORM
9471 WHERE denorm_id = p_orig_transaction_reference;
9472
9473 l_test NUMBER;
9474
9475 BEGIN
9476
9477 --If the transaction source is NULL then the item was not imported to Projects
9478 --from an external system so RETURN.
9479
9480
9481 IF (p_transaction_source IS NULL) THEN
9482
9483 x_return_status := 'S';
9484
9485 RETURN;
9486
9487 END IF; --p_transaction_source is null
9488
9489 --If p_transaction_source is Oracle Self Service Time then check if the item has
9490 --already been adjusted in Self Service Time.
9491
9492 IF (p_transaction_source = 'Oracle Self Service Time') THEN
9493
9494 OPEN sst_adjustment;
9495
9496 FETCH sst_adjustment INTO l_net_zero_ei_date;
9497
9498 --If no records are in the cursor then the item was not found in SST.
9499 --This indicates data corruption. No adjustment will be allowed.
9500
9501 IF (sst_adjustment%ROWCOUNT = 0) THEN
9502
9503 x_allow_adjustment_code := 'N';
9504
9505 x_return_status := 'E';
9506
9507 x_application_code := 'PA';
9508
9509 x_message_code := 'PA_SST_ITEM_NOT_FOUND';
9510
9511 ELSIF (l_net_zero_ei_date.expenditure_item_date_1 = p_expenditure_item_date) AND
9512 (l_net_zero_ei_date.net_zero_adjustment_flag_1 = 'Y') THEN
9513
9514 x_allow_adjustment_code := 'N';
9515 x_return_status := 'S';
9516
9517 ELSIF (l_net_zero_ei_date.expenditure_item_date_2 = p_expenditure_item_date) AND
9518 (l_net_zero_ei_date.net_zero_adjustment_flag_2 = 'Y') THEN
9519
9520 x_allow_adjustment_code := 'N';
9521 x_return_status := 'S';
9522
9523 ELSIF (l_net_zero_ei_date.expenditure_item_date_3 = p_expenditure_item_date) AND
9524 (l_net_zero_ei_date.net_zero_adjustment_flag_3 = 'Y') THEN
9525
9526 x_allow_adjustment_code := 'N';
9527 x_return_status := 'S';
9528
9529 ELSIF (l_net_zero_ei_date.expenditure_item_date_4 = p_expenditure_item_date) AND
9530 (l_net_zero_ei_date.net_zero_adjustment_flag_4 = 'Y') THEN
9531
9532 x_allow_adjustment_code := 'N';
9533 x_return_status := 'S';
9534
9535 ELSIF (l_net_zero_ei_date.expenditure_item_date_5 = p_expenditure_item_date) AND
9536 (l_net_zero_ei_date.net_zero_adjustment_flag_5 = 'Y') THEN
9537
9538 x_allow_adjustment_code := 'N';
9539 x_return_status := 'S';
9540
9541 ELSIF (l_net_zero_ei_date.expenditure_item_date_6 = p_expenditure_item_date) AND
9542 (l_net_zero_ei_date.net_zero_adjustment_flag_6 = 'Y') THEN
9543
9544 x_allow_adjustment_code := 'N';
9545 x_return_status := 'S';
9546
9547 ELSIF (l_net_zero_ei_date.expenditure_item_date_7 = p_expenditure_item_date) AND
9548 (l_net_zero_ei_date.net_zero_adjustment_flag_7 = 'Y') THEN
9549
9550 x_allow_adjustment_code := 'N';
9551 x_return_status := 'S';
9552
9553 --If the net_zero_adjustmentment_flag <> 'Y' then an adjustment should be allowed.
9554
9555 ELSE x_allow_adjustment_code := 'Y';
9556 x_return_status := 'S';
9557
9558 END IF;
9559
9560 CLOSE sst_adjustment;
9561
9562 --If the transaction source is NOT NULL and is NOT SST then
9563 --open the allow_adjustment cursor.
9564
9565 ELSE OPEN allow_adjustment;
9566
9567 FETCH allow_adjustment INTO l_allow_adjustment_flag, l_predefined_flag;
9568
9569 CLOSE allow_adjustment;
9570
9571 --If the transaction source is seeded then set x_allow_adjustment_code
9572 --to the allow_adjustment_flag for that transaction source.
9573
9574 IF (l_predefined_flag = 'Y') THEN
9575
9576 x_allow_adjustment_code := l_allow_adjustment_flag;
9577 x_return_status := 'S';
9578
9579 --If the transaction source is not seeded then call
9580 --the Allow Adjustment client extension. By default, the
9581 --allow_adjustment_extn will return the allow_adjustment_flag
9582 --for the given transaction source.
9583
9584 ELSE PA_TRANSACTIONS_PUB.Allow_Adjustment_Extn(
9585 p_transaction_source => p_transaction_source,
9586 p_allow_adjustment_flag => l_allow_adjustment_flag,
9587 p_orig_transaction_reference => p_orig_transaction_reference,
9588 p_expenditure_type_class => p_expenditure_type_class,
9589 p_expenditure_type => p_expenditure_type,
9590 p_expenditure_item_id => p_expenditure_item_id,
9591 p_expenditure_item_date => p_expenditure_item_date,
9592 p_employee_number => p_employee_number,
9593 p_expenditure_org_name => p_expenditure_org_name,
9594 p_project_number => p_project_number,
9595 p_task_number => p_task_number,
9596 p_non_labor_resource => p_non_labor_resource,
9597 p_non_labor_resource_org_name => p_non_labor_resource_org_name,
9598 p_quantity => p_quantity,
9599 p_raw_cost => p_raw_cost,
9600 p_attribute_category => p_attribute_category,
9601 p_attribute1 => p_attribute1,
9602 p_attribute2 => p_attribute2,
9603 p_attribute3 => p_attribute3,
9604 p_attribute4 => p_attribute4,
9605 p_attribute5 => p_attribute5,
9606 p_attribute6 => p_attribute6,
9607 p_attribute7 => p_attribute7,
9608 p_attribute8 => p_attribute8,
9609 p_attribute9 => p_attribute9,
9610 p_attribute10 => p_attribute10,
9611 p_org_id => p_org_id,
9612 x_allow_adjustment_code => x_allow_adjustment_code,
9613 x_return_status => x_return_status,
9614 x_application_code => x_application_code,
9615 x_message_code => x_message_code,
9616 x_token_name1 => x_token_name1,
9617 x_token_val1 => x_token_val1,
9618 x_token_name2 => x_token_name2,
9619 x_token_val2 => x_token_val2,
9620 x_token_name3 => x_token_name3,
9621 x_token_val3 => x_token_val3);
9622
9623 End IF; --l_predefined_flag = 'Y'
9624
9625 END IF; --p_transaction_source = 'Oracle Self Service Time'
9626
9627 EXCEPTION
9628
9629 WHEN others THEN
9630
9631 x_return_status := 'U';
9632
9633 x_message_code := to_char(SQLCODE);
9634
9635 END Allow_Adjustment;
9636
9637 /* This public function get_denom_curr_code() is added for bug#2291180 */
9638 FUNCTION get_denom_curr_code
9639 (p_transaction_source IN VARCHAR2
9640 , p_exp_type IN VARCHAR2
9641 , p_denom_currency_code IN VARCHAR2
9642 , p_acct_currency_code IN VARCHAR2
9643 , p_system_linkage_function IN VARCHAR2
9644 , p_calling_mode IN VARCHAR2 default 'ADJUST' /*Bugfix:2798742 */
9645 , p_person_id IN NUMBER default NULL /*Bugfix:2798742 */
9646 , p_ei_date IN DATE default NULL /*Bugfix:2798742 */
9647 ) RETURN VARCHAR2 IS
9648
9649 l_return_currency_code pa_expenditure_items_all.denom_currency_code%type;
9650 l_gl_accounted_flag pa_transaction_sources.gl_accounted_flag%type;
9651 l_costed_flag pa_transaction_sources.costed_flag%type; /* added bug 3142879 */
9652 l_cost_rate_flag pa_expenditure_types.cost_rate_flag%type;
9653 l_job_id pa_expenditure_items_all.job_id%TYPE;
9654 l_organization_id pa_expenditures_all.incurred_by_organization_id%TYPE;
9655 l_cost_rate pa_bill_rates_all.rate%TYPE;
9656 l_start_date Date;
9657 l_end_date Date;
9658 l_org_labor_sch_rule_id pa_org_labor_sch_rule.org_labor_sch_rule_id%TYPE;
9659 l_costing_rule pa_compensation_rule_sets.compensation_rule_set%TYPE;
9660 l_rate_sch_id pa_std_bill_rate_schedules_all.bill_rate_sch_id%TYPE;
9661 l_acct_rate_type pa_expenditure_items_all.acct_rate_type%TYPE;
9662 l_acct_rate_date_code pa_implementations_all.acct_rate_date_code%TYPE;
9663 l_acct_exch_rate pa_org_labor_sch_rule.acct_exchange_rate%TYPE;
9664 l_ot_project_id pa_projects_all.project_id%TYPE;
9665 l_ot_task_id pa_tasks.task_id%TYPE;
9666 l_err_stage number;
9667 l_err_code varchar2(1000);
9668 OTHERS_EXCEPTION EXCEPTION;
9669
9670 BEGIN
9671
9672 /* If Transaction Source is Null, set the flag to 'N' */
9673 IF p_transaction_source IS NULL THEN
9674 l_gl_accounted_flag := 'N';
9675 l_costed_flag := 'N';/* added bug 3142879 */
9676 ELSE
9677 SELECT gl_accounted_flag, costed_flag
9678 INTO l_gl_accounted_flag, l_costed_flag /* added costed flag bug 3142879 */
9679 FROM pa_transaction_sources
9680 WHERE transaction_source = p_transaction_source;
9681 END IF;
9682
9683 /* Get the cost_rate_flag */
9684 BEGIN
9685 SELECT cost_rate_flag
9686 INTO l_cost_rate_flag
9687 FROM pa_expenditure_types
9688 WHERE expenditure_type = p_exp_type;
9689
9690 EXCEPTION
9691 WHEN NO_DATA_FOUND THEN
9692 l_cost_rate_flag := 'N';
9693
9694 END; /* cost_rate_flag */
9695
9696 /*
9697 Do not do any processing if the EI is externally accounted
9698 or
9699 EI(s) are from the Expense Reports entered in PA.
9700 For ST/OT/Usages, if acct_currency_code <> denom_currency_code,
9701 then return functional currency code from the SOB.
9702 Else if cost_rate_flag is Y and acct_currency_code <> denom_currency_code
9703 then return functional currency code from the SOB.
9704 */
9705
9706 IF (l_gl_accounted_flag = 'Y') OR (l_costed_flag = 'Y') OR /* added costed flag bug 3142879 */
9707 (p_transaction_source IS NULL and p_system_linkage_function = 'ER') THEN
9708
9709 l_return_currency_code := p_denom_currency_code;
9710
9711 ELSIF p_system_linkage_function in ('ST','OT') THEN
9712 /** Start of Bug fix:2798742 */
9713 IF p_acct_currency_code = p_denom_currency_code THEN
9714 l_return_currency_code := p_denom_currency_code;
9715 ELSE
9716 /* bug fix:2822620 get_labor_rate API should be called only for Split, as these EIs are not
9717 * cost distributed again, where as for Transfer case, New currency code will be
9718 * derived during cost distribution process
9719 */
9720 IF p_calling_mode = 'SPLIT' Then
9721
9722 l_return_currency_code := null;
9723 --Derive denorm_currency_code based on rate
9724 PA_COST_RATE_PUB.get_labor_rate
9725 ( p_person_id => p_person_id
9726 ,p_txn_date => p_ei_date
9727 ,p_calling_module => 'STAFFED'
9728 ,x_job_id => l_job_id
9729 ,x_organization_id => l_organization_id
9730 ,x_cost_rate => l_cost_rate
9731 ,x_start_date_active => l_start_date
9732 ,x_end_date_active => l_end_date
9733 ,x_org_labor_sch_rule_id => l_org_labor_sch_rule_id
9734 ,x_costing_rule => l_costing_rule
9735 ,x_rate_sch_id => l_rate_sch_id
9736 ,x_cost_rate_curr_code => l_return_currency_code
9737 ,x_acct_rate_type => l_acct_rate_type
9738 ,x_acct_rate_date_code => l_acct_rate_date_code
9739 ,x_acct_exch_rate => l_acct_exch_rate
9740 ,x_ot_project_id => l_ot_project_id
9741 ,x_ot_task_id => l_ot_task_id
9742 ,x_err_stage => l_err_stage
9743 ,x_err_code => l_err_code
9744 );
9745 print_message('l_return_currency_code['||l_return_currency_code||']l_err_stage['||l_err_stage||
9746 ']l_err_code['||l_err_code||']');
9747
9748 /* bug fix 2822620 --If l_return_currency_code IS NOT NULL Then **/
9749 If l_return_currency_code IS NULL Then
9750
9751 Raise OTHERS_EXCEPTION;
9752
9753 End If;
9754
9755 ELse -- calling_mode = 'ADJUST'
9756 print_message('Calling mode ADJUST so return account currency code');
9757 l_return_currency_code := pa_currency.get_currency_code;
9758 End If;
9759
9760
9761 END IF;
9762 /** End of Bug fix:2798742 */
9763 ELSIF l_cost_rate_flag = 'Y' THEN
9764
9765 IF p_acct_currency_code = p_denom_currency_code THEN
9766 l_return_currency_code := p_denom_currency_code;
9767 ELSE
9768 l_return_currency_code := pa_currency.get_currency_code;
9769 END IF;
9770
9771 ELSE
9772 l_return_currency_code := p_denom_currency_code;
9773
9774 END IF;
9775
9776 RETURN l_return_currency_code;
9777
9778 EXCEPTION
9779 WHEN OTHERS_EXCEPTION THEN
9780 print_message('inside OTHERS_EXCEPTION l_return_currency_code['||l_return_currency_code||']');
9781 If l_return_currency_code IS NULL Then
9782 RAISE;
9783 ELSE
9784 return l_return_currency_code;
9785 END IF;
9786
9787 WHEN OTHERS THEN
9788 If l_return_currency_code IS NULL Then
9789 RAISE;
9790 ELSE
9791 return l_return_currency_code;
9792 END IF;
9793 RAISE;
9794
9795 END get_denom_curr_code;
9796
9797 /* R12 Changes Start */
9798 PROCEDURE Get_Old_and_New_CCID(
9799 p_expenditure_item_id IN NUMBER
9800 ,p_project_id IN NUMBER
9801 ,p_task_id IN NUMBER
9802 ,p_expenditure_type IN VARCHAR2
9803 ,p_vendor_id IN NUMBER
9804 ,p_expenditure_organization_id IN NUMBER
9805 ,p_expenditure_item_date IN DATE
9806 ,p_billable_flag IN VARCHAR2
9807 ,p_org_id IN NUMBER
9808 ,p_emp_id IN NUMBER
9809 ,p_award_id IN NUMBER
9810 ,p_system_linkage_function IN VARCHAR2
9811 ,p_transaction_source IN VARCHAR2
9812 ,p_invoice_distribution_id IN NUMBER
9813 ,x_old_ccid OUT NOCOPY VARCHAR2
9814 ,x_new_ccid OUT NOCOPY VARCHAR2
9815 ,x_encoded_error_message OUT NOCOPY VARCHAR2) IS /* Bug 4997739 */
9816
9817 l_pa_gl_app_id NUMBER := 8721;
9818 l_concat_segs VARCHAR2(240);
9819 l_concat_ids VARCHAR2(240);
9820 l_concat_descrs VARCHAR2(240);
9821 l_vendor_id NUMBER;
9822 l_gl_date DATE;
9823 l_sob_id NUMBER;
9824 l_coa_id NUMBER;
9825 l_emp_ccid NUMBER;
9826 l_expense_type NUMBER;
9827 l_encoded_error_message VARCHAR2(2000);
9828
9829 /* this cursor derives the set of books and the chart of account
9830 associated with Organization in which the transaction was entered */
9831 CURSOR C_SOB_COA_CUR IS
9832 SELECT IMP.SET_OF_BOOKS_ID
9833 , GL.CHART_OF_ACCOUNTS_ID
9834 FROM GL_LEDGERS_PUBLIC_V GL
9835 , PA_IMPLEMENTATIONS IMP
9836 WHERE GL.LEDGER_ID = IMP.SET_OF_BOOKS_ID;
9837
9838 /* this cursor gets the vendor id of the employee for which the ER was entered */
9839 CURSOR C_VENDOR_ID_CUR(p_emp_id NUMBER) IS
9840 SELECT VENDOR_ID
9841 FROM PO_VENDORS_AP_V
9842 WHERE ACTIVE_FLAG = 'Y'
9843 AND ENABLED_FLAG = 'Y'
9844 AND EMPLOYEE_ID = p_emp_id;
9845
9846 /* this cursor gets the CCID of the employee for ehich the ER was entered */
9847 CURSOR C_EMP_CCID_CUR(p_emp_id NUMBER, p_sob_id NUMBER) IS
9848 SELECT DEFAULT_CODE_COMB_ID
9849 FROM PER_ASSIGNMENTS_F
9850 WHERE PERSON_ID = p_emp_id
9851 AND SET_OF_BOOKS_ID = p_sob_id
9852 AND TRUNC(SYSDATE) BETWEEN TRUNC(EFFECTIVE_START_DATE)
9853 AND NVL(TRUNC(EFFECTIVE_END_DATE), TRUNC(SYSDATE));
9854
9855 /* this cursor get the expense type */
9856 CURSOR C_EXPENSE_TYPE_CUR(p_invoice_distribution_id NUMBER) IS
9857 SELECT WEB_PARAMETER_ID
9858 FROM AP_INVOICE_DISTRIBUTIONS
9859 WHERE INVOICE_DISTRIBUTION_ID = p_invoice_distribution_id;
9860
9861 /* this cursor gets the old ccid and gl date */
9862 CURSOR C_OLD_CCID_AND_GL_DATE_CUR(p_expenditure_item_id NUMBER) IS
9863 SELECT DR_CODE_COMBINATION_ID, GL_DATE
9864 FROM PA_COST_DISTRIBUTION_LINES
9865 WHERE EXPENDITURE_ITEM_ID = ( SELECT EXPENDITURE_ITEM_ID
9866 FROM PA_EXPENDITURE_ITEMS
9867 WHERE TRANSFERRED_FROM_EXP_ITEM_ID IS NULL
9868 START WITH EXPENDITURE_ITEM_ID = p_expenditure_item_id
9869 CONNECT BY PRIOR TRANSFERRED_FROM_EXP_ITEM_ID = EXPENDITURE_ITEM_ID)
9870 AND TRANSFER_STATUS_CODE = 'V';
9871
9872 workflow_exception EXCEPTION;
9873 PRAGMA EXCEPTION_INIT(workflow_exception,-20001);
9874
9875 BEGIN
9876
9877 /* Check if the organization is cached. If yes then it implies that
9878 the Chart of Accounts is also cached */
9879 IF p_org_id <> NVL(G_ORG_ID,-99) THEN
9880
9881 /* If not, get new chart of accounts id */
9882 OPEN C_SOB_COA_CUR;
9883 FETCH C_SOB_COA_CUR INTO l_sob_id, l_coa_id;
9884 CLOSE C_SOB_COA_CUR;
9885
9886 END IF;
9887
9888 IF p_system_linkage_function = 'ER' THEN
9889
9890 /* For ERs, check if employee id is cached. If yes, then it implies that
9891 vendor information is also cached */
9892 IF p_vendor_id IS NULL
9893 AND p_emp_id <> NVL(G_EMP_ID,-99) THEN
9894
9895 /* If not, get employee id */
9896 OPEN C_VENDOR_ID_CUR(p_emp_id);
9897 FETCH C_VENDOR_ID_CUR INTO l_vendor_id;
9898 CLOSE C_VENDOR_ID_CUR;
9899
9900 END IF;
9901
9902 /* For ERs, check if employee id and set of books id is cached. If yes,
9903 then it implies that the employee ccid is also cached */
9904 IF p_emp_id <> NVL(G_EMP_ID,-99)
9905 OR l_sob_id <> NVL(G_SET_OF_BOOKS_ID,-99) THEN
9906
9907 /* If not, get new employee ccid */
9908 OPEN C_EMP_CCID_CUR(p_emp_id, l_sob_id);
9909 FETCH C_EMP_CCID_CUR INTO l_emp_ccid;
9910 CLOSE C_EMP_CCID_CUR;
9911
9912 END IF;
9913
9914 /* For ERs from Payables, check if invoice distribution id is cached. If yes, it implies
9915 thet the expense type is also cached */
9916 IF p_transaction_source = 'AP EXPENSE'
9917 AND p_invoice_distribution_id <> NVL(G_INVOICE_DISTRIBUTION_ID,-99) THEN
9918
9919 /* If not, get expense type */
9920 OPEN C_EXPENSE_TYPE_CUR(p_invoice_distribution_id);
9921 FETCH C_EXPENSE_TYPE_CUR into l_expense_type;
9922 CLOSE C_EXPENSE_TYPE_CUR;
9923
9924 END IF;
9925
9926 END IF;
9927
9928 /* Update cache */
9929 G_ORG_ID := NVL(p_org_id, G_ORG_ID);
9930 G_SET_OF_BOOKS_ID := NVL(l_sob_id,G_SET_OF_BOOKS_ID);
9931 G_COA_ID := NVL(l_coa_id, G_COA_ID);
9932 G_VENDOR_ID := NVL(p_vendor_id,NVL(l_vendor_id,G_VENDOR_ID));
9933 G_EMP_ID := NVL(p_emp_id, G_EMP_ID); /* 4991601 */
9934 G_EMP_CCID := NVL(l_emp_ccid, G_EMP_CCID);
9935 G_INVOICE_DISTRIBUTION_ID := NVL(p_invoice_distribution_id,G_INVOICE_DISTRIBUTION_ID);
9936 G_EXPENSE_TYPE := NVL(l_expense_type, G_EXPENSE_TYPE);
9937
9938 OPEN C_OLD_CCID_AND_GL_DATE_CUR(p_expenditure_item_id);
9939 FETCH C_OLD_CCID_AND_GL_DATE_CUR INTO x_old_ccid, l_gl_date;
9940 CLOSE C_OLD_CCID_AND_GL_DATE_CUR;
9941
9942 IF p_system_linkage_function = 'VI' THEN
9943
9944 /* For Supplier Costs, we have to pass the accounting data
9945 as a parameter. We derive the latest open GL period */
9946
9947 l_gl_date := NVL(pa_utils2.get_prvdr_gl_date(p_reference_date => l_gl_date
9948 ,p_application_id => l_pa_gl_app_id
9949 ,p_set_of_books_id => G_SET_OF_BOOKS_ID),l_gl_date);
9950
9951 /* Call Supplier Invoice Account Generator Workflow */
9952 IF NOT pa_acc_gen_wf_pkg.ap_inv_generate_account
9953 (p_expenditure_item_id => p_expenditure_item_id
9954 ,p_project_id => p_project_id
9955 ,p_task_id => p_task_id
9956 ,p_expenditure_type => p_expenditure_type
9957 ,p_vendor_id => G_VENDOR_ID
9958 ,p_expenditure_organization_id => p_expenditure_organization_id
9959 ,p_expenditure_item_date => p_expenditure_item_date
9960 ,p_billable_flag => p_billable_flag
9961 ,p_chart_of_accounts_id => G_COA_ID
9962 ,p_attribute_category => NULL
9963 ,p_attribute1 => NULL
9964 ,p_attribute2 => NULL
9965 ,p_attribute3 => NULL
9966 ,p_attribute4 => NULL
9967 ,p_attribute5 => NULL
9968 ,p_attribute6 => NULL
9969 ,p_attribute7 => NULL
9970 ,p_attribute8 => NULL
9971 ,p_attribute9 => NULL
9972 ,p_attribute10 => NULL
9973 ,p_attribute11 => NULL
9974 ,p_attribute12 => NULL
9975 ,p_attribute13 => NULL
9976 ,p_attribute14 => NULL
9977 ,p_attribute15 => NULL
9978 ,p_dist_attribute_category => NULL
9979 ,p_dist_attribute1 => NULL
9980 ,p_dist_attribute2 => NULL
9981 ,p_dist_attribute3 => NULL
9982 ,p_dist_attribute4 => NULL
9983 ,p_dist_attribute5 => NULL
9984 ,p_dist_attribute6 => NULL
9985 ,p_dist_attribute7 => NULL
9986 ,p_dist_attribute8 => NULL
9987 ,p_dist_attribute9 => NULL
9988 ,p_dist_attribute10 => NULL
9989 ,p_dist_attribute11 => NULL
9990 ,p_dist_attribute12 => NULL
9991 ,p_dist_attribute13 => NULL
9992 ,p_dist_attribute14 => NULL
9993 ,p_dist_attribute15 => NULL
9994 ,x_return_ccid => x_new_ccid /* Bug 4610677 */
9995 ,x_concat_segs => l_concat_segs
9996 ,x_concat_ids => l_concat_ids
9997 ,x_concat_descrs => l_concat_descrs
9998 ,x_error_message => l_encoded_error_message /* Bug 4997739 */
9999 ,p_award_id => p_award_id
10000 ,p_accounting_date => l_gl_date) THEN
10001
10002 /* Raise an exception if the workflow returns with an error */
10003 /* 4627975 - Set the encoded message on the message stack before raising exception */
10004 x_encoded_error_message := l_encoded_error_message; /* Bug 4997739 */
10005
10006 END IF;
10007 ELSE
10008
10009 /* Call Expense Report Account Generator Workflow */
10010 IF NOT pa_acc_gen_wf_pkg.ap_er_generate_account
10011 (p_expenditure_item_id => p_expenditure_item_id
10012 ,p_project_id => p_project_id
10013 ,p_task_id => p_task_id
10014 ,p_expenditure_type => p_expenditure_type
10015 ,p_vendor_id => G_VENDOR_ID
10016 ,p_expenditure_organization_id => p_expenditure_organization_id
10017 ,p_expenditure_item_date => p_expenditure_item_date
10018 ,p_billable_flag => p_billable_flag
10019 ,p_chart_of_accounts_id => G_COA_ID
10020 ,p_calling_module => 'APXINWKB'
10021 ,p_employee_id => G_EMP_ID
10022 ,p_employee_ccid => G_EMP_CCID
10023 ,p_expense_type => G_EXPENSE_TYPE
10024 ,p_expense_cc => NULL
10025 ,p_attribute_category => NULL
10026 ,p_attribute1 => NULL
10027 ,p_attribute2 => NULL
10028 ,p_attribute3 => NULL
10029 ,p_attribute4 => NULL
10030 ,p_attribute5 => NULL
10031 ,p_attribute6 => NULL
10032 ,p_attribute7 => NULL
10033 ,p_attribute8 => NULL
10034 ,p_attribute9 => NULL
10035 ,p_attribute10 => NULL
10036 ,p_attribute11 => NULL
10037 ,p_attribute12 => NULL
10038 ,p_attribute13 => NULL
10039 ,p_attribute14 => NULL
10040 ,p_attribute15 => NULL
10041 ,p_line_attribute_category => NULL
10042 ,p_line_attribute1 => NULL
10043 ,p_line_attribute2 => NULL
10044 ,p_line_attribute3 => NULL
10045 ,p_line_attribute4 => NULL
10046 ,p_line_attribute5 => NULL
10047 ,p_line_attribute6 => NULL
10048 ,p_line_attribute7 => NULL
10049 ,p_line_attribute8 => NULL
10050 ,p_line_attribute9 => NULL
10051 ,p_line_attribute10 => NULL
10052 ,p_line_attribute11 => NULL
10053 ,p_line_attribute12 => NULL
10054 ,p_line_attribute13 => NULL
10055 ,p_line_attribute14 => NULL
10056 ,p_line_attribute15 => NULL
10057 ,x_return_ccid => x_new_ccid /* Bug 4610677 */
10058 ,x_concat_segs => l_concat_segs
10059 ,x_concat_ids => l_concat_ids
10060 ,x_concat_descrs => l_concat_descrs
10061 ,x_error_message => l_encoded_error_message /* Bug 4997739 */
10062 ,p_award_id => p_award_id) THEN
10063
10064 /* Raise an exception if the workflow returns with an error */
10065 /* 4627975 - Set the encoded message on the message stack before raising exception */
10066 x_encoded_error_message := l_encoded_error_message; /* Bug 4997739 */
10067
10068 END IF;
10069
10070 END IF;
10071
10072 END Get_Old_and_New_CCID;
10073
10074 FUNCTION get_auto_offsets_segments
10075 (p_auto_offset_option AP_SYSTEM_PARAMETERS.liability_post_lookup_code%TYPE
10076 ,P_base_ccid NUMBER
10077 ,p_coa_id NUMBER) return varchar2 is
10078
10079 l_base_segments FND_FLEX_EXT.SEGMENTARRAY ;
10080 l_overlay_segments FND_FLEX_EXT.SEGMENTARRAY ;
10081 l_segments FND_FLEX_EXT.SEGMENTARRAY ;
10082 l_num_of_segments NUMBER ;
10083 l_result BOOLEAN ;
10084 l_flex_qualifier_name VARCHAR2(100);
10085 l_flex_segment_num NUMBER;
10086 l_return_segments varchar2(200) := null;
10087
10088
10089 BEGIN
10090
10091 /* Get flexfield qualifier segment number */
10092
10093 IF (p_auto_offset_option = 'ACCOUNT_SEGMENT_VALUE') THEN
10094
10095 l_flex_qualifier_name := 'GL_ACCOUNT' ;
10096
10097 ELSIF (p_auto_offset_option = 'BALANCING_SEGMENT') THEN
10098
10099 l_flex_qualifier_name := 'GL_BALANCING' ;
10100
10101 ELSIF (p_auto_offset_option = 'NONE') THEN
10102
10103 RETURN NULL;
10104
10105 END IF;
10106
10107 l_result := FND_FLEX_APIS.GET_QUALIFIER_SEGNUM(101
10108 ,'GL#'
10109 ,p_coa_id
10110 ,l_flex_qualifier_name
10111 ,l_flex_segment_num);
10112
10113 /* Get the segments of the given account */
10114 IF (NOT FND_FLEX_EXT.GET_SEGMENTS('SQLGL'
10115 ,'GL#'
10116 , p_coa_id
10117 ,P_base_ccid
10118 ,l_num_of_segments
10119 ,l_base_segments)) THEN
10120
10121 RETURN -1 ;
10122
10123 END IF;
10124
10125 /* Get the Balancing Segment or Accounting Segment based on the auto-offset option */
10126 FOR i IN 1.. l_num_of_segments LOOP
10127
10128 IF (l_Flex_Qualifier_Name = 'GL_BALANCING') THEN
10129
10130 IF (i = l_flex_segment_num) THEN
10131
10132 l_segments(i) := l_base_segments(i);
10133 l_return_segments := l_segments(i);
10134
10135 END IF;
10136
10137 ELSIF (l_Flex_Qualifier_Name = 'GL_ACCOUNT') THEN
10138
10139 IF (i = l_flex_segment_num) THEN
10140
10141 l_segments(i) := l_base_segments(i);
10142
10143 ELSE
10144
10145 l_segments(i) := l_base_segments(i);
10146 l_return_segments := l_return_segments || l_segments(i) ;
10147
10148 END IF;
10149
10150 END IF;
10151
10152 END LOOP;
10153
10154 return l_return_segments;
10155
10156 END get_auto_offsets_segments;
10157
10158 FUNCTION Allow_Adjust_with_Auto_Offset
10159 (p_expenditure_item_id IN NUMBER,
10160 p_org_id IN NUMBER,
10161 p_system_linkage_function IN VARCHAR2,
10162 p_transaction_source IN VARCHAR2,
10163 P_action IN VARCHAR2,
10164 P_project_id IN NUMBER,
10165 P_task_id IN NUMBER,
10166 p_expenditure_type IN VARCHAR2,
10167 p_vendor_id IN NUMBER,
10168 p_expenditure_organization_id IN NUMBER,
10169 p_expenditure_item_date IN DATE,
10170 p_emp_id IN NUMBER,
10171 p_invoice_distribution_id IN NUMBER,
10172 p_invoice_payment_id IN AP_INVOICE_PAYMENTS_ALL.INVOICE_PAYMENT_ID%TYPE, /* Bug 5006835 */
10173 p_award_id IN NUMBER,
10174 p_billable_flag1 IN VARCHAR2,
10175 p_billable_flag2 IN VARCHAR2,
10176 x_encoded_error_message OUT NOCOPY VARCHAR2) /* Bug 4997739 */
10177 RETURN BOOLEAN IS
10178
10179 l_automatic_offset_method VARCHAR2(25) := 'UNKNOWN';
10180 l_billable_flag VARCHAR2(1);
10181 l_return BOOLEAN := TRUE;
10182 l_pooled_flag VARCHAR(1); /* Bug 5006835 */
10183 l_encoded_error_message VARCHAR2(2000); /* Bug 4997739 */
10184 l_historical_flag PA_EXPENDITURE_ITEMS_ALL.HISTORICAL_FLAG%TYPE := 'N'; /* Bug 5551933 */
10185
10186 CURSOR c_get_ap_offset_method IS
10187 SELECT LIABILITY_POST_LOOKUP_CODE
10188 FROM AP_SYSTEM_PARAMETERS;
10189
10190 /* Bug 5006835 - Start */
10191 /* This cursor is used to determine if the disbursement bank account is pooled
10192 for a payment in cash basis accounting setup */
10193 CURSOR c_get_pooled_flag(p_invoice_payment_id AP_INVOICE_PAYMENTS_ALL.INVOICE_PAYMENT_ID%TYPE) IS
10194 SELECT B.POOLED_FLAG
10195 FROM CE_BANK_ACCOUNTS B
10196 , AP_CHECKS_ALL C
10197 , AP_INVOICE_PAYMENTS_ALL A
10198 WHERE A.INVOICE_PAYMENT_ID = p_invoice_payment_id
10199 AND A.CHECK_ID = C.CHECK_ID
10200 AND C.CE_BANK_ACCT_USE_ID = B.BANK_ACCOUNT_ID;
10201 /* Bug 5006835 - End */
10202
10203 BEGIN
10204
10205 /* Bug 5006835 - Start */
10206 IF PA_UTILS4.get_ledger_cash_basis_flag = 'Y' THEN
10207
10208 /* Bug 5551933 - Start */
10209 IF p_transaction_source = 'AP DISCOUNTS' THEN
10210
10211 /* Bug 5559214 - Start */
10212 SELECT nvl(historical_flag, 'N')
10213 INTO l_historical_flag
10214 FROM ap_invoice_distributions_all
10215 WHERE invoice_distribution_id = p_invoice_distribution_id;
10216 /* Bug 5559214 - End */
10217
10218 END IF;
10219
10220 IF l_historical_flag = 'N'
10221 AND p_invoice_payment_id IS NOT NULL THEN /* Bug 5455212 */
10222
10223 OPEN c_get_pooled_flag(p_invoice_payment_id);
10224 FETCH c_get_pooled_flag INTO l_pooled_flag;
10225 CLOSE c_get_pooled_flag;
10226
10227 IF NVL(l_pooled_flag, 'N') = 'N' THEN
10228
10229 RETURN TRUE;
10230
10231 END IF;
10232
10233 END IF;
10234 /* Bug 5551933 - End */
10235
10236 END IF;
10237 /* Bug 5006835 - End */
10238
10239 /* Account can change only when the project, task, billability or capitalizability changes */
10240 IF G_AUTOMATIC_OFFSET_METHOD.COUNT = 0 THEN
10241
10242 /* If cache is empty, then populate the PL/SQL table with the offset method and
10243 corresponding org_id */
10244 OPEN c_get_ap_offset_method;
10245 FETCH c_get_ap_offset_method
10246 INTO l_automatic_offset_method;
10247 CLOSE c_get_ap_offset_method;
10248
10249 G_AUTOMATIC_OFFSET_METHOD(1).ORG_ID := p_org_id;
10250 G_AUTOMATIC_OFFSET_METHOD(1).METHOD := l_automatic_offset_method;
10251
10252 ELSE
10253
10254 /* else check the cache to see if the automatic offset method is cached for this org */
10255 FOR i IN G_AUTOMATIC_OFFSET_METHOD.FIRST..G_AUTOMATIC_OFFSET_METHOD.LAST LOOP
10256
10257 IF G_AUTOMATIC_OFFSET_METHOD(i).ORG_ID = p_org_id THEN
10258
10259 l_automatic_offset_method := G_AUTOMATIC_OFFSET_METHOD(i).METHOD;
10260 EXIT;
10261
10262 END IF;
10263
10264 END LOOP;
10265
10266 IF l_automatic_offset_method = 'UNKNOWN' THEN
10267
10268 /* if the offset method is still undetermined, it means that it was not found in the cahce.
10269 So it has to be derived using the cursor and the cache has to be updated */
10270 OPEN c_get_ap_offset_method;
10271 FETCH c_get_ap_offset_method
10272 INTO l_automatic_offset_method;
10273 CLOSE c_get_ap_offset_method;
10274
10275 G_AUTOMATIC_OFFSET_METHOD(G_AUTOMATIC_OFFSET_METHOD.LAST + 1).ORG_ID := p_org_id;
10276 G_AUTOMATIC_OFFSET_METHOD(G_AUTOMATIC_OFFSET_METHOD.LAST + 1).METHOD := l_automatic_offset_method;
10277
10278 END IF;
10279
10280 END IF;
10281
10282 IF l_automatic_offset_method IS NOT NULL THEN
10283
10284 /* If automatic adjustment is enabled, then check if the transaction can be adjusted or not */
10285
10286 /* we can set the billable/capitalizable flag based on the adjustment action */
10287 IF p_action IN ('BILLABLE RECLASS','CAPITALIZABLE RECLASS') THEN
10288
10289 l_billable_flag := 'Y';
10290
10291 ELSIF p_action IN ('NON-BILLABLE RECLASS','NON-CAPITALIZABLE RECLASS') THEN
10292
10293 l_billable_flag := 'N';
10294
10295 ELSE
10296
10297 l_billable_flag := p_billable_flag1;
10298
10299 END IF;
10300
10301 /* get the original and new Charge account */
10302 IF p_expenditure_item_id <> NVL(G_EXP_ITEM_ID,-99) THEN
10303 get_old_and_new_ccid(p_expenditure_item_id
10304 ,p_project_id
10305 ,p_task_id
10306 ,p_expenditure_type
10307 ,p_vendor_id
10308 ,p_expenditure_organization_id
10309 ,p_expenditure_item_date
10310 ,l_billable_flag
10311 ,p_org_id
10312 ,p_emp_id
10313 ,p_award_id
10314 ,p_system_linkage_function
10315 ,p_transaction_source
10316 ,p_invoice_distribution_id
10317 ,G_OLD_CCID
10318 ,G_NEW_CCID
10319 ,l_encoded_error_message); /* Bug 4997739 */
10320 /* Bug 4997739 - Return false if there were any errors in workflow */
10321 IF l_encoded_error_message IS NOT NULL THEN
10322 x_encoded_error_message := l_encoded_error_message;
10323 RETURN FALSE;
10324 END IF;
10325 G_EXP_ITEM_ID := p_expenditure_item_id;
10326 END IF;
10327
10328 /* check if the liability account is affected */
10329 IF get_auto_offsets_segments(l_automatic_offset_method,G_OLD_CCID,G_COA_ID)
10330 <> get_auto_offsets_segments(l_automatic_offset_method,G_NEW_CCID,G_COA_ID) THEN
10331
10332 /* if yes, then set the return value to FALSE */
10333 l_return := FALSE;
10334
10335 END IF;
10336
10337 IF l_return = TRUE
10338 AND p_action = 'SPLIT' THEN
10339
10340 /* if the adjustment action is split, then the second part of the split transaction
10341 also has to be verified */
10342 IF p_expenditure_item_id <> NVL(G_EXP_ITEM_ID,-99) THEN
10343 get_old_and_new_ccid(p_expenditure_item_id
10344 ,p_project_id
10345 ,p_task_id
10346 ,p_expenditure_type
10347 ,p_vendor_id
10348 ,p_expenditure_organization_id
10349 ,p_expenditure_item_date
10350 ,p_billable_flag2
10351 ,p_org_id
10352 ,p_emp_id
10353 ,p_award_id
10354 ,p_system_linkage_function
10355 ,p_transaction_source
10356 ,p_invoice_distribution_id
10357 ,G_OLD_CCID
10358 ,G_NEW_CCID
10359 ,l_encoded_error_message); /* Bug 4997739 */
10360 /* Bug 4997739 - Return false if there were any errors in workflow */
10361 IF l_encoded_error_message IS NOT NULL THEN
10362 x_encoded_error_message := l_encoded_error_message;
10363 RETURN FALSE;
10364 END IF;
10365 G_EXP_ITEM_ID := p_expenditure_item_id;
10366 END IF;
10367
10368 IF get_auto_offsets_segments(l_automatic_offset_method,G_OLD_CCID,G_COA_ID)
10369 <> get_auto_offsets_segments(l_automatic_offset_method,G_NEW_CCID,G_COA_ID) THEN
10370
10371 l_return := FALSE;
10372
10373 END IF;
10374
10375 END IF;
10376
10377 END IF;
10378
10379 RETURN l_return;
10380
10381 END Allow_Adjust_with_Auto_Offset;
10382 /* R12 changes End */
10383
10384 /* R12 Changes Start */
10385 FUNCTION Get_Displayed_Field
10386 ( p_lookup_type varchar2
10387 , p_lookup_code varchar2)
10388 RETURN VARCHAR2 IS
10389
10390 CURSOR C_Inv_Displayed_Field_Cur IS
10391 SELECT displayed_field
10392 FROM ap_lookup_codes
10393 WHERE lookup_type = p_lookup_type
10394 AND lookup_code = p_lookup_code
10395 UNION /*Bug # 13547633 Self Assessed Tax Changes */
10396 SELECT meaning
10397 FROM pa_lookups
10398 WHERE lookup_type = p_lookup_type
10399 AND lookup_code = p_lookup_code;
10400
10401 CURSOR C_PO_Displayed_Field_Cur IS
10402 SELECT displayed_field
10403 FROM po_lookup_codes
10404 WHERE lookup_type = p_lookup_type
10405 AND lookup_code = p_lookup_code;
10406
10407 BEGIN
10408
10409 IF p_lookup_type = 'INVOICE TYPE' THEN
10410
10411 IF p_lookup_code <> NVL(G_INV_TYPE_CODE,-99) THEN
10412
10413 OPEN C_Inv_Displayed_Field_Cur;
10414 FETCH C_Inv_Displayed_Field_Cur
10415 INTO G_INV_TYPE;
10416 CLOSE C_Inv_Displayed_Field_Cur;
10417
10418 G_INV_TYPE_CODE := p_lookup_code;
10419
10420 END IF;
10421
10422 RETURN G_INV_TYPE;
10423
10424 END IF;
10425
10426 IF p_lookup_type = 'INVOICE LINE TYPE' THEN
10427
10428 IF p_lookup_code <> NVL(G_INV_LINE_TYPE_CODE,-99) THEN
10429
10430 OPEN C_Inv_Displayed_Field_Cur;
10431 FETCH C_Inv_Displayed_Field_Cur
10432 INTO G_INV_LINE_TYPE;
10433 CLOSE C_Inv_Displayed_Field_Cur;
10434
10435 G_INV_LINE_TYPE_CODE := p_lookup_code;
10436
10437 END IF;
10438
10439 RETURN G_INV_LINE_TYPE;
10440
10441 END IF;
10442
10443 IF (p_lookup_type = 'INVOICE DISTRIBUTION TYPE' OR p_lookup_type = 'TRANSACTION_TYPE' )THEN /*Bug # 13547633 Self Assessed Tax Changes */
10444
10445 IF p_lookup_code <> NVL(G_INV_DIST_TYPE_CODE,-99) THEN
10446
10447 OPEN C_Inv_Displayed_Field_Cur;
10448 FETCH C_Inv_Displayed_Field_Cur
10449 INTO G_INV_DIST_TYPE;
10450 CLOSE C_Inv_Displayed_Field_Cur;
10451
10452 G_INV_DIST_TYPE_CODE := p_lookup_code;
10453
10454 END IF;
10455
10456 RETURN G_INV_DIST_TYPE;
10457
10458 END IF;
10459
10460 /* Bug 4914048 - Start */
10461 IF p_lookup_type = 'PAYMENT TYPE' THEN
10462
10463 IF p_lookup_code <> NVL(G_PAYMENT_TYPE_CODE,-99) THEN
10464
10465 OPEN C_Inv_Displayed_Field_Cur;
10466 FETCH C_Inv_Displayed_Field_Cur
10467 INTO G_PAYMENT_TYPE;
10468 CLOSE C_Inv_Displayed_Field_Cur;
10469
10470 G_PAYMENT_TYPE_CODE := p_lookup_code;
10471
10472 END IF;
10473
10474 RETURN G_PAYMENT_TYPE;
10475
10476 END IF;
10477 /* Bug 4914048 - End */
10478
10479 IF p_lookup_type = 'PO TYPE' THEN
10480
10481 IF p_lookup_code <> NVL(G_PO_DIST_TYPE_CODE,-99) THEN
10482
10483 OPEN C_PO_Displayed_Field_Cur;
10484 FETCH C_PO_Displayed_Field_Cur
10485 INTO G_PO_DIST_TYPE;
10486 CLOSE C_PO_Displayed_Field_Cur;
10487
10488 G_PO_DIST_TYPE_CODE := p_lookup_code;
10489
10490 END IF;
10491
10492 RETURN G_PO_DIST_TYPE;
10493
10494 END IF;
10495
10496 IF p_lookup_type = 'RCV TRANSACTION TYPE' THEN
10497
10498 IF p_lookup_code <> NVL(G_RCV_TXN_TYPE_CODE,-99) THEN
10499
10500 OPEN C_PO_Displayed_Field_Cur;
10501 FETCH C_PO_Displayed_Field_Cur
10502 INTO G_RCV_TXN_TYPE;
10503 CLOSE C_PO_Displayed_Field_Cur;
10504
10505 G_RCV_TXN_TYPE_CODE := p_lookup_code;
10506
10507 END IF;
10508
10509 RETURN G_RCV_TXN_TYPE;
10510
10511 END IF;
10512
10513 RETURN NULL;
10514
10515 END Get_Displayed_Field;
10516
10517 FUNCTION Get_PO_Info
10518 ( p_key varchar2
10519 , p_po_distribution_id number)
10520 RETURN VARCHAR2 IS
10521
10522 l_po_distribution_type_code varchar2(30);
10523
10524 CURSOR C_PO_Info_Cur IS
10525 SELECT po.po_header_id
10526 , po.segment1
10527 , po.creation_date
10528 , po_line.line_num
10529 , po_dist.distribution_num
10530 , po_dist.distribution_type
10531 FROM po_headers po
10532 , po_lines po_line
10533 , po_distributions po_dist
10534 WHERE po.po_header_id = po_line.po_header_id
10535 AND po_line.po_line_id = po_dist.po_line_id
10536 AND po_dist.po_distribution_id = p_po_distribution_id;
10537 BEGIN
10538
10539 IF p_po_distribution_id IS NULL THEN
10540
10541 RETURN NULL;
10542
10543 END IF;
10544
10545 IF NVL(G_PO_DIST_ID,-99) <> p_po_distribution_id THEN
10546
10547 OPEN C_PO_Info_Cur;
10548 FETCH C_PO_Info_Cur
10549 INTO G_PO_HEADER_ID
10550 , G_PO_NUM
10551 , G_PO_DATE
10552 , G_PO_LINE_NUM
10553 , G_PO_DIST_NUM
10554 , l_po_distribution_type_code;
10555 CLOSE C_PO_Info_Cur;
10556
10557 G_PO_DIST_TYPE := Get_Displayed_Field('PO TYPE', l_po_distribution_type_code);
10558
10559 G_PO_DIST_ID := p_po_distribution_id;
10560
10561 END IF;
10562
10563 CASE p_key
10564 WHEN 'PO HEADER ID' THEN RETURN G_PO_HEADER_ID;
10565 WHEN 'PO NUM' THEN RETURN G_PO_NUM;
10566 WHEN 'PO DATE' THEN RETURN to_char(G_PO_DATE,'DD-MON-YYYY');
10567 WHEN 'PO LINE NUM' THEN RETURN G_PO_LINE_NUM;
10568 WHEN 'PO DIST NUM' THEN RETURN G_PO_DIST_NUM;
10569 WHEN 'PO TYPE' THEN RETURN G_PO_DIST_TYPE;
10570 END CASE;
10571
10572 EXCEPTION
10573 WHEN OTHERS THEN
10574 G_PO_DIST_ID := NULL;
10575 G_PO_HEADER_ID := NULL;
10576 G_PO_NUM := NULL;
10577 G_PO_DATE := NULL;
10578 G_PO_LINE_NUM := NULL;
10579 G_PO_DIST_NUM := NULL;
10580 G_PO_DIST_TYPE := NULL;
10581 RAISE;
10582
10583 END Get_PO_Info;
10584
10585 FUNCTION Get_Rcv_Info
10586 ( p_key varchar2
10587 , p_rcv_transaction_id number)
10588 RETURN VARCHAR2 IS
10589
10590 l_rcv_transaction_type_code varchar2(30);
10591
10592 CURSOR C_Rcv_Info_Cur IS
10593 SELECT rcv.receipt_num
10594 , rcvtxn.transaction_date
10595 , rcvtxn.transaction_type
10596 FROM rcv_shipment_headers rcv
10597 , rcv_transactions rcvtxn
10598 WHERE rcv.shipment_header_id = rcvtxn.shipment_header_id
10599 AND rcvtxn.transaction_id = p_rcv_transaction_id;
10600
10601 BEGIN
10602
10603 IF p_rcv_transaction_id IS NULL THEN
10604
10605 RETURN NULL;
10606
10607 END IF;
10608
10609 IF NVL(G_RCV_TXN_ID,-1) <> p_rcv_transaction_id THEN
10610
10611 OPEN C_Rcv_Info_Cur;
10612 FETCH C_Rcv_Info_Cur
10613 INTO G_RCV_NUM
10614 , G_RCV_DATE
10615 , l_rcv_transaction_type_code;
10616 CLOSE C_Rcv_Info_Cur;
10617
10618 G_RCV_TXN_TYPE := Get_Displayed_Field('RCV TRANSACTION TYPE', l_rcv_transaction_type_code);
10619
10620 G_RCV_TXN_ID := p_rcv_transaction_id;
10621
10622 END IF;
10623
10624 CASE p_key
10625 WHEN 'RECEIPT NUMBER' THEN RETURN G_RCV_NUM;
10626 WHEN 'RECEIPT DATE' THEN RETURN to_char(G_RCV_DATE,'DD-MON-YYYY');
10627 WHEN 'RCV TRANSACTION TYPE' THEN RETURN G_RCV_TXN_TYPE;
10628 END CASE;
10629
10630 EXCEPTION
10631 WHEN OTHERS THEN
10632 G_RCV_TXN_ID := NULL;
10633 G_RCV_NUM := NULL;
10634 G_RCV_DATE := NULL;
10635 RAISE;
10636
10637 END Get_Rcv_Info;
10638
10639 FUNCTION Get_Inv_Info
10640 ( p_key varchar2
10641 , p_invoice_id number)
10642 RETURN VARCHAR2 IS
10643
10644 l_inv_type_code varchar2(30);
10645
10646 CURSOR C_Inv_Info_Cur IS
10647 SELECT ap.invoice_type_lookup_code
10648 , ap.invoice_num
10649 , ap.invoice_date
10650 FROM ap_invoices ap
10651 WHERE ap.invoice_id = p_invoice_id;
10652
10653 BEGIN
10654
10655 IF p_invoice_id IS NULL THEN
10656
10657 RETURN NULL;
10658
10659 END IF;
10660
10661 IF NVL(G_INV_ID,-1) <> p_invoice_id THEN
10662
10663 OPEN C_Inv_Info_Cur;
10664 FETCH C_Inv_Info_Cur
10665 INTO l_inv_type_code
10666 , G_INV_NUM
10667 , G_INV_DATE;
10668 CLOSE C_Inv_Info_Cur;
10669
10670 G_INV_TYPE := Get_Displayed_Field('INVOICE TYPE', l_inv_type_code);
10671
10672 G_INV_ID := p_invoice_id;
10673
10674 END IF;
10675
10676 CASE p_key
10677 WHEN 'INVOICE TYPE' THEN RETURN G_INV_TYPE;
10678 WHEN 'INVOICE NUMBER' THEN RETURN G_INV_NUM;
10679 WHEN 'INVOICE DATE' THEN RETURN to_char(G_INV_DATE,'DD-MON-YYYY');
10680 END CASE;
10681
10682 EXCEPTION
10683 WHEN OTHERS THEN
10684 G_INV_ID := NULL;
10685 G_INV_NUM := NULL;
10686 G_INV_DATE := NULL;
10687 RAISE;
10688
10689 END Get_Inv_Info;
10690
10691 --=======================================================================
10692 -- Function is_recoverability_affected
10693 --=======================================================================
10694 FUNCTION is_recoverability_affected
10695 (p_expenditure_item_id IN NUMBER,
10696 p_org_id IN NUMBER,
10697 p_system_linkage_function IN VARCHAR2,
10698 p_transaction_source IN VARCHAR2,
10699 P_action IN VARCHAR2,
10700 P_project_id IN NUMBER,
10701 P_task_id IN NUMBER,
10702 p_expenditure_type IN VARCHAR2,
10703 p_vendor_id IN NUMBER,
10704 p_expenditure_organization_id IN NUMBER,
10705 p_expenditure_item_date IN DATE,
10706 p_emp_id IN NUMBER,
10707 p_document_header_id IN NUMBER,
10708 p_document_line_number IN NUMBER,
10709 p_document_distribution_id IN NUMBER,
10710 p_document_distribution_type IN VARCHAR2 DEFAULT NULL, /*Self Assessed Tax Changes*//*Bug 13906739: Added NULL as default parameter Value*/
10711 p_document_type IN VARCHAR2,
10712 p_award_id IN NUMBER,
10713 p_billable_flag1 IN VARCHAR2,
10714 p_billable_flag2 IN VARCHAR2,
10715 x_error_message_name OUT NOCOPY VARCHAR2, /* Bug 4997739 */
10716 x_encoded_error_message OUT NOCOPY VARCHAR2) /* Bug 4997739 */
10717 return BOOLEAN is
10718
10719 l_billable_flag VARCHAR2(1);
10720 l_po_line_location_id NUMBER;
10721 l_old_ccid NUMBER;
10722 l_new_ccid NUMBER;
10723 l_return BOOLEAN := FALSE;
10724 l_pa_item_info_tbl ZX_API_PUB.pa_item_info_tbl_type;
10725 l_return_status VARCHAR2(1);
10726 l_msg_count NUMBER;
10727 X_error_code VARCHAR2(30);
10728 l_encoded_error_message VARCHAR2(2000);
10729 l_parent_distribution_id AP_INVOICE_DISTRIBUTIONS_ALL.INVOICE_DISTRIBUTION_ID%TYPE; /* Bug 5386471 */
10730 l_parent_line_number AP_INVOICE_DISTRIBUTIONS_ALL.INVOICE_LINE_NUMBER%TYPE; /* Bug 5386471 */
10731 l_ccid_changed BOOLEAN := FALSE; /* Bug 5440305 */
10732
10733 CURSOR c_po_shipment_id_cur(p_po_distribution_id NUMBER) IS
10734 SELECT LINE_LOCATION_ID
10735 FROM PO_DISTRIBUTIONS
10736 WHERE PO_DISTRIBUTION_ID = p_po_distribution_id;
10737
10738 /* Bug 5386471 - Start */
10739 CURSOR c_parent_distribution_id_cur(p_invoice_distribution_id AP_INVOICE_DISTRIBUTIONS_ALL.INVOICE_DISTRIBUTION_ID%TYPE) IS
10740 SELECT NVL(charge_applicable_to_dist_id,NVL(related_id, invoice_distribution_id))
10741 FROM ap_invoice_distributions_all
10742 WHERE invoice_distribution_id = p_invoice_distribution_id;
10743
10744 CURSOR c_parent_line_number_cur(p_parent_distribution_id AP_INVOICE_DISTRIBUTIONS_ALL.INVOICE_DISTRIBUTION_ID%TYPE) IS
10745 SELECT invoice_line_number
10746 FROM ap_invoice_distributions_all
10747 WHERE invoice_distribution_id = p_parent_distribution_id;
10748 /*Self Assessed Tax Changes */
10749
10750 CURSOR c_parent_dist_id_sat_cur(p_invoice_distribution_id AP_SELF_ASSESSED_TAX_DIST_ALL.INVOICE_DISTRIBUTION_ID%TYPE) IS
10751 SELECT NVL(charge_applicable_to_dist_id,NVL(related_id, invoice_distribution_id))
10752 FROM ap_self_assessed_tax_dist_all
10753 WHERE invoice_distribution_id = p_invoice_distribution_id;
10754
10755 CURSOR c_parent_line_number_sat_cur(p_parent_distribution_id AP_SELF_ASSESSED_TAX_DIST_ALL.INVOICE_DISTRIBUTION_ID%TYPE) IS
10756 SELECT invoice_line_number
10757 FROM ap_self_assessed_tax_dist_all
10758 WHERE invoice_distribution_id = p_parent_distribution_id;
10759 /* Bug 5386471 - End */
10760
10761 etax_exception EXCEPTION;
10762 PRAGMA EXCEPTION_INIT(etax_exception,-20001);
10763 BEGIN
10764 /* check if the tax recovery rate can change */
10765 IF p_action IN ('BILLABLE RECLASS','CAPITALIZABLE RECLASS') THEN
10766
10767 l_billable_flag := 'Y';
10768
10769 ELSIF p_action IN ('NON-BILLABLE RECLASS','NON-CAPITALIZABLE RECLASS') THEN
10770
10771 l_billable_flag := 'N';
10772
10773 ELSE
10774
10775 l_billable_flag := p_billable_flag1;
10776
10777 END IF;
10778
10779 /* get the original and new Charge account */
10780 IF p_expenditure_item_id <> NVL(G_EXP_ITEM_ID,-99) THEN
10781
10782 get_old_and_new_ccid(p_expenditure_item_id
10783 ,p_project_id
10784 ,p_task_id
10785 ,p_expenditure_type
10786 ,p_vendor_id
10787 ,p_expenditure_organization_id
10788 ,p_expenditure_item_date
10789 ,l_billable_flag
10790 ,p_org_id
10791 ,p_emp_id
10792 ,p_award_id
10793 ,p_system_linkage_function
10794 ,p_transaction_source
10795 ,p_document_distribution_id
10796 ,G_OLD_CCID
10797 ,G_NEW_CCID
10798 ,l_encoded_error_message); /* Bug 4997739 */
10799 /* Bug 4997739 - Return true if there were any errors in workflow */
10800 IF l_encoded_error_message IS NOT NULL THEN
10801 x_encoded_error_message := l_encoded_error_message;
10802 RETURN TRUE;
10803 END IF;
10804 G_EXP_ITEM_ID := p_expenditure_item_id;
10805
10806 END IF;
10807
10808 /* Bug 5440305 - Set flag if the account changes */
10809 IF G_OLD_CCID <> G_NEW_CCID THEN
10810
10811 l_ccid_changed := TRUE;
10812
10813 END IF;
10814
10815 IF p_transaction_source IN ('AP INVOICE'
10816 ,'INTERCOMPANY_AP_INVOICES'
10817 ,'INTERPROJECT_AP_INVOICES'
10818 ,'AP VARIANCE'
10819 ,'AP NRTAX'
10820 ,'AP DISCOUNTS'
10821 ,'AP EXPENSE'
10822 ,'AP ERV') THEN /* Bug 5235354 */
10823
10824 /* Bug 5386471 - Start */
10825 /*Self Assessed Tax Changes*/
10826 if p_document_distribution_type <> 'SELF_ASSESSED_TAX' then
10827 OPEN c_parent_distribution_id_cur(p_document_distribution_id);
10828 FETCH c_parent_distribution_id_cur
10829 INTO l_parent_distribution_id;
10830 CLOSE c_parent_distribution_id_cur;
10831 else
10832 OPEN c_parent_dist_id_sat_cur(p_document_distribution_id);
10833 FETCH c_parent_dist_id_sat_cur
10834 INTO l_parent_distribution_id;
10835 CLOSE c_parent_dist_id_sat_cur;
10836 end if;
10837
10838
10839 IF l_parent_distribution_id = p_document_distribution_id THEN
10840 l_parent_line_number := p_document_line_number;
10841 ELSE
10842 /*Self Assessed Tax Changes*/
10843 if p_document_distribution_type <> 'SELF_ASSESSED_TAX' then
10844 OPEN c_parent_line_number_cur(l_parent_distribution_id);
10845 FETCH c_parent_line_number_cur
10846 INTO l_parent_line_number;
10847 CLOSE c_parent_line_number_cur;
10848 else
10849 OPEN c_parent_line_number_sat_cur(p_document_distribution_id);
10850 FETCH c_parent_line_number_sat_cur
10851 INTO l_parent_line_number;
10852 CLOSE c_parent_line_number_sat_cur;
10853 end if;
10854
10855 END IF;
10856 /* Bug 5386471 - End */
10857
10858 l_pa_item_info_tbl(1).APPLICATION_ID := 200; --(Oracle payables application Id)
10859 l_pa_item_info_tbl(1).ENTITY_CODE := 'AP_INVOICES';
10860 CASE p_document_type
10861 WHEN 'STANDARD' THEN l_pa_item_info_tbl(1).EVENT_CLASS_CODE := 'STANDARD INVOICES';
10862 WHEN 'PREPAYMENT' THEN l_pa_item_info_tbl(1).EVENT_CLASS_CODE := 'PREPAYMENT INVOICES';
10863 WHEN 'EXPENSE REPORT' THEN l_pa_item_info_tbl(1).EVENT_CLASS_CODE := 'EXPENSE REPORTS';
10864 /* Bug 5386471 - Start */
10865 WHEN 'CREDIT' THEN l_pa_item_info_tbl(1).EVENT_CLASS_CODE := 'STANDARD INVOICES';
10866 WHEN 'DEBIT' THEN l_pa_item_info_tbl(1).EVENT_CLASS_CODE := 'STANDARD INVOICES';
10867 WHEN 'MIXED' THEN l_pa_item_info_tbl(1).EVENT_CLASS_CODE := 'STANDARD INVOICES';
10868 /* Bug 5386471 - End */
10869 ELSE l_pa_item_info_tbl(1).EVENT_CLASS_CODE := NULL;
10870 END CASE;
10871 l_pa_item_info_tbl(1).TRX_ID := p_document_header_id;
10872 l_pa_item_info_tbl(1).TRX_LINE_ID := l_parent_line_number; /* Bug 5386471 */
10873 l_pa_item_info_tbl(1).TRX_LEVEL_TYPE := 'LINE';
10874 l_pa_item_info_tbl(1).ITEM_EXPENSE_DIST_ID := l_parent_distribution_id; /* Bug 5386471 */
10875 l_pa_item_info_tbl(1).NEW_ACCOUNT_CCID := G_NEW_CCID;
10876 l_pa_item_info_tbl(1).NEW_ACCOUNT_STRING := NULL;
10877 l_pa_item_info_tbl(1).NEW_PROJECT_ID := p_project_id;
10878 l_pa_item_info_tbl(1).NEW_TASK_ID := p_task_id;
10879 l_pa_item_info_tbl(1).RECOVERABILITY_AFFECTED := FALSE;
10880
10881 ELSIF p_transaction_source IN ('PO RECEIPT'
10882 ,'PO RECEIPT NRTAX'
10883 ,'PO RECEIPT NRTAX PRICE ADJ'
10884 ,'PO RECEIPT PRICE ADJ') THEN
10885
10886 /* Bug 5386471 - Start */
10887 OPEN c_po_shipment_id_cur(p_document_line_number);
10888 FETCH c_po_shipment_id_cur
10889 INTO l_po_line_location_id;
10890 CLOSE c_po_shipment_id_cur;
10891 /* Bug 5386471 - End */
10892
10893 l_pa_item_info_tbl(1).APPLICATION_ID := 201; --(Oracle purchasing application Id)
10894 l_pa_item_info_tbl(1).ENTITY_CODE := 'PURCHASE_ORDER';
10895 l_pa_item_info_tbl(1).EVENT_CLASS_CODE := 'PO_PA';
10896 l_pa_item_info_tbl(1).TRX_ID := p_document_header_id;
10897 l_pa_item_info_tbl(1).TRX_LINE_ID := l_po_line_location_id;
10898 l_pa_item_info_tbl(1).TRX_LEVEL_TYPE := 'SHIPMENT'; /* Bug 5386471 */
10899 l_pa_item_info_tbl(1).ITEM_EXPENSE_DIST_ID := p_document_line_number; /* Bug 5386471 */
10900 l_pa_item_info_tbl(1).NEW_ACCOUNT_CCID := G_NEW_CCID;
10901 l_pa_item_info_tbl(1).NEW_ACCOUNT_STRING := NULL ;
10902 l_pa_item_info_tbl(1).NEW_PROJECT_ID := p_project_id;
10903 l_pa_item_info_tbl(1).NEW_TASK_ID := p_task_id;
10904 l_pa_item_info_tbl(1).RECOVERABILITY_AFFECTED := FALSE;
10905
10906 END IF;
10907
10908 /* Bug 5440305 - eBTax API will be called only if there is a change in the account */
10909 IF l_ccid_changed THEN
10910
10911 l_ccid_changed := FALSE; /* Bug 5440305 - Reset the flag */
10912
10913 ZX_API_PUB.is_recoverability_affected(
10914 p_api_version => 1.0,
10915 p_init_msg_list => FND_API.G_TRUE,
10916 p_commit => NULL,
10917 p_validation_level => NULL,
10918 x_return_status => l_return_status,
10919 x_msg_count => l_msg_count,
10920 x_msg_data => X_error_code,
10921 p_pa_item_info_tbl => l_pa_item_info_tbl);
10922
10923 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
10924
10925 x_error_message_name := 'PA_SI_ADJ_ETAX_EXCEPTION';
10926 RETURN TRUE;
10927
10928 END IF;
10929
10930 IF l_pa_item_info_tbl(1).RECOVERABILITY_AFFECTED THEN
10931
10932 l_return := TRUE;
10933
10934 END IF;
10935
10936 END IF;
10937
10938 IF l_return = FALSE
10939 AND p_action = 'SPLIT' THEN
10940
10941 /* if the adjustment action is split, then the second part of the split transaction
10942 also has to be verified */
10943 IF p_expenditure_item_id <> NVL(G_EXP_ITEM_ID,-99) THEN
10944
10945 get_old_and_new_ccid(p_expenditure_item_id
10946 ,p_project_id
10947 ,p_task_id
10948 ,p_expenditure_type
10949 ,p_vendor_id
10950 ,p_expenditure_organization_id
10951 ,p_expenditure_item_date
10952 ,p_billable_flag2
10953 ,p_org_id
10954 ,p_emp_id
10955 ,p_award_id
10956 ,p_system_linkage_function
10957 ,p_transaction_source
10958 ,p_document_distribution_id
10959 ,G_OLD_CCID
10960 ,G_NEW_CCID
10961 ,l_encoded_error_message); /* Bug 4997739 */
10962 /* Bug 4997739 - Return true if there were any errors in workflow */
10963 IF l_encoded_error_message IS NOT NULL THEN
10964 x_encoded_error_message := l_encoded_error_message;
10965 RETURN TRUE;
10966 END IF;
10967
10968 G_EXP_ITEM_ID := p_expenditure_item_id;
10969
10970 END IF;
10971
10972 /* Bug 5440305 - Set flag if the account changes */
10973 IF G_OLD_CCID <> G_NEW_CCID THEN
10974
10975 l_ccid_changed := TRUE;
10976
10977 END IF;
10978
10979 l_pa_item_info_tbl(1).NEW_ACCOUNT_CCID := G_NEW_CCID;
10980
10981 /* Bug 5440305 - eBTax API will be called only if there is a change in the account */
10982 IF l_ccid_changed THEN
10983
10984 l_ccid_changed := FALSE; /* Bug 5440305 - Reset the flag */
10985 ZX_API_PUB.is_recoverability_affected(
10986 p_api_version => 1.0,
10987 p_init_msg_list => FND_API.G_TRUE,
10988 p_commit => NULL,
10989 p_validation_level => NULL,
10990 x_return_status => l_return_status,
10991 x_msg_count => l_msg_count,
10992 x_msg_data => X_error_code,
10993 p_pa_item_info_tbl => l_pa_item_info_tbl);
10994
10995 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
10996
10997 x_error_message_name := 'PA_SI_ADJ_ETAX_EXCEPTION';
10998 RETURN TRUE;
10999
11000 END IF;
11001
11002 IF l_pa_item_info_tbl(1).RECOVERABILITY_AFFECTED THEN
11003
11004 l_return := TRUE;
11005
11006 END IF;
11007
11008 END IF;
11009
11010 END IF;
11011
11012 IF l_return = TRUE THEN
11013
11014 x_error_message_name := 'PA_SI_ADJ_NRTAX_CHG_NOT_ALLOW';
11015
11016 END IF;
11017
11018 RETURN l_return;
11019
11020 END is_recoverability_affected;
11021 /* R12 Changes End */
11022
11023 /* Bug 4901129 - Start */
11024 FUNCTION is_orphaned_src_sys_reversal( p_document_distribution_id IN PA_EXPENDITURE_ITEMS_ALL.DOCUMENT_DISTRIBUTION_ID%TYPE
11025 , p_transaction_source IN PA_EXPENDITURE_ITEMS_ALL.TRANSACTION_SOURCE%TYPE)
11026 RETURN VARCHAR2 IS
11027 l_result VARCHAR2(1) := 'N';
11028
11029 CURSOR c_get_count IS
11030 SELECT DECODE(count(*),0,'N','Y')
11031 FROM pa_expenditure_items_all ei /* Bug 5561597 */
11032 WHERE ( ei.document_header_id, ei.document_distribution_id) IN
11033 ( SELECT apdist2.invoice_id, apdist2.invoice_distribution_id /* Bug 5561597 */
11034 FROM ap_invoice_distributions_all apdist1, /* Bug 5561597 */
11035 ap_invoice_distributions_all apdist2 /* Bug 5561597 */
11036 WHERE p_document_distribution_id = apdist1.invoice_distribution_id
11037 AND apdist1.reversal_flag = 'Y'
11038 AND apdist1.parent_reversal_id = apdist2.invoice_distribution_id
11039 AND apdist2.old_distribution_id IS NOT NULL
11040 AND p_transaction_source IN ('AP VARIANCE','AP INVOICE'
11041 ,'AP DISCOUNTS','INTERCOMPANY_AP_INVOICES','INTERPROJECT_AP_INVOICES'
11042 ,'AP NRTAX','AP EXPENSE','AP ERV') /* Bug 5235354 */
11043 UNION ALL
11044 SELECT apdist2.invoice_id, apdist2.invoice_distribution_id /*Self Assessed Tax Changes*/
11045 FROM ap_self_assessed_tax_dist_all apdist1,
11046 ap_self_assessed_tax_dist_all apdist2
11047 WHERE p_document_distribution_id = apdist1.invoice_distribution_id
11048 AND apdist1.reversal_flag = 'Y'
11049 AND apdist1.parent_reversal_id = apdist2.invoice_distribution_id
11050 --AND apdist2.old_distribution_id IS NOT NULL
11051 AND p_transaction_source IN ('AP VARIANCE','AP INVOICE'
11052 ,'AP DISCOUNTS','INTERCOMPANY_AP_INVOICES','INTERPROJECT_AP_INVOICES'
11053 ,'AP NRTAX','AP EXPENSE','AP ERV')
11054 UNION ALL
11055 SELECT rcv2.po_header_id, rcv2.transaction_id
11056 FROM rcv_transactions rcv1
11057 , rcv_transactions rcv2
11058 WHERE rcv1.transaction_id = p_document_distribution_id
11059 AND rcv1.transaction_type in ('RETURN TO RECEIVING','RETURN TO VENDOR','CORRECT')
11060 AND rcv1.parent_transaction_id = rcv2.transaction_id
11061 AND p_transaction_source IN ('PO RECEIPT','PO RECEIPT NRTAX',
11062 'PO RECEIPT NRTAX PRICE ADJ','PO RECEIPT PRICE ADJ'))
11063 AND ( ei.net_zero_adjustment_flag = 'Y'
11064 OR EXISTS ( SELECT NULL
11065 FROM pa_cost_distribution_lines_all cdl2
11066 WHERE cdl2.expenditure_item_id = ei.expenditure_item_id
11067 AND cdl2.line_num = 1
11068 AND cdl2.reversed_flag = 'Y'));
11069 BEGIN
11070 OPEN c_get_count;
11071 FETCH c_get_count INTO l_result;
11072 CLOSE c_get_count;
11073
11074 RETURN l_result;
11075 END is_orphaned_src_sys_reversal;
11076 /* Bug 4901129 - End */
11077
11078 /* Bug 5235354 - Start */
11079 FUNCTION RepCurrOrSecLedgerDiffCurr(p_org_id PA_EXPENDITURE_ITEMS_ALL.ORG_ID%TYPE)
11080 RETURN BOOLEAN IS
11081
11082 l_count NUMBER := -1;
11083 l_return BOOLEAN := FALSE;
11084
11085 CURSOR c_rep_curr_or_sec_ledger is
11086 SELECT COUNT(*)
11087 FROM gl_ledgers_v gl,
11088 pa_implementations imp
11089 WHERE imp.set_of_books_id = gl.ledger_id
11090 AND (EXISTS
11091 (SELECT NULL
11092 FROM gl_secondary_ledger_rships_v sl,
11093 xla_subledger_options_v xso
11094 WHERE sl.primary_ledger_id = gl.ledger_id
11095 AND sl.currency_code <> gl.currency_code
11096 AND sl.relationship_enabled_flag = 'Y'
11097 AND xso.application_id = 275
11098 AND xso.enabled_flag = 'Y'
11099 AND xso.ledger_id = sl.ledger_id)
11100 OR EXISTS
11101 (SELECT NULL
11102 FROM gl_alc_ledger_rships_v alc
11103 WHERE alc.primary_ledger_id = gl.ledger_id
11104 AND alc.currency_code <> gl.currency_code
11105 AND alc.application_id = 275
11106 AND relationship_enabled_flag = 'Y'));
11107
11108 BEGIN
11109 IF G_LEDGER_CNT.COUNT = 0 THEN
11110
11111 /* If cache is empty, then populate the PL/SQL table with the query result and
11112 corresponding org_id */
11113 OPEN c_rep_curr_or_sec_ledger;
11114 FETCH c_rep_curr_or_sec_ledger INTO l_count;
11115 CLOSE c_rep_curr_or_sec_ledger ;
11116
11117 G_LEDGER_CNT(1).ORG_ID := p_org_id;
11118 G_LEDGER_CNT(1).CNT := l_count;
11119
11120 ELSE
11121
11122 /* else check the cache to see if it is cached for this org */
11123 FOR i IN G_LEDGER_CNT.FIRST..G_LEDGER_CNT.LAST LOOP
11124
11125 IF G_LEDGER_CNT(i).ORG_ID = p_org_id THEN
11126
11127 l_count := G_LEDGER_CNT(i).CNT;
11128 EXIT;
11129
11130 END IF;
11131
11132 END LOOP;
11133
11134 IF l_count = -1 THEN
11135
11136 /* if it is still undetermined, it means that it was not found in the cahce.
11137 So it has to be derived using the cursor and the cache has to be updated */
11138 OPEN c_rep_curr_or_sec_ledger;
11139 FETCH c_rep_curr_or_sec_ledger INTO l_count;
11140 CLOSE c_rep_curr_or_sec_ledger ;
11141
11142 G_LEDGER_CNT(G_LEDGER_CNT.LAST + 1).ORG_ID := p_org_id;
11143 G_LEDGER_CNT(G_LEDGER_CNT.LAST + 1).CNT := l_count;
11144
11145 END IF;
11146
11147 END IF;
11148
11149 IF l_count > 0 THEN
11150 l_return := TRUE;
11151 END IF;
11152
11153 RETURN l_return;
11154
11155 END RepCurrOrSecLedgerDiffCurr;
11156 /* Bug 5235354 - End */
11157
11158 /* Bug 5381260 - Start */
11159 FUNCTION IsPeriodEndAccrual(p_invoice_distribution_id AP_INVOICE_DISTRIBUTIONS_ALL.INVOICE_DISTRIBUTION_ID%TYPE)
11160 RETURN BOOLEAN IS
11161 l_accrue_on_receipt_flag PO_LINE_LOCATIONS_ALL.ACCRUE_ON_RECEIPT_FLAG%TYPE;
11162 l_result BOOLEAN := TRUE;
11163
11164 CURSOR c_get_accrue_on_receipt_flag IS
11165 SELECT poll.accrue_on_receipt_flag
11166 FROM po_line_locations_all poll
11167 , po_distributions_all pod
11168 , ap_invoice_distributions_all aid
11169 WHERE poll.line_location_id = pod.line_location_id
11170 AND pod.po_distribution_id = aid.po_distribution_id
11171 AND aid.invoice_distribution_id = p_invoice_distribution_id;
11172 BEGIN
11173 OPEN c_get_accrue_on_receipt_flag;
11174 FETCH c_get_accrue_on_receipt_flag INTO l_accrue_on_receipt_flag;
11175 CLOSE c_get_Accrue_on_receipt_flag;
11176
11177 IF l_accrue_on_receipt_flag = 'Y' THEN
11178 l_result := FALSE;
11179 END IF;
11180
11181 RETURN l_result;
11182 END IsPeriodEndAccrual;
11183 /* Bug 5381260 - End */
11184
11185 /* Bug 5501250 - Start */
11186 FUNCTION IsRelatedToPrepayApp(
11187 p_invoice_distribution_id AP_INVOICE_DISTRIBUTIONS_ALL.INVOICE_DISTRIBUTION_ID%TYPE,
11188 p_document_distribution_type PA_EXPENDITURE_ITEMS_ALL.DOCUMENT_DISTRIBUTION_TYPE%TYPE DEFAULT NULL /*Bug 13906739: Added NULL as default parameter Value*/
11189 ) RETURN BOOLEAN IS
11190 l_dummy varchar2(1);
11191 BEGIN
11192
11193 IF p_document_distribution_type <> 'SELF_ASSESSED_TAX' then /*Self Assessed Tax Changes*/
11194 SELECT NULL
11195 INTO l_dummy
11196 FROM ap_invoice_distributions_all dist
11197 WHERE dist.invoice_distribution_id = p_invoice_distribution_id
11198 AND EXISTS (
11199 SELECT NULL
11200 FROM ap_invoice_distributions_all ppdist
11201 WHERE ppdist.invoice_distribution_id = dist.charge_applicable_to_dist_id
11202 AND ppdist.line_type_lookup_code = 'PREPAY'
11203 );
11204 RETURN TRUE;
11205 ELSE /*Self Assessed Tax Changes*/
11206 SELECT NULL
11207 INTO l_dummy
11208 FROM ap_self_assessed_tax_dist_all dist
11209 WHERE dist.invoice_distribution_id = p_invoice_distribution_id
11210 AND EXISTS (
11211 SELECT NULL
11212 FROM ap_invoice_distributions_all ppdist
11213 WHERE ppdist.invoice_distribution_id = dist.charge_applicable_to_dist_id
11214 AND ppdist.line_type_lookup_code = 'PREPAY'
11215 );
11216 END IF;
11217
11218 EXCEPTION
11219 WHEN NO_DATA_FOUND THEN
11220 RETURN FALSE;
11221 END IsRelatedToPrepayApp;
11222 /* Bug 5501250 - End */
11223
11224 END PA_ADJUSTMENTS ;