1 package body PA_COST_PLUS as
2 -- $Header: PAXCCPEB.pls 120.26.12020000.3 2012/12/31 10:54:54 sisana ship $
3 -- Package constants
4 NO_DATA_FOUND_ERR number := 100;
5 INDIRECT_COST_CODE varchar2(30) := 'INDIRECT COST';
6 G_MODULE varchar2(10) := 'XXX'; /*3005625*/
7 /*3005625 : Added variable G_MODULE -this is set to value 'NEW_ORG' whenver
8 process Added New organization is run i.e new_organization is called.
9 This is to generate compiled multipliers for the new organization in
10 all the burden schedule revisions (even when nothing has changed in the
11 revision i.e ready_to_compile_flag is <>'Y'/'X')*/
12
13 /* Start : Add a variable (G_GMS_ENABLED) to hold the value of GMS implemented status
14 ** for Operating Unit with a default value of NULL
15 ** 2981752 - PA.L:BURDENING ENHANCEMENTS : TRACKING BUG
16 */
17
18 /*Added these variables for the bug 4527736*/
19 G_RATE_SCH_REVISION_ID PA_IND_RATE_SCH_REVISIONS.IND_RATE_SCH_REVISION_ID%TYPE ;
20 G_CP_STRUCTURE PA_COST_PLUS_STRUCTURES.COST_PLUS_STRUCTURE%TYPE;
21 G_ORG_STRUC_VER_ID PA_IND_RATE_SCH_REVISIONS.ORG_STRUCTURE_VERSION_ID%TYPE;
22 G_START_ORGANIZATION_ID PA_IND_RATE_SCH_REVISIONS.START_ORGANIZATION_ID%TYPE;
23
24 G_IMPACTED_COST_BASES_TAB PA_PLSQL_DATATYPES.Char30TabTyp;
25 G_EXPENDITURE_ITEM_ID_TAB PA_PLSQL_DATATYPES.IDTABTYP;
26 G_ADJ_TYPE_TAB PA_PLSQL_DATATYPES.Char30TabTyp;
27
28 /*
29 * Private Procedure.
30 */
31 PROCEDURE Cache_Impacted_Cost_Bases ( P_Ind_Rate_Sch_Revision_Id IN PA_IND_RATE_SCH_REVISIONS.IND_RATE_SCH_REVISION_ID%TYPE
32 ,P_Cp_Structure IN PA_COST_PLUS_STRUCTURES.COST_PLUS_STRUCTURE%TYPE
33 );
34 /* End Bug# 4527736 */
35
36 G_gms_enabled varchar2(1):= gms_pa_api3.grants_enabled ;
37
38
39 /* End : Add a variable (G_GMS_ENABLED) to hold the value of GMS implemented status
40 ** for Operating Unit with a default value of NULL.
41 ** 2981752 - PA.L:BURDENING ENHANCEMENTS : TRACKING BUG
42 */
43
44
45 -- Package type
46 TYPE precedence_tab_type IS TABLE OF pa_compiled_multipliers.precedence%TYPE
47 INDEX BY BINARY_INTEGER;
48 TYPE ind_cost_code_tab_type IS TABLE OF
49 pa_compiled_multipliers.ind_cost_code%TYPE INDEX BY BINARY_INTEGER;
50 TYPE multiplier_tab_type IS TABLE OF pa_ind_cost_multipliers.multiplier%TYPE
51 INDEX BY BINARY_INTEGER;
52
53 /***Bug# 2933915:Cursor for selecting impacted cost bases for which :
54 ****the organization/cost code has ready_to_compile_flag as 'Y' or 'X' i.e the multiplier is modified or deleted respectively in
55 pa_ind_cost_multipliers
56 OR
57 ****G_MODULE ='NEW_ORG' i.e when we need to generate new compiled set ids in all the revisions for a new organization even when there
58 is no change to the burden schedule******************************/
59
60 CURSOR impacted_cost_bases(rate_sch_rev_id NUMBER)
61 IS
62 SELECT pcb.COST_BASE
63 FROM PA_COST_BASES pcb
64 WHERE pcb.COST_BASE_TYPE = INDIRECT_COST_CODE
65 AND EXISTS
66 (
67 SELECT 1 /* Bug# 4527736 */
68 FROM PA_COST_BASE_COST_CODES CBICC,
69 PA_IND_COST_MULTIPLIERS ICM,
70 PA_IND_RATE_SCH_REVISIONS IRSR
71 WHERE IRSR.IND_RATE_SCH_REVISION_ID = ICM.IND_RATE_SCH_REVISION_ID
72 AND IRSR.IND_RATE_SCH_REVISION_ID = rate_sch_rev_id
73 AND (NVL(ICM.READY_TO_COMPILE_FLAG,'N') IN ('Y','X')
74 OR NVL(G_MODULE ,'XXX') = 'NEW_ORG')
75 AND IRSR.COST_PLUS_STRUCTURE = CBICC.COST_PLUS_STRUCTURE
76 AND CBICC.IND_COST_CODE = ICM.IND_COST_CODE
77 AND CBICC.COST_BASE = PCB.COST_BASE
78 AND CBICC.COST_BASE_TYPE = PCB.COST_BASE_TYPE );
79
80 /*End of change 2933915*/
81 --
82 -- PROCEDURE
83 -- compile_org_rates
84 --
85 -- PURPOSE
86 -- The objective of this procedure is to compile the rates of
87 -- indirect costs. An expenditure item may associate with a
88 -- couple of indirect costs. The amount of these indirect costs
89 -- is the product of the raw cost of expenditure item and the
90 -- indirect cost rate. The indirect cost rate is based on
91 -- rate schedule, cost base, and organization. This procedure
92 -- will compile indirect cost rates for a specific rate schedule,
93 -- cost base, and organization. Moreover, the indirect cost
94 -- rates of all descendant organizations are compiled as well.
95 --
96 -- CONSTRAINTS
97 -- The mulipliers of the top organization MUST be specified.
98 --
99 --
100 -- HISTORY
101 -- 07-JUN-94 S Lee Added status and stage
102 -- 29-MAR-94 S Lee Modified for using new database schema and
103 -- application standards
104 -- 18-NOV-93 S Lee Revamped
105 -- 28-SEP-93 S Lee Created
106 --
107
108
109 procedure compile_org_rates (rate_sch_rev_id IN number,
110 org_id IN number,
111 org_struc_ver_id IN number,
112 start_org IN number,
113 status IN OUT NOCOPY number,
114 stage IN OUT NOCOPY number)
115 IS
116
117 --
118 -- CONSTANT definition
119 --
120
121 --
122 -- VARIABLE definition
123 --
124
125 base pa_compiled_multipliers.compiled_multiplier%TYPE;
126 defined_org_id hr_organization_units.organization_id%TYPE;
127 ind_cost_multiplier pa_ind_cost_multipliers.multiplier%TYPE;
128 old_cost_base pa_cost_bases.cost_base%TYPE DEFAULT NULL;
129 old_precedence pa_cost_base_cost_codes.precedence%TYPE DEFAULT NULL;
130 ind_cost_multiplier_sum pa_ind_cost_multipliers.multiplier%TYPE;
131 compiled_set_id pa_ind_compiled_sets.ind_compiled_set_id%TYPE;
132 org_override NUMBER(15) DEFAULT 0;
133 l_start_date DATE;
134 l_end_date DATE;
135 l_org_override NUMBER(15) DEFAULT 0; /*2933915*/
136
137 -- Standard who
138 x_last_updated_by NUMBER(15);
139 x_created_by NUMBER(15);
140 x_last_update_login NUMBER(15);
141 x_request_id NUMBER(15);
142 x_program_application_id NUMBER(15);
143 x_program_id NUMBER(15);
144
145 --
146 -- CURSOR definition
147 --
148 /*2933915 :Modified the existing ind_cost_code_cursor to select for impacted cost bases ONLY and not for all the
149 cost bases as was earlier*/
150
151 /* Replaced this cursor with the below defined cursor for the bug 4527736
152 CURSOR ind_cost_code_cursor(x_base VARCHAR2) IS -- 2933915
153 SELECT
154 cbicc.cost_base_cost_code_id,
155 cbicc.cost_base,
156 cbicc.ind_cost_code,
157 cbicc.precedence
158 FROM pa_cost_base_cost_codes cbicc,
159 pa_ind_rate_sch_revisions irsr
160 WHERE irsr.ind_rate_sch_revision_id = rate_sch_rev_id
161 AND irsr.cost_plus_structure = cbicc.cost_plus_structure
162 AND cbicc.cost_base = x_base -- 2933915
163 AND cbicc.cost_base_type = INDIRECT_COST_CODE
164 ORDER BY
165 cbicc.cost_base, cbicc.precedence;
166 */
167
168 CURSOR ind_cost_code_cursor(x_base VARCHAR2) IS
169 SELECT
170 cbicc.cost_base_cost_code_id,
171 cbicc.cost_base,
172 cbicc.ind_cost_code,
173 cbicc.precedence
174 FROM pa_cost_base_cost_codes cbicc
175 WHERE cbicc.cost_plus_structure = G_CP_STRUCTURE
176 AND cbicc.cost_base = x_base
177 AND cbicc.cost_base_type = INDIRECT_COST_CODE
178 ORDER BY
179 cbicc.cost_base, cbicc.precedence;
180 --
181 -- Procedure body
182 --
183
184
185 BEGIN
186
187 status := 0;
188 stage := 100;
189
190 --
191 -- Get the standard who information
192 --
193 x_created_by := FND_GLOBAL.USER_ID;
194 x_last_updated_by := FND_GLOBAL.USER_ID;
195 x_last_update_login := FND_GLOBAL.LOGIN_ID;
196 x_request_id := FND_GLOBAL.CONC_REQUEST_ID;
197 x_program_application_id := FND_GLOBAL.PROG_APPL_ID;
198 x_program_id := FND_GLOBAL.CONC_PROGRAM_ID;
199
200
201 -- Get the standard who information
202 --
203 -- Compile the indirect cost rates for this organization.
204 -- First check if there is an override on this organization.
205 -- If so, compile rates for this organization, and create a new set.
206 -- If not, use the compiled set of its parent organization.
207 --
208
209 /*2933915 :Whatever org is passed here -we are ensuring this in the calling procedure that it has proper value of
210 ready to compile flag i.e 'N','Y','X' respectively depending on whether the multiplier is deleted ,changed or not changed
211 for that ORG . BUT we also need to ensure that if EXPLICIT multipliers are defined for an org for ALL
212 cost codes belonging to AFFECTED cost bases then new CSID should not be generated for that ie it should not be recompiled
213 If multipliers are not found for ANY of the cost code then we should go ahead with compiling new one*/
214
215
216 BEGIN
217 SELECT /*+ FIRST_ROWS */
218 1
219 INTO org_override
220 FROM sys.dual WHERE EXISTS
221 (SELECT /*+ FIRST_ROWS */
222 1
223 FROM pa_ind_cost_multipliers
224 WHERE ind_rate_sch_revision_id = rate_sch_rev_id
225 AND organization_id = org_id
226 AND nvl(ready_to_compile_flag,'N') <> 'X') ;
227
228 EXCEPTION
229 WHEN NO_DATA_FOUND THEN
230 org_override := 0; /**Multipliers are not found for any of the cost code for this org**/
231 WHEN OTHERS THEN
232 status := SQLCODE;
233 return;
234 END;
235
236 IF check_for_explicit_multiplier(rate_sch_rev_id, org_id) = 0 THEN /*Bug 4739218 */
237
238 IF org_override = 0 THEN
239 --
240 -- This organization does not have cost override. Therefore, its
241 -- compiled rate is as same as its parent organization.
242 -- Bug# 2933915 : Adding loop for doing this only for impacted cost bases
243 -- 4527736
244 -- FOR cost_base_rec in impacted_cost_bases(rate_sch_rev_id) /*2933915*/
245 IF G_IMPACTED_COST_BASES_TAB.COUNT <> 0 THEN /*4590268*/
246
247 FOR i IN G_IMPACTED_COST_BASES_TAB.FIRST .. G_IMPACTED_COST_BASES_TAB.LAST
248 LOOP
249
250 BEGIN
251
252 --
253 -- Get the set id information from its parent organization
254 --
255
256 SELECT /*+ ORDERED
257 INDEX(ose PER_ORG_STRUCTURE_ELEMENTS_FK4)
258 INDEX(ics PA_IND_COMPILED_SETS_N1) */
259 ics.ind_compiled_set_id
260 INTO compiled_set_id
261 FROM per_org_structure_elements ose,
262 pa_ind_compiled_sets ics
263 WHERE ose.organization_id_child = org_id
264 AND ose.org_structure_version_id = org_struc_ver_id
265 AND ose.organization_id_parent = ics.organization_id
266 AND ics.ind_rate_sch_revision_id = rate_sch_rev_id
267 --4527736
268 -- AND ics.cost_base = cost_base_rec.cost_base /*2933915*/
269 AND ics.cost_base = G_IMPACTED_COST_BASES_TAB(i)
270 AND ics.status = 'A';
271
272 --
273 -- Add the set id information to this organization
274 --
275 /*S.O. 4888548
276 INSERT INTO pa_ind_compiled_sets
277 (ind_compiled_set_id,
278 ind_rate_sch_revision_id,
279 organization_id,
280 cost_base, /*2933915*
281 last_update_date,
282 last_updated_by,
283 created_by,
284 creation_date,
285 last_update_login,
286 request_id,
287 program_application_id,
288 program_id,
289 program_update_date,
290 status)
291 VALUES(compiled_set_id,
292 rate_sch_rev_id,
293 org_id,
294 --4527736
295 -- cost_base_rec.cost_base, /*2933915
296 G_IMPACTED_COST_BASES_TAB(i),
297 SYSDATE,
298 x_last_updated_by,
299 x_created_by,
300 SYSDATE,
301 x_last_update_login,
302 x_request_id,
303 x_program_application_id,
304 x_program_id,
305 SYSDATE,
306 'A');
307 E.O. 4888548 */
308
309 /*S.N. 4888548 */
310 INSERT INTO pa_ind_compiled_sets
311 (ind_compiled_set_id,
312 ind_rate_sch_revision_id,
313 organization_id,
314 cost_base,
315 last_update_date,
316 last_updated_by,
317 created_by,
318 creation_date,
319 last_update_login,
320 request_id,
321 program_application_id,
322 program_id,
323 program_update_date,
324 status)
325 SELECT compiled_set_id,
326 rate_sch_rev_id,
327 org_id,
328 --4527736
329 -- cost_base_rec.cost_base,
330 G_IMPACTED_COST_BASES_TAB(i),
331 SYSDATE,
332 x_last_updated_by,
333 x_created_by,
334 SYSDATE,
335 x_last_update_login,
336 x_request_id,
337 x_program_application_id,
338 x_program_id,
339 SYSDATE,
340 'A'
341 FROM DUAL
342 WHERE NOT EXISTS
343 ( SELECT 1 from pa_ind_compiled_sets ics
344 WHERE ics.ind_rate_sch_revision_id =rate_sch_rev_id
345 AND ics.organization_id = org_id
346 AND ics.cost_base = G_IMPACTED_COST_BASES_TAB(i)
347 AND ics.status='A'
348 ) ;
349 /*E.N. 4888548 */
350
351
352 EXCEPTION
353 WHEN NO_DATA_FOUND THEN
354 --
355 -- The parent organization has not been compiled yet.
356 -- or this organization does not have a parent organization.
357 -- We will compile a new set for this organization.
358 --
359 l_org_override := -1 ;
360
361 WHEN OTHERS THEN
362 --
363 -- This rate schedule for this organization has been compiled
364 -- previously. The compiled set must be deleted before
365 -- adding the new set id.
366 --
367 status := SQLCODE;
368 RETURN;
369
370 END;
371
372 END LOOP; /*End of impacted_cost_bases loop :2933915*/
373
374 END IF; /*4590268*/
375
376 IF l_org_override = 0 THEN /*2933915 :Compiled set id found for all the impacted cost bases for the parent org*/
377 COMMIT;
378 RETURN ;
379 END IF ;
380
381 END IF; /*End if org_override =0*/
382 END IF; /* Bug 4739218 */
383 /**2933915 :
384 If EXPLICIT multipliers are defined for ALL the cost codes in that structure for this org then any change in parent orgs would not
385 impact the child org and hence recompilation is not required so return to the calling procedure to get the next org *******/
386
387 IF (org_override = 1 OR l_org_override =-1) THEN
388 --4527736
389 --FOR cost_base_rec in impacted_cost_bases(rate_sch_rev_id)
390 IF G_IMPACTED_COST_BASES_TAB.COUNT <> 0 THEN /*4590268*/
391
392 FOR i IN G_IMPACTED_COST_BASES_TAB.FIRST .. G_IMPACTED_COST_BASES_TAB.LAST
393 LOOP
394 --4527736
395 --FOR cost_code_rec in ind_cost_code_cursor(cost_base_rec.cost_base) **2933915 :Cost codes of impacted cost bases**
396 FOR cost_code_rec in ind_cost_code_cursor(G_IMPACTED_COST_BASES_TAB(i))
397 LOOP
398 BEGIN
399 SELECT /*+ FIRST_ROWS */
400 1
401 INTO l_org_override
402 FROM sys.dual WHERE EXISTS
403 (SELECT /*+ FIRST_ROWS */
404 1
405 FROM pa_ind_cost_multipliers icm,
406 pa_ind_compiled_sets ics
407 WHERE icm.ind_rate_sch_revision_id =ics.ind_rate_sch_revision_id
408 AND icm.ind_rate_sch_revision_id = rate_sch_rev_id
409 AND icm.organization_id =ics.organization_id
410 AND icm.organization_id = org_id
411 --AND ics.cost_base = cost_base_rec.cost_base --4527736
412 AND ics.cost_base = G_IMPACTED_COST_BASES_TAB(i)
413 AND ics.status ='A'
414 AND icm.ind_cost_code =cost_code_rec.ind_cost_code
415 AND nvl(icm.ready_to_compile_flag,'N') <>'X'); /*Should not consider 'X' records as they are actually
416 deleted records */
417
418 EXCEPTION
419 WHEN NO_DATA_FOUND THEN
420 l_org_override := 0;
421 WHEN OTHERS THEN
422 status := SQLCODE;
423 return;
424 END;
425 END LOOP; /*End loop ind_cost_code_cursor*/
426
427 IF l_org_override =0 THEN
428 EXIT;
429 END IF;
430 END LOOP; /*End loop impacted_cost_bases*/
431 END IF; /*4590268*/
432
433 IF l_org_override =1 THEN /***Bug 2933915 :Explicit multipliers found for all the cost codes in impacted cost bases*/
434 RETURN ;
435 END IF ;
436 END IF; /*End if of org_overrride OR l_orgoverride... */
437
438 /****End of changes for bug# 2933915******/
439
440 --
441 -- Okay, there is override for this organization. We need to compile a
442 -- new set of multipliers. First pick up a number for set id.
443 --
444
445 stage := 200;
446
447 SELECT pa_ind_compiled_sets_s.NEXTVAL into compiled_set_id FROM sys.dual;
448
449
450 SAVEPOINT before_adding_multipliers;
451
452 BEGIN
453
454 <<process_ind_cost_codes>>
455 --FOR cost_base_rec in impacted_cost_bases(rate_sch_rev_id) --4527736
456 IF G_IMPACTED_COST_BASES_TAB.COUNT <> 0 THEN /*4590268*/
457
458 FOR i IN G_IMPACTED_COST_BASES_TAB.FIRST .. G_IMPACTED_COST_BASES_TAB.LAST --4527736
459 LOOP
460
461 --FOR icc_row IN ind_cost_code_cursor(cost_base_rec.cost_base) LOOP --4527736
462 FOR icc_row IN ind_cost_code_cursor(G_IMPACTED_COST_BASES_TAB(i)) LOOP --4527736
463
464 --
465 -- We want to get the multiplier for this organization.
466 -- First set the current organization as the starting point.
467 -- If the multiplier is not found, we will go one level higher.
468 --
469 defined_org_id := org_id;
470
471 <<find_multiplier>>
472 LOOP
473 --
474 -- Retrieve the value of multiplier from the pre-defined table
475 --
476 BEGIN
477 --
478 -- Find out whether the ICM of this organization is defined or not.
479 -- If so, retrieve the ICM and exit the loop.
480 -- If not, trace upward to see whether its parent organization is
481 -- defined or not.
482 --
483
484 SELECT multiplier
485 INTO ind_cost_multiplier
486 FROM
487 pa_ind_cost_multipliers
488 WHERE
489 organization_id = defined_org_id
490 AND ind_cost_code = icc_row.ind_cost_code
491 AND ind_rate_sch_revision_id = rate_sch_rev_id
492 AND nvl(ready_to_compile_flag,'N') <> 'X' ; /*3005954 :Multipliers of deleted(i.e marked for deletion
493 internally) record for org should not be considered*/
494
495 --
496 -- If NO_DATA_FOUND exception is not raised, the multiplier is
497 -- defined. Exit this loop.
498 --
499
500 EXIT;
501
502
503 EXCEPTION
504 WHEN NO_DATA_FOUND THEN
505 --
506 -- Verify whether we have reached the top of organization
507 --
508 IF defined_org_id = start_org THEN
509 --
510 -- The multiplier is still not found at the top of the
511 -- organization structure. Set the ICM to 0.
512 --
513 ind_cost_multiplier := 0;
514 EXIT;
515 END IF;
516
517 --
518 -- Multiplier is not defined in this level. Go up one level
519 -- further.
520 --
521
522 SELECT organization_id_parent
523 INTO defined_org_id
524 FROM per_org_structure_elements
525 WHERE
526 organization_id_child = defined_org_id
527 AND org_structure_version_id = org_struc_ver_id;
528
529 WHEN OTHERS THEN
530 status := SQLCODE;
531 RETURN;
532
533 END;
534
535 END LOOP find_multiplier;
536
537 stage := 300;
538
539 --
540 -- Check whether this is a new cost base. If yes, change
541 -- the base of calculation.
542 --
543
544 IF (old_cost_base IS NULL) OR
545 (icc_row.cost_base <> old_cost_base) THEN
546 --
547 -- Base is used to compile the multipier.
548 -- Base is set to 1 when using a new cost base.
549 --
550
551 base := 1;
552
553 --
554 -- ind_cost_multiplier_sum is used to store the summation of
555 -- compiled multipliers which have the same precedence.
556 -- Set to 0 at for the first indirect cost code.
557 --
558
559 ind_cost_multiplier_sum := 0;
560
561 ELSE
562 --
563 -- The cost base of this indirect cost code is as same as the
564 -- previous one.
565 --
566
567 IF old_precedence <> icc_row.precedence THEN
568 --
569 -- The calculation base will grow when the compiled rate
570 -- of previous indirect cost code is added into the base.
571 -- The current indirect cost code has a higher precedence,
572 -- hence change the base of calculation.
573 --
574
575 base := base * (1 + ind_cost_multiplier_sum);
576
577 --
578 -- Reset the sum whenever the precedence is changed.
579 --
580
581 ind_cost_multiplier_sum := 0;
582
583 END IF;
584 END IF;
585
586 --
587 -- Enter the compiled rate into table
588 --
589
590 INSERT INTO pa_compiled_multipliers
591 (ind_compiled_set_id,
592 cost_base_cost_code_id,
593 cost_base,
594 ind_cost_code,
595 precedence,
596 compiled_multiplier,
597 multiplier,
598 last_update_date,
599 last_updated_by,
600 created_by,
601 creation_date,
602 last_update_login,
603 request_id,
604 program_application_id,
605 program_id,
606 program_update_date)
607 VALUES
608 (compiled_set_id,
609 icc_row.cost_base_cost_code_id,
610 icc_row.cost_base,
611 icc_row.ind_cost_code,
612 icc_row.precedence,
613 base * ind_cost_multiplier,
614 ind_cost_multiplier,
615 SYSDATE,
616 x_last_updated_by,
617 x_created_by,
618 SYSDATE,
619 x_last_update_login,
620 x_request_id,
621 x_program_application_id,
622 x_program_id,
623 SYSDATE
624 );
625
626
627 --
628 -- 1. Get the summation of indirect cost multipliers that have
629 -- the same precedence.
630 -- 2. Keep the old precedence in order to know when to change
631 -- base.
632 -- 3. Memorize the current cost base.
633 --
634 ind_cost_multiplier_sum := ind_cost_multiplier_sum + ind_cost_multiplier;
635 old_precedence := icc_row.precedence;
636
637 /*Bug# 2933915 : Insert Compiled sets ids for organization_id/Cost_base combination .
638 Earlier CSID was inserted for organization.Now it has to be inserted for organization_id/Cost_base combination */
639
640 IF (old_cost_base is NULL) OR (icc_row.cost_base <> old_cost_base) THEN /*Bug 2933915*/
641
642 /*S.N. 4888548
643 INSERT INTO pa_ind_compiled_sets
644 (ind_compiled_set_id,
645 ind_rate_sch_revision_id,
646 organization_id,
647 cost_base, /*Bug# 2933915
648 last_update_date,
649 last_updated_by,
650 created_by,
651 creation_date,
652 last_update_login,
653 request_id,
654 program_application_id,
655 program_id,
656 program_update_date,
657 status)
658 VALUES
659 (compiled_set_id,
660 rate_sch_rev_id,
661 org_id,
662 icc_row.cost_base, /*Bug# 2933915
663 SYSDATE,
664 x_last_updated_by,
665 x_created_by,
666 SYSDATE,
667 x_last_update_login,
668 x_request_id,
669 x_program_application_id,
670 x_program_id,
671 SYSDATE,
672 'A'
673 );
674 E.O. 4888548 */
675
676 /*S.N. 4888548 */
677 INSERT INTO pa_ind_compiled_sets
678 (ind_compiled_set_id,
679 ind_rate_sch_revision_id,
680 organization_id,
681 cost_base,
682 last_update_date,
683 last_updated_by,
684 created_by,
685 creation_date,
686 last_update_login,
687 request_id,
688 program_application_id,
689 program_id,
690 program_update_date,
691 status)
692 SELECT
693 compiled_set_id,
694 rate_sch_rev_id,
695 org_id,
696 icc_row.cost_base,
697 SYSDATE,
698 x_last_updated_by,
699 x_created_by,
700 SYSDATE,
701 x_last_update_login,
702 x_request_id,
703 x_program_application_id,
704 x_program_id,
705 SYSDATE,
706 'A'
707 FROM DUAL
708 WHERE NOT EXISTS
709 ( SELECT 1 from pa_ind_compiled_sets ics
710 WHERE ics.ind_rate_sch_revision_id =rate_sch_rev_id
711 AND ics.organization_id = org_id
712 AND ics.cost_base =icc_row.cost_base
713 AND ics.status='A'
714 ) ;
715 /*E.N. 4888548 */
716
717 END IF ;
718 old_cost_base := icc_row.cost_base; /*2933915*/
719
720 END LOOP process_ind_cost_codes; /*2933915*/
721 END LOOP ; /*impacted_cost_base_cur*/ /*2933915*/
722
723 END IF; /*4590268*/
724
725 EXCEPTION
726 WHEN OTHERS THEN
727 --
728 -- remove the multipliers which are defined previously
729 --
730 ROLLBACK TO before_adding_multipliers;
731 status := SQLCODE;
732 RETURN;
733
734 END;
735 --
736 -- Commit the whole transaction now.
737 --
738 COMMIT;
739 RETURN;
740
741 EXCEPTION
742 WHEN OTHERS THEN
743 status := SQLCODE;
744 RETURN;
745
746 END compile_org_rates;
747
748
749 --
750 -- PROCEDURE
751 -- compile_org_hierarchy_rates
752 --
753 -- PURPOSE
754 -- The objective of this procedure is to create compiled rates for
755 -- the whole organization hierarchy using a specific rate schedule.
756 --
757 -- HISTORY
758 --
759 -- 08-JUN-94 S Lee Created
760 --
761
762
763 PROCEDURE compile_org_hierarchy_rates(rate_sch_rev_id IN number,
764 org_id IN number,
765 comp_type IN varchar2,
766 status IN OUT NOCOPY number,
767 stage IN OUT NOCOPY number)
768 IS
769 CURSOR org_cursor(ver_id NUMBER) /*Bug# 2933915 :removed bg_id for business_group_id from cursor as it is not reqd*/
770 IS
771 SELECT organization_id_child
772 FROM per_org_structure_elements
773 CONNECT BY PRIOR organization_id_child = organization_id_parent
774 AND org_structure_version_id = ver_id
775 START WITH organization_id_parent = org_id
776 AND org_structure_version_id = ver_id;
777
778 /*business_gid Number; Bug# 29399915*/
779 org_struc_ver_id Number;
780 start_org Number;
781
782
783 BEGIN
784
785 status := 0;
786
787 org_struc_ver_id := G_ORG_STRUC_VER_ID;
788 start_org := G_START_ORGANIZATION_ID ;
789 /*
790 * Commented for bug 4527736
791 *
792 pa_cost_plus.get_hierarchy_from_revision(rate_sch_rev_id,
793 org_struc_ver_id,
794 start_org,
795 status,
796 stage);
797
798
799 IF status <> 0 THEN
800 stage := 50;
801 RETURN;
802 END IF;
803 */
804 --
805 -- First compile the current organization
806 --
807
808 if (comp_type = 'INCREMENTAL') then
809
810 pa_cost_plus.disable_sch_rev_org(rate_sch_rev_id,
811 org_id,
812 status,
813 stage);
814
815 end if;
816
817 pa_cost_plus.compile_org_rates(rate_sch_rev_id,
818 org_id,
819 org_struc_ver_id,
820 start_org,
821 status,
822 stage);
823
824 IF status <> 0 THEN
825 RETURN;
826 END IF;
827
828 --
829 -- Compile all the organizations under this organization
830 -- Ues the for loop cursor to fetch one qualified row at a time
831 --
832
833 <<process_org>>
834 FOR org_row IN org_cursor(org_struc_ver_id) /*29399915 -Removed business_gid as it is not required */
835 LOOP
836
837 --
838 -- Create the compiled multipliers for the every organization.
839 --
840
841 if (comp_type = 'INCREMENTAL') then
842
843 pa_cost_plus.disable_sch_rev_org(rate_sch_rev_id,
844 org_row.organization_id_child,
845 status,
846 stage);
847
848 end if;
849
850 pa_cost_plus.compile_org_rates(rate_sch_rev_id,
851 org_row.organization_id_child,
852 org_struc_ver_id,
853 start_org,
854 status,
855 stage);
856
857 IF status <> 0 THEN
858 RETURN;
859 END IF;
860
861 END LOOP process_org;
862
863
864 --
865 -- Set the compilation time in the rate schedule revision
866 --
867
868 UPDATE pa_ind_rate_sch_revisions
869 SET
870 compiled_flag = 'Y',
871 compiled_date = SYSDATE
872 WHERE
873 ind_rate_sch_revision_id = rate_sch_rev_id;
874
875
876 END compile_org_hierarchy_rates;
877
878
879 --
880 -- PROCEDURE
881 -- new_organization
882 --
883 -- PURPOSE
884 -- The objective of this procedure is to create compiled rates for
885 -- a new organization and its sub-organizations
886 --
887 -- HISTORY
888 --
889 -- 19-AUG-94 S Lee Created
890 --
891
892
893 PROCEDURE new_organization(errbuf IN OUT NOCOPY varchar2,
894 retcode IN OUT NOCOPY varchar2,
895 organization_id IN varchar2)
896 IS
897 -- Local variables
898 l_org_id number;
899 status number;
900 stage number;
901 l_org_exists BOOLEAN;
902 /* l_business_gid NUMBER; commented as it is not used :Bug 2933915*/
903 l_org_struc_ver_id NUMBER;
904 l_start_org NUMBER;
905 l_compiled_set_id NUMBER;
906
907 -- Cursor definition
908
909 /* CURSOR rev_cursor IS
910 SELECT irsr.ind_rate_sch_revision_id
911 FROM pa_ind_rate_sch_revisions irsr
912 WHERE irsr.compiled_flag = 'Y' -- revision has been compiled before
913 AND irsr.ready_to_compile_flag = 'Y'; -- compilation is not on hold
914 *** cusor commented for bug 3033195 */
915
916 /*
917 * Bug#1163654
918 * cursor added to check the existence of compiled set information
919 * for a given revision and organization.
920 */
921
922 CURSOR rev_org_cursor(p_rev_id IN NUMBER, p_org_id IN NUMBER) IS /* p_org_id added for 3033195 */
923 SELECT '1'
924 FROM pa_ind_compiled_sets cmp
925 WHERE cmp.organization_id = p_org_id
926 AND cmp.ind_rate_sch_revision_id = p_rev_id
927 AND status = 'A';
928
929 -- Standard who
930 x_last_updated_by NUMBER(15);
931 x_last_update_login NUMBER(15);
932 x_request_id NUMBER(15);
933 x_program_application_id NUMBER(15);
934 x_program_id NUMBER(15);
935 x_created_by NUMBER(15);
936
937 /* Two cursors added below for bug 3033195 */
938
939 Cursor rev_struct_cursor is
940 SELECT ind_rate_sch_revision_id, org_structure_version_id,cost_plus_structure,start_organization_id /*4590268*/
941 FROM pa_ind_rate_sch_revisions
942 WHERE compiled_flag = 'Y'
943 AND ready_to_compile_flag = 'Y'
944 AND org_structure_version_id in
945 (select org_structure_version_id
946 from per_org_structure_elements
947 where organization_id_child = l_org_id
948 or organization_id_parent = l_org_id);
949
950 Cursor orgn_cursor(ver_id in NUMBER) is
951 SELECT level, organization_id_child organization_id
952 FROM per_org_structure_elements
953 CONNECT BY PRIOR organization_id_child = organization_id_parent
954 AND org_structure_version_id = ver_id
955 START WITH organization_id_parent = l_org_id
956 AND org_structure_version_id = ver_id
957 UNION ALL
958 SELECT 0,l_org_id organization_id FROM dual
959 ORDER BY 1;
960
961 BEGIN
962
963 l_org_id := to_number(organization_id);
964 G_MODULE := 'NEW_ORG'; /*3005625*/
965 /*3005625 :G_MODULE is set to value 'NEW_ORG' whenver process Add New organization is
966 run i.e new_organization is called.
967 This is to generate compiled multipliers for the new organization in all the burden
968 schedule revisions (even when nothing has changed in the revisions
969 i.e ready_to_compile_flag is <>'Y'/'X')*/
970 --
971 -- Get the standard who information
972 --
973 x_last_updated_by := FND_GLOBAL.USER_ID;
974 x_last_update_login := FND_GLOBAL.LOGIN_ID;
975 x_request_id := FND_GLOBAL.CONC_REQUEST_ID;
976 x_program_application_id := FND_GLOBAL.PROG_APPL_ID;
977 x_program_id := FND_GLOBAL.CONC_PROGRAM_ID;
978 x_created_by := FND_GLOBAL.USER_ID;
979
980 /* 3033195 */
981
982 /*S.N. 4590268*/
983 FOR rev_struct_row in rev_struct_cursor LOOP
984 --###
985 IF (nvl(G_RATE_SCH_REVISION_ID,-999)=rev_struct_row.ind_rate_sch_revision_id
986 AND nvl(G_CP_STRUCTURE,-999)= rev_struct_row.cost_plus_structure
987 AND G_IMPACTED_COST_BASES_TAB.count <> 0 ) THEN
988
989 NULL;
990
991 ELSE
992 G_RATE_SCH_REVISION_ID := rev_struct_row.ind_rate_sch_revision_id;
993 G_CP_STRUCTURE := rev_struct_row.cost_plus_structure;
994
995 pa_cost_plus.Cache_Impacted_Cost_Bases( G_RATE_SCH_REVISION_ID
996 ,G_CP_STRUCTURE);
997 END IF;
998
999 G_ORG_STRUC_VER_ID := rev_struct_row.org_structure_version_id;
1000 G_START_ORGANIZATION_ID := rev_struct_row.start_organization_id;
1001 /*E.N. 4590268*/
1002
1003 FOR orgn_row in orgn_cursor(rev_struct_row.org_structure_version_id) LOOP
1004
1005 l_org_exists := FALSE;
1006
1007 FOR rev_org_row in rev_org_cursor(rev_struct_row.ind_rate_sch_revision_id,orgn_row.organization_id)
1008 LOOP
1009 l_org_exists := TRUE;
1010 END LOOP;
1011
1012 IF l_org_exists THEN
1013 NULL;
1014 ELSE
1015
1016 UPDATE pa_ind_rate_sch_revisions
1017 SET
1018 last_update_date = SYSDATE,
1019 last_updated_by = x_last_updated_by,
1020 last_update_login = x_last_update_login,
1021 request_id = x_request_id,
1022 program_application_id = x_program_application_id,
1023 program_id = x_program_id,
1024 program_update_date = SYSDATE
1025 WHERE
1026 ind_rate_sch_revision_id = rev_struct_row.ind_rate_sch_revision_id;
1027
1028 COMMIT;
1029
1030 pa_cost_plus.compile_org_hierarchy_rates(
1031 rev_struct_row.ind_rate_sch_revision_id,
1032 orgn_row.organization_id,
1033 'INCREMENTAL',
1034 status,
1035 stage);
1036
1037 if (status < 0) then
1038 errbuf := sqlerrm(status);
1039 retcode := 2;
1040 return;
1041 end if;
1042
1043 END IF; -- l_org_exists
1044
1045 END LOOP; -- orgn_cursor
1046
1047 END LOOP; -- rev_struct_cursor
1048
1049 EXCEPTION
1050 WHEN OTHERS THEN
1051 errbuf := sqlerrm(status);
1052 retcode := 2;
1053 RAISE;
1054
1055 END new_organization;
1056
1057 /* Code Changes End for 3033195 . The old code below has been commented for better readability. */
1058
1059 --
1060 -- compile all rate schedules
1061 --
1062
1063 -- FOR rev_row IN rev_cursor
1064 -- LOOP
1065 --
1066 --
1067 -- /*
1068 -- * Bug#1163654
1069 -- *
1070 -- * If compiled set exists for a given Organization and revision, then
1071 -- * no action is necessary. Else enter a record in the compiled set table
1072 -- * for the given revision and organization with the compiled set id same as
1073 -- * that of its parent
1074 -- */
1075 --
1076 -- l_org_exists := FALSE;
1077 --
1078 -- FOR rev_org_row in rev_org_cursor(rev_row.ind_rate_sch_revision_id)
1079 -- LOOP
1080 -- l_org_exists := TRUE;
1081 -- END LOOP;
1082 --
1083 -- /*Bug# 1851731:If compiled set information exists for a given organization and
1084 -- revision then no action but instead of exiting from the procedure ,continue for
1085 -- other revisions fetched by rev_cursor */
1086 --
1087 -- IF l_org_exists THEN
1088 -- /*RETURN; Commented for bug# 1851731*/
1089 -- NULL; /*Bug# 1851731*/
1090 -- ELSE
1091 --
1092 --
1093 -- Set the compilation time in the rate schedule revision
1094 --
1095
1096 -- UPDATE pa_ind_rate_sch_revisions
1097 -- SET
1098 -- last_update_date = SYSDATE,
1099 -- last_updated_by = x_last_updated_by,
1100 -- last_update_login = x_last_update_login,
1101 -- request_id = x_request_id,
1102 -- program_application_id = x_program_application_id,
1103 -- program_id = x_program_id,
1104 -- program_update_date = SYSDATE
1105 -- WHERE
1106 -- ind_rate_sch_revision_id = rev_row.ind_rate_sch_revision_id;
1107 --
1108 -- COMMIT;
1109 --
1110 -- pa_cost_plus.compile_org_hierarchy_rates(
1111 -- rev_row.ind_rate_sch_revision_id,
1112 -- l_org_id,
1113 -- 'INCREMENTAL',
1114 -- status,
1115 -- stage);
1116 --
1117 -- if (status < 0) then
1118 -- errbuf := sqlerrm(status);
1119 -- retcode := 2;
1120 -- return;
1121 -- end if;
1122 --
1123 --
1124 --
1125 /*Bug# 1851731:Commented the SELECT and INSERT below as they are redundant.*/
1126 /*The code in SELECT and INSERT was carried over from R11.0 and introduced in*/
1127 /*this procedure as part of code fix for bug# 1163654. But it is not required*/
1128 /*here as code in R11i is restructured.*/
1129
1130 /*
1131 * Get compiled set id of the parent.
1132 */
1133 /*Bug# 1851731:
1134 SELECT + ORDERED
1135 INDEX(ose PER_ORG_STRUCTURE_ELEMENTS_FK4)
1136 INDEX(ics PA_IND_COMPILED_SETS_N1)
1137 ics.ind_compiled_set_id
1138 INTO l_compiled_set_id
1139 FROM per_org_structure_elements ose,
1140 pa_ind_compiled_sets ics
1141 WHERE ose.organization_id_child = l_org_id
1142 AND ose.org_structure_version_id = l_org_struc_ver_id
1143 AND ose.organization_id_parent = ics.organization_id
1144 AND ics.ind_rate_sch_revision_id = rev_row.ind_rate_sch_revision_id
1145 AND ics.status = 'A'; Commented for bug# 1851731*/
1146
1147 /*
1148 * Insert compiled set information
1149 */
1150
1151 /* Bug# 1851731 : INSERT INTO pa_ind_compiled_sets
1152 (ind_compiled_set_id,
1153 ind_rate_sch_revision_id,
1154 organization_id,
1155 last_update_date,
1156 last_updated_by,
1157 created_by,
1158 creation_date,
1159 last_update_login,
1160 request_id,
1161 program_application_id,
1162 program_id,
1163 program_update_date,
1164 status)
1165 VALUES(l_compiled_set_id,
1166 rev_row.ind_rate_sch_revision_id,
1167 l_org_id,
1168 SYSDATE,
1169 x_last_updated_by,
1170 x_created_by,
1171 SYSDATE,
1172 x_last_update_login,
1173 x_request_id,
1174 x_program_application_id,
1175 x_program_id,
1176 SYSDATE,
1177 'A'); Commented for bug# 1851731 */
1178 -- END IF;
1179 -- END LOOP;
1180 --EXCEPTION
1181 -- WHEN OTHERS THEN
1182 -- errbuf := sqlerrm(status);
1183 -- retcode := 2;
1184 -- RAISE;
1185 --
1186 --END new_organization;
1187
1188
1189 --
1190 -- PROCEDURE
1191 -- compile_schedule
1192 --
1193 -- PURPOSE
1194 -- The objective of this procedure is to create compiled rates
1195 -- using a specific rate schedule.
1196 --
1197 -- HISTORY
1198 --
1199 -- 08-JUN-94 S Lee Created
1200 --
1201
1202
1203 PROCEDURE compile_schedule(errbuf IN OUT NOCOPY varchar2,
1204 retcode IN OUT NOCOPY varchar2,
1205 sch_rev_id IN varchar2)
1206
1207 IS
1208 -- Local variables
1209 /* business_gid Number; commented as it is not used :Bug 2933915*/
1210 org_struc_ver_id Number;
1211 start_org Number;
1212
1213 status number;
1214 stage number;
1215 rate_sch_rev_id number;
1216 org_tab org_tab_type; /*2933915*/ /*To store top impacted orgs*/
1217 lstatus number ; /*2933915*/
1218 l_check number ; /*3055700*/
1219 l_cp_structure pa_cost_plus_structures.cost_plus_structure%TYPE ; /*3055700*/
1220 -- Standard who
1221 x_last_updated_by NUMBER(15);
1222 x_last_update_login NUMBER(15);
1223 x_request_id NUMBER(15);
1224 x_program_application_id NUMBER(15);
1225 x_program_id NUMBER(15);
1226 l_created_by NUMBER(15); /*3055700*/
1227
1228 /*3055700 :cursor to select all the cost bases */
1229 CURSOR all_cost_bases
1230 IS
1231 SELECT
1232 distinct cost_base
1233 FROM pa_cost_base_cost_codes
1234 WHERE cost_plus_structure =l_cp_structure
1235 AND cost_base_type = INDIRECT_COST_CODE ;
1236
1237 BEGIN
1238 lstatus :=0; /*2933915*/
1239 status := 0;
1240 rate_sch_rev_id := sch_rev_id;
1241 G_RATE_SCH_REVISION_ID := rate_sch_rev_id;
1242 --
1243 -- Get the standard who information
1244 --
1245 x_last_updated_by := FND_GLOBAL.USER_ID;
1246 x_last_update_login := FND_GLOBAL.LOGIN_ID;
1247 x_request_id := FND_GLOBAL.CONC_REQUEST_ID;
1248 x_program_application_id := FND_GLOBAL.PROG_APPL_ID;
1249 x_program_id := FND_GLOBAL.CONC_PROGRAM_ID;
1250 l_created_by := -999999;
1251 --
1252 -- Set the compilation time in the rate schedule revision
1253 --
1254
1255 UPDATE pa_ind_rate_sch_revisions
1256 SET
1257 last_update_date = SYSDATE,
1258 last_updated_by = x_last_updated_by,
1259 last_update_login = x_last_update_login,
1260 request_id = x_request_id,
1261 program_application_id = x_program_application_id,
1262 program_id = x_program_id,
1263 program_update_date = SYSDATE
1264 WHERE
1265 --ind_rate_sch_revision_id = rate_sch_rev_id; 4527736
1266 ind_rate_sch_revision_id = G_RATE_SCH_REVISION_ID;
1267 COMMIT;
1268
1269 --
1270 -- Get the current org_structure_version_id.
1271 -- Join can not be used in a CONNECT BY statement
1272 --
1273
1274
1275 pa_cost_plus.get_hierarchy_from_revision(G_RATE_SCH_REVISION_ID, /* 4527736 */
1276 org_struc_ver_id,
1277 start_org,
1278 status,
1279 stage);
1280
1281 if (status < 0) then
1282 errbuf := sqlerrm (status);
1283 retcode := 2;
1284 return;
1285 end if;
1286 G_ORG_STRUC_VER_ID := org_struc_ver_id;
1287 G_START_ORGANIZATION_ID := start_org;
1288
1289 /*Changes for Bug# 3055700:
1290 Inserting dummy enteries of 0 in pa_ind_cost_multipliers for Start Org and all the cost
1291 bases when the version is compiled .
1292 This has to be done when there exists no compiled set ids for ALL the cost bases with
1293 status 'A' for start_org .
1294 This will ensure that the compiled set ids are generated for all the orgs in hierarchy
1295 and all the cost bases .
1296 Subsequently any changes in multiplies will affect only impacted org and
1297 impacted cost base as per enhancement .
1298 *********************************************************************************************/
1299
1300 pa_cost_plus.get_cost_plus_structure(rate_sch_rev_id,
1301 l_cp_structure,
1302 status,
1303 stage);
1304
1305 IF (status <> 0) THEN
1306 errbuf := sqlerrm (status);
1307 return;
1308 END IF;
1309 G_CP_STRUCTURE := l_cp_structure;
1310
1311 /* 4527736
1312 * Call Cache_Impacted_Cost_Bases.
1313 */
1314 /* pa_cost_plus.Cache_Impacted_Cost_Bases( G_RATE_SCH_REVISION_ID
1315 ,G_CP_STRUCTURE); Commented for Bug 5181688 */
1316
1317 Begin
1318 /*If for start_org there are compiled set ids present with status 'A' for ALL the cost bases then
1319 l_check = 1 else 0*/
1320 FOR base_rec in all_cost_bases
1321 LOOP
1322 select 1
1323 into l_check
1324 from sys.dual
1325 where exists(select 1
1326 from pa_ind_compiled_sets
1327 where ind_rate_sch_revision_id =G_RATE_SCH_REVISION_ID /* 4527736 */
1328 and organization_id =start_org
1329 and cost_base = base_rec.cost_base
1330 and status ='A');
1331 END LOOP;
1332 Exception
1333 WHEN NO_DATA_FOUND THEN
1334 l_check :=0 ;
1335 End;
1336
1337 IF (l_check =0) THEN
1338 /*If explicit multipliers are not defined for start org for ALL cost codes then only insert*/
1339
1340 IF pa_cost_plus.check_for_explicit_multiplier(G_RATE_SCH_REVISION_ID ,start_org) =0 THEN /* 0 means not present*/
1341
1342 Begin
1343
1344 INSERT into pa_ind_cost_multipliers (ind_rate_sch_revision_id,
1345 organization_id,
1346 ind_cost_code,
1347 multiplier,
1348 last_update_date,
1349 last_updated_by,
1350 created_by,
1351 creation_date,
1352 last_update_login,
1353 ready_to_compile_flag)
1354 select G_RATE_SCH_REVISION_ID,
1355 start_org,
1356 cbicc.ind_cost_code,
1357 0,
1358 SYSDATE,
1359 x_last_updated_by,
1360 l_created_by,
1361 SYSDATE,
1362 x_last_update_login,
1363 'Y'
1364 from pa_cost_base_cost_codes cbicc
1365 where cbicc.cost_plus_structure = G_CP_STRUCTURE /* 4527736 */
1366 and cbicc.cost_base_type = INDIRECT_COST_CODE
1367 and cbicc.ind_cost_code not in (select m.ind_cost_code
1368 from pa_ind_cost_multipliers m
1369 where m.ind_rate_sch_revision_id = G_RATE_SCH_REVISION_ID /* 4527736 */
1370 and m.organization_id =start_org)
1371 group by cbicc.ind_cost_code;
1372
1373 Exception
1374 WHEN OTHERS THEN
1375 status := SQLCODE;
1376 End ;
1377 End if ;
1378 End if ; /*l_check =0*/
1379
1380 /*End of changes for 3055700 */
1381
1382 /*Bug 5181688 */
1383 pa_cost_plus.Cache_Impacted_Cost_Bases( G_RATE_SCH_REVISION_ID
1384 ,G_CP_STRUCTURE);
1385
1386
1387 /*2933915 :Added call to procedure find_impacted_top_org() that should return the PL/SQL table of
1388 AFFECTED TOP organization org_list*/
1389 /*Basically for this the hierarchy attached to the revision is traversed and we find the top most
1390 organizations out of the complete set of organizations for which the multipliers have changed.
1391 This is to avoid compiling ALL the organizations in the hierarchy as was happening earlier and hence
1392 to start compiling from the top most impacted orgs */
1393
1394 /* 4527736 */
1395 pa_cost_plus.find_impacted_top_org(G_RATE_SCH_REVISION_ID,G_ORG_STRUC_VER_ID,start_org,org_tab,status); /*2933915*/
1396
1397 if (status < 0) then /*2933915*/
1398
1399 errbuf := sqlerrm (status);
1400 retcode := 2;
1401 return;
1402 end if;
1403 --
1404 -- Verify whether there is any costed expenditure item
1405 --
1406
1407 -- 4527736
1408 pa_cost_plus.check_revision_used(G_RATE_SCH_REVISION_ID, lstatus, stage); /*2933915*/
1409
1410 /*2933915 : FOR SELECTIVE DELETION AND OBSOLETION */
1411 /***Added a LOOP for the processing to go for each TOP IMPACTED organization returned by the above procedure in org_tab
1412 We are going to process for all the children of the top affected org **********/
1413
1414
1415 IF org_tab.exists(1) THEN
1416 FOR i in org_tab.first..org_tab.last
1417 LOOP
1418
1419 /*4642011 if (lstatus = 0) then /*2933915*/
1420
1421
1422 /*4642011 delete_rate_sch_revision(G_RATE_SCH_REVISION_ID,G_ORG_STRUC_VER_ID,org_tab(i),status,stage); --2933915
1423
1424 if (status < 0) then
1425 errbuf := sqlerrm (status);
1426 retcode := 2;
1427 return;
1428 end if; */
1429
1430 /************************MOVED ALL THIS to new procedure delete_rate_sch_revision()
1431 -
1432
1433 if (status = 0) then
1434
1435 --
1436 -- Remove redundant compiled sets and multipiers.
1437 --
1438 DELETE pa_compiled_multipliers
1439 WHERE ind_compiled_set_id IN
1440 (SELECT ind_compiled_set_id
1441 FROM pa_ind_compiled_sets
1442 WHERE ind_rate_sch_revision_id = rate_sch_rev_id);
1443
1444 DELETE pa_ind_compiled_sets
1445 WHERE ind_rate_sch_revision_id = rate_sch_rev_id;
1446 ***************************************************************************************/
1447 /*4642011
1448 else
1449 /*4642011*/
1450 --
1451 -- Disable the current rate schedule if any
1452 --
1453 -- 4527736
1454 pa_cost_plus.disable_rate_sch_revision(G_RATE_SCH_REVISION_ID,G_ORG_STRUC_VER_ID,org_tab(i),status, stage );
1455 /*2933915 :ADDED org_struc_ver_id and org_id as parameter *****/
1456 if (status < 0) then
1457 errbuf := sqlerrm (status);
1458 retcode := 2;
1459 return;
1460 end if;
1461
1462 /*4642011
1463 end if;
1464 /*4642011*/
1465
1466 --
1467 -- Compile rates for all organizations starting from the top impacted organization
1468 --
1469
1470 pa_cost_plus.compile_org_hierarchy_rates(G_RATE_SCH_REVISION_ID,
1471 org_tab(i), /*2933915 : Replaced start_org by org_tab(i)*/
1472 'ALL',
1473 status,
1474 stage);
1475
1476 if (status < 0) then
1477 errbuf := sqlerrm (status);
1478 retcode := 2;
1479 return;
1480 end if;
1481
1482 END LOOP ; /*2933915*/
1483 END IF ; /*If org_tab.exists*/
1484
1485 -- Mark impacted expenditure items for re-costing
1486
1487 pa_cost_plus.mark_impacted_exp_items(G_RATE_SCH_REVISION_ID,status, stage);
1488
1489 if (status < 0) then
1490 errbuf := sqlerrm (status);
1491 retcode := 2;
1492 return;
1493 end if;
1494
1495 /*2933915 :After compilation is over we need to reset the ready_to_compile_flag back to 'N' for this revision_id and also
1496 delete the records having ready_to_compile_flag as 'X' .
1497 For reference :Ready_to_compile_flag 'X' records are actually deleted records but they were retained till this point of time for
1498 processing and treating them as impacted records***/
1499
1500 /*3055700 :Deleting the dummy entries inserted earlier since by now processing is done*/
1501 DELETE pa_ind_cost_multipliers
1502 where ind_rate_sch_revision_id = G_RATE_SCH_REVISION_ID
1503 and organization_id = start_org
1504 and created_by = l_created_by ;
1505 /*3055700*/
1506
1507 DELETE pa_ind_cost_multipliers
1508 where ind_rate_sch_revision_id = G_RATE_SCH_REVISION_ID
1509 and nvl(ready_to_compile_flag,'N') ='X';
1510
1511 UPDATE pa_ind_cost_multipliers
1512 set ready_to_compile_flag ='N'
1513 where ind_rate_sch_revision_id = G_RATE_SCH_REVISION_ID
1514 and nvl(ready_to_compile_flag,'N') ='Y';
1515
1516 COMMIT;
1517
1518 /*End of changes for bug 2933915*/
1519
1520 END compile_schedule;
1521
1522
1523
1524 --
1525 -- PROCEDURE
1526 -- compile_all
1527 --
1528 -- PURPOSE
1529 -- The objective of this procedure is to create compiled rates
1530 -- for all rate schedules which have been marked as 'ready to
1531 -- compile'.
1532 --
1533 -- HISTORY
1534 --
1535 -- 22-JUN-94 S Lee Created
1536 --
1537
1538
1539 PROCEDURE compile_all(errbuf IN OUT NOCOPY varchar2,
1540 retcode IN OUT NOCOPY varchar2)
1541
1542 IS
1543 --
1544 -- Cursor definition
1545 --
1546
1547 /*Bug 2933915 :We need to compile only the schedules wherein some multiplier has changed .Hence modified the cursor for the same.*/
1548
1549 CURSOR sch_cursor
1550 IS
1551 SELECT ind_rate_sch_revision_id
1552 FROM pa_ind_rate_sch_revisions irsr
1553 WHERE irsr.compiled_flag = 'N'
1554 AND nvl(irsr.ready_to_compile_flag,'N') = 'Y'
1555 AND EXISTS (Select 1
1556 from pa_ind_cost_multipliers icm
1557 WHERE icm.ind_rate_sch_revision_id = irsr.ind_rate_sch_revision_id
1558 AND nvl(icm.ready_to_compile_flag,'N') in ('Y','X'));
1559
1560 -- Local variables
1561
1562 sch_rev_id varchar2(30);
1563
1564 BEGIN
1565
1566 <<process_sch>>
1567 FOR sch_row IN sch_cursor
1568 LOOP
1569
1570 BEGIN
1571 sch_rev_id := sch_row.ind_rate_sch_revision_id;
1572
1573 pa_cost_plus.compile_schedule(errbuf,
1574 retcode,
1575 sch_rev_id);
1576
1577 END;
1578
1579 END LOOP process_sch;
1580
1581 END compile_all;
1582
1583
1584
1585 --
1586 -- PROCEDURE
1587 -- get_exp_item_indirect_cost
1588 --
1589 -- PURPOSE
1590 -- The objective of this procedure is to retrieve the total
1591 -- indirect cost for an expenditure item. User can specify the
1592 -- expenditure item information and the type of indirect rate
1593 -- schedule, and get the total amount of indirect cost associated
1594 -- with the expenditure item.
1595 --
1596 -- Note: This procedure gets called from both the project and expenditure
1597 -- oriented process. Hence should always refer to the base tables
1598 -- and not the Morg view.
1599 --
1600 -- HISTORY
1601 --
1602 -- 10-JUN-94 S Lee Created
1603 --
1604
1605
1606 /*
1607 Multi-Currency Related Changes:
1608 Two new parameters added
1609 indirect_cost_acct
1610 indirect_cost_denom
1611 */
1612 procedure get_exp_item_indirect_cost(exp_item_id IN Number,
1613 schedule_type IN Varchar2,
1614 indirect_cost IN OUT NOCOPY Number,
1615 indirect_cost_acct IN OUT NOCOPY Number,
1616 indirect_cost_denom IN OUT NOCOPY Number,
1617 indirect_cost_project IN OUT NOCOPY Number, /* EPP */
1618 rate_sch_rev_id IN OUT NOCOPY Number,
1619 compiled_set_id IN OUT NOCOPY Number,
1620 status IN OUT NOCOPY Number,
1621 stage IN OUT NOCOPY Number)
1622
1623 IS
1624
1625 --
1626 -- Local variables
1627 --
1628
1629 /*
1630 Multi-Currency Related Changes: New Local variables added
1631 direct_cost_denom, direct_cost_acct
1632 burden_cost_denom, burden_cost_acct
1633 compiled_multiplier
1634 */
1635 exp_type Varchar2(30);
1636 cp_structure Varchar2(30);
1637 c_base Varchar2(30);
1638 org_id Number(15);
1639 direct_cost Number(22,5);
1640 direct_cost_denom Number;
1641 direct_cost_acct Number;
1642 direct_cost_project Number; /* ProjCurr Changes */
1643 l_denom_currency_code VARCHAR2(15);
1644 l_acct_currency_code VARCHAR2(15);
1645 l_project_currency_code VARCHAR2(15);
1646 l_projfunc_currency_code VARCHAR2(15);
1647 quantity pa_expenditure_items_all.quantity%TYPE;
1648 burden_cost pa_expenditure_items_all.burden_cost%TYPE;
1649 burden_cost_denom pa_expenditure_items_all.denom_burdened_cost%TYPE;
1650 burden_cost_acct pa_expenditure_items_all.acct_burdened_cost%TYPE;
1651 burden_cost_project pa_expenditure_items_all.project_burdened_cost%TYPE; /* ProjCurr Changes */
1652 system_linkage pa_expenditure_items_all.system_linkage_function%TYPE;
1653 compiled_multiplier pa_compiled_multipliers.compiled_multiplier%TYPE;
1654
1655 BEGIN
1656
1657 -- Initialize output parameters
1658 status := 0;
1659 stage := 100;
1660 indirect_cost := NULL;
1661 rate_sch_rev_id := NULL;
1662 compiled_set_id := NULL;
1663
1664 --
1665 -- Retrieve the information of the expenditure item
1666 -- As this procedure can be called from project Oriented or Expenditure
1667 -- oriented process, hence the uderlying select uses base table.
1668 --
1669
1670 /*
1671 Multi-Currency Related Changes:
1672 Select additional columns
1673 denom_raw_cost, Acct_raw_cost
1674 denom_burdened_cost,Acct_burdened_cost
1675 */
1676 SELECT expenditure_type,
1677 raw_cost,
1678 denom_raw_cost,
1679 acct_raw_cost,
1680 project_raw_cost,
1681 quantity,
1682 burden_cost,
1683 denom_burdened_cost,
1684 acct_burdened_cost,
1685 project_burdened_cost, /* ProjCurr Changes */
1686 projfunc_currency_code, /* ProjCurr Changes */
1687 acct_currency_code,
1688 denom_currency_code,
1689 project_currency_code,
1690 system_linkage_function
1691 INTO exp_type,
1692 direct_cost,
1693 direct_cost_denom,
1694 direct_cost_acct,
1695 direct_cost_project,
1696 quantity,
1697 burden_cost,
1698 burden_cost_denom,
1699 burden_cost_acct,
1700 burden_cost_project, /* ProjCurr Changes */
1701 l_projfunc_currency_code, /* ProjCurr Changes */
1702 l_acct_currency_code,
1703 l_denom_currency_code,
1704 l_project_currency_code,
1705 system_linkage
1706 FROM pa_expenditure_items_all
1707 WHERE expenditure_item_id = exp_item_id;
1708
1709 -- For Project Manufacturing, specifically BURDEN_TRANSACTIONS, raw_cost,
1710 -- quantity will be zero but burden_cost will not be zero
1711 -- For Billing purpose (Revenue and Invoicing) we will take burden_cost and
1712 -- apply burden multipliers on burden_cost.
1713 --
1714 -- Except Burden Transactions, there will not be any items with raw_cost and
1715 -- quantity=0 with burden_cost <> 0
1716 -- Following query will be modified in R11 for getting system_linkage from
1717 -- new intersection entity
1718 --
1719 /*
1720 Multi-Currency Related Changes:
1721 Set direct_cost_denom and direct_cost_acct also.
1722 */
1723 IF (direct_cost = 0 AND quantity = 0 AND burden_cost <> 0)
1724 AND ( schedule_type='R' OR schedule_type='I') THEN
1725 IF ( system_linkage='BTC') THEN
1726 direct_cost := burden_cost;
1727 direct_cost_denom := burden_cost_denom;
1728 direct_cost_acct := burden_cost_acct;
1729 direct_cost_project := burden_cost_project; /* epp */
1730 END IF;
1731 END IF;
1732 --
1733 -- Get the rate schedule revision id
1734 --
1735
1736 pa_cost_plus.get_rate_sch_rev_id(exp_item_id,
1737 schedule_type,
1738 rate_sch_rev_id,
1739 status,
1740 stage);
1741
1742 IF (status <> 0) THEN
1743 stage := 200;
1744 return;
1745 END IF;
1746
1747 --
1748 -- Get the cost plus structure
1749 --
1750
1751 pa_cost_plus.get_cost_plus_structure(rate_sch_rev_id,
1752 cp_structure,
1753 status,
1754 stage);
1755
1756 IF (status <> 0) THEN
1757 stage := 300;
1758 return;
1759 END IF;
1760
1761
1762 --
1763 -- Get the cost base
1764 --
1765
1766 pa_cost_plus.get_cost_base(exp_type,
1767 cp_structure,
1768 c_base,
1769 status,
1770 stage);
1771
1772 IF (status <> 0) THEN
1773 stage := 400;
1774 return;
1775 END IF;
1776
1777
1778 --
1779 -- Get the organization
1780 --
1781
1782 pa_cost_plus.get_organization_id(exp_item_id,
1783 org_id,
1784 status,
1785 stage);
1786
1787 IF (status <> 0) THEN
1788 stage := 500;
1789 return;
1790 END IF;
1791
1792 /*
1793 Multi-Currency Related Changes:
1794 The Call to Get_indirect_cost_sum is removed
1795 */
1796 --
1797 -- Get the indirect cost
1798 --
1799
1800 /*
1801 pa_cost_plus.get_indirect_cost_sum(org_id,
1802 c_base,
1803 rate_sch_rev_id,
1804 direct_cost,
1805 2, -- FOR US CURRENCY
1806 indirect_cost,
1807 status,
1808 stage);
1809
1810 */
1811
1812 /*
1813 Multi-Currency Related Changes:
1814 Get_compiled_multiplier is called to get the sum of the compiled multipliers.
1815 Use that multiplier to get the indirect costs in all the currencies.
1816 */
1817 --
1818 -- Get the sum of the compiled Multipliers
1819 --
1820
1821 /*
1822 * Bug#2110452
1823 * Commented to implement the same logic for burden cost calculation
1824 * as is used in R10.7/R11.0.
1825 *
1826 * pa_cost_plus.get_compiled_multiplier(org_id,
1827 * c_base,
1828 * rate_sch_rev_id,
1829 * compiled_multiplier,
1830 * status,
1831 * stage);
1832 */
1833
1834 /*
1835 * Bug#2110452
1836 * To implement the same logic as is used in R10.7/R11.0 for
1837 * burden cost calculation.
1838 */
1839
1840 pa_cost_plus.get_indirect_cost_sum1 ( org_id => org_id
1841 ,c_base => c_base
1842 ,rate_sch_rev_id => rate_sch_rev_id
1843 ,direct_cost => direct_cost
1844 ,direct_cost_denom => direct_cost_denom
1845 ,direct_cost_acct => direct_cost_acct
1846 ,direct_cost_project => direct_cost_project
1847 ,precision => 2 -- FOR US CURRENCY
1848 ,indirect_cost_sum => indirect_cost
1849 ,indirect_cost_denom_sum => indirect_cost_denom
1850 ,indirect_cost_acct_sum => indirect_cost_acct
1851 ,indirect_cost_project_sum => indirect_cost_project
1852 ,l_projfunc_currency_code => l_projfunc_currency_code
1853 ,l_project_currency_code => l_project_currency_code
1854 ,l_acct_currency_code => l_acct_currency_code
1855 ,l_denom_currency_code => l_denom_currency_code
1856 ,status => status
1857 ,stage => stage
1858 );
1859
1860 IF (status <> 0) THEN
1861 stage := 600;
1862 return;
1863 END IF;
1864
1865 /*
1866 * Bug#2110452
1867 *
1868 * indirect_cost := PA_CURRENCY.ROUND_TRANS_CURRENCY_AMT(direct_cost*compiled_multiplier,
1869 * l_project_currency_code);
1870 * indirect_cost_denom := PA_CURRENCY.ROUND_TRANS_CURRENCY_AMT(direct_cost_denom*compiled_multiplier,
1871 * l_denom_currency_code);
1872 * indirect_cost_acct := PA_CURRENCY.ROUND_TRANS_CURRENCY_AMT(direct_cost_acct*compiled_multiplier,
1873 * l_acct_currency_code);
1874 * indirect_cost_project := PA_CURRENCY.ROUND_TRANS_CURRENCY_AMT(direct_cost_project*compiled_multiplier,
1875 * l_project_currency_code);
1876 */
1877
1878 stage := 700;
1879
1880 --
1881 -- Get the compiled set id
1882 --
1883
1884 SELECT ind_compiled_set_id
1885 INTO compiled_set_id
1886 FROM pa_ind_compiled_sets
1887 WHERE ind_rate_sch_revision_id = rate_sch_rev_id
1888 AND organization_id = org_id
1889 AND cost_base = c_base /*Bug# 2933915*/
1890 AND STATUS = 'A';
1891
1892
1893 EXCEPTION
1894
1895 WHEN OTHERS THEN
1896 status := SQLCODE;
1897
1898 END get_exp_item_indirect_cost;
1899
1900
1901 --
1902 -- PROCEDURE
1903 -- get_exp_item_burden_amount
1904 --
1905 -- PURPOSE
1906 -- This is a pseudo procedure that provides a shell of
1907 -- get_exp_item_indirect_cost. This procedure is introduced
1908 -- due to terminology change.
1909 --
1910 -- HISTORY
1911 --
1912 -- 30-DEC-94 S Lee Created
1913 --
1914
1915
1916 procedure get_exp_item_burden_amount(exp_item_id IN Number,
1917 schedule_type IN Varchar2,
1918 burden_amount IN OUT NOCOPY Number,
1919 rate_sch_rev_id IN OUT NOCOPY Number,
1920 compiled_set_id IN OUT NOCOPY Number,
1921 status IN OUT NOCOPY Number,
1922 stage IN OUT NOCOPY Number)
1923
1924 IS
1925 /*
1926 Multi-Currency Related Changes:
1927 Interface of the procedure get_exp_item_indirect_cost is changed.
1928 Two additional parameters are passed but not used within this procedure.
1929 */
1930 /*
1931 * EPP.
1932 * Project Currency related Changes.
1933 * Passing new parameter burden_amount_project.
1934 */
1935 burden_amount_denom PA_EXPENDITURE_ITEMS.Denom_Burdened_cost%TYPE;
1936 burden_amount_Acct PA_EXPENDITURE_ITEMS.Acct_Burdened_cost%TYPE;
1937 burden_amount_Project PA_EXPENDITURE_ITEMS.Project_Burdened_cost%TYPE; /* epp */
1938 BEGIN
1939 pa_cost_plus.get_exp_item_indirect_cost(exp_item_id,
1940 schedule_type,
1941 burden_amount,
1942 burden_amount_denom,
1943 burden_amount_acct,
1944 burden_amount_project, /* epp */
1945 rate_sch_rev_id,
1946 compiled_set_id,
1947 status,
1948 stage);
1949
1950
1951 END get_exp_item_burden_amount;
1952
1953 --
1954 -- PROCEDURE
1955 -- populate_indirect_cost
1956 --
1957 -- PURPOSE
1958 -- The objective of this procedure is to populate the total
1959 -- indirect cost for an expenditure item.
1960 --
1961 -- HISTORY
1962 --
1963 -- 09-AUG-94 S Lee Created
1964 --
1965
1966 PROCEDURE populate_indirect_cost(update_count IN OUT NOCOPY NUMBER)
1967 IS
1968
1969 -- Cursor definition
1970 /*
1971 Multi-Currency Related Changes:
1972 Acct_Raw_Cost and Denom_Raw_Cost picked up; also the check is done on the basis
1973 of Denom Costs. (previously the checks were done on the basis of raw_cost)
1974 */
1975 /*
1976 Burdening related changes:
1977 record is picked up for burdening if either of three buckets is null
1978 */
1979 /*
1980 * Bug# 855461
1981 * Denom_burdened_cost and transaction_source also picked up.
1982 */
1983 /*
1984 * Bug# 913273
1985 * BTC Items are not processed here. It is done within
1986 * Costing process.
1987 *
1988 * Bug#1002399
1989 * 'OT' items are not processed . Removed this condition for Bug #1946968
1990 */
1991 CURSOR Exp_Item_Cursor IS
1992 SELECT ITEM.Expenditure_Item_ID,
1993 ITEM.Raw_Cost,
1994 ITEM.Acct_Raw_Cost,
1995 ITEM.Project_Raw_Cost, /* ProjCurr Changes */
1996 ITEM.Denom_Raw_Cost,
1997 ITEM.Denom_Burdened_Cost,
1998 ITEM.Burden_Cost,
1999 ITEM.Acct_burdened_Cost,
2000 ITEM.Project_burdened_Cost,
2001 ITEM.Transaction_Source,
2002 ITEM.Quantity,
2003 ITEM.Raw_Cost_Rate,
2004 ITEM.System_Linkage_Function,
2005 ITEM.cost_ind_compiled_set_id,
2006 nvl(ITEM.net_zero_adjustment_flag,'N') net_zero_adjustment_flag,
2007 TYPE.burden_amt_display_method,
2008 ITEM.adjusted_expenditure_item_id, -- Bug 3893837
2009 ITEM.project_id -- added bug 8248419
2010 FROM PA_Expenditure_Items ITEM,
2011 --PA_TASKS TASK, /* Bug 3458139 */
2012 PA_PROJECTS_ALL PROJ,
2013 PA_PROJECT_TYPES_ALL TYPE
2014 WHERE ITEM.Cost_Distributed_Flag = 'S'
2015 AND ITEM.Denom_Raw_Cost IS NOT NULL
2016 AND (ITEM.Denom_Burdened_Cost IS NULL
2017 OR
2018 ITEM.Acct_Burdened_Cost IS NULL
2019 OR
2020 ITEM.Burden_Cost IS NULL
2021 OR
2022 ITEM.Transferred_from_exp_item_id IS NOT NULL /*2217540*/
2023 OR /* 2328366 */
2024 EXISTS (SELECT 1
2025 FROM PA_TRANSACTION_SOURCES PTS
2026 WHERE PTS.Transaction_source = ITEM.Transaction_source
2027 AND PTS.Allow_Burden_Flag = 'Y')
2028 OR ITEM.cost_ind_compiled_set_id is null) /* 3008365 */
2029 AND ITEM.Cost_Dist_Rejection_Code IS NULL
2030 --AND ITEM.Task_ID = TASK.Task_ID /* Bug 3458139 */
2031 --AND TASK.Project_ID = PROJ.Project_ID /* Bug 3458139 */
2032 AND ITEM.Project_Id = PROJ.Project_Id /* Bug 3458139 */
2033 AND PROJ.Project_Type = TYPE.Project_Type
2034 /* AND nvl(TYPE.Org_Id, -99) = nvl(PROJ.Org_Id, -99) bug 5374745 */
2035 AND TYPE.Org_id = PROJ.Org_id -- bug 5374745
2036 AND TYPE.burden_cost_flag = 'Y'
2037 -- AND ITEM.System_Linkage_Function NOT IN ('BTC','OT'); /* Commented for Bug#1946968 */
2038 AND ITEM.System_Linkage_Function <> 'BTC'
2039 ORDER BY ITEM.Expenditure_Item_ID; /*for bug 6066796*/
2040 /*
2041 Multi-Currency Related Changes:
2042 New Variables defined : indirect_cost_denom, indirect_cost_acct
2043 total_burden_cost_denom, total_burden_cost_acct
2044 */
2045 indirect_cost PA_Expenditure_Items.Burden_Cost%TYPE;
2046 indirect_cost_denom PA_Expenditure_Items.Denom_Burdened_Cost%TYPE;
2047 indirect_cost_acct PA_Expenditure_Items.Acct_Burdened_Cost%TYPE;
2048 indirect_cost_project PA_Expenditure_Items.Project_Burdened_Cost%TYPE; /* ProjCurr Changes */
2049 burdened_cost PA_Expenditure_Items.Burden_Cost%TYPE;
2050 burdened_cost_denom PA_Expenditure_Items.Denom_Burdened_Cost%TYPE;
2051 burdened_cost_acct PA_Expenditure_Items.Acct_Burdened_Cost%TYPE;
2052 burdened_cost_project PA_Expenditure_Items.Project_Burdened_Cost%TYPE; /* ProjCurr Changes */
2053 x_Burden_Cost_Rate PA_Expenditure_Items.Burden_Cost_Rate%TYPE;
2054 total_burden_cost PA_Expenditure_Items.Burden_Cost%TYPE;
2055 total_burden_cost_denom PA_Expenditure_Items.Denom_Burdened_Cost%TYPE;
2056 total_burden_cost_acct PA_Expenditure_Items.Acct_Burdened_Cost%TYPE;
2057 total_burden_cost_project PA_Expenditure_Items.Project_Burdened_Cost%TYPE; /* ProjCurr Changes */
2058 qty PA_Expenditure_Items.Quantity%TYPE;
2059 compiled_set_id PA_Expenditure_Items.Cost_Ind_Compiled_Set_ID%TYPE;
2060 reason PA_Expenditure_Items.Ind_Cost_Dist_Rejection_Code%TYPE;
2061 rate_sch_rev_id PA_Ind_Rate_Sch_Revisions.Ind_Rate_Sch_Revision_ID%TYPE;
2062 status number(15);
2063 stage number(15);
2064 /*
2065 * Bug# 855461
2066 * New Variables defined
2067 *
2068 * the variable l_api_call_reqd is used to save the
2069 * call to general API for the imported trnasction with
2070 * transaction source. allow burden = 'Y'
2071 *
2072 */
2073 l_allow_burden_flag PA_TRANSACTION_SOURCES.Allow_Burden_Flag%TYPE;
2074 l_api_call_reqd VARCHAR2(1) ;
2075
2076 -- Bug 3893837 : Introduced cursor to fetch burden cost for adjusted expenditure
2077 -- items from the original expenditure item which is already costed.
2078
2079 CURSOR Adj_Exp_Item_Cursor (p_exp_item_id NUMBER ,p_denom_raw_cost NUMBER ) IS
2080 SELECT cost_ind_compiled_set_id,
2081 -1 * Burden_Cost ,
2082 -1 * Denom_Burdened_Cost,
2083 -1 * Acct_Burdened_Cost ,
2084 -1 * Project_burdened_Cost,
2085 Burden_Cost_Rate
2086 FROM pa_expenditure_items_all
2087 WHERE expenditure_item_id = p_exp_item_id
2088 AND Denom_Raw_Cost = -1 * p_denom_raw_cost
2089 AND Denom_Burdened_Cost IS NOT NULL
2090 AND Acct_Burdened_Cost IS NOT NULL
2091 AND Burden_Cost IS NOT NULL ;
2092 /*
2093 ** Bug: 5155112
2094 ** BURDEN SEPARATE LINE - AMOUNT NOT EQUAL TO BURDENED_COST
2095 ** Issue was with the check " AND cost_ind_compiled_set_id IS NOT NULL" in CURSOR Adj_Exp_Item_Cursor
2096 ** This failed for trxns not attached to any burden cost base thereby populating the burden cost column with cached
2097 ** values(incorrectly).
2098 ** AND cost_ind_compiled_set_id IS NOT NULL ;
2099 */
2100
2101 l_adjusted_item_flag VARCHAR2(1);
2102
2103 -- added bug 8248419 start
2104 CURSOR Cost_Burden_Flag_Cursor (p_project_id Number) IS
2105 SELECT NVL(burden_cost_flag,'N'),
2106 NVL(total_burden_flag,'N')
2107 FROM pa_projects_all prj, pa_project_types_all prj_type --Bug14158202
2108 WHERE prj.project_id = p_project_id
2109 AND prj.project_TYPE = prj_type.project_TYPE;
2110
2111 l_burden_cost_flag pa_project_types.BURDEN_COST_FLAG%TYPE;
2112 l_total_burden_flag pa_project_types.TOTAL_BURDEN_FLAG%TYPE;
2113 l_cost_burden_distributed_flag pa_Expenditure_Items.cost_burden_distributed_flag%TYPE;
2114 -- bug 8248419 end
2115
2116 BEGIN
2117
2118 update_count := 0;
2119 FOR Exp_Item_Row IN Exp_Item_Cursor LOOP
2120
2121 compiled_set_id := NULL; -- Bug 3365476 : Nullify the compiled_set_id, so that it is not
2122 -- populated for already burdened expenditures.
2123 l_burden_cost_flag := NULL; --Bug14158202
2124 l_total_burden_flag := NULL; --Bug14158202
2125 l_cost_burden_distributed_flag := NULL; --Bug14158202
2126 --
2127 -- Get the indirect cost and other information
2128 --
2129
2130 /*
2131 * Bug# 855461
2132 * For imported transactions with allow_burden_flag = 'Y'
2133 * take the ratio of transaction burdened cost to tranaction raw cost
2134 * to get the burden multiplier and use it to calculate
2135 * acct burdened and project burdened cost
2136 */
2137 l_api_call_reqd := 'Y';
2138 l_adjusted_item_flag := 'N'; -- Bug 3893837
2139 IF Exp_Item_Row.transaction_source IS NOT NULL THEN
2140 SELECT Allow_Burden_Flag
2141 INTO l_allow_burden_flag
2142 FROM PA_TRANSACTION_SOURCES
2143 WHERE Transaction_Source = Exp_Item_Row.transaction_source;
2144 /* Bug 902578: Fist we calculate the burdened cost using the ratio calculation.
2145 Then we derive the burden cost by subtracting raw cost from burdened cost.
2146 The burden cost (indirect cost) will later be used to calculate total burden cost
2147 which is equivalent to our burdened cost
2148 Example
2149 Raw Cost Burdened Cost Indirect Cost
2150 20 30 10
2151 Acct Raw Cost
2152 60
2153 Burdened_cost_acct = 60 * (30/20) = 90
2154 Indirect_cost_acct = 90 - 60 = 30
2155 */
2156
2157 IF l_allow_burden_flag = 'Y' THEN
2158 /* Bug 4375749 - Divide-by-zero error when Denom_Raw_Cost = 0 */
2159 IF Exp_item_Row.Denom_Raw_Cost <> 0 THEN
2160 burdened_cost := (Exp_Item_Row.Denom_Burdened_Cost/Exp_item_Row.Denom_Raw_Cost)
2161 * Exp_Item_Row.Raw_Cost;
2162 indirect_cost := burdened_cost - Exp_item_Row.Raw_Cost;
2163
2164 burdened_cost_acct := (Exp_Item_Row.Denom_Burdened_Cost/Exp_item_Row.Denom_Raw_Cost)
2165 * Exp_Item_Row.Acct_Raw_Cost;
2166 indirect_cost_acct := burdened_cost_acct - Exp_item_Row.Acct_Raw_Cost;
2167
2168 /*
2169 * Bug 4063390
2170 * burdened_cost_denom := Exp_Item_Row.Denom_Burdened_Cost -
2171 * Exp_Item_Row.Denom_Raw_Cost;
2172 */
2173 burdened_cost_denom := Exp_Item_Row.Denom_Burdened_Cost;
2174 indirect_cost_denom := burdened_cost_denom - Exp_Item_Row.Denom_Raw_Cost;
2175
2176 burdened_cost_project := (Exp_Item_Row.Denom_Burdened_Cost/Exp_item_Row.Denom_Raw_Cost)
2177 * Exp_Item_Row.Project_Raw_Cost;
2178 indirect_cost_project := burdened_cost_project - Exp_item_Row.Project_Raw_Cost;
2179
2180 ELSE
2181 burdened_cost := 0;
2182 indirect_cost := 0;
2183 burdened_cost_acct := 0;
2184 indirect_cost_acct := 0;
2185 burdened_cost_denom:= 0;
2186 indirect_cost_denom:= 0;
2187 burdened_cost_project:= 0;
2188 indirect_cost_project:= 0;
2189 END IF;
2190 /* Bug 4375749 */
2191 status := 0;
2192 l_api_call_reqd := 'N';
2193 END IF;
2194 END IF;
2195 /*
2196 Multi-Currency Related Changes:
2197 Additional Parameters passed (indirect_cost_acct, indirect_cost_denom)
2198 */
2199 IF l_api_call_reqd = 'Y' THEN
2200
2201 -- Bug 3893837 : Calculate the burden cost for adjusted expenditure items
2202 -- by taking the original expenditure items cost.If the original item has NULL
2203 -- burden costs/ compiled set id then both the costs of the orginal
2204 -- and adjusting items will be processed in this program as if they were
2205 -- 'normal' (non-adjusted) expenditure items ,and both will have same compiled set id as
2206 -- they are derived at same time.
2207
2208 IF Exp_Item_Row.net_zero_adjustment_flag = 'Y' AND Exp_Item_Row.adjusted_expenditure_item_id IS NOT NULL THEN
2209
2210 OPEN Adj_Exp_Item_Cursor(Exp_Item_Row.adjusted_expenditure_item_id,Exp_Item_Row.Denom_Raw_Cost);
2211 FETCH Adj_Exp_Item_Cursor INTO compiled_set_id,total_burden_cost,total_burden_cost_denom,
2212 total_burden_cost_Acct,total_burden_cost_Project,x_Burden_Cost_Rate;
2213 CLOSE Adj_Exp_Item_Cursor;
2214
2215 l_adjusted_item_flag := 'Y';
2216 status := 0;
2217
2218 ELSE
2219
2220 pa_cost_plus.get_exp_item_indirect_cost(
2221 Exp_Item_Row.Expenditure_Item_ID,
2222 'C',
2223 indirect_cost,
2224 indirect_cost_acct,
2225 indirect_cost_denom,
2226 indirect_cost_project, /* ProjCurr Changes */
2227 rate_sch_rev_id,
2228 compiled_set_id,
2229 status,
2230 stage);
2231 END IF;
2232 END IF;
2233
2234 -- added Bug 8248419 start
2235 OPEN Cost_Burden_Flag_Cursor (Exp_Item_Row.project_id);
2236 FETCH Cost_Burden_Flag_CURSOR INTO l_burden_cost_flag, l_total_burden_flag;
2237 CLOSE Cost_Burden_Flag_Cursor;
2238
2239 IF (NVL(l_burden_cost_flag, 'N') = 'Y' OR NVL(l_total_burden_flag, 'N') = 'Y') --Bug14158202
2240 THEN l_cost_burden_distributed_flag := 'Z';
2241 END IF;
2242 -- Bug 8248419 end
2243
2244
2245 IF (status = 0) THEN
2246 --
2247 -- The indirect cost is retrieved successfully.
2248 -- Update the expenditure item.
2249 --
2250 qty := Exp_Item_Row.Quantity;
2251 --
2252 -- If Burden amount is going to be displayed on same transaction
2253 -- then do the calculation else burden_cost=raw_cost
2254 --
2255 /*
2256 Multi-Currency Related Changes:
2257 Set total_burden_cost_denom and total_burden_cost_acct
2258 */
2259 IF (Exp_Item_Row.System_Linkage_Function <> 'BTC') AND l_adjusted_item_flag ='N' THEN -- Bug
2260 IF (Exp_Item_Row.Burden_Amt_Display_Method = 'S') THEN
2261 total_burden_cost := Exp_Item_Row.Raw_Cost + indirect_cost;
2262 total_burden_cost_denom := Exp_Item_Row.Denom_Raw_Cost + indirect_cost_denom;
2263 total_burden_cost_acct := Exp_Item_Row.Acct_Raw_Cost + indirect_cost_acct;
2264 total_burden_cost_project := Exp_Item_Row.Project_Raw_Cost + indirect_cost_project; /* ProjCurr Changes */
2265 IF (qty <> 0) THEN
2266 x_Burden_Cost_Rate := (total_burden_cost_denom /nvl(qty,1));
2267 ELSE
2268 x_Burden_Cost_Rate := total_burden_cost_denom;
2269 END IF;
2270 ELSE -- Burden amount to be displayed as separate EI
2271 total_burden_cost := Exp_Item_Row.Raw_Cost;
2272 total_burden_cost_denom := Exp_Item_Row.Denom_Raw_Cost;
2273 total_burden_cost_acct := Exp_Item_Row.Acct_Raw_Cost;
2274 total_burden_cost_project := Exp_Item_Row.Project_Raw_Cost; /* ProjCurr Changes */
2275 x_Burden_Cost_Rate := Exp_Item_Row.Raw_Cost_Rate;
2276 END IF;-- end if of Burden Amount_display_method
2277 END IF; -- end if of Expenditure_type BTC
2278
2279 /*
2280 Multi-Currency Related Changes:
2281 Update Denom_burdened_cost and Acct_burdened_cost
2282 */
2283 /*
2284 Burdening related changes:
2285 Set the value of that bucket which is null.
2286 */
2287
2288 -- Bug 3893837 : Moved the logic of deriving rates for net zero items in the starting.
2289 -- Bug fixes 3617506 and 3834184 are obsoleted as its incorrect to
2290 -- copy the same burden costs in case compiled_set_id is same or net zero is yes.
2291 -- Reason : As per main query ,this code gets fired only if any of the burden costs are NULL/
2292 -- compiled set is NULL.So in case burden costs are null ,compiled set is NOT NULL and
2293 -- net zero is Yes then the burden costs should be copied from original item if
2294 -- already costed else rederive .
2295 -- Note : Please test all scenarios mentioned in bug 3893837 if this logic is modified in future.
2296
2297 UPDATE PA_Expenditure_Items
2298 SET Burden_Cost_Rate = x_Burden_Cost_Rate,
2299 Burden_Cost = total_burden_cost,
2300 Denom_burdened_Cost = total_burden_cost_denom,
2301 Acct_burdened_Cost = total_burden_cost_Acct,
2302 Project_burdened_Cost = total_burden_cost_Project, /* ProjCurr Changes */
2303 Cost_Ind_Compiled_Set_Id = compiled_set_id,
2304 Ind_Cost_Dist_Rejection_Code = NULL,
2305 cost_burden_distributed_flag = decode(l_cost_burden_distributed_flag,'Z','Z',
2306 decode(l_api_call_reqd,'N','Z',cost_burden_distributed_flag)) /*2450423 changed bug 8248419*/
2307 WHERE Expenditure_Item_ID = Exp_Item_Row.Expenditure_Item_ID;
2308
2309 update_count := update_count + 1;
2310
2311 ELSE
2312 --
2313 -- Error handling. Explain the rejection reason.
2314 --
2315 IF ((status = 100) and (stage = 400)) THEN
2316 --
2317 -- Can not find cost base. The total burdened cost
2318 -- equals raw cost.
2319 --
2320 /*
2321 Multi-Currency Related Changes:
2322 Update Denom_burdened_cost and Acct_burdened_cost
2323 */
2324 /*
2325 Bug# 805725
2326 Set cost_burden_distributed_flag to some impossible value ('Z')
2327 */
2328 /*
2329 Burdening related changes:
2330 Set the value of that bucket which is null.
2331 */
2332 UPDATE PA_Expenditure_Items
2333 SET Burden_Cost_Rate = Raw_Cost_Rate,
2334 Burden_Cost = NVL(Burden_Cost,Raw_Cost),
2335 Denom_Burdened_Cost = NVL(Denom_Burdened_Cost,Denom_Raw_Cost),
2336 Acct_Burdened_Cost = NVL(Acct_Burdened_Cost,Acct_Raw_Cost),
2337 Project_Burdened_Cost = NVL(Project_Burdened_Cost,Project_Raw_Cost), /* epp */
2338 -- Cost_Burden_Distributed_Flag = 'Z', -- commented bug 8715545
2339 Cost_Burden_Distributed_Flag = decode(l_cost_burden_distributed_flag,'Z','Z','X'), -- added bug 8248419
2340 -- Cost_Burden_Distributed_Flag = 'X', -- added bug 8715545
2341 Cost_Ind_Compiled_Set_Id = NULL
2342 WHERE Expenditure_Item_ID = Exp_Item_Row.Expenditure_Item_ID;
2343
2344 update_count := update_count + 1;
2345 ELSE
2346 IF (status = 100) THEN
2347 IF (stage = 200) THEN
2348 reason := 'NO_IND_RATE_SCH_REVISION';
2349 ELSIF (stage = 300) THEN
2350 reason := 'NO_COST_PLUS_STRUCTURE';
2351 ELSIF (stage = 500) THEN
2352 reason := 'NO_ORGANIZATION';
2353 ELSIF (stage = 600) THEN
2354 reason := 'NO_COMPILED_MULTIPLIER';/* Bug 5884742 */
2355 ELSIF (stage = 700) THEN
2356 reason := 'NO_ACTIVE_COMPILED_SET';
2357 ELSE
2358 reason := 'GET_INDIRECT_COST_FAIL';
2359 END IF;
2360 ELSE
2361 reason := 'GET_INDIRECT_COST_FAIL';
2362 END IF;
2363
2364 /*
2365 Multi-Currency Related Changes:
2366 Update Denom_burdened_cost and Acct_burdened_cost
2367 */
2368 /*
2369 Burdening related changes:
2370 Dont reset burdened cost.
2371 */
2372 UPDATE PA_Expenditure_Items
2373 SET Cost_Dist_Rejection_Code = reason
2374 /*****************************
2375 ***** Burden_Cost_Rate = NULL,
2376 ***** Burden_Cost = NULL,
2377 ***** Denom_Burdened_Cost = NULL,
2378 ***** Acct_Burdened_Cost = NULL,
2379 ***** Cost_Ind_Compiled_Set_Id = NULL
2380 ******************************/
2381 WHERE Expenditure_Item_ID = Exp_Item_Row.Expenditure_Item_ID;
2382
2383 END IF;
2384
2385 END IF;
2386
2387 END LOOP;
2388
2389
2390 END populate_indirect_cost;
2391
2392
2393 --
2394 -- PROCEDURE
2395 -- get_indirect_cost_sum
2396 --
2397 -- PURPOSE
2398 -- The objective of this function is to retrieve the sum of
2399 -- indirect cost. The amount of indirect cost is the procudt
2400 -- of direct cost and the indirect cost multiplier. This
2401 -- procedure calculates the indirect cost for each indirect cost
2402 -- code with a specified precision, then sum up the total
2403 -- indirect cost.
2404 --
2405 -- HISTORY
2406 --
2407 -- 16-MAY-94 S Lee Created
2408 --
2409
2410
2411 procedure get_indirect_cost_sum(org_id IN number,
2412 c_base IN varchar2,
2413 rate_sch_rev_id IN number,
2414 direct_cost IN number,
2415 precision IN number,
2416 indirect_cost_sum IN OUT NOCOPY number,
2417 status IN OUT NOCOPY number,
2418 stage IN OUT NOCOPY number)
2419 IS
2420
2421 BEGIN
2422
2423 status := 0;
2424 stage := 100;
2425
2426 /* No longer precision argument is used; PA_CURRENCY.ROUND_CURRENCY_AMT
2427 is going to take care that. */
2428
2429 --
2430 -- Here the occurrence of ROUND_CURRENCY_AMT was not changed to ROUND_TRANS_CURRENCY_AMT
2431 -- because this is used in View Burden Costs for which displays the amount fields in
2432 -- functional currency
2433 --
2434 SELECT SUM(PA_CURRENCY.ROUND_CURRENCY_AMT((direct_cost * icpm.compiled_multiplier)))
2435 into indirect_cost_sum
2436 FROM pa_ind_compiled_sets ics,
2437 pa_compiled_multipliers icpm
2438 WHERE
2439 ics.ind_rate_sch_revision_id = rate_sch_rev_id
2440 AND ics.organization_id = org_id
2441 AND ics.status = 'A'
2442 AND ics.ind_compiled_set_id =
2443 icpm.ind_compiled_set_id
2444 AND ics.cost_base =icpm.cost_base /*Bug# 2933915*/
2445 AND icpm.cost_base = c_base;
2446
2447 if (indirect_cost_sum is null) then
2448 status := NO_DATA_FOUND_ERR;
2449 end if;
2450
2451 EXCEPTION
2452
2453 WHEN OTHERS THEN
2454 status := SQLCODE;
2455
2456 END get_indirect_cost_sum;
2457
2458
2459
2460 -- PROCEDURE
2461 -- get_indirect_cost_sum1
2462 --
2463 -- PURPOSE
2464 -- The objective of this function is to retrieve the sum of
2465 -- indirect costs(separately for indirect cost ,indirect cost acct and direct cost denom).
2466 -- The amount of indirect cost is the product
2467 -- of direct cost and the indirect cost multiplier. This
2468 -- procedure calculates the indirect cost for each indirect cost
2469 -- code rounds it , then sum up the total indirect cost (each component separately ).
2470 --
2471 -- HISTORY
2472 --
2473 -- 22-NOV-01 Seema Created /*Bug# 2110452*/
2474
2475 procedure get_indirect_cost_sum1(org_id IN number,
2476 c_base IN varchar2,
2477 rate_sch_rev_id IN number,
2478 direct_cost IN number,
2479 direct_cost_denom IN number,
2480 direct_cost_acct IN number,
2481 direct_cost_project IN number,
2482 precision IN number,
2483 indirect_cost_sum IN OUT NOCOPY number,
2484 indirect_cost_denom_sum IN OUT NOCOPY number,
2485 indirect_cost_acct_sum IN OUT NOCOPY number,
2486 indirect_cost_project_sum IN OUT NOCOPY number,
2487 l_projfunc_currency_code IN varchar2,
2488 l_project_currency_code IN varchar2,
2489 l_acct_currency_code IN varchar2,
2490 l_denom_currency_code IN varchar2,
2491 status IN OUT NOCOPY number,
2492 stage IN OUT NOCOPY number)
2493 IS
2494
2495 BEGIN
2496
2497 status := 0;
2498 stage := 100;
2499 /* Begin bug 5391496 */
2500 -- SELECT SUM(PA_CURRENCY.ROUND_TRANS_CURRENCY_AMT((direct_cost * icpm.compiled_multiplier),
2501 -- l_projfunc_currency_code)),
2502 -- SUM(PA_CURRENCY.ROUND_TRANS_CURRENCY_AMT((direct_cost_denom * icpm.compiled_multiplier),
2503 -- l_denom_currency_code)),
2504 -- SUM(PA_CURRENCY.ROUND_TRANS_CURRENCY_AMT((direct_cost_acct * icpm.compiled_multiplier),
2505 -- l_acct_currency_code)),
2506 -- SUM(PA_CURRENCY.ROUND_TRANS_CURRENCY_AMT((direct_cost_project * icpm.compiled_multiplier),
2507 -- l_project_currency_code))
2508 -- into indirect_cost_sum,
2509 -- indirect_cost_denom_sum,
2510 -- indirect_cost_acct_sum,
2511 -- indirect_cost_project_sum
2512 -- FROM pa_ind_compiled_sets ics,
2513 -- pa_compiled_multipliers icpm
2514 -- WHERE
2515 -- ics.ind_rate_sch_revision_id = rate_sch_rev_id
2516 -- AND ics.organization_id = org_id
2517 -- AND ics.status = 'A'
2518 -- AND ics.ind_compiled_set_id = icpm.ind_compiled_set_id
2519 -- AND ics.cost_base =icpm.cost_base /*Bug# 2933915*/
2520 -- AND icpm.cost_base = c_base;
2521
2522 SELECT SUM(PA_CURRENCY.ROUND_TRANS_CURRENCY_AMT1((direct_cost * icpm.compiled_multiplier),
2523 l_projfunc_currency_code)),
2524 SUM(PA_CURRENCY.ROUND_TRANS_CURRENCY_AMT1((direct_cost_denom * icpm.compiled_multiplier),
2525 l_denom_currency_code)),
2526 SUM(PA_CURRENCY.ROUND_TRANS_CURRENCY_AMT1((direct_cost_acct * icpm.compiled_multiplier),
2527 l_acct_currency_code)),
2528 SUM(PA_CURRENCY.ROUND_TRANS_CURRENCY_AMT1((direct_cost_project * icpm.compiled_multiplier),
2529 l_project_currency_code))
2530 into indirect_cost_sum,
2531 indirect_cost_denom_sum,
2532 indirect_cost_acct_sum,
2533 indirect_cost_project_sum
2534 FROM pa_ind_compiled_sets ics,
2535 pa_compiled_multipliers icpm
2536 WHERE
2537 ics.ind_rate_sch_revision_id = rate_sch_rev_id
2538 AND ics.organization_id = org_id
2539 AND ics.status = 'A'
2540 AND ics.ind_compiled_set_id = icpm.ind_compiled_set_id
2541 AND ics.cost_base =icpm.cost_base /*Bug# 2933915*/
2542 AND icpm.cost_base = c_base;
2543 /* End bug 5391496 */
2544
2545 if (indirect_cost_sum is null) then
2546 status := NO_DATA_FOUND_ERR;
2547 end if;
2548
2549 EXCEPTION
2550
2551 WHEN OTHERS THEN
2552 status := SQLCODE;
2553
2554 END get_indirect_cost_sum1;
2555
2556 --
2557 -- PROCEDURE
2558 -- view_indirect_cost
2559 --
2560 -- PURPOSE
2561 -- The objective of this procedure is to retrieve the total
2562 -- indirect cost based on a set of qualifications. User can
2563 -- specify the qualifications and the type of indirect rate
2564 -- schedule, then get the total amount of indirect cost.
2565 --
2566 -- HISTORY
2567 --
2568 -- 10-JUN-94 S Lee Created
2569 --
2570
2571 procedure view_indirect_cost(transaction_id IN Number,
2572 transaction_type IN Varchar2,
2573 task_id IN Number,
2574 effective_date IN Date,
2575 expenditure_type IN Varchar2,
2576 organization_id IN Number,
2577 schedule_type IN Varchar2,
2578 direct_cost IN Number,
2579 indirect_cost IN OUT NOCOPY Number,
2580 status IN OUT NOCOPY Number,
2581 stage IN OUT NOCOPY Number)
2582
2583 IS
2584
2585 -- Bug Fix for 886868, Burden amount is showing twice for projects that allow
2586 -- burden amount to be shown as a separate expenditure items on same project
2587 --
2588 -- NOTE : This procedure is called from 2 different programs
2589 -- PABCMTB.pls (commitments)
2590 -- PAAPIMPB.pls (Web Expense) integration
2591 -- This aPi is also called from GET_INDIRECT_COST_AMOUNTS procedure
2592 -- for which I couldn't find any references in 11.0 source stream
2593 -- By adding this change, we will be sending the indirect_cost as
2594 -- 0 if the burden amount to be displayed on same project as separate
2595 -- expenditure items
2596 -- Will make appropriate modifications to PA_COST_PLUS1 package to call
2597 -- PA_COST_PLUS1.view_indirect_cost instead of
2598 -- PA_COST_PLUS.view_indirect_cost
2599 --
2600 /*
2601 * Bug#1065740
2602 * parameter added to this cursor to avoid conflict
2603 * between local variable name and the column name in database.
2604 */
2605 CURSOR Burden_Method_Cursor(l_task_id in number) IS
2606 SELECT TYPE.burden_amt_display_method
2607 FROM PA_TASKS TASK,
2608 PA_PROJECTS_ALL PROJ,
2609 PA_PROJECT_TYPES_ALL TYPE
2610 WHERE
2611 TASK.Task_ID = l_task_id
2612 AND TASK.Project_ID = PROJ.Project_ID
2613 AND PROJ.Project_Type = TYPE.Project_Type
2614 /* AND nvl(TYPE.Org_Id, -99) = nvl(PROJ.Org_Id, -99) bug 5374745 */
2615 AND TYPE.Org_Id = PROJ.Org_id -- bug 5374745
2616 AND TYPE.burden_cost_flag = 'Y';
2617
2618 --
2619 -- Local variables
2620 --
2621
2622 rate_sch_rev_id Number(15);
2623 sch_id Number(15);
2624 sch_fixed_date Date;
2625 cp_structure Varchar2(30);
2626 c_base Varchar2(30);
2627
2628 BEGIN
2629
2630 status := 0;
2631
2632 --
2633 -- Get the rate schedule revision id
2634 --
2635 -- Bug Fix for 886868, Burden amount is showing twice for projects that allow
2636 -- burden amount to be shown as a separate expenditure items on same project
2637 --
2638 -- Opening the cursor before calling other APIs to avoid performance
2639 -- problem. If burden summarization method is D (i.e. burden amount on
2640 -- different expenditure items on same project/task, then we will need to
2641 -- set indirect_cost to 0.
2642 -- NOTE : Objective of this API is only to calculate the indirect cost and
2643 -- not to return compiled_set_id and hence we are calling cursor
2644 -- before deriving the other attributes
2645
2646 /* Bug 2989775: Added the condition to check for the value returned by the client
2647 extension function Same_Line_Burden_Cmt If the value returned is TRUE, then
2648 indirect cost should not be set to 0 even if burdening is set up on separate
2649 line at the project type level so that burdening will be on the same line for
2650 commitment transactions when viewed from the PSI screen */
2651
2652 IF PA_CLIENT_EXTN_BURDEN_SUMMARY.Same_Line_Burden_Cmt
2653 then
2654 null;
2655 ELSE
2656 FOR Burden_Method_Row IN Burden_Method_Cursor(task_id) LOOP
2657 -- If Burden amount is NOT going to be displayed on same transaction
2658 -- then set indirect_cost to 0 and return
2659 --
2660 IF (Burden_Method_Row.Burden_Amt_Display_Method <> 'S') THEN
2661 indirect_cost := 0;
2662 stage := 75;
2663 return;
2664 END IF;
2665 END LOOP;
2666 END IF;
2667
2668
2669 pa_cost_plus.find_rate_sch_rev_id(
2670 transaction_id,
2671 transaction_type,
2672 task_id,
2673 schedule_type,
2674 effective_date,
2675 sch_id,
2676 rate_sch_rev_id,
2677 sch_fixed_date,
2678 status,
2679 stage);
2680
2681 stage := 100;
2682
2683 IF (status <> 0) THEN
2684 return;
2685 END IF;
2686
2687 --
2688 -- Get the cost plus structure
2689 --
2690
2691 pa_cost_plus.get_cost_plus_structure(rate_sch_rev_id,
2692 cp_structure,
2693 status,
2694 stage);
2695
2696 IF (status <> 0) THEN
2697 stage := 200;
2698 return;
2699 END IF;
2700
2701
2702 --
2703 -- Get the cost base
2704 --
2705
2706 pa_cost_plus.get_cost_base(expenditure_type,
2707 cp_structure,
2708 c_base,
2709 status,
2710 stage);
2711
2712 /* Bug 925488: If expenditure type is not defined with a cost base,
2713 get_cost_base return with status = 100. This means this expenditure
2714 type should not be burdened. Thus, indirect cost should be 0. */
2715 IF (status <> 0) THEN
2716 IF (status = 100) THEN
2717 indirect_cost := 0;
2718 status := 0;
2719 return;
2720 ELSE
2721 stage := 300;
2722 return;
2723 END IF;
2724 END IF;
2725
2726 --
2727 -- Get the indirect cost
2728 --
2729
2730 pa_cost_plus.get_indirect_cost_sum(organization_id,
2731 c_base,
2732 rate_sch_rev_id,
2733 direct_cost,
2734 2, -- FOR US CURRENCY
2735 indirect_cost,
2736 status,
2737 stage);
2738
2739 IF (status <> 0) THEN
2740 stage := 400;
2741 return;
2742 END IF;
2743
2744
2745 EXCEPTION
2746
2747 WHEN OTHERS THEN
2748 status := SQLCODE;
2749
2750 END view_indirect_cost;
2751
2752
2753 --
2754 -- PROCEDURE
2755 -- get_burden_amount
2756 --
2757 -- PURPOSE
2758 -- The objective of this procedure is to retrieve the
2759 -- burden amount based on a set of qualifications.
2760 --
2761 -- HISTORY
2762 --
2763 -- 05-JAN-95 S Lee Created
2764 --
2765
2766 procedure get_burden_amount(burden_schedule_id IN Number,
2767 effective_date IN Date,
2768 expenditure_type IN Varchar2,
2769 organization_id IN Number,
2770 raw_amount IN Number,
2771 burden_amount IN OUT NOCOPY Number,
2772 burden_sch_rev_id IN OUT NOCOPY Number,
2773 compiled_set_id IN OUT NOCOPY Number,
2774 status IN OUT NOCOPY Number,
2775 stage IN OUT NOCOPY Number)
2776
2777 IS
2778
2779 --
2780 -- Local variables
2781 --
2782
2783 cp_structure Varchar2(30);
2784 c_base Varchar2(30);
2785
2786 BEGIN
2787
2788 status := 0;
2789
2790 --
2791 -- Get the rate schedule revision id
2792 --
2793
2794 pa_cost_plus.get_revision_by_date(burden_schedule_id,
2795 effective_date,
2796 effective_date,
2797 burden_sch_rev_id,
2798 status,
2799 stage);
2800
2801 stage := 100;
2802
2803 IF (status <> 0) THEN
2804 return;
2805 END IF;
2806
2807 --
2808 -- Get the cost plus structure
2809 --
2810
2811 pa_cost_plus.get_cost_plus_structure(burden_sch_rev_id,
2812 cp_structure,
2813 status,
2814 stage);
2815
2816 IF (status <> 0) THEN
2817 stage := 200;
2818 return;
2819 END IF;
2820
2821
2822 --
2823 -- Get the cost base
2824 --
2825
2826 pa_cost_plus.get_cost_base(expenditure_type,
2827 cp_structure,
2828 c_base,
2829 status,
2830 stage);
2831
2832 IF (status <> 0) THEN
2833 stage := 300;
2834 return;
2835 END IF;
2836
2837
2838 --
2839 -- Get the compiled set id
2840 --
2841
2842 pa_cost_plus.get_compiled_set_id(burden_sch_rev_id,
2843 organization_id,
2844 c_base, /*Bug# 2933915*/
2845 compiled_set_id,
2846 status,
2847 stage);
2848
2849 IF (status <> 0) THEN
2850 stage := 400;
2851 return;
2852 END IF;
2853
2854 --
2855 -- Get the indirect cost
2856 --
2857
2858 pa_cost_plus.get_indirect_cost_sum(organization_id,
2859 c_base,
2860 burden_sch_rev_id,
2861 raw_amount,
2862 2, -- FOR US CURRENCY
2863 burden_amount,
2864 status,
2865 stage);
2866
2867 IF (status <> 0) THEN
2868 stage := 500;
2869 return;
2870 END IF;
2871
2872
2873 EXCEPTION
2874
2875 WHEN OTHERS THEN
2876 status := SQLCODE;
2877
2878 END get_burden_amount;
2879
2880 /* added for bug#3117191 */
2881 procedure get_burden_amount1(--burden_schedule_id IN Number,
2882 -- effective_date IN Date,
2883 expenditure_type IN Varchar2,
2884 organization_id IN Number,
2885 raw_amount IN Number,
2886 burden_amount IN OUT NOCOPY Number,
2887 burden_sch_rev_id IN OUT NOCOPY Number,
2888 compiled_set_id IN OUT NOCOPY Number,
2889 status IN OUT NOCOPY Number,
2890 stage IN OUT NOCOPY Number)
2891
2892 IS
2893
2894 --
2895 -- Local variables
2896 --
2897
2898 cp_structure Varchar2(30);
2899 c_base Varchar2(30);
2900
2901 BEGIN
2902
2903 status := 0;
2904
2905 --
2906 -- Get the rate schedule revision id
2907 --
2908
2909 /*
2910 pa_cost_plus.get_revision_by_date(burden_schedule_id,
2911 effective_date,
2912 effective_date,
2913 burden_sch_rev_id,
2914 status,
2915 stage);
2916
2917 stage := 100;
2918
2919 IF (status <> 0) THEN
2920 return;
2921 END IF;
2922 */
2923
2924
2925 --
2926 -- Get the cost plus structure
2927 --
2928
2929 pa_cost_plus.get_cost_plus_structure(burden_sch_rev_id,
2930 cp_structure,
2931 status,
2932 stage);
2933
2934 IF (status <> 0) THEN
2935 stage := 200;
2936 return;
2937 END IF;
2938
2939
2940 --
2941 -- Get the cost base
2942 --
2943
2944 pa_cost_plus.get_cost_base(expenditure_type,
2945 cp_structure,
2946 c_base,
2947 status,
2948 stage);
2949
2950 IF (status <> 0) THEN
2951 stage := 300;
2952 return;
2953 END IF;
2954
2955
2956 --
2957 -- Get the compiled set id
2958 --
2959
2960 pa_cost_plus.get_compiled_set_id(burden_sch_rev_id,
2961 organization_id,
2962 c_base, /*Bug# 2933915*/
2963 compiled_set_id,
2964 status,
2965 stage);
2966
2967 IF (status <> 0) THEN
2968 stage := 400;
2969 return;
2970 END IF;
2971
2972 --
2973 -- Get the indirect cost
2974 --
2975
2976 pa_cost_plus.get_indirect_cost_sum(organization_id,
2977 c_base,
2978 burden_sch_rev_id,
2979 raw_amount,
2980 2, -- FOR US CURRENCY
2981 burden_amount,
2982 status,
2983 stage);
2984
2985 IF (status <> 0) THEN
2986 stage := 500;
2987 return;
2988 END IF;
2989
2990
2991 EXCEPTION
2992
2993 WHEN OTHERS THEN
2994 status := SQLCODE;
2995
2996 END get_burden_amount1;
2997 /* end for bug#3117191 */
2998
2999 --
3000 -- PROCEDURE
3001 -- get_hierarchy_from_revision
3002 --
3003 -- PURPOSE
3004 --
3005 --
3006 -- HISTORY
3007 --
3008 -- 10-APR-2000 C.Yuvaraj Created
3009 --
3010
3011 procedure get_hierarchy_from_revision(p_sch_rev_id IN number,
3012 x_org_struc_ver_id OUT NOCOPY number,
3013 x_start_org OUT NOCOPY number,
3014 x_status OUT NOCOPY number,
3015 x_stage OUT NOCOPY number)
3016 IS
3017 BEGIN
3018
3019 x_status := 0;
3020 x_stage := 100;
3021
3022
3023 select org_structure_version_id,start_organization_id
3024 into x_org_struc_ver_id,x_start_org
3025 from pa_ind_rate_sch_revisions
3026 where ind_rate_sch_revision_id = p_sch_rev_id;
3027
3028
3029 EXCEPTION
3030 when NO_DATA_FOUND then
3031 x_status := NO_DATA_FOUND_ERR;
3032 when OTHERS then
3033 x_status := SQLCODE;
3034
3035 end get_hierarchy_from_revision;
3036
3037
3038
3039 --
3040 -- PROCEDURE
3041 -- find_rate_sch_rev_id
3042 --
3043 -- PURPOSE
3044 -- The objective of this procedure is to retrieve the rate schedule
3045 -- revision id assigned for a task. The sequence to find the
3046 -- rate schedule revision is
3047 -- (1) task level schedule override
3048 -- (2) project level schedule override
3049 -- (3) lowest level task schedule.
3050 --
3051 -- Note: This procedure gets called from both the project and expenditure
3052 -- oriented process. Hence should always refer to the base tables
3053 -- and not the Morg view.
3054 --
3055 --
3056 -- HISTORY
3057 --
3058 -- 10-JUN-94 S Lee Created
3059 --
3060
3061 procedure find_rate_sch_rev_id(
3062 transaction_id IN Number,
3063 transaction_type IN Varchar2,
3064 t_id IN Number,
3065 schedule_type IN Varchar2,
3066 exp_item_date IN Date,
3067 sch_id IN OUT NOCOPY Number,
3068 rate_sch_rev_id IN OUT NOCOPY Number,
3069 sch_fixed_date IN OUT NOCOPY Date,
3070 status IN OUT NOCOPY Number,
3071 stage IN OUT NOCOPY Number)
3072 IS
3073
3074 -- Local variables
3075
3076 t_rate_sch_rev_id number;
3077 t_sch_fixed_date date;
3078
3079 BEGIN
3080
3081 --
3082 -- Find the rate schedule according to the sequence
3083 -- (1) task level schedule override
3084 -- (2) project level schedule override
3085 -- (3) lowest level task schedule
3086 --
3087
3088 status := 0;
3089 stage := 100;
3090 sch_id := NULL;
3091 rate_sch_rev_id := NULL;
3092 sch_fixed_date := NULL;
3093 t_rate_sch_rev_id := NULL;
3094 t_sch_fixed_date := NULL;
3095
3096 --
3097 -- Find the override rate schedule at task level
3098 --
3099
3100 BEGIN
3101
3102 if (schedule_type = 'C') then
3103
3104 SELECT irs.ind_rate_sch_id,
3105 t.cost_ind_sch_fixed_date
3106 INTO sch_id,
3107 sch_fixed_date
3108 FROM pa_tasks t,
3109 pa_ind_rate_schedules irs
3110 WHERE t.task_id = t_id
3111 AND t.task_id = irs.task_id
3112 AND irs.cost_ovr_sch_flag = 'Y';
3113
3114 elsif (schedule_type = 'R') then
3115
3116 SELECT irs.ind_rate_sch_id,
3117 t.rev_ind_sch_fixed_date
3118 INTO sch_id,
3119 sch_fixed_date
3120 FROM pa_tasks t,
3121 pa_ind_rate_schedules irs
3122 WHERE t.task_id = t_id
3123 AND t.task_id = irs.task_id
3124 AND irs.rev_ovr_sch_flag = 'Y';
3125
3126 else
3127
3128 SELECT irs.ind_rate_sch_id,
3129 t.inv_ind_sch_fixed_date
3130 INTO sch_id,
3131 sch_fixed_date
3132 FROM pa_tasks t,
3133 pa_ind_rate_schedules irs
3134 WHERE t.task_id = t_id
3135 AND t.task_id = irs.task_id
3136 AND irs.inv_ovr_sch_flag = 'Y';
3137
3138 end if;
3139
3140 EXCEPTION
3141
3142 when NO_DATA_FOUND then
3143 sch_id := NULL;
3144 sch_fixed_date := NULL;
3145
3146 when OTHERS then
3147 status := SQLCODE;
3148 return;
3149 END;
3150
3151 --
3152 -- Get revision id if schedule is not null
3153 --
3154
3155 IF (sch_id IS NOT NULL) THEN
3156 pa_cost_plus.get_revision_by_date(sch_id,
3157 sch_fixed_date,
3158 exp_item_date,
3159 rate_sch_rev_id,
3160 status,
3161 stage);
3162 END IF;
3163
3164 --
3165 -- Calling client extension to override rate_sch_rev_id
3166 --
3167 PA_CLIENT_EXTN_BURDEN.Override_Rate_Rev_Id(
3168 'ACTUAL',
3169 transaction_id, -- Transaction Item Id
3170 transaction_type, -- Transaction Type
3171 t_id, -- Task Id
3172 schedule_type, -- Schedule Type
3173 exp_item_date, -- EI Date
3174 t_sch_fixed_date, -- Sch_fixed_date (Out)
3175 t_rate_sch_rev_id, -- Rate_sch_rev_id (Out)
3176 status); -- Status (Out)
3177
3178 /* Begin bug 5169080 */
3179 If (nvl(status , 0) <> 0) Then
3180 Return;
3181 End If;
3182 /* End bug 5169080 */
3183
3184 IF (t_rate_sch_rev_id IS NOT NULL) THEN
3185 rate_sch_rev_id := t_rate_sch_rev_id;
3186 IF (t_sch_fixed_date IS NOT NULL) THEN
3187 sch_fixed_date := t_sch_fixed_date;
3188 END IF;
3189 END IF;
3190
3191 /* Start : GMS code hook to override rate_sch_rev_id.
3192 ** 2981752 - PA.L:BURDENING ENHANCEMENTS : TRACKING BUG
3193 */
3194
3195 IF ( NVL(g_gms_enabled,'N') = 'Y' ) THEN
3196
3197 IF (t_rate_sch_rev_id is NULL ) THEN
3198
3199 t_sch_fixed_date := sch_fixed_date ;
3200
3201 GMS_PA_API3.Override_Rate_Rev_Id( transaction_id, -- Transaction Item Id
3202 transaction_type, -- Transaction Type
3203 t_id, -- Task Id
3204 schedule_type, -- Schedule Type
3205 exp_item_date, -- EI Date
3206 t_sch_fixed_date, -- Sch_fixed_date ( IN Out)
3207 t_rate_sch_rev_id, -- Rate_sch_rev_id (Out)
3208 status); -- Status (Out)
3209
3210 /* Start : The status controls to override rate_sch_rev_id
3211 ** Or not. The possible values are :
3212 ** 0 : Override ( award specific and sponsored project. )
3213 ** 1 : Don't override ( Non sponsored project continue with Default PA logic. )
3214 */
3215
3216 IF ( status = 0 ) THEN
3217
3218 rate_sch_rev_id := t_rate_sch_rev_id;
3219 sch_fixed_date := t_sch_fixed_date ;
3220 return ;
3221
3222 END IF ; -- ( status = 0 )
3223
3224 END IF ; -- (t_rate_sch_rev_id is NULL )
3225
3226 END IF ; -- ( NVL(g_gms_enabled,'N') = 'Y' )
3227
3228 /* End : End of GMS code hook to override rate_sch_rev_id .
3229 ** 2981752 - PA.L:BURDENING ENHANCEMENTS : TRACKING BUG
3230 */
3231
3232
3233 IF (rate_sch_rev_id IS NOT NULL) THEN
3234 return;
3235
3236 ELSE
3237 --
3238 -- There is no override rate schedule id found at the task level
3239 -- Find the override rate schedule at project level
3240 --
3241 stage := 200;
3242 status := 0;
3243 sch_id := NULL;
3244 sch_fixed_date := NULL;
3245
3246 BEGIN
3247 if (schedule_type = 'C') then
3248
3249 SELECT irs.ind_rate_sch_id,
3250 p.cost_ind_sch_fixed_date
3251 INTO sch_id,
3252 sch_fixed_date
3253 FROM pa_tasks t,
3254 pa_projects_all p,
3255 pa_ind_rate_schedules irs
3256 WHERE t.task_id = t_id
3257 AND t.project_id = p.project_id
3258 AND t.project_id = irs.project_id
3259 AND irs.cost_ovr_sch_flag = 'Y'
3260 AND irs.task_id is null;
3261
3262 elsif (schedule_type = 'R') then
3263
3264 SELECT irs.ind_rate_sch_id,
3265 p.rev_ind_sch_fixed_date
3266 INTO sch_id,
3267 sch_fixed_date
3268 FROM pa_tasks t,
3269 pa_projects_all p,
3270 pa_ind_rate_schedules irs
3271 WHERE t.task_id = t_id
3272 AND t.project_id = p.project_id
3273 AND t.project_id = irs.project_id
3274 AND irs.rev_ovr_sch_flag = 'Y'
3275 AND irs.task_id is null;
3276
3277 else
3278
3279 SELECT irs.ind_rate_sch_id,
3280 p.inv_ind_sch_fixed_date
3281 INTO sch_id,
3282 sch_fixed_date
3283 FROM pa_tasks t,
3284 pa_projects_all p,
3285 pa_ind_rate_schedules irs
3286 WHERE t.task_id = t_id
3287 AND t.project_id = p.project_id
3288 AND t.project_id = irs.project_id
3289 AND irs.inv_ovr_sch_flag = 'Y'
3290 AND irs.task_id is null;
3291
3292 end if;
3293
3294 EXCEPTION
3295
3296 when NO_DATA_FOUND then
3297 sch_id := NULL;
3298 sch_fixed_date := NULL;
3299
3300 when OTHERS then
3301 status := SQLCODE;
3302 return;
3303 END;
3304
3305 --
3306 -- Get the project override schedule id and fixed date
3307 --
3308
3309 END IF;
3310
3311
3312 if (sch_id IS NOT NULL) then
3313 pa_cost_plus.get_revision_by_date(sch_id,
3314 sch_fixed_date,
3315 exp_item_date,
3316 rate_sch_rev_id,
3317 status,
3318 stage);
3319 end if;
3320
3321
3322 IF (rate_sch_rev_id IS NOT NULL) then
3323 return;
3324
3325 ELSE
3326 --
3327 -- Override rate schedule does not exist at task or project level
3328 --
3329 stage := 300;
3330 status := 0;
3331 sch_id := NULL;
3332 sch_fixed_date := NULL;
3333
3334 IF (schedule_type = 'C') THEN
3335
3336 SELECT cost_ind_rate_sch_id,
3337 cost_ind_sch_fixed_date
3338 INTO sch_id,
3339 sch_fixed_date
3340 FROM pa_tasks
3341 WHERE task_id = t_id;
3342
3343 ELSIF (schedule_type = 'R') THEN
3344
3345 SELECT rev_ind_rate_sch_id,
3346 rev_ind_sch_fixed_date
3347 INTO sch_id,
3348 sch_fixed_date
3349 FROM pa_tasks
3350 WHERE task_id = t_id;
3351
3352 ELSE
3353
3354 SELECT inv_ind_rate_sch_id,
3355 inv_ind_sch_fixed_date
3356 INTO sch_id,
3357 sch_fixed_date
3358 FROM pa_tasks
3359 WHERE task_id = t_id;
3360
3361 END IF;
3362
3363 END IF;
3364
3365 if (sch_id IS NOT NULL) then
3366 pa_cost_plus.get_revision_by_date(sch_id,
3367 sch_fixed_date,
3368 exp_item_date,
3369 rate_sch_rev_id,
3370 status,
3371 stage);
3372 else
3373 status := 100;
3374 END IF;
3375
3376
3377 EXCEPTION
3378 when NO_DATA_FOUND then
3379 status := NO_DATA_FOUND_ERR;
3380 when OTHERS then
3381 status := SQLCODE;
3382
3383 END find_rate_sch_rev_id;
3384
3385
3386 --
3387 -- PROCEDURE
3388 -- get_rate_sch_rev_id
3389 --
3390 -- PURPOSE
3391 -- The objective of this procedure is to retrieve revision ID for a
3392 -- particular type of indirect rate schedule. A rate schedule may
3393 -- have many revisions divided by periods. This procedure uses
3394 -- an effective date locate the correct revision.
3395 --
3396 -- Note: This procedure gets called from both the project and expenditure
3397 -- oriented process. Hence should always refer to the base tables
3398 -- and not the Morg view.
3399 --
3400 -- HISTORY
3401 --
3402 -- 09-JUN-94 S Lee Created
3403 --
3404
3405 procedure get_rate_sch_rev_id(exp_item_id IN Number,
3406 schedule_type IN Varchar2,
3407 rate_sch_rev_id IN OUT NOCOPY Number,
3408 status IN OUT NOCOPY Number,
3409 stage IN OUT NOCOPY Number)
3410 IS
3411
3412 -- Local variables
3413
3414 t_id NUMBER(15);
3415 exp_item_date DATE;
3416 sch_id NUMBER(15);
3417 sch_fixed_date DATE;
3418 effective_date DATE;
3419
3420 BEGIN
3421
3422
3423 status := 0;
3424
3425 --
3426 -- Get the task id and expenditure item date
3427 -- As this procedure can be called from project Oriented or Expenditure
3428 -- oriented process, hence the uderlying select uses base table.
3429 --
3430
3431 SELECT task_id,
3432 expenditure_item_date
3433 INTO t_id,
3434 exp_item_date
3435 FROM pa_expenditure_items_all
3436 WHERE expenditure_item_id = exp_item_id;
3437
3438 --
3439 -- Get the indirect rate schedule
3440 --
3441
3442 pa_cost_plus.find_rate_sch_rev_id(
3443 exp_item_id,
3444 'PA',
3445 t_id,
3446 schedule_type,
3447 exp_item_date,
3448 sch_id,
3449 rate_sch_rev_id,
3450 sch_fixed_date,
3451 status,
3452 stage);
3453
3454 IF (status <> 0) THEN
3455 stage := 100;
3456 return;
3457 END IF;
3458
3459
3460 EXCEPTION
3461 when NO_DATA_FOUND then
3462 status := NO_DATA_FOUND_ERR;
3463 when OTHERS then
3464 status := SQLCODE;
3465
3466 END get_rate_sch_rev_id;
3467
3468
3469
3470 --
3471 -- PROCEDURE
3472 -- get_cost_base
3473 --
3474 -- PURPOSE
3475 -- The objective of this procedure is to retrieve the current
3476 -- cost base information for a particular expenditure item.
3477 -- We may get the indirect cost rates through cost base.
3478 --
3479 -- HISTORY
3480 --
3481 -- 08-JUN-94 S Lee Changed the input parameter
3482 -- 18-APR-94 S Lee Added error handler
3483 -- 29-MAR-94 S Lee Modified for the new database schema and
3484 -- application standard
3485 -- 20-NOV-93 S Lee Created
3486 --
3487
3488 procedure get_cost_base (exp_type IN varchar2,
3489 cp_structure IN varchar2,
3490 c_base IN OUT NOCOPY varchar2,
3491 status IN OUT NOCOPY number,
3492 stage IN OUT NOCOPY number)
3493 IS
3494
3495 BEGIN
3496
3497 status := 0;
3498 stage := 100;
3499
3500 SELECT
3501 cbet.cost_base
3502 INTO c_base
3503 FROM
3504 pa_cost_base_exp_types cbet
3505 WHERE
3506 cbet.cost_plus_structure = cp_structure
3507 AND cbet.expenditure_type = exp_type
3508 AND cbet.cost_base_type = INDIRECT_COST_CODE;
3509
3510 EXCEPTION
3511
3512 WHEN NO_DATA_FOUND THEN
3513 status := NO_DATA_FOUND_ERR;
3514 WHEN OTHERS THEN
3515 status := SQLCODE;
3516
3517 END get_cost_base;
3518
3519
3520 --
3521 -- PROCEDURE
3522 -- get_cost_plus_structure
3523 --
3524 -- PURPOSE
3525 -- The objective of this procedure is to retrieve the cost plus
3526 -- structure used by a rate schedule revision.
3527 --
3528 -- HISTORY
3529 --
3530 -- 08-JUN-94 S Lee Created
3531 --
3532
3533 procedure get_cost_plus_structure (rate_sch_rev_id IN Number,
3534 cp_structure IN OUT NOCOPY varchar2,
3535 status IN OUT NOCOPY number,
3536 stage IN OUT NOCOPY number)
3537 IS
3538
3539 BEGIN
3540
3541 status := 0;
3542 stage := 100;
3543
3544 SELECT
3545 cost_plus_structure
3546 INTO cp_structure
3547 FROM
3548 pa_ind_rate_sch_revisions
3549 WHERE
3550 ind_rate_sch_revision_id = rate_sch_rev_id;
3551
3552 EXCEPTION
3553
3554 WHEN NO_DATA_FOUND THEN
3555 status := NO_DATA_FOUND_ERR;
3556 WHEN OTHERS THEN
3557 status := SQLCODE;
3558
3559 END get_cost_plus_structure;
3560
3561
3562
3563 -- PROCEDURE
3564 -- get_organization_id
3565 --
3566 -- PURPOSE
3567 -- The objective of this procedure is to retrieve the ID of the
3568 -- organization which the expenditure item is charged against.
3569 --
3570 -- Note: This procedure gets called from both the project and expenditure
3571 -- oriented process. Hence should always refer to the base tables
3572 -- and not the Morg view.
3573 --
3574 -- HISTORY
3575 --
3576 -- 08-JUN-94 S Lee Created
3577 --
3578
3579 procedure get_organization_id (exp_item_id IN number,
3580 organization_id IN OUT NOCOPY number,
3581 status IN OUT NOCOPY number,
3582 stage IN OUT NOCOPY number)
3583 IS
3584
3585 BEGIN
3586
3587 status := 0;
3588 stage := 100;
3589
3590 -- As this procedure can be called from project Oriented or Expenditure
3591 -- oriented process, hence the uderlying select uses base table.
3592
3593 SELECT override_to_organization_id
3594 INTO organization_id
3595 FROM pa_expenditure_items_all
3596 WHERE expenditure_item_id = exp_item_id;
3597
3598 IF organization_id IS NULL THEN
3599 --
3600 -- the organization is at expenditures level
3601 --
3602 stage := 200;
3603
3604 SELECT incurred_by_organization_id
3605 INTO organization_id
3606 FROM pa_expenditures_all exp,
3607 pa_expenditure_items_all exp_item
3608 WHERE exp_item.expenditure_item_id = exp_item_id
3609 AND exp_item.expenditure_id = exp.expenditure_id
3610 AND ( (exp_item.org_id is null) or (exp_item.org_id = exp.org_id));
3611
3612 END IF;
3613
3614 EXCEPTION
3615
3616 WHEN NO_DATA_FOUND THEN
3617 status := NO_DATA_FOUND_ERR;
3618 WHEN OTHERS THEN
3619 status := SQLCODE;
3620
3621 END get_organization_id;
3622
3623
3624
3625 -- PROCEDURE
3626 -- get_compiled_set_id
3627 --
3628 -- PURPOSE
3629 -- The objective of this procedure is to retrieve the ID of the
3630 -- compiled set id by rate schedule revision id and organization
3631 -- id.
3632 --
3633 -- HISTORY
3634 --
3635 -- 05-JAN-94 S Lee Created
3636 --
3637
3638 procedure get_compiled_set_id(rate_sch_rev_id IN Number,
3639 org_id IN Number,
3640 c_base IN Varchar2, /*2933915*/
3641 compiled_set_id IN OUT NOCOPY Number,
3642 status IN OUT NOCOPY Number,
3643 stage IN OUT NOCOPY Number)
3644
3645 IS
3646
3647 BEGIN
3648
3649 status := 0;
3650 stage := 100;
3651
3652 SELECT ics.ind_compiled_set_id
3653 INTO compiled_set_id
3654 FROM pa_ind_compiled_sets ics
3655 WHERE ics.ind_rate_sch_revision_id = rate_sch_rev_id
3656 AND ics.organization_id = org_id
3657 AND cost_base =c_base /*2933915*/
3658 AND ics.status = 'A';
3659
3660 EXCEPTION
3661
3662 WHEN NO_DATA_FOUND THEN
3663 status := NO_DATA_FOUND_ERR;
3664 WHEN OTHERS THEN
3665 status := SQLCODE;
3666
3667 END get_compiled_set_id;
3668
3669
3670
3671 -- PROCEDURE
3672 -- get_revision_by_date
3673 --
3674 -- PURPOSE
3675 -- The objective of this procedure is to retrieve the ID of the
3676 -- rate schedule revision according to the provided date
3677 --
3678 -- HISTORY
3679 --
3680 -- 05-JAN-94 S Lee Created
3681 --
3682
3683 procedure get_revision_by_date(sch_id IN Number,
3684 sch_fixed_date IN Date,
3685 exp_item_date IN Date,
3686 rate_sch_rev_id IN OUT NOCOPY Number,
3687 status IN OUT NOCOPY Number,
3688 stage IN OUT NOCOPY Number)
3689
3690
3691 IS
3692
3693 x_ind_rate_schedule_type VARCHAR2(1);
3694 base_date DATE;
3695
3696 BEGIN
3697
3698 status := 0;
3699 rate_sch_rev_id := NULL;
3700
3701 --
3702 -- Retrieve the type of the schedule
3703 --
3704
3705 /* Bug 3786374 : Introduced Caching Logic for ind_rate_schedule_type */
3706
3707 If g_sch_id = sch_id Then
3708
3709 x_ind_rate_schedule_type := g_ind_rate_schedule_type ;
3710
3711 Else
3712
3713 SELECT ind_rate_schedule_type
3714 INTO x_ind_rate_schedule_type
3715 FROM pa_ind_rate_schedules
3716 WHERE ind_rate_sch_id = sch_id;
3717
3718 g_ind_rate_schedule_type := x_ind_rate_schedule_type;
3719 g_sch_id := sch_id;
3720
3721 End If;
3722
3723
3724 IF (x_ind_rate_schedule_type = 'F') THEN
3725 --
3726 -- Firm rate schedule type. Use expenditure item date except if
3727 -- schedule fixed date is defined.
3728
3729 IF (sch_fixed_date IS NOT NULL) THEN
3730 base_date := sch_fixed_date;
3731 ELSE
3732 base_date := exp_item_date;
3733 END IF;
3734
3735 ELSE
3736
3737 --
3738 -- Find out the effective gl period
3739 --
3740 /* Commented out for Bug 1277815 as this check is done in PAXCOIRS.fmb
3741 SELECT PERIOD.end_date
3742 INTO base_date
3743 FROM GL_Period_Statuses PERIOD,
3744 PA_Implementations IMP
3745 WHERE PERIOD.Application_ID = 101
3746 AND PERIOD.Set_Of_Books_ID = IMP.Set_Of_Books_ID
3747 AND PERIOD.ADJUSTMENT_PERIOD_FLAG = 'N'
3748 AND TRUNC(exp_item_date) BETWEEN
3749 TRUNC(PERIOD.start_date) and TRUNC(PERIOD.end_date);*/
3750
3751 base_date := exp_item_date; /* Added for bug 1277815*/
3752
3753 END IF;
3754
3755 BEGIN
3756
3757 --
3758 -- Get the actual revision if there is one
3759 --
3760 SELECT irsr.ind_rate_sch_revision_id
3761 INTO rate_sch_rev_id
3762 FROM pa_ind_rate_sch_revisions irsr
3763 WHERE irsr.ind_rate_sch_id = sch_id
3764 AND TRUNC(base_date) BETWEEN
3765 TRUNC(irsr.start_date_active) AND
3766 TRUNC(NVL(irsr.end_date_active, base_date))
3767 AND irsr.ind_rate_sch_revision_type = 'A';
3768
3769 EXCEPTION
3770 when NO_DATA_FOUND then
3771 --
3772 -- Actual revision is not available
3773 --
3774 SELECT irsr.ind_rate_sch_revision_id
3775 INTO rate_sch_rev_id
3776 FROM pa_ind_rate_sch_revisions irsr
3777 WHERE irsr.ind_rate_sch_id = sch_id
3778 AND TRUNC(base_date) BETWEEN
3779 TRUNC(irsr.start_date_active) AND
3780 TRUNC(NVL(irsr.end_date_active, base_date));
3781 END;
3782
3783 EXCEPTION
3784
3785 WHEN NO_DATA_FOUND THEN
3786 status := NO_DATA_FOUND_ERR;
3787 WHEN OTHERS THEN
3788 status := SQLCODE;
3789
3790 END get_revision_by_date;
3791
3792
3793
3794 --
3795 -- PROCEDURE
3796 -- check_revision_used
3797 --
3798 -- PURPOSE
3799 -- The objective of this procedure is to check whether the
3800 -- rate schedule revision has been used. 'Used' is defined as
3801 -- there are costed expenditure items with this rate schedule
3802 -- revision.
3803 --
3804 -- HISTORY
3805 --
3806 -- 06-JUL-94 S Lee Changed FK of expenditure item
3807 -- 07-MAY-94 S Lee Created
3808 --
3809
3810 procedure check_revision_used(rate_sch_rev_id IN number,
3811 status IN OUT NOCOPY number,
3812 stage IN OUT NOCOPY number)
3813 is
3814 dummy number;
3815 begin
3816
3817 status := 0;
3818
3819 /*
3820 * IC related change:
3821 * this procedure will return 0 in case of TP schedule
3822 * also.
3823 */
3824
3825 --S.O. /*Bug 4527736 */
3826 -- SELECT 1 INTO dummy FROM sys.dual WHERE NOT EXISTS
3827 -- (SELECT 1 FROM pa_ind_compiled_sets ICS, /* Removed Hint NO_INDEX(ITEM PA_EXPENDITURE_ITEMS_N13) */
3828 -- pa_expenditure_items_all ITEM
3829 -- WHERE
3830 -- ICS.ind_rate_sch_revision_id = rate_sch_rev_id
3831 -- AND ( (ICS.ind_compiled_set_id = ITEM.cost_ind_compiled_set_id)
3832 -- OR (ICS.ind_compiled_set_id = ITEM.rev_ind_compiled_set_id)
3833 -- OR (ICS.ind_compiled_set_id = ITEM.tp_ind_compiled_set_id)
3834 -- OR (ICS.ind_compiled_set_id = ITEM.inv_ind_compiled_set_id)));
3835 --E.O. /*Bug 4527736 */
3836 --S.N. /*Bug 4527736 */
3837 SELECT 1 INTO dummy FROM SYS.DUAL
3838 WHERE NOT EXISTS
3839 (SELECT 1
3840 FROM PA_IND_COMPILED_SETS ICS
3841 WHERE ICS.IND_RATE_SCH_REVISION_ID = rate_sch_rev_id
3842 AND EXISTS
3843 (SELECT /*+ no_unnest */ ITEM.COST_IND_COMPILED_SET_ID --Bug 12811820
3844 FROM PA_EXPENDITURE_ITEMS_ALL ITEM
3845 WHERE ICS.IND_COMPILED_SET_ID = ITEM.COST_IND_COMPILED_SET_ID
3846 UNION ALL
3847 SELECT ITEM.REV_IND_COMPILED_SET_ID
3848 FROM PA_EXPENDITURE_ITEMS_ALL ITEM
3849 WHERE ICS.IND_COMPILED_SET_ID = ITEM.REV_IND_COMPILED_SET_ID
3850 UNION ALL
3851 SELECT ITEM.TP_IND_COMPILED_SET_ID
3852 FROM PA_EXPENDITURE_ITEMS_ALL ITEM
3853 WHERE ICS.IND_COMPILED_SET_ID = ITEM.TP_IND_COMPILED_SET_ID
3854 UNION ALL
3855 SELECT ITEM.INV_IND_COMPILED_SET_ID
3856 FROM PA_EXPENDITURE_ITEMS_ALL ITEM
3857 WHERE ICS.IND_COMPILED_SET_ID = ITEM.INV_IND_COMPILED_SET_ID
3858 )
3859 );
3860 --E.N. /*Bug 4527736 */
3861
3862 exception
3863 when NO_DATA_FOUND then
3864 status := 100;
3865 when OTHERS then
3866 status := SQLCODE;
3867
3868 end check_revision_used;
3869
3870
3871 --
3872 -- PROCEDURE
3873 -- check_structure_used
3874 --
3875 -- PURPOSE
3876 -- The objective of this procedure is to check whether the
3877 -- cost plus structure has been used. 'Used' is defined as
3878 -- there are costed expenditure items in this cost plus structure.
3879 --
3880 -- HISTORY
3881 --
3882 -- 07-MAY-94 S Lee Created
3883 --
3884
3885 procedure check_structure_used(structure IN varchar2,
3886 status IN OUT NOCOPY number,
3887 stage IN OUT NOCOPY number)
3888 is
3889 -- cursor definition
3890
3891 CURSOR rev_cursor
3892 IS
3893 SELECT ind_rate_sch_revision_id
3894 FROM pa_ind_rate_sch_revisions
3895 WHERE cost_plus_structure = structure;
3896
3897 BEGIN
3898
3899 status := 0;
3900
3901 FOR rev_row IN rev_cursor LOOP
3902
3903 pa_cost_plus.check_revision_used(rev_row.ind_rate_sch_revision_id,
3904 status,
3905 stage);
3906
3907 if (status <> 0) then
3908 stage := 100;
3909 EXIT;
3910 end if;
3911
3912 END LOOP;
3913
3914 EXCEPTION
3915 WHEN OTHERS THEN
3916 stage := 100;
3917
3918 END check_structure_used;
3919
3920
3921 --
3922 -- PROCEDURE
3923 -- copy_structure
3924 --
3925 -- PURPOSE
3926 -- The objective of this procedure is to check whether the
3927 -- cost plus structure has been used. 'Used' is defined as
3928 -- there are costed expenditure items in this cost plus structure.
3929 --
3930 -- HISTORY
3931 --
3932 -- 07-MAY-94 S Lee Created
3933 --
3934
3935 procedure copy_structure(source IN varchar2,
3936 destination IN varchar2,
3937 status IN OUT NOCOPY number,
3938 stage IN OUT NOCOPY number)
3939 is
3940
3941 -- cursor definition
3942 CURSOR icc_cursor
3943 IS
3944 SELECT cost_base,
3945 cost_base_type,
3946 ind_cost_code,
3947 precedence
3948 FROM pa_cost_base_cost_codes
3949 WHERE cost_plus_structure = source;
3950
3951 CURSOR et_cursor
3952 IS
3953 SELECT cost_base,
3954 cost_base_type,
3955 expenditure_type
3956 FROM pa_cost_base_exp_types
3957 WHERE cost_plus_structure = source;
3958
3959 -- Local variables
3960 cbicc_id number;
3961 structure_type varchar2(30);
3962 icc_precedence number;
3963
3964 -- Standard who
3965 x_last_updated_by NUMBER(15);
3966 x_created_by NUMBER(15);
3967 x_last_update_login NUMBER(15);
3968
3969
3970 begin
3971
3972 stage := 100;
3973 status := 0;
3974
3975 --
3976 -- Standard who
3977 --
3978
3979 x_created_by := FND_GLOBAL.USER_ID;
3980 x_last_updated_by := FND_GLOBAL.USER_ID;
3981 x_last_update_login := FND_GLOBAL.LOGIN_ID;
3982
3983 SELECT cost_plus_structure_type
3984 INTO structure_type
3985 FROM pa_cost_plus_structures
3986 WHERE cost_plus_structure = destination;
3987
3988 if (structure_type = 'A') then
3989 icc_precedence := 1 ;
3990 else
3991 icc_precedence := NULL;
3992 end if;
3993
3994
3995 for icc_row in icc_cursor loop
3996 SELECT pa_cost_base_cost_codes_s.nextval into cbicc_id FROM sys.dual;
3997
3998 INSERT INTO pa_cost_base_cost_codes
3999 (cost_base_cost_code_id,
4000 cost_plus_structure,
4001 cost_base,
4002 cost_base_type,
4003 ind_cost_code,
4004 precedence,
4005 last_update_date,
4006 last_updated_by,
4007 creation_date,
4008 created_by,
4009 last_update_login
4010 )
4011 VALUES
4012 (cbicc_id,
4013 destination,
4014 icc_row.cost_base,
4015 icc_row.cost_base_type,
4016 icc_row.ind_cost_code,
4017 NVL(icc_precedence,icc_row.precedence),
4018 SYSDATE,
4019 x_last_updated_by,
4020 SYSDATE,
4021 x_created_by,
4022 x_last_update_login);
4023
4024 end loop;
4025
4026 stage := 200;
4027
4028 for et_row in et_cursor loop
4029
4030 INSERT INTO pa_cost_base_exp_types
4031 (cost_plus_structure,
4032 cost_base,
4033 cost_base_type,
4034 expenditure_type,
4035 last_update_date,
4036 last_updated_by,
4037 creation_date,
4038 created_by,
4039 last_update_login
4040 )
4041 VALUES
4042 (destination,
4043 et_row.cost_base,
4044 et_row.cost_base_type,
4045 et_row.expenditure_type,
4046 SYSDATE,
4047 x_last_updated_by,
4048 SYSDATE,
4049 x_created_by,
4050 x_last_update_login);
4051
4052 end loop;
4053
4054 COMMIT;
4055
4056 exception
4057 WHEN OTHERS THEN
4058 status := SQLCODE;
4059 end copy_structure;
4060
4061
4062 --
4063 -- PROCEDURE
4064 -- mark_impacted_exp_items
4065 --
4066 -- PURPOSE
4067 -- The objective of this procedure is to mark expenditure items for
4068 -- adjustments. For example, if the multipliers of a rate
4069 -- schedule are changed, then the expenditure items that were
4070 -- costed by the original schedule must be identified.
4071 --
4072 -- HISTORY
4073 --
4074 -- 30-JAN-95 S Lee Added adjustment activities
4075 -- 22-AUG-94 S Lee Revised due to suggestions in design review
4076 -- 19-AUG-94 S Lee Modified to handle adjustments
4077 -- 10-JUN-94 S Lee Created
4078 --
4079 /****PA L Enhancement :Modified this procedure to mark the eis selectively on the
4080 basis of impacted cost bases ****************************/
4081
4082 procedure mark_impacted_exp_items(rate_sch_rev_id IN number,
4083 status IN OUT NOCOPY number,
4084 stage IN OUT NOCOPY number)
4085
4086 is
4087 --
4088 -- Local variables
4089 --
4090 sch_id number;
4091 l_start_date date;
4092 l_end_date date;
4093 rev_type varchar2(1);
4094 rev_done number;
4095 l_gms_enabled VARCHAR2(2) :='N'; /*3059344*/
4096 l_cp_structure pa_ind_rate_sch_revisions.cost_plus_structure%TYPE ; /*3054111*/
4097
4098 l_this_fetch number:= 0;
4099 l_this_commit_cycle number:= 0;
4100 l_totally_fetched number:= 0;
4101 l_fetch_size number:= 1000;
4102 l_commit_size number:= 10000;
4103 adj_module constant varchar2(10) := 'PACOCRSR';
4104 err_buf varchar2(4000);--Bug 5726575
4105 ret_code varchar2(250);--Bug 5726575
4106 GMS_INSERT_ENC_ITEM_ERROR exception; --Bug 5726575
4107
4108 l_eiid_tbl pa_plsql_datatypes.IdTabTyp;
4109 l_csid_tbl pa_plsql_datatypes.IdTabTyp;
4110 l_rowid_tbl pa_plsql_datatypes.RowidTabTyp;
4111 l_rev_inv_flag_tbl pa_plsql_datatypes.Char1TabTyp;
4112
4113 /* Commented for the bug 4527736
4114 CURSOR mark_impacted_cost_bases --3054111
4115 IS
4116 SELECT
4117 DISTINCT cbicc.cost_base ,cbicc.cost_plus_structure
4118 FROM pa_cost_base_cost_codes cbicc,
4119 pa_ind_cost_multipliers icm
4120 WHERE icm.ind_rate_sch_revision_id = rate_sch_rev_id --3054111
4121 AND (nvl(icm.ready_to_compile_flag,'N') in ('Y','X') OR nvl(G_MODULE,'XXX') ='NEW_ORG')
4122 AND cbicc.cost_plus_structure = l_cp_structure --3054111
4123 AND cbicc.ind_cost_code = icm.ind_cost_code
4124 AND cbicc.cost_base_type = INDIRECT_COST_CODE ;
4125 */
4126
4127 /****2933915 :Modified this cursor
4128 CURSOR cs1_cursor
4129 IS
4130 SELECT DISTINCT ind_compiled_set_id
4131 FROM pa_ind_compiled_sets
4132 WHERE ind_rate_sch_revision_id = rate_sch_rev_id
4133 AND status = 'H';
4134 *************************************************/
4135
4136 CURSOR cs1_cursor(c_base VARCHAR2)
4137 IS
4138 SELECT DISTINCT ICS.ind_compiled_set_id
4139 FROM pa_ind_compiled_sets ICS
4140 WHERE ICS.ind_rate_sch_revision_id = rate_sch_rev_id
4141 AND ICS.cost_base = c_base
4142 AND ICS.status = 'H';
4143
4144 /*2933915 :No change reqd in cs2/cs3 as they should pick up all 'A' records for the earlier revisions irrespective
4145 of cost base */
4146
4147 CURSOR cs2_cursor
4148 IS
4149 SELECT /*+ ORDERED
4150 INDEX(irsr PA_IND_RATE_SCH_REVISIONS_N1) */
4151 DISTINCT ics.ind_compiled_set_id
4152 FROM pa_ind_rate_sch_revisions irsr,
4153 pa_ind_compiled_sets ics
4154 WHERE ics.status = 'A'
4155 AND ics.ind_rate_sch_revision_id = irsr.ind_rate_sch_revision_id
4156 AND irsr.ind_rate_sch_id = sch_id
4157 AND irsr.start_date_active < l_start_date
4158 AND irsr.ind_rate_sch_revision_type <> 'A';
4159
4160 CURSOR cs3_cursor
4161 IS
4162 SELECT /*+ ORDERED */
4163 DISTINCT ics.ind_compiled_set_id
4164 FROM pa_ind_rate_sch_revisions irsr,
4165 pa_ind_compiled_sets ics
4166 WHERE ics.status = 'A'
4167 AND ics.ind_rate_sch_revision_id = irsr.ind_rate_sch_revision_id
4168 AND irsr.actual_sch_revision_id = rate_sch_rev_id;
4169
4170
4171
4172 -- Standard who
4173 x_last_updated_by NUMBER(15);
4174 x_last_update_login NUMBER(15);
4175 x_request_id NUMBER(15);
4176 x_program_application_id NUMBER(15);
4177 x_program_id NUMBER(15);
4178 l_burden_profile VARCHAR2(2); /*2933915*/
4179 l_row_count NUMBER(15);
4180
4181 BEGIN
4182
4183 -- Initialize output parameters
4184 status := 0;
4185 l_row_count := 0;
4186
4187 gl_mc_currency_pkg.G_PA_UPGRADE_MODE := TRUE; /*Bug 4527736 */
4188
4189 --
4190 -- Get the standard who information
4191 --
4192 x_last_updated_by := FND_GLOBAL.USER_ID;
4193 x_last_update_login := FND_GLOBAL.LOGIN_ID;
4194 x_request_id := FND_GLOBAL.CONC_REQUEST_ID;
4195 x_program_application_id := FND_GLOBAL.PROG_APPL_ID;
4196 x_program_id := FND_GLOBAL.CONC_PROGRAM_ID;
4197
4198 -- l_burden_profile := nvl(fnd_profile.value('PA_ENHANCED_BURDENING'),'N'); /*2933915 */
4199 l_burden_profile := pa_utils2.IsEnhancedBurdeningEnabled;
4200
4201 IF gms_install.enabled THEN /*3059344 :To check if grants is installed */
4202 l_gms_enabled := 'Y' ;
4203 END IF ;
4204
4205 --
4206 -- Case 1: The indirect rate scheudle is modified.
4207 -- Mark expenditure items whose compiled_set_id is associated with
4208 -- the rate schedule revision.
4209 --
4210 BEGIN
4211 SELECT ind_rate_sch_id, start_date_active, end_date_active,
4212 ind_rate_sch_revision_type,cost_plus_structure
4213 INTO sch_id, l_start_date, l_end_date, rev_type,l_cp_structure
4214 FROM pa_ind_rate_sch_revisions irsr
4215 WHERE ind_rate_sch_revision_id = rate_sch_rev_id;
4216 EXCEPTION
4217 WHEN OTHERS THEN
4218 gl_mc_currency_pkg.G_PA_UPGRADE_MODE := FALSE; /*Bug 4456789 */
4219 RAISE;
4220 END;
4221
4222 BEGIN
4223
4224
4225 --FOR cost_base_rec in mark_impacted_cost_bases
4226 IF G_IMPACTED_COST_BASES_TAB.COUNT <> 0 THEN /*4590268*/
4227
4228 FOR i IN G_IMPACTED_COST_BASES_TAB.FIRST .. G_IMPACTED_COST_BASES_TAB.LAST
4229 LOOP
4230
4231 --FOR cs1_row IN cs1_cursor(cost_base_rec.cost_base)
4232 FOR cs1_row IN cs1_cursor(G_IMPACTED_COST_BASES_TAB(i))
4233 LOOP
4234
4235 /*======================================================================================+
4236 | This update handles the following cases. |
4237 | o [Cost/TP] Same and Separate line burdening transactions - when enhanced burdening |
4238 | profile option is not enabled. |
4239 | o [Cost/TP] Same line burdening transactions when enahanced burdening profile option |
4240 | is enabled. |
4241 | o [Revenue] Capital Projects with revenue based on burdened cost - for same line |
4242 | burdening transactions. |
4243 +======================================================================================*/
4244
4245 G_EXPENDITURE_ITEM_ID_TAB.DELETE; /*4456789*/
4246 G_ADJ_TYPE_TAB.DELETE; /*4456789*/
4247
4248 stage := 100;
4249 UPDATE pa_expenditure_items_all ITEM
4250 SET ITEM.cost_distributed_flag =
4251 DECODE(ITEM.cost_distributed_flag, 'Y',
4252 decode(ITEM.cost_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4253 'N',ITEM.cost_distributed_flag), ITEM.cost_distributed_flag),
4254 ITEM.revenue_distributed_flag =
4255 decode(ITEM.cost_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4256 decode(pa_utils2.get_capital_cost_type_code(ITEM.project_id),'B', 'N',ITEM.revenue_distributed_flag)
4257 ,ITEM.revenue_distributed_flag),
4258 ITEM.adjustment_type =
4259 DECODE(ITEM.cost_distributed_flag, 'Y',
4260 decode(ITEM.cost_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4261 'BURDEN_RECOMPILE',ITEM.adjustment_type),ITEM.adjustment_type),
4262 ITEM.cost_burden_distributed_flag =
4263 DECODE(ITEM.cost_distributed_flag, 'Y',
4264 decode(ITEM.cost_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4265 'N',ITEM.cost_burden_distributed_flag),ITEM.cost_burden_distributed_flag),
4266 ITEM.last_update_date = SYSDATE,
4267 ITEM.last_updated_by = x_last_updated_by,
4268 ITEM.last_update_login = x_last_update_login,
4269 ITEM.request_id = x_request_id,
4270 ITEM.program_application_id = x_program_application_id,
4271 ITEM.program_id = x_program_id,
4272 ITEM.program_update_date = SYSDATE,
4273 ITEM.project_burdened_cost =
4274 DECODE(ITEM.cost_distributed_flag, 'Y',
4275 decode(ITEM.cost_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4276 NULL, ITEM.project_burdened_cost), ITEM.project_burdened_cost),
4277 ITEM.denom_burdened_cost =
4278 DECODE(ITEM.cost_distributed_flag, 'Y',
4279 decode(ITEM.cost_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4280 NULL, ITEM.denom_burdened_cost), ITEM.denom_burdened_cost),
4281 ITEM.acct_burdened_cost =
4282 DECODE(ITEM.cost_distributed_flag, 'Y',
4283 decode(ITEM.cost_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4284 NULL, ITEM.acct_burdened_cost), ITEM.acct_burdened_cost),
4285 ITEM.burden_cost =
4286 DECODE(ITEM.cost_distributed_flag, 'Y',
4287 decode(ITEM.cost_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4288 NULL, ITEM.burden_cost), ITEM.burden_cost),
4289 ITEM.cc_bl_distributed_code =
4290 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4291 decode(ITEM.cc_cross_charge_code,'B',
4292 'N',
4293 ITEM.cc_bl_distributed_code),
4294 ITEM.cc_bl_distributed_code),
4295 ITEM.cc_ic_processed_code =
4296 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4297 decode(ITEM.cc_cross_charge_code,'I',
4298 'N',
4299 ITEM.cc_ic_processed_code),
4300 ITEM.cc_ic_processed_code),
4301 ITEM.Denom_Tp_Currency_Code =
4302 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4303 NULL, ITEM.denom_tp_currency_code),
4304 ITEM.Denom_Transfer_Price =
4305 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4306 NULL, ITEM.denom_transfer_price),
4307 ITEM.Acct_Tp_Rate_Type =
4308 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4309 NULL, ITEM.acct_tp_rate_type),
4310 ITEM.Acct_Tp_Rate_Date =
4311 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4312 NULL, ITEM.acct_tp_rate_date),
4313 ITEM.Acct_Tp_Exchange_Rate =
4314 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4315 NULL, ITEM.acct_tp_exchange_rate),
4316 ITEM.Acct_Transfer_Price =
4317 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4318 NULL, ITEM.acct_transfer_price),
4319 ITEM.Projacct_Transfer_Price =
4320 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4321 NULL, ITEM.projacct_transfer_price),
4322 ITEM.Cc_Markup_Base_Code =
4323 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4324 NULL, ITEM.cc_markup_base_code),
4325 ITEM.Tp_Base_Amount =
4326 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4327 NULL, ITEM.tp_base_amount),
4328 ITEM.Tp_Bill_Rate =
4329 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4330 NULL, ITEM.tp_bill_rate),
4331 ITEM.Tp_Bill_Markup_Percentage =
4332 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4333 NULL, ITEM.tp_bill_markup_percentage),
4334 ITEM.Tp_Schedule_line_Percentage =
4335 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4336 NULL, ITEM.tp_schedule_line_percentage),
4337 ITEM.Tp_Rule_percentage =
4338 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4339 NULL, ITEM.tp_rule_percentage)
4340 WHERE ((ITEM.cost_ind_compiled_set_id = cs1_row.ind_compiled_set_id AND ITEM.cost_distributed_flag = 'Y')
4341 OR ITEM.tp_ind_compiled_set_id = cs1_row.ind_compiled_set_id)
4342 AND NVL(ITEM.net_zero_adjustment_flag,'N') <> 'Y'
4343 AND pa_project_stus_utils.Is_Project_Closed(ITEM.project_id) <>'Y'
4344 AND decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ITEM.expenditure_item_id,ITEM.task_id),'N') = 'N'
4345 AND exists (select /*+ PUSH_SUBQ NO_UNNEST */ null
4346 from pa_cost_base_exp_types cbet
4347 --where cbet.cost_base = cost_base_rec.cost_base
4348 where cbet.cost_base = G_IMPACTED_COST_BASES_TAB(i)
4349 AND cbet.cost_plus_structure = G_CP_STRUCTURE
4350 AND cbet.cost_base_type = INDIRECT_COST_CODE
4351 AND cbet.expenditure_type = ITEM.expenditure_type
4352 )
4353 /*3055700 :Added this exist clause for bug# 3016281 :to mark selectively if explicit multipliers
4354 are defined for an org for all the cost codes */
4355 /* 4527736
4356 AND exists (SELECT NULL
4357 FROM pa_expenditures_all exp
4358 ,pa_ind_compiled_sets ics
4359 WHERE exp.expenditure_id = ITEM.expenditure_id
4360 AND ((ics.ind_compiled_set_id = ITEM.cost_ind_compiled_set_id)
4361 or (ics.ind_compiled_set_id = ITEM.tp_ind_compiled_set_id))
4362 AND nvl(ITEM.override_to_organization_id,exp.incurred_by_organization_id) =ics.organization_id
4363 AND ics.status = 'H'
4364 * AND pa_cost_plus.check_for_explicit_multiplier(rate_sch_rev_id,ics.organization_id ) =0 -- Bug# 3134445
4365 AND decode(rate_sch_rev_id,g_rate_sch_rev_id,decode(ics.organization_id,g_org_id,g_org_override,pa_cost_plus.check_for_explicit_multiplier(rate_sch_rev_id,ics.organization_id))
4366 ,pa_cost_plus.check_for_explicit_multiplier(rate_sch_rev_id,ics.organization_id ))=0 -- Bug# 3134445 and Bug 3938479
4367 ) */
4368 AND EXISTS ((SELECT /*+ PUSH_SUBQ NO_UNNEST */ 1
4369 FROM PA_EXPENDITURES_ALL EXP
4370 ,PA_IND_COMPILED_SETS ICS
4371 WHERE EXP.EXPENDITURE_ID = ITEM.EXPENDITURE_ID
4372 AND (ICS.IND_COMPILED_SET_ID = ITEM.COST_IND_COMPILED_SET_ID)
4373 AND NVL(ITEM.OVERRIDE_TO_ORGANIZATION_ID, EXP.INCURRED_BY_ORGANIZATION_ID) =ICS.ORGANIZATION_ID
4374 AND ICS.IND_RATE_SCH_REVISION_ID = rate_sch_rev_id /* Added for Bug 5683523 */
4375 AND ICS.STATUS = 'H'
4376 AND DECODE(rate_sch_rev_id ,g_rate_sch_rev_id ,DECODE(ICS.ORGANIZATION_ID,g_org_id ,g_org_override
4377 , PA_COST_PLUS.CHECK_FOR_EXPLICIT_MULTIPLIER(rate_sch_rev_id ,ICS.ORGANIZATION_ID))
4378 , PA_COST_PLUS.CHECK_FOR_EXPLICIT_MULTIPLIER(rate_sch_rev_id ,ICS.ORGANIZATION_ID ))=0
4379 )
4380 UNION ALL (SELECT /*+ PUSH_SUBQ NO_UNNEST */ 1
4381 FROM PA_EXPENDITURES_ALL EXP
4382 ,PA_IND_COMPILED_SETS ICS
4383 WHERE EXP.EXPENDITURE_ID = ITEM.EXPENDITURE_ID
4384 AND (ICS.IND_COMPILED_SET_ID = ITEM.TP_IND_COMPILED_SET_ID)
4385 AND NVL(ITEM.OVERRIDE_TO_ORGANIZATION_ID, EXP.INCURRED_BY_ORGANIZATION_ID) =ICS.ORGANIZATION_ID
4386 AND ICS.IND_RATE_SCH_REVISION_ID = rate_sch_rev_id /* Added for Bug 5683523 */
4387 AND ICS.STATUS = 'H'
4388 AND DECODE(rate_sch_rev_id ,g_rate_sch_rev_id ,DECODE(ICS.ORGANIZATION_ID,g_org_id ,g_org_override
4389 , PA_COST_PLUS.CHECK_FOR_EXPLICIT_MULTIPLIER(rate_sch_rev_id ,ICS.ORGANIZATION_ID))
4390 , PA_COST_PLUS.CHECK_FOR_EXPLICIT_MULTIPLIER(rate_sch_rev_id ,ICS.ORGANIZATION_ID ))=0
4391 )
4392 )
4393 AND ((pa_utils2.Proj_Type_Burden_Disp_Method(ITEM.project_id) IN ('S','s','D','d') AND l_burden_profile ='N')
4394 OR (pa_utils2.Proj_Type_Burden_Disp_Method(ITEM.project_id) IN ('S','s') AND l_burden_profile ='Y'))
4395 RETURNING expenditure_item_id, decode(cs1_row.ind_compiled_set_id,ITEM.tp_ind_compiled_set_id,'UPDATE TP SCHEDULE REVISION','UPDATE COST SCHEDULE REVISION')
4396 BULK COLLECT INTO G_EXPENDITURE_ITEM_ID_TAB,G_ADJ_TYPE_TAB;
4397
4398 stage := 290 ;
4399 pa_cost_plus.add_adjustment_activity(G_EXPENDITURE_ITEM_ID_TAB
4400 ,G_ADJ_TYPE_TAB
4401 ,status
4402 ,stage
4403 );
4404 IF (status <> 0) THEN
4405 return;
4406 END IF;
4407
4408 --Bug 5726575
4409 if l_gms_enabled = 'Y' then
4410 gms_pa_api3.mark_impacted_enc_items(errbuf => err_buf,
4411 retcode => ret_code,
4412 p_ind_compiled_set_id => cs1_row.ind_compiled_set_id,
4413 p_g_impacted_cost_bases => G_IMPACTED_COST_BASES_TAB(i),
4414 p_g_cp_structure => G_CP_STRUCTURE,
4415 p_indirect_cost_code => INDIRECT_COST_CODE,
4416 p_rate_sch_rev_id => rate_sch_rev_id,
4417 p_g_rate_sch_rev_id => g_rate_sch_rev_id,
4418 p_g_org_id => g_org_id,
4419 p_g_org_override => g_org_override);
4420 if err_buf is not null then
4421 raise GMS_INSERT_ENC_ITEM_ERROR;
4422 end if;
4423 end if;
4424
4425 /*======================================================================================+
4426 | This update handles the following cases. |
4427 | o [Cost/TP] Separate line burdening transactions when enahanced burdening profile |
4428 | option is enabled. |
4429 | o [Revenue] Capital Projects with revenue based on burdened cost - for separate line |
4430 | burdening transactions. |
4431 +======================================================================================*/
4432 IF l_burden_profile ='Y' THEN
4433
4434 /*===============================================================+
4435 | M - All pre-cost distributed transactions with separate line |
4436 | burdening are set for BURDEN_RESUMMARIZE - if |
4437 | Enhanced Burdening is SET. |
4438 | Cost Distributed Flag is left untouched. |
4439 | Earlier, supplier invoice transactions with budgetory |
4440 | control were being routed via the distribution process. |
4441 +===============================================================*/
4442 l_row_count :=0;
4443 stage := 200;
4444
4445 G_EXPENDITURE_ITEM_ID_TAB.DELETE; /*4527736*/
4446 G_ADJ_TYPE_TAB.DELETE; /*4527736*/
4447
4448 UPDATE pa_expenditure_items_all ITEM
4449 SET ITEM.last_update_date = SYSDATE,
4450 ITEM.last_updated_by = x_last_updated_by,
4451 ITEM.last_update_login = x_last_update_login,
4452 ITEM.request_id = x_request_id,
4453 ITEM.program_application_id = x_program_application_id,
4454 ITEM.program_id = x_program_id,
4455 ITEM.program_update_date = SYSDATE,
4456 /*************************
4457 ITEM.cost_distributed_flag = DECODE(ITEM.cost_ind_compiled_set_id, cs1_row.ind_compiled_set_id
4458 , DECODE(ITEM.cost_distributed_flag , 'Y'
4459
4460 , DECODE(ITEM.system_linkage_function, 'VI'
4461 , DECODE(Pa_Funds_Control_Utils.Get_Fnd_Reqd_Flag(ITEM.project_id, 'STD'), 'Y', 'N'
4462 ,ITEM.cost_distributed_flag)
4463 ,ITEM.cost_distributed_flag)
4464
4465 ,ITEM.cost_distributed_flag)
4466 ,ITEM.cost_distributed_flag),
4467 ******************/
4468 ITEM.revenue_distributed_flag =
4469 decode(ITEM.cost_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4470 decode(pa_utils2.get_capital_cost_type_code(ITEM.project_id),'B', 'N',ITEM.revenue_distributed_flag)
4471 ,ITEM.revenue_distributed_flag),
4472 ITEM.cc_bl_distributed_code =
4473 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4474 decode(ITEM.cc_cross_charge_code,'B',
4475 'N',
4476 ITEM.cc_bl_distributed_code),
4477 ITEM.cc_bl_distributed_code),
4478 ITEM.cc_ic_processed_code =
4479 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4480 decode(ITEM.cc_cross_charge_code,'I',
4481 'N',
4482 ITEM.cc_ic_processed_code),
4483 ITEM.cc_ic_processed_code),
4484 ITEM.Denom_Tp_Currency_Code =
4485 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4486 NULL, ITEM.denom_tp_currency_code),
4487 ITEM.Denom_Transfer_Price =
4488 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4489 NULL, ITEM.denom_transfer_price),
4490 ITEM.Acct_Tp_Rate_Type =
4491 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4492 NULL, ITEM.acct_tp_rate_type),
4493 ITEM.Acct_Tp_Rate_Date =
4494 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4495 NULL, ITEM.acct_tp_rate_date),
4496 ITEM.Acct_Tp_Exchange_Rate =
4497 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4498 NULL, ITEM.acct_tp_exchange_rate),
4499 ITEM.Acct_Transfer_Price =
4500 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4501 NULL, ITEM.acct_transfer_price),
4502 ITEM.Projacct_Transfer_Price =
4503 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4504 NULL, ITEM.projacct_transfer_price),
4505 ITEM.Cc_Markup_Base_Code =
4506 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4507 NULL, ITEM.cc_markup_base_code),
4508 ITEM.Tp_Base_Amount =
4509 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4510 NULL, ITEM.tp_base_amount),
4511 ITEM.Tp_Bill_Rate =
4512 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4513 NULL, ITEM.tp_bill_rate),
4514 ITEM.Tp_Bill_Markup_Percentage =
4515 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4516 NULL, ITEM.tp_bill_markup_percentage),
4517 ITEM.Tp_Schedule_line_Percentage =
4518 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4519 NULL, ITEM.tp_schedule_line_percentage),
4520 ITEM.Tp_Rule_percentage =
4521 decode(ITEM.tp_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4522 NULL, ITEM.tp_rule_percentage),
4523 ITEM.adjustment_type = DECODE(ITEM.cost_distributed_flag, 'Y', 'BURDEN_RESUMMARIZE', ITEM.adjustment_type)
4524 /********************
4525 ,ITEM.denom_burdened_cost =
4526 decode(ITEM.cost_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4527 decode(ITEM.cost_distributed_flag ,'Y'
4528 ,decode(ITEM.system_linkage_function, 'VI'
4529 ,decode(Pa_Funds_Control_Utils.Get_Fnd_Reqd_Flag(ITEM.project_id, 'STD'), 'Y', NULL,
4530 ITEM.denom_burdened_cost), ITEM.denom_burdened_cost), ITEM.denom_burdened_cost),
4531 ITEM.denom_burdened_cost)
4532 ,ITEM.acct_burdened_cost =
4533 decode(ITEM.cost_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4534 decode(ITEM.cost_distributed_flag ,'Y'
4535 ,decode(ITEM.system_linkage_function, 'VI'
4536 ,decode(Pa_Funds_Control_Utils.Get_Fnd_Reqd_Flag(ITEM.project_id, 'STD'), 'Y', NULL,
4537 ITEM.acct_burdened_cost), ITEM.acct_burdened_cost), ITEM.acct_burdened_cost),
4538 ITEM.acct_burdened_cost)
4539 ,ITEM.project_burdened_cost =
4540 decode(ITEM.cost_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4541 decode(ITEM.cost_distributed_flag ,'Y'
4542 ,decode(ITEM.system_linkage_function, 'VI'
4543 ,decode(Pa_Funds_Control_Utils.Get_Fnd_Reqd_Flag(ITEM.project_id, 'STD'), 'Y', NULL,
4544 ITEM.project_burdened_cost), ITEM.project_burdened_cost), ITEM.project_burdened_cost),
4545 ITEM.project_burdened_cost)
4546 ,ITEM.burden_cost =
4547 decode(ITEM.cost_ind_compiled_set_id, cs1_row.ind_compiled_set_id,
4548 decode(ITEM.cost_distributed_flag ,'Y'
4549 ,decode(ITEM.system_linkage_function, 'VI'
4550 ,decode(Pa_Funds_Control_Utils.Get_Fnd_Reqd_Flag(ITEM.project_id, 'STD'), 'Y', NULL,
4551 ITEM.burden_cost), ITEM.burden_cost), ITEM.burden_cost),
4552 ITEM.burden_cost)
4553 ***************************/
4554 WHERE (ITEM.tp_ind_compiled_set_id = cs1_row.ind_compiled_set_id OR
4555 ITEM.cost_ind_compiled_set_id = cs1_row.ind_compiled_set_id )
4556 AND pa_project_stus_utils.Is_Project_Closed(ITEM.project_id) <>'Y'
4557 AND decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ITEM.expenditure_item_id,ITEM.task_id),'N') = 'N'
4558 AND NVL(ITEM.net_zero_adjustment_flag,'N') <> 'Y'
4559 AND exists (select /*+ NO_UNNEST */ null
4560 from pa_cost_base_exp_types cbet
4561 -- where cbet.cost_base = cost_base_rec.cost_base -- 4527736
4562 where cbet.cost_base = G_IMPACTED_COST_BASES_TAB(i)
4563 AND cbet.cost_plus_structure = l_cp_structure
4564 AND cbet.cost_base_type = INDIRECT_COST_CODE
4565 AND cbet.expenditure_type = ITEM.expenditure_type
4566 )
4567 /*Bug# 3055700 ::Added this exist clause back for bug# 3016281*/
4568 AND exists (SELECT NULL
4569 FROM pa_expenditures_all exp
4570 ,pa_ind_compiled_sets ics
4571 WHERE exp.expenditure_id = ITEM.expenditure_id
4572 AND ((ics.ind_compiled_set_id = ITEM.cost_ind_compiled_set_id)
4573 or (ics.ind_compiled_set_id = ITEM.tp_ind_compiled_set_id))
4574 AND nvl(ITEM.override_to_organization_id,exp.incurred_by_organization_id) =ics.organization_id
4575 AND ics.status = 'H'
4576 /*AND pa_cost_plus.check_for_explicit_multiplier(rate_sch_rev_id,ics.organization_id ) =0 /*3134445*/
4577 AND decode(rate_sch_rev_id,g_rate_sch_rev_id,decode(ics.organization_id,g_org_id,g_org_override,pa_cost_plus.check_for_explicit_multiplier(rate_sch_rev_id,ics.organization_id))
4578 ,pa_cost_plus.check_for_explicit_multiplier(rate_sch_rev_id,ics.organization_id ))=0 /*Bug# 3134445 and Bug 3938479*/
4579 )
4580
4581 /*****************************************************************
4582 AND exists (select 1
4583 from pa_project_types_all pt,
4584 pa_projects_all pp
4585 where pp.project_id =ITEM.project_id
4586 AND pp.project_type =pt.project_type
4587 AND pt.burden_amt_display_method in ('D','d')
4588 AND nvl(pt.org_id,-99) =nvl(pp.org_id,-99) )
4589 *************************************************************/
4590 AND pa_utils2.Proj_Type_Burden_Disp_Method(ITEM.project_id) IN ('D','d')
4591 RETURNING expenditure_item_id, decode(cs1_row.ind_compiled_set_id,ITEM.tp_ind_compiled_set_id,'UPDATE TP SCHEDULE REVISION','UPDATE COST SCHEDULE REVISION')
4592 BULK COLLECT INTO G_EXPENDITURE_ITEM_ID_TAB,G_ADJ_TYPE_TAB;
4593
4594 stage := 300 ;
4595 /*
4596 pa_cost_plus.add_adjustment_activity(cs1_row.ind_compiled_set_id
4597 --,cost_base_rec.cost_base
4598 ,G_IMPACTED_COST_BASES_TAB(i)
4599 ,l_cp_structure
4600 ,'UPDATE COST SCHEDULE REVISION'
4601 ,NULL
4602 ,NULL
4603 ,'UPDATE TP SCHEDULE REVISION'
4604 ,status
4605 ,stage
4606 ,G_EXPENDITURE_ITEM_ID_TAB
4607 ,G_ADJ_TYPE_TAB);
4608 */
4609 pa_cost_plus.add_adjustment_activity(G_EXPENDITURE_ITEM_ID_TAB
4610 ,G_ADJ_TYPE_TAB
4611 ,status
4612 ,stage
4613 );
4614 IF (status <> 0) THEN
4615 return;
4616 END IF;
4617
4618 END IF; -- profile option
4619
4620 COMMIT;
4621
4622
4623 /*======================================================================================+
4624 | This update handles the following cases. |
4625 | o [Rev/Inv] Same and Separate line burdening transactions - irrespective of profile |
4626 | option. |
4627 +======================================================================================*/
4628
4629 stage := 400;
4630 l_row_count :=0;
4631
4632 G_EXPENDITURE_ITEM_ID_TAB.DELETE; /*4527736*/
4633 G_ADJ_TYPE_TAB.DELETE; /*4527736*/
4634
4635 UPDATE pa_expenditure_items_all ITEM
4636 SET ITEM.revenue_distributed_flag = 'N',
4637 ITEM.last_update_date = SYSDATE,
4638 ITEM.last_updated_by = x_last_updated_by,
4639 ITEM.last_update_login = x_last_update_login,
4640 ITEM.request_id = x_request_id,
4641 ITEM.program_application_id = x_program_application_id,
4642 ITEM.program_id = x_program_id,
4643 ITEM.program_update_date = SYSDATE
4644 WHERE (ITEM.rev_ind_compiled_set_id = cs1_row.ind_compiled_set_id
4645 OR ITEM.inv_ind_compiled_set_id = cs1_row.ind_compiled_set_id)
4646 AND pa_project_stus_utils.Is_Project_Closed(ITEM.project_id) <>'Y'
4647 AND decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ITEM.expenditure_item_id,ITEM.task_id),'N') = 'N'
4648 AND NVL(ITEM.net_zero_adjustment_flag,'N') <> 'Y' /* missing condition added for bug 4574721 */
4649 AND EXISTS (select /*+ NO_UNNEST */ 1
4650 from pa_cost_base_exp_types cbet
4651 --where cbet.cost_base = cost_base_rec.cost_base
4652 where cbet.cost_base = G_IMPACTED_COST_BASES_TAB(i)
4653 and cbet.cost_plus_structure = l_cp_structure
4654 and cbet.cost_base_type = INDIRECT_COST_CODE
4655 and cbet.expenditure_type = ITEM.expenditure_type
4656 )
4657 /*Bug# 3055700 : Added this exist clause back for bug# 3016281*/
4658 AND EXISTS (SELECT /*+ index(ics PA_IND_COMPILED_SETS_N6) */ NULL /*Added index hint for Bug 5683523 */
4659 FROM pa_expenditures_all exp
4660 ,pa_ind_compiled_sets ics
4661 WHERE exp.expenditure_id = ITEM.expenditure_id
4662 AND ((ics.ind_compiled_set_id = ITEM.rev_ind_compiled_set_id)
4663 or (ics.ind_compiled_set_id = ITEM.inv_ind_compiled_set_id))
4664 AND nvl(ITEM.override_to_organization_id,exp.incurred_by_organization_id) =ics.organization_id
4665 AND ics.ind_rate_sch_revision_id = rate_sch_rev_id /* Added for Bug 5683523 */
4666 AND ics.status = 'H'
4667 /*AND pa_cost_plus.check_for_explicit_multiplier(rate_sch_rev_id,ics.organization_id ) =0 /*Bug# 3134445*/
4668 AND decode(rate_sch_rev_id,g_rate_sch_rev_id,decode(ics.organization_id,g_org_id,g_org_override,pa_cost_plus.check_for_explicit_multiplier(rate_sch_rev_id,ics.organization_id))
4669 ,pa_cost_plus.check_for_explicit_multiplier(rate_sch_rev_id,ics.organization_id ))=0 /*Bug# 3134445 and Bug 3938479*/
4670 )
4671 RETURNING expenditure_item_id, decode(cs1_row.ind_compiled_set_id,ITEM.rev_ind_compiled_set_id,'UPDATE REV SCHEDULE REVISION','UPDATE INV SCHEDULE REVISION')
4672 BULK COLLECT INTO G_EXPENDITURE_ITEM_ID_TAB,G_ADJ_TYPE_TAB;
4673
4674 stage := 450 ;
4675 /* pa_cost_plus.add_adjustment_activity(cs1_row.ind_compiled_set_id
4676 --,cost_base_rec.cost_base
4677 ,G_IMPACTED_COST_BASES_TAB(i)
4678 ,l_cp_structure
4679 ,NULL
4680 ,'UPDATE REV SCHEDULE REVISION'
4681 ,'UPDATE INV SCHEDULE REVISION'
4682 ,NULL
4683 ,status
4684 ,stage
4685 ,G_EXPENDITURE_ITEM_ID_TAB
4686 ,G_ADJ_TYPE_TAB);
4687 */
4688
4689 pa_cost_plus.add_adjustment_activity(G_EXPENDITURE_ITEM_ID_TAB
4690 ,G_ADJ_TYPE_TAB
4691 ,status
4692 ,stage
4693 );
4694 IF (status <> 0) THEN
4695 return;
4696 END IF;
4697
4698 -- consider volume of expenditure items having the same compiled set id
4699 COMMIT;
4700
4701 end loop; -- cs1_cursor
4702 end loop; --G_IMPACTED_COST_BASES_TAB
4703 END IF; --G_IMPACTED_COST_BASES_TAB.COUNT <> 0 THEN /*4590268*/
4704
4705 EXCEPTION /*2933915*/
4706 when OTHERS then
4707 status := SQLCODE;
4708 gl_mc_currency_pkg.G_PA_UPGRADE_MODE := FALSE; /*Bug 4456789 */
4709 END;
4710
4711 --
4712 -- Case 2: Change the end date of an existing indirect rate schedule from
4713 -- NULL to a new date.
4714 -- The expenditure items that have the same rate schedule and their
4715 -- incurred date are in the date range of new rate schedule are
4716 -- marked for recosting.
4717 /****
4718 stage := 400;
4719
4720 *** merged with a pervious select
4721 SELECT ind_rate_sch_id, start_date_active, end_date_active,
4722 ind_rate_sch_revision_type
4723 INTO sch_id, l_start_date, l_end_date, rev_type
4724 FROM pa_ind_rate_sch_revisions irsr
4725 WHERE ind_rate_sch_revision_id = rate_sch_rev_id;
4726 ****/
4727
4728
4729 BEGIN
4730 FOR cs2_row IN cs2_cursor LOOP
4731
4732 stage := 500;
4733
4734 pa_cost_plus.mark_prev_rev_exp_items(cs2_row.ind_compiled_set_id,
4735 rev_type,
4736 'NEW REVISION',
4737 l_start_date,
4738 l_end_date,
4739 status,
4740 stage);
4741 if (status <> 0) then
4742 return;
4743 end if;
4744
4745 END LOOP;
4746
4747 EXCEPTION
4748 when NO_DATA_FOUND then
4749 return;
4750 when OTHERS then
4751 status := SQLCODE;
4752 gl_mc_currency_pkg.G_PA_UPGRADE_MODE := FALSE; /*Bug 4456789 */
4753 END;
4754
4755 --
4756 -- Case 3: Apply actual rates
4757 -- mark those expenditure items that use the same rate schedule and
4758 -- their incurred date are in the date range of actual rate schedule
4759
4760 BEGIN
4761 FOR cs3_row IN cs3_cursor LOOP
4762
4763 stage := 600;
4764
4765 pa_cost_plus.mark_prev_rev_exp_items(cs3_row.ind_compiled_set_id,
4766 rev_type,
4767 'APPLY ACTUAL',
4768 l_start_date,
4769 l_end_date,
4770 status,
4771 stage);
4772
4773 if (status <> 0) then
4774 return;
4775 end if;
4776
4777
4778 END LOOP;
4779
4780 EXCEPTION
4781 when NO_DATA_FOUND then
4782 return;
4783 when OTHERS then
4784 status := SQLCODE;
4785 gl_mc_currency_pkg.G_PA_UPGRADE_MODE := FALSE; /*Bug 4456789 */
4786 END;
4787
4788 COMMIT;
4789 gl_mc_currency_pkg.G_PA_UPGRADE_MODE := FALSE; /*Bug 4456789 */
4790
4791 EXCEPTION
4792 when GMS_INSERT_ENC_ITEM_ERROR then --Bug 5726575
4793 stage := 110;
4794 status := ret_code;
4795 WHEN OTHERS THEN
4796 status := SQLCODE;
4797 gl_mc_currency_pkg.G_PA_UPGRADE_MODE := FALSE; /*Bug 4456789 */
4798 END mark_impacted_exp_items;
4799
4800
4801 --
4802 -- PROCEDURE
4803 -- mark_prev_rev_exp_items
4804 --
4805 -- PURPOSE
4806 -- The objective of this procedure is to mark the impacted
4807 -- expenditure items of previous revisions. When the actual
4808 -- rate schedule revision is applied, or an end date is assigned
4809 -- to an open-end revision, then the expenditure items need
4810 -- to be marked for recosting.
4811 --
4812 -- HISTORY
4813 --
4814 -- 23-AUG-94 S Lee Created
4815 --
4816
4817 procedure mark_prev_rev_exp_items(compiled_set_id IN number,
4818 rev_type IN varchar2,
4819 reason IN varchar2,
4820 l_start_date IN date,
4821 l_end_date IN date,
4822 status IN OUT NOCOPY number,
4823 stage IN OUT NOCOPY number)
4824 is
4825 -- Local variable
4826 ei_count number;
4827 adj_module constant varchar2(10) := 'PACOCRSR';
4828 cost_adj_reason varchar2(30);
4829 rev_adj_reason varchar2(30);
4830 inv_adj_reason varchar2(30);
4831 tp_adj_reason varchar2(30);
4832 l_gms_enabled VARCHAR2(2) :='N'; /*3059344*/
4833 err_buf varchar2(4000);--Bug 5726575
4834 ret_code varchar2(250);--Bug 5726575
4835 GMS_INSERT_ENC_ITEM_ERROR exception; --Bug 5726575
4836 INSERT_ADJ_ACTIVITY_ERROR exception;
4837
4838 -- Cursor definition
4839
4840 -- The following cursor definitions were changed to select from
4841 -- PA_EXPENDITURE_ITEMS_ALL instead of PA_EXPENDITURE_ITEMS to support
4842 -- a multi-org implementation where expenditure items may span across
4843 -- operating units.
4844
4845 -- Modifying the statement to exclude closed project items as well as
4846 -- net zero items (Bug # 730849)
4847 -- (09/17/98)
4848 --
4849 -- Added Nvl for net_zero_adjustment_flag (896190)
4850 --
4851 CURSOR ei1_cursor
4852 IS
4853 SELECT expenditure_item_id
4854 FROM pa_expenditure_items_all ei
4855 WHERE cost_ind_compiled_set_id = compiled_set_id
4856 AND EXISTS
4857 (SELECT task_id
4858 FROM pa_tasks task
4859 WHERE task.task_id = ei.task_id
4860 AND task.cost_ind_sch_fixed_date BETWEEN --Bug 5917245 Removed TRUNC
4861 l_start_date AND
4862 NVL(l_end_date, cost_ind_sch_fixed_date))
4863 AND nvl(ei.net_zero_adjustment_flag,'N') <>'Y'
4864 /******** AND ei.task_id NOT IN
4865 (select t.task_id
4866 FROM pa_projects_all p, pa_tasks t
4867 WHERE t.project_id=p.project_id AND
4868 ei.task_id = t.task_id AND
4869 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for Bug# 2933915*/
4870 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <>'Y' /*Added for bug# 2933915*/
4871 AND decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id),'N') = 'N'; /*3059344*/
4872
4873 CURSOR ei2_cursor
4874 IS
4875 SELECT expenditure_item_id
4876 FROM pa_expenditure_items_all ei
4877 WHERE rev_ind_compiled_set_id = compiled_set_id
4878 AND EXISTS
4879 (SELECT task_id
4880 FROM pa_tasks task
4881 WHERE task.task_id = ei.task_id
4882 AND (task.rev_ind_sch_fixed_date BETWEEN --Bug 5917245 Removed TRUNC
4883 l_start_date AND
4884 NVL(l_end_date, rev_ind_sch_fixed_date)))
4885 AND nvl(ei.net_zero_adjustment_flag ,'N')<>'Y'
4886 /********AND ei.task_id NOT IN
4887 (select t.task_id
4888 FROM pa_projects_all p, pa_tasks t
4889 WHERE t.project_id=p.project_id AND
4890 ei.task_id = t.task_id AND
4891 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for Bug# 2933915*/
4892 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <>'Y' /*Added for bug# 2933915*/
4893 AND ( decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id),'N') = 'N' ); /*3059344*/
4894
4895 CURSOR ei3_cursor
4896 IS
4897 SELECT expenditure_item_id
4898 FROM pa_expenditure_items_all ei
4899 WHERE inv_ind_compiled_set_id = compiled_set_id
4900 AND EXISTS
4901 (SELECT task_id
4902 FROM pa_tasks task
4903 WHERE task.task_id = ei.task_id
4904 AND (task.inv_ind_sch_fixed_date BETWEEN --Bug 5917245Removed TRUNC
4905 l_start_date AND
4906 NVL(l_end_date, inv_ind_sch_fixed_date)))
4907 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
4908 /***** AND ei.task_id NOT IN
4909 (select t.task_id
4910 FROM pa_projects_all p, pa_tasks t
4911 WHERE t.project_id=p.project_id AND
4912 ei.task_id = t.task_id AND
4913 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for Bug# 2933915*/
4914 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <>'Y' /*Added for bug# 2933915*/
4915 AND ( decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id),'N') = 'N' ); /*3059344*/
4916
4917
4918 CURSOR ei4_cursor
4919 IS
4920 SELECT expenditure_item_id
4921 FROM pa_expenditure_items_all ei
4922 WHERE cost_ind_compiled_set_id = compiled_set_id
4923 AND expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
4924 l_start_date AND
4925 NVL(l_end_date, expenditure_item_date)
4926 AND EXISTS
4927 (SELECT task_id
4928 FROM pa_tasks task
4929 WHERE task.task_id = ei.task_id
4930 AND task.cost_ind_sch_fixed_date IS NULL)
4931 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
4932 /****** AND ei.task_id NOT IN
4933 (select t.task_id
4934 FROM pa_projects_all p, pa_tasks t
4935 WHERE t.project_id=p.project_id AND
4936 ei.task_id = t.task_id AND
4937 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for Bug# 2933915*/
4938 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <>'Y' /*Added for bug# 2933915*/
4939 AND ( decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id),'N') = 'N' ); /*3059344*/
4940
4941
4942 CURSOR ei5_cursor
4943 IS
4944 SELECT expenditure_item_id
4945 FROM pa_expenditure_items_all ei
4946 WHERE rev_ind_compiled_set_id = compiled_set_id
4947 AND expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
4948 l_start_date AND
4949 NVL(l_end_date, expenditure_item_date)
4950 AND EXISTS
4951 (SELECT task_id
4952 FROM pa_tasks task
4953 WHERE task.task_id = ei.task_id
4954 AND task.rev_ind_sch_fixed_date IS NULL)
4955 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
4956 /****** AND ei.task_id NOT IN
4957 (select t.task_id
4958 FROM pa_projects_all p, pa_tasks t
4959 WHERE t.project_id=p.project_id AND
4960 ei.task_id = t.task_id AND
4961 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for Bug# 2933915*/
4962 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <>'Y' /*Added for bug# 2933915*/
4963 AND ( decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id),'N') = 'N' ); /*3059344*/
4964
4965
4966 CURSOR ei6_cursor
4967 IS
4968 SELECT expenditure_item_id
4969 FROM pa_expenditure_items_all ei
4970 WHERE inv_ind_compiled_set_id = compiled_set_id
4971 AND expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
4972 l_start_date AND
4973 NVL(l_end_date, expenditure_item_date)
4974 AND EXISTS
4975 (SELECT task_id
4976 FROM pa_tasks task
4977 WHERE task.task_id = ei.task_id
4978 AND task.inv_ind_sch_fixed_date IS NULL)
4979 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
4980 /****** AND ei.task_id NOT IN
4981 (select t.task_id
4982 FROM pa_projects_all p, pa_tasks t
4983 WHERE t.project_id=p.project_id AND
4984 ei.task_id = t.task_id AND
4985 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for bug2933915*/
4986 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <>'Y' /*Added for bug# 2933915*/
4987 AND ( decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id),'N') = 'N' ); /*3059344*/
4988
4989
4990 CURSOR ei7_cursor
4991 IS
4992 SELECT expenditure_item_id
4993 FROM pa_expenditure_items_all ei
4994 WHERE cost_ind_compiled_set_id = compiled_set_id
4995 AND expenditure_item_date BETWEEN --Bug 5917245 removed TRUNC
4996 l_start_date AND NVL(l_end_date, expenditure_item_date)
4997 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
4998 /****** AND ei.task_id NOT IN
4999 (select t.task_id
5000 FROM pa_projects_all p, pa_tasks t
5001 WHERE t.project_id=p.project_id AND
5002 ei.task_id = t.task_id AND
5003 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for bug# 2933915*/
5004 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <>'Y' /*Added for bug# 2933915*/
5005 AND (decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id),'N') = 'N' ); /*3059344*/
5006
5007 CURSOR ei8_cursor
5008 IS
5009 SELECT expenditure_item_id
5010 FROM pa_expenditure_items_all ei
5011 WHERE rev_ind_compiled_set_id = compiled_set_id
5012 AND expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
5013 l_start_date AND
5014 NVL(l_end_date, expenditure_item_date)
5015 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
5016 /*****AND ei.task_id NOT IN
5017 (select t.task_id
5018 FROM pa_projects_all p, pa_tasks t
5019 WHERE t.project_id=p.project_id AND
5020 ei.task_id = t.task_id AND
5021 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for bug 2933915*/
5022 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <>'Y' /*Added for bug# 2933915*/
5023 AND ( decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id),'N') = 'N' ); /*3059344*/
5024
5025 CURSOR ei9_cursor
5026 IS
5027 SELECT expenditure_item_id
5028 FROM pa_expenditure_items_all ei
5029 WHERE inv_ind_compiled_set_id = compiled_set_id
5030 AND expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
5031 l_start_date AND
5032 NVL(l_end_date, expenditure_item_date)
5033 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
5034 /***** AND ei.task_id NOT IN
5035 (select t.task_id
5036 FROM pa_projects_all p, pa_tasks t
5037 WHERE t.project_id=p.project_id AND
5038 ei.task_id = t.task_id AND
5039 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for Bug 2933915 */
5040 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <>'Y' /*Added for bug# 2933915*/
5041 AND ( decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id),'N') = 'N' ); /*3059344*/
5042
5043 CURSOR ei10_cursor
5044 IS
5045 SELECT expenditure_item_id
5046 FROM pa_expenditure_items_all ei
5047 WHERE cost_ind_compiled_set_id = compiled_set_id
5048 AND EXISTS
5049 (SELECT t1.task_id
5050 FROM pa_project_types_all pt,
5051 pa_projects_all p,
5052 pa_tasks t1
5053 WHERE pt.project_type = p.project_type
5054 /* AND nvl(pt.org_id, -99) = nvl(p.org_id, -99) Bug 5374745 */
5055 AND pt.org_id = p.org_id -- bug 5374745
5056 AND p.project_id = t1.project_id
5057 AND t1.cost_ind_sch_fixed_date BETWEEN --Bug 5917245 Removed TRUNC
5058 l_start_date AND
5059 NVL(l_end_date, t1.rev_ind_sch_fixed_date)
5060 AND t1.task_id = ei.task_id
5061 AND pt.project_type_class_code = 'CAPITAL'
5062 AND pt.capital_cost_type_code = 'B')
5063 AND nvl(ei.net_zero_adjustment_flag,'N') <>'Y'
5064 /**** AND ei.task_id NOT IN
5065 (select t.task_id
5066 FROM pa_projects_all p, pa_tasks t
5067 WHERE t.project_id=p.project_id AND
5068 ei.task_id = t.task_id AND
5069 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for Bug 2933915*/
5070 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <>'Y' /*Added for bug# 2933915*/
5071 AND ( decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id),'N') = 'N' ); /*3059344*/
5072
5073 CURSOR ei11_cursor
5074 IS
5075 SELECT expenditure_item_id
5076 FROM pa_expenditure_items_all ei
5077 WHERE cost_ind_compiled_set_id = compiled_set_id
5078 AND expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
5079 l_start_date AND
5080 NVL(l_end_date, expenditure_item_date)
5081 AND EXISTS
5082 (SELECT /*+ no_unnest */ t1.task_id --Bug 12811820
5083 FROM pa_project_types_all pt,
5084 pa_projects_all p,
5085 pa_tasks t1
5086 WHERE pt.project_type = p.project_type
5087 /* AND nvl(pt.org_id, -99) = nvl(p.org_id, -99) bug 5374745 */
5088 AND pt.org_id = p.org_id -- bug 5374745
5089 AND p.project_id = t1.project_id
5090 AND t1.cost_ind_sch_fixed_date is NULL
5091 AND t1.task_id = ei.task_id
5092 AND pt.project_type_class_code = 'CAPITAL'
5093 AND pt.capital_cost_type_code = 'B')
5094 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
5095 /***** AND ei.task_id NOT IN
5096 (select t.task_id
5097 FROM pa_projects_all p, pa_tasks t
5098 WHERE t.project_id=p.project_id AND
5099 ei.task_id = t.task_id AND
5100 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for Bug 2933915*/
5101 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <>'Y' /*Added for bug# 2933915*/
5102 AND ( decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id),'N') = 'N' ); /*3059344*/
5103
5104 CURSOR ei12_cursor
5105 IS
5106 SELECT expenditure_item_id
5107 FROM pa_expenditure_items_all ei
5108 WHERE cost_ind_compiled_set_id = compiled_set_id
5109 AND expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
5110 l_start_date AND
5111 NVL(l_end_date, expenditure_item_date)
5112 AND EXISTS
5113 (SELECT /*+ no_unnest */ t1.task_id --Bug 12811820
5114 FROM pa_project_types_all pt,
5115 pa_projects_all p,
5116 pa_tasks t1
5117 WHERE pt.project_type = p.project_type
5118 /* AND nvl(pt.org_id, -99) = nvl(p.org_id, -99) Bug 5374745 */
5119 AND pt.org_id = p.org_id -- bug 5374745
5120 AND p.project_id = t1.project_id
5121 AND t1.task_id = ei.task_id
5122 AND pt.project_type_class_code = 'CAPITAL'
5123 AND pt.capital_cost_type_code = 'B')
5124 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
5125 /****** AND ei.task_id NOT IN
5126 (select t.task_id
5127 FROM pa_projects_all p, pa_tasks t
5128 WHERE t.project_id=p.project_id AND
5129 ei.task_id = t.task_id AND
5130 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for bug# 2933915*/
5131 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <>'Y' /*Added for bug# 2933915*/
5132 AND ( decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id),'N') = 'N' ); /*3059344*/
5133
5134
5135 /*
5136 * IC related change:
5137 * cursors defined for TP schedule related changes.
5138 * ei13 is for FIRM schedule where as ei14 is for PROVISIONAL schedule.
5139 * Note: explain plan is fine in RBO, cant test it in CBO because of
5140 * non-availability of volume data.
5141 */
5142 /*Bug# 2164590:Commenting this query and tuned it below*/
5143 /*
5144 CURSOR ei13_cursor
5145 IS
5146 SELECT expenditure_item_id
5147 FROM pa_expenditure_items_all ei,
5148 pa_system_linkages syslink,
5149 pa_tasks task,
5150 pa_projects_all proj
5151 WHERE ei.tp_ind_compiled_set_id = compiled_set_id
5152 AND ei.system_linkage_function = syslink.function
5153 AND task.task_id = ei.task_id
5154 AND (
5155 ( TRUNC(NVL(task.labor_tp_fixed_date, ei.expenditure_item_date)) BETWEEN
5156 TRUNC(l_start_date) AND
5157 TRUNC(NVL(l_end_date, NVL(task.labor_tp_fixed_date,ei.expenditure_item_date)))
5158 AND
5159 syslink.labor_non_labor_flag = 'Y')
5160 OR
5161 ( TRUNC(NVL(task.nl_tp_fixed_date, ei.expenditure_item_date)) BETWEEN
5162 TRUNC(l_start_date) AND
5163 TRUNC(NVL(l_end_date, NVL(task.nl_tp_fixed_date,ei.expenditure_item_date)))
5164 AND
5165 syslink.labor_non_labor_flag = 'N')
5166 )
5167 AND nvl(ei.net_zero_adjustment_flag, 'N') <> 'Y'
5168 AND proj.project_id = task.project_id
5169 AND pa_project_stus_utils.Is_Project_Status_Closed(proj.project_status_code) <> 'Y';*/
5170
5171 /*Bug# 2164590:Changed ei13_cursor for performance*/
5172 CURSOR ei13_cursor
5173 IS
5174 SELECT EXPENDITURE_ITEM_ID
5175 FROM PA_EXPENDITURE_ITEMS_ALL EI
5176 WHERE tp_ind_compiled_set_id = compiled_set_id
5177 AND EXISTS
5178 (SELECT task_id
5179 FROM pa_tasks task, pa_system_linkages syslink /*2933915 : ,pa_projects_all proj :Join with pa_projects is not required here */
5180 WHERE task.task_id = ei.task_id
5181 AND ei.system_linkage_function = syslink.function
5182 /*AND task.project_id = proj.project_id 2933915*/
5183 AND task.project_id = ei.project_id /*2933915*/
5184 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <> 'Y' /*2933915*/
5185 AND ( decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id),'N') = 'N' ) /*3059344*/
5186 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
5187 AND ((NVL(task.labor_tp_fixed_date, ei.expenditure_item_date) BETWEEN --Bug 5917245 Removed TRUNC
5188 l_start_date
5189 AND NVL(l_end_date, NVL(task.labor_tp_fixed_date,ei.expenditure_item_date))
5190 AND syslink.labor_non_labor_flag = 'Y')
5191 OR (NVL(task.nl_tp_fixed_date, ei.expenditure_item_date) BETWEEN --Bug 5917245 Removed TRUNC
5192 l_start_date AND
5193 NVL(l_end_date, NVL(task.nl_tp_fixed_date,ei.expenditure_item_date))
5194 AND syslink.labor_non_labor_flag = 'N')
5195 ));
5196
5197 CURSOR ei14_cursor
5198 IS
5199 SELECT expenditure_item_id
5200 FROM pa_expenditure_items_all ei
5201 /* pa_tasks task -- Commented for Bug#3585192 */
5202 /* pa_projects_all proj :2933915 :Redundant join and hence can be removed */
5203 WHERE tp_ind_compiled_set_id = compiled_set_id
5204 AND ei.expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
5205 l_start_date AND
5206 NVL(l_end_date, ei.expenditure_item_date)
5207 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
5208 /**** AND ei.task_id = task.task_id
5209 AND proj.project_id = task.project_id
5210 AND pa_project_stus_utils.Is_Project_Status_Closed(proj.project_status_code) <> 'Y' ****2933915*/
5211 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <> 'Y' /*2933915*/
5212 AND ( decode(l_gms_enabled,'Y',gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id),'N') = 'N' ); /*3059344*/
5213
5214
5215
5216 -- Standard who
5217 x_last_updated_by NUMBER(15);
5218 x_last_update_login NUMBER(15);
5219 x_request_id NUMBER(15);
5220 x_program_application_id NUMBER(15);
5221 x_program_id NUMBER(15);
5222
5223 l_burden_profile VARCHAR2(2); /*2933915*/
5224
5225 BEGIN
5226
5227 --
5228 -- Get the standard who information
5229 --
5230 x_last_updated_by := FND_GLOBAL.USER_ID;
5231 x_last_update_login := FND_GLOBAL.LOGIN_ID;
5232 x_request_id := FND_GLOBAL.CONC_REQUEST_ID;
5233 x_program_application_id := FND_GLOBAL.PROG_APPL_ID;
5234 x_program_id := FND_GLOBAL.CONC_PROGRAM_ID;
5235
5236 -- l_burden_profile := nvl(fnd_profile.value('PA_ENHANCED_BURDENING'),'N'); /*2933915*/
5237 l_burden_profile := pa_utils2.IsEnhancedBurdeningEnabled;
5238
5239 IF gms_install.enabled THEN /*3059344 :To check if grants is installed */
5240 l_gms_enabled := 'Y' ;
5241 END IF ;
5242
5243 /*
5244 * IC related change:
5245 * New reason added for TP schedule changes.
5246 */
5247 if (reason = 'APPLY ACTUAL') then
5248
5249 cost_adj_reason := 'APPLY ACTUAL COST SCH REV';
5250 rev_adj_reason := 'APPLY ACTUAL REV SCH REV';
5251 inv_adj_reason := 'APPLY ACTUAL INV SCH REV';
5252 tp_adj_reason := 'APPLY_ACTUAL_TP_SCH_REV';
5253
5254 else
5255
5256 cost_adj_reason := 'NEW COST SCHEDULE REVISION';
5257 rev_adj_reason := 'NEW REV SCHEDULE REVISION';
5258 inv_adj_reason := 'NEW INV SCHEDULE REVISION';
5259 tp_adj_reason := 'NEW_TP_SCHEDULE_REVISION';
5260
5261 end if;
5262
5263 --
5264 -- Mark expenditure items for previous revisions
5265 --
5266
5267 if (rev_type = 'F') then
5268
5269 --
5270 -- Check if schedule fixed date is within the range.
5271 -- Costing with schedule fixed date
5272 --
5273
5274 /*
5275 Burdening related changes
5276 Reset burdened_costs to null so that costing program recalculates them.
5277 */
5278 -- Modifying the statement to exclude closed project items as well as
5279 -- net zero items (Bug # 730849)
5280 -- (09/17/98)
5281 --
5282 -- Added Nvl for net_zero_adjustment_flag (896190)
5283 -- ---------------------------------------------------------------------
5284 /* Updating Project_Burdened_Cost also for Bug 2736773 */
5285
5286 /***Bug 2933915 : Added the exists clause in this update to indicate that except profile ='Y' and display_method ='D' -for all
5287 cases we will be marking ei for cost reprocessing */
5288 /*If Burdening is on same ei then update adjustment_type as BURDEN_COMPILE else update it as BURDEN_RESUMMARIZE .*/
5289
5290 UPDATE pa_expenditure_items_all ei
5291 SET cost_distributed_flag = 'N',
5292 adjustment_type ='BURDEN_RECOMPILE', /*2933915*/
5293 cost_burden_distributed_flag = 'N',
5294 last_update_date = SYSDATE,
5295 last_updated_by = x_last_updated_by,
5296 last_update_login = x_last_update_login,
5297 request_id = x_request_id,
5298 program_application_id = x_program_application_id,
5299 program_id = x_program_id,
5300 program_update_date = SYSDATE,
5301 denom_burdened_cost = NULL,
5302 project_burdened_cost = NULL,
5303 acct_burdened_cost = NULL,
5304 burden_cost = NULL
5305 WHERE cost_ind_compiled_set_id = compiled_set_id
5306 AND EXISTS
5307 (SELECT task_id
5308 FROM pa_tasks task
5309 WHERE task.task_id = ei.task_id
5310 AND task.cost_ind_sch_fixed_date BETWEEN
5311 l_start_date AND
5312 NVL(l_end_date, cost_ind_sch_fixed_date))
5313 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
5314 /****** AND ei.task_id NOT IN
5315 (select t.task_id
5316 FROM pa_projects_all p, pa_tasks t
5317 WHERE t.project_id=p.project_id AND
5318 ei.task_id = t.task_id AND
5319 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for Bug 2933915*/
5320 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <>'Y' /*2933915*/
5321 AND ((pa_utils2.Proj_Type_Burden_Disp_Method(ei.project_id) IN ('S','s','D','d') AND l_burden_profile ='N') /*Added for 2933915*/
5322 OR (pa_utils2.Proj_Type_Burden_Disp_Method(ei.project_id) IN ('S','s') AND l_burden_profile ='Y'))
5323 AND ( gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' );
5324
5325
5326 -- consider volume of expenditure items having the same compiled set id
5327 COMMIT;
5328
5329 if l_gms_enabled = 'Y' then --Bug 5693864
5330 gms_pa_api3.mark_prev_rev_enc_items (errbuf => err_buf,
5331 retcode => ret_code,
5332 p_compiled_set_id => compiled_set_id,
5333 p_start_date => l_start_date,
5334 p_end_date => l_end_date,
5335 p_mode => 'T');
5336 if err_buf is not null then
5337 raise GMS_INSERT_ENC_ITEM_ERROR;
5338 end if;
5339 commit;
5340 end if;
5341
5342 ei_count := 0;
5343
5344 FOR ei1_row IN ei1_cursor LOOP
5345
5346 PA_Adjustments.InsAuditRec(ei1_row.expenditure_item_id,
5347 cost_adj_reason,
5348 adj_module,
5349 x_last_updated_by,
5350 x_last_update_login,
5351 status,
5352 x_request_id,
5353 x_program_id,
5354 x_program_application_id,
5355 SYSDATE);
5356
5357 IF (status <> 0) THEN
5358 raise INSERT_ADJ_ACTIVITY_ERROR;
5359 END IF;
5360
5361 ei_count := ei_count + 1;
5362
5363 IF (ei_count >= 500) THEN
5364 COMMIT;
5365 ei_count := 0;
5366 END IF;
5367
5368 END LOOP;
5369
5370 COMMIT;
5371
5372
5373 --
5374 -- Revenue and invoice with schedule fixed date
5375 --
5376
5377 -- Modifying the statement to exclude closed project items as well as
5378 -- net zero items (Bug # 730849)
5379 -- (09/17/98)
5380 --
5381 -- Added Nvl for net_zero_adjustment_flag (896190)
5382 --
5383 UPDATE pa_expenditure_items_all ei
5384 SET revenue_distributed_flag = 'N',
5385 last_update_date = SYSDATE,
5386 last_updated_by = x_last_updated_by,
5387 last_update_login = x_last_update_login,
5388 request_id = x_request_id,
5389 program_application_id = x_program_application_id,
5390 program_id = x_program_id,
5391 program_update_date = SYSDATE
5392 WHERE rev_ind_compiled_set_id = compiled_set_id
5393 AND EXISTS
5394 (SELECT task_id
5395 FROM pa_tasks task
5396 WHERE task.task_id = ei.task_id
5397 AND task.rev_ind_sch_fixed_date BETWEEN --Bug#5917245 Removed TRUNC
5398 l_start_date AND
5399 NVL(l_end_date, rev_ind_sch_fixed_date))
5400 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
5401 /****2933915 AND ei.task_id NOT IN
5402 (select t.task_id
5403 FROM pa_projects_all p, pa_tasks t
5404 WHERE t.project_id=p.project_id AND
5405 ei.task_id = t.task_id AND
5406 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commenteed for bug# 2933915*/
5407 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id)<>'Y' /*2933915*/
5408 AND ( gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' );
5409
5410
5411 -- consider volume of expenditure items having the same compiled set id
5412 COMMIT;
5413
5414 ei_count := 0;
5415
5416 FOR ei2_row IN ei2_cursor LOOP
5417
5418 PA_Adjustments.InsAuditRec(ei2_row.expenditure_item_id,
5419 rev_adj_reason,
5420 adj_module,
5421 x_last_updated_by,
5422 x_last_update_login,
5423 status,
5424 x_request_id,
5425 x_program_id,
5426 x_program_application_id,
5427 SYSDATE);
5428
5429 IF (status <> 0) THEN
5430 raise INSERT_ADJ_ACTIVITY_ERROR;
5431 END IF;
5432
5433 ei_count := ei_count + 1;
5434
5435 IF (ei_count >= 500) THEN
5436 COMMIT;
5437 ei_count := 0;
5438 END IF;
5439
5440 END LOOP;
5441
5442 COMMIT;
5443
5444 -- Modifying the statement to exclude closed project items as well as
5445 -- net zero items (Bug # 730849)
5446 -- (09/17/98)
5447 --
5448 -- Added Nvl for net_zero_adjustment_flag (896190)
5449 --
5450
5451 UPDATE pa_expenditure_items_all ei
5452 SET revenue_distributed_flag = 'N',
5453 last_update_date = SYSDATE,
5454 last_updated_by = x_last_updated_by,
5455 last_update_login = x_last_update_login,
5456 request_id = x_request_id,
5457 program_application_id = x_program_application_id,
5458 program_id = x_program_id,
5459 program_update_date = SYSDATE
5460 WHERE inv_ind_compiled_set_id = compiled_set_id
5461 AND EXISTS
5462 (SELECT task_id
5463 FROM pa_tasks task
5464 WHERE task.task_id = ei.task_id
5465 AND task.inv_ind_sch_fixed_date BETWEEN --Bug#5917245 Removed TRUNC
5466 l_start_date AND
5467 NVL(l_end_date, inv_ind_sch_fixed_date))
5468 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
5469 /***** AND ei.task_id NOT IN
5470 (select t.task_id
5471 FROM pa_projects_all p, pa_tasks t
5472 WHERE t.project_id=p.project_id AND
5473 ei.task_id = t.task_id AND
5474 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for bug# 2933915*/
5475 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id)<>'Y' /*2933915*/
5476 AND ( gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' );
5477
5478
5479 -- consider volume of expenditure items having the same compiled set id
5480 COMMIT;
5481
5482 ei_count := 0;
5483
5484 FOR ei3_row IN ei3_cursor LOOP
5485
5486 PA_Adjustments.InsAuditRec(ei3_row.expenditure_item_id,
5487 inv_adj_reason,
5488 adj_module,
5489 x_last_updated_by,
5490 x_last_update_login,
5491 status,
5492 x_request_id,
5493 x_program_id,
5494 x_program_application_id,
5495 SYSDATE);
5496
5497 IF (status <> 0) THEN
5498 raise INSERT_ADJ_ACTIVITY_ERROR;
5499 END IF;
5500
5501 ei_count := ei_count + 1;
5502
5503 IF (ei_count >= 500) THEN
5504 COMMIT;
5505 ei_count := 0;
5506 END IF;
5507
5508 END LOOP;
5509
5510 COMMIT;
5511
5512 --
5513 -- Section For Capital Projects
5514 --
5515 -- This section is added as a part of fix for bug 897479.
5516 --
5517 UPDATE pa_expenditure_items_all ei
5518 SET revenue_distributed_flag = 'N',
5519 last_update_date = SYSDATE,
5520 last_updated_by = x_last_updated_by,
5521 last_update_login = x_last_update_login,
5522 request_id = x_request_id,
5523 program_application_id = x_program_application_id,
5524 program_id = x_program_id,
5525 program_update_date = SYSDATE
5526 WHERE cost_ind_compiled_set_id = compiled_set_id
5527 AND EXISTS
5528 (SELECT t1.task_id
5529 FROM pa_project_types_all pt,
5530 pa_projects_all p,
5531 pa_tasks t1
5532 WHERE pt.project_type = p.project_type
5533 AND nvl(pt.org_id, -99) = nvl(p.org_id, -99)
5534 AND p.project_id = t1.project_id
5535 AND TRUNC(t1.cost_ind_sch_fixed_date) BETWEEN
5536 TRUNC(l_start_date) AND
5537 TRUNC(NVL(l_end_date, t1.rev_ind_sch_fixed_date))
5538 AND t1.task_id = ei.task_id
5539 AND pt.project_type_class_code = 'CAPITAL'
5540 AND pt.capital_cost_type_code = 'B')
5541 AND nvl(ei.net_zero_adjustment_flag,'N') <>'Y'
5542 /**** AND ei.task_id NOT IN
5543 (select t.task_id
5544 FROM pa_projects_all p, pa_tasks t
5545 WHERE t.project_id=p.project_id AND
5546 ei.task_id = t.task_id AND
5547 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for 2933915*/
5548 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id)<>'Y' /*2933915*/
5549 AND ( gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' );
5550
5551 -- consider volume of expenditure items having the same compiled set id
5552 COMMIT;
5553
5554 ei_count := 0;
5555
5556 FOR ei10_row IN ei10_cursor LOOP
5557
5558 PA_Adjustments.InsAuditRec(ei10_row.expenditure_item_id,
5559 cost_adj_reason,
5560 adj_module,
5561 x_last_updated_by,
5562 x_last_update_login,
5563 status,
5564 x_request_id,
5565 x_program_id,
5566 x_program_application_id,
5567 SYSDATE);
5568
5569 IF (status <> 0) THEN
5570 raise INSERT_ADJ_ACTIVITY_ERROR;
5571 END IF;
5572
5573 ei_count := ei_count + 1;
5574
5575 IF (ei_count >= 500) THEN
5576 COMMIT;
5577 ei_count := 0;
5578 END IF;
5579
5580 END LOOP;
5581
5582 COMMIT;
5583
5584 --
5585 -- End Section For Capital Projects
5586 --
5587
5588 --
5589 -- Costing without schedule fixed date. Use expenditure item date.
5590 --
5591
5592 /*
5593 Burdening related changes
5594 Reset burdened_costs to null so that costing program recalculates them.
5595 */
5596 -- Modifying the statement to exclude closed project items as well as
5597 -- net zero items (Bug # 730849)
5598 -- (09/17/98)
5599 --
5600 -- Added Nvl for net_zero_adjustment_flag (896190)
5601 -- ---------------------------------------------------------------------
5602 /* Updating Project_Burdened_Cost also for Bug 2736773 */
5603 UPDATE pa_expenditure_items_all ei
5604 SET cost_distributed_flag = 'N' ,
5605 adjustment_type ='BURDEN_RECOMPILE', /*2933915*/
5606 cost_burden_distributed_flag = 'N',
5607 last_update_date = SYSDATE,
5608 last_updated_by = x_last_updated_by,
5609 last_update_login = x_last_update_login,
5610 request_id = x_request_id,
5611 program_application_id = x_program_application_id,
5612 program_id = x_program_id,
5613 program_update_date = SYSDATE,
5614 denom_burdened_cost = NULL,
5615 project_burdened_cost = NULL,
5616 acct_burdened_cost = NULL,
5617 burden_cost = NULL
5618 WHERE cost_ind_compiled_set_id = compiled_set_id
5619 AND ei.expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
5620 l_start_date AND NVL(l_end_date, ei.expenditure_item_date)
5621 AND EXISTS
5622 (SELECT task_id
5623 FROM pa_tasks task
5624 WHERE task.task_id = ei.task_id
5625 AND task.cost_ind_sch_fixed_date IS NULL)
5626 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
5627 /***** AND ei.task_id NOT IN
5628 (select t.task_id
5629 FROM pa_projects_all p, pa_tasks t
5630 WHERE t.project_id=p.project_id AND
5631 ei.task_id = t.task_id AND
5632 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for bug 2933915*/
5633 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id)<>'Y' /*2933915*/
5634 AND ( gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' )
5635 AND ((pa_utils2.Proj_Type_Burden_Disp_Method(ei.project_id) IN ('S','s','D','d') AND l_burden_profile ='N') /*Added for 2933915*/
5636 OR (pa_utils2.Proj_Type_Burden_Disp_Method(ei.project_id) IN ('S','s') AND l_burden_profile ='Y')) ;
5637
5638 COMMIT;
5639
5640 if l_gms_enabled = 'Y' then --Bug 5726575
5641 gms_pa_api3.mark_prev_rev_enc_items (errbuf => err_buf,
5642 retcode => ret_code,
5643 p_compiled_set_id => compiled_set_id,
5644 p_start_date => l_start_date,
5645 p_end_date => l_end_date,
5646 p_mode => 'N');
5647 if err_buf is not null then
5648 raise GMS_INSERT_ENC_ITEM_ERROR;
5649 end if;
5650 commit;
5651 end if;
5652
5653 ei_count := 0;
5654
5655 FOR ei4_row IN ei4_cursor LOOP
5656
5657 PA_Adjustments.InsAuditRec(ei4_row.expenditure_item_id,
5658 cost_adj_reason,
5659 adj_module,
5660 x_last_updated_by,
5661 x_last_update_login,
5662 status,
5663 x_request_id,
5664 x_program_id,
5665 x_program_application_id,
5666 SYSDATE);
5667
5668 IF (status <> 0) THEN
5669 raise INSERT_ADJ_ACTIVITY_ERROR;
5670 END IF;
5671
5672 ei_count := ei_count + 1;
5673
5674 IF (ei_count >= 500) THEN
5675 COMMIT;
5676 ei_count := 0;
5677 END IF;
5678
5679 END LOOP;
5680
5681 COMMIT;
5682
5683 --
5684 -- Revenue and invoice without schedule fixed date. Use expenditure
5685 -- item date.
5686 --
5687 -- Modifying the statement to exclude closed project items as well as
5688 -- net zero items (Bug # 730849)
5689 -- (09/17/98)
5690 --
5691 -- Added Nvl for net_zero_adjustment_flag (896190)
5692 --
5693
5694 UPDATE pa_expenditure_items_all ei
5695 SET revenue_distributed_flag = 'N',
5696 last_update_date = SYSDATE,
5697 last_updated_by = x_last_updated_by,
5698 last_update_login = x_last_update_login,
5699 request_id = x_request_id,
5700 program_application_id = x_program_application_id,
5701 program_id = x_program_id,
5702 program_update_date = SYSDATE
5703 WHERE rev_ind_compiled_set_id = compiled_set_id
5704 AND expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
5705 l_start_date AND
5706 NVL(l_end_date, expenditure_item_date)
5707 AND EXISTS
5708 (SELECT task_id
5709 FROM pa_tasks task
5710 WHERE task.task_id = ei.task_id
5711 AND task.rev_ind_sch_fixed_date IS NULL)
5712 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
5713 /*** AND ei.task_id NOT IN
5714 (select t.task_id
5715 FROM pa_projects_all p, pa_tasks t
5716 WHERE t.project_id=p.project_id AND
5717 ei.task_id = t.task_id AND
5718 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for bug2933915*/
5719 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id)<>'Y' /*2933915*/
5720 AND ( gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' );
5721
5722
5723 -- consider volume of expenditure items having the same compiled set id
5724 COMMIT;
5725
5726 ei_count := 0;
5727
5728 FOR ei5_row IN ei5_cursor LOOP
5729
5730 PA_Adjustments.InsAuditRec(ei5_row.expenditure_item_id,
5731 rev_adj_reason,
5732 adj_module,
5733 x_last_updated_by,
5734 x_last_update_login,
5735 status,
5736 x_request_id,
5737 x_program_id,
5738 x_program_application_id,
5739 SYSDATE);
5740
5741 IF (status <> 0) THEN
5742 raise INSERT_ADJ_ACTIVITY_ERROR;
5743 END IF;
5744
5745 ei_count := ei_count + 1;
5746
5747 IF (ei_count >= 500) THEN
5748 COMMIT;
5749 ei_count := 0;
5750 END IF;
5751
5752 END LOOP;
5753
5754 COMMIT;
5755
5756 -- Modifying the statement to exclude closed project items as well as
5757 -- net zero items (Bug # 730849)
5758 -- (09/17/98)
5759 --
5760 -- Added Nvl for net_zero_adjustment_flag (896190)
5761 --
5762 UPDATE pa_expenditure_items_all ei
5763 SET revenue_distributed_flag = 'N',
5764 last_update_date = SYSDATE,
5765 last_updated_by = x_last_updated_by,
5766 last_update_login = x_last_update_login,
5767 request_id = x_request_id,
5768 program_application_id = x_program_application_id,
5769 program_id = x_program_id,
5770 program_update_date = SYSDATE
5771 WHERE inv_ind_compiled_set_id = compiled_set_id
5772 AND expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
5773 l_start_date AND
5774 NVL(l_end_date, expenditure_item_date)
5775 AND EXISTS
5776 (SELECT task_id
5777 FROM pa_tasks task
5778 WHERE task.task_id = ei.task_id
5779 AND task.inv_ind_sch_fixed_date IS NULL)
5780 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
5781 /*** AND ei.task_id NOT IN
5782 (select t.task_id
5783 FROM pa_projects_all p, pa_tasks t
5784 WHERE t.project_id=p.project_id AND
5785 ei.task_id = t.task_id AND
5786 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for bug# 2933915*/
5787 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id)<>'Y' /*2933915*/
5788 AND ( gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' );
5789
5790
5791 -- consider volume of expenditure items having the same compiled set id
5792 COMMIT;
5793
5794 ei_count := 0;
5795
5796 FOR ei6_row IN ei6_cursor LOOP
5797
5798 PA_Adjustments.InsAuditRec(ei6_row.expenditure_item_id,
5799 inv_adj_reason,
5800 adj_module,
5801 x_last_updated_by,
5802 x_last_update_login,
5803 status,
5804 x_request_id,
5805 x_program_id,
5806 x_program_application_id,
5807 SYSDATE);
5808
5809 IF (status <> 0) THEN
5810 raise INSERT_ADJ_ACTIVITY_ERROR;
5811 END IF;
5812
5813 ei_count := ei_count + 1;
5814
5815 IF (ei_count >= 500) THEN
5816 COMMIT;
5817 ei_count := 0;
5818 END IF;
5819
5820 END LOOP;
5821
5822 COMMIT;
5823
5824 --
5825 -- Section for Capital projects
5826 --
5827 --
5828 -- This section has been added as a part of bug 897479.
5829 --
5830 --
5831
5832 IF l_end_date IS NOT NULL THEN
5833
5834 UPDATE pa_expenditure_items_all ei
5835 SET revenue_distributed_flag = 'N',
5836 last_update_date = SYSDATE,
5837 last_updated_by = x_last_updated_by,
5838 last_update_login = x_last_update_login,
5839 request_id = x_request_id,
5840 program_application_id = x_program_application_id,
5841 program_id = x_program_id,
5842 program_update_date = SYSDATE
5843 WHERE cost_ind_compiled_set_id = compiled_set_id
5844 AND expenditure_item_date BETWEEN --Bug5917245 Removed TRUNC
5845 l_start_date AND l_end_date
5846 /* NVL(l_end_date, expenditure_item_date) bug 8668217 */
5847 AND EXISTS
5848 (SELECT t1.task_id
5849 FROM pa_project_types_all pt,
5850 pa_projects_all p,
5851 pa_tasks t1
5852 WHERE pt.project_type = p.project_type
5853 AND nvl(pt.org_id, -99) = nvl(p.org_id, -99)
5854 AND p.project_id = t1.project_id
5855 AND t1.cost_ind_sch_fixed_date is NULL
5856 AND t1.task_id = ei.task_id
5857 AND pt.project_type_class_code = 'CAPITAL'
5858 AND pt.capital_cost_type_code = 'B')
5859 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
5860 /* AND ei.task_id NOT IN
5861 (select t.task_id
5862 FROM pa_projects_all p, pa_tasks t
5863 WHERE t.project_id=p.project_id AND
5864 ei.task_id = t.task_id AND
5865 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for bug# 2933915*/
5866 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id)<>'Y' /*2933915*/
5867 AND ( gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' );
5868
5869 ELSE
5870 UPDATE pa_expenditure_items_all ei
5871 SET revenue_distributed_flag = 'N',
5872 last_update_date = SYSDATE,
5873 last_updated_by = x_last_updated_by,
5874 last_update_login = x_last_update_login,
5875 request_id = x_request_id,
5876 program_application_id = x_program_application_id,
5877 program_id = x_program_id,
5878 program_update_date = SYSDATE
5879 WHERE cost_ind_compiled_set_id = compiled_set_id
5880 AND expenditure_item_date >= l_start_date /*BETWEEN --Bug5917245 Removed TRUNC
5881 l_start_date AND bug 8668217
5882 NVL(l_end_date, expenditure_item_date)*/
5883 AND EXISTS
5884 (SELECT t1.task_id
5885 FROM pa_project_types_all pt,
5886 pa_projects_all p,
5887 pa_tasks t1
5888 WHERE pt.project_type = p.project_type
5889 AND nvl(pt.org_id, -99) = nvl(p.org_id, -99)
5890 AND p.project_id = t1.project_id
5891 AND t1.cost_ind_sch_fixed_date is NULL
5892 AND t1.task_id = ei.task_id
5893 AND pt.project_type_class_code = 'CAPITAL'
5894 AND pt.capital_cost_type_code = 'B')
5895 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
5896 /* AND ei.task_id NOT IN
5897 (select t.task_id
5898 FROM pa_projects_all p, pa_tasks t
5899 WHERE t.project_id=p.project_id AND
5900 ei.task_id = t.task_id AND
5901 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for bug# 2933915*/
5902 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id)<>'Y' /*2933915*/
5903 AND ( gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' );
5904
5905 END IF;
5906
5907 COMMIT;
5908
5909 ei_count := 0;
5910
5911 FOR ei11_row IN ei11_cursor LOOP
5912
5913 PA_Adjustments.InsAuditRec(ei11_row.expenditure_item_id,
5914 cost_adj_reason,
5915 adj_module,
5916 x_last_updated_by,
5917 x_last_update_login,
5918 status,
5919 x_request_id,
5920 x_program_id,
5921 x_program_application_id,
5922 SYSDATE);
5923
5924 IF (status <> 0) THEN
5925 raise INSERT_ADJ_ACTIVITY_ERROR;
5926 END IF;
5927
5928 ei_count := ei_count + 1;
5929
5930 IF (ei_count >= 500) THEN
5931 COMMIT;
5932 ei_count := 0;
5933 END IF;
5934
5935 END LOOP;
5936
5937 COMMIT;
5938
5939 --
5940 -- Section for Capital projects
5941 --
5942
5943
5944 /*
5945 * IC related change:
5946 * updates and activity logging done for TP schedule change.
5947 * Note: explain plan is fine in RBO, cant test it in CBO because of
5948 * non-availability of volume data.
5949 */
5950 /*
5951 * Bug 4885396 : Moved 3 EI based checks from Exists subquery to the
5952 * main query.
5953 */
5954 UPDATE pa_expenditure_items_all ei
5955 SET cc_bl_distributed_code =
5956 decode( cc_cross_charge_code,'B',
5957 'N',
5958 cc_bl_distributed_code),
5959 cc_ic_processed_code =
5960 decode( cc_cross_charge_code,'I',
5961 'N',
5962 cc_ic_processed_code),
5963 Denom_Tp_Currency_Code = NULL,
5964 Denom_Transfer_Price = NULL,
5965 Acct_Tp_Rate_Type = NULL,
5966 Acct_Tp_Rate_Date = NULL,
5967 Acct_Tp_Exchange_Rate = NULL,
5968 Acct_Transfer_Price = NULL,
5969 Projacct_Transfer_Price = NULL,
5970 Cc_Markup_Base_Code = NULL,
5971 Tp_Base_Amount = NULL,
5972 Tp_Bill_Rate = NULL,
5973 Tp_Bill_Markup_Percentage = NULL,
5974 Tp_Schedule_line_Percentage = NULL,
5975 Tp_Rule_percentage = NULL,
5976 last_update_date = SYSDATE,
5977 last_updated_by = x_last_updated_by,
5978 last_update_login = x_last_update_login,
5979 request_id = x_request_id,
5980 program_application_id = x_program_application_id,
5981 program_id = x_program_id,
5982 program_update_date = SYSDATE
5983 WHERE tp_ind_compiled_set_id = compiled_set_id
5984 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <> 'Y'
5985 AND ( gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' )
5986 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
5987 AND EXISTS
5988 (SELECT task_id
5989 FROM pa_tasks task, pa_system_linkages syslink /*, pa_projects_all proj :Redundant :2933915*/
5990 WHERE task.task_id = ei.task_id
5991 AND ei.system_linkage_function = syslink.function
5992 /* AND task.project_id = proj.project_id Commented for 2933915*/
5993 AND task.project_id = ei.project_id /*2933915*/
5994 AND (
5995 ( NVL(task.labor_tp_fixed_date, ei.expenditure_item_date) BETWEEN --Bug 5917245 Removed TRUNC
5996 l_start_date AND
5997 NVL(l_end_date, NVL(task.labor_tp_fixed_date,ei.expenditure_item_date))
5998 AND
5999 syslink.labor_non_labor_flag = 'Y')
6000 OR
6001 ( NVL(task.nl_tp_fixed_date, ei.expenditure_item_date) BETWEEN --Bug 5917245 Removed TRUNC
6002 l_start_date AND
6003 NVL(l_end_date, NVL(task.nl_tp_fixed_date,ei.expenditure_item_date))
6004 AND
6005 syslink.labor_non_labor_flag = 'N')
6006 ));
6007
6008 COMMIT;
6009
6010 ei_count := 0;
6011
6012 FOR ei13_row IN ei13_cursor LOOP
6013
6014 PA_Adjustments.InsAuditRec(ei13_row.expenditure_item_id,
6015 tp_adj_reason,
6016 adj_module,
6017 x_last_updated_by,
6018 x_last_update_login,
6019 status,
6020 x_request_id,
6021 x_program_id,
6022 x_program_application_id,
6023 SYSDATE);
6024
6025 IF (status <> 0) THEN
6026 raise INSERT_ADJ_ACTIVITY_ERROR;
6027 END IF;
6028
6029 ei_count := ei_count + 1;
6030
6031 IF (ei_count >= 500) THEN
6032 COMMIT;
6033 ei_count := 0;
6034 END IF;
6035
6036 END LOOP;
6037
6038 COMMIT;
6039
6040 /* Changes for bug 8282545 start here */
6041
6042 /* When fixed date is NULL */
6043 UPDATE pa_expenditure_items_all ITEM
6044 SET ITEM.adjustment_type = decode(ITEM.cost_ind_compiled_set_id, compiled_set_id, 'BURDEN_RESUMMARIZE' ,ITEM.adjustment_type)
6045 WHERE ITEM.cost_distributed_flag ='Y'
6046 AND ITEM.adjustment_type IS NULL
6047 AND exists ( select 1 from pa_cost_distribution_lines_all cdl
6048 where cdl.burden_sum_source_run_id >0
6049 AND cdl.expenditure_item_id =ITEM.expenditure_item_id
6050 AND cdl.line_type ='R'
6051 AND nvl(cdl.reversed_flag,'N') ='N'
6052 AND cdl.line_num_reversed is NULL)
6053 AND ITEM.cost_ind_compiled_set_id = compiled_set_id
6054 /*S.N. Bug4560630*/
6055 AND (ITEM.expenditure_item_date BETWEEN --Bug 5861858 Removed TRUNC
6056 l_start_date AND
6057 NVL(l_end_date, ITEM.expenditure_item_date))
6058 AND EXISTS
6059 (SELECT task_id
6060 FROM pa_tasks task
6061 WHERE task.task_id = ITEM.task_id
6062 AND task.cost_ind_sch_fixed_date IS NULL)
6063 /*E.N. Bug4560630*/
6064 AND l_burden_profile ='Y'
6065 AND pa_utils2.Proj_Type_Burden_Disp_Method(ITEM.project_id) IN ('D','d');
6066
6067 COMMIT;
6068
6069 /* When fixed date is NOT NULL */
6070
6071 UPDATE pa_expenditure_items_all ITEM
6072 SET ITEM.adjustment_type = decode(ITEM.cost_ind_compiled_set_id, compiled_set_id, 'BURDEN_RESUMMARIZE' ,ITEM.adjustment_type)
6073 WHERE ITEM.cost_distributed_flag ='Y'
6074 AND ITEM.adjustment_type IS NULL
6075 AND exists ( select 1 from pa_cost_distribution_lines_all cdl
6076 where cdl.burden_sum_source_run_id >0
6077 AND cdl.expenditure_item_id =ITEM.expenditure_item_id
6078 AND cdl.line_type ='R'
6079 AND nvl(cdl.reversed_flag,'N') ='N'
6080 AND cdl.line_num_reversed is NULL)
6081 AND ITEM.cost_ind_compiled_set_id = compiled_set_id
6082 /*S.N. Bug4560630*/
6083 AND EXISTS
6084 (SELECT task_id
6085 FROM pa_tasks task
6086 WHERE task.task_id = ITEM.task_id
6087 AND task.cost_ind_sch_fixed_date BETWEEN
6088 l_start_date AND
6089 NVL(l_end_date, cost_ind_sch_fixed_date))
6090 /*E.N. Bug4560630*/
6091 AND l_burden_profile ='Y'
6092 AND pa_utils2.Proj_Type_Burden_Disp_Method(ITEM.project_id) IN ('D','d');
6093
6094 COMMIT;
6095
6096 /* Changes for bug 8282545 end here */
6097
6098 else
6099
6100 --
6101 -- Provisional types
6102 --
6103
6104 /*
6105 Burdening related changes
6106 Reset burdened_costs to null so that costing program recalculates them.
6107 */
6108 -- Modifying the statement to exclude closed project items as well as
6109 -- net zero items (Bug # 730849)
6110 -- (09/17/98)
6111 --
6112 -- Added Nvl for net_zero_adjustment_flag (896190)
6113 -- ---------------------------------------------------------------------
6114 /* Updating Project_Burdened_Cost also for Bug 2736773 */
6115
6116 if l_end_date is NOT NULL THEN
6117
6118 UPDATE pa_expenditure_items_all ei
6119 SET cost_distributed_flag = 'N' ,
6120 adjustment_type ='BURDEN_RECOMPILE',
6121 cost_burden_distributed_flag = 'N',
6122 last_update_date = SYSDATE,
6123 last_updated_by = x_last_updated_by,
6124 last_update_login = x_last_update_login,
6125 request_id = x_request_id,
6126 program_application_id = x_program_application_id,
6127 program_id = x_program_id,
6128 program_update_date = SYSDATE,
6129 denom_burdened_cost = NULL,
6130 project_burdened_cost = NULL,
6131 acct_burdened_cost = NULL,
6132 burden_cost = NULL
6133 WHERE ei.cost_ind_compiled_set_id = compiled_set_id
6134 AND ei.expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
6135 l_start_date AND l_end_date
6136 -- bug 8668217 NVL(l_end_date, ei.expenditure_item_date)
6137 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
6138 /* AND ei.task_id NOT IN
6139 (select t.task_id
6140 FROM pa_projects_all p, pa_tasks t
6141 WHERE t.project_id=p.project_id AND
6142 ei.task_id = t.task_id AND
6143 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for 2933915*/
6144 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id)<>'Y' /*2933915*/
6145 AND ((pa_utils2.Proj_Type_Burden_Disp_Method(ei.project_id) IN ('S','s','D','d') AND l_burden_profile ='N') /*Added for 2933915*/
6146 OR (pa_utils2.Proj_Type_Burden_Disp_Method(ei.project_id) IN ('S','s') AND l_burden_profile ='Y'))
6147 AND ( l_gms_enabled = 'N' OR gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' ) ;
6148
6149 else
6150 UPDATE pa_expenditure_items_all ei
6151 SET cost_distributed_flag = 'N' ,
6152 adjustment_type ='BURDEN_RECOMPILE',
6153 cost_burden_distributed_flag = 'N',
6154 last_update_date = SYSDATE,
6155 last_updated_by = x_last_updated_by,
6156 last_update_login = x_last_update_login,
6157 request_id = x_request_id,
6158 program_application_id = x_program_application_id,
6159 program_id = x_program_id,
6160 program_update_date = SYSDATE,
6161 denom_burdened_cost = NULL,
6162 project_burdened_cost = NULL,
6163 acct_burdened_cost = NULL,
6164 burden_cost = NULL
6165 WHERE ei.cost_ind_compiled_set_id = compiled_set_id
6166 AND ei.expenditure_item_date >= l_start_date --BETWEEN --Bug 5917245 Removed TRUNC
6167 -- bug 8668217 AND NVL(l_end_date, ei.expenditure_item_date)
6168 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
6169 /* AND ei.task_id NOT IN
6170 (select t.task_id
6171 FROM pa_projects_all p, pa_tasks t
6172 WHERE t.project_id=p.project_id AND
6173 ei.task_id = t.task_id AND
6174 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for 2933915*/
6175 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id)<>'Y' /*2933915*/
6176 AND ((pa_utils2.Proj_Type_Burden_Disp_Method(ei.project_id) IN ('S','s','D','d') AND l_burden_profile ='N') /*Added for 2933915*/
6177 OR (pa_utils2.Proj_Type_Burden_Disp_Method(ei.project_id) IN ('S','s') AND l_burden_profile ='Y'))
6178 AND ( l_gms_enabled = 'N' OR gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' ) ;
6179
6180 end if;
6181
6182
6183 /*2933915 :Added the exists clause in above update to indicate that except profile ='Y' and display_method ='D' -for all cases we will
6184 be marking ei for cost reprocessing */
6185
6186 -- consider volume of expenditure items having the same compiled set id
6187 COMMIT;
6188
6189 if l_gms_enabled = 'Y' then --Bug 5726575
6190 gms_pa_api3.mark_prev_rev_enc_items (errbuf => err_buf,
6191 retcode => ret_code,
6192 p_compiled_set_id => compiled_set_id,
6193 p_start_date => l_start_date,
6194 p_end_date => l_end_date,
6195 p_mode => 'O');
6196 if err_buf is not null then
6197 raise GMS_INSERT_ENC_ITEM_ERROR;
6198 end if;
6199 commit;
6200 end if;
6201
6202 FOR ei7_row IN ei7_cursor LOOP
6203
6204 PA_Adjustments.InsAuditRec(ei7_row.expenditure_item_id,
6205 cost_adj_reason,
6206 adj_module,
6207 x_last_updated_by,
6208 x_last_update_login,
6209 status,
6210 x_request_id,
6211 x_program_id,
6212 x_program_application_id,
6213 SYSDATE);
6214
6215 IF (status <> 0) THEN
6216 raise INSERT_ADJ_ACTIVITY_ERROR;
6217 END IF;
6218
6219 ei_count := ei_count + 1;
6220
6221 IF (ei_count >= 500) THEN
6222 COMMIT;
6223 ei_count := 0;
6224 END IF;
6225
6226 END LOOP;
6227
6228 COMMIT;
6229
6230 -- Modifying the statement to exclude closed project items as well as
6231 -- net zero items (Bug # 730849)
6232 -- (09/17/98)
6233 --
6234 -- Added Nvl for net_zero_adjustment_flag (896190)
6235 --
6236 -- Split the update into 2 seperate statements and added l_gms_enabled check for perf issue 9266246
6237 /* 9266246 - Start */
6238 UPDATE pa_expenditure_items_all ei
6239 SET revenue_distributed_flag = 'N',
6240 last_update_date = SYSDATE,
6241 last_updated_by = x_last_updated_by,
6242 last_update_login = x_last_update_login,
6243 request_id = x_request_id,
6244 program_application_id = x_program_application_id,
6245 program_id = x_program_id,
6246 program_update_date = SYSDATE
6247 WHERE rev_ind_compiled_set_id = compiled_set_id
6248 AND expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
6249 l_start_date AND
6250 NVL(l_end_date, expenditure_item_date)
6251 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
6252 /***** AND ei.task_id NOT IN
6253 (select t.task_id
6254 FROM pa_projects_all p, pa_tasks t
6255 WHERE t.project_id=p.project_id AND
6256 ei.task_id = t.task_id AND
6257 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for 2933915*/
6258 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <> 'Y' /*2933915*/
6259 AND (l_gms_enabled = 'N' OR gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' ) ;
6260
6261
6262 UPDATE pa_expenditure_items_all ei
6263 SET revenue_distributed_flag = 'N',
6264 last_update_date = SYSDATE,
6265 last_updated_by = x_last_updated_by,
6266 last_update_login = x_last_update_login,
6267 request_id = x_request_id,
6268 program_application_id = x_program_application_id,
6269 program_id = x_program_id,
6270 program_update_date = SYSDATE
6271 WHERE inv_ind_compiled_set_id = compiled_set_id
6272 AND expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
6273 l_start_date AND
6274 NVL(l_end_date, expenditure_item_date)
6275 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
6276 /***** AND ei.task_id NOT IN
6277 (select t.task_id
6278 FROM pa_projects_all p, pa_tasks t
6279 WHERE t.project_id=p.project_id AND
6280 ei.task_id = t.task_id AND
6281 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for 2933915*/
6282 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <> 'Y' /*2933915*/
6283 AND (l_gms_enabled = 'N' OR gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' ) ;
6284
6285 /* 9266246 - End */
6286
6287 FOR ei8_row IN ei8_cursor LOOP
6288
6289 PA_Adjustments.InsAuditRec(ei8_row.expenditure_item_id,
6290 rev_adj_reason,
6291 adj_module,
6292 x_last_updated_by,
6293 x_last_update_login,
6294 status,
6295 x_request_id,
6296 x_program_id,
6297 x_program_application_id,
6298 SYSDATE);
6299
6300 IF (status <> 0) THEN
6301 raise INSERT_ADJ_ACTIVITY_ERROR;
6302 END IF;
6303
6304 ei_count := ei_count + 1;
6305
6306 IF (ei_count >= 500) THEN
6307 COMMIT;
6308 ei_count := 0;
6309 END IF;
6310
6311 END LOOP;
6312
6313 COMMIT;
6314
6315 FOR ei9_row IN ei9_cursor LOOP
6316
6317 PA_Adjustments.InsAuditRec(ei9_row.expenditure_item_id,
6318 inv_adj_reason,
6319 adj_module,
6320 x_last_updated_by,
6321 x_last_update_login,
6322 status,
6323 x_request_id,
6324 x_program_id,
6325 x_program_application_id,
6326 SYSDATE);
6327
6328 IF (status <> 0) THEN
6329 raise INSERT_ADJ_ACTIVITY_ERROR;
6330 END IF;
6331
6332 ei_count := ei_count + 1;
6333
6334 IF (ei_count >= 500) THEN
6335 COMMIT;
6336 ei_count := 0;
6337 END IF;
6338
6339 END LOOP;
6340
6341 COMMIT;
6342
6343 --
6344 -- Section for Capital Projects
6345 --
6346 -- This section is created as a part of fix for bug 897479 .
6347 --
6348 --
6349
6350 IF l_end_date IS NOT NULL THEN
6351 UPDATE pa_expenditure_items_all ei
6352 SET revenue_distributed_flag = 'N',
6353 last_update_date = SYSDATE,
6354 last_updated_by = x_last_updated_by,
6355 last_update_login = x_last_update_login,
6356 request_id = x_request_id,
6357 program_application_id = x_program_application_id,
6358 program_id = x_program_id,
6359 program_update_date = SYSDATE
6360 WHERE cost_ind_compiled_set_id = compiled_set_id
6361 AND expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
6362 l_start_date AND l_end_date
6363 -- bug 8668217 NVL(l_end_date, expenditure_item_date)
6364 AND EXISTS
6365 (SELECT 1
6366 FROM pa_project_types_all pt,
6367 pa_projects_all p
6368 WHERE pt.project_type = p.project_type
6369 AND nvl(pt.org_id, -99) = nvl(p.org_id, -99)
6370 AND p.project_id = ei.project_id
6371 AND pt.project_type_class_code = 'CAPITAL'
6372 AND pt.capital_cost_type_code = 'B')
6373 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
6374 /**** AND ei.task_id NOT IN
6375 (select t.task_id
6376 FROM pa_projects_all p, pa_tasks t
6377 WHERE t.project_id=p.project_id AND
6378 ei.task_id = t.task_id AND
6379 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for 2933915*/
6380 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <> 'Y' /*2933915*/
6381 AND ( gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' ) ;
6382
6383 -- consider volume of expenditure items having the same compiled set id
6384 COMMIT;
6385
6386 ELSE
6387 UPDATE pa_expenditure_items_all ei
6388 SET revenue_distributed_flag = 'N',
6389 last_update_date = SYSDATE,
6390 last_updated_by = x_last_updated_by,
6391 last_update_login = x_last_update_login,
6392 request_id = x_request_id,
6393 program_application_id = x_program_application_id,
6394 program_id = x_program_id,
6395 program_update_date = SYSDATE
6396 WHERE cost_ind_compiled_set_id = compiled_set_id
6397 AND expenditure_item_date >= l_start_date /* bug 8668217BETWEEN --Bug 5917245 Removed TRUNC
6398 l_start_date AND
6399 NVL(l_end_date, expenditure_item_date)*/
6400 AND EXISTS
6401 (SELECT 1
6402 FROM pa_project_types_all pt,
6403 pa_projects_all p
6404 WHERE pt.project_type = p.project_type
6405 AND nvl(pt.org_id, -99) = nvl(p.org_id, -99)
6406 AND p.project_id = ei.project_id
6407 AND pt.project_type_class_code = 'CAPITAL'
6408 AND pt.capital_cost_type_code = 'B')
6409 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
6410 /**** AND ei.task_id NOT IN
6411 (select t.task_id
6412 FROM pa_projects_all p, pa_tasks t
6413 WHERE t.project_id=p.project_id AND
6414 ei.task_id = t.task_id AND
6415 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for 2933915*/
6416 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <> 'Y' /*2933915*/
6417 AND ( gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' ) ;
6418
6419 END IF;
6420
6421 FOR ei12_row IN ei12_cursor LOOP
6422
6423 PA_Adjustments.InsAuditRec(ei12_row.expenditure_item_id,
6424 cost_adj_reason,
6425 adj_module,
6426 x_last_updated_by,
6427 x_last_update_login,
6428 status,
6429 x_request_id,
6430 x_program_id,
6431 x_program_application_id,
6432 SYSDATE);
6433
6434 IF (status <> 0) THEN
6435 raise INSERT_ADJ_ACTIVITY_ERROR;
6436 END IF;
6437
6438 ei_count := ei_count + 1;
6439
6440 IF (ei_count >= 500) THEN
6441 COMMIT;
6442 ei_count := 0;
6443 END IF;
6444
6445 END LOOP;
6446
6447 COMMIT;
6448
6449 --
6450 -- End section for Capital projects
6451 --
6452
6453
6454 /*
6455 * IC related change:
6456 * updates and activity logging done for TP schedule change.
6457 * Note: explain plan is fine in RBO, cant test it in CBO because of
6458 * non-availability of volume data.
6459 */
6460 UPDATE pa_expenditure_items_all ei
6461 SET cc_bl_distributed_code =
6462 decode( cc_cross_charge_code,'B',
6463 'N',
6464 cc_bl_distributed_code),
6465 cc_ic_processed_code =
6466 decode( cc_cross_charge_code,'I',
6467 'N',
6468 cc_ic_processed_code),
6469 Denom_Tp_Currency_Code = NULL,
6470 Denom_Transfer_Price = NULL,
6471 Acct_Tp_Rate_Type = NULL,
6472 Acct_Tp_Rate_Date = NULL,
6473 Acct_Tp_Exchange_Rate = NULL,
6474 Acct_Transfer_Price = NULL,
6475 Projacct_Transfer_Price = NULL,
6476 Cc_Markup_Base_Code = NULL,
6477 Tp_Base_Amount = NULL,
6478 Tp_Bill_Rate = NULL,
6479 Tp_Bill_Markup_Percentage = NULL,
6480 Tp_Schedule_line_Percentage = NULL,
6481 Tp_Rule_percentage = NULL,
6482 last_update_date = SYSDATE,
6483 last_updated_by = x_last_updated_by,
6484 last_update_login = x_last_update_login,
6485 request_id = x_request_id,
6486 program_application_id = x_program_application_id,
6487 program_id = x_program_id,
6488 program_update_date = SYSDATE
6489 WHERE ei.tp_ind_compiled_set_id = compiled_set_id
6490 AND ei.expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
6491 l_start_date AND
6492 NVL(l_end_date, ei.expenditure_item_date)
6493 AND nvl(ei.net_zero_adjustment_flag, 'N') <>'Y'
6494 /*** AND ei.task_id NOT IN
6495 (select t.task_id
6496 FROM pa_projects_all p, pa_tasks t
6497 WHERE t.project_id=p.project_id AND
6498 ei.task_id = t.task_id AND
6499 pa_project_stus_utils.Is_Project_Status_Closed(p.project_status_code)='Y') Commented for 2933915*/
6500 AND pa_project_stus_utils.Is_Project_Closed(ei.project_id) <> 'Y' /*2933915*/
6501 AND ( gms_pa_api2.is_award_closed(ei.expenditure_item_id,ei.task_id) = 'N' ) ;
6502
6503
6504 /***2933915:UPDATE eis for 'BURDEN_RESUMMARIZE' ONLY if cost_distributed_flag ='Y' and profile option is enabled and burdening is
6505 on separate ei */
6506
6507 /*====================================================================+
6508 | M - If Enhanced Burdening is SET, for Separate line burdening |
6509 | transactions the adjustment_type is set to BURDEN_RESUMMARIZE |
6510 | - if cost_distributed_flag is Y. |
6511 +====================================================================*/
6512 UPDATE pa_expenditure_items_all ITEM
6513 SET ITEM.adjustment_type = decode(ITEM.cost_ind_compiled_set_id, compiled_set_id, 'BURDEN_RESUMMARIZE' ,ITEM.adjustment_type)
6514 WHERE ITEM.cost_distributed_flag ='Y'
6515 AND ITEM.adjustment_type IS NULL
6516 AND exists ( select 1 from pa_cost_distribution_lines_all cdl
6517 where cdl.burden_sum_source_run_id >0
6518 AND cdl.expenditure_item_id =ITEM.expenditure_item_id
6519 AND cdl.line_type ='R'
6520 AND nvl(cdl.reversed_flag,'N') ='N'
6521 AND cdl.line_num_reversed is NULL)
6522 AND ITEM.cost_ind_compiled_set_id = compiled_set_id
6523 /*S.N. Bug4560630*/
6524 AND (ITEM.expenditure_item_date BETWEEN --Bug 5917245 Removed TRUNC
6525 l_start_date AND
6526 NVL(l_end_date, ITEM.expenditure_item_date))
6527 /*E.N. Bug4560630*/
6528 AND l_burden_profile ='Y'
6529 AND pa_utils2.Proj_Type_Burden_Disp_Method(ITEM.project_id) IN ('D','d');
6530
6531 COMMIT;
6532
6533 FOR ei14_row IN ei14_cursor LOOP
6534
6535 PA_Adjustments.InsAuditRec(ei14_row.expenditure_item_id,
6536 tp_adj_reason,
6537 adj_module,
6538 x_last_updated_by,
6539 x_last_update_login,
6540 status,
6541 x_request_id,
6542 x_program_id,
6543 x_program_application_id,
6544 SYSDATE);
6545
6546 IF (status <> 0) THEN
6547 raise INSERT_ADJ_ACTIVITY_ERROR;
6548 END IF;
6549
6550 ei_count := ei_count + 1;
6551
6552 IF (ei_count >= 500) THEN
6553 COMMIT;
6554 ei_count := 0;
6555 END IF;
6556
6557 END LOOP;
6558
6559 COMMIT;
6560
6561 end if;
6562
6563 EXCEPTION
6564 when INSERT_ADJ_ACTIVITY_ERROR then
6565 return;
6566
6567 when GMS_INSERT_ENC_ITEM_ERROR then --Bug 5726575
6568 stage := 120;
6569 status := ret_code;
6570
6571 when OTHERS then
6572 stage := 100;
6573 status := sqlcode;
6574
6575 END mark_prev_rev_exp_items;
6576
6577
6578 --
6579 -- PROCEDURE
6580 -- add_adjustment_activity
6581 --
6582 -- PURPOSE
6583 -- The objective of this procedure is to add adjustment
6584 -- activity of affected expenditure items for auditing purpose
6585 --
6586 -- HISTORY
6587 --
6588 -- 30-JAN-95 S Lee Created
6589 --
6590
6591 /*
6592 procedure add_adjustment_activity(compiled_set_id IN number,
6593 p_cost_base IN pa_cost_bases.cost_base%TYPE
6594 ,p_cost_plus_structure IN pa_cost_plus_structures.cost_plus_structure%TYPE,
6595 cost_adj_reason IN varchar2,
6596 rev_adj_reason IN varchar2,
6597 inv_adj_reason IN varchar2,
6598 tp_adj_reason IN varchar2,
6599 status IN OUT NOCOPY number,
6600 stage IN OUT NOCOPY number,
6601 l_expenditure_item_id_tab IN PA_PLSQL_DATATYPES.IDTABTYP,
6602 l_adj_tyep_tab IN PA_PLSQL_DATATYPES.Char30TabTyp)
6603 */
6604 procedure add_adjustment_activity( l_expenditure_item_id_tab IN PA_PLSQL_DATATYPES.IDTABTYP
6605 ,l_adj_type_tab IN PA_PLSQL_DATATYPES.Char30TabTyp
6606 ,status IN OUT NOCOPY number
6607 ,stage IN OUT NOCOPY number
6608 )
6609 IS
6610
6611 -- Local variable
6612 ei_count number;
6613 adj_module constant varchar2(10) := 'PACOCRSR';
6614
6615 -- Standard who
6616 x_request_id NUMBER(15);
6617
6618 -- Exception
6619 INSERT_ADJ_ACTIVITY_ERROR exception;
6620
6621 /* -- Commented for bug4527736
6622 -- Cursor definition
6623
6624 CURSOR ei_cost_cursor
6625 IS
6626 SELECT expenditure_item_id
6627 FROM pa_expenditure_items_all ITEM
6628 WHERE cost_ind_compiled_set_id = compiled_set_id
6629 AND adjustment_type in ('BURDEN_RECOMPILE','BURDEN_RESUMMARIZE','RECALC_BURDEN')
6630 AND request_id = x_request_id
6631 AND EXISTS (SELECT NULL
6632 FROM pa_cost_base_exp_types cbet
6633 WHERE cbet.cost_base = p_cost_base
6634 AND cbet.cost_plus_structure = p_cost_plus_structure
6635 AND cbet.cost_base_type = INDIRECT_COST_CODE
6636 AND cbet.expenditure_type = ITEM.expenditure_type
6637 )
6638 ;
6639
6640 CURSOR ei_rev_cursor
6641 IS
6642 SELECT expenditure_item_id
6643 FROM pa_expenditure_items_all ITEM
6644 WHERE rev_ind_compiled_set_id = compiled_set_id
6645 AND request_id = x_request_id
6646 AND EXISTS (SELECT NULL
6647 FROM pa_cost_base_exp_types cbet
6648 WHERE cbet.cost_base = p_cost_base
6649 AND cbet.cost_plus_structure = p_cost_plus_structure
6650 AND cbet.cost_base_type = INDIRECT_COST_CODE
6651 AND cbet.expenditure_type = ITEM.expenditure_type
6652 )
6653 ;
6654
6655 CURSOR ei_inv_cursor
6656 IS
6657 SELECT expenditure_item_id
6658 FROM pa_expenditure_items_all ITEM
6659 WHERE inv_ind_compiled_set_id = compiled_set_id
6660 AND request_id = x_request_id
6661 AND EXISTS (SELECT NULL
6662 FROM pa_cost_base_exp_types cbet
6663 WHERE cbet.cost_base = p_cost_base
6664 AND cbet.cost_plus_structure = p_cost_plus_structure
6665 AND cbet.cost_base_type = INDIRECT_COST_CODE
6666 AND cbet.expenditure_type = ITEM.expenditure_type
6667 )
6668 ; End Comment bug4527736 */
6669 /*
6670 * IC related change:
6671 * New cursor added for TP schedule.
6672 */
6673 /* Commented for bug 4527736
6674 CURSOR ei_tp_cursor
6675 IS
6676 SELECT expenditure_item_id
6677 FROM pa_expenditure_items_all ITEM
6678 WHERE tp_ind_compiled_set_id = compiled_set_id
6679 AND request_id = x_request_id
6680 AND EXISTS (SELECT NULL
6681 FROM pa_cost_base_exp_types cbet
6682 WHERE cbet.cost_base = p_cost_base
6683 AND cbet.cost_plus_structure = p_cost_plus_structure
6684 AND cbet.cost_base_type = INDIRECT_COST_CODE
6685 AND cbet.expenditure_type = ITEM.expenditure_type
6686 )
6687 ;*/
6688
6689 -- Standard who
6690 x_last_updated_by NUMBER(15);
6691 x_last_update_login NUMBER(15);
6692 x_program_application_id NUMBER(15);
6693 x_program_id NUMBER(15);
6694 -- l_eid_tbl PA_PLSQL_DATATYPES.IdTabTyp; /*3040724*/
6695 l_limit_size NUMBER :=500 ; /*3040724*/
6696
6697 BEGIN
6698
6699 -- Initialize output parameters
6700 status := 0;
6701 stage := 100;
6702
6703 --
6704 -- Get the standard who information
6705 --
6706 x_last_updated_by := FND_GLOBAL.USER_ID;
6707 x_last_update_login := FND_GLOBAL.LOGIN_ID;
6708 x_request_id := FND_GLOBAL.CONC_REQUEST_ID;
6709 x_program_id := FND_GLOBAL.CONC_PROGRAM_ID;
6710 x_program_application_id := FND_GLOBAL.PROG_APPL_ID;
6711
6712 ei_count := 0;
6713 /*
6714 IF (cost_adj_reason IS NOT NULL)
6715 THEN
6716 begin
6717
6718 OPEN ei_cost_cursor;
6719 LOOP
6720
6721 l_eid_tbl.DELETE;
6722 FETCH ei_cost_cursor BULK COLLECT INTO l_eid_tbl
6723 LIMIT l_limit_size ;
6724
6725 IF l_eid_tbl.count = 0
6726 THEN
6727 EXIT;
6728 END IF;
6729
6730 FORALL i in 1..l_eid_tbl.count
6731 INSERT INTO pa_expend_item_adj_activities (
6732 expenditure_item_id
6733 , last_update_date
6734 , last_updated_by
6735 , creation_date
6736 , created_by
6737 , last_update_login
6738 , activity_date
6739 , exception_activity_code
6740 , module_code
6741 , request_id
6742 , program_application_id
6743 , program_id
6744 , program_update_date )
6745 VALUES (
6746 l_eid_tbl(i) -- expenditure_item_id
6747 , sysdate -- last_update_date
6748 , x_last_updated_by -- last_updated_by
6749 , sysdate -- creation_date
6750 , x_last_updated_by -- created_by
6751 , x_last_update_login -- last_update_login
6752 , sysdate -- activity_date
6753 , cost_adj_reason -- exception_activity_code
6754 , adj_module -- module_code
6755 , x_request_id -- request_id
6756 , x_program_application_id -- program_application_id
6757 , x_program_id -- program_id
6758 , sysdate ); -- program_update_date
6759
6760 EXIT WHEN ei_cost_cursor%NOTFOUND;
6761
6762 END LOOP;
6763 CLOSE ei_cost_cursor;
6764 EXCEPTION
6765 WHEN OTHERS THEN
6766 raise INSERT_ADJ_ACTIVITY_ERROR;
6767 end ;
6768 END IF ; ------ cost_adj_reason
6769
6770 IF (rev_adj_reason IS NOT NULL)
6771 THEN
6772 begin
6773
6774 OPEN ei_rev_cursor;
6775 LOOP
6776
6777 l_eid_tbl.DELETE;
6778 FETCH ei_rev_cursor BULK COLLECT INTO l_eid_tbl
6779 LIMIT l_limit_size ;
6780
6781 IF l_eid_tbl.count = 0
6782 THEN
6783 EXIT;
6784 END IF;
6785
6786 FORALL i in 1..l_eid_tbl.count
6787 INSERT INTO pa_expend_item_adj_activities (
6788 expenditure_item_id
6789 , last_update_date
6790 , last_updated_by
6791 , creation_date
6792 , created_by
6793 , last_update_login
6794 , activity_date
6795 , exception_activity_code
6796 , module_code
6797 , request_id
6798 , program_application_id
6799 , program_id
6800 , program_update_date )
6801 VALUES (
6802 l_eid_tbl(i) -- expenditure_item_id
6803 , sysdate -- last_update_date
6804 , x_last_updated_by -- last_updated_by
6805 , sysdate -- creation_date
6806 , x_last_updated_by -- created_by
6807 , x_last_update_login -- last_update_login
6808 , sysdate -- activity_date
6809 , rev_adj_reason -- exception_activity_code
6810 , adj_module -- module_code
6811 , x_request_id -- request_id
6812 , x_program_application_id -- program_application_id
6813 , x_program_id -- program_id
6814 , sysdate ); -- program_update_date
6815
6816 EXIT WHEN ei_rev_cursor%NOTFOUND;
6817 END LOOP;
6818 Close ei_rev_cursor;
6819 EXCEPTION
6820 WHEN OTHERS THEN
6821 raise INSERT_ADJ_ACTIVITY_ERROR;
6822 end ;
6823 END IF ; ------ rev_adj_reason
6824
6825 IF (inv_adj_reason IS NOT NULL)
6826 THEN
6827 begin
6828
6829 OPEN ei_inv_cursor;
6830 LOOP
6831
6832 l_eid_tbl.DELETE;
6833 FETCH ei_inv_cursor BULK COLLECT INTO l_eid_tbl
6834 LIMIT l_limit_size ;
6835
6836 IF l_eid_tbl.count = 0
6837 THEN
6838 EXIT;
6839 END IF;
6840
6841 FORALL i in 1..l_eid_tbl.count
6842 INSERT INTO pa_expend_item_adj_activities (
6843 expenditure_item_id
6844 , last_update_date
6845 , last_updated_by
6846 , creation_date
6847 , created_by
6848 , last_update_login
6849 , activity_date
6850 , exception_activity_code
6851 , module_code
6852 , request_id
6853 , program_application_id
6854 , program_id
6855 , program_update_date )
6856 VALUES (
6857 l_eid_tbl(i) -- expenditure_item_id
6858 , sysdate -- last_update_date
6859 , x_last_updated_by -- last_updated_by
6860 , sysdate -- creation_date
6861 , x_last_updated_by -- created_by
6862 , x_last_update_login -- last_update_login
6863 , sysdate -- activity_date
6864 , inv_adj_reason -- exception_activity_code
6865 , adj_module -- module_code
6866 , x_request_id -- request_id
6867 , x_program_application_id -- program_application_id
6868 , x_program_id -- program_id
6869 , sysdate ); -- program_update_date
6870
6871 EXIT WHEN ei_inv_cursor%NOTFOUND;
6872 END LOOP;
6873 Close ei_inv_cursor;
6874 EXCEPTION
6875 WHEN OTHERS THEN
6876 raise INSERT_ADJ_ACTIVITY_ERROR;
6877 end ;
6878 END IF ; ------ inv_adj_reason
6879
6880 IF (tp_adj_reason IS NOT NULL)
6881 THEN
6882 begin
6883
6884 OPEN ei_tp_cursor;
6885 LOOP
6886
6887 l_eid_tbl.DELETE;
6888 FETCH ei_tp_cursor BULK COLLECT INTO l_eid_tbl
6889 LIMIT l_limit_size ;
6890
6891 IF l_eid_tbl.count = 0
6892 THEN
6893 EXIT;
6894 END IF;
6895
6896 FORALL i in 1..l_eid_tbl.count
6897 INSERT INTO pa_expend_item_adj_activities (
6898 expenditure_item_id
6899 , last_update_date
6900 , last_updated_by
6901 , creation_date
6902 , created_by
6903 , last_update_login
6904 , activity_date
6905 , exception_activity_code
6906 , module_code
6907 , request_id
6908 , program_application_id
6909 , program_id
6910 , program_update_date )
6911 VALUES (
6912 l_eid_tbl(i) -- expenditure_item_id
6913 , sysdate -- last_update_date
6914 , x_last_updated_by -- last_updated_by
6915 , sysdate -- creation_date
6916 , x_last_updated_by -- created_by
6917 , x_last_update_login -- last_update_login
6918 , sysdate -- activity_date
6919 , tp_adj_reason -- exception_activity_code
6920 , adj_module -- module_code
6921 , x_request_id -- request_id
6922 , x_program_application_id -- program_application_id
6923 , x_program_id -- program_id
6924 , sysdate ); -- program_update_date
6925
6926 EXIT WHEN ei_tp_cursor%NOTFOUND;
6927 END LOOP;
6928 Close ei_tp_cursor;
6929 EXCEPTION
6930 WHEN OTHERS THEN
6931 raise INSERT_ADJ_ACTIVITY_ERROR;
6932 end ;
6933 END IF ; ------ tp_adj_reason
6934 */
6935 if l_expenditure_item_id_tab.count > 0 then
6936 FORALL i in 1..l_expenditure_item_id_tab.count
6937 INSERT INTO pa_expend_item_adj_activities (
6938 expenditure_item_id
6939 , last_update_date
6940 , last_updated_by
6941 , creation_date
6942 , created_by
6943 , last_update_login
6944 , activity_date
6945 , exception_activity_code
6946 , module_code
6947 , request_id
6948 , program_application_id
6949 , program_id
6950 , program_update_date )
6951 VALUES (
6952 l_expenditure_item_id_tab(i) -- expenditure_item_id
6953 , sysdate -- last_update_date
6954 , x_last_updated_by -- last_updated_by
6955 , sysdate -- creation_date
6956 , x_last_updated_by -- created_by
6957 , x_last_update_login -- last_update_login
6958 , sysdate -- activity_date
6959 , l_adj_type_tab(i) -- exception_activity_code
6960 , adj_module -- module_code
6961 , x_request_id -- request_id
6962 , x_program_application_id -- program_application_id
6963 , x_program_id -- program_id
6964 , sysdate ); -- program_update_date
6965 end if;
6966
6967 EXCEPTION
6968 when OTHERS then
6969 status := SQLCODE;
6970
6971 END add_adjustment_activity;
6972
6973
6974 --
6975 -- PROCEDURE
6976 -- disable_rate_sch_revision
6977 --
6978 -- PURPOSE
6979 -- The objective of this procedure is to mark the compiled sets
6980 -- as history for an out-of-date rate schedule revision.
6981 -- When the indirect cost multipliers are updated, the original
6982 -- compiled sets are out of date, and should be marked as history.
6983 --
6984 -- HISTORY
6985 --
6986 -- 10-JUN-94 S Lee Created
6987 --
6988 /****2933915 : Restructured this procedure to do Selective Obsoletion .
6989 Selective obsoletion implies that only those compiled set ids will be obsoleted
6990 for which the cost base is impacted i.e if any of the cost code is modified/deleted
6991 for any org . in a particular revision .
6992 If multipliers are present explicitly for any org for ALL the cost codes -that have
6993 not changed then we should not be obsoleting the compiled set id for this org/cost base .
6994 ************************************************************************************/
6995 procedure disable_rate_sch_revision(rate_sch_rev_id IN number,
6996 ver_id IN number, /*2933915**/
6997 org_id IN number, /**2933915**/
6998 status IN OUT NOCOPY number,
6999 stage IN OUT NOCOPY number)
7000
7001 is
7002
7003 CURSOR org_cursor
7004 IS
7005 SELECT organization_id_child org_id_child
7006 FROM per_org_structure_elements
7007 CONNECT BY PRIOR organization_id_child = organization_id_parent
7008 AND org_structure_version_id = ver_id
7009 START WITH organization_id_parent = org_id
7010 AND org_structure_version_id = ver_id
7011 UNION
7012 select org_id from dual ;
7013
7014 -- Standard who
7015 x_last_updated_by NUMBER(15);
7016 x_last_update_login NUMBER(15);
7017 x_request_id NUMBER(15);
7018 x_program_application_id NUMBER(15);
7019 x_program_id NUMBER(15);
7020 org_override NUMBER :=0;
7021 BEGIN
7022
7023 --
7024 -- Get the standard who information
7025 --
7026 x_last_updated_by := FND_GLOBAL.USER_ID;
7027 x_last_update_login := FND_GLOBAL.LOGIN_ID;
7028 x_request_id := FND_GLOBAL.CONC_REQUEST_ID;
7029 x_program_application_id := FND_GLOBAL.PROG_APPL_ID;
7030 x_program_id := FND_GLOBAL.CONC_PROGRAM_ID;
7031
7032 FOR org_id_rec in org_cursor /*Loop for all the children (including impacted org) of the impacted org*/
7033 LOOP
7034
7035 /*3016281 :If explicit multipliers are defined for all the cost codes in impacted cost bases for an org then we should not obsolete
7036 compiled set ids for that.
7037 This is in view of the enhancement that new compiled set ids will not be generated for an org if explicit multipliers are defined
7038 for all the cost codes in impacted cost bases for that org*/
7039
7040 IF pa_cost_plus.check_for_explicit_multiplier(rate_sch_rev_id ,org_id_rec.org_id_child) =0 THEN /*3016281*/
7041 --FOR cost_base_rec in impacted_cost_bases(rate_sch_rev_id)
7042 IF G_IMPACTED_COST_BASES_TAB.COUNT <> 0 THEN /*4590268*/
7043
7044 FOR i IN G_IMPACTED_COST_BASES_TAB.FIRST .. G_IMPACTED_COST_BASES_TAB.LAST
7045 LOOP
7046 UPDATE pa_ind_compiled_sets
7047 SET status = 'H',
7048 last_update_date = SYSDATE,
7049 last_updated_by = x_last_updated_by,
7050 last_update_login = x_last_update_login,
7051 request_id = x_request_id,
7052 program_application_id = x_program_application_id,
7053 program_id = x_program_id,
7054 program_update_date = SYSDATE
7055 WHERE ind_rate_sch_revision_id = rate_sch_rev_id
7056 AND organization_id = org_id_rec.org_id_child
7057 --AND cost_base = cost_base_rec.cost_base
7058 AND cost_base = G_IMPACTED_COST_BASES_TAB(i)
7059 AND status = 'A' ;
7060 END LOOP ; /*End of LOOP for impacted_cost_bases*/
7061 END IF; /*4590268*/
7062 END IF; /*3016281*/
7063 END LOOP; /*End of LOOP for Org_cursor*/
7064 EXCEPTION
7065 WHEN OTHERS THEN
7066 stage := 100;
7067 status := SQLCODE;
7068 END disable_rate_sch_revision;
7069
7070 --
7071 -- PROCEDURE
7072 -- disable_sch_rev_org
7073 --
7074 -- PURPOSE
7075 -- The objective of this procedure is to mark the compiled sets
7076 -- as history for the specified rate schedule revision and
7077 -- organization .
7078 --
7079 -- HISTORY
7080 --
7081 -- 25-AUG-94 S Lee Created
7082 --
7083
7084 procedure disable_sch_rev_org(rate_sch_rev_id IN number,
7085 org_id IN number,
7086 status IN OUT NOCOPY number,
7087 stage IN OUT NOCOPY number)
7088
7089 is
7090
7091 -- Standard who
7092 x_last_updated_by NUMBER(15);
7093 x_last_update_login NUMBER(15);
7094 x_request_id NUMBER(15);
7095 x_program_application_id NUMBER(15);
7096 x_program_id NUMBER(15);
7097
7098 BEGIN
7099
7100 --
7101 -- Get the standard who information
7102 --
7103 x_last_updated_by := FND_GLOBAL.USER_ID;
7104 x_last_update_login := FND_GLOBAL.LOGIN_ID;
7105 x_request_id := FND_GLOBAL.CONC_REQUEST_ID;
7106 x_program_application_id := FND_GLOBAL.PROG_APPL_ID;
7107 x_program_id := FND_GLOBAL.CONC_PROGRAM_ID;
7108
7109 --
7110 -- Set the compiled set to history
7111 --
7112 /*FOR cost_base_rec in impacted_cost_bases(rate_sch_rev_id) **2933915*/
7113 IF G_IMPACTED_COST_BASES_TAB.COUNT <> 0 THEN /*4590268*/
7114
7115 FOR i IN G_IMPACTED_COST_BASES_TAB.FIRST .. G_IMPACTED_COST_BASES_TAB.LAST
7116 LOOP
7117
7118 --
7119 -- Set the compiled set to history
7120 --
7121
7122 UPDATE pa_ind_compiled_sets
7123 SET status = 'H',
7124 last_update_date = SYSDATE,
7125 last_updated_by = x_last_updated_by,
7126 last_update_login = x_last_update_login,
7127 request_id = x_request_id,
7128 program_application_id = x_program_application_id,
7129 program_id = x_program_id,
7130 program_update_date = SYSDATE
7131 WHERE ind_rate_sch_revision_id = rate_sch_rev_id
7132 AND organization_id = org_id
7133 --AND cost_base = cost_base_rec.cost_base
7134 AND cost_base = G_IMPACTED_COST_BASES_TAB(i)
7135 AND status = 'A' ; /*2933915*/
7136
7137 END LOOP;
7138
7139 END IF; /*4590268*/
7140
7141 EXCEPTION
7142 WHEN OTHERS THEN
7143 stage := 100;
7144 status := SQLCODE;
7145
7146 END disable_sch_rev_org;
7147
7148
7149 procedure get_indirect_cost_amounts (x_indirect_cost_costing IN OUT NOCOPY number,
7150 x_indirect_cost_revenue IN OUT NOCOPY number,
7151 x_indirect_cost_invoice IN OUT NOCOPY number,
7152 x_task_id IN number,
7153 x_gl_date IN date,
7154 x_expenditure_type IN varchar2,
7155 x_organization_id IN number,
7156 x_direct_cost IN number,
7157 x_return_status IN OUT NOCOPY number,
7158 x_stage IN OUT NOCOPY number)
7159 is
7160 begin
7161
7162 --
7163 -- Get the costing indirect cost
7164 --
7165 pa_cost_plus.view_indirect_cost(
7166 NULL,
7167 'PA',
7168 x_task_id,
7169 x_gl_date,
7170 x_expenditure_type,
7171 x_organization_id,
7172 'C',
7173 x_direct_cost,
7174 x_indirect_cost_costing,
7175 x_return_status,
7176 x_stage);
7177
7178 /*
7179 if (x_return_status <> 0) then
7180 x_stage := x_stage + 1000;
7181 end if;
7182 */
7183
7184 if (x_return_status <> 0) then
7185 x_indirect_cost_costing := 0;
7186 end if;
7187
7188 --
7189 -- Get the revenue indirect cost
7190 --
7191 pa_cost_plus.view_indirect_cost(
7192 NULL,
7193 'PA',
7194 x_task_id,
7195 x_gl_date,
7196 x_expenditure_type,
7197 x_organization_id,
7198 'R',
7199 x_direct_cost,
7200 x_indirect_cost_revenue,
7201 x_return_status,
7202 x_stage);
7203
7204 /*
7205 if (x_return_status = NO_RATE_SCH_ID) then
7206 -- Acceptable. Reset the status
7207 x_indirect_cost_revenue := 0;
7208 x_return_status := 0;
7209 elsif (x_return_status <> 0) then
7210 x_stage := x_stage + 2000;
7211 return;
7212 end if;
7213 */
7214
7215 if (x_return_status <> 0) then
7216 x_indirect_cost_revenue := 0;
7217 end if;
7218
7219 --
7220 -- Get the invoice indirect cost
7221 --
7222 pa_cost_plus.view_indirect_cost(
7223 NULL,
7224 'PA',
7225 x_task_id,
7226 x_gl_date,
7227 x_expenditure_type,
7228 x_organization_id,
7229 'I',
7230 x_direct_cost,
7231 x_indirect_cost_invoice,
7232 x_return_status,
7233 x_stage);
7234
7235 /*
7236 if (x_return_status = NO_RATE_SCH_ID) then
7237 -- Acceptable. Reset the status
7238 x_indirect_cost_invoice := 0;
7239 x_return_status := 0;
7240 elsif (x_return_status <> 0) then
7241 x_stage := x_stage + 3000;
7242 return;
7243 end if;
7244 */
7245
7246 if (x_return_status <> 0) then
7247 x_indirect_cost_invoice := 0;
7248 end if;
7249
7250
7251 end get_indirect_cost_amounts;
7252
7253
7254
7255 procedure get_ind_rate_sch_rev(x_ind_rate_sch_name IN OUT NOCOPY varchar2,
7256 x_ind_rate_sch_revision IN OUT NOCOPY varchar2,
7257 x_ind_rate_sch_revision_type IN OUT NOCOPY varchar2,
7258 x_start_date_active IN OUT NOCOPY date,
7259 x_end_date_active IN OUT NOCOPY date,
7260 x_task_id IN number,
7261 x_gl_date IN date,
7262 x_detail_type_flag IN varchar2,
7263 x_expenditure_type IN varchar2,
7264 x_cost_base IN OUT NOCOPY varchar2,
7265 x_ind_compiled_set_id IN OUT NOCOPY number,
7266 x_organization_id IN number,
7267 x_return_status IN OUT NOCOPY number,
7268 x_stage IN OUT NOCOPY number)
7269 is
7270 x_rate_sch_rev_id number;
7271 x_sch_id number;
7272 x_sch_fixed_date date;
7273 x_cp_structure varchar2(30);
7274
7275 begin
7276
7277 x_return_status := 0;
7278 x_stage := 0;
7279
7280 pa_cost_plus.find_rate_sch_rev_id (NULL,
7281 'PA',
7282 x_task_id,
7283 x_detail_type_flag,
7284 x_gl_date,
7285 x_sch_id,
7286 x_rate_sch_rev_id,
7287 x_sch_fixed_date,
7288 x_return_status,
7289 x_stage);
7290 if (x_return_status > 0) then
7291 begin
7292 x_stage := 1;
7293 return;
7294 end;
7295 elsif (x_return_status < 0) then
7296 begin
7297 return;
7298 end;
7299 end if;
7300
7301
7302 begin
7303
7304 pa_cost_plus.get_cost_plus_structure(x_rate_sch_rev_id,
7305 x_cp_structure,
7306 x_return_status,
7307 x_stage);
7308
7309 pa_cost_plus.get_cost_base (x_expenditure_type,
7310 x_cp_structure,
7311 x_cost_base,
7312 x_return_status,
7313 x_stage);
7314 if (x_return_status > 0) then
7315 begin
7316 x_stage := 2;
7317 return;
7318 end;
7319 elsif (x_return_status < 0) then
7320 begin
7321 return;
7322 end;
7323 end if;
7324
7325 begin
7326 select ind_compiled_set_id
7327 into x_ind_compiled_set_id
7328 from pa_ind_compiled_sets
7329 where ind_rate_sch_revision_id = x_rate_sch_rev_id
7330 and organization_id = x_organization_id
7331 and status = 'A';
7332
7333 EXCEPTION
7334 WHEN NO_DATA_FOUND then
7335 x_stage := 3;
7336 x_return_status := 1;
7337 end;
7338
7339 begin
7340 select s.ind_rate_sch_name,
7341 sr.ind_rate_sch_revision,
7342 pl.meaning,
7343 sr.start_date_active,
7344 sr.end_date_active
7345 into x_ind_rate_sch_name,
7346 x_ind_rate_sch_revision,
7347 x_ind_rate_sch_revision_type,
7348 x_start_date_active,
7349 x_end_date_active
7350 from pa_ind_rate_schedules s,
7351 pa_ind_rate_sch_revisions sr,
7352 pa_lookups pl
7353 where s.ind_rate_sch_id = sr.ind_rate_sch_id
7354 and sr.ind_rate_sch_revision_type = pl.lookup_code
7355 and pl.lookup_type = 'IND RATE SCHEDULE REV TYPE'
7356 and sr.ind_rate_sch_revision_id = x_rate_sch_rev_id;
7357
7358 EXCEPTION
7359 WHEN NO_DATA_FOUND then
7360 if x_stage = 3 then
7361 x_stage := 3;
7362 else
7363 x_stage := 4;
7364 end if;
7365 x_return_status := 1;
7366 end;
7367
7368
7369 EXCEPTION
7370 WHEN NO_DATA_FOUND then
7371 x_return_status := 1;
7372
7373 WHEN OTHERS then
7374 x_return_status := SQLCODE;
7375 end;
7376
7377 end get_ind_rate_sch_rev;
7378
7379 /*
7380 Multi-Currency Related Changes:
7381 New procedure added to get the sum of the compiled multiplier.
7382 This multiplier is used to calculate the burden cost in all the currencies.
7383 */
7384
7385 PROCEDURE get_compiled_multiplier(P_Org_id IN NUMBER,
7386 P_C_base IN VARCHAR2,
7387 P_Rate_sch_rev_id IN NUMBER,
7388 P_Compiled_multiplier IN OUT NOCOPY NUMBER,
7389 P_Status IN OUT NOCOPY NUMBER,
7390 P_Stage IN OUT NOCOPY NUMBER)
7391
7392 IS
7393
7394 BEGIN
7395
7396 P_status := 0;
7397 P_stage := 100;
7398
7399 SELECT SUM(icpm.compiled_multiplier)
7400 INTO P_Compiled_multiplier
7401 FROM pa_ind_compiled_sets ics,
7402 pa_compiled_multipliers icpm
7403 WHERE ics.ind_rate_sch_revision_id = P_Rate_sch_rev_id
7404 AND ics.organization_id = P_Org_id
7405 AND ics.status = 'A'
7406 AND ics.ind_compiled_set_id = icpm.ind_compiled_set_id
7407 AND icpm.cost_base =ics.cost_base /*2933915*/
7408 AND icpm.cost_base = P_C_base;
7409
7410 if (P_compiled_multiplier is null) then
7411 P_Status := NO_DATA_FOUND_ERR;
7412 end if;
7413
7414 EXCEPTION
7415
7416 WHEN OTHERS THEN
7417 P_Status := SQLCODE;
7418
7419 END get_compiled_multiplier;
7420
7421 FUNCTION Get_Mltplr_For_Compiled_Set( P_Ind_Compiled_Set_Id IN NUMBER) RETURN NUMBER
7422 IS
7423 l_Compiled_Multiplier NUMBER;
7424 BEGIN
7425 /*
7426 * Here we sum up all the compiled multipliers against a compiled set, across
7427 * all cost-base/cost-code combinations to get the final multiplier
7428 * which can be applied on the raw-cost to get the burden cost.
7429 */
7430 SELECT SUM(icpm.compiled_multiplier)
7431 INTO l_Compiled_multiplier
7432 FROM pa_compiled_multipliers icpm
7433 WHERE icpm.ind_compiled_set_id = P_Ind_Compiled_Set_Id;
7434 /*
7435 * No Compiled Multipliers available for the compiled set, passed.
7436 * Raise no_data_found exception explicitly.
7437 */
7438 IF (l_Compiled_Multiplier IS NULL) THEN
7439 RAISE NO_DATA_FOUND;
7440 END IF;
7441 /*
7442 * Return compiled multiplier
7443 */
7444 RETURN(l_Compiled_Multiplier);
7445 EXCEPTION
7446 WHEN OTHERS THEN
7447 RAISE;
7448 END Get_Mltplr_For_Compiled_Set;
7449
7450 /************2933915 :New procedure to do Selective Deletion now *****************************************************/
7451 /*
7452 PROCEDURE
7453 delete_rate_sch_revision
7454
7455 PURPOSE
7456 The objective of this procedure is to delete only the
7457 impacted compiled sets i.e for impacted organizations and impacted cost bases ,
7458 for which no ei exists . */
7459 /***********************************************************************************************************************/
7460 procedure delete_rate_sch_revision(rate_sch_rev_id IN number,
7461 ver_id IN number,
7462 org_id IN number,
7463 status IN OUT NOCOPY number,
7464 stage IN OUT NOCOPY number)
7465
7466 is
7467 CURSOR org_cursor
7468 IS
7469 SELECT organization_id_child org_id_child
7470 FROM per_org_structure_elements
7471 CONNECT BY PRIOR organization_id_child = organization_id_parent
7472 AND org_structure_version_id = ver_id
7473 START WITH organization_id_parent = org_id
7474 AND org_structure_version_id = ver_id
7475 UNION
7476 select org_id from dual ;
7477
7478 BEGIN
7479 --
7480 -- Remove redundant compiled sets and multipiers.
7481 --
7482 FOR ORG_REC in ORG_CURSOR
7483 LOOP
7484 FOR cost_base_rec in impacted_cost_bases(rate_sch_rev_id)
7485 LOOP
7486
7487 /* S.N. Bug 3946409
7488
7489 DELETE pa_compiled_multipliers
7490 WHERE ind_compiled_set_id IN
7491 (SELECT ind_compiled_set_id
7492 FROM pa_ind_compiled_sets
7493 WHERE ind_rate_sch_revision_id = rate_sch_rev_id
7494 and organization_id = ORG_REC.org_id_child
7495 and cost_base = cost_base_rec.cost_base) ;
7496
7497 E.N. Bug 3946409 */
7498
7499 /* Bug# 4527736
7500 DELETE pa_ind_compiled_sets
7501 WHERE ind_rate_sch_revision_id = rate_sch_rev_id
7502 and organization_id =ORG_REC.org_id_child
7503 and cost_base =G_IMPACTED_COST_BASES_TAB(i)
7504 Bug# 4527736 */
7505 NULL;
7506
7507 END LOOP ;
7508 END LOOP ;
7509 EXCEPTION
7510 WHEN OTHERS THEN
7511 stage := 100;
7512 status := SQLCODE;
7513
7514 END delete_rate_sch_revision;
7515
7516
7517 /*****************2933915 :New procedure to find the impacted top orgs******************************************
7518
7519 PROCEDURE
7520 find_impacted_top_org
7521
7522 PURPOSE
7523 The objective of this procedure is to find the highest
7524 organizations with ready_to_compile_flag as 'Y'
7525 in pa_ind_cost_multipliers .
7526 This is to ensure that compilation starts from highest impacted orgs rather than from Start_org
7527 ***************************************************************************************************************/
7528
7529 procedure find_impacted_top_org(rate_sch_rev_id IN number,
7530 ver_id IN number ,
7531 start_org IN number ,
7532 org_tab OUT NOCOPY org_tab_type,
7533 status IN OUT NOCOPY number)
7534
7535 is
7536
7537 /*Cursor to select distinct organizations having ready_to_compile_flag as 'Y' */
7538 Cursor ready_to_compile_orgs is
7539 select DISTINCT organization_id
7540 from pa_ind_cost_multipliers
7541 where ind_rate_sch_revision_id = rate_sch_rev_id
7542 and nvl(ready_to_compile_flag,'N') in ('Y','X') ;
7543
7544 l_count NUMBER ;
7545 l_parent NUMBER ;
7546 i NUMBER :=1 ;
7547
7548 BEGIN
7549
7550 FOR org in ready_to_compile_orgs LOOP
7551 BEGIN
7552
7553 SELECT count(a.organization_id_parent)
7554 into l_count FROM
7555 ( SELECT organization_id_parent
7556 FROM per_org_structure_elements
7557 CONNECT BY PRIOR organization_id_parent = organization_id_child
7558 AND org_structure_version_id = ver_id
7559 START WITH organization_id_child = org.organization_id
7560 AND org_structure_version_id = ver_id) a
7561 WHERE a.organization_id_parent in (select DISTINCT organization_id
7562 from pa_ind_cost_multipliers
7563 where ind_rate_sch_revision_id = rate_sch_rev_id
7564 and nvl(ready_to_compile_flag,'N') in ('Y','X') );
7565
7566
7567 if (l_count =0 ) then
7568
7569 l_parent := org.organization_id ;
7570
7571 /*There will not be many records in this table since we are storing only the top impacted org in this after
7572 full traversal of one branch(starting from start org till last child i.e leaf node) -so looping through the
7573 table should be OK */
7574
7575 org_tab(i) := l_parent;
7576
7577
7578
7579 /* If at any point of finding top org we come across any org that is same as start org then no need to
7580 process remaining orgs in cursor ready_to_compile_orgs since we have reached start org so that means
7581 compilation has to start from stat org itself. */
7582
7583 If l_parent = start_org then
7584 status :=0 ;
7585 EXIT ;
7586 End if ;
7587 i:=i +1 ;
7588 elsif (l_count =1 ) then
7589
7590 SELECT b.organization_id_parent
7591 into l_parent
7592 FROM (SELECT organization_id_parent
7593 FROM per_org_structure_elements
7594 CONNECT BY PRIOR organization_id_parent = organization_id_child
7595 AND org_structure_version_id = ver_id
7596 START WITH organization_id_child = org.organization_id
7597 AND org_structure_version_id = ver_id) b
7598 WHERE b.organization_id_parent in (select DISTINCT organization_id
7599 from pa_ind_cost_multipliers
7600 where ind_rate_sch_revision_id = rate_sch_rev_id
7601 and nvl(ready_to_compile_flag,'N') in ('Y','X'));
7602
7603 /*There will not be many records in this table since we are storing only the top impacted org in this after full traversal of one
7604 branch (starting from start org till last child i.e leaf node) -so looping through the table should be OK */
7605
7606
7607 org_tab(i) := l_parent;
7608
7609
7610 /* If at any point of finding top org we come across any org that is same as start org then no need to process
7611 remaining orgs in cursor ready_to_compile_orgs since we have reached start org so that means compilation has to start
7612 from stat org itself. */
7613
7614 If l_parent = start_org then
7615 status :=0 ;
7616 EXIT ;
7617 End if ;
7618
7619 i:=i+1 ;
7620 End if ;
7621
7622
7623 EXCEPTION
7624 WHEN OTHERS THEN
7625 status := SQLCODE;
7626 END ;
7627 END LOOP ;
7628 END find_impacted_top_org ;
7629
7630 /*3016281 :Added this new function to check (and return 1 else 0 ) if explicit multipliers are defined for all the
7631 cost codes in impacted cost bases for an org .
7632 This is to implement the functionality that in the above mentioned case compiled set ids should neither be obsoleted
7633 nor generated for an org. */
7634
7635 FUNCTION check_for_explicit_multiplier(rate_sch_rev_id IN NUMBER,org_id IN NUMBER) RETURN NUMBER
7636 IS
7637 org_override NUMBER :=0;
7638 l_org_id_parent NUMBER(15) DEFAULT 0; /* Bug 4739218 */
7639
7640 /*
7641 * Repalced with the below sql. Hari 19-JUL-05.
7642 CURSOR impacted_cost_code_cur(x_base VARCHAR2) **Cursor for all the cost codes of impacted cost bases**
7643 IS
7644 SELECT distinct cbicc.ind_cost_code
7645 FROM pa_cost_base_cost_codes cbicc,
7646 pa_ind_rate_sch_revisions irsr
7647 WHERE irsr.ind_rate_sch_revision_id = rate_sch_rev_id
7648 AND irsr.cost_plus_structure = cbicc.cost_plus_structure
7649 AND cbicc.cost_base = x_base
7650 AND cbicc.cost_base_type = INDIRECT_COST_CODE ;
7651 */
7652 CURSOR impacted_cost_code_cur(x_base VARCHAR2) /*Cursor for all the cost codes of impacted cost bases*/
7653 IS
7654 SELECT distinct cbicc.ind_cost_code
7655 FROM pa_cost_base_cost_codes cbicc
7656 WHERE cbicc.cost_plus_structure = G_CP_STRUCTURE
7657 AND cbicc.cost_base = x_base
7658 AND cbicc.cost_base_type = INDIRECT_COST_CODE ;
7659
7660 BEGIN
7661
7662 /* S.N. Bug 3938479 */
7663
7664 /* bug 14330754 */
7665 --IF rate_sch_rev_id = g_rate_sch_rev_id AND org_id = g_org_id Then
7666
7667 hashkey := rate_sch_rev_id||'-'||org_id ;
7668 if (g_org_override_tab.exists(hashkey)) then
7669
7670 g_org_override := G_org_override_tab(HASHKEY);
7671
7672 org_override := g_org_override;
7673 RETURN org_override;
7674
7675 ELSE
7676
7677 g_rate_sch_rev_id := rate_sch_rev_id;
7678 g_org_id := org_id ;
7679
7680 /* E.N. Bug 3938479 */
7681
7682
7683 /*FOR cost_base_rec in impacted_cost_bases(rate_sch_rev_id) **Loop for impacted cost bases*/
7684 IF G_IMPACTED_COST_BASES_TAB.COUNT <> 0 THEN /*4590268*/
7685
7686 FOR i in G_IMPACTED_COST_BASES_TAB.FIRST .. G_IMPACTED_COST_BASES_TAB.LAST
7687 LOOP
7688 --FOR cost_code_rec in impacted_cost_code_cur(cost_base_rec.cost_base)
7689 FOR cost_code_rec in impacted_cost_code_cur(G_IMPACTED_COST_BASES_TAB(i))
7690
7691 LOOP
7692 BEGIN
7693 /* Modified for 14330754
7694 select 1 into org_override
7695 from sys.dual
7696 where exists(*/
7697 select /*+ use_nl(ICS) */ 1 into org_override
7698 from pa_ind_cost_multipliers icm ,
7699 pa_ind_compiled_sets ics
7700 where icm.ind_rate_sch_revision_id =ics.ind_rate_sch_revision_id
7701 and icm.ind_rate_sch_revision_id = rate_sch_rev_id
7702 AND icm.organization_id =ics.organization_id
7703 and icm.organization_id = org_id
7704 --AND ics.cost_base = cost_base_rec.cost_base
7705 AND ics.cost_base = G_IMPACTED_COST_BASES_TAB(i)
7706 AND ics.status ='A'
7707 and icm.ind_cost_code = cost_code_rec.ind_cost_code
7708 and nvl(icm.ready_to_compile_flag,'N') ='N'
7709 and ROWNUM=1;
7710 /*Ready_to_compile_flag 'N' means unchanged so will check for this only*/
7711
7712 /* bug 14330754 */
7713 hashkey := rate_sch_rev_id||'-'||org_id ;
7714 G_org_override_tab(hashkey):= org_override;
7715
7716 EXCEPTION
7717 WHEN NO_DATA_FOUND THEN
7718 BEGIN /* Code change for Bug 4739218 Starts */
7719 --Bug 10057189 Rewriting the below SQL for performance tuning
7720 /*select 0 into org_override
7721 from sys.dual
7722 where exists
7723 (
7724 select 1
7725 from pa_ind_cost_multipliers icm ,
7726 pa_ind_compiled_sets ics
7727 where icm.ind_rate_sch_revision_id =ics.ind_rate_sch_revision_id
7728 and icm.ind_rate_sch_revision_id = rate_sch_rev_id
7729 and icm.organization_id =ics.organization_id
7730 and icm.organization_id = org_id
7731 and nvl(icm.ready_to_compile_flag,'N') <> 'N'
7732 );*/
7733 SELECT /*+ use_nl(ICS) */ 0
7734 INTO org_override
7735 FROM PA_IND_COST_MULTIPLIERS ICM ,
7736 PA_IND_COMPILED_SETS ICS
7737 WHERE ICM.IND_RATE_SCH_REVISION_ID = ICS.IND_RATE_SCH_REVISION_ID
7738 AND ICM.IND_RATE_SCH_REVISION_ID = RATE_SCH_REV_ID
7739 AND ICM.ORGANIZATION_ID =ICS.ORGANIZATION_ID
7740 AND ICM.ORGANIZATION_ID = ORG_ID
7741 AND NVL(ICM.READY_TO_COMPILE_FLAG,'N') <> 'N'
7742 AND ROWNUM = 1; --Bug 10057189
7743
7744 /* bug 14330754 */
7745 hashkey := rate_sch_rev_id||'-'||org_id ;
7746 g_org_override_tab(hashkey):= org_override;
7747
7748 /*If explicit multipliers exists and got changed then org_overrride = 0 */
7749 EXIT;
7750 EXCEPTION
7751 WHEN NO_DATA_FOUND THEN
7752 BEGIN
7753 SELECT organization_id_parent into l_org_id_parent
7754 FROM per_org_structure_elements
7755 WHERE organization_id_child = org_id
7756 AND org_structure_version_id = G_ORG_STRUC_VER_ID;
7757 org_override := check_for_explicit_multiplier(rate_sch_rev_id, l_org_id_parent);
7758
7759 /* bug 14330754 */
7760 hashkey := rate_sch_rev_id||'-'||l_org_id_parent ;
7761 G_org_override_tab(hashkey):= org_override;
7762
7763 return org_override;
7764 EXCEPTION
7765 WHEN NO_DATA_FOUND THEN
7766 org_override := 1 ;/* This is the start_org and explicit multiplier are not defined */
7767 /* bug 14330754 */
7768 hashkey := rate_sch_rev_id||'-'||org_id ;
7769 G_org_override_tab(hashkey):= org_override;
7770 return org_override;
7771 WHEN OTHERS THEN
7772 RAISE;
7773 END;
7774 END; /*Code change for Bug 4739218 Ends */
7775 END;
7776 END LOOP;
7777
7778 If org_override =0 THEN
7779 /* bug 14330754 */
7780 hashkey := rate_sch_rev_id||'-'||org_id ;
7781 G_org_override_tab(hashkey):= org_override;
7782 EXIT;
7783 END IF;
7784 END LOOP;
7785 END IF; -- G_IMPACTED_COST_BASES_TAB.COUNT <> 0 THEN /*4590268*/
7786
7787 END IF ;/* Bug 3938479 */
7788
7789 g_org_override := org_override; /* Bug 3938479 */
7790 RETURN org_override;
7791
7792 EXCEPTION
7793 WHEN OTHERS THEN
7794 RAISE;
7795 END check_for_explicit_multiplier ; /*3012681*/
7796
7797 PROCEDURE Cache_Impacted_Cost_Bases ( P_Ind_Rate_Sch_Revision_Id IN PA_IND_RATE_SCH_REVISIONS.IND_RATE_SCH_REVISION_ID%TYPE
7798 ,P_Cp_Structure IN PA_COST_PLUS_STRUCTURES.COST_PLUS_STRUCTURE%TYPE
7799 )
7800 IS
7801 CURSOR impacted_cost_bases_cur( P_Ind_Rate_Sch_Revision_Id PA_IND_RATE_SCH_REVISIONS.IND_RATE_SCH_REVISION_ID%TYPE
7802 ,P_Cp_Structure PA_COST_PLUS_STRUCTURES.COST_PLUS_STRUCTURE%TYPE
7803 )
7804 IS
7805 SELECT pcb.COST_BASE
7806 FROM PA_COST_BASES pcb
7807 WHERE pcb.COST_BASE_TYPE = INDIRECT_COST_CODE
7808 AND nvl(G_MODULE ,'XXX') <> 'NEW_ORG' /*4870539*/
7809 AND EXISTS
7810 (
7811 SELECT 1
7812 FROM PA_COST_BASE_COST_CODES CBICC,
7813 PA_IND_COST_MULTIPLIERS ICM
7814 WHERE ICM.IND_RATE_SCH_REVISION_ID = P_Ind_Rate_Sch_Revision_Id
7815 AND (NVL(ICM.READY_TO_COMPILE_FLAG,'N') IN ('Y','X') AND NVL(G_MODULE ,'XXX') <> 'NEW_ORG')/*4870539*/
7816 AND CBICC.COST_PLUS_STRUCTURE = P_Cp_Structure
7817 AND CBICC.IND_COST_CODE = ICM.IND_COST_CODE
7818 AND CBICC.COST_BASE = PCB.COST_BASE
7819 AND CBICC.COST_BASE_TYPE = PCB.COST_BASE_TYPE )
7820 UNION /*4870539 :Added union*/
7821 SELECT pcb.COST_BASE
7822 FROM PA_COST_BASES pcb
7823 WHERE pcb.COST_BASE_TYPE = INDIRECT_COST_CODE
7824 AND nvl(G_MODULE ,'XXX') = 'NEW_ORG'
7825 AND EXISTS
7826 (
7827 SELECT 1
7828 FROM PA_COST_BASE_COST_CODES CBICC,
7829 PA_IND_rate_sch_revisions IRSR
7830 WHERE IRSR.IND_RATE_SCH_REVISION_ID = P_Ind_Rate_Sch_Revision_Id
7831 AND nvl(G_MODULE ,'XXX') = 'NEW_ORG'
7832 AND IRSR.COST_PLUS_STRUCTURE= CBICC.COST_PLUS_STRUCTURE
7833 AND CBICC.COST_PLUS_STRUCTURE = P_Cp_Structure
7834 AND CBICC.COST_BASE = PCB.COST_BASE
7835 AND CBICC.COST_BASE_TYPE = PCB.COST_BASE_TYPE ); /*End of changes for 4870539*/
7836 BEGIN
7837
7838 G_IMPACTED_COST_BASES_TAB.DELETE;
7839 OPEN impacted_cost_bases_cur (P_Ind_Rate_Sch_Revision_Id,P_Cp_Structure);
7840 FETCH impacted_cost_bases_cur BULK COLLECT INTO G_IMPACTED_COST_BASES_TAB;
7841 CLOSE impacted_cost_bases_cur;
7842
7843 END Cache_Impacted_Cost_Bases;
7844
7845 /* Added this procedure for bug 9643997. The procedure deletes dangling
7846 C or D lines, for which the creation of the other counterpart line ( D or C) had
7847 failed because of any reason */
7848
7849 PROCEDURE validate_CrDr_lines ( p_request_id IN NUMBER
7850 ,x_return_status OUT NOCOPY NUMBER
7851 ,x_error_code OUT NOCOPY VARCHAR2
7852 ,x_error_stage OUT NOCOPY NUMBER
7853 ) IS
7854 g_request_id NUMBER;
7855 l_stage NUMBER;
7856
7857 BEGIN
7858 g_request_id := p_request_id;
7859 x_return_status := 0;
7860 l_stage := 100;
7861 DELETE
7862 FROM pa_cost_distribution_lines cdl
7863 WHERE cdl.line_type IN ('C', 'D')
7864 AND cdl.request_id = g_request_id
7865 AND cdl.expenditure_item_id in (Select
7866 ei.expenditure_item_id from pa_expenditure_items ei
7867 where ei.cost_burden_distributed_flag = 'S'
7868 and ei.ind_cost_dist_rejection_code IS NOT NULL);
7869 EXCEPTION
7870 WHEN OTHERS
7871 THEN
7872 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7873 x_error_code := TO_CHAR(SQLCODE) || SQLERRM ;
7874 x_error_stage := l_stage ;
7875 RAISE;
7876
7877 END validate_CrDr_lines;
7878
7879 end PA_COST_PLUS ;