DBA Data[Home] [Help]

PACKAGE BODY: APPS.PJI_FM_PLAN_CAL_RLPS_T

Source


1 PACKAGE BODY PJI_FM_PLAN_CAL_RLPS_T AS
2 /* $Header: PJIPP05B.pls 120.8.12000000.2 2007/07/25 10:57:49 bifernan ship $ */
3 
4 
5 g_package_name      VARCHAR2(100) := 'PJI_FM_PLAN_CAL_RLPS_T';
6 
7 g_worker_id         NUMBER        := 1; -- PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
8 g_default_prg_level NUMBER        := 0;
9 
10 
11 PROCEDURE PRINT_TIME(p_tag IN VARCHAR2);
12 
13 
14 
15 PROCEDURE CREATE_FP_PA_ROLLUP IS -- Public
16 BEGIN
17   CREATE_FP_PA_PRI_ROLLUP ;
18 EXCEPTION
19   WHEN OTHERS THEN
20     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
21                              p_procedure_name => 'CREATE_FP_PA_ROLLUP');
22     RAISE;
23 END;
24 
25 
26 PROCEDURE CREATE_FP_GL_ROLLUP IS -- Public
27 BEGIN
28   CREATE_FP_GL_PRI_ROLLUP ;
29 EXCEPTION
30   WHEN OTHERS THEN
31     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
32                              p_procedure_name => 'CREATE_FP_GL_ROLLUP');
33     RAISE;
34 END;
35 
36 PROCEDURE CREATE_FP_NONTP_ROLLUP IS -- Public. Not needed.
37 BEGIN
38   NULL;
39 EXCEPTION
40   WHEN OTHERS THEN
41     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
42                              p_procedure_name => 'CREATE_FP_NONTP_ROLLUP');
43     RAISE;
44 END;
45 
46 
47 PROCEDURE CREATE_FP_ENT_ROLLUP IS -- Public
48 BEGIN
49 
50   -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
51 
52   INSERT INTO PJI_FP_AGGR_PJP1_T
53   (
54        WORKER_ID
55      , PROJECT_ID
56      , PROJECT_ORG_ID
57      , PROJECT_ORGANIZATION_ID
58      , PROJECT_ELEMENT_ID
59      , TIME_ID
60      , PERIOD_TYPE_ID
61      , CALENDAR_TYPE
62      , RBS_AGGR_LEVEL
63      , WBS_ROLLUP_FLAG
64      , PRG_ROLLUP_FLAG
65      , CURR_RECORD_TYPE_ID
66      , CURRENCY_CODE
67      , RBS_ELEMENT_ID
68      , RBS_VERSION_ID
69      , PLAN_VERSION_ID
70      , PLAN_TYPE_ID
71      , RAW_COST
72      , BRDN_COST
73      , REVENUE
74      , BILL_RAW_COST
75      , BILL_BRDN_COST
76      , BILL_LABOR_RAW_COST
77      , BILL_LABOR_BRDN_COST
78      , BILL_LABOR_HRS
79      , EQUIPMENT_RAW_COST
80      , EQUIPMENT_BRDN_COST
81      , CAPITALIZABLE_RAW_COST
82      , CAPITALIZABLE_BRDN_COST
83      , LABOR_RAW_COST
84      , LABOR_BRDN_COST
85      , LABOR_HRS
86      , LABOR_REVENUE
87      , EQUIPMENT_HOURS
88      , BILLABLE_EQUIPMENT_HOURS
89      , SUP_INV_COMMITTED_COST
90      , PO_COMMITTED_COST
91      , PR_COMMITTED_COST
92      , OTH_COMMITTED_COST
93        , ACT_LABOR_HRS
94 	   , ACT_EQUIP_HRS
95 	   , ACT_LABOR_BRDN_COST
96 	   , ACT_EQUIP_BRDN_COST
97 	   , ACT_BRDN_COST
98 	   , ACT_RAW_COST
99 	   , ACT_REVENUE
100          , ACT_LABOR_RAW_COST
101          , ACT_EQUIP_RAW_COST
102 	   , ETC_LABOR_HRS
103 	   , ETC_EQUIP_HRS
104 	   , ETC_LABOR_BRDN_COST
105 	   , ETC_EQUIP_BRDN_COST
106 	   , ETC_BRDN_COST
107          , ETC_RAW_COST
108          , ETC_LABOR_RAW_COST
109          , ETC_EQUIP_RAW_COST
110      , CUSTOM1
111      , CUSTOM2
112      , CUSTOM3
113      , CUSTOM4
114      , CUSTOM5
115      , CUSTOM6
116      , CUSTOM7
117      , CUSTOM8
118      , CUSTOM9
119      , CUSTOM10
120      , CUSTOM11
121      , CUSTOM12
122      , CUSTOM13
123      , CUSTOM14
124      , CUSTOM15
125      , LINE_TYPE
126      , PRG_LEVEL
127      , PLAN_TYPE_CODE   /* 4471527 */
128   )
129   SELECT * FROM (
130   SELECT
131       g_worker_id
132     , fact1.PROJECT_ID
133     , fact1.PROJECT_ORG_ID
134     , fact1.PROJECT_ORGANIZATION_ID
135     , fact1.PROJECT_ELEMENT_ID
136     , DECODE (
137                (grouping(qtr.ENT_YEAR_ID) || grouping(period.ENT_QTR_ID) || grouping(period.ENT_PERIOD_ID) )
138              , '000', period.ENT_PERIOD_ID
139              , '001', period.ENT_QTR_ID
140              , '011', qtr.ENT_YEAR_ID
141              , '111', -1 ) TIME_ID
142     , DECODE (
143                (grouping(qtr.ENT_YEAR_ID) || grouping(period.ENT_QTR_ID) || grouping(period.ENT_PERIOD_ID) )
144              , '000', 32
145              , '001', 64
146              , '011', 128
147              , '111', 2048 ) PERIOD_TYPE_ID
148     , DECODE (
149                grouping(qtr.ENT_YEAR_ID)
150              , 0 , 'E'
151              , 'A') CALENDAR_TYPE
152     , RBS_AGGR_LEVEL
153     , WBS_ROLLUP_FLAG
154     , PRG_ROLLUP_FLAG
155     , fact1.CURR_RECORD_TYPE_ID
156     , fact1.CURRENCY_CODE
157     , fact1.RBS_ELEMENT_ID
158     , fact1.RBS_VERSION_ID
159     , fact1.PLAN_VERSION_ID
160     , fact1.plan_type_id
161     , SUM(fact1.RAW_COST)
162     , SUM(fact1.BRDN_COST)
163     , SUM(fact1.REVENUE)
164     , SUM(fact1.BILL_RAW_COST)
165     , SUM(fact1.BILL_BRDN_COST )
166     , SUM(fact1.BILL_LABOR_RAW_COST)
167     , SUM(fact1.BILL_LABOR_BRDN_COST )
168     , SUM(fact1.BILL_LABOR_HRS )
169     , SUM(fact1.EQUIPMENT_RAW_COST )
170     , SUM(fact1.EQUIPMENT_BRDN_COST )
171     , SUM(fact1.CAPITALIZABLE_RAW_COST )
172     , SUM(fact1.CAPITALIZABLE_BRDN_COST )
173     , SUM(fact1.LABOR_RAW_COST )
174     , SUM(fact1.LABOR_BRDN_COST )
175     , SUM(fact1.LABOR_HRS)
176     , SUM(fact1.LABOR_REVENUE)
177     , SUM(fact1.EQUIPMENT_HOURS)
178     , SUM(fact1.BILLABLE_EQUIPMENT_HOURS)
179     , SUM(fact1.SUP_INV_COMMITTED_COST)
180     , SUM(fact1.PO_COMMITTED_COST   )
181     , SUM(fact1.PR_COMMITTED_COST  )
182     , SUM(fact1.OTH_COMMITTED_COST)
183        , SUM(fact1.ACT_LABOR_HRS)
184 	 , SUM(fact1.ACT_EQUIP_HRS)
185 	 , SUM(fact1.ACT_LABOR_BRDN_COST)
186 	 , SUM(fact1.ACT_EQUIP_BRDN_COST)
187 	 , SUM(fact1.ACT_BRDN_COST)
188 	 , SUM(fact1.ACT_RAW_COST)
189 	 , SUM(fact1.ACT_REVENUE)
190        , SUM(fact1.ACT_LABOR_RAW_COST)
191        , SUM(fact1.ACT_EQUIP_RAW_COST)
192 	 , SUM(fact1.ETC_LABOR_HRS)
193 	 , SUM(fact1.ETC_EQUIP_HRS)
194 	 , SUM(fact1.ETC_LABOR_BRDN_COST)
195 	 , SUM(fact1.ETC_EQUIP_BRDN_COST)
196 	 , SUM(fact1.ETC_BRDN_COST )
197        , SUM(fact1.ETC_RAW_COST )
198        , SUM(fact1.ETC_LABOR_RAW_COST)
199        , SUM(fact1.ETC_EQUIP_RAW_COST)
200     , SUM(CUSTOM1	)
201     , SUM(CUSTOM2	)
202     , SUM(CUSTOM3	)
203     , SUM(CUSTOM4	)
204     , SUM(CUSTOM5	)
205     , SUM(CUSTOM6	)
206     , SUM(CUSTOM7	)
207     , SUM(CUSTOM8	)
208     , SUM(CUSTOM9	)
209     , SUM(CUSTOM10	)
210     , SUM(CUSTOM11	)
211     , SUM(CUSTOM12	)
212     , SUM(CUSTOM13	)
213     , SUM(CUSTOM14	)
214     , SUM(CUSTOM15)
215     , 'ENTR'
216     , g_default_prg_level prg_level
217     , fact1.PLAN_TYPE_CODE PLAN_TYPE_CODE   /* 4471527 */
218     FROM
219 	  PJI_FP_AGGR_PJP1_T fact1  -- ,  PJI_FM_EXTR_PLNVER3_T ver
220       , pji_time_ENT_PERIOD period
221 	, pji_time_ENT_QTR    qtr
222     , pji_fm_extr_plnver3_t  ver
223     WHERE
224         fact1.calendar_type = 'E'
225     AND period.ENT_period_id = fact1.time_id
226     AND period.ENT_qtr_id = qtr.ENT_qtr_id
227     AND fact1.period_type_id = 32
228     AND fact1.worker_id = g_worker_id
229    -- AND fact1.rbs_version_id IN (ver.rbs_struct_version_id, -1)   /* 4632551 */
230     AND NVL(ver.rbs_struct_version_id, -1) = fact1.rbs_version_id
231     -- AND ver.secondary_rbs_flag = 'N'
232     AND fact1.plan_version_id = ver.plan_version_id
233     AND fact1.plan_type_code = ver.plan_type_code    /* 4471527 */
234 	GROUP BY
235  	  fact1.PROJECT_ID
236     , fact1.PROJECT_ORG_ID
237     , fact1.PROJECT_ORGANIZATION_ID
238     , fact1.PROJECT_ELEMENT_ID
239     , fact1.calendar_type
240     , RBS_AGGR_LEVEL
241     , WBS_ROLLUP_FLAG
242     , PRG_ROLLUP_FLAG
243     , fact1.CURR_RECORD_TYPE_ID
244     , fact1.CURRENCY_CODE
245     , fact1.RBS_ELEMENT_ID
246     , fact1.RBS_VERSION_ID
247     , fact1.PLAN_VERSION_ID
248     , fact1.plan_type_id
249     , fact1.plan_type_code    /* 4471527 */
250     , rollup (qtr.ENT_YEAR_ID,
251               period.ENT_QTR_ID,
252               period.ENT_PERIOD_ID))
253    WHERE period_type_id > 32
254      AND period_type_id < 2048;
255 
256 EXCEPTION
257   WHEN OTHERS THEN
258     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
259                              p_procedure_name => 'CREATE_FP_ENT_ROLLUP');
260     RAISE;
261 END;
262 
263 
264 PROCEDURE CREATE_FP_PA_PRI_ROLLUP (
265   p_honor_rbs  IN VARCHAR2 := 'Y'
266 ) IS
267 
268     -- l_last_update_date     date   := SYSDATE;
269     -- l_last_updated_by      NUMBER := FND_GLOBAL.USER_ID;
270     -- l_creation_date        date   := SYSDATE;
271     -- l_created_by           NUMBER := FND_GLOBAL.USER_ID;
272     -- l_last_update_login    NUMBER := FND_GLOBAL.LOGIN_ID;
273     l_calendar_type        VARCHAR2(15) := 'P';
274     l_line_type            VARCHAR2(15) := 'PAR';
275 
276 BEGIN
277 
278   -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
279 
280   INSERT INTO pji_fp_aggr_pjp1_t
281   (
282          WORKER_ID
283        , PROJECT_ID
284        , PROJECT_ORG_ID
285        , PROJECT_ORGANIZATION_ID
286        , PROJECT_ELEMENT_ID
287        , TIME_ID
288        , PERIOD_TYPE_ID
289        , CALENDAR_TYPE
290        , RBS_AGGR_LEVEL
291        , WBS_ROLLUP_FLAG
292        , PRG_ROLLUP_FLAG
293        , CURR_RECORD_TYPE_ID
294        , CURRENCY_CODE
295        , RBS_ELEMENT_ID
296        , RBS_VERSION_ID
297        , PLAN_VERSION_ID
298        , PLAN_TYPE_ID
299        , RAW_COST
300        , BRDN_COST
301        , REVENUE
302        , BILL_RAW_COST
303        , BILL_BRDN_COST
304        , BILL_LABOR_RAW_COST
305        , BILL_LABOR_BRDN_COST
306        , BILL_LABOR_HRS
307        , EQUIPMENT_RAW_COST
308        , EQUIPMENT_BRDN_COST
309        , CAPITALIZABLE_RAW_COST
310        , CAPITALIZABLE_BRDN_COST
311        , LABOR_RAW_COST
312        , LABOR_BRDN_COST
313        , LABOR_HRS
314        , LABOR_REVENUE
315        , EQUIPMENT_HOURS
316        , BILLABLE_EQUIPMENT_HOURS
317        , SUP_INV_COMMITTED_COST
318        , PO_COMMITTED_COST
319        , PR_COMMITTED_COST
320        , OTH_COMMITTED_COST
321        , ACT_LABOR_HRS
322 	   , ACT_EQUIP_HRS
323 	   , ACT_LABOR_BRDN_COST
324 	   , ACT_EQUIP_BRDN_COST
325 	   , ACT_BRDN_COST
326 	   , ACT_RAW_COST
327 	   , ACT_REVENUE
328          , ACT_LABOR_RAW_COST
329          , ACT_EQUIP_RAW_COST
330 	   , ETC_LABOR_HRS
331 	   , ETC_EQUIP_HRS
332 	   , ETC_LABOR_BRDN_COST
333 	   , ETC_EQUIP_BRDN_COST
334 	   , ETC_BRDN_COST
335          , ETC_RAW_COST
336          , ETC_LABOR_RAW_COST
337          , ETC_EQUIP_RAW_COST
338        , CUSTOM1
339        , CUSTOM2
340        , CUSTOM3
341        , CUSTOM4
342        , CUSTOM5
343        , CUSTOM6
344        , CUSTOM7
345        , CUSTOM8
346        , CUSTOM9
347        , CUSTOM10
348        , CUSTOM11
349        , CUSTOM12
350        , CUSTOM13
351        , CUSTOM14
352        , CUSTOM15
353        , LINE_TYPE
354        -- , RATE_DANGLING_FLAG
355        -- , TIME_DANGLING_FLAG
356        -- , START_DATE
357        -- , END_DATE
358        , PRG_LEVEL
359        , PLAN_TYPE_CODE    /* 4471527 */
360     )
361   SELECT * FROM (
362   SELECT
363        g_worker_id -- partition id
364 	, fact1.PROJECT_ID
365     , fact1.PROJECT_ORG_ID
366     , fact1.PROJECT_ORGANIZATION_ID
367     , fact1.PROJECT_ELEMENT_ID
368     , DECODE (
369                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
370              , '000', period.CAL_PERIOD_ID
371              , '001', period.CAL_QTR_ID
372              , '011', qtr.CAL_YEAR_ID
373              , '111', -1 ) TIME_ID
374     , DECODE (
375                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
376              , '000', 32
377              , '001', 64
378              , '011', 128
379              , '111', 2048 ) PERIOD_TYPE_ID
380     , DECODE (
381                grouping(qtr.CAL_YEAR_ID)
382              , 0 , l_calendar_type
383              , 'A') CALENDAR_TYPE
384     , fact1.RBS_AGGR_LEVEL
385     , fact1.WBS_ROLLUP_FLAG
386     , fact1.PRG_ROLLUP_FLAG
387     , fact1.CURR_RECORD_TYPE_ID
388     , fact1.CURRENCY_CODE
389     , fact1.RBS_ELEMENT_ID
390     , fact1.RBS_VERSION_ID
391     , fact1.PLAN_VERSION_ID
392 	, fact1.PLAN_TYPE_ID
393     , SUM(fact1.RAW_COST)  RAW_COST
394     , SUM(fact1.BRDN_COST)  BRDN_COST
395     , SUM(fact1.REVENUE)  REVENUE
396     , SUM(fact1.BILL_RAW_COST)  BILL_RAW_COST
397     , SUM(fact1.BILL_BRDN_COST )  BILL_BRDN_COST
398     , SUM(fact1.BILL_LABOR_RAW_COST)  BILL_LABOR_RAW_COST
399     , SUM(fact1.BILL_LABOR_BRDN_COST )  BILL_LABOR_BRDN_COST
400     , SUM(fact1.BILL_LABOR_HRS )  BILL_LABOR_HRS
401     , SUM(fact1.EQUIPMENT_RAW_COST )  EQUIPMENT_RAW_COST
402     , SUM(fact1.EQUIPMENT_BRDN_COST ) EQUIPMENT_BRDN_COST
403     , SUM(fact1.CAPITALIZABLE_RAW_COST ) CAPITALIZABLE_RAW_COST
404     , SUM(fact1.CAPITALIZABLE_BRDN_COST )   CAPITALIZABLE_BRDN_COST
405     , SUM(fact1.LABOR_RAW_COST )  LABOR_RAW_COST
406     , SUM(fact1.LABOR_BRDN_COST ) LABOR_BRDN_COST
407     , SUM(fact1.LABOR_HRS)  LABOR_HRS
408     , SUM(fact1.LABOR_REVENUE)    LABOR_REVENUE
409     , SUM(fact1.EQUIPMENT_HOURS)  EQUIPMENT_HOURS
410     , SUM(fact1.BILLABLE_EQUIPMENT_HOURS)  BILLABLE_EQUIPMENT_HOURS
411     , SUM(fact1.SUP_INV_COMMITTED_COST)   SUP_INV_COMMITTED_COST
412     , SUM(fact1.PO_COMMITTED_COST   )  PO_COMMITTED_COST
413     , SUM(fact1.PR_COMMITTED_COST  ) PR_COMMITTED_COST
414     , SUM(fact1.OTH_COMMITTED_COST)  OTH_COMMITTED_COST
415        , SUM(fact1.ACT_LABOR_HRS)
416 	 , SUM(fact1.ACT_EQUIP_HRS)
417 	 , SUM(fact1.ACT_LABOR_BRDN_COST)
418 	 , SUM(fact1.ACT_EQUIP_BRDN_COST)
419 	 , SUM(fact1.ACT_BRDN_COST)
420 	 , SUM(fact1.ACT_RAW_COST)
421 	 , SUM(fact1.ACT_REVENUE)
422        , SUM(fact1.ACT_LABOR_RAW_COST)
423        , SUM(fact1.ACT_EQUIP_RAW_COST)
424 	 , SUM(fact1.ETC_LABOR_HRS)
425 	 , SUM(fact1.ETC_EQUIP_HRS)
426 	 , SUM(fact1.ETC_LABOR_BRDN_COST)
427 	 , SUM(fact1.ETC_EQUIP_BRDN_COST)
428 	 , SUM(fact1.ETC_BRDN_COST )
429        , SUM(fact1.ETC_RAW_COST )
430        , SUM(fact1.ETC_LABOR_RAW_COST)
431        , SUM(fact1.ETC_EQUIP_RAW_COST)
432     , SUM(CUSTOM1	) CUSTOM1
433     , SUM(CUSTOM2	) CUSTOM2
434     , SUM(CUSTOM3	) CUSTOM3
435     , SUM(CUSTOM4	) CUSTOM4
436     , SUM(CUSTOM5	) CUSTOM5
437     , SUM(CUSTOM6	) CUSTOM6
438     , SUM(CUSTOM7	) CUSTOM7
439     , SUM(CUSTOM8	) CUSTOM8
440     , SUM(CUSTOM9	) CUSTOM9
441     , SUM(CUSTOM10	) CUSTOM10
442     , SUM(CUSTOM11	) CUSTOM11
443     , SUM(CUSTOM12	) CUSTOM12
444     , SUM(CUSTOM13	) CUSTOM13
445     , SUM(CUSTOM14	) CUSTOM14
446     , SUM(CUSTOM15) CUSTOM15
447     , l_line_type line_type
448     , g_default_prg_level prg_level
449     , fact1.PLAN_TYPE_CODE PLAN_TYPE_CODE   /* 4471527 */
450     FROM
451 	pji_fp_aggr_pjp1_t fact1  -- ,  PJI_FM_EXTR_PLNVER3_T ver
452     , pji_time_CAL_PERIOD period
453     , pji_time_CAL_QTR    qtr
454     , pji_fm_extr_plnver3_t  ver
455     WHERE
456         fact1.calendar_type = 'P'
457     AND period.cal_period_id = fact1.time_id
458     AND period.cal_qtr_id = qtr.cal_qtr_id
459     AND fact1.period_type_id = 32 -- > 0 -- <>  -1
460     AND fact1.worker_id = g_worker_id
461 --    AND fact1.rbs_version_id IN (ver.rbs_struct_version_id, -1)   /* 4632551 */
462     AND (
463           (     NVL(ver.rbs_struct_version_id, -1) = fact1.rbs_version_id
467           ( p_honor_rbs = 'N' )
464             AND p_honor_rbs = 'Y'
465           )
466           OR
468         )
469     -- AND ver.secondary_rbs_flag = 'N'
470     AND fact1.plan_version_id = ver.plan_version_id
471    AND fact1.plan_type_code = ver.plan_type_code   /* 4471527 */
472    GROUP BY
473 	fact1.PROJECT_ID
474     , fact1.PROJECT_ORGANIZATION_ID
475     , fact1.PROJECT_ORG_ID
476     -- -- -- , fact1.PARTITION_ID
477     , fact1.PROJECT_ELEMENT_ID
478     , rollup (qtr.CAL_YEAR_ID,
479               period.CAL_QTR_ID,
480               period.CAL_PERIOD_ID)
481     , fact1.calendar_type
482     , fact1.RBS_AGGR_LEVEL
483     , fact1.WBS_ROLLUP_FLAG
484     , fact1.PRG_ROLLUP_FLAG
485     , fact1.CURR_RECORD_TYPE_ID
486     , fact1.CURRENCY_CODE
487     , fact1.RBS_ELEMENT_ID
488     , fact1.RBS_VERSION_ID
489     , fact1.PLAN_VERSION_ID
490     , fact1.PLAN_TYPE_ID
491     , fact1.PLAN_TYPE_CODE )      /* 4471527 */
492     WHERE period_type_id > 32
493      AND period_type_id < 2048;
494 
495 EXCEPTION
496   WHEN OTHERS THEN
497     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
498                              p_procedure_name => 'CREATE_FP_PA_PRI_ROLLUP');
499     RAISE;
500 END;
501 
502 
503 PROCEDURE CREATE_FP_GL_PRI_ROLLUP (
504   p_honor_rbs  IN VARCHAR2 := 'Y'
505 ) IS
506     -- l_last_update_date     date   := SYSDATE;
507     -- l_last_updated_by      NUMBER := FND_GLOBAL.USER_ID;
508     -- l_creation_date        date   := SYSDATE;
509     -- l_created_by           NUMBER := FND_GLOBAL.USER_ID;
510     l_last_update_login    NUMBER := FND_GLOBAL.LOGIN_ID;
511     l_calendar_type        VARCHAR2(15) := 'G';
512     l_line_type            VARCHAR2(15) := 'GLR';
513 
514 BEGIN
515 
516   -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
517 
518   INSERT INTO pji_fp_aggr_pjp1_t
519   (
520        WORKER_ID
521      , PROJECT_ID
522      , PROJECT_ORG_ID
523      , PROJECT_ORGANIZATION_ID
524      -- , PARTITION_ID
525      , PROJECT_ELEMENT_ID
526      , TIME_ID
527      , PERIOD_TYPE_ID
528      , CALENDAR_TYPE
529      , RBS_AGGR_LEVEL
530      , WBS_ROLLUP_FLAG
531      , PRG_ROLLUP_FLAG
532      , CURR_RECORD_TYPE_ID
533      , CURRENCY_CODE
534      , RBS_ELEMENT_ID
535      , RBS_VERSION_ID
536      , PLAN_VERSION_ID
537      , PLAN_TYPE_ID
538      -- , LAST_UPDATE_DATE
539      -- , LAST_UPDATED_BY
540      -- , CREATION_DATE
541      -- , CREATED_BY
542      -- , LAST_UPDATE_LOGIN
543      , RAW_COST
544      , BRDN_COST
545      , REVENUE
546      , BILL_RAW_COST
547      , BILL_BRDN_COST
548      , BILL_LABOR_RAW_COST
549      , BILL_LABOR_BRDN_COST
550      , BILL_LABOR_HRS
551      , EQUIPMENT_RAW_COST
552      , EQUIPMENT_BRDN_COST
553      , CAPITALIZABLE_RAW_COST
554      , CAPITALIZABLE_BRDN_COST
555      , LABOR_RAW_COST
556      , LABOR_BRDN_COST
557      , LABOR_HRS
558      , LABOR_REVENUE
559      , EQUIPMENT_HOURS
560      , BILLABLE_EQUIPMENT_HOURS
561      , SUP_INV_COMMITTED_COST
562      , PO_COMMITTED_COST
563      , PR_COMMITTED_COST
564      , OTH_COMMITTED_COST
565        , ACT_LABOR_HRS
566 	   , ACT_EQUIP_HRS
567 	   , ACT_LABOR_BRDN_COST
568 	   , ACT_EQUIP_BRDN_COST
569 	   , ACT_BRDN_COST
570 	   , ACT_RAW_COST
571 	   , ACT_REVENUE
572          , ACT_LABOR_RAW_COST
573          , ACT_EQUIP_RAW_COST
574 	   , ETC_LABOR_HRS
575 	   , ETC_EQUIP_HRS
576 	   , ETC_LABOR_BRDN_COST
577 	   , ETC_EQUIP_BRDN_COST
578 	   , ETC_BRDN_COST
579          , ETC_RAW_COST
580          , ETC_LABOR_RAW_COST
581          , ETC_EQUIP_RAW_COST
582      , CUSTOM1
583      , CUSTOM2
584      , CUSTOM3
585      , CUSTOM4
586      , CUSTOM5
587      , CUSTOM6
588      , CUSTOM7
589      , CUSTOM8
590      , CUSTOM9
591      , CUSTOM10
592      , CUSTOM11
593      , CUSTOM12
594      , CUSTOM13
595      , CUSTOM14
596      , CUSTOM15
597      , LINE_TYPE
598      , PRG_LEVEL
599      , PLAN_TYPE_CODE      /* 4471527 */
600   )
601   SELECT * FROM (
602   SELECT
603     -- GROUPING(qtr.CAL_YEAR_ID)  gy
604     -- , GROUPING(period.CAL_QTR_ID)  gq
605     -- , GROUPING(period.CAL_PERIOD_ID)  gp
606 	-- ,
607       g_worker_id
608     , fact1.PROJECT_ID
609     , fact1.PROJECT_ORG_ID
610     , fact1.PROJECT_ORGANIZATION_ID
611     -- -- -- , fact1.PARTITION_ID
612     , fact1.PROJECT_ELEMENT_ID
613     , DECODE (
614                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
615              , '000', period.CAL_PERIOD_ID
616              , '001', period.CAL_QTR_ID
617              , '011', qtr.CAL_YEAR_ID
618              , '111', -1 ) TIME_ID
619     , DECODE (
620                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
621              , '000', 32
622              , '001', 64
623              , '011', 128
624              , '111', 2048 ) PERIOD_TYPE_ID
625     , DECODE (
626                grouping(qtr.CAL_YEAR_ID)
627              , 0 , l_calendar_type
628              , 'A') CALENDAR_TYPE
629     , fact1.RBS_AGGR_LEVEL
633     , fact1.CURRENCY_CODE
630     , fact1.WBS_ROLLUP_FLAG
631     , fact1.PRG_ROLLUP_FLAG
632     , fact1.CURR_RECORD_TYPE_ID
634     , fact1.RBS_ELEMENT_ID
635     , fact1.RBS_VERSION_ID
636     , fact1.PLAN_VERSION_ID
637 	, fact1.PLAN_TYPE_ID
638     , SUM(fact1.RAW_COST)  RAW_COST
639     , SUM(fact1.BRDN_COST)  BRDN_COST
640     , SUM(fact1.REVENUE)  REVENUE
641     , SUM(fact1.BILL_RAW_COST)  BILL_RAW_COST
642     , SUM(fact1.BILL_BRDN_COST )  BILL_BRDN_COST
643     , SUM(fact1.BILL_LABOR_RAW_COST)  BILL_LABOR_RAW_COST
644     , SUM(fact1.BILL_LABOR_BRDN_COST )  BILL_LABOR_BRDN_COST
645     , SUM(fact1.BILL_LABOR_HRS )  BILL_LABOR_HRS
646     , SUM(fact1.EQUIPMENT_RAW_COST )  EQUIPMENT_RAW_COST
647     , SUM(fact1.EQUIPMENT_BRDN_COST ) EQUIPMENT_BRDN_COST
648     , SUM(fact1.CAPITALIZABLE_RAW_COST ) CAPITALIZABLE_RAW_COST
649     , SUM(fact1.CAPITALIZABLE_BRDN_COST )   CAPITALIZABLE_BRDN_COST
650     , SUM(fact1.LABOR_RAW_COST )  LABOR_RAW_COST
651     , SUM(fact1.LABOR_BRDN_COST ) LABOR_BRDN_COST
652     , SUM(fact1.LABOR_HRS)  LABOR_HRS
653     , SUM(fact1.LABOR_REVENUE)    LABOR_REVENUE
654     , SUM(fact1.EQUIPMENT_HOURS)  EQUIPMENT_HOURS
655     , SUM(fact1.BILLABLE_EQUIPMENT_HOURS)  BILLABLE_EQUIPMENT_HOURS
656     , SUM(fact1.SUP_INV_COMMITTED_COST)   SUP_INV_COMMITTED_COST
657     , SUM(fact1.PO_COMMITTED_COST   )  PO_COMMITTED_COST
658     , SUM(fact1.PR_COMMITTED_COST  ) PR_COMMITTED_COST
659     , SUM(fact1.OTH_COMMITTED_COST)  OTH_COMMITTED_COST
660        , SUM(fact1.ACT_LABOR_HRS)
661 	 , SUM(fact1.ACT_EQUIP_HRS)
662 	 , SUM(fact1.ACT_LABOR_BRDN_COST)
663 	 , SUM(fact1.ACT_EQUIP_BRDN_COST)
664 	 , SUM(fact1.ACT_BRDN_COST)
665 	 , SUM(fact1.ACT_RAW_COST)
666 	 , SUM(fact1.ACT_REVENUE)
667        , SUM(fact1.ACT_LABOR_RAW_COST)
668        , SUM(fact1.ACT_EQUIP_RAW_COST)
669 	 , SUM(fact1.ETC_LABOR_HRS)
670 	 , SUM(fact1.ETC_EQUIP_HRS)
671 	 , SUM(fact1.ETC_LABOR_BRDN_COST)
672 	 , SUM(fact1.ETC_EQUIP_BRDN_COST)
673 	 , SUM(fact1.ETC_BRDN_COST )
674        , SUM(fact1.ETC_RAW_COST )
675        , SUM(fact1.ETC_LABOR_RAW_COST)
676        , SUM(fact1.ETC_EQUIP_RAW_COST)
677     , SUM(CUSTOM1	) CUSTOM1
678     , SUM(CUSTOM2	) CUSTOM2
679     , SUM(CUSTOM3	) CUSTOM3
680     , SUM(CUSTOM4	) CUSTOM4
681     , SUM(CUSTOM5	) CUSTOM5
682     , SUM(CUSTOM6	) CUSTOM6
683     , SUM(CUSTOM7	) CUSTOM7
684     , SUM(CUSTOM8	) CUSTOM8
685     , SUM(CUSTOM9	) CUSTOM9
686     , SUM(CUSTOM10	) CUSTOM10
687     , SUM(CUSTOM11	) CUSTOM11
688     , SUM(CUSTOM12	) CUSTOM12
689     , SUM(CUSTOM13	) CUSTOM13
690     , SUM(CUSTOM14	) CUSTOM14
691     , SUM(CUSTOM15) CUSTOM15
692     , l_line_type
693     , g_default_prg_level prg_level
694     , fact1.PLAN_TYPE_CODE PLAN_TYPE_CODE   /* 4471527 */
695     FROM
696 	pji_fp_aggr_pjp1_t fact1  -- ,  PJI_FM_EXTR_PLNVER3_T ver
697     , pji_time_CAL_PERIOD period
698     , pji_time_CAL_QTR    qtr
699     , pji_fm_extr_plnver3_t  ver
700     WHERE
701         fact1.calendar_type = l_calendar_type
702     AND period.cal_period_id = fact1.time_id
703     AND period.cal_qtr_id = qtr.cal_qtr_id
704     AND fact1.period_type_id = 32 -- <>  -1
705     AND fact1.worker_id = g_worker_id
706 --    AND fact1.rbs_version_id IN (ver.rbs_struct_version_id, -1)   /* 4632551 */
707     AND (
708           (     NVL(ver.rbs_struct_version_id, -1) = fact1.rbs_version_id
709             AND p_honor_rbs = 'Y'
710           )
711           OR
712           ( p_honor_rbs = 'N' )
713         )
714     -- AND ver.secondary_rbs_flag = 'N'
715     AND fact1.plan_version_id = ver.plan_version_id
716     AND fact1.plan_type_code = ver.plan_type_code      /* 4471527 */
717    GROUP BY
718 	fact1.PROJECT_ID
719     , fact1.PROJECT_ORGANIZATION_ID
720     , fact1.PROJECT_ORG_ID
721     -- -- -- , fact1.PARTITION_ID
722     , fact1.PROJECT_ELEMENT_ID
723     , rollup (qtr.CAL_YEAR_ID,
724               period.CAL_QTR_ID,
725               period.CAL_PERIOD_ID)
726     , fact1.calendar_type
727     , fact1.RBS_AGGR_LEVEL
728     , fact1.WBS_ROLLUP_FLAG
729     , fact1.PRG_ROLLUP_FLAG
730     , fact1.CURR_RECORD_TYPE_ID
731     , fact1.CURRENCY_CODE
732     , fact1.RBS_ELEMENT_ID
733     , fact1.RBS_VERSION_ID
734     , fact1.PLAN_VERSION_ID
735     , fact1.PLAN_TYPE_ID
736     , fact1.PLAN_TYPE_CODE)   /* 4471527 */
737    WHERE period_type_id > 32
738      AND period_type_id < 2048;
739 
740 
741 EXCEPTION
742   WHEN OTHERS THEN
743     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
744                              p_procedure_name => 'CREATE_FP_GL_PRI_ROLLUP');
745     RAISE;
746 END;
747 
748 
749 PROCEDURE CREATE_FP_ALL_T_PRI_ROLLUP (
750   p_honor_rbs     IN VARCHAR2 := 'Y'
751 , p_calendar_type IN VARCHAR2 := 'G' ) IS
752 
753     l_last_update_login    NUMBER := FND_GLOBAL.LOGIN_ID;
754     l_line_type            VARCHAR2(15);
755     l_time_phase_change      NUMBER := 0;
756 
757 BEGIN
758 
759   -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
760 
761   IF (p_calendar_type NOT IN ('P', 'G','C') ) THEN  -- 'C' for time phase change
762     RETURN;
763   ELSE
764     IF (p_calendar_type = 'P') THEN
765       l_line_type := 'PAR';
766     ELSIF (p_calendar_type = 'G') THEN
767       l_line_type := 'GLR';
771   END IF;
768     ELSE
769       l_line_type := 'CLR';
770     END IF;
772 /*  4604617 */
773 BEGIN
774     select  1 into l_time_phase_change from  PJI_FM_EXTR_PLNVER3_T VER
775     where EXISTS (SELECT 1 FROM PJI_FM_EXTR_PLAN_LINES PL
776          	    WHERE PL.PROJECT_ID = VER.PROJECT_ID
777                     AND PL.PLAN_VERSION_ID = VER.PLAN_VERSION_ID
778                     AND PL.PLAN_TYPE_ID = VER.PLAN_TYPE_ID
779             	    AND PL.CALENDAR_TYPE <> VER.TIME_PHASED_TYPE_CODE);
780   exception when NO_DATA_FOUND then
781     null;
782  end ;
783 IF l_time_phase_change = 0 THEN
784 
785 INSERT INTO PJI_FP_AGGR_PJP1_T
786   (
787        WORKER_ID
788      , PROJECT_ID
789      , PROJECT_ORG_ID
790      , PROJECT_ORGANIZATION_ID
791      , PROJECT_ELEMENT_ID
792      , TIME_ID
793      , PERIOD_TYPE_ID
794      , CALENDAR_TYPE
795      , RBS_AGGR_LEVEL
796      , WBS_ROLLUP_FLAG
797      , PRG_ROLLUP_FLAG
798      , CURR_RECORD_TYPE_ID
799      , CURRENCY_CODE
800      , RBS_ELEMENT_ID
801      , RBS_VERSION_ID
802      , PLAN_VERSION_ID
803      , PLAN_TYPE_ID
804      , RAW_COST
805      , BRDN_COST
806      , REVENUE
807      , BILL_RAW_COST
808      , BILL_BRDN_COST
809      , BILL_LABOR_RAW_COST
810      , BILL_LABOR_BRDN_COST
811      , BILL_LABOR_HRS
812      , EQUIPMENT_RAW_COST
813      , EQUIPMENT_BRDN_COST
814      , CAPITALIZABLE_RAW_COST
815      , CAPITALIZABLE_BRDN_COST
816      , LABOR_RAW_COST
817      , LABOR_BRDN_COST
818      , LABOR_HRS
819      , LABOR_REVENUE
820      , EQUIPMENT_HOURS
821      , BILLABLE_EQUIPMENT_HOURS
822      , SUP_INV_COMMITTED_COST
823      , PO_COMMITTED_COST
824      , PR_COMMITTED_COST
825      , OTH_COMMITTED_COST
826        , ACT_LABOR_HRS
827 	   , ACT_EQUIP_HRS
828 	   , ACT_LABOR_BRDN_COST
829 	   , ACT_EQUIP_BRDN_COST
830 	   , ACT_BRDN_COST
831 	   , ACT_RAW_COST
832 	   , ACT_REVENUE
833          , ACT_LABOR_RAW_COST
834          , ACT_EQUIP_RAW_COST
835 	   , ETC_LABOR_HRS
836 	   , ETC_EQUIP_HRS
837 	   , ETC_LABOR_BRDN_COST
838 	   , ETC_EQUIP_BRDN_COST
839 	   , ETC_BRDN_COST
840          , ETC_RAW_COST
841          , ETC_LABOR_RAW_COST
842          , ETC_EQUIP_RAW_COST
843      , CUSTOM1
844      , CUSTOM2
845      , CUSTOM3
846      , CUSTOM4
847      , CUSTOM5
848      , CUSTOM6
849      , CUSTOM7
850      , CUSTOM8
851      , CUSTOM9
852      , CUSTOM10
853      , CUSTOM11
854      , CUSTOM12
855      , CUSTOM13
856      , CUSTOM14
857      , CUSTOM15
858      , LINE_TYPE
859      , PRG_LEVEL
860     , PLAN_TYPE_CODE   /* 4471527 */
861   )
862    SELECT
863       g_worker_id
864     , fact1.PROJECT_ID
865     , fact1.PROJECT_ORG_ID
866     , fact1.PROJECT_ORGANIZATION_ID
867     , fact1.PROJECT_ELEMENT_ID
868 /*    , DECODE (
869                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
870              , '000', period.CAL_PERIOD_ID
871              , '001', period.CAL_QTR_ID
872              , '011', qtr.CAL_YEAR_ID
873              , '111', -1 ) TIME_ID
874     , DECODE (
875                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
876              , '000', 32
877              , '001', 64
878              , '011', 128
879              , '111', 2048 ) PERIOD_TYPE_ID
880     , DECODE (
881                grouping(qtr.CAL_YEAR_ID)
882              , 0 ,p_calendar_type
883              , 'A') CALENDAR_TYPE    */
884     , -1   TIME_ID
885     , 2048 PERIOD_TYPE_ID
886     , 'A'  CALENDAR_TYPE
887     , fact1.RBS_AGGR_LEVEL
888     , fact1.WBS_ROLLUP_FLAG
889     , fact1.PRG_ROLLUP_FLAG
890     , fact1.CURR_RECORD_TYPE_ID
891     , fact1.CURRENCY_CODE
892     , fact1.RBS_ELEMENT_ID
893     , fact1.RBS_VERSION_ID
894     , fact1.PLAN_VERSION_ID
895 	, fact1.PLAN_TYPE_ID
896     , SUM(fact1.RAW_COST)  RAW_COST
897     , SUM(fact1.BRDN_COST)  BRDN_COST
898     , SUM(fact1.REVENUE)  REVENUE
899     , SUM(fact1.BILL_RAW_COST)  BILL_RAW_COST
900     , SUM(fact1.BILL_BRDN_COST )  BILL_BRDN_COST
901     , SUM(fact1.BILL_LABOR_RAW_COST)  BILL_LABOR_RAW_COST
902     , SUM(fact1.BILL_LABOR_BRDN_COST )  BILL_LABOR_BRDN_COST
903     , SUM(fact1.BILL_LABOR_HRS )  BILL_LABOR_HRS
904     , SUM(fact1.EQUIPMENT_RAW_COST )  EQUIPMENT_RAW_COST
905     , SUM(fact1.EQUIPMENT_BRDN_COST ) EQUIPMENT_BRDN_COST
906     , SUM(fact1.CAPITALIZABLE_RAW_COST ) CAPITALIZABLE_RAW_COST
907     , SUM(fact1.CAPITALIZABLE_BRDN_COST )   CAPITALIZABLE_BRDN_COST
908     , SUM(fact1.LABOR_RAW_COST )  LABOR_RAW_COST
909     , SUM(fact1.LABOR_BRDN_COST ) LABOR_BRDN_COST
910     , SUM(fact1.LABOR_HRS)  LABOR_HRS
911     , SUM(fact1.LABOR_REVENUE)    LABOR_REVENUE
912     , SUM(fact1.EQUIPMENT_HOURS)  EQUIPMENT_HOURS
913     , SUM(fact1.BILLABLE_EQUIPMENT_HOURS)  BILLABLE_EQUIPMENT_HOURS
914     , SUM(fact1.SUP_INV_COMMITTED_COST)   SUP_INV_COMMITTED_COST
915     , SUM(fact1.PO_COMMITTED_COST   )  PO_COMMITTED_COST
916     , SUM(fact1.PR_COMMITTED_COST  ) PR_COMMITTED_COST
920 	 , SUM(fact1.ACT_LABOR_BRDN_COST)
917     , SUM(fact1.OTH_COMMITTED_COST)  OTH_COMMITTED_COST
918        , SUM(fact1.ACT_LABOR_HRS)
919 	 , SUM(fact1.ACT_EQUIP_HRS)
921 	 , SUM(fact1.ACT_EQUIP_BRDN_COST)
922 	 , SUM(fact1.ACT_BRDN_COST)
923 	 , SUM(fact1.ACT_RAW_COST)
924 	 , SUM(fact1.ACT_REVENUE)
925        , SUM(fact1.ACT_LABOR_RAW_COST)
926        , SUM(fact1.ACT_EQUIP_RAW_COST)
927 	 , SUM(fact1.ETC_LABOR_HRS)
928 	 , SUM(fact1.ETC_EQUIP_HRS)
929 	 , SUM(fact1.ETC_LABOR_BRDN_COST)
930 	 , SUM(fact1.ETC_EQUIP_BRDN_COST)
931 	 , SUM(fact1.ETC_BRDN_COST )
932        , SUM(fact1.ETC_RAW_COST )
933        , SUM(fact1.ETC_LABOR_RAW_COST)
934        , SUM(fact1.ETC_EQUIP_RAW_COST)
935     , SUM(CUSTOM1	) CUSTOM1
936     , SUM(CUSTOM2	) CUSTOM2
937     , SUM(CUSTOM3	) CUSTOM3
938     , SUM(CUSTOM4	) CUSTOM4
939     , SUM(CUSTOM5	) CUSTOM5
940     , SUM(CUSTOM6	) CUSTOM6
941     , SUM(CUSTOM7	) CUSTOM7
942     , SUM(CUSTOM8	) CUSTOM8
943     , SUM(CUSTOM9	) CUSTOM9
944     , SUM(CUSTOM10	) CUSTOM10
945     , SUM(CUSTOM11	) CUSTOM11
946     , SUM(CUSTOM12	) CUSTOM12
947     , SUM(CUSTOM13	) CUSTOM13
948     , SUM(CUSTOM14	) CUSTOM14
949     , SUM(CUSTOM15) CUSTOM15
950     ,l_line_type
951     , g_default_prg_level prg_level
952    , fact1.PLAN_TYPE_CODE PLAN_TYPE_CODE   /* 4471527 */
953     FROM
954 	PJI_FP_AGGR_PJP1_T fact1
955     , pji_time_CAL_PERIOD period
956     , pji_time_CAL_QTR    qtr
957     , pji_fm_extr_plnver3_t ver
958     WHERE
959         fact1.calendar_type IN ( p_calendar_type
960   				 , DECODE (p_calendar_type ,'C','G','X')
961 				 , DECODE (p_calendar_type ,'C','P','X')
962 				)
963     AND period.cal_period_id = fact1.time_id
964     AND period.cal_qtr_id = qtr.cal_qtr_id
965     AND fact1.period_type_id = 32
966     AND ver.time_phased_type_code IN ('P', 'G') -- If non time phased plan, then calender type is C.
967     AND ver.project_id = fact1.project_id
968     AND ver.plan_version_id = fact1.plan_version_id
969     AND ver.plan_type_code  = fact1.plan_type_code   /* 4471527 */
970     AND fact1.worker_id = g_worker_id
971 --    AND fact1.rbs_version_id IN (ver.rbs_struct_version_id, -1)   /* 4632551 */
972     AND (
973           (     NVL(ver.rbs_struct_version_id, -1) = fact1.rbs_version_id
974             AND p_honor_rbs = 'Y'
975           )
976           OR
977           ( p_honor_rbs = 'N' )
978         )
979 --    AND fact1.plan_version_id = ver.plan_version_id
980    GROUP BY
981 	fact1.PROJECT_ID
982     , fact1.PROJECT_ORGANIZATION_ID
983     , fact1.PROJECT_ORG_ID
984     , fact1.PROJECT_ELEMENT_ID
985     , fact1.RBS_AGGR_LEVEL
986     , fact1.WBS_ROLLUP_FLAG
987     , fact1.PRG_ROLLUP_FLAG
988     , fact1.CURR_RECORD_TYPE_ID
989     , fact1.CURRENCY_CODE
990     , fact1.RBS_ELEMENT_ID
991     , fact1.RBS_VERSION_ID
992     , fact1.PLAN_VERSION_ID
993     , fact1.PLAN_TYPE_ID
994     , fact1.PLAN_TYPE_CODE ;   /* 4471527 */
995 
996 ELSE
997 /* 4604617 */
998 /*When Time phase change from PA/GL to None then update the existing A lines
999   When Gl to PA or vice versa , insert only one -A lines */
1000 MERGE INTO PJI_FP_AGGR_PJP1_T F1
1001 USING ( SELECT   g_worker_id WORKER_ID
1002     , fact1.PROJECT_ID
1003     , fact1.PROJECT_ORG_ID
1004     , fact1.PROJECT_ORGANIZATION_ID
1005     , fact1.PROJECT_ELEMENT_ID
1006     , -1   TIME_ID
1007     , 2048 PERIOD_TYPE_ID
1008     , 'A'  CALENDAR_TYPE
1009     , fact1.RBS_AGGR_LEVEL
1010     , fact1.WBS_ROLLUP_FLAG
1011     , fact1.PRG_ROLLUP_FLAG
1012     , fact1.CURR_RECORD_TYPE_ID
1013     , fact1.CURRENCY_CODE
1014     , fact1.RBS_ELEMENT_ID
1015     , fact1.RBS_VERSION_ID
1016     , fact1.PLAN_VERSION_ID
1017     , fact1.PLAN_TYPE_ID
1018     , SUM(fact1.RAW_COST)  RAW_COST
1019     , SUM(fact1.BRDN_COST)  BRDN_COST
1020     , SUM(fact1.REVENUE)  REVENUE
1021     , SUM(fact1.BILL_RAW_COST)  BILL_RAW_COST
1022     , SUM(fact1.BILL_BRDN_COST )  BILL_BRDN_COST
1023     , SUM(fact1.BILL_LABOR_RAW_COST)  BILL_LABOR_RAW_COST
1024     , SUM(fact1.BILL_LABOR_BRDN_COST )  BILL_LABOR_BRDN_COST
1025     , SUM(fact1.BILL_LABOR_HRS )  BILL_LABOR_HRS
1026     , SUM(fact1.EQUIPMENT_RAW_COST )  EQUIPMENT_RAW_COST
1027     , SUM(fact1.EQUIPMENT_BRDN_COST ) EQUIPMENT_BRDN_COST
1028     , SUM(fact1.CAPITALIZABLE_RAW_COST ) CAPITALIZABLE_RAW_COST
1029     , SUM(fact1.CAPITALIZABLE_BRDN_COST )   CAPITALIZABLE_BRDN_COST
1030     , SUM(fact1.LABOR_RAW_COST )  LABOR_RAW_COST
1031     , SUM(fact1.LABOR_BRDN_COST ) LABOR_BRDN_COST
1032     , SUM(fact1.LABOR_HRS)  LABOR_HRS
1033     , SUM(fact1.LABOR_REVENUE)    LABOR_REVENUE
1034     , SUM(fact1.EQUIPMENT_HOURS)  EQUIPMENT_HOURS
1035     , SUM(fact1.BILLABLE_EQUIPMENT_HOURS)  BILLABLE_EQUIPMENT_HOURS
1036     , SUM(fact1.SUP_INV_COMMITTED_COST)   SUP_INV_COMMITTED_COST
1037     , SUM(fact1.PO_COMMITTED_COST   )  PO_COMMITTED_COST
1038     , SUM(fact1.PR_COMMITTED_COST  ) PR_COMMITTED_COST
1039     , SUM(fact1.OTH_COMMITTED_COST)  OTH_COMMITTED_COST
1040     , SUM(CUSTOM1	) CUSTOM1
1041     , SUM(CUSTOM2	) CUSTOM2
1042     , SUM(CUSTOM3	) CUSTOM3
1043     , SUM(CUSTOM4	) CUSTOM4
1044     , SUM(CUSTOM5	) CUSTOM5
1045     , SUM(CUSTOM6	) CUSTOM6
1046     , SUM(CUSTOM7	) CUSTOM7
1047     , SUM(CUSTOM8	) CUSTOM8
1051     , SUM(CUSTOM12	) CUSTOM12
1048     , SUM(CUSTOM9	) CUSTOM9
1049     , SUM(CUSTOM10	) CUSTOM10
1050     , SUM(CUSTOM11	) CUSTOM11
1052     , SUM(CUSTOM13	) CUSTOM13
1053     , SUM(CUSTOM14	) CUSTOM14
1054     , SUM(CUSTOM15) CUSTOM15
1055     , SUM(fact1.ACT_LABOR_HRS) ACT_LABOR_HRS
1056     , SUM(fact1.ACT_EQUIP_HRS) ACT_EQUIP_HRS
1057     , SUM(fact1.ACT_LABOR_BRDN_COST) ACT_LABOR_BRDN_COST
1058     , SUM(fact1.ACT_EQUIP_BRDN_COST) ACT_EQUIP_BRDN_COST
1059     , SUM(fact1.ACT_BRDN_COST) ACT_BRDN_COST
1060     , SUM(fact1.ACT_RAW_COST) ACT_RAW_COST
1061     , SUM(fact1.ACT_REVENUE) ACT_REVENUE
1062     , SUM(fact1.ACT_LABOR_RAW_COST) ACT_LABOR_RAW_COST
1063     , SUM(fact1.ACT_EQUIP_RAW_COST) ACT_EQUIP_RAW_COST
1064     , SUM(fact1.ETC_LABOR_HRS) ETC_LABOR_HRS
1065     , SUM(fact1.ETC_EQUIP_HRS) ETC_EQUIP_HRS
1066     , SUM(fact1.ETC_LABOR_BRDN_COST) ETC_LABOR_BRDN_COST
1067     , SUM(fact1.ETC_EQUIP_BRDN_COST) ETC_EQUIP_BRDN_COST
1068     , SUM(fact1.ETC_BRDN_COST ) ETC_BRDN_COST
1069     , SUM(fact1.ETC_RAW_COST ) ETC_RAW_COST
1070     , SUM(fact1.ETC_LABOR_RAW_COST) ETC_LABOR_RAW_COST
1071     , SUM(fact1.ETC_EQUIP_RAW_COST) ETC_EQUIP_RAW_COST
1072     , g_default_prg_level PRG_LEVEL
1073     , l_line_type LINE_TYPE
1074     , fact1.PLAN_TYPE_CODE PLAN_TYPE_CODE     /* 4471527 */
1075     FROM
1076     PJI_FP_AGGR_PJP1_T fact1
1077     , pji_time_CAL_PERIOD period
1078     , pji_time_CAL_QTR    qtr
1079     , pji_fm_extr_plnver3_t ver
1080     WHERE
1081         fact1.calendar_type IN ( p_calendar_type
1082   				 , DECODE (p_calendar_type ,'C','G','X')
1083 				 , DECODE (p_calendar_type ,'C','P','X')
1084 				)
1085     AND period.cal_period_id = fact1.time_id
1086     AND period.cal_qtr_id = qtr.cal_qtr_id
1087     AND fact1.period_type_id = 32
1088     AND ver.time_phased_type_code IN ('P', 'G','N') -- If non time phased plan, then calender type is C.
1089     AND ver.project_id = fact1.project_id
1090     AND ver.plan_version_id = fact1.plan_version_id
1091    AND ver.plan_type_code = fact1.plan_type_code    /* 4471527 */
1092     AND fact1.worker_id = g_worker_id
1093 --    AND fact1.rbs_version_id IN (ver.rbs_struct_version_id, -1)   /* 4632551 */
1094     AND NVL(ver.rbs_struct_version_id, -1) = fact1.rbs_version_id
1095 --    AND fact1.plan_version_id = ver.plan_version_id
1096    GROUP BY
1097 	fact1.PROJECT_ID
1098     , fact1.PROJECT_ORGANIZATION_ID
1099     , fact1.PROJECT_ORG_ID
1100     , fact1.PROJECT_ELEMENT_ID
1101     , fact1.RBS_AGGR_LEVEL
1102     , fact1.WBS_ROLLUP_FLAG
1103     , fact1.PRG_ROLLUP_FLAG
1104     , fact1.CURR_RECORD_TYPE_ID
1105     , fact1.CURRENCY_CODE
1106     , fact1.RBS_ELEMENT_ID
1107     , fact1.RBS_VERSION_ID
1108     , fact1.PLAN_VERSION_ID
1109     , fact1.PLAN_TYPE_ID
1110     , fact1.PLAN_TYPE_CODE ) F2         /* 4471527 */
1111 ON (F1.WORKER_ID = F2.WORKER_ID
1112     AND F1.PROJECT_ID = F2.PROJECT_ID
1113     AND F1.PROJECT_ORGANIZATION_ID = F2.PROJECT_ORGANIZATION_ID
1114     AND F1.PROJECT_ORG_ID = F2.PROJECT_ORG_ID
1115     AND F1.PROJECT_ELEMENT_ID = F2.PROJECT_ELEMENT_ID
1116     AND F1.RBS_AGGR_LEVEL = F2.RBS_AGGR_LEVEL
1117     AND F1.WBS_ROLLUP_FLAG = F2.WBS_ROLLUP_FLAG
1118     AND F1.PRG_ROLLUP_FLAG = F2.PRG_ROLLUP_FLAG
1119     AND F1.CURR_RECORD_TYPE_ID = F2.CURR_RECORD_TYPE_ID
1120     AND F1.CURRENCY_CODE = F2.CURRENCY_CODE
1121     AND F1.RBS_ELEMENT_ID = F2.RBS_ELEMENT_ID
1122     AND F1.RBS_VERSION_ID = F2.RBS_VERSION_ID
1123     AND F1.PLAN_VERSION_ID = F2.PLAN_VERSION_ID
1124     AND F1.PLAN_TYPE_ID = F2.PLAN_TYPE_ID
1125     AND F1.PLAN_TYPE_CODE = F2.PLAN_TYPE_CODE    /* 4471527 */
1126     AND F1.TIME_ID = F2.TIME_ID
1127     AND F1.CALENDAR_TYPE = F2.CALENDAR_TYPE
1128     AND F1.PERIOD_TYPE_ID = F2.PERIOD_TYPE_ID )
1129 WHEN MATCHED THEN
1130 UPDATE
1131 SET   F1.RAW_COST = F1.RAW_COST + F2.RAW_COST
1132     , F1.BRDN_COST = F1.BRDN_COST + F2.BRDN_COST
1133     , F1.REVENUE = F1.REVENUE + F2.REVENUE
1134     , F1.BILL_RAW_COST = F1.BILL_RAW_COST + F2.BILL_RAW_COST
1135     , F1.BILL_BRDN_COST = F1.BILL_BRDN_COST + F2.BILL_BRDN_COST
1136     , F1.BILL_LABOR_RAW_COST = F1.BILL_LABOR_RAW_COST + F2.BILL_LABOR_RAW_COST
1137     , F1.BILL_LABOR_BRDN_COST = F1.BILL_LABOR_BRDN_COST + F2.BILL_LABOR_BRDN_COST
1138     , F1.BILL_LABOR_HRS = F1.BILL_LABOR_HRS + F2.BILL_LABOR_HRS
1139     , F1.EQUIPMENT_RAW_COST = F1.EQUIPMENT_RAW_COST + F2.EQUIPMENT_RAW_COST
1140     , F1.EQUIPMENT_BRDN_COST = F1.EQUIPMENT_BRDN_COST + F2.EQUIPMENT_BRDN_COST
1141     , F1.CAPITALIZABLE_RAW_COST = F1.CAPITALIZABLE_RAW_COST + F2.CAPITALIZABLE_RAW_COST
1142     , F1.CAPITALIZABLE_BRDN_COST = F1.CAPITALIZABLE_BRDN_COST + F2.CAPITALIZABLE_BRDN_COST
1143     , F1.LABOR_RAW_COST = F1.LABOR_RAW_COST + F2.LABOR_RAW_COST
1144     , F1.LABOR_BRDN_COST = F1.LABOR_BRDN_COST + F2.LABOR_BRDN_COST
1145     , F1.LABOR_HRS = F1.LABOR_HRS + F2.LABOR_HRS
1146     , F1.LABOR_REVENUE = F1.LABOR_REVENUE + F2.LABOR_REVENUE
1147     , F1.EQUIPMENT_HOURS = F1.EQUIPMENT_HOURS + F2.EQUIPMENT_HOURS
1148     , F1.BILLABLE_EQUIPMENT_HOURS = F1.BILLABLE_EQUIPMENT_HOURS + F2.BILLABLE_EQUIPMENT_HOURS
1149     , F1.SUP_INV_COMMITTED_COST = F1.SUP_INV_COMMITTED_COST + F2.SUP_INV_COMMITTED_COST
1150     , F1.PO_COMMITTED_COST = F1.PO_COMMITTED_COST + F2.PO_COMMITTED_COST
1151     , F1.PR_COMMITTED_COST = F1.PR_COMMITTED_COST + F2.PR_COMMITTED_COST
1152     , F1.OTH_COMMITTED_COST = F1.OTH_COMMITTED_COST + F2.OTH_COMMITTED_COST
1153     , F1.ACT_LABOR_HRS = F1.ACT_LABOR_HRS + F2.ACT_LABOR_HRS
1154     , F1.ACT_EQUIP_HRS = F1.ACT_EQUIP_HRS + F2.ACT_EQUIP_HRS
1155     , F1.ACT_LABOR_BRDN_COST = F1.ACT_LABOR_BRDN_COST + F2.ACT_LABOR_BRDN_COST
1156     , F1.ACT_EQUIP_BRDN_COST = F1.ACT_EQUIP_BRDN_COST + F2.ACT_EQUIP_BRDN_COST
1160     , F1.ACT_LABOR_RAW_COST = F1.ACT_LABOR_RAW_COST +F2.ACT_LABOR_RAW_COST
1157     , F1.ACT_BRDN_COST = F1.ACT_BRDN_COST + F2.ACT_BRDN_COST
1158     , F1.ACT_RAW_COST = F1.ACT_RAW_COST + F2.ACT_RAW_COST
1159     , F1.ACT_REVENUE = F1.ACT_REVENUE + F2.ACT_REVENUE
1161     , F1.ACT_EQUIP_RAW_COST = F1.ACT_EQUIP_RAW_COST + F2.ACT_EQUIP_RAW_COST
1162     , F1.ETC_LABOR_HRS = F1.ETC_LABOR_HRS + F2.ETC_LABOR_HRS
1163     , F1.ETC_EQUIP_HRS = F1.ETC_EQUIP_HRS + F2.ETC_EQUIP_HRS
1164     , F1.ETC_LABOR_BRDN_COST = F1.ETC_LABOR_BRDN_COST + F2.ETC_LABOR_BRDN_COST
1165     , F1.ETC_EQUIP_BRDN_COST = F1.ETC_EQUIP_BRDN_COST + F2.ETC_EQUIP_BRDN_COST
1166     , F1.ETC_BRDN_COST = F1.ETC_BRDN_COST + F2.ETC_BRDN_COST
1167     , F1.ETC_RAW_COST = F1.ETC_RAW_COST + F2.ETC_RAW_COST
1168     , F1.ETC_LABOR_RAW_COST = F1.ETC_LABOR_RAW_COST + F2.ETC_LABOR_RAW_COST
1169     , F1.ETC_EQUIP_RAW_COST = F1.ETC_EQUIP_RAW_COST + F2.ETC_EQUIP_RAW_COST
1170     , F1.CUSTOM1 = F1.CUSTOM1 + F2.CUSTOM1
1171     , F1.CUSTOM2 = F1.CUSTOM2 + F2.CUSTOM2
1172     , F1.CUSTOM3 = F1.CUSTOM3 + F2.CUSTOM3
1173     , F1.CUSTOM4 = F1.CUSTOM4 + F2.CUSTOM4
1174     , F1.CUSTOM5 = F1.CUSTOM5 + F2.CUSTOM5
1175     , F1.CUSTOM6 = F1.CUSTOM6 + F2.CUSTOM6
1176     , F1.CUSTOM7 = F1.CUSTOM7 + F2.CUSTOM7
1177     , F1.CUSTOM8 = F1.CUSTOM8 + F2.CUSTOM8
1178     , F1.CUSTOM9 = F1.CUSTOM9 + F2.CUSTOM9
1179     , F1.CUSTOM10 = F1.CUSTOM10 + F2.CUSTOM10
1180     , F1.CUSTOM11 = F1.CUSTOM11 + F2.CUSTOM11
1181     , F1.CUSTOM12 = F1.CUSTOM12 + F2.CUSTOM12
1182     , F1.CUSTOM13 = F1.CUSTOM13 + F2.CUSTOM13
1183     , F1.CUSTOM14 = F1.CUSTOM14 + F2.CUSTOM14
1184     , F1.CUSTOM15 = F1.CUSTOM15 + F2.CUSTOM15
1185  WHEN NOT MATCHED THEN
1186 INSERT
1187   (  F1.WORKER_ID
1188      , F1.PROJECT_ID
1189      , F1.PROJECT_ORG_ID
1190      , F1.PROJECT_ORGANIZATION_ID
1191      , F1.PROJECT_ELEMENT_ID
1192      , F1.TIME_ID
1193      , F1.PERIOD_TYPE_ID
1194      , F1.CALENDAR_TYPE
1195      , F1.RBS_AGGR_LEVEL
1196      , F1.WBS_ROLLUP_FLAG
1197      , F1.PRG_ROLLUP_FLAG
1198      , F1.CURR_RECORD_TYPE_ID
1199      , F1.CURRENCY_CODE
1200      , F1.RBS_ELEMENT_ID
1201      , F1.RBS_VERSION_ID
1202      , F1.PLAN_VERSION_ID
1203      , F1.PLAN_TYPE_ID
1204      , F1.RAW_COST
1205      , F1.BRDN_COST
1206      , F1.REVENUE
1207      , F1.BILL_RAW_COST
1208      , F1.BILL_BRDN_COST
1209      , F1.BILL_LABOR_RAW_COST
1210      , F1.BILL_LABOR_BRDN_COST
1211      , F1.BILL_LABOR_HRS
1212      , F1.EQUIPMENT_RAW_COST
1213      , F1.EQUIPMENT_BRDN_COST
1214      , F1.CAPITALIZABLE_RAW_COST
1215      , F1.CAPITALIZABLE_BRDN_COST
1216      , F1.LABOR_RAW_COST
1217      , F1.LABOR_BRDN_COST
1218      , F1.LABOR_HRS
1219      , F1.LABOR_REVENUE
1220      , F1.EQUIPMENT_HOURS
1221      , F1.BILLABLE_EQUIPMENT_HOURS
1222      , F1.SUP_INV_COMMITTED_COST
1223      , F1.PO_COMMITTED_COST
1224      , F1.PR_COMMITTED_COST
1225      , F1.OTH_COMMITTED_COST
1226      , F1.ACT_LABOR_HRS
1227      , F1.ACT_EQUIP_HRS
1228      , F1.ACT_LABOR_BRDN_COST
1229      , F1.ACT_EQUIP_BRDN_COST
1230      , F1.ACT_BRDN_COST
1231      , F1.ACT_RAW_COST
1232      , F1.ACT_REVENUE
1233      , F1.ACT_LABOR_RAW_COST
1234      , F1.ACT_EQUIP_RAW_COST
1235      , F1.ETC_LABOR_HRS
1236      , F1.ETC_EQUIP_HRS
1237      , F1.ETC_LABOR_BRDN_COST
1238      , F1.ETC_EQUIP_BRDN_COST
1239      , F1.ETC_BRDN_COST
1240      , F1.ETC_RAW_COST
1241      , F1.ETC_LABOR_RAW_COST
1242      , F1.ETC_EQUIP_RAW_COST
1243      , F1.CUSTOM1
1244      , F1.CUSTOM2
1245      , F1.CUSTOM3
1246      , F1.CUSTOM4
1247      , F1.CUSTOM5
1248      , F1.CUSTOM6
1249      , F1.CUSTOM7
1250      , F1.CUSTOM8
1251      , F1.CUSTOM9
1252      , F1.CUSTOM10
1253      , F1.CUSTOM11
1254      , F1.CUSTOM12
1255      , F1.CUSTOM13
1256      , F1.CUSTOM14
1257      , F1.CUSTOM15
1258      , F1.LINE_TYPE
1259      , F1.PRG_LEVEL
1260      , F1.PLAN_TYPE_CODE    /* 4471527 */
1261   )
1262 VALUES
1263 (  F2.WORKER_ID
1264      , F2.PROJECT_ID
1265      , F2.PROJECT_ORG_ID
1266      , F2.PROJECT_ORGANIZATION_ID
1267      , F2.PROJECT_ELEMENT_ID
1268      , F2.TIME_ID
1269      , F2.PERIOD_TYPE_ID
1270      , F2.CALENDAR_TYPE
1271      , F2.RBS_AGGR_LEVEL
1272      , F2.WBS_ROLLUP_FLAG
1273      , F2.PRG_ROLLUP_FLAG
1274      , F2.CURR_RECORD_TYPE_ID
1275      , F2.CURRENCY_CODE
1276      , F2.RBS_ELEMENT_ID
1277      , F2.RBS_VERSION_ID
1278      , F2.PLAN_VERSION_ID
1279      , F2.PLAN_TYPE_ID
1280      , F2.RAW_COST
1281      , F2.BRDN_COST
1282      , F2.REVENUE
1283      , F2.BILL_RAW_COST
1284      , F2.BILL_BRDN_COST
1285      , F2.BILL_LABOR_RAW_COST
1286      , F2.BILL_LABOR_BRDN_COST
1287      , F2.BILL_LABOR_HRS
1288      , F2.EQUIPMENT_RAW_COST
1289      , F2.EQUIPMENT_BRDN_COST
1290      , F2.CAPITALIZABLE_RAW_COST
1291      , F2.CAPITALIZABLE_BRDN_COST
1292      , F2.LABOR_RAW_COST
1293      , F2.LABOR_BRDN_COST
1294      , F2.LABOR_HRS
1295      , F2.LABOR_REVENUE
1296      , F2.EQUIPMENT_HOURS
1297      , F2.BILLABLE_EQUIPMENT_HOURS
1298      , F2.SUP_INV_COMMITTED_COST
1299      , F2.PO_COMMITTED_COST
1300      , F2.PR_COMMITTED_COST
1301      , F2.OTH_COMMITTED_COST
1302      , F2.ACT_LABOR_HRS
1303      , F2.ACT_EQUIP_HRS
1304      , F2.ACT_LABOR_BRDN_COST
1305      , F2.ACT_EQUIP_BRDN_COST
1306      , F2.ACT_BRDN_COST
1307      , F2.ACT_RAW_COST
1308      , F2.ACT_REVENUE
1309      , F2.ACT_LABOR_RAW_COST
1310      , F2.ACT_EQUIP_RAW_COST
1311      , F2.ETC_LABOR_HRS
1312      , F2.ETC_EQUIP_HRS
1313      , F2.ETC_LABOR_BRDN_COST
1317      , F2.ETC_LABOR_RAW_COST
1314      , F2.ETC_EQUIP_BRDN_COST
1315      , F2.ETC_BRDN_COST
1316      , F2.ETC_RAW_COST
1318      , F2.ETC_EQUIP_RAW_COST
1319      , F2.CUSTOM1
1320      , F2.CUSTOM2
1321      , F2.CUSTOM3
1322      , F2.CUSTOM4
1323      , F2.CUSTOM5
1324      , F2.CUSTOM6
1325      , F2.CUSTOM7
1326      , F2.CUSTOM8
1327      , F2.CUSTOM9
1328      , F2.CUSTOM10
1329      , F2.CUSTOM11
1330      , F2.CUSTOM12
1331      , F2.CUSTOM13
1332      , F2.CUSTOM14
1333      , F2.CUSTOM15
1334      , F2.LINE_TYPE
1335      , F2.PRG_LEVEL
1336      , F2.PLAN_TYPE_CODE    /* 4471527 */
1337   );
1338 
1339 END IF;
1340 
1341 EXCEPTION
1342   WHEN OTHERS THEN
1343     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
1344                              p_procedure_name => 'CREATE_FP_ALL_T_PRI_ROLLUP');
1345     RAISE;
1346 END;
1347 
1348 
1349 PROCEDURE CREATE_FP_ALLT_PRI_AGGREGATE IS
1350     -- l_last_update_date     date   := SYSDATE;
1351     -- l_last_updated_by      NUMBER := FND_GLOBAL.USER_ID;
1352     -- l_creation_date        date   := SYSDATE;
1353     -- l_created_by           NUMBER := FND_GLOBAL.USER_ID;
1354     l_last_update_login    NUMBER := FND_GLOBAL.LOGIN_ID;
1355     l_calendar_type        VARCHAR2(15) := 'A';
1356     l_line_type            VARCHAR2(15) := 'ATR';
1357     l_time_id              NUMBER := -1;
1358     l_period_type_id       NUMBER := 2048;
1359 
1360 BEGIN
1361 
1362   -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
1363 
1364   INSERT INTO pji_fp_aggr_pjp1_t
1365   (
1366        WORKER_ID
1367      , PRG_LEVEL
1368      , PROJECT_ID
1369      , PROJECT_ORG_ID
1370      , PROJECT_ORGANIZATION_ID
1371      , PROJECT_ELEMENT_ID
1372      , TIME_ID
1373      , PERIOD_TYPE_ID
1374      , CALENDAR_TYPE
1375      , RBS_AGGR_LEVEL
1376      , WBS_ROLLUP_FLAG
1377      , PRG_ROLLUP_FLAG
1378      , CURR_RECORD_TYPE_ID
1379      , CURRENCY_CODE
1380      , RBS_ELEMENT_ID
1381      , RBS_VERSION_ID
1382      , PLAN_VERSION_ID
1383      , PLAN_TYPE_ID
1384      , RAW_COST
1385      , BRDN_COST
1386      , REVENUE
1387      , BILL_RAW_COST
1388      , BILL_BRDN_COST
1389      , BILL_LABOR_RAW_COST
1390      , BILL_LABOR_BRDN_COST
1391      , BILL_LABOR_HRS
1392      , EQUIPMENT_RAW_COST
1393      , EQUIPMENT_BRDN_COST
1394      , CAPITALIZABLE_RAW_COST
1395      , CAPITALIZABLE_BRDN_COST
1396      , LABOR_RAW_COST
1397      , LABOR_BRDN_COST
1398      , LABOR_HRS
1399      , LABOR_REVENUE
1400      , EQUIPMENT_HOURS
1401      , BILLABLE_EQUIPMENT_HOURS
1402      , SUP_INV_COMMITTED_COST
1403      , PO_COMMITTED_COST
1404      , PR_COMMITTED_COST
1405      , OTH_COMMITTED_COST
1406        , ACT_LABOR_HRS
1407 	   , ACT_EQUIP_HRS
1408 	   , ACT_LABOR_BRDN_COST
1409 	   , ACT_EQUIP_BRDN_COST
1410 	   , ACT_BRDN_COST
1411 	   , ACT_RAW_COST
1412 	   , ACT_REVENUE
1413          , ACT_LABOR_RAW_COST
1414          , ACT_EQUIP_RAW_COST
1415 	   , ETC_LABOR_HRS
1416 	   , ETC_EQUIP_HRS
1417 	   , ETC_LABOR_BRDN_COST
1418 	   , ETC_EQUIP_BRDN_COST
1419 	   , ETC_BRDN_COST
1420          , ETC_RAW_COST
1421          , ETC_LABOR_RAW_COST
1422          , ETC_EQUIP_RAW_COST
1423      , CUSTOM1
1424      , CUSTOM2
1425      , CUSTOM3
1426      , CUSTOM4
1427      , CUSTOM5
1428      , CUSTOM6
1429      , CUSTOM7
1430      , CUSTOM8
1431      , CUSTOM9
1432      , CUSTOM10
1433      , CUSTOM11
1434      , CUSTOM12
1435      , CUSTOM13
1436      , CUSTOM14
1437      , CUSTOM15
1438      , LINE_TYPE
1439      , PLAN_TYPE_CODE
1440   )
1441   SELECT * FROM (
1442   SELECT
1443       g_worker_id
1444     , g_default_prg_level prg_level
1445     , fact1.PROJECT_ID
1446     , fact1.PROJECT_ORG_ID
1447     , fact1.PROJECT_ORGANIZATION_ID
1448     , fact1.PROJECT_ELEMENT_ID
1449     , l_time_id                             TIME_ID
1450     , l_period_type_id                      PERIOD_TYPE_ID
1451     , l_calendar_type                       CALENDAR_TYPE
1452     , fact1.RBS_AGGR_LEVEL
1453     , fact1.WBS_ROLLUP_FLAG
1454     , fact1.PRG_ROLLUP_FLAG
1455     , fact1.CURR_RECORD_TYPE_ID
1456     , fact1.CURRENCY_CODE
1457     , fact1.RBS_ELEMENT_ID
1458     , fact1.RBS_VERSION_ID
1459     , fact1.PLAN_VERSION_ID
1460 	, fact1.PLAN_TYPE_ID
1461     , SUM(fact1.RAW_COST)  RAW_COST
1462     , SUM(fact1.BRDN_COST)  BRDN_COST
1463     , SUM(fact1.REVENUE)  REVENUE
1464     , SUM(fact1.BILL_RAW_COST)  BILL_RAW_COST
1465     , SUM(fact1.BILL_BRDN_COST )  BILL_BRDN_COST
1466     , SUM(fact1.BILL_LABOR_RAW_COST)  BILL_LABOR_RAW_COST
1467     , SUM(fact1.BILL_LABOR_BRDN_COST )  BILL_LABOR_BRDN_COST
1468     , SUM(fact1.BILL_LABOR_HRS )  BILL_LABOR_HRS
1469     , SUM(fact1.EQUIPMENT_RAW_COST )  EQUIPMENT_RAW_COST
1470     , SUM(fact1.EQUIPMENT_BRDN_COST ) EQUIPMENT_BRDN_COST
1471     , SUM(fact1.CAPITALIZABLE_RAW_COST ) CAPITALIZABLE_RAW_COST
1472     , SUM(fact1.CAPITALIZABLE_BRDN_COST )   CAPITALIZABLE_BRDN_COST
1473     , SUM(fact1.LABOR_RAW_COST )  LABOR_RAW_COST
1474     , SUM(fact1.LABOR_BRDN_COST ) LABOR_BRDN_COST
1475     , SUM(fact1.LABOR_HRS)  LABOR_HRS
1479     , SUM(fact1.SUP_INV_COMMITTED_COST)   SUP_INV_COMMITTED_COST
1476     , SUM(fact1.LABOR_REVENUE)    LABOR_REVENUE
1477     , SUM(fact1.EQUIPMENT_HOURS)  EQUIPMENT_HOURS
1478     , SUM(fact1.BILLABLE_EQUIPMENT_HOURS)  BILLABLE_EQUIPMENT_HOURS
1480     , SUM(fact1.PO_COMMITTED_COST   )  PO_COMMITTED_COST
1481     , SUM(fact1.PR_COMMITTED_COST  ) PR_COMMITTED_COST
1482     , SUM(fact1.OTH_COMMITTED_COST)  OTH_COMMITTED_COST
1483        , SUM(fact1.ACT_LABOR_HRS)
1484 	 , SUM(fact1.ACT_EQUIP_HRS)
1485 	 , SUM(fact1.ACT_LABOR_BRDN_COST)
1486 	 , SUM(fact1.ACT_EQUIP_BRDN_COST)
1487 	 , SUM(fact1.ACT_BRDN_COST)
1488 	 , SUM(fact1.ACT_RAW_COST)
1489 	 , SUM(fact1.ACT_REVENUE)
1490        , SUM(fact1.ACT_LABOR_RAW_COST)
1491        , SUM(fact1.ACT_EQUIP_RAW_COST)
1492 	 , SUM(fact1.ETC_LABOR_HRS)
1493 	 , SUM(fact1.ETC_EQUIP_HRS)
1494 	 , SUM(fact1.ETC_LABOR_BRDN_COST)
1495 	 , SUM(fact1.ETC_EQUIP_BRDN_COST)
1496 	 , SUM(fact1.ETC_BRDN_COST )
1497        , SUM(fact1.ETC_RAW_COST )
1498        , SUM(fact1.ETC_LABOR_RAW_COST)
1499        , SUM(fact1.ETC_EQUIP_RAW_COST)
1500     , SUM(CUSTOM1	) CUSTOM1
1501     , SUM(CUSTOM2	) CUSTOM2
1502     , SUM(CUSTOM3	) CUSTOM3
1503     , SUM(CUSTOM4	) CUSTOM4
1504     , SUM(CUSTOM5	) CUSTOM5
1505     , SUM(CUSTOM6	) CUSTOM6
1506     , SUM(CUSTOM7	) CUSTOM7
1507     , SUM(CUSTOM8	) CUSTOM8
1508     , SUM(CUSTOM9	) CUSTOM9
1509     , SUM(CUSTOM10	) CUSTOM10
1510     , SUM(CUSTOM11	) CUSTOM11
1511     , SUM(CUSTOM12	) CUSTOM12
1512     , SUM(CUSTOM13	) CUSTOM13
1513     , SUM(CUSTOM14	) CUSTOM14
1514     , SUM(CUSTOM15) CUSTOM15
1515     , l_line_type
1516     , fact1.PLAN_TYPE_CODE PLAN_TYPE_CODE   /* 4471527 */
1517     FROM
1518 	  pji_fp_aggr_pjp1_t fact1  -- ,  PJI_FM_EXTR_PLNVER3_T ver
1519     , pji_fm_extr_plnver3_t  ver
1520     WHERE
1521         fact1.calendar_type = l_calendar_type
1522     AND fact1.period_type_id = l_period_type_id
1523     AND fact1.time_id = l_time_id
1524     AND fact1.worker_id = g_worker_id
1525 --    AND fact1.rbs_version_id IN (ver.rbs_struct_version_id, -1)   /* 4632551 */
1526   --  AND ( ver.rbs_struct_version_id = fact1.rbs_version_id  OR fact1.rbs_version_id = -1)
1527     AND NVL(ver.rbs_struct_version_id, -1) = fact1.rbs_version_id
1528     AND ver.secondary_rbs_flag = 'N'
1529     AND fact1.plan_version_id = ver.plan_version_id
1530     AND fact1.plan_type_code = ver.plan_type_code   /* 4471527 */
1531    GROUP BY
1532       fact1.PROJECT_ID
1533     , fact1.PROJECT_ORGANIZATION_ID
1534     , fact1.PROJECT_ORG_ID
1535     , fact1.PROJECT_ELEMENT_ID
1536     , fact1.RBS_AGGR_LEVEL
1537     , fact1.WBS_ROLLUP_FLAG
1538     , fact1.PRG_ROLLUP_FLAG
1539     , fact1.CURR_RECORD_TYPE_ID
1540     , fact1.CURRENCY_CODE
1541     , fact1.RBS_ELEMENT_ID
1542     , fact1.RBS_VERSION_ID
1543     , fact1.PLAN_VERSION_ID
1544     , fact1.PLAN_TYPE_ID
1545     , fact1.PLAN_TYPE_CODE) WHERE period_type_id > 32;
1546 
1547 
1548 EXCEPTION
1549   WHEN OTHERS THEN
1550     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
1551                              p_procedure_name => 'CREATE_FP_ALLT_PRI_AGGREGATE');
1552     RAISE;
1553 END;
1554 
1555 
1556 PROCEDURE CREATE_FP_ALLT_SEC_AGGREGATE IS
1557     -- l_last_update_date     date   := SYSDATE;
1558     -- l_last_updated_by      NUMBER := FND_GLOBAL.USER_ID;
1559     -- l_creation_date        date   := SYSDATE;
1560     -- l_created_by           NUMBER := FND_GLOBAL.USER_ID;
1561     l_last_update_login    NUMBER := FND_GLOBAL.LOGIN_ID;
1562     l_calendar_type        VARCHAR2(15) := 'A';
1563     l_line_type            VARCHAR2(15) := 'ATR';
1564     l_time_id              NUMBER := -1;
1565     l_period_type_id       NUMBER := 2048;
1566 
1567 BEGIN
1568 
1569   NULL;
1570 
1571 EXCEPTION
1572   WHEN OTHERS THEN
1573     RAISE;
1574 END;
1575 
1576 
1577 PROCEDURE CREATE_FP_PA_SEC_ROLLUP IS
1578     -- l_last_update_date     date   := SYSDATE;
1579     -- l_last_updated_by      NUMBER := FND_GLOBAL.USER_ID;
1580     -- l_creation_date        date   := SYSDATE;
1581     -- l_created_by           NUMBER := FND_GLOBAL.USER_ID;
1582     -- l_last_update_login    NUMBER := FND_GLOBAL.LOGIN_ID;
1583 BEGIN
1584 
1585   -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
1586 
1587   INSERT INTO pji_fp_aggr_pjp1_t
1588   (
1589        WORKER_ID
1590      , PROJECT_ID
1591      , PROJECT_ORG_ID
1592      , PROJECT_ORGANIZATION_ID
1593      -- , PARTITION_ID
1594      , PROJECT_ELEMENT_ID
1595      , TIME_ID
1596      , PERIOD_TYPE_ID
1597      , CALENDAR_TYPE
1598      , RBS_AGGR_LEVEL
1599      , WBS_ROLLUP_FLAG
1600      , PRG_ROLLUP_FLAG
1601      , CURR_RECORD_TYPE_ID
1602      , CURRENCY_CODE
1603      , RBS_ELEMENT_ID
1604      , RBS_VERSION_ID
1605      , PLAN_VERSION_ID
1606      , PLAN_TYPE_ID
1607      -- , LAST_UPDATE_DATE
1608      -- , LAST_UPDATED_BY
1609      -- , CREATION_DATE
1610      -- , CREATED_BY
1611      -- , LAST_UPDATE_LOGIN
1612      , RAW_COST
1613      , BRDN_COST
1614      , REVENUE
1615      , BILL_RAW_COST
1616      , BILL_BRDN_COST
1617      , BILL_LABOR_RAW_COST
1618      , BILL_LABOR_BRDN_COST
1619      , BILL_LABOR_HRS
1620      , EQUIPMENT_RAW_COST
1621      , EQUIPMENT_BRDN_COST
1622      , CAPITALIZABLE_RAW_COST
1623      , CAPITALIZABLE_BRDN_COST
1624      , LABOR_RAW_COST
1625      , LABOR_BRDN_COST
1626      , LABOR_HRS
1627      , LABOR_REVENUE
1631      , PO_COMMITTED_COST
1628      , EQUIPMENT_HOURS
1629      , BILLABLE_EQUIPMENT_HOURS
1630      , SUP_INV_COMMITTED_COST
1632      , PR_COMMITTED_COST
1633      , OTH_COMMITTED_COST
1634        , ACT_LABOR_HRS
1635 	   , ACT_EQUIP_HRS
1636 	   , ACT_LABOR_BRDN_COST
1637 	   , ACT_EQUIP_BRDN_COST
1638 	   , ACT_BRDN_COST
1639 	   , ACT_RAW_COST
1640 	   , ACT_REVENUE
1641          , ACT_LABOR_RAW_COST
1642          , ACT_EQUIP_RAW_COST
1643 	   , ETC_LABOR_HRS
1644 	   , ETC_EQUIP_HRS
1645 	   , ETC_LABOR_BRDN_COST
1646 	   , ETC_EQUIP_BRDN_COST
1647 	   , ETC_BRDN_COST
1648          , ETC_RAW_COST
1649          , ETC_LABOR_RAW_COST
1650          , ETC_EQUIP_RAW_COST
1651      , CUSTOM1
1652      , CUSTOM2
1653      , CUSTOM3
1654      , CUSTOM4
1655      , CUSTOM5
1656      , CUSTOM6
1657      , CUSTOM7
1658      , CUSTOM8
1659      , CUSTOM9
1660      , CUSTOM10
1661      , CUSTOM11
1662      , CUSTOM12
1663      , CUSTOM13
1664      , CUSTOM14
1665      , CUSTOM15
1666      , LINE_TYPE
1667      , PRG_LEVEL
1668      , PLAN_TYPE_CODE   /* 4471527 */
1669   )
1670   SELECT * FROM (
1671   SELECT
1672     -- GROUPING(qtr.CAL_YEAR_ID)  gy
1673     -- , GROUPING(period.CAL_QTR_ID)  gq
1674     -- , GROUPING(period.CAL_PERIOD_ID)  gp
1675 	-- ,
1676 	g_worker_id
1677     , fact1.PROJECT_ID
1678     , fact1.PROJECT_ORG_ID
1679     , fact1.PROJECT_ORGANIZATION_ID
1680     -- -- -- , fact1.PARTITION_ID
1681     , fact1.PROJECT_ELEMENT_ID
1682     , DECODE (
1683                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
1684              , '000', period.CAL_PERIOD_ID
1685              , '001', period.CAL_QTR_ID
1686              , '011', qtr.CAL_YEAR_ID
1687              , '111', -1 ) TIME_ID
1688     , DECODE (
1689                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
1690              , '000', 32
1691              , '001', 64
1692              , '011', 128
1693              , '111', 2048 ) PERIOD_TYPE_ID
1694     , DECODE (
1695                grouping(qtr.CAL_YEAR_ID)
1696              , 0 , 'P'
1697              , 'A') CALENDAR_TYPE
1698     , fact1.RBS_AGGR_LEVEL
1699     , fact1.WBS_ROLLUP_FLAG
1700     , fact1.PRG_ROLLUP_FLAG
1701     , fact1.CURR_RECORD_TYPE_ID
1702     , fact1.CURRENCY_CODE
1703     , fact1.RBS_ELEMENT_ID
1704     , fact1.RBS_VERSION_ID
1705     , fact1.PLAN_VERSION_ID
1706 	, fact1.PLAN_TYPE_ID
1707     -- , l_last_update_date
1708     -- , l_last_updated_by
1709     -- , l_creation_date
1710     -- , l_created_by
1711     -- , l_last_update_login
1712     , SUM(fact1.RAW_COST)
1713     , SUM(fact1.BRDN_COST)
1714     , SUM(fact1.REVENUE)
1715     , SUM(fact1.BILL_RAW_COST)
1716     , SUM(fact1.BILL_BRDN_COST )
1717     , SUM(fact1.BILL_LABOR_RAW_COST)
1718     , SUM(fact1.BILL_LABOR_BRDN_COST )
1719     , SUM(fact1.BILL_LABOR_HRS )
1720     , SUM(fact1.EQUIPMENT_RAW_COST )
1721     , SUM(fact1.EQUIPMENT_BRDN_COST )
1722     , SUM(fact1.CAPITALIZABLE_RAW_COST )
1723     , SUM(fact1.CAPITALIZABLE_BRDN_COST )
1724     , SUM(fact1.LABOR_RAW_COST )
1725     , SUM(fact1.LABOR_BRDN_COST )
1726     , SUM(fact1.LABOR_HRS)
1727     , SUM(fact1.LABOR_REVENUE)
1728     , SUM(fact1.EQUIPMENT_HOURS)
1729     , SUM(fact1.BILLABLE_EQUIPMENT_HOURS)
1730     , SUM(fact1.SUP_INV_COMMITTED_COST)
1731     , SUM(fact1.PO_COMMITTED_COST   )
1732     , SUM(fact1.PR_COMMITTED_COST  )
1733     , SUM(fact1.OTH_COMMITTED_COST)
1734        , SUM(fact1.ACT_LABOR_HRS)
1735 	 , SUM(fact1.ACT_EQUIP_HRS)
1736 	 , SUM(fact1.ACT_LABOR_BRDN_COST)
1737 	 , SUM(fact1.ACT_EQUIP_BRDN_COST)
1738 	 , SUM(fact1.ACT_BRDN_COST)
1739 	 , SUM(fact1.ACT_RAW_COST)
1740 	 , SUM(fact1.ACT_REVENUE)
1741        , SUM(fact1.ACT_LABOR_RAW_COST)
1742        , SUM(fact1.ACT_EQUIP_RAW_COST)
1743 	 , SUM(fact1.ETC_LABOR_HRS)
1744 	 , SUM(fact1.ETC_EQUIP_HRS)
1745 	 , SUM(fact1.ETC_LABOR_BRDN_COST)
1746 	 , SUM(fact1.ETC_EQUIP_BRDN_COST)
1747 	 , SUM(fact1.ETC_BRDN_COST )
1748        , SUM(fact1.ETC_RAW_COST )
1749        , SUM(fact1.ETC_LABOR_RAW_COST)
1750        , SUM(fact1.ETC_EQUIP_RAW_COST)
1751     , SUM(CUSTOM1	)
1752     , SUM(CUSTOM2	)
1753     , SUM(CUSTOM3	)
1754     , SUM(CUSTOM4	)
1755     , SUM(CUSTOM5	)
1756     , SUM(CUSTOM6	)
1757     , SUM(CUSTOM7	)
1758     , SUM(CUSTOM8	)
1759     , SUM(CUSTOM9	)
1760     , SUM(CUSTOM10	)
1761     , SUM(CUSTOM11	)
1762     , SUM(CUSTOM12	)
1763     , SUM(CUSTOM13	)
1764     , SUM(CUSTOM14	)
1765     , SUM(CUSTOM15)
1766     , 'PAR'
1767     , g_default_prg_level prg_level
1768     , fact1.plan_type_code plan_type_code     /* 4471527 */
1769    FROM
1770 	  pji_fp_aggr_pjp1_t fact1  -- ,  PJI_FM_EXTR_PLNVER3_T ver
1771     , pji_time_CAL_PERIOD period
1772     , pji_time_CAL_QTR    qtr
1773     , pji_fm_extr_plnver3_t  ver
1774    WHERE
1775         fact1.calendar_type = 'P'
1776     AND period.cal_period_id = fact1.time_id
1777     AND period.cal_qtr_id = qtr.cal_qtr_id
1778     AND fact1.period_type_id = 32
1779     AND fact1.line_type <> 'OF'
1780     AND fact1.worker_id = g_worker_id
1781   --  AND fact1.rbs_version_id IN (ver.rbs_struct_version_id, -1)   /* 4632551 */
1782     -- AND ( ver.rbs_struct_version_id = fact1.rbs_version_id  OR fact1.rbs_version_id = -1)
1783     AND NVL(ver.rbs_struct_version_id, -1) = fact1.rbs_version_id
1784     AND ver.secondary_rbs_flag = 'N'
1785     AND fact1.plan_version_id = ver.plan_version_id
1789     , fact1.PROJECT_ORGANIZATION_ID
1786     AND fact1.plan_type_code = ver.plan_type_code    /* 4471527 */
1787     GROUP BY
1788 	  fact1.PROJECT_ID
1790     , fact1.PROJECT_ORG_ID
1791     -- -- -- , fact1.PARTITION_ID
1792     , fact1.PROJECT_ELEMENT_ID
1793     , rollup (qtr.CAL_YEAR_ID,
1794               period.CAL_QTR_ID,
1795               period.CAL_PERIOD_ID)
1796     , fact1.calendar_type
1797     , fact1.RBS_AGGR_LEVEL
1798     , fact1.WBS_ROLLUP_FLAG
1799     , fact1.PRG_ROLLUP_FLAG
1800     , fact1.CURR_RECORD_TYPE_ID
1801     , fact1.CURRENCY_CODE
1802     , fact1.RBS_ELEMENT_ID
1803     , fact1.RBS_VERSION_ID
1804     , fact1.PLAN_VERSION_ID
1805     , fact1.PLAN_TYPE_ID
1806     , fact1.PLAN_TYPE_CODE)
1807    WHERE 1=1
1808      AND period_type_id > 32
1809      AND period_type_id < 2048;
1810 
1811 
1812 EXCEPTION
1813   WHEN OTHERS THEN
1814     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
1815                              p_procedure_name => 'CREATE_FP_ALLT_SEC_AGGREGATE');
1816     RAISE;
1817 END;
1818 
1819 
1820 PROCEDURE CREATE_FP_GL_SEC_ROLLUP IS
1821     -- l_last_update_date     date   := SYSDATE;
1822     -- l_last_updated_by      NUMBER := FND_GLOBAL.USER_ID;
1823     -- l_creation_date        date   := SYSDATE;
1824     -- l_created_by           NUMBER := FND_GLOBAL.USER_ID;
1825     -- l_last_update_login    NUMBER := FND_GLOBAL.LOGIN_ID;
1826 BEGIN
1827 
1828   -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
1829 
1830   INSERT INTO pji_fp_aggr_pjp1_t
1831   (
1832        WORKER_ID
1833      , PROJECT_ID
1834      , PROJECT_ORG_ID
1835      , PROJECT_ORGANIZATION_ID
1836      -- , PARTITION_ID
1837      , PROJECT_ELEMENT_ID
1838      , TIME_ID
1839      , PERIOD_TYPE_ID
1840      , CALENDAR_TYPE
1841      , RBS_AGGR_LEVEL
1842      , WBS_ROLLUP_FLAG
1843      , PRG_ROLLUP_FLAG
1844      , CURR_RECORD_TYPE_ID
1845      , CURRENCY_CODE
1846      , RBS_ELEMENT_ID
1847      , RBS_VERSION_ID
1848      , PLAN_VERSION_ID
1849      , PLAN_TYPE_ID
1850      -- , LAST_UPDATE_DATE
1851      -- , LAST_UPDATED_BY
1852      -- , CREATION_DATE
1853      -- , CREATED_BY
1854      -- , LAST_UPDATE_LOGIN
1855      , RAW_COST
1856      , BRDN_COST
1857      , REVENUE
1858      , BILL_RAW_COST
1859      , BILL_BRDN_COST
1860      , BILL_LABOR_RAW_COST
1861      , BILL_LABOR_BRDN_COST
1862      , BILL_LABOR_HRS
1863      , EQUIPMENT_RAW_COST
1864      , EQUIPMENT_BRDN_COST
1865      , CAPITALIZABLE_RAW_COST
1866      , CAPITALIZABLE_BRDN_COST
1867      , LABOR_RAW_COST
1868      , LABOR_BRDN_COST
1869      , LABOR_HRS
1870      , LABOR_REVENUE
1871      , EQUIPMENT_HOURS
1872      , BILLABLE_EQUIPMENT_HOURS
1873      , SUP_INV_COMMITTED_COST
1874      , PO_COMMITTED_COST
1875      , PR_COMMITTED_COST
1876      , OTH_COMMITTED_COST
1877        , ACT_LABOR_HRS
1878 	   , ACT_EQUIP_HRS
1879 	   , ACT_LABOR_BRDN_COST
1880 	   , ACT_EQUIP_BRDN_COST
1881 	   , ACT_BRDN_COST
1882 	   , ACT_RAW_COST
1883 	   , ACT_REVENUE
1884          , ACT_LABOR_RAW_COST
1885          , ACT_EQUIP_RAW_COST
1886 	   , ETC_LABOR_HRS
1887 	   , ETC_EQUIP_HRS
1888 	   , ETC_LABOR_BRDN_COST
1889 	   , ETC_EQUIP_BRDN_COST
1890 	   , ETC_BRDN_COST
1891          , ETC_RAW_COST
1892          , ETC_LABOR_RAW_COST
1893          , ETC_EQUIP_RAW_COST
1894      , CUSTOM1
1895      , CUSTOM2
1896      , CUSTOM3
1897      , CUSTOM4
1898      , CUSTOM5
1899      , CUSTOM6
1900      , CUSTOM7
1901      , CUSTOM8
1902      , CUSTOM9
1903      , CUSTOM10
1904      , CUSTOM11
1905      , CUSTOM12
1906      , CUSTOM13
1907      , CUSTOM14
1908      , CUSTOM15
1909      , LINE_TYPE
1910      , PRG_LEVEL
1911      , PLAN_TYPE_CODE     /* 4471527 */
1912   )
1913   SELECT * FROM (
1914   SELECT
1915     -- GROUPING(qtr.CAL_YEAR_ID)  gy
1916     -- , GROUPING(period.CAL_QTR_ID)  gq
1917     -- , GROUPING(period.CAL_PERIOD_ID)  gp
1918 	-- ,
1919 	g_worker_id
1920     , fact1.PROJECT_ID
1921     , fact1.PROJECT_ORG_ID
1922     , fact1.PROJECT_ORGANIZATION_ID
1923     -- -- -- , fact1.PARTITION_ID
1924     , fact1.PROJECT_ELEMENT_ID
1925     , DECODE (
1926                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
1927              , '000', period.CAL_PERIOD_ID
1928              , '001', period.CAL_QTR_ID
1929              , '011', qtr.CAL_YEAR_ID
1930              , '111', -1 ) TIME_ID
1931     , DECODE (
1932                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
1933              , '000', 32
1934              , '001', 64
1935              , '011', 128
1936              , '111', 2048 ) PERIOD_TYPE_ID
1937     , DECODE (
1938                grouping(qtr.CAL_YEAR_ID)
1939              , 0 , 'G'
1940              , 'A') CALENDAR_TYPE
1941     , fact1.RBS_AGGR_LEVEL
1942     , fact1.WBS_ROLLUP_FLAG
1943     , fact1.PRG_ROLLUP_FLAG
1944     , fact1.CURR_RECORD_TYPE_ID
1945     , fact1.CURRENCY_CODE
1946     , fact1.RBS_ELEMENT_ID
1947     , fact1.RBS_VERSION_ID
1948     , fact1.PLAN_VERSION_ID
1949     , fact1.PLAN_TYPE_ID
1950     -- , l_last_update_date
1951     -- , l_last_updated_by
1952     -- , l_creation_date
1953     -- , l_created_by
1957     , SUM(fact1.REVENUE)
1954     -- , l_last_update_login
1955     , SUM(fact1.RAW_COST)
1956     , SUM(fact1.BRDN_COST)
1958     , SUM(fact1.BILL_RAW_COST)
1959     , SUM(fact1.BILL_BRDN_COST )
1960     , SUM(fact1.BILL_LABOR_RAW_COST)
1961     , SUM(fact1.BILL_LABOR_BRDN_COST )
1962     , SUM(fact1.BILL_LABOR_HRS )
1963     , SUM(fact1.EQUIPMENT_RAW_COST )
1964     , SUM(fact1.EQUIPMENT_BRDN_COST )
1965     , SUM(fact1.CAPITALIZABLE_RAW_COST )
1966     , SUM(fact1.CAPITALIZABLE_BRDN_COST )
1967     , SUM(fact1.LABOR_RAW_COST )
1968     , SUM(fact1.LABOR_BRDN_COST )
1969     , SUM(fact1.LABOR_HRS)
1970     , SUM(fact1.LABOR_REVENUE)
1971     , SUM(fact1.EQUIPMENT_HOURS)
1972     , SUM(fact1.BILLABLE_EQUIPMENT_HOURS)
1973     , SUM(fact1.SUP_INV_COMMITTED_COST)
1974     , SUM(fact1.PO_COMMITTED_COST   )
1975     , SUM(fact1.PR_COMMITTED_COST  )
1976     , SUM(fact1.OTH_COMMITTED_COST)
1977        , SUM(fact1.ACT_LABOR_HRS)
1978 	 , SUM(fact1.ACT_EQUIP_HRS)
1979 	 , SUM(fact1.ACT_LABOR_BRDN_COST)
1980 	 , SUM(fact1.ACT_EQUIP_BRDN_COST)
1981 	 , SUM(fact1.ACT_BRDN_COST)
1982 	 , SUM(fact1.ACT_RAW_COST)
1983 	 , SUM(fact1.ACT_REVENUE)
1984        , SUM(fact1.ACT_LABOR_RAW_COST)
1985        , SUM(fact1.ACT_EQUIP_RAW_COST)
1986 	 , SUM(fact1.ETC_LABOR_HRS)
1987 	 , SUM(fact1.ETC_EQUIP_HRS)
1988 	 , SUM(fact1.ETC_LABOR_BRDN_COST)
1989 	 , SUM(fact1.ETC_EQUIP_BRDN_COST)
1990 	 , SUM(fact1.ETC_BRDN_COST )
1991        , SUM(fact1.ETC_RAW_COST )
1992        , SUM(fact1.ETC_LABOR_RAW_COST)
1993        , SUM(fact1.ETC_EQUIP_RAW_COST)
1994     , SUM(CUSTOM1	)
1995     , SUM(CUSTOM2	)
1996     , SUM(CUSTOM3	)
1997     , SUM(CUSTOM4	)
1998     , SUM(CUSTOM5	)
1999     , SUM(CUSTOM6	)
2000     , SUM(CUSTOM7	)
2001     , SUM(CUSTOM8	)
2002     , SUM(CUSTOM9	)
2003     , SUM(CUSTOM10)
2004     , SUM(CUSTOM11)
2005     , SUM(CUSTOM12)
2006     , SUM(CUSTOM13)
2007     , SUM(CUSTOM14)
2008     , SUM(CUSTOM15)
2009     , 'GLR'
2010     , g_default_prg_level prg_level
2011     , fact1.PLAN_TYPE_CODE  PLAN_TYPE_CODE   /* 4471527 */
2012     FROM
2013 	  pji_fp_aggr_pjp1_t fact1  -- ,  PJI_FM_EXTR_PLNVER3_T ver
2014     , pji_time_CAL_PERIOD period
2015 	, pji_time_CAL_QTR    qtr
2016     , pji_fm_extr_plnver3_t  ver
2017     WHERE
2018         fact1.calendar_type = 'G'
2019     AND period.cal_period_id = fact1.time_id
2020     AND period.cal_qtr_id = qtr.cal_qtr_id
2021     AND fact1.period_type_id = 32
2022     AND fact1.line_type <> 'OF'
2023     AND fact1.worker_id = g_worker_id
2024 --    AND fact1.rbs_version_id IN (ver.rbs_struct_version_id, -1)   /* 4632551 */
2025     -- AND ( ver.rbs_struct_version_id = fact1.rbs_version_id  OR fact1.rbs_version_id = -1)
2026     AND NVL(ver.rbs_struct_version_id, -1) = fact1.rbs_version_id
2027     AND ver.secondary_rbs_flag = 'N'
2028     AND fact1.plan_version_id = ver.plan_version_id
2029     AND fact1.plan_type_code = ver.plan_type_code    /* 4471527 */
2030   GROUP BY
2031 	  fact1.PROJECT_ID
2032     , fact1.PROJECT_ORGANIZATION_ID
2033     , fact1.PROJECT_ORG_ID
2034     -- -- -- , fact1.PARTITION_ID
2035     , fact1.PROJECT_ELEMENT_ID
2036     , rollup (qtr.CAL_YEAR_ID,
2037               period.CAL_QTR_ID,
2038               period.CAL_PERIOD_ID)
2039     , fact1.calendar_type
2040     , fact1.RBS_AGGR_LEVEL
2041     , fact1.WBS_ROLLUP_FLAG
2042     , fact1.PRG_ROLLUP_FLAG
2043     , fact1.CURR_RECORD_TYPE_ID
2044     , fact1.CURRENCY_CODE
2045     , fact1.RBS_ELEMENT_ID
2046     , fact1.RBS_VERSION_ID
2047     , fact1.PLAN_VERSION_ID
2048     , fact1.PLAN_TYPE_ID
2049     , fact1.PLAN_TYPE_CODE )
2050    WHERE 1=1
2051      AND period_type_id > 32
2052      AND period_type_id < 2048;
2053 
2054 
2055 EXCEPTION
2056   WHEN OTHERS THEN
2057     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
2058                              p_procedure_name => 'CREATE_FP_GL_SEC_ROLLUP');
2059     RAISE;
2060 END;
2061 
2062 
2063 PROCEDURE CREATE_FP_ENT_SEC_ROLLUP IS
2064     -- l_last_update_date     date   := SYSDATE;
2065     -- l_last_updated_by      NUMBER := FND_GLOBAL.USER_ID;
2066     -- l_creation_date        date   := SYSDATE;
2067     -- l_created_by           NUMBER := FND_GLOBAL.USER_ID;
2068     -- l_last_update_login    NUMBER := FND_GLOBAL.LOGIN_ID;
2069 BEGIN
2070 
2071   -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
2072 
2073   INSERT INTO pji_fp_aggr_pjp1_t
2074   (
2075        WORKER_ID
2076      , PROJECT_ID
2077      , PROJECT_ORG_ID
2078      , PROJECT_ORGANIZATION_ID
2079      -- , PARTITION_ID
2080      , PROJECT_ELEMENT_ID
2081      , TIME_ID
2082      , PERIOD_TYPE_ID
2083      , CALENDAR_TYPE
2084      , RBS_AGGR_LEVEL
2085      , WBS_ROLLUP_FLAG
2086      , PRG_ROLLUP_FLAG
2087      , CURR_RECORD_TYPE_ID
2088      , CURRENCY_CODE
2089      , RBS_ELEMENT_ID
2090      , RBS_VERSION_ID
2091      , PLAN_VERSION_ID
2092      , PLAN_TYPE_ID
2093      -- , LAST_UPDATE_DATE
2094      -- , LAST_UPDATED_BY
2095      -- , CREATION_DATE
2096      -- , CREATED_BY
2097      -- , LAST_UPDATE_LOGIN
2098      , RAW_COST
2099      , BRDN_COST
2100      , REVENUE
2101      , BILL_RAW_COST
2102      , BILL_BRDN_COST
2103      , BILL_LABOR_RAW_COST
2104      , BILL_LABOR_BRDN_COST
2105      , BILL_LABOR_HRS
2106      , EQUIPMENT_RAW_COST
2107      , EQUIPMENT_BRDN_COST
2108      , CAPITALIZABLE_RAW_COST
2109      , CAPITALIZABLE_BRDN_COST
2110      , LABOR_RAW_COST
2114      , EQUIPMENT_HOURS
2111      , LABOR_BRDN_COST
2112      , LABOR_HRS
2113      , LABOR_REVENUE
2115      , BILLABLE_EQUIPMENT_HOURS
2116      , SUP_INV_COMMITTED_COST
2117      , PO_COMMITTED_COST
2118      , PR_COMMITTED_COST
2119      , OTH_COMMITTED_COST
2120        , ACT_LABOR_HRS
2121 	   , ACT_EQUIP_HRS
2122 	   , ACT_LABOR_BRDN_COST
2123 	   , ACT_EQUIP_BRDN_COST
2124 	   , ACT_BRDN_COST
2125 	   , ACT_RAW_COST
2126 	   , ACT_REVENUE
2127          , ACT_LABOR_RAW_COST
2128          , ACT_EQUIP_RAW_COST
2129 	   , ETC_LABOR_HRS
2130 	   , ETC_EQUIP_HRS
2131 	   , ETC_LABOR_BRDN_COST
2132 	   , ETC_EQUIP_BRDN_COST
2133 	   , ETC_BRDN_COST
2134          , ETC_RAW_COST
2135          , ETC_LABOR_RAW_COST
2136          , ETC_EQUIP_RAW_COST
2137      , CUSTOM1
2138      , CUSTOM2
2139      , CUSTOM3
2140      , CUSTOM4
2141      , CUSTOM5
2142      , CUSTOM6
2143      , CUSTOM7
2144      , CUSTOM8
2145      , CUSTOM9
2146      , CUSTOM10
2147      , CUSTOM11
2148      , CUSTOM12
2149      , CUSTOM13
2150      , CUSTOM14
2151      , CUSTOM15
2152      , LINE_TYPE
2153      , PRG_LEVEL
2154      , PLAN_TYPE_CODE    /* 4471527 */
2155   )
2156   SELECT * FROM (
2157   SELECT
2158     --    GROUPING(qtr.ENT_YEAR_ID)  gy
2159     --, GROUPING(period.ENT_QTR_ID)  gq
2160     --, GROUPING(period.ENT_PERIOD_ID)  gp
2161 	--,
2162       g_worker_id
2163     , fact1.PROJECT_ID
2164     , fact1.PROJECT_ORG_ID
2165     , fact1.PROJECT_ORGANIZATION_ID
2166     -- -- -- , fact1.PARTITION_ID
2167     , fact1.PROJECT_ELEMENT_ID
2168     , DECODE (
2169                (grouping(qtr.ENT_YEAR_ID) || grouping(period.ENT_QTR_ID) || grouping(period.ENT_PERIOD_ID) )
2170              , '000', period.ENT_PERIOD_ID
2171              , '001', period.ENT_QTR_ID
2172              , '011', qtr.ENT_YEAR_ID
2173              , '111', -1 ) TIME_ID
2174     , DECODE (
2175                (grouping(qtr.ENT_YEAR_ID) || grouping(period.ENT_QTR_ID) || grouping(period.ENT_PERIOD_ID) )
2176              , '000', 32
2177              , '001', 64
2178              , '011', 128
2179              , '111', 2048 ) PERIOD_TYPE_ID
2180     , DECODE (
2181                grouping(qtr.ENT_YEAR_ID)
2182              , 0 , 'E'
2183              , 'A') CALENDAR_TYPE
2184     , RBS_AGGR_LEVEL
2185     , WBS_ROLLUP_FLAG
2186     , PRG_ROLLUP_FLAG
2187     , fact1.CURR_RECORD_TYPE_ID
2188     , fact1.CURRENCY_CODE
2189     , fact1.RBS_ELEMENT_ID
2190     , fact1.RBS_VERSION_ID
2191     , fact1.PLAN_VERSION_ID
2192     , fact1.plan_type_id
2193     -- , l_last_update_date
2194     -- , l_last_updated_by
2195     -- , l_creation_date
2196     -- , l_created_by
2197     -- , l_last_update_login
2198     , SUM(fact1.RAW_COST)
2199     , SUM(fact1.BRDN_COST)
2200     , SUM(fact1.REVENUE)
2201     , SUM(fact1.BILL_RAW_COST)
2202     , SUM(fact1.BILL_BRDN_COST )
2203     , SUM(fact1.BILL_LABOR_RAW_COST)
2204     , SUM(fact1.BILL_LABOR_BRDN_COST )
2205     , SUM(fact1.BILL_LABOR_HRS )
2206     , SUM(fact1.EQUIPMENT_RAW_COST )
2207     , SUM(fact1.EQUIPMENT_BRDN_COST )
2208     , SUM(fact1.CAPITALIZABLE_RAW_COST )
2209     , SUM(fact1.CAPITALIZABLE_BRDN_COST )
2210     , SUM(fact1.LABOR_RAW_COST )
2211     , SUM(fact1.LABOR_BRDN_COST )
2212     , SUM(fact1.LABOR_HRS)
2213     , SUM(fact1.LABOR_REVENUE)
2214     , SUM(fact1.EQUIPMENT_HOURS)
2215     , SUM(fact1.BILLABLE_EQUIPMENT_HOURS)
2216     , SUM(fact1.SUP_INV_COMMITTED_COST)
2217     , SUM(fact1.PO_COMMITTED_COST   )
2218     , SUM(fact1.PR_COMMITTED_COST  )
2219     , SUM(fact1.OTH_COMMITTED_COST)
2220        , SUM(fact1.ACT_LABOR_HRS)
2221 	 , SUM(fact1.ACT_EQUIP_HRS)
2222 	 , SUM(fact1.ACT_LABOR_BRDN_COST)
2223 	 , SUM(fact1.ACT_EQUIP_BRDN_COST)
2224 	 , SUM(fact1.ACT_BRDN_COST)
2225 	 , SUM(fact1.ACT_RAW_COST)
2226 	 , SUM(fact1.ACT_REVENUE)
2227        , SUM(fact1.ACT_LABOR_RAW_COST)
2228        , SUM(fact1.ACT_EQUIP_RAW_COST)
2229 	 , SUM(fact1.ETC_LABOR_HRS)
2230 	 , SUM(fact1.ETC_EQUIP_HRS)
2231 	 , SUM(fact1.ETC_LABOR_BRDN_COST)
2232 	 , SUM(fact1.ETC_EQUIP_BRDN_COST)
2233 	 , SUM(fact1.ETC_BRDN_COST )
2234        , SUM(fact1.ETC_RAW_COST )
2235        , SUM(fact1.ETC_LABOR_RAW_COST)
2236        , SUM(fact1.ETC_EQUIP_RAW_COST)
2237     , SUM(CUSTOM1	)
2238     , SUM(CUSTOM2	)
2239     , SUM(CUSTOM3	)
2240     , SUM(CUSTOM4	)
2241     , SUM(CUSTOM5	)
2242     , SUM(CUSTOM6	)
2243     , SUM(CUSTOM7	)
2244     , SUM(CUSTOM8	)
2245     , SUM(CUSTOM9	)
2246     , SUM(CUSTOM10	)
2247     , SUM(CUSTOM11	)
2248     , SUM(CUSTOM12	)
2249     , SUM(CUSTOM13	)
2250     , SUM(CUSTOM14	)
2251     , SUM(CUSTOM15)
2252     , 'ENTR'
2253     , g_default_prg_level prg_level
2254     , fact1.PLAN_TYPE_CODE PLAN_TYPE_CODE    /* 4471527 */
2255     FROM
2256 	  pji_fp_aggr_pjp1_t fact1  -- ,  PJI_FM_EXTR_PLNVER3_T ver
2257       , pji_time_ENT_PERIOD period
2258 	, pji_time_ENT_QTR    qtr
2259     , pji_fm_extr_plnver3_t  ver
2260     WHERE
2261         fact1.calendar_type = 'E'
2262     AND period.ENT_period_id = fact1.time_id
2263     AND period.ENT_qtr_id = qtr.ENT_qtr_id
2264     AND fact1.period_type_id = 32
2265     AND fact1.worker_id = g_worker_id
2266 --    AND fact1.rbs_version_id IN (ver.rbs_struct_version_id, -1)   /* 4632551 */
2267     -- AND ( ver.rbs_struct_version_id = fact1.rbs_version_id  OR fact1.rbs_version_id = -1)
2271     AND fact1.plan_type_code = ver.plan_type_code    /*  4471527 */
2268     AND NVL(ver.rbs_struct_version_id, -1) = fact1.rbs_version_id
2269     AND ver.secondary_rbs_flag = 'N'
2270     AND fact1.plan_version_id = ver.plan_version_id
2272   GROUP BY
2273       fact1.PROJECT_ID
2274     , fact1.PROJECT_ORG_ID
2275     , fact1.PROJECT_ORGANIZATION_ID
2276     -- -- -- , fact1.PARTITION_ID
2277     , fact1.PROJECT_ELEMENT_ID
2278     , fact1.calendar_type
2279     , RBS_AGGR_LEVEL
2280     , WBS_ROLLUP_FLAG
2281     , PRG_ROLLUP_FLAG
2282     , fact1.CURR_RECORD_TYPE_ID
2283     , fact1.CURRENCY_CODE
2284     , fact1.RBS_ELEMENT_ID
2285     , fact1.RBS_VERSION_ID
2286     , fact1.PLAN_VERSION_ID
2287     , fact1.plan_type_id
2288     , fact1.plan_type_code    /*4471527 */
2289     , rollup (qtr.ENT_YEAR_ID,
2290               period.ENT_QTR_ID,
2291               period.ENT_PERIOD_ID))
2292    WHERE 1=1
2293      AND period_type_id > 32
2294      AND period_type_id < 2048;
2295 
2296 EXCEPTION
2297   WHEN OTHERS THEN
2298     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
2299                              p_procedure_name => 'CREATE_FP_ENT_SEC_ROLLUP');
2300     RAISE;
2301 END;
2302 
2303 
2304 PROCEDURE CREATE_AC_PA_ROLLUP IS
2305 BEGIN
2306 
2307     -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
2308 
2309     INSERT INTO pji_ac_aggr_pjp1_t
2310     (
2311        WORKER_ID
2312      , PROJECT_ID
2313      , PROJECT_ORG_ID
2314      , PROJECT_ORGANIZATION_ID
2315      -- , PARTITION_ID
2316      , PROJECT_ELEMENT_ID
2317      , TIME_ID
2318      , PERIOD_TYPE_ID
2319      , CALENDAR_TYPE
2320      , WBS_ROLLUP_FLAG
2321      , PRG_ROLLUP_FLAG
2322      , CURR_RECORD_TYPE_ID
2323      , CURRENCY_CODE
2324      , REVENUE
2325      , INITIAL_FUNDING_AMOUNT
2326      , INITIAL_FUNDING_COUNT
2327      , ADDITIONAL_FUNDING_AMOUNT
2328      , ADDITIONAL_FUNDING_COUNT
2329      , CANCELLED_FUNDING_AMOUNT
2330      , CANCELLED_FUNDING_COUNT
2331      , FUNDING_ADJUSTMENT_AMOUNT
2332      , FUNDING_ADJUSTMENT_COUNT
2333      , REVENUE_WRITEOFF
2334      , AR_INVOICE_AMOUNT
2335      , AR_INVOICE_COUNT
2336      , AR_CASH_APPLIED_AMOUNT
2337      , AR_INVOICE_WRITE_OFF_AMOUNT
2338      , AR_INVOICE_WRITEOFF_COUNT
2339      , AR_CREDIT_MEMO_AMOUNT
2340      , AR_CREDIT_MEMO_COUNT
2341      , UNBILLED_RECEIVABLES
2342      , UNEARNED_REVENUE
2343      , AR_UNAPPR_INVOICE_AMOUNT
2344      , AR_UNAPPR_INVOICE_COUNT
2345      , AR_APPR_INVOICE_AMOUNT
2346      , AR_APPR_INVOICE_COUNT
2347      , AR_AMOUNT_DUE
2348      , AR_COUNT_DUE
2349      , AR_AMOUNT_OVERDUE
2350      , AR_COUNT_OVERDUE
2351      , DORMANT_BACKLOG_INACTIV
2352      , DORMANT_BACKLOG_START
2353      , LOST_BACKLOG
2354      , ACTIVE_BACKLOG
2355      , REVENUE_AT_RISK
2356      , CUSTOM1
2357      , CUSTOM2
2358      , CUSTOM3
2359      , CUSTOM4
2360      , CUSTOM5
2361      , CUSTOM6
2362      , CUSTOM7
2363      , CUSTOM8
2364      , CUSTOM9
2365      , CUSTOM10
2366      , CUSTOM11
2367      , CUSTOM12
2368      , CUSTOM13
2369      , CUSTOM14
2370      , CUSTOM15
2371      , PRG_LEVEL
2372     )
2373   SELECT * FROM (
2374     SELECT
2375       -- GROUPING(qtr.CAL_YEAR_ID)  gy
2376       -- , GROUPING(period.CAL_QTR_ID)  gq
2377       -- , GROUPING(period.CAL_PERIOD_ID)  gp
2378       -- ,
2379        g_worker_id
2380      , fact1.PROJECT_ID
2381      , fact1.PROJECT_ORG_ID
2382      , fact1.PROJECT_ORGANIZATION_ID
2383      -- -- -- , fact1.PARTITION_ID
2384      , fact1.PROJECT_ELEMENT_ID
2385      , DECODE (
2386                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
2387              , '000', period.CAL_PERIOD_ID
2388              , '001', period.CAL_QTR_ID
2389              , '011', qtr.CAL_YEAR_ID
2390              , '111', -1 ) TIME_ID
2391      , DECODE (
2392                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
2393              , '000', 32
2394              , '001', 64
2395              , '011', 128
2396              , '111', 2048 ) PERIOD_TYPE_ID
2397      , fact1.CALENDAR_TYPE
2398      , fact1.WBS_ROLLUP_FLAG
2399      , fact1.PRG_ROLLUP_FLAG
2400      , fact1.CURR_RECORD_TYPE_ID
2401      , fact1.CURRENCY_CODE
2402      , SUM(fact1.REVENUE )
2403      , SUM(fact1.INITIAL_FUNDING_AMOUNT )
2404      , SUM(fact1.INITIAL_FUNDING_COUNT)
2405      , SUM(fact1.ADDITIONAL_FUNDING_AMOUNT)
2406      , SUM(fact1.ADDITIONAL_FUNDING_COUNT  )
2407      , SUM(fact1.CANCELLED_FUNDING_AMOUNT)
2408      , SUM(fact1.CANCELLED_FUNDING_COUNT)
2409      , SUM(fact1.FUNDING_ADJUSTMENT_AMOUNT)
2410      , SUM(fact1.FUNDING_ADJUSTMENT_COUNT)
2411      , SUM(fact1.REVENUE_WRITEOFF)
2412      , SUM(fact1.AR_INVOICE_AMOUNT)
2413      , SUM(fact1.AR_INVOICE_COUNT)
2414      , SUM(fact1.AR_CASH_APPLIED_AMOUNT)
2415      , SUM(fact1.AR_INVOICE_WRITE_OFF_AMOUNT)
2416      , SUM(fact1.AR_INVOICE_WRITEOFF_COUNT)
2417      , SUM(fact1.AR_CREDIT_MEMO_AMOUNT)
2418      , SUM(fact1.AR_CREDIT_MEMO_COUNT)
2419      , SUM(fact1.UNBILLED_RECEIVABLES)
2420      , SUM(fact1.UNEARNED_REVENUE)
2421      , SUM(fact1.AR_UNAPPR_INVOICE_AMOUNT)
2422      , SUM(fact1.AR_UNAPPR_INVOICE_COUNT)
2423      , SUM(fact1.AR_APPR_INVOICE_AMOUNT)
2424      , SUM(fact1.AR_APPR_INVOICE_COUNT)
2428      , SUM(fact1.AR_COUNT_OVERDUE)
2425      , SUM(fact1.AR_AMOUNT_DUE)
2426      , SUM(fact1.AR_COUNT_DUE)
2427      , SUM(fact1.AR_AMOUNT_OVERDUE)
2429      , SUM(fact1.DORMANT_BACKLOG_INACTIV)
2430      , SUM(fact1.DORMANT_BACKLOG_START)
2431      , SUM(fact1.LOST_BACKLOG)
2432      , SUM(fact1.ACTIVE_BACKLOG)
2433      , SUM(fact1.REVENUE_AT_RISK)
2434      , SUM(fact1.CUSTOM1)
2435      , SUM(fact1.CUSTOM2)
2436      , SUM(fact1.CUSTOM3)
2437      , SUM(fact1.CUSTOM4)
2438      , SUM(fact1.CUSTOM5)
2439      , SUM(fact1.CUSTOM6)
2440      , SUM(fact1.CUSTOM7)
2441      , SUM(fact1.CUSTOM8)
2442      , SUM(fact1.CUSTOM9)
2443      , SUM(fact1.CUSTOM10)
2444      , SUM(fact1.CUSTOM11)
2445      , SUM(fact1.CUSTOM12)
2446      , SUM(fact1.CUSTOM13)
2447      , SUM(fact1.CUSTOM14)
2448      , SUM(fact1.CUSTOM15)
2449      , g_default_prg_level prg_level
2450     FROM
2451       pji_ac_aggr_pjp1_t fact1
2452     , pji_time_CAL_PERIOD period
2453 	, pji_time_CAL_QTR    qtr
2454     WHERE
2455         fact1.calendar_type = 'P'
2456     AND period.cal_period_id = fact1.time_id
2457     AND period.cal_qtr_id = qtr.cal_qtr_id
2458     AND fact1.period_type_id = 32
2459     AND fact1.worker_id = g_worker_id
2460   GROUP BY
2461        fact1.PROJECT_ID
2462      , fact1.PROJECT_ORG_ID
2463      , fact1.PROJECT_ORGANIZATION_ID
2464      -- -- -- , fact1.PARTITION_ID
2465      , fact1.PROJECT_ELEMENT_ID
2466      , fact1.CALENDAR_TYPE
2467      , rollup (qtr.CAL_YEAR_ID,
2468                period.CAL_QTR_ID,
2469                period.CAL_PERIOD_ID)
2470      , fact1.WBS_ROLLUP_FLAG
2471      , fact1.PRG_ROLLUP_FLAG
2472      , fact1.CURR_RECORD_TYPE_ID
2473      , fact1.CURRENCY_CODE )
2474    WHERE 1=1
2475      AND period_type_id > 32
2476      AND period_type_id < 2048;
2477 
2478 
2479 EXCEPTION
2480   WHEN OTHERS THEN
2481     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
2482                              p_procedure_name => 'CREATE_AC_PA_ROLLUP');
2483     RAISE;
2484 END;
2485 
2486 
2487 PROCEDURE CREATE_AC_GL_ROLLUP IS
2488 BEGIN
2489 
2490     -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
2491 
2492     INSERT INTO pji_ac_aggr_pjp1_t
2493     (
2494        worker_id
2495      , PROJECT_ID
2496      , PROJECT_ORG_ID
2497      , PROJECT_ORGANIZATION_ID
2498      -- , PARTITION_ID
2499      , PROJECT_ELEMENT_ID
2500      , TIME_ID
2501      , PERIOD_TYPE_ID
2502      , CALENDAR_TYPE
2503      , WBS_ROLLUP_FLAG
2504      , PRG_ROLLUP_FLAG
2505      , CURR_RECORD_TYPE_ID
2506      , CURRENCY_CODE
2507      , REVENUE
2508      , INITIAL_FUNDING_AMOUNT
2509      , INITIAL_FUNDING_COUNT
2510      , ADDITIONAL_FUNDING_AMOUNT
2511      , ADDITIONAL_FUNDING_COUNT
2512      , CANCELLED_FUNDING_AMOUNT
2513      , CANCELLED_FUNDING_COUNT
2514      , FUNDING_ADJUSTMENT_AMOUNT
2515      , FUNDING_ADJUSTMENT_COUNT
2516      , REVENUE_WRITEOFF
2517      , AR_INVOICE_AMOUNT
2518      , AR_INVOICE_COUNT
2519      , AR_CASH_APPLIED_AMOUNT
2520      , AR_INVOICE_WRITE_OFF_AMOUNT
2521      , AR_INVOICE_WRITEOFF_COUNT
2522      , AR_CREDIT_MEMO_AMOUNT
2523      , AR_CREDIT_MEMO_COUNT
2524      , UNBILLED_RECEIVABLES
2525      , UNEARNED_REVENUE
2526      , AR_UNAPPR_INVOICE_AMOUNT
2527      , AR_UNAPPR_INVOICE_COUNT
2528      , AR_APPR_INVOICE_AMOUNT
2529      , AR_APPR_INVOICE_COUNT
2530      , AR_AMOUNT_DUE
2531      , AR_COUNT_DUE
2532      , AR_AMOUNT_OVERDUE
2533      , AR_COUNT_OVERDUE
2534      , DORMANT_BACKLOG_INACTIV
2535      , DORMANT_BACKLOG_START
2536      , LOST_BACKLOG
2537      , ACTIVE_BACKLOG
2538      , REVENUE_AT_RISK
2539      , CUSTOM1
2540      , CUSTOM2
2541      , CUSTOM3
2542      , CUSTOM4
2543      , CUSTOM5
2544      , CUSTOM6
2545      , CUSTOM7
2546      , CUSTOM8
2547      , CUSTOM9
2548      , CUSTOM10
2549      , CUSTOM11
2550      , CUSTOM12
2551      , CUSTOM13
2552      , CUSTOM14
2553      , CUSTOM15
2554      , PRG_LEVEL
2555     )
2556   SELECT * FROM (
2557     SELECT
2558       -- GROUPING(qtr.CAL_YEAR_ID)  gy
2559       -- , GROUPING(period.CAL_QTR_ID)  gq
2560       -- , GROUPING(period.CAL_PERIOD_ID)  gp
2561       -- ,
2562        g_worker_id
2563      , fact1.PROJECT_ID
2564      , fact1.PROJECT_ORG_ID
2565      , fact1.PROJECT_ORGANIZATION_ID
2566      -- -- -- , fact1.PARTITION_ID
2567      , fact1.PROJECT_ELEMENT_ID
2568      , DECODE (
2569                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
2570              , '000', period.CAL_PERIOD_ID
2571              , '001', period.CAL_QTR_ID
2572              , '011', qtr.CAL_YEAR_ID
2573              , '111', -1 ) TIME_ID
2574      , DECODE (
2575                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
2576              , '000', 32
2577              , '001', 64
2578              , '011', 128
2579              , '111', 2048 ) PERIOD_TYPE_ID
2580      , fact1.CALENDAR_TYPE
2581      , fact1.WBS_ROLLUP_FLAG
2582      , fact1.PRG_ROLLUP_FLAG
2583      , fact1.CURR_RECORD_TYPE_ID
2584      , fact1.CURRENCY_CODE
2585      , SUM(fact1.REVENUE )
2586      , SUM(fact1.INITIAL_FUNDING_AMOUNT )
2587      , SUM(fact1.INITIAL_FUNDING_COUNT)
2588      , SUM(fact1.ADDITIONAL_FUNDING_AMOUNT)
2589      , SUM(fact1.ADDITIONAL_FUNDING_COUNT  )
2593      , SUM(fact1.FUNDING_ADJUSTMENT_COUNT)
2590      , SUM(fact1.CANCELLED_FUNDING_AMOUNT)
2591      , SUM(fact1.CANCELLED_FUNDING_COUNT)
2592      , SUM(fact1.FUNDING_ADJUSTMENT_AMOUNT)
2594      , SUM(fact1.REVENUE_WRITEOFF)
2595      , SUM(fact1.AR_INVOICE_AMOUNT)
2596      , SUM(fact1.AR_INVOICE_COUNT)
2597      , SUM(fact1.AR_CASH_APPLIED_AMOUNT)
2598      , SUM(fact1.AR_INVOICE_WRITE_OFF_AMOUNT)
2599      , SUM(fact1.AR_INVOICE_WRITEOFF_COUNT)
2600      , SUM(fact1.AR_CREDIT_MEMO_AMOUNT)
2601      , SUM(fact1.AR_CREDIT_MEMO_COUNT)
2602      , SUM(fact1.UNBILLED_RECEIVABLES)
2603      , SUM(fact1.UNEARNED_REVENUE)
2604      , SUM(fact1.AR_UNAPPR_INVOICE_AMOUNT)
2605      , SUM(fact1.AR_UNAPPR_INVOICE_COUNT)
2606      , SUM(fact1.AR_APPR_INVOICE_AMOUNT)
2607      , SUM(fact1.AR_APPR_INVOICE_COUNT)
2608      , SUM(fact1.AR_AMOUNT_DUE)
2609      , SUM(fact1.AR_COUNT_DUE)
2610      , SUM(fact1.AR_AMOUNT_OVERDUE)
2611      , SUM(fact1.AR_COUNT_OVERDUE)
2612      , SUM(fact1.DORMANT_BACKLOG_INACTIV)
2613      , SUM(fact1.DORMANT_BACKLOG_START)
2614      , SUM(fact1.LOST_BACKLOG)
2615      , SUM(fact1.ACTIVE_BACKLOG)
2616      , SUM(fact1.REVENUE_AT_RISK)
2617      , SUM(fact1.CUSTOM1)
2618      , SUM(fact1.CUSTOM2)
2619      , SUM(fact1.CUSTOM3)
2620      , SUM(fact1.CUSTOM4)
2621      , SUM(fact1.CUSTOM5)
2622      , SUM(fact1.CUSTOM6)
2623      , SUM(fact1.CUSTOM7)
2624      , SUM(fact1.CUSTOM8)
2625      , SUM(fact1.CUSTOM9)
2626      , SUM(fact1.CUSTOM10)
2627      , SUM(fact1.CUSTOM11)
2628      , SUM(fact1.CUSTOM12)
2629      , SUM(fact1.CUSTOM13)
2630      , SUM(fact1.CUSTOM14)
2631      , SUM(fact1.CUSTOM15)
2632      , g_default_prg_level prg_level
2633     FROM
2634       pji_ac_aggr_pjp1_t fact1
2635     , pji_time_CAL_PERIOD period
2636 	, pji_time_CAL_QTR    qtr
2637     WHERE
2638           fact1.calendar_type = 'G'
2639       AND period.cal_period_id = fact1.time_id
2640 	AND period.cal_qtr_id = qtr.cal_qtr_id
2641       AND fact1.period_type_id = 32
2642       AND fact1.worker_id = g_worker_id
2643     GROUP BY
2644        fact1.PROJECT_ID
2645      , fact1.PROJECT_ORG_ID
2646      , fact1.PROJECT_ORGANIZATION_ID
2647      -- -- -- , fact1.PARTITION_ID
2648      , fact1.PROJECT_ELEMENT_ID
2649      , fact1.CALENDAR_TYPE
2650      , rollup (qtr.CAL_YEAR_ID,
2651                period.CAL_QTR_ID,
2652                period.CAL_PERIOD_ID)
2653      , fact1.WBS_ROLLUP_FLAG
2654      , fact1.PRG_ROLLUP_FLAG
2655      , fact1.CURR_RECORD_TYPE_ID
2656      , fact1.CURRENCY_CODE )
2657    WHERE 1=1
2658      AND period_type_id > 32
2659      AND period_type_id < 2048;
2660 
2661 EXCEPTION
2662   WHEN OTHERS THEN
2663     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
2664                              p_procedure_name => 'CREATE_AC_GL_ROLLUP');
2665     RAISE;
2666 END;
2667 
2668 
2669 PROCEDURE CREATE_AC_ENT_ROLLUP IS
2670 BEGIN
2671 
2672   -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
2673 
2674   INSERT INTO pji_ac_aggr_pjp1_t
2675   (
2676        worker_id
2677      , PROJECT_ID
2678      , PROJECT_ORG_ID
2679      , PROJECT_ORGANIZATION_ID
2680      -- , PARTITION_ID
2681      , PROJECT_ELEMENT_ID
2682      , TIME_ID
2683      , PERIOD_TYPE_ID
2684      , CALENDAR_TYPE
2685      , WBS_ROLLUP_FLAG
2686      , PRG_ROLLUP_FLAG
2687      , CURR_RECORD_TYPE_ID
2688      , CURRENCY_CODE
2689      , REVENUE
2690      , INITIAL_FUNDING_AMOUNT
2691      , INITIAL_FUNDING_COUNT
2692      , ADDITIONAL_FUNDING_AMOUNT
2693      , ADDITIONAL_FUNDING_COUNT
2694      , CANCELLED_FUNDING_AMOUNT
2695      , CANCELLED_FUNDING_COUNT
2696      , FUNDING_ADJUSTMENT_AMOUNT
2697      , FUNDING_ADJUSTMENT_COUNT
2698      , REVENUE_WRITEOFF
2699      , AR_INVOICE_AMOUNT
2700      , AR_INVOICE_COUNT
2701      , AR_CASH_APPLIED_AMOUNT
2702      , AR_INVOICE_WRITE_OFF_AMOUNT
2703      , AR_INVOICE_WRITEOFF_COUNT
2704      , AR_CREDIT_MEMO_AMOUNT
2705      , AR_CREDIT_MEMO_COUNT
2706      , UNBILLED_RECEIVABLES
2707      , UNEARNED_REVENUE
2708      , AR_UNAPPR_INVOICE_AMOUNT
2709      , AR_UNAPPR_INVOICE_COUNT
2710      , AR_APPR_INVOICE_AMOUNT
2711      , AR_APPR_INVOICE_COUNT
2712      , AR_AMOUNT_DUE
2713      , AR_COUNT_DUE
2714      , AR_AMOUNT_OVERDUE
2715      , AR_COUNT_OVERDUE
2716      , DORMANT_BACKLOG_INACTIV
2717      , DORMANT_BACKLOG_START
2718      , LOST_BACKLOG
2719      , ACTIVE_BACKLOG
2720      , REVENUE_AT_RISK
2721      , CUSTOM1
2722      , CUSTOM2
2723      , CUSTOM3
2724      , CUSTOM4
2725      , CUSTOM5
2726      , CUSTOM6
2727      , CUSTOM7
2728      , CUSTOM8
2729      , CUSTOM9
2730      , CUSTOM10
2731      , CUSTOM11
2732      , CUSTOM12
2733      , CUSTOM13
2734      , CUSTOM14
2735      , CUSTOM15
2736      , PRG_LEVEL
2737   )
2738   SELECT * FROM (
2739   SELECT
2740       -- GROUPING(qtr.CAL_YEAR_ID)  gy
2741       -- , GROUPING(period.CAL_QTR_ID)  gq
2742       -- , GROUPING(period.CAL_PERIOD_ID)  gp
2743       -- ,
2744        g_worker_id
2745      , fact1.PROJECT_ID
2746      , fact1.PROJECT_ORG_ID
2747      , fact1.PROJECT_ORGANIZATION_ID
2748      -- -- -- , fact1.PARTITION_ID
2749      , fact1.PROJECT_ELEMENT_ID
2750      , DECODE (
2751                (grouping(qtr.ENT_YEAR_ID) || grouping(period.ENT_QTR_ID) || grouping(period.ENT_PERIOD_ID) )
2755              , '111', -1 ) TIME_ID
2752              , '000', period.ENT_PERIOD_ID
2753              , '001', period.ENT_QTR_ID
2754              , '011', qtr.ENT_YEAR_ID
2756      , DECODE (
2757                (grouping(qtr.ENT_YEAR_ID) || grouping(period.ENT_QTR_ID) || grouping(period.ENT_PERIOD_ID) )
2758              , '000', 32
2759              , '001', 64
2760              , '011', 128
2761              , '111', 2048 ) PERIOD_TYPE_ID
2762      , fact1.CALENDAR_TYPE
2763      , fact1.WBS_ROLLUP_FLAG
2764      , fact1.PRG_ROLLUP_FLAG
2765      , fact1.CURR_RECORD_TYPE_ID
2766      , fact1.CURRENCY_CODE
2767      , SUM(fact1.REVENUE )
2768      , SUM(fact1.INITIAL_FUNDING_AMOUNT )
2769      , SUM(fact1.INITIAL_FUNDING_COUNT)
2770      , SUM(fact1.ADDITIONAL_FUNDING_AMOUNT)
2771      , SUM(fact1.ADDITIONAL_FUNDING_COUNT  )
2772      , SUM(fact1.CANCELLED_FUNDING_AMOUNT)
2773      , SUM(fact1.CANCELLED_FUNDING_COUNT)
2774      , SUM(fact1.FUNDING_ADJUSTMENT_AMOUNT)
2775      , SUM(fact1.FUNDING_ADJUSTMENT_COUNT)
2776      , SUM(fact1.REVENUE_WRITEOFF)
2777      , SUM(fact1.AR_INVOICE_AMOUNT)
2778      , SUM(fact1.AR_INVOICE_COUNT)
2779      , SUM(fact1.AR_CASH_APPLIED_AMOUNT)
2780      , SUM(fact1.AR_INVOICE_WRITE_OFF_AMOUNT)
2781      , SUM(fact1.AR_INVOICE_WRITEOFF_COUNT)
2782      , SUM(fact1.AR_CREDIT_MEMO_AMOUNT)
2783      , SUM(fact1.AR_CREDIT_MEMO_COUNT)
2784      , SUM(fact1.UNBILLED_RECEIVABLES)
2785      , SUM(fact1.UNEARNED_REVENUE)
2786      , SUM(fact1.AR_UNAPPR_INVOICE_AMOUNT)
2787      , SUM(fact1.AR_UNAPPR_INVOICE_COUNT)
2788      , SUM(fact1.AR_APPR_INVOICE_AMOUNT)
2789      , SUM(fact1.AR_APPR_INVOICE_COUNT)
2790      , SUM(fact1.AR_AMOUNT_DUE)
2791      , SUM(fact1.AR_COUNT_DUE)
2792      , SUM(fact1.AR_AMOUNT_OVERDUE)
2793      , SUM(fact1.AR_COUNT_OVERDUE)
2794      , SUM(fact1.DORMANT_BACKLOG_INACTIV)
2795      , SUM(fact1.DORMANT_BACKLOG_START)
2796      , SUM(fact1.LOST_BACKLOG)
2797      , SUM(fact1.ACTIVE_BACKLOG)
2798      , SUM(fact1.REVENUE_AT_RISK)
2799      , SUM(fact1.CUSTOM1)
2800      , SUM(fact1.CUSTOM2)
2801      , SUM(fact1.CUSTOM3)
2802      , SUM(fact1.CUSTOM4)
2803      , SUM(fact1.CUSTOM5)
2804      , SUM(fact1.CUSTOM6)
2805      , SUM(fact1.CUSTOM7)
2806      , SUM(fact1.CUSTOM8)
2807      , SUM(fact1.CUSTOM9)
2808      , SUM(fact1.CUSTOM10)
2809      , SUM(fact1.CUSTOM11)
2810      , SUM(fact1.CUSTOM12)
2811      , SUM(fact1.CUSTOM13)
2812      , SUM(fact1.CUSTOM14)
2813      , SUM(fact1.CUSTOM15)
2814      , g_default_prg_level prg_level
2815     FROM
2816 	   pji_ac_aggr_pjp1_t fact1
2817      , pji_time_ENT_PERIOD period
2818  	 , pji_time_ENT_QTR    qtr
2819     WHERE
2820         fact1.calendar_type = 'E'
2821     AND period.ENT_period_id = fact1.time_id
2822     AND period.ENT_qtr_id = qtr.ENT_qtr_id
2823     AND fact1.period_type_id = 32
2824     AND fact1.worker_id = g_worker_id
2825   GROUP BY
2826        fact1.PROJECT_ID
2827      , fact1.PROJECT_ORG_ID
2828      , fact1.PROJECT_ORGANIZATION_ID
2829      -- -- -- , fact1.PARTITION_ID
2830      , fact1.PROJECT_ELEMENT_ID
2831      , fact1.CALENDAR_TYPE
2832      , fact1.WBS_ROLLUP_FLAG
2833      , fact1.PRG_ROLLUP_FLAG
2834      , fact1.CURR_RECORD_TYPE_ID
2835      , fact1.CURRENCY_CODE
2836      , rollup (qtr.ENT_YEAR_ID,
2837               period.ENT_QTR_ID,
2838               period.ENT_PERIOD_ID))
2839    WHERE 1=1
2840      AND period_type_id > 32
2841      AND period_type_id < 2048;
2842 
2843 EXCEPTION
2844   WHEN OTHERS THEN
2845     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
2846                              p_procedure_name => 'CREATE_AC_ENT_ROLLUP');
2847     RAISE;
2848 END;
2849 
2850 
2851 
2852 PROCEDURE CREATE_AC_ALL_T_PRI_ROLLUP (
2853   p_calendar_type IN VARCHAR2 := 'G' ) IS
2854     -- l_last_update_date     date   := SYSDATE;
2855     -- l_last_updated_by      NUMBER := FND_GLOBAL.USER_ID;
2856     -- l_creation_date        date   := SYSDATE;
2857     -- l_created_by           NUMBER := FND_GLOBAL.USER_ID;
2858     l_last_update_login    NUMBER := FND_GLOBAL.LOGIN_ID;
2859     l_line_type            VARCHAR2(15);
2860 
2861 BEGIN
2862 
2863   -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
2864 
2865   IF (p_calendar_type NOT IN ('P', 'G') ) THEN
2866     RETURN;
2867   ELSE
2868     IF (p_calendar_type = 'P') THEN
2869       l_line_type := 'PAR';
2870     ELSE
2871       l_line_type := 'GLR';
2872     END IF;
2873   END IF;
2874 
2875     INSERT INTO PJI_AC_AGGR_PJP1_T
2876     (
2877        worker_id
2878      , PROJECT_ID
2879      , PROJECT_ORG_ID
2880      , PROJECT_ORGANIZATION_ID
2881      -- , PARTITION_ID
2882      , PROJECT_ELEMENT_ID
2883      , TIME_ID
2884      , PERIOD_TYPE_ID
2885      , CALENDAR_TYPE
2886      , WBS_ROLLUP_FLAG
2887      , PRG_ROLLUP_FLAG
2888      , CURR_RECORD_TYPE_ID
2889      , CURRENCY_CODE
2890      , REVENUE
2891      , INITIAL_FUNDING_AMOUNT
2892      , INITIAL_FUNDING_COUNT
2893      , ADDITIONAL_FUNDING_AMOUNT
2894      , ADDITIONAL_FUNDING_COUNT
2895      , CANCELLED_FUNDING_AMOUNT
2896      , CANCELLED_FUNDING_COUNT
2897      , FUNDING_ADJUSTMENT_AMOUNT
2898      , FUNDING_ADJUSTMENT_COUNT
2899      , REVENUE_WRITEOFF
2900      , AR_INVOICE_AMOUNT
2901      , AR_INVOICE_COUNT
2902      , AR_CASH_APPLIED_AMOUNT
2903      , AR_INVOICE_WRITE_OFF_AMOUNT
2904      , AR_INVOICE_WRITEOFF_COUNT
2908      , UNEARNED_REVENUE
2905      , AR_CREDIT_MEMO_AMOUNT
2906      , AR_CREDIT_MEMO_COUNT
2907      , UNBILLED_RECEIVABLES
2909      , AR_UNAPPR_INVOICE_AMOUNT
2910      , AR_UNAPPR_INVOICE_COUNT
2911      , AR_APPR_INVOICE_AMOUNT
2912      , AR_APPR_INVOICE_COUNT
2913      , AR_AMOUNT_DUE
2914      , AR_COUNT_DUE
2915      , AR_AMOUNT_OVERDUE
2916      , AR_COUNT_OVERDUE
2917      , DORMANT_BACKLOG_INACTIV
2918      , DORMANT_BACKLOG_START
2919      , LOST_BACKLOG
2920      , ACTIVE_BACKLOG
2921      , REVENUE_AT_RISK
2922      , CUSTOM1
2923      , CUSTOM2
2924      , CUSTOM3
2925      , CUSTOM4
2926      , CUSTOM5
2927      , CUSTOM6
2928      , CUSTOM7
2929      , CUSTOM8
2930      , CUSTOM9
2931      , CUSTOM10
2932      , CUSTOM11
2933      , CUSTOM12
2934      , CUSTOM13
2935      , CUSTOM14
2936      , CUSTOM15
2937      , PRG_LEVEL
2938     )
2939   SELECT * FROM (
2940     SELECT
2941       -- GROUPING(qtr.CAL_YEAR_ID)  gy
2942       -- , GROUPING(period.CAL_QTR_ID)  gq
2943       -- , GROUPING(period.CAL_PERIOD_ID)  gp
2944       -- ,
2945        g_worker_id
2946      , fact1.PROJECT_ID
2947      , fact1.PROJECT_ORG_ID
2948      , fact1.PROJECT_ORGANIZATION_ID
2949      -- -- -- , fact1.PARTITION_ID
2950      , fact1.PROJECT_ELEMENT_ID
2951      , DECODE (
2952                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
2953              , '000', period.CAL_PERIOD_ID
2954              , '001', period.CAL_QTR_ID
2955              , '011', qtr.CAL_YEAR_ID
2956              , '111', -1 ) TIME_ID
2957      , DECODE (
2958                (grouping(qtr.CAL_YEAR_ID) || grouping(period.CAL_QTR_ID) || grouping(period.CAL_PERIOD_ID) )
2959              , '000', 32
2960              , '001', 64
2961              , '011', 128
2962              , '111', 2048 ) PERIOD_TYPE_ID
2963      , fact1.CALENDAR_TYPE
2964      , fact1.WBS_ROLLUP_FLAG
2965      , fact1.PRG_ROLLUP_FLAG
2966      , fact1.CURR_RECORD_TYPE_ID
2967      , fact1.CURRENCY_CODE
2968      , SUM(fact1.REVENUE )
2969      , SUM(fact1.INITIAL_FUNDING_AMOUNT )
2970      , SUM(fact1.INITIAL_FUNDING_COUNT)
2971      , SUM(fact1.ADDITIONAL_FUNDING_AMOUNT)
2972      , SUM(fact1.ADDITIONAL_FUNDING_COUNT  )
2973      , SUM(fact1.CANCELLED_FUNDING_AMOUNT)
2974      , SUM(fact1.CANCELLED_FUNDING_COUNT)
2975      , SUM(fact1.FUNDING_ADJUSTMENT_AMOUNT)
2976      , SUM(fact1.FUNDING_ADJUSTMENT_COUNT)
2977      , SUM(fact1.REVENUE_WRITEOFF)
2978      , SUM(fact1.AR_INVOICE_AMOUNT)
2979      , SUM(fact1.AR_INVOICE_COUNT)
2980      , SUM(fact1.AR_CASH_APPLIED_AMOUNT)
2981      , SUM(fact1.AR_INVOICE_WRITE_OFF_AMOUNT)
2982      , SUM(fact1.AR_INVOICE_WRITEOFF_COUNT)
2983      , SUM(fact1.AR_CREDIT_MEMO_AMOUNT)
2984      , SUM(fact1.AR_CREDIT_MEMO_COUNT)
2985      , SUM(fact1.UNBILLED_RECEIVABLES)
2986      , SUM(fact1.UNEARNED_REVENUE)
2987      , SUM(fact1.AR_UNAPPR_INVOICE_AMOUNT)
2988      , SUM(fact1.AR_UNAPPR_INVOICE_COUNT)
2989      , SUM(fact1.AR_APPR_INVOICE_AMOUNT)
2990      , SUM(fact1.AR_APPR_INVOICE_COUNT)
2991      , SUM(fact1.AR_AMOUNT_DUE)
2992      , SUM(fact1.AR_COUNT_DUE)
2993      , SUM(fact1.AR_AMOUNT_OVERDUE)
2994      , SUM(fact1.AR_COUNT_OVERDUE)
2995      , SUM(fact1.DORMANT_BACKLOG_INACTIV)
2996      , SUM(fact1.DORMANT_BACKLOG_START)
2997      , SUM(fact1.LOST_BACKLOG)
2998      , SUM(fact1.ACTIVE_BACKLOG)
2999      , SUM(fact1.REVENUE_AT_RISK)
3000      , SUM(fact1.CUSTOM1)
3001      , SUM(fact1.CUSTOM2)
3002      , SUM(fact1.CUSTOM3)
3003      , SUM(fact1.CUSTOM4)
3004      , SUM(fact1.CUSTOM5)
3005      , SUM(fact1.CUSTOM6)
3006      , SUM(fact1.CUSTOM7)
3007      , SUM(fact1.CUSTOM8)
3008      , SUM(fact1.CUSTOM9)
3009      , SUM(fact1.CUSTOM10)
3010      , SUM(fact1.CUSTOM11)
3011      , SUM(fact1.CUSTOM12)
3012      , SUM(fact1.CUSTOM13)
3013      , SUM(fact1.CUSTOM14)
3014      , SUM(fact1.CUSTOM15)
3015      , g_default_prg_level prg_level
3016     FROM
3017       PJI_AC_AGGR_PJP1_T fact1
3018     , pji_time_CAL_PERIOD period
3019 	, pji_time_CAL_QTR    qtr
3020     WHERE
3021           fact1.calendar_type = p_calendar_type
3022       AND period.cal_period_id = fact1.time_id
3023 	AND period.cal_qtr_id = qtr.cal_qtr_id
3024       AND fact1.period_type_id = 32
3025       AND fact1.worker_id = g_worker_id
3026     GROUP BY
3027        fact1.PROJECT_ID
3028      , fact1.PROJECT_ORG_ID
3029      , fact1.PROJECT_ORGANIZATION_ID
3030      -- -- -- , fact1.PARTITION_ID
3031      , fact1.PROJECT_ELEMENT_ID
3032      , fact1.CALENDAR_TYPE
3033      , rollup (qtr.CAL_YEAR_ID,
3034                period.CAL_QTR_ID,
3035                period.CAL_PERIOD_ID)
3036      , fact1.WBS_ROLLUP_FLAG
3037      , fact1.PRG_ROLLUP_FLAG
3038      , fact1.CURR_RECORD_TYPE_ID
3039      , fact1.CURRENCY_CODE )
3040    WHERE 1=1
3041      AND period_type_id = 2048;
3042 
3043 EXCEPTION
3044   WHEN OTHERS THEN
3045     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
3046                              p_procedure_name => 'CREATE_AC_ALL_T_PRI_ROLLUP');
3047     RAISE;
3048 END;
3049 
3050 
3051 --
3052 -- Prorate PA, GL entered entries in pjp1 table.
3053 --
3054 PROCEDURE PRORATE_TO_ENT_PG_PJP1_D IS
3055 BEGIN
3056 
3057     -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
3058 
3059 /* Commented for bug 4005006
3060     INSERT INTO pji_fp_aggr_pjp1_t
3061     (
3065      , PROJECT_ORGANIZATION_ID
3062        WORKER_ID
3063      , PROJECT_ID
3064      , PROJECT_ORG_ID
3066      -- , PARTITION_ID
3067      , PROJECT_ELEMENT_ID
3068      , TIME_ID
3069      , PERIOD_TYPE_ID
3070      , CALENDAR_TYPE
3071      , RBS_AGGR_LEVEL
3072      , WBS_ROLLUP_FLAG
3073      , PRG_ROLLUP_FLAG
3074      , CURR_RECORD_TYPE_ID
3075      , CURRENCY_CODE
3076      , RBS_ELEMENT_ID
3077      , RBS_VERSION_ID
3078      , PLAN_VERSION_ID
3079      , PLAN_TYPE_ID
3080      , RAW_COST
3081      , BRDN_COST
3082      , REVENUE
3083      , BILL_RAW_COST
3084      , BILL_BRDN_COST
3085      , BILL_LABOR_RAW_COST
3086      , BILL_LABOR_BRDN_COST
3087      , BILL_LABOR_HRS
3088      , EQUIPMENT_RAW_COST
3089      , EQUIPMENT_BRDN_COST
3090      , CAPITALIZABLE_RAW_COST
3091      , CAPITALIZABLE_BRDN_COST
3092      , LABOR_RAW_COST
3093      , LABOR_BRDN_COST
3094      , LABOR_HRS
3095      , LABOR_REVENUE
3096      , EQUIPMENT_HOURS
3097      , BILLABLE_EQUIPMENT_HOURS
3098      , SUP_INV_COMMITTED_COST
3099      , PO_COMMITTED_COST
3100      , PR_COMMITTED_COST
3101      , OTH_COMMITTED_COST
3102        , ACT_LABOR_HRS
3103 	   , ACT_EQUIP_HRS
3104 	   , ACT_LABOR_BRDN_COST
3105 	   , ACT_EQUIP_BRDN_COST
3106 	   , ACT_BRDN_COST
3107 	   , ACT_RAW_COST
3108 	   , ACT_REVENUE
3109          , ACT_LABOR_RAW_COST
3110          , ACT_EQUIP_RAW_COST
3111 	   , ETC_LABOR_HRS
3112 	   , ETC_EQUIP_HRS
3113 	   , ETC_LABOR_BRDN_COST
3114 	   , ETC_EQUIP_BRDN_COST
3115 	   , ETC_BRDN_COST
3116          , ETC_RAW_COST
3117          , ETC_LABOR_RAW_COST
3118          , ETC_EQUIP_RAW_COST
3119      , CUSTOM1
3120      , CUSTOM2
3121      , CUSTOM3
3122      , CUSTOM4
3123      , CUSTOM5
3124      , CUSTOM6
3125      , CUSTOM7
3126      , CUSTOM8
3127      , CUSTOM9
3128      , CUSTOM10
3129      , CUSTOM11
3130      , CUSTOM12
3131      , CUSTOM13
3132      , CUSTOM14
3133      , CUSTOM15
3134      , LINE_TYPE
3135      , TIME_DANGLING_FLAG
3136      , RATE_DANGLING_FLAG
3137      , PRG_LEVEL
3138 	)
3139    SELECT
3140        g_worker_id worker_id
3141      , a.PROJECT_ID
3142      , a.PROJECT_ORG_ID
3143      , a.PROJECT_ORGANIZATION_ID
3144      , a.PROJECT_ELEMENT_ID
3145      , a.TIME_ID
3146      , a.PERIOD_TYPE_ID
3147      , a.CALENDAR_TYPE
3148      , a.RBS_AGGR_LEVEL
3149      , a.WBS_ROLLUP_FLAG
3150      , a.PRG_ROLLUP_FLAG
3151      , a.CURR_RECORD_TYPE_ID
3152      , a.CURRENCY_CODE
3153      , a.RBS_ELEMENT_ID
3154      , a.RBS_VERSION_ID
3155      , a.PLAN_VERSION_ID
3156      , a.PLAN_TYPE_ID
3157      , SUM(a.RAW_COST       )
3158      , SUM(a.BRDN_COST 	)
3159      , SUM(a.REVENUE	)
3160      , SUM(a.BILL_RAW_COST )
3161      , SUM(a.BILL_BRDN_COST )
3162      , SUM(a.BILL_LABOR_RAW_COST )
3163      , SUM(a.BILL_LABOR_BRDN_COST )
3164      , SUM(a.BILL_LABOR_HRS )
3165      , SUM(a.EQUIPMENT_RAW_COST )
3166      , SUM(a.EQUIPMENT_BRDN_COST )
3167      , SUM(a.CAPITALIZABLE_RAW_COST )
3168      , SUM(a.CAPITALIZABLE_BRDN_COST )
3169      , SUM(a.LABOR_RAW_COST )
3170      , SUM(a.LABOR_BRDN_COST)
3171      , SUM(a.LABOR_HRS )
3172      , SUM(a.LABOR_REVENUE )
3173      , SUM(a.EQUIPMENT_HOURS )
3174      , SUM(a.BILLABLE_EQUIPMENT_HOURS)
3175      , SUM(a.SUP_INV_COMMITTED_COST)
3176      , SUM(a.PO_COMMITTED_COST )
3177      , SUM(a.PR_COMMITTED_COST )
3178      , SUM(a.OTH_COMMITTED_COST)
3179        , SUM(a.ACT_LABOR_HRS)
3180 	   , SUM(a.ACT_EQUIP_HRS)
3181 	   , SUM(a.ACT_LABOR_BRDN_COST)
3182 	   , SUM(a.ACT_EQUIP_BRDN_COST)
3183 	   , SUM(a.ACT_BRDN_COST    )
3184 	   , SUM(a.ACT_RAW_COST    )
3185 	   , SUM(a.ACT_REVENUE    )
3186          , SUM(a.ACT_LABOR_RAW_COST)
3187          , SUM(a.ACT_EQUIP_RAW_COST)
3188 	   , SUM(a.ETC_LABOR_HRS         )
3189 	   , SUM(a.ETC_EQUIP_HRS        )
3190 	   , SUM(a.ETC_LABOR_BRDN_COST )
3191 	   , SUM(a.ETC_EQUIP_BRDN_COST)
3192 	   , SUM(a.ETC_BRDN_COST )
3193          , SUM(a.ETC_RAW_COST)
3194          , SUM(a.ETC_LABOR_RAW_COST)
3195          , SUM(a.ETC_EQUIP_RAW_COST)
3196      , SUM(a.CUSTOM1	)
3197      , SUM(a.CUSTOM2	)
3198      , SUM(a.CUSTOM3	)
3199      , SUM(a.CUSTOM4	)
3200      , SUM(a.CUSTOM5	)
3201      , SUM(a.CUSTOM6	)
3202      , SUM(a.CUSTOM7	)
3203      , SUM(a.CUSTOM8	)
3204      , SUM(a.CUSTOM9	)
3205      , SUM(a.CUSTOM10	)
3206      , SUM(a.CUSTOM11	)
3207      , SUM(a.CUSTOM12	)
3208      , SUM(a.CUSTOM13	)
3209      , SUM(a.CUSTOM14	)
3210      , SUM(a.CUSTOM15	)
3211      , a.LINE_TYPE
3212      , a.TIME_DANGLING_FLAG
3213      , a.RATE_DANGLING_FLAG
3214      , g_default_prg_level prg_level
3215    FROM (
3216    SELECT
3217          fact.project_id  project_id
3218    	 , fact.project_ORG_ID project_ORG_ID
3219    	 , fact.project_ORGANIZATION_ID project_ORGANIZATION_ID
3220      -- , fact.PARTITION_ID PARTITION_ID
3221    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
3222    	 , pa_cal.ent_period_id TIME_ID
3223    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
3224    	 , 'E' CALENDAR_TYPE -- fact.CALENDAR_TYPE
3225      , fact.RBS_AGGR_LEVEL
3226      , fact.WBS_ROLLUP_FLAG
3227      , fact.PRG_ROLLUP_FLAG
3228    	 , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
3229    	 , fact.CURRENCY_CODE CURRENCY_CODE
3233 	 , fact.PLAN_TYPE_ID  PLAN_TYPE_ID
3230    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
3231    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
3232    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
3234 	 , ROUND (
3235              NVL (
3236             DECODE (
3237                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3238 			  , '00'   , fact.raw_cost
3239 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3240 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3241 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3242 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3243 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3244 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3245 			  , '0-1'  , fact.raw_cost
3246 			  , '1-1'  , fact.raw_cost
3247 			  , 0  ) -- end decode
3248 			    , 0  ) -- end nvl
3249 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3250 						* PJI_UTILS.GET_MAU (fact.currency_code)	raw_cost
3251 	 , ROUND (
3252              NVL (
3253             DECODE (
3254                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3255 			 , '00'   , fact.brdn_cost
3256 			 , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3257 			 , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3258 			 , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3259 			 , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3260 			 , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3261 			 , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3262 			 , '0-1'  , fact.brdn_cost
3263 			 , '1-1'  , fact.brdn_cost
3264 			 , 0  ) -- end decode
3265 			  , 0  ) -- end nvl
3266 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3267 						* PJI_UTILS.GET_MAU (fact.currency_code)	brdn_cost
3268 	 , ROUND (
3269              NVL (
3270             DECODE (
3271                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3272 			 , '00'   , fact.revenue
3273 			 , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3274 			 , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3275 			 , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3276 			 , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3277 			 , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3278 			 , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3279 			 , '0-1'  , fact.revenue
3280 			 , '1-1'  , fact.revenue
3281 			 , 0  ) -- end decode
3282 			  , 0  ) -- end nvl
3283 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3284 						* PJI_UTILS.GET_MAU (fact.currency_code)	revenue
3285 	 , ROUND (
3286              NVL (
3287             DECODE (
3288                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3289 			  , '00'   , fact.bill_raw_cost
3290 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3291 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3292 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3293 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3294 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3295 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3296 			  , '0-1'  , fact.bill_raw_cost
3297 			  , '1-1'  , fact.bill_raw_cost
3298 			  , 0  ) -- end decode
3299 			    , 0  ) -- end nvl
3300 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3301 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_raw_cost
3302 	 , ROUND (
3303              NVL (
3304             DECODE (
3305                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3306 			  , '00'   , fact.bill_brdn_cost
3307 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3311 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3308 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3309 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3310 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3312 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3313 			  , '0-1'  , fact.bill_brdn_cost
3314 			  , '1-1'  , fact.bill_brdn_cost
3315 			  , 0  ) -- end decode
3316 			    , 0  ) -- end nvl
3317 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3318 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_brdn_cost
3319 	 , ROUND (
3320              NVL (
3321             DECODE (
3322                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3323 			  , '00'   , fact.bill_labor_raw_cost
3324 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3325 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3326 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3327 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3328 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3329 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3330 			  , '0-1'  , fact.bill_labor_raw_cost
3331 			  , '1-1'  , fact.bill_labor_raw_cost
3332 			  , 0  ) -- end decode
3333 			    , 0  ) -- end nvl
3334 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3335 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_raw_cost
3336 	 , ROUND (
3337              NVL (
3338             DECODE (
3339                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3340 			  , '00'   , fact.bill_labor_brdn_cost
3341 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3342 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3343 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3344 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3345 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3346 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3347 			  , '0-1'  , fact.bill_labor_brdn_cost
3348 			  , '1-1'  , fact.bill_labor_brdn_cost
3349 			  , 0  ) -- end decode
3350 			    , 0  ) -- end nvl
3351 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3352 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_brdn_cost
3353 	 , ROUND (
3354              NVL (
3355             DECODE (
3356                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3357 			  , '00'   , fact.bill_labor_hrs
3358 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3359 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3360 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3361 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3362 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3363 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3364 			  , '0-1'  , fact.bill_labor_hrs
3365 			  , '1-1'  , fact.bill_labor_hrs
3366 			  , 0  ) -- end decode
3367 			    , 0  ) -- end nvl
3368 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3369 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_hrs
3370 	 , ROUND (
3371              NVL (
3372             DECODE (
3373                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3374 			  , '00'   , fact.equipment_raw_cost
3375 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3376 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3377 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3378 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3379 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3383 			  , 0  ) -- end decode
3380 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3381 			  , '0-1'  , fact.equipment_raw_cost
3382 			  , '1-1'  , fact.equipment_raw_cost
3384 			    , 0  ) -- end nvl
3385 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3386 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_raw_cost
3387 	 , ROUND (
3388              NVL (
3389             DECODE (
3390                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3391 			  , '00'   , fact.equipment_brdn_cost
3392 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3393 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3394 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3395 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3396 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3397 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3398 			  , '0-1'  , fact.equipment_brdn_cost
3399 			  , '1-1'  , fact.equipment_brdn_cost
3400 			  , 0  ) -- end decode
3401 			    , 0  ) -- end nvl
3402 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3403 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_brdn_cost
3404 	 , ROUND (
3405              NVL (
3406             DECODE (
3407                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3408 			  , '00'   , fact.capitalizable_raw_cost
3409 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3410 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3411 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3412 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3413 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3414 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3415 			  , '0-1'  , fact.capitalizable_raw_cost
3416 			  , '1-1'  , fact.capitalizable_raw_cost
3417 			  , 0  ) -- end decode
3418 			    , 0  ) -- end nvl
3419 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3420 						* PJI_UTILS.GET_MAU (fact.currency_code)	capitalizable_raw_cost
3421 	 , ROUND (
3422              NVL (
3423             DECODE (
3424                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3425 			  , '00'   , fact.capitalizable_brdn_cost
3426 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3427 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3428 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3429 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3430 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3431 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3432 			  , '0-1'  , fact.capitalizable_brdn_cost
3433 			  , '1-1'  , fact.capitalizable_brdn_cost
3434 			  , 0  ) -- end decode
3435 			    , 0  ) -- end nvl
3436 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3437 						* PJI_UTILS.GET_MAU (fact.currency_code)	capitalizable_brdn_cost
3438 	 , ROUND (
3439              NVL (
3440             DECODE (
3441                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3442 			  , '00'   , fact.labor_raw_cost
3443 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3444 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3445 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3446 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3447 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3448 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3449 			  , '0-1'  , fact.labor_raw_cost
3450 			  , '1-1'  , fact.labor_raw_cost
3451 			  , 0  ) -- end decode
3452 			    , 0  ) -- end nvl
3453 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3454 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_raw_cost
3455 	 , ROUND (
3456              NVL (
3457             DECODE (
3461 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3458                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3459 			  , '00'   , fact.labor_brdn_cost
3460 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3462 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3463 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3464 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3465 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3466 			  , '0-1'  , fact.labor_brdn_cost
3467 			  , '1-1'  , fact.labor_brdn_cost
3468 			  , 0  ) -- end decode
3469 			    , 0  ) -- end nvl
3470 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3471 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_brdn_cost
3472 	 , ROUND (
3473              NVL (
3474             DECODE (
3475                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3476 			  , '00'   , fact.labor_hrs
3477 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3478 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3479 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3480 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3481 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3482 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3483 			  , '0-1'  , fact.labor_hrs
3484 			  , '1-1'  , fact.labor_hrs
3485 			  , 0  ) -- end decode
3486 			    , 0  ) -- end nvl
3487 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3488 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_hrs
3489 	 , ROUND (
3490              NVL (
3491             DECODE (
3492                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3493 			  , '00'   , fact.labor_revenue
3494 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3495 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3496 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3497 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3498 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3499 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3500 			  , '0-1'  , fact.labor_revenue
3501 			  , '1-1'  , fact.labor_revenue
3502 			  , 0  ) -- end decode
3503 			    , 0  ) -- end nvl
3504 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3505 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_revenue
3506 	 , ROUND (
3507              NVL (
3508             DECODE (
3509                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3510 			  , '00'   , fact.equipment_hours
3511 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3512 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3513 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3514 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3515 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3516 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3517 			  , '0-1'  , fact.equipment_hours
3518 			  , '1-1'  , fact.equipment_hours
3519 			  , 0  ) -- end decode
3520 			    , 0  ) -- end nvl
3521 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3522 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_hours
3523 	 , ROUND (
3524              NVL (
3525             DECODE (
3526                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3527 			  , '00'   , fact.billable_equipment_hours
3528 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3529 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3530 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3531 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3535 			  , '1-1'  , fact.billable_equipment_hours
3532 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3533 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3534 			  , '0-1'  , fact.billable_equipment_hours
3536 			  , 0  ) -- end decode
3537 			    , 0  ) -- end nvl
3538 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3539 						* PJI_UTILS.GET_MAU (fact.currency_code)	billable_equipment_hours
3540 	 , ROUND (
3541              NVL (
3542             DECODE (
3543                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3544 			  , '00'   , fact.sup_inv_committed_cost
3545 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3546 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3547 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3548 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3549 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3550 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3551 			  , '0-1'  , fact.sup_inv_committed_cost
3552 			  , '1-1'  , fact.sup_inv_committed_cost
3553 			  , 0  ) -- end decode
3554 			    , 0  ) -- end nvl
3555 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3556 						* PJI_UTILS.GET_MAU (fact.currency_code)	sup_inv_committed_cost
3557 	 , ROUND (
3558              NVL (
3559             DECODE (
3560                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3561 			  , '00'   , fact.po_committed_cost
3562 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3563 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3564 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3565 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3566 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3567 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3568 			  , '0-1'  , fact.po_committed_cost
3569 			  , '1-1'  , fact.po_committed_cost
3570 			  , 0  ) -- end decode
3571 			    , 0  ) -- end nvl
3572 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3573 						* PJI_UTILS.GET_MAU (fact.currency_code)	po_committed_cost
3574 	 , ROUND (
3575              NVL (
3576             DECODE (
3577                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3578 			  , '00'   , fact.pr_committed_cost
3579 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3580 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3581 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3582 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3583 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3584 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3585 			  , '0-1'  , fact.pr_committed_cost
3586 			  , '1-1'  , fact.pr_committed_cost
3587 			  , 0  ) -- end decode
3588 			    , 0  ) -- end nvl
3589 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3590 						* PJI_UTILS.GET_MAU (fact.currency_code)	pr_committed_cost
3591 	 , ROUND (
3592              NVL (
3593             DECODE (
3594                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3595 			  , '00'   , fact.oth_committed_cost
3596 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3597 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3598 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3599 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3600 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3601 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3602 			  , '0-1'  , fact.oth_committed_cost
3603 			  , '1-1'  , fact.oth_committed_cost
3604 			  , 0  ) -- end decode
3605 			    , 0  ) -- end nvl
3606 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3607 						* PJI_UTILS.GET_MAU (fact.currency_code)	oth_committed_cost
3611                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3608 	 , ROUND (
3609              NVL (
3610             DECODE (
3612 			  , '00'   , fact.ACT_LABOR_HRS
3613 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3614 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3615 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3616 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3617 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3618 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3619 			  , '0-1'  , fact.ACT_LABOR_HRS
3620 			  , '1-1'  , fact.ACT_LABOR_HRS
3621 			  , 0  ) -- end decode
3622 			    , 0  ) -- end nvl
3623 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3624 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_HRS
3625 	 , ROUND (
3626              NVL (
3627             DECODE (
3628                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3629 			  , '00'   , fact.ACT_EQUIP_HRS
3630 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3631 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3632 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3633 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3634 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3635 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3636 			  , '0-1'  , fact.ACT_EQUIP_HRS
3637 			  , '1-1'  , fact.ACT_EQUIP_HRS
3638 			  , 0  ) -- end decode
3639 			    , 0  ) -- end nvl
3640 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3641 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_HRS
3642 	 , ROUND (
3643              NVL (
3644             DECODE (
3645                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3646 			  , '00'   , fact.ACT_LABOR_BRDN_COST
3647 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3648 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3649 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3650 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3651 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3652 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3653 			  , '0-1'  , fact.ACT_LABOR_BRDN_COST
3654 			  , '1-1'  , fact.ACT_LABOR_BRDN_COST
3655 			  , 0  ) -- end decode
3656 			    , 0  ) -- end nvl
3657 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3658 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_BRDN_COST
3659 	 , ROUND (
3660              NVL (
3661             DECODE (
3662                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3663 			  , '00'   , fact.ACT_EQUIP_BRDN_COST
3664 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3665 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3666 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3667 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3668 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3669 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3670 			  , '0-1'  , fact.ACT_EQUIP_BRDN_COST
3671 			  , '1-1'  , fact.ACT_EQUIP_BRDN_COST
3672 			  , 0  ) -- end decode
3673 			    , 0  ) -- end nvl
3674 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3675 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_BRDN_COST
3676 	 , ROUND (
3677              NVL (
3678             DECODE (
3679                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3680 			  , '00'   , fact.ACT_BRDN_COST
3681 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3682 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3683 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3687 			  , '0-1'  , fact.ACT_BRDN_COST
3684 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3685 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3686 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3688 			  , '1-1'  , fact.ACT_BRDN_COST
3689 			  , 0  ) -- end decode
3690 			    , 0  ) -- end nvl
3691 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3692 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_BRDN_COST
3693 	 , ROUND (
3694              NVL (
3695             DECODE (
3696                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3697 			  , '00'   , fact.ACT_RAW_COST
3698 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3699 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3700 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3701 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3702 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3703 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3704 			  , '0-1'  , fact.ACT_RAW_COST
3705 			  , '1-1'  , fact.ACT_RAW_COST
3706 			  , 0  ) -- end decode
3707 			    , 0  ) -- end nvl
3708 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3709 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_RAW_COST
3710 	 , ROUND (
3711              NVL (
3712             DECODE (
3713                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3714 			  , '00'   , fact.ACT_REVENUE
3715 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3716 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3717 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3718 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3719 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3720 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3721 			  , '0-1'  , fact.ACT_REVENUE
3722 			  , '1-1'  , fact.ACT_REVENUE
3723 			  , 0  ) -- end decode
3724 			    , 0  ) -- end nvl
3725 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3726 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_REVENUE
3727 	 , ROUND (
3728              NVL (
3729             DECODE (
3730                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3731 			  , '00'   , fact.ACT_LABOR_RAW_COST
3732 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3733 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3734 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3735 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3736 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3737 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3738 			  , '0-1'  , fact.ACT_LABOR_RAW_COST
3739 			  , '1-1'  , fact.ACT_LABOR_RAW_COST
3740 			  , 0  ) -- end decode
3741 			    , 0  ) -- end nvl
3742 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3743 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_RAW_COST
3744 	 , ROUND (
3745              NVL (
3746             DECODE (
3747                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3748 			  , '00'   , fact.ACT_EQUIP_RAW_COST
3749 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3750 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3751 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3752 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3753 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3754 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3755 			  , '0-1'  , fact.ACT_EQUIP_RAW_COST
3756 			  , '1-1'  , fact.ACT_EQUIP_RAW_COST
3757 			  , 0  ) -- end decode
3758 			    , 0  ) -- end nvl
3759 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3760 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_RAW_COST
3761 	 , ROUND (
3762              NVL (
3763             DECODE (
3767 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3764                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3765 			  , '00'   , fact.ETC_LABOR_HRS
3766 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3768 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3769 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3770 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3771 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3772 			  , '0-1'  , fact.ETC_LABOR_HRS
3773 			  , '1-1'  , fact.ETC_LABOR_HRS
3774 			  , 0  ) -- end decode
3775 			    , 0  ) -- end nvl
3776 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3777 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_HRS
3778 	 , ROUND (
3779              NVL (
3780             DECODE (
3781                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3782 			  , '00'   , fact.ETC_EQUIP_HRS
3783 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3784 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3785 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3786 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3787 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3788 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3789 			  , '0-1'  , fact.ETC_EQUIP_HRS
3790 			  , '1-1'  , fact.ETC_EQUIP_HRS
3791 			  , 0  ) -- end decode
3792 			    , 0  ) -- end nvl
3793 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3794 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_HRS
3795 	 , ROUND (
3796              NVL (
3797             DECODE (
3798                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3799 			  , '00'   , fact.ETC_LABOR_BRDN_COST
3800 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3801 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3802 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3803 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3804 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3805 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3806 			  , '0-1'  , fact.ETC_LABOR_BRDN_COST
3807 			  , '1-1'  , fact.ETC_LABOR_BRDN_COST
3808 			  , 0  ) -- end decode
3809 			    , 0  ) -- end nvl
3810 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3811 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_BRDN_COST
3812 	 , ROUND (
3813              NVL (
3814             DECODE (
3815                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3816 			  , '00'   , fact.ETC_EQUIP_BRDN_COST
3817 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3818 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3819 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3820 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3821 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3822 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3823 			  , '0-1'  , fact.ETC_EQUIP_BRDN_COST
3824 			  , '1-1'  , fact.ETC_EQUIP_BRDN_COST
3825 			  , 0  ) -- end decode
3826 			    , 0  ) -- end nvl
3827 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3828 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_BRDN_COST
3829 	 , ROUND (
3830              NVL (
3831             DECODE (
3832                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3833 			  , '00'   , fact.ETC_BRDN_COST
3834 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3835 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3836 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3837 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3841 			  , '1-1'  , fact.ETC_BRDN_COST
3838 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3839 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3840 			  , '0-1'  , fact.ETC_BRDN_COST
3842 			  , 0  ) -- end decode
3843 			    , 0  ) -- end nvl
3844 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3845 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_BRDN_COST
3846 	 , ROUND (
3847              NVL (
3848             DECODE (
3849                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3850 			  , '00'   , fact.ETC_RAW_COST
3851 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3852 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3853 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3854 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3855 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3856 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3857 			  , '0-1'  , fact.ETC_RAW_COST
3858 			  , '1-1'  , fact.ETC_RAW_COST
3859 			  , 0  ) -- end decode
3860 			    , 0  ) -- end nvl
3861 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3862 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_RAW_COST
3863 	 , ROUND (
3864              NVL (
3865             DECODE (
3866                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3867 			  , '00'   , fact.ETC_LABOR_RAW_COST
3868 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3869 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3870 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3871 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3872 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3873 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3874 			  , '0-1'  , fact.ETC_LABOR_RAW_COST
3875 			  , '1-1'  , fact.ETC_LABOR_RAW_COST
3876 			  , 0  ) -- end decode
3877 			    , 0  ) -- end nvl
3878 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3879 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_RAW_COST
3880 	 , ROUND (
3881              NVL (
3882             DECODE (
3883                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3884 			  , '00'   , fact.ETC_EQUIP_RAW_COST
3885 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3886 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3887 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3888 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3889 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3890 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3891 			  , '0-1'  , fact.ETC_EQUIP_RAW_COST
3892 			  , '1-1'  , fact.ETC_EQUIP_RAW_COST
3893 			  , 0  ) -- end decode
3894 			    , 0  ) -- end nvl
3895 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3896 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_RAW_COST
3897 	 , ROUND (
3898              NVL (
3899             DECODE (
3900                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3901 			  , '00'   , fact.custom1
3902 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3903 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3904 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3905 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3906 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3907 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3908 			  , '0-1'  , fact.custom1
3909 			  , '1-1'  , fact.custom1
3910 			  , 0  ) -- end decode
3911 			    , 0  ) -- end nvl
3912 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3913 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom1
3914 	 , ROUND (
3915              NVL (
3916             DECODE (
3917                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3921 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3918 			  , '00'   , fact.custom2
3919 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3920 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3922 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3923 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3924 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3925 			  , '0-1'  , fact.custom2
3926 			  , '1-1'  , fact.custom2
3927 			  , 0  ) -- end decode
3928 			    , 0  ) -- end nvl
3929 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3930 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom2
3931 	 , ROUND (
3932              NVL (
3933             DECODE (
3934                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3935 			  , '00'   , fact.custom3
3936 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3937 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3938 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3939 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3940 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3941 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3942 			  , '0-1'  , fact.custom3
3943 			  , '1-1'  , fact.custom3
3944 			  , 0  ) -- end decode
3945 			    , 0  ) -- end nvl
3946 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3947 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom3
3948 	 , ROUND (
3949              NVL (
3950             DECODE (
3951                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3952 			  , '00'   , fact.custom4
3953 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3954 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3955 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3956 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3957 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3958 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3959 			  , '0-1'  , fact.custom4
3960 			  , '1-1'  , fact.custom4
3961 			  , 0  ) -- end decode
3962 			    , 0  ) -- end nvl
3963 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3964 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom4
3965 	 , ROUND (
3966              NVL (
3967             DECODE (
3968                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3969 			  , '00'   , fact.custom5
3970 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3971 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3972 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3973 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3974 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3975 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3976 			  , '0-1'  , fact.custom5
3977 			  , '1-1'  , fact.custom5
3978 			  , 0  ) -- end decode
3979 			    , 0  ) -- end nvl
3980 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
3981 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom5
3982 	 , ROUND (
3983              NVL (
3984             DECODE (
3985                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
3986 			  , '00'   , fact.custom6
3987 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3988 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3989 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3990 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3991 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3992 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
3993 			  , '0-1'  , fact.custom6
3994 			  , '1-1'  , fact.custom6
3995 			  , 0  ) -- end decode
3996 			    , 0  ) -- end nvl
3997 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4001             DECODE (
3998 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom6
3999 	 , ROUND (
4000              NVL (
4002                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4003 			  , '00'   , fact.custom7
4004 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4005 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4006 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4007 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4008 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4009 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4010 			  , '0-1'  , fact.custom7
4011 			  , '1-1'  , fact.custom7
4012 			  , 0  ) -- end decode
4013 			    , 0  ) -- end nvl
4014 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4015 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom7
4016 	 , ROUND (
4017              NVL (
4018             DECODE (
4019                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4020 			  , '00'   , fact.custom8
4021 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4022 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4023 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4024 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4025 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4026 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4027 			  , '0-1'  , fact.custom8
4028 			  , '1-1'  , fact.custom8
4029 			  , 0  ) -- end decode
4030 			    , 0  ) -- end nvl
4031 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4032 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom8
4033 	 , ROUND (
4034              NVL (
4035             DECODE (
4036                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4037 			  , '00'   , fact.custom9
4038 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4039 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4040 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4041 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4042 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4043 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4044 			  , '0-1'  , fact.custom9
4045 			  , '1-1'  , fact.custom9
4046 			  , 0  ) -- end decode
4047 			    , 0  ) -- end nvl
4048 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4049 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom9
4050 	 , ROUND (
4051              NVL (
4052             DECODE (
4053                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4054 			  , '00'   , fact.custom10
4055 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4056 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4057 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4058 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4059 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4060 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4061 			  , '0-1'  , fact.custom10
4062 			  , '1-1'  , fact.custom10
4063 			  , 0  ) -- end decode
4064 			    , 0  ) -- end nvl
4065 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4066 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom10
4067 	 , ROUND (
4068              NVL (
4069             DECODE (
4070                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4071 			  , '00'   , fact.custom11
4072 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4073 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4074 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4075 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4076 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4080 			  , 0  ) -- end decode
4077 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4078 			  , '0-1'  , fact.custom11
4079 			  , '1-1'  , fact.custom11
4081 			    , 0  ) -- end nvl
4082 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4083 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom11
4084 	 , ROUND (
4085              NVL (
4086             DECODE (
4087                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4088 			  , '00'   , fact.custom12
4089 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4090 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4091 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4092 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4093 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4094 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4095 			  , '0-1'  , fact.custom12
4096 			  , '1-1'  , fact.custom12
4097 			  , 0  ) -- end decode
4098 			    , 0  ) -- end nvl
4099 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4100 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom12
4101 	 , ROUND (
4102              NVL (
4103             DECODE (
4104                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4105 			  , '00'   , fact.custom13
4106 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4107 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4108 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4109 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4110 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4111 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4112 			  , '0-1'  , fact.custom13
4113 			  , '1-1'  , fact.custom13
4114 			  , 0  ) -- end decode
4115 			    , 0  ) -- end nvl
4116 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4117 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom13
4118 	 , ROUND (
4119              NVL (
4120             DECODE (
4121                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4122 			  , '00'   , fact.custom14
4123 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4124 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4125 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4126 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4127 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4128 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4129 			  , '0-1'  , fact.custom14
4130 			  , '1-1'  , fact.custom14
4131 			  , 0  ) -- end decode
4132 			    , 0  ) -- end nvl
4133 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4134 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom14
4135 	 , ROUND (
4136              NVL (
4137             DECODE (
4138                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4139 			  , '00'   , fact.custom15
4140 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4141 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4142 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4143 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4144 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4145 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4146 			  , '0-1'  , fact.custom15
4147 			  , '1-1'  , fact.custom15
4148 			  , 0  ) -- end decode
4149 			    , 0  ) -- end nvl
4150 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4151 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom15
4152      , 'CF'   line_type
4153      , fact.time_dangling_flag time_dangling_flag
4154      , fact.rate_dangling_flag rate_dangling_flag
4155      , g_default_prg_level prg_level
4156    FROM   pji_fp_aggr_pjp1_t fact
4157         , pji_time_cal_period  non_pa_cal
4158    	 , pji_time_ent_period  pa_cal
4159        , pji_fm_extr_plnver3_t  ver
4160    WHERE  fact.CALENDAR_TYPE IN ('P', 'G')
4161       AND fact.worker_id = g_worker_id
4162       AND non_pa_cal.cal_period_id = fact.time_id
4163       AND fact.line_type like 'OF%'
4167 	    OR ( pa_cal.start_date <= non_pa_cal.start_date  AND pa_cal.end_date <= non_pa_cal.end_date AND pa_cal.end_date >= non_pa_cal.start_date )
4164       AND (
4165 	       ( pa_cal.start_date >= non_pa_cal.start_date  AND pa_cal.end_date <= non_pa_cal.end_date )
4166 	    OR ( pa_cal.start_date <= non_pa_cal.start_date  AND pa_cal.end_date >= non_pa_cal.end_date )
4168 	    OR ( pa_cal.start_date >= non_pa_cal.start_date  AND pa_cal.end_date >= non_pa_cal.end_date AND pa_cal.start_date <= non_pa_cal.end_date )
4169           )
4170       AND fact.time_dangling_flag IS NULL
4171       AND fact.rate_dangling_flag IS NULL
4172       AND fact.period_type_id = 32
4173       AND fact.plan_version_id = ver.plan_version_id
4174       AND ver.wp_flag = 'N'
4175       AND ver.baselined_flag = 'Y'
4176 	-- AND ( ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
4177       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
4178 	  ) a
4179 	  GROUP BY
4180 	   a.PROJECT_ID
4181      , a.PROJECT_ORG_ID
4182      , a.PROJECT_ORGANIZATION_ID
4183      , a.PROJECT_ELEMENT_ID
4184      , a.TIME_ID
4185      , a.PERIOD_TYPE_ID
4186      , a.CALENDAR_TYPE
4187      , a.RBS_AGGR_LEVEL
4188      , a.WBS_ROLLUP_FLAG
4189      , a.PRG_ROLLUP_FLAG
4190      , a.CURR_RECORD_TYPE_ID
4191      , a.CURRENCY_CODE
4192      , a.RBS_ELEMENT_ID
4193      , a.RBS_VERSION_ID
4194      , a.PLAN_VERSION_ID
4195      , a.PLAN_TYPE_ID
4196 
4197 	 , a.LINE_TYPE
4198 	 , a.TIME_DANGLING_FLAG
4199 	 , a.RATE_DANGLING_FLAG;
4200  End of 4005006*/
4201 
4202     INSERT INTO pji_fp_aggr_pjp1_t
4203     (
4204        WORKER_ID
4205      , PROJECT_ID
4206      , PROJECT_ORG_ID
4207      , PROJECT_ORGANIZATION_ID
4208      -- , PARTITION_ID
4209      , PROJECT_ELEMENT_ID
4210      , TIME_ID
4211      , PERIOD_TYPE_ID
4212      , CALENDAR_TYPE
4213      , RBS_AGGR_LEVEL
4214      , WBS_ROLLUP_FLAG
4215      , PRG_ROLLUP_FLAG
4216      , CURR_RECORD_TYPE_ID
4217      , CURRENCY_CODE
4218      , RBS_ELEMENT_ID
4219      , RBS_VERSION_ID
4220      , PLAN_VERSION_ID
4221      , PLAN_TYPE_ID
4222      , RAW_COST
4223      , BRDN_COST
4224      , REVENUE
4225      , BILL_RAW_COST
4226      , BILL_BRDN_COST
4227      , BILL_LABOR_RAW_COST
4228      , BILL_LABOR_BRDN_COST
4229      , BILL_LABOR_HRS
4230      , EQUIPMENT_RAW_COST
4231      , EQUIPMENT_BRDN_COST
4232      , CAPITALIZABLE_RAW_COST
4233      , CAPITALIZABLE_BRDN_COST
4234      , LABOR_RAW_COST
4235      , LABOR_BRDN_COST
4236      , LABOR_HRS
4237      , LABOR_REVENUE
4238      , EQUIPMENT_HOURS
4239      , BILLABLE_EQUIPMENT_HOURS
4240      , SUP_INV_COMMITTED_COST
4241      , PO_COMMITTED_COST
4242      , PR_COMMITTED_COST
4243      , OTH_COMMITTED_COST
4244      , ACT_LABOR_HRS
4245      , ACT_EQUIP_HRS
4246      , ACT_LABOR_BRDN_COST
4247      , ACT_EQUIP_BRDN_COST
4248      , ACT_BRDN_COST
4249      , ACT_RAW_COST
4250      , ACT_REVENUE
4251      , ACT_LABOR_RAW_COST
4252      , ACT_EQUIP_RAW_COST
4253      , ETC_LABOR_HRS
4254      , ETC_EQUIP_HRS
4255      , ETC_LABOR_BRDN_COST
4256      , ETC_EQUIP_BRDN_COST
4257      , ETC_BRDN_COST
4258      , ETC_RAW_COST
4259      , ETC_LABOR_RAW_COST
4260      , ETC_EQUIP_RAW_COST
4261      , CUSTOM1
4262      , CUSTOM2
4263      , CUSTOM3
4264      , CUSTOM4
4265      , CUSTOM5
4266      , CUSTOM6
4267      , CUSTOM7
4268      , CUSTOM8
4269      , CUSTOM9
4270      , CUSTOM10
4271      , CUSTOM11
4272      , CUSTOM12
4273      , CUSTOM13
4274      , CUSTOM14
4275      , CUSTOM15
4276      , TIME_DANGLING_FLAG
4277      , RATE_DANGLING_FLAG
4278      , PRG_LEVEL
4279      , PLAN_TYPE_CODE    /* 4471527 */
4280 	)
4281    SELECT
4282            g_worker_id worker_id
4283          , a.PROJECT_ID
4284          , a.PROJECT_ORG_ID
4285          , a.PROJECT_ORGANIZATION_ID
4286          , a.PROJECT_ELEMENT_ID
4287          , a.TIME_ID
4288          , a.PERIOD_TYPE_ID
4289          , a.CALENDAR_TYPE
4290          , a.RBS_AGGR_LEVEL
4291          , a.WBS_ROLLUP_FLAG
4292          , a.PRG_ROLLUP_FLAG
4293          , a.CURR_RECORD_TYPE_ID
4294          , a.CURRENCY_CODE
4295          , a.RBS_ELEMENT_ID
4296          , a.RBS_VERSION_ID
4297          , a.PLAN_VERSION_ID
4298          , a.PLAN_TYPE_ID
4299 	 , SUM(ROUND (nvl(a.raw_cost,0)*a.factor/a.mau)*a.mau) raw_cost
4300 	 , SUM(ROUND (nvl(a.brdn_cost,0)*a.factor/a.mau)*a.mau) brdn_cost
4301 	 , SUM(ROUND (nvl(a.revenue,0)*a.factor/a.mau)*a.mau) revenue
4302 	 , SUM(ROUND (nvl(a.bill_raw_cost,0)*a.factor/a.mau)*a.mau) bill_raw_cost
4303 	 , SUM(ROUND (nvl(a.bill_brdn_cost,0)*a.factor/a.mau)*a.mau) bill_brdn_cost
4304 	 , SUM(ROUND (nvl(a.bill_labor_raw_cost,0)*a.factor/a.mau)*a.mau) bill_labor_raw_cost
4305 	 , SUM(ROUND (nvl(a.bill_labor_brdn_cost,0)*a.factor/a.mau)*a.mau) bill_labor_brdn_cost
4306 	 , SUM(ROUND (nvl(a.bill_labor_hrs,0)*a.factor/a.mau)*a.mau) bill_labor_hrs
4307 	 , SUM(ROUND (nvl(a.equipment_raw_cost,0)*a.factor/a.mau)*a.mau) equipment_raw_cost
4308 	 , SUM(ROUND (nvl(a.equipment_brdn_cost,0)*a.factor/a.mau)*a.mau) equipment_brdn_cost
4309 	 , SUM(ROUND (nvl(a.capitalizable_raw_cost,0)*a.factor/a.mau)*a.mau) capitalizable_raw_cost
4310 	 , SUM(ROUND (nvl(a.capitalizable_brdn_cost,0)*a.factor/a.mau)*a.mau) capitalizable_brdn_cost
4311 	 , SUM(ROUND (nvl(a.labor_raw_cost,0)*a.factor/a.mau)*a.mau) labor_raw_cost
4315 	 , SUM(ROUND (nvl(a.equipment_hours,0)*a.factor/a.mau)*a.mau) equipment_hours
4312 	 , SUM(ROUND (nvl(a.labor_brdn_cost,0)*a.factor/a.mau)*a.mau) labor_brdn_cost
4313 	 , SUM(ROUND (nvl(a.labor_hrs,0)*a.factor/a.mau)*a.mau) labor_hrs
4314 	 , SUM(ROUND (nvl(a.labor_revenue,0)*a.factor/a.mau)*a.mau) labor_revenue
4316 	 , SUM(ROUND (nvl(a.billable_equipment_hours,0)*a.factor/a.mau)*a.mau) billable_equipment_hours
4317 	 , SUM(ROUND (nvl(a.sup_inv_committed_cost,0)*a.factor/a.mau)*a.mau) sup_inv_committed_cost
4318 	 , SUM(ROUND (nvl(a.po_committed_cost,0)*a.factor/a.mau)*a.mau) po_committed_cost
4319 	 , SUM(ROUND (nvl(a.pr_committed_cost,0)*a.factor/a.mau)*a.mau) pr_committed_cost
4320 	 , SUM(ROUND (nvl(a.oth_committed_cost,0)*a.factor/a.mau)*a.mau) oth_committed_cost
4321 	 , SUM(ROUND (nvl(a.ACT_LABOR_HRS,0)*a.factor/a.mau)*a.mau) ACT_LABOR_HRS
4322 	 , SUM(ROUND (nvl(a.ACT_EQUIP_HRS,0)*a.factor/a.mau)*a.mau) ACT_EQUIP_HRS
4323 	 , SUM(ROUND (nvl(a.ACT_LABOR_BRDN_COST,0)*a.factor/a.mau)*a.mau) ACT_LABOR_BRDN_COST
4324 	 , SUM(ROUND (nvl(a.ACT_EQUIP_BRDN_COST,0)*a.factor/a.mau)*a.mau) ACT_EQUIP_BRDN_COST
4325 	 , SUM(ROUND (nvl(a.ACT_BRDN_COST,0)*a.factor/a.mau)*a.mau) ACT_BRDN_COST
4326 	 , SUM(ROUND (nvl(a.ACT_RAW_COST,0)*a.factor/a.mau)*a.mau) ACT_RAW_COST
4327 	 , SUM(ROUND (nvl(a.ACT_REVENUE,0)*a.factor/a.mau)*a.mau) ACT_REVENUE
4328 	 , SUM(ROUND (nvl(a.ACT_LABOR_RAW_COST,0)*a.factor/a.mau)*a.mau) ACT_LABOR_RAW_COST
4329 	 , SUM(ROUND (nvl(a.ACT_EQUIP_RAW_COST,0)*a.factor/a.mau)*a.mau) ACT_EQUIP_RAW_COST
4330 	 , SUM(ROUND (nvl(a.ETC_LABOR_HRS,0)*a.factor/a.mau)*a.mau) ETC_LABOR_HRS
4331 	 , SUM(ROUND (nvl(a.ETC_EQUIP_HRS,0)*a.factor/a.mau)*a.mau) ETC_EQUIP_HRS
4332 	 , SUM(ROUND (nvl(a.ETC_LABOR_BRDN_COST,0)*a.factor/a.mau)*a.mau) ETC_LABOR_BRDN_COST
4333 	 , SUM(ROUND (nvl(a.ETC_EQUIP_BRDN_COST,0)*a.factor/a.mau)*a.mau) ETC_EQUIP_BRDN_COST
4334 	 , SUM(ROUND (nvl(a.ETC_BRDN_COST,0)*a.factor/a.mau)*a.mau) ETC_BRDN_COST
4335 	 , SUM(ROUND (nvl(a.ETC_RAW_COST,0)*a.factor/a.mau)*a.mau) ETC_RAW_COST
4336 	 , SUM(ROUND (nvl(a.ETC_LABOR_RAW_COST,0)*a.factor/a.mau)*a.mau) ETC_LABOR_RAW_COST
4337 	 , SUM(ROUND (nvl(a.ETC_EQUIP_RAW_COST,0)*a.factor/a.mau)*a.mau) ETC_EQUIP_RAW_COST
4338 	 , SUM(ROUND (nvl(a.custom1,0)*a.factor/a.mau)*a.mau) custom1
4339 	 , SUM(ROUND (nvl(a.custom2,0)*a.factor/a.mau)*a.mau) custom2
4340 	 , SUM(ROUND (nvl(a.custom3,0)*a.factor/a.mau)*a.mau) custom3
4341 	 , SUM(ROUND (nvl(a.custom4,0)*a.factor/a.mau)*a.mau) custom4
4342 	 , SUM(ROUND (nvl(a.custom5,0)*a.factor/a.mau)*a.mau) custom5
4343 	 , SUM(ROUND (nvl(a.custom6,0)*a.factor/a.mau)*a.mau) custom6
4344 	 , SUM(ROUND (nvl(a.custom7,0)*a.factor/a.mau)*a.mau) custom7
4345 	 , SUM(ROUND (nvl(a.custom8,0)*a.factor/a.mau)*a.mau) custom8
4346 	 , SUM(ROUND (nvl(a.custom9,0)*a.factor/a.mau)*a.mau) custom9
4347 	 , SUM(ROUND (nvl(a.custom10,0)*a.factor/a.mau)*a.mau) custom10
4348 	 , SUM(ROUND (nvl(a.custom11,0)*a.factor/a.mau)*a.mau) custom11
4349 	 , SUM(ROUND (nvl(a.custom12,0)*a.factor/a.mau)*a.mau) custom12
4350 	 , SUM(ROUND (nvl(a.custom13,0)*a.factor/a.mau)*a.mau) custom13
4351 	 , SUM(ROUND (nvl(a.custom14,0)*a.factor/a.mau)*a.mau) custom14
4352 	 , SUM(ROUND (nvl(a.custom15,0)*a.factor/a.mau)*a.mau) custom15
4353          , a.TIME_DANGLING_FLAG
4354          , a.RATE_DANGLING_FLAG
4355          , g_default_prg_level prg_level
4356          , a.plan_type_code plan_type_code    /* 4471527 */
4357    FROM (
4358    SELECT /*+ NO_MERGE */
4359          fact.project_id  project_id
4360    	 , fact.project_ORG_ID project_ORG_ID
4361    	 , fact.project_ORGANIZATION_ID project_ORGANIZATION_ID
4362    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
4363    	 , pa_cal.ent_period_id TIME_ID
4364    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
4365    	 , 'E' CALENDAR_TYPE -- fact.CALENDAR_TYPE
4366          , fact.RBS_AGGR_LEVEL
4367          , fact.WBS_ROLLUP_FLAG
4368          , fact.PRG_ROLLUP_FLAG
4369    	 , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
4370    	 , fact.CURRENCY_CODE CURRENCY_CODE
4371    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
4372    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
4373    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
4374 	 , fact.PLAN_TYPE_ID  PLAN_TYPE_ID
4375 	 , fact.raw_cost
4376 	 , fact.brdn_cost
4377 	 , fact.revenue
4378 	 , fact.bill_raw_cost
4379 	 , fact.bill_brdn_cost
4380 	 , fact.bill_labor_raw_cost
4381 	 , fact.bill_labor_brdn_cost
4382 	 , fact.bill_labor_hrs
4383 	 , fact.equipment_raw_cost
4384 	 , fact.equipment_brdn_cost
4385 	 , fact.capitalizable_raw_cost
4386 	 , fact.capitalizable_brdn_cost
4387 	 , fact.labor_raw_cost
4388 	 , fact.labor_brdn_cost
4389 	 , fact.labor_hrs
4390 	 , fact.labor_revenue
4391 	 , fact.equipment_hours
4392 	 , fact.billable_equipment_hours
4393 	 , fact.sup_inv_committed_cost
4394 	 , fact.po_committed_cost
4395 	 , fact.pr_committed_cost
4396 	 , fact.oth_committed_cost
4397 	 , fact.ACT_LABOR_HRS
4398 	 , fact.ACT_EQUIP_HRS
4399 	 , fact.ACT_LABOR_BRDN_COST
4400 	 , fact.ACT_EQUIP_BRDN_COST
4401 	 , fact.ACT_BRDN_COST
4402 	 , fact.ACT_RAW_COST
4403 	 , fact.ACT_REVENUE
4404 	 , fact.ACT_LABOR_RAW_COST
4405 	 , fact.ACT_EQUIP_RAW_COST
4406 	 , fact.ETC_LABOR_HRS
4407 	 , fact.ETC_EQUIP_HRS
4408 	 , fact.ETC_LABOR_BRDN_COST
4409 	 , fact.ETC_EQUIP_BRDN_COST
4410 	 , fact.ETC_BRDN_COST
4411 	 , fact.ETC_RAW_COST
4412 	 , fact.ETC_LABOR_RAW_COST
4413 	 , fact.ETC_EQUIP_RAW_COST
4414 	 , fact.custom1
4415 	 , fact.custom2
4416 	 , fact.custom3
4420 	 , fact.custom7
4417 	 , fact.custom4
4418 	 , fact.custom5
4419 	 , fact.custom6
4421 	 , fact.custom8
4422 	 , fact.custom9
4423 	 , fact.custom10
4424 	 , fact.custom11
4425 	 , fact.custom12
4426 	 , fact.custom13
4427 	 , fact.custom14
4428 	 , fact.custom15
4429 	 , fact.time_dangling_flag time_dangling_flag
4430 	 , fact.rate_dangling_flag rate_dangling_flag
4431          , cur.mau mau
4432          , (LEAST(non_pa_cal.end_date,pa_cal.end_date) -
4433                     Greatest(non_pa_cal.start_date,pa_cal.start_date)+1)
4434                               / (non_pa_cal.end_date - non_pa_cal.start_date+1) factor
4435              , fact.plan_type_code  plan_type_code   /* 4471527 */
4436    FROM   pji_fp_aggr_pjp1_t fact
4437         , pji_time_cal_period_v  non_pa_cal
4438         , pji_time_ent_period_v  pa_cal
4439         , pji_fm_extr_plnver3_t  ver
4440         , (SELECT currency_code,
4441                    decode(nvl(MINIMUM_ACCOUNTABLE_UNIT, power(10, (-1 * PRECISION))),
4442                       null, 0.01,
4443                          0, 1,
4444                          nvl(MINIMUM_ACCOUNTABLE_UNIT, power(10, (-1 * PRECISION)))) mau
4445               FROM FND_CURRENCIES) cur
4446    WHERE  fact.CALENDAR_TYPE IN ('P', 'G')
4447       AND fact.worker_id = g_worker_id
4448       AND non_pa_cal.cal_period_id = fact.time_id
4449       AND fact.line_type like 'OF%'
4450       AND non_pa_cal.start_date<= pa_cal.end_date
4451       AND non_pa_cal.end_Date >=pa_cal.start_date
4452       AND fact.currency_code = cur.currency_code
4453       AND fact.time_dangling_flag IS NULL
4454       AND fact.rate_dangling_flag IS NULL
4455       AND fact.period_type_id = 32
4456       AND fact.plan_version_id = ver.plan_version_id
4457       AND fact.plan_type_code = ver.plan_type_code    /* 4471527 */
4458       AND ver.wp_flag = 'N'
4459       AND ver.baselined_flag = 'Y'
4460       -- AND ( ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
4461       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
4462 	  ) a
4463      WHERE a.factor >0
4464 	  GROUP BY
4465 	   a.PROJECT_ID
4466      , a.PROJECT_ORG_ID
4467      , a.PROJECT_ORGANIZATION_ID
4468      , a.PROJECT_ELEMENT_ID
4469      , a.TIME_ID
4470      , a.PERIOD_TYPE_ID
4471      , a.CALENDAR_TYPE
4472      , a.RBS_AGGR_LEVEL
4473      , a.WBS_ROLLUP_FLAG
4474      , a.PRG_ROLLUP_FLAG
4475      , a.CURR_RECORD_TYPE_ID
4476      , a.CURRENCY_CODE
4477      , a.RBS_ELEMENT_ID
4478      , a.RBS_VERSION_ID
4479      , a.PLAN_VERSION_ID
4480      , a.PLAN_TYPE_ID
4481      , a.PLAN_TYPE_CODE     /* 4471527 */
4482      , a.TIME_DANGLING_FLAG
4483      , a.RATE_DANGLING_FLAG;
4484 
4485 EXCEPTION
4486   WHEN OTHERS THEN
4487     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
4488                              p_procedure_name => ' PRORATE_TO_ENT_PG_PJP1_D ');
4489     RAISE;
4490 END;
4491 
4492 
4493 PROCEDURE PRORATE_TO_ENT_PG_FPRL_D IS
4494 BEGIN
4495 
4496     -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
4497 
4498     INSERT INTO pji_fp_aggr_pjp1_t -- PA, GL calendar entries in FP Reporting lines.
4499     (
4500        WORKER_ID
4501      , PROJECT_ID
4502      , PROJECT_ORG_ID
4503      , PROJECT_ORGANIZATION_ID
4504      -- , PARTITION_ID
4505      , PROJECT_ELEMENT_ID
4506      , TIME_ID
4507      , PERIOD_TYPE_ID
4508      , CALENDAR_TYPE
4509      , RBS_AGGR_LEVEL
4510      , WBS_ROLLUP_FLAG
4511      , PRG_ROLLUP_FLAG
4512      , CURR_RECORD_TYPE_ID
4513      , CURRENCY_CODE
4514      , RBS_ELEMENT_ID
4515      , RBS_VERSION_ID
4516      , PLAN_VERSION_ID
4517      , PLAN_TYPE_ID
4518      , RAW_COST
4519      , BRDN_COST
4520      , REVENUE
4521      , BILL_RAW_COST
4522      , BILL_BRDN_COST
4523      , BILL_LABOR_RAW_COST
4524      , BILL_LABOR_BRDN_COST
4525      , BILL_LABOR_HRS
4526      , EQUIPMENT_RAW_COST
4527      , EQUIPMENT_BRDN_COST
4528      , CAPITALIZABLE_RAW_COST
4529      , CAPITALIZABLE_BRDN_COST
4530      , LABOR_RAW_COST
4531      , LABOR_BRDN_COST
4532      , LABOR_HRS
4533      , LABOR_REVENUE
4534      , EQUIPMENT_HOURS
4535      , BILLABLE_EQUIPMENT_HOURS
4536      , SUP_INV_COMMITTED_COST
4537      , PO_COMMITTED_COST
4538      , PR_COMMITTED_COST
4539      , OTH_COMMITTED_COST
4540        , ACT_LABOR_HRS
4541 	   , ACT_EQUIP_HRS
4542 	   , ACT_LABOR_BRDN_COST
4543 	   , ACT_EQUIP_BRDN_COST
4544 	   , ACT_BRDN_COST
4545 	   , ACT_RAW_COST
4546 	   , ACT_REVENUE
4547          , ACT_LABOR_RAW_COST
4548          , ACT_EQUIP_RAW_COST
4549 	   , ETC_LABOR_HRS
4550 	   , ETC_EQUIP_HRS
4551 	   , ETC_LABOR_BRDN_COST
4552 	   , ETC_EQUIP_BRDN_COST
4553 	   , ETC_BRDN_COST
4554          , ETC_RAW_COST
4555          , ETC_LABOR_RAW_COST
4556          , ETC_EQUIP_RAW_COST
4557      , CUSTOM1
4558      , CUSTOM2
4559      , CUSTOM3
4560      , CUSTOM4
4561      , CUSTOM5
4562      , CUSTOM6
4563      , CUSTOM7
4564      , CUSTOM8
4565      , CUSTOM9
4566      , CUSTOM10
4567      , CUSTOM11
4568      , CUSTOM12
4569      , CUSTOM13
4570      , CUSTOM14
4571      , CUSTOM15
4572      , PRG_LEVEL
4573      , PLAN_TYPE_CODE   /* 4471527 */
4574 	)
4575    SELECT
4576        g_worker_id worker_id
4577      , a.PROJECT_ID
4578      , a.PROJECT_ORG_ID
4582      , a.PERIOD_TYPE_ID
4579      , a.PROJECT_ORGANIZATION_ID
4580      , a.PROJECT_ELEMENT_ID
4581      , a.TIME_ID
4583      , a.CALENDAR_TYPE
4584      , a.RBS_AGGR_LEVEL
4585      , a.WBS_ROLLUP_FLAG
4586      , a.PRG_ROLLUP_FLAG
4587      , a.CURR_RECORD_TYPE_ID
4588      , a.CURRENCY_CODE
4589      , a.RBS_ELEMENT_ID
4590      , a.RBS_VERSION_ID
4591      , a.PLAN_VERSION_ID
4592      , a.PLAN_TYPE_ID
4593      , SUM(a.RAW_COST       )
4594      , SUM(a.BRDN_COST 	)
4595      , SUM(a.REVENUE	)
4596      , SUM(a.BILL_RAW_COST )
4597      , SUM(a.BILL_BRDN_COST )
4598      , SUM(a.BILL_LABOR_RAW_COST )
4599      , SUM(a.BILL_LABOR_BRDN_COST )
4600      , SUM(a.BILL_LABOR_HRS )
4601      , SUM(a.EQUIPMENT_RAW_COST )
4602      , SUM(a.EQUIPMENT_BRDN_COST )
4603      , SUM(a.CAPITALIZABLE_RAW_COST )
4604      , SUM(a.CAPITALIZABLE_BRDN_COST )
4605      , SUM(a.LABOR_RAW_COST )
4606      , SUM(a.LABOR_BRDN_COST)
4607      , SUM(a.LABOR_HRS )
4608      , SUM(a.LABOR_REVENUE )
4609      , SUM(a.EQUIPMENT_HOURS )
4610      , SUM(a.BILLABLE_EQUIPMENT_HOURS)
4611      , SUM(a.SUP_INV_COMMITTED_COST)
4612      , SUM(a.PO_COMMITTED_COST )
4613      , SUM(a.PR_COMMITTED_COST )
4614      , SUM(a.OTH_COMMITTED_COST)
4615        , SUM(a.ACT_LABOR_HRS)
4616 	   , SUM(a.ACT_EQUIP_HRS)
4617 	   , SUM(a.ACT_LABOR_BRDN_COST)
4618 	   , SUM(a.ACT_EQUIP_BRDN_COST)
4619 	   , SUM(a.ACT_BRDN_COST    )
4620 	   , SUM(a.ACT_RAW_COST    )
4621 	   , SUM(a.ACT_REVENUE    )
4622          , SUM(a.ACT_LABOR_RAW_COST)
4623          , SUM(a.ACT_EQUIP_RAW_COST)
4624 	   , SUM(a.ETC_LABOR_HRS         )
4625 	   , SUM(a.ETC_EQUIP_HRS        )
4626 	   , SUM(a.ETC_LABOR_BRDN_COST )
4627 	   , SUM(a.ETC_EQUIP_BRDN_COST)
4628 	   , SUM(a.ETC_BRDN_COST )
4629          , SUM(a.ETC_RAW_COST)
4630          , SUM(a.ETC_LABOR_RAW_COST)
4631          , SUM(a.ETC_EQUIP_RAW_COST)
4632      , SUM(a.CUSTOM1	)
4633      , SUM(a.CUSTOM2	)
4634      , SUM(a.CUSTOM3	)
4635      , SUM(a.CUSTOM4	)
4636      , SUM(a.CUSTOM5	)
4637      , SUM(a.CUSTOM6	)
4638      , SUM(a.CUSTOM7	)
4639      , SUM(a.CUSTOM8	)
4640      , SUM(a.CUSTOM9	)
4641      , SUM(a.CUSTOM10	)
4642      , SUM(a.CUSTOM11	)
4643      , SUM(a.CUSTOM12	)
4644      , SUM(a.CUSTOM13	)
4645      , SUM(a.CUSTOM14	)
4646      , SUM(a.CUSTOM15	)
4647      , g_default_prg_level prg_level
4648      , a.plan_type_code plan_type_code    /* 4471527 */
4649    FROM (
4650    SELECT
4651          fact.project_id  project_id
4652    	 , fact.project_ORG_ID project_ORG_ID
4653    	 , fact.project_ORGANIZATION_ID project_ORGANIZATION_ID
4654      -- , fact.PARTITION_ID PARTITION_ID
4655    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
4656    	 , pa_cal.ent_period_id TIME_ID
4657    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
4658    	 , 'E' CALENDAR_TYPE -- fact.CALENDAR_TYPE
4659      , fact.RBS_AGGR_LEVEL
4660      , fact.WBS_ROLLUP_FLAG
4661      , fact.PRG_ROLLUP_FLAG
4662    	 , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
4663    	 , fact.CURRENCY_CODE CURRENCY_CODE
4664    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
4665    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
4666    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
4667 	 , fact.PLAN_TYPE_ID  PLAN_TYPE_ID
4668 	 , ROUND (
4669              NVL (
4670             DECODE (
4671                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4672 			  , '00'   , fact.raw_cost
4673 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4674 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4675 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4676 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4677 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4678 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4679 			  , '0-1'  , fact.raw_cost
4680 			  , '1-1'  , fact.raw_cost
4681 			  , 0  ) -- end decode
4682 			    , 0  ) -- end nvl
4683 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4684 						* PJI_UTILS.GET_MAU (fact.currency_code)	raw_cost
4685 	 , ROUND (
4686              NVL (
4687             DECODE (
4688                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4689 			 , '00'   , fact.brdn_cost
4690 			 , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4691 			 , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4692 			 , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4693 			 , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4694 			 , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4698 			 , 0  ) -- end decode
4695 			 , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4696 			 , '0-1'  , fact.brdn_cost
4697 			 , '1-1'  , fact.brdn_cost
4699 			  , 0  ) -- end nvl
4700 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4701 						* PJI_UTILS.GET_MAU (fact.currency_code)	brdn_cost
4702 	 , ROUND (
4703              NVL (
4704             DECODE (
4705                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4706 			 , '00'   , fact.revenue
4707 			 , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4708 			 , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4709 			 , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4710 			 , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4711 			 , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4712 			 , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4713 			 , '0-1'  , fact.revenue
4714 			 , '1-1'  , fact.revenue
4715 			 , 0  ) -- end decode
4716 			  , 0  ) -- end nvl
4717 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4718 						* PJI_UTILS.GET_MAU (fact.currency_code)	revenue
4719 	 , ROUND (
4720              NVL (
4721             DECODE (
4722                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4723 			  , '00'   , fact.bill_raw_cost
4724 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4725 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4726 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4727 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4728 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4729 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4730 			  , '0-1'  , fact.bill_raw_cost
4731 			  , '1-1'  , fact.bill_raw_cost
4732 			  , 0  ) -- end decode
4733 			    , 0  ) -- end nvl
4734 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4735 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_raw_cost
4736 	 , ROUND (
4737              NVL (
4738             DECODE (
4739                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4740 			  , '00'   , fact.bill_brdn_cost
4741 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4742 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4743 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4744 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4745 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4746 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4747 			  , '0-1'  , fact.bill_brdn_cost
4748 			  , '1-1'  , fact.bill_brdn_cost
4749 			  , 0  ) -- end decode
4750 			    , 0  ) -- end nvl
4751 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4752 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_brdn_cost
4753 	 , ROUND (
4754              NVL (
4755             DECODE (
4756                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4757 			  , '00'   , fact.bill_labor_raw_cost
4758 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4759 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4760 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4761 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4762 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4763 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4764 			  , '0-1'  , fact.bill_labor_raw_cost
4765 			  , '1-1'  , fact.bill_labor_raw_cost
4766 			  , 0  ) -- end decode
4767 			    , 0  ) -- end nvl
4768 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4769 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_raw_cost
4770 	 , ROUND (
4771              NVL (
4772             DECODE (
4773                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4774 			  , '00'   , fact.bill_labor_brdn_cost
4778 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4775 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4776 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4777 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4779 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4780 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4781 			  , '0-1'  , fact.bill_labor_brdn_cost
4782 			  , '1-1'  , fact.bill_labor_brdn_cost
4783 			  , 0  ) -- end decode
4784 			    , 0  ) -- end nvl
4785 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4786 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_brdn_cost
4787 	 , ROUND (
4788              NVL (
4789             DECODE (
4790                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4791 			  , '00'   , fact.bill_labor_hrs
4792 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4793 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4794 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4795 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4796 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4797 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4798 			  , '0-1'  , fact.bill_labor_hrs
4799 			  , '1-1'  , fact.bill_labor_hrs
4800 			  , 0  ) -- end decode
4801 			    , 0  ) -- end nvl
4802 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4803 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_hrs
4804 	 , ROUND (
4805              NVL (
4806             DECODE (
4807                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4808 			  , '00'   , fact.equipment_raw_cost
4809 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4810 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4811 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4812 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4813 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4814 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4815 			  , '0-1'  , fact.equipment_raw_cost
4816 			  , '1-1'  , fact.equipment_raw_cost
4817 			  , 0  ) -- end decode
4818 			    , 0  ) -- end nvl
4819 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4820 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_raw_cost
4821 	 , ROUND (
4822              NVL (
4823             DECODE (
4824                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4825 			  , '00'   , fact.equipment_brdn_cost
4826 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4827 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4828 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4829 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4830 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4831 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4832 			  , '0-1'  , fact.equipment_brdn_cost
4833 			  , '1-1'  , fact.equipment_brdn_cost
4834 			  , 0  ) -- end decode
4835 			    , 0  ) -- end nvl
4836 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4837 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_brdn_cost
4838 	 , ROUND (
4839              NVL (
4840             DECODE (
4841                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4842 			  , '00'   , fact.capitalizable_raw_cost
4843 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4844 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4845 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4846 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4850 			  , '1-1'  , fact.capitalizable_raw_cost
4847 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4848 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4849 			  , '0-1'  , fact.capitalizable_raw_cost
4851 			  , 0  ) -- end decode
4852 			    , 0  ) -- end nvl
4853 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4854 						* PJI_UTILS.GET_MAU (fact.currency_code)	capitalizable_raw_cost
4855 	 , ROUND (
4856              NVL (
4857             DECODE (
4858                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4859 			  , '00'   , fact.capitalizable_brdn_cost
4860 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4861 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4862 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4863 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4864 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4865 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4866 			  , '0-1'  , fact.capitalizable_brdn_cost
4867 			  , '1-1'  , fact.capitalizable_brdn_cost
4868 			  , 0  ) -- end decode
4869 			    , 0  ) -- end nvl
4870 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4871 						* PJI_UTILS.GET_MAU (fact.currency_code)	capitalizable_brdn_cost
4872 	 , ROUND (
4873              NVL (
4874             DECODE (
4875                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4876 			  , '00'   , fact.labor_raw_cost
4877 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4878 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4879 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4880 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4881 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4882 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4883 			  , '0-1'  , fact.labor_raw_cost
4884 			  , '1-1'  , fact.labor_raw_cost
4885 			  , 0  ) -- end decode
4886 			    , 0  ) -- end nvl
4887 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4888 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_raw_cost
4889 	 , ROUND (
4890              NVL (
4891             DECODE (
4892                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4893 			  , '00'   , fact.labor_brdn_cost
4894 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4895 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4896 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4897 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4898 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4899 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4900 			  , '0-1'  , fact.labor_brdn_cost
4901 			  , '1-1'  , fact.labor_brdn_cost
4902 			  , 0  ) -- end decode
4903 			    , 0  ) -- end nvl
4904 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4905 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_brdn_cost
4906 	 , ROUND (
4907              NVL (
4908             DECODE (
4909                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4910 			  , '00'   , fact.labor_hrs
4911 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4912 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4913 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4914 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4915 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4916 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4917 			  , '0-1'  , fact.labor_hrs
4918 			  , '1-1'  , fact.labor_hrs
4919 			  , 0  ) -- end decode
4920 			    , 0  ) -- end nvl
4921 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4922 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_hrs
4923 	 , ROUND (
4924              NVL (
4925             DECODE (
4929 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4926                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4927 			  , '00'   , fact.labor_revenue
4928 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4930 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4931 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4932 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4933 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4934 			  , '0-1'  , fact.labor_revenue
4935 			  , '1-1'  , fact.labor_revenue
4936 			  , 0  ) -- end decode
4937 			    , 0  ) -- end nvl
4938 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4939 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_revenue
4940 	 , ROUND (
4941              NVL (
4942             DECODE (
4943                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4944 			  , '00'   , fact.equipment_hours
4945 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4946 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4947 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4948 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4949 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4950 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4951 			  , '0-1'  , fact.equipment_hours
4952 			  , '1-1'  , fact.equipment_hours
4953 			  , 0  ) -- end decode
4954 			    , 0  ) -- end nvl
4955 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4956 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_hours
4957 	 , ROUND (
4958              NVL (
4959             DECODE (
4960                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4961 			  , '00'   , fact.billable_equipment_hours
4962 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4963 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4964 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4965 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4966 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4967 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4968 			  , '0-1'  , fact.billable_equipment_hours
4969 			  , '1-1'  , fact.billable_equipment_hours
4970 			  , 0  ) -- end decode
4971 			    , 0  ) -- end nvl
4972 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4973 						* PJI_UTILS.GET_MAU (fact.currency_code)	billable_equipment_hours
4974 	 , ROUND (
4975              NVL (
4976             DECODE (
4977                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4978 			  , '00'   , fact.sup_inv_committed_cost
4979 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4980 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4981 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4982 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4983 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4984 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4985 			  , '0-1'  , fact.sup_inv_committed_cost
4986 			  , '1-1'  , fact.sup_inv_committed_cost
4987 			  , 0  ) -- end decode
4988 			    , 0  ) -- end nvl
4989 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
4990 						* PJI_UTILS.GET_MAU (fact.currency_code)	sup_inv_committed_cost
4991 	 , ROUND (
4992              NVL (
4993             DECODE (
4994                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
4995 			  , '00'   , fact.po_committed_cost
4996 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4997 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
4998 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5002 			  , '0-1'  , fact.po_committed_cost
4999 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5000 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5001 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5003 			  , '1-1'  , fact.po_committed_cost
5004 			  , 0  ) -- end decode
5005 			    , 0  ) -- end nvl
5006 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5007 						* PJI_UTILS.GET_MAU (fact.currency_code)	po_committed_cost
5008 	 , ROUND (
5009              NVL (
5010             DECODE (
5011                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5012 			  , '00'   , fact.pr_committed_cost
5013 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5014 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5015 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5016 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5017 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5018 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5019 			  , '0-1'  , fact.pr_committed_cost
5020 			  , '1-1'  , fact.pr_committed_cost
5021 			  , 0  ) -- end decode
5022 			    , 0  ) -- end nvl
5023 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5024 						* PJI_UTILS.GET_MAU (fact.currency_code)	pr_committed_cost
5025 	 , ROUND (
5026              NVL (
5027             DECODE (
5028                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5029 			  , '00'   , fact.oth_committed_cost
5030 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5031 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5032 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5033 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5034 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5035 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5036 			  , '0-1'  , fact.oth_committed_cost
5037 			  , '1-1'  , fact.oth_committed_cost
5038 			  , 0  ) -- end decode
5039 			    , 0  ) -- end nvl
5040 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5041 						* PJI_UTILS.GET_MAU (fact.currency_code)	oth_committed_cost
5042 	 , ROUND (
5043              NVL (
5044             DECODE (
5045                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5046 			  , '00'   , fact.ACT_LABOR_HRS
5047 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5048 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5049 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5050 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5051 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5052 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5053 			  , '0-1'  , fact.ACT_LABOR_HRS
5054 			  , '1-1'  , fact.ACT_LABOR_HRS
5055 			  , 0  ) -- end decode
5056 			    , 0  ) -- end nvl
5057 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5058 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_HRS
5059 	 , ROUND (
5060              NVL (
5061             DECODE (
5062                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5063 			  , '00'   , fact.ACT_EQUIP_HRS
5064 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5065 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5066 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5067 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5068 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5069 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5070 			  , '0-1'  , fact.ACT_EQUIP_HRS
5071 			  , '1-1'  , fact.ACT_EQUIP_HRS
5072 			  , 0  ) -- end decode
5073 			    , 0  ) -- end nvl
5074 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5075 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_HRS
5076 	 , ROUND (
5080 			  , '00'   , fact.ACT_LABOR_BRDN_COST
5077              NVL (
5078             DECODE (
5079                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5081 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5082 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5083 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5084 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5085 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5086 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5087 			  , '0-1'  , fact.ACT_LABOR_BRDN_COST
5088 			  , '1-1'  , fact.ACT_LABOR_BRDN_COST
5089 			  , 0  ) -- end decode
5090 			    , 0  ) -- end nvl
5091 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5092 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_BRDN_COST
5093 	 , ROUND (
5094              NVL (
5095             DECODE (
5096                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5097 			  , '00'   , fact.ACT_EQUIP_BRDN_COST
5098 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5099 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5100 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5101 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5102 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5103 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5104 			  , '0-1'  , fact.ACT_EQUIP_BRDN_COST
5105 			  , '1-1'  , fact.ACT_EQUIP_BRDN_COST
5106 			  , 0  ) -- end decode
5107 			    , 0  ) -- end nvl
5108 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5109 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_BRDN_COST
5110 	 , ROUND (
5111              NVL (
5112             DECODE (
5113                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5114 			  , '00'   , fact.ACT_BRDN_COST
5115 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5116 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5117 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5118 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5119 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5120 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5121 			  , '0-1'  , fact.ACT_BRDN_COST
5122 			  , '1-1'  , fact.ACT_BRDN_COST
5123 			  , 0  ) -- end decode
5124 			    , 0  ) -- end nvl
5125 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5126 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_BRDN_COST
5127 	 , ROUND (
5128              NVL (
5129             DECODE (
5130                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5131 			  , '00'   , fact.ACT_RAW_COST
5132 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5133 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5134 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5135 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5136 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5137 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5138 			  , '0-1'  , fact.ACT_RAW_COST
5139 			  , '1-1'  , fact.ACT_RAW_COST
5140 			  , 0  ) -- end decode
5141 			    , 0  ) -- end nvl
5142 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5143 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_RAW_COST
5144 	 , ROUND (
5145              NVL (
5146             DECODE (
5147                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5148 			  , '00'   , fact.ACT_REVENUE
5149 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5150 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5151 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5152 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5156 			  , '1-1'  , fact.ACT_REVENUE
5153 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5154 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5155 			  , '0-1'  , fact.ACT_REVENUE
5157 			  , 0  ) -- end decode
5158 			    , 0  ) -- end nvl
5159 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5160 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_REVENUE
5161 	 , ROUND (
5162              NVL (
5163             DECODE (
5164                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5165 			  , '00'   , fact.ACT_LABOR_RAW_COST
5166 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5167 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5168 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5169 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5170 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5171 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5172 			  , '0-1'  , fact.ACT_LABOR_RAW_COST
5173 			  , '1-1'  , fact.ACT_LABOR_RAW_COST
5174 			  , 0  ) -- end decode
5175 			    , 0  ) -- end nvl
5176 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5177 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_RAW_COST
5178 	 , ROUND (
5179              NVL (
5180             DECODE (
5181                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5182 			  , '00'   , fact.ACT_EQUIP_RAW_COST
5183 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5184 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5185 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5186 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5187 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5188 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5189 			  , '0-1'  , fact.ACT_EQUIP_RAW_COST
5190 			  , '1-1'  , fact.ACT_EQUIP_RAW_COST
5191 			  , 0  ) -- end decode
5192 			    , 0  ) -- end nvl
5193 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5194 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_RAW_COST
5195 	 , ROUND (
5196              NVL (
5197             DECODE (
5198                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5199 			  , '00'   , fact.ETC_LABOR_HRS
5200 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5201 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5202 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5203 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5204 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5205 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5206 			  , '0-1'  , fact.ETC_LABOR_HRS
5207 			  , '1-1'  , fact.ETC_LABOR_HRS
5208 			  , 0  ) -- end decode
5209 			    , 0  ) -- end nvl
5210 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5211 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_HRS
5212 	 , ROUND (
5213              NVL (
5214             DECODE (
5215                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5216 			  , '00'   , fact.ETC_EQUIP_HRS
5217 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5218 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5219 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5220 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5221 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5222 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5223 			  , '0-1'  , fact.ETC_EQUIP_HRS
5224 			  , '1-1'  , fact.ETC_EQUIP_HRS
5225 			  , 0  ) -- end decode
5226 			    , 0  ) -- end nvl
5227 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5228 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_HRS
5229 	 , ROUND (
5230              NVL (
5231             DECODE (
5235 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5232                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5233 			  , '00'   , fact.ETC_LABOR_BRDN_COST
5234 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5236 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5237 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5238 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5239 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5240 			  , '0-1'  , fact.ETC_LABOR_BRDN_COST
5241 			  , '1-1'  , fact.ETC_LABOR_BRDN_COST
5242 			  , 0  ) -- end decode
5243 			    , 0  ) -- end nvl
5244 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5245 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_BRDN_COST
5246 	 , ROUND (
5247              NVL (
5248             DECODE (
5249                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5250 			  , '00'   , fact.ETC_EQUIP_BRDN_COST
5251 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5252 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5253 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5254 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5255 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5256 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5257 			  , '0-1'  , fact.ETC_EQUIP_BRDN_COST
5258 			  , '1-1'  , fact.ETC_EQUIP_BRDN_COST
5259 			  , 0  ) -- end decode
5260 			    , 0  ) -- end nvl
5261 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5262 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_BRDN_COST
5263 	 , ROUND (
5264              NVL (
5265             DECODE (
5266                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5267 			  , '00'   , fact.ETC_BRDN_COST
5268 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5269 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5270 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5271 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5272 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5273 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5274 			  , '0-1'  , fact.ETC_BRDN_COST
5275 			  , '1-1'  , fact.ETC_BRDN_COST
5276 			  , 0  ) -- end decode
5277 			    , 0  ) -- end nvl
5278 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5279 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_BRDN_COST
5280 	 , ROUND (
5281              NVL (
5282             DECODE (
5283                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5284 			  , '00'   , fact.ETC_RAW_COST
5285 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5286 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5287 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5288 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5289 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5290 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5291 			  , '0-1'  , fact.ETC_RAW_COST
5292 			  , '1-1'  , fact.ETC_RAW_COST
5293 			  , 0  ) -- end decode
5294 			    , 0  ) -- end nvl
5295 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5296 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_RAW_COST
5297 	 , ROUND (
5298              NVL (
5299             DECODE (
5300                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5301 			  , '00'   , fact.ETC_LABOR_RAW_COST
5302 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5303 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5304 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5305 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5309 			  , '1-1'  , fact.ETC_LABOR_RAW_COST
5306 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5307 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5308 			  , '0-1'  , fact.ETC_LABOR_RAW_COST
5310 			  , 0  ) -- end decode
5311 			    , 0  ) -- end nvl
5312 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5313 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_RAW_COST
5314 	 , ROUND (
5315              NVL (
5316             DECODE (
5317                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5318 			  , '00'   , fact.ETC_EQUIP_RAW_COST
5319 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5320 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5321 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5322 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5323 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5324 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5325 			  , '0-1'  , fact.ETC_EQUIP_RAW_COST
5326 			  , '1-1'  , fact.ETC_EQUIP_RAW_COST
5327 			  , 0  ) -- end decode
5328 			    , 0  ) -- end nvl
5329 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5330 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_RAW_COST
5331 	 , ROUND (
5332              NVL (
5333             DECODE (
5334                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5335 			  , '00'   , fact.custom1
5336 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5337 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5338 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5339 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5340 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5341 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5342 			  , '0-1'  , fact.custom1
5343 			  , '1-1'  , fact.custom1
5344 			  , 0  ) -- end decode
5345 			    , 0  ) -- end nvl
5346 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5347 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom1
5348 	 , ROUND (
5349              NVL (
5350             DECODE (
5351                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5352 			  , '00'   , fact.custom2
5353 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5354 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5355 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5356 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5357 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5358 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5359 			  , '0-1'  , fact.custom2
5360 			  , '1-1'  , fact.custom2
5361 			  , 0  ) -- end decode
5362 			    , 0  ) -- end nvl
5363 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5364 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom2
5365 	 , ROUND (
5366              NVL (
5367             DECODE (
5368                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5369 			  , '00'   , fact.custom3
5370 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5371 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5372 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5373 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5374 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5375 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5376 			  , '0-1'  , fact.custom3
5377 			  , '1-1'  , fact.custom3
5378 			  , 0  ) -- end decode
5379 			    , 0  ) -- end nvl
5380 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5381 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom3
5382 	 , ROUND (
5383              NVL (
5384             DECODE (
5385                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5386 			  , '00'   , fact.custom4
5390 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5387 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5388 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5389 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5391 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5392 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5393 			  , '0-1'  , fact.custom4
5394 			  , '1-1'  , fact.custom4
5395 			  , 0  ) -- end decode
5396 			    , 0  ) -- end nvl
5397 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5398 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom4
5399 	 , ROUND (
5400              NVL (
5401             DECODE (
5402                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5403 			  , '00'   , fact.custom5
5404 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5405 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5406 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5407 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5408 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5409 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5410 			  , '0-1'  , fact.custom5
5411 			  , '1-1'  , fact.custom5
5412 			  , 0  ) -- end decode
5413 			    , 0  ) -- end nvl
5414 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5415 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom5
5416 	 , ROUND (
5417              NVL (
5418             DECODE (
5419                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5420 			  , '00'   , fact.custom6
5421 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5422 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5423 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5424 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5425 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5426 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5427 			  , '0-1'  , fact.custom6
5428 			  , '1-1'  , fact.custom6
5429 			  , 0  ) -- end decode
5430 			    , 0  ) -- end nvl
5431 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5432 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom6
5433 	 , ROUND (
5434              NVL (
5435             DECODE (
5436                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5437 			  , '00'   , fact.custom7
5438 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5439 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5440 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5441 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5442 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5443 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5444 			  , '0-1'  , fact.custom7
5445 			  , '1-1'  , fact.custom7
5446 			  , 0  ) -- end decode
5447 			    , 0  ) -- end nvl
5448 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5449 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom7
5450 	 , ROUND (
5451              NVL (
5452             DECODE (
5453                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5454 			  , '00'   , fact.custom8
5455 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5456 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5457 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5458 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5459 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5460 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5461 			  , '0-1'  , fact.custom8
5462 			  , '1-1'  , fact.custom8
5463 			  , 0  ) -- end decode
5464 			    , 0  ) -- end nvl
5465 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5466 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom8
5467 	 , ROUND (
5471 			  , '00'   , fact.custom9
5468              NVL (
5469             DECODE (
5470                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5472 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5473 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5474 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5475 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5476 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5477 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5478 			  , '0-1'  , fact.custom9
5479 			  , '1-1'  , fact.custom9
5480 			  , 0  ) -- end decode
5481 			    , 0  ) -- end nvl
5482 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5483 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom9
5484 	 , ROUND (
5485              NVL (
5486             DECODE (
5487                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5488 			  , '00'   , fact.custom10
5489 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5490 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5491 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5492 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5493 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5494 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5495 			  , '0-1'  , fact.custom10
5496 			  , '1-1'  , fact.custom10
5497 			  , 0  ) -- end decode
5498 			    , 0  ) -- end nvl
5499 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5500 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom10
5501 	 , ROUND (
5502              NVL (
5503             DECODE (
5504                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5505 			  , '00'   , fact.custom11
5506 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5507 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5508 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5509 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5510 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5511 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5512 			  , '0-1'  , fact.custom11
5513 			  , '1-1'  , fact.custom11
5514 			  , 0  ) -- end decode
5515 			    , 0  ) -- end nvl
5516 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5517 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom11
5518 	 , ROUND (
5519              NVL (
5520             DECODE (
5521                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5522 			  , '00'   , fact.custom12
5523 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5524 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5525 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5526 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5527 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5528 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5529 			  , '0-1'  , fact.custom12
5530 			  , '1-1'  , fact.custom12
5531 			  , 0  ) -- end decode
5532 			    , 0  ) -- end nvl
5533 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5534 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom12
5535 	 , ROUND (
5536              NVL (
5537             DECODE (
5538                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5539 			  , '00'   , fact.custom13
5540 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5541 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5542 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5543 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5544 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5545 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5549 			    , 0  ) -- end nvl
5546 			  , '0-1'  , fact.custom13
5547 			  , '1-1'  , fact.custom13
5548 			  , 0  ) -- end decode
5550 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5551 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom13
5552 	 , ROUND (
5553              NVL (
5554             DECODE (
5555                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5556 			  , '00'   , fact.custom14
5557 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5558 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5559 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5560 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5561 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5562 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5563 			  , '0-1'  , fact.custom14
5564 			  , '1-1'  , fact.custom14
5565 			  , 0  ) -- end decode
5566 			    , 0  ) -- end nvl
5567 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5568 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom14
5569 	 , ROUND (
5570              NVL (
5571             DECODE (
5572                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
5573 			  , '00'   , fact.custom15
5574 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5575 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5576 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5577 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5578 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5579 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
5580 			  , '0-1'  , fact.custom15
5581 			  , '1-1'  , fact.custom15
5582 			  , 0  ) -- end decode
5583 			    , 0  ) -- end nvl
5584 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5585 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom15
5586          , fact.plan_type_code   plan_type_code     /* 4471527  */
5587    FROM  pji_fp_xbs_accum_f  fact
5588        , pji_time_cal_period  non_pa_cal
5589     -- , pji_org_extr_info  orginfo
5590    	 , pji_time_ent_period  pa_cal
5591        , PJI_FM_EXTR_PLNVER3_T ver
5592    WHERE  1 = 1
5593       AND fact.calendar_type IN ('P', 'G')
5594       AND fact.period_type_id = 32
5595       AND non_pa_cal.cal_period_id = fact.time_id
5596       AND ver.project_id = fact.project_id
5597       AND ver.plan_version_id = fact.plan_version_id
5598       ANd ver.plan_type_code = fact.plan_type_code    /* 4471527 */
5599       -- AND orginfo.org_id = fact.PROJECT_ORG_ID
5600       -- AND orginfo.pa_calendar_id = pa_cal.calendar_id
5601       -- AND pa_cal.start_date >= non_pa_cal.start_date
5602       AND (
5603 	       ( pa_cal.start_date >= non_pa_cal.start_date  AND pa_cal.end_date <= non_pa_cal.end_date )
5604 	    OR ( pa_cal.start_date <= non_pa_cal.start_date  AND pa_cal.end_date >= non_pa_cal.end_date )
5605 	    OR ( pa_cal.start_date <= non_pa_cal.start_date  AND pa_cal.end_date <= non_pa_cal.end_date AND pa_cal.end_date >= non_pa_cal.start_date )
5606 	    OR ( pa_cal.start_date >= non_pa_cal.start_date  AND pa_cal.end_date >= non_pa_cal.end_date AND pa_cal.start_date <= non_pa_cal.end_date )
5607           )
5608       AND fact.period_type_id = 32
5609       AND ver.wp_flag = 'N'
5610       AND ver.baselined_flag = 'Y'
5611 	-- AND ( ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
5612       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
5613 	  ) a
5614 	  GROUP BY
5615 	   a.PROJECT_ID
5616      , a.PROJECT_ORG_ID
5617      , a.PROJECT_ORGANIZATION_ID
5618      , a.PROJECT_ELEMENT_ID
5619      , a.TIME_ID
5620      , a.PERIOD_TYPE_ID
5621      , a.CALENDAR_TYPE
5622      , a.RBS_AGGR_LEVEL
5623      , a.WBS_ROLLUP_FLAG
5624      , a.PRG_ROLLUP_FLAG
5625      , a.CURR_RECORD_TYPE_ID
5626      , a.CURRENCY_CODE
5627      , a.RBS_ELEMENT_ID
5628      , a.RBS_VERSION_ID
5629      , a.PLAN_VERSION_ID
5630      , a.PLAN_TYPE_ID
5631      , a.PLAN_TYPE_CODE ;
5632 
5633 EXCEPTION
5634   WHEN OTHERS THEN
5635     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
5636                              p_procedure_name => 'PRORATE_TO_ENT_PG_FPRL_D ');
5637     RAISE;
5638 END;
5639 
5640 
5641 PROCEDURE PRORATE_TO_ENT_N_PJP1_D IS
5642 BEGIN
5643 
5644     -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
5645 
5646 /* Commented for bug 4005006
5647     INSERT INTO pji_fp_aggr_pjp1_t   -- Non time phased entries in pjp1 table.
5648     (
5649        WORKER_ID
5650      , PROJECT_ID
5651      , PROJECT_ORG_ID
5652      , PROJECT_ORGANIZATION_ID
5653      -- , PARTITION_ID
5654      , PROJECT_ELEMENT_ID
5655      , TIME_ID
5656      , PERIOD_TYPE_ID
5657      , CALENDAR_TYPE
5658      , RBS_AGGR_LEVEL
5659      , WBS_ROLLUP_FLAG
5660      , PRG_ROLLUP_FLAG
5661      , CURR_RECORD_TYPE_ID
5662      , CURRENCY_CODE
5666      , PLAN_TYPE_ID
5663      , RBS_ELEMENT_ID
5664      , RBS_VERSION_ID
5665      , PLAN_VERSION_ID
5667      , RAW_COST
5668      , BRDN_COST
5669      , REVENUE
5670      , BILL_RAW_COST
5671      , BILL_BRDN_COST
5672      , BILL_LABOR_RAW_COST
5673      , BILL_LABOR_BRDN_COST
5674      , BILL_LABOR_HRS
5675      , EQUIPMENT_RAW_COST
5676      , EQUIPMENT_BRDN_COST
5677      , CAPITALIZABLE_RAW_COST
5678      , CAPITALIZABLE_BRDN_COST
5679      , LABOR_RAW_COST
5680      , LABOR_BRDN_COST
5681      , LABOR_HRS
5682      , LABOR_REVENUE
5683      , EQUIPMENT_HOURS
5684      , BILLABLE_EQUIPMENT_HOURS
5685      , SUP_INV_COMMITTED_COST
5686      , PO_COMMITTED_COST
5687      , PR_COMMITTED_COST
5688      , OTH_COMMITTED_COST
5689        , ACT_LABOR_HRS
5690 	   , ACT_EQUIP_HRS
5691 	   , ACT_LABOR_BRDN_COST
5692 	   , ACT_EQUIP_BRDN_COST
5693 	   , ACT_BRDN_COST
5694 	   , ACT_RAW_COST
5695 	   , ACT_REVENUE
5696          , ACT_LABOR_RAW_COST
5697          , ACT_EQUIP_RAW_COST
5698 	   , ETC_LABOR_HRS
5699 	   , ETC_EQUIP_HRS
5700 	   , ETC_LABOR_BRDN_COST
5701 	   , ETC_EQUIP_BRDN_COST
5702 	   , ETC_BRDN_COST
5703          , ETC_RAW_COST
5704          , ETC_LABOR_RAW_COST
5705          , ETC_EQUIP_RAW_COST
5706      , CUSTOM1
5707      , CUSTOM2
5708      , CUSTOM3
5709      , CUSTOM4
5710      , CUSTOM5
5711      , CUSTOM6
5712      , CUSTOM7
5713      , CUSTOM8
5714      , CUSTOM9
5715      , CUSTOM10
5716      , CUSTOM11
5717      , CUSTOM12
5718      , CUSTOM13
5719      , CUSTOM14
5720      , CUSTOM15
5721      , LINE_TYPE
5722      , TIME_DANGLING_FLAG
5723      , RATE_DANGLING_FLAG
5724      , PRG_LEVEL
5725    )
5726    SELECT
5727        g_worker_id worker_id
5728      , a.PROJECT_ID
5729      , a.PROJECT_ORG_ID
5730      , a.PROJECT_ORGANIZATION_ID
5731      , a.PROJECT_ELEMENT_ID
5732      , a.TIME_ID
5733      , 32 -- a.PERIOD_TYPE_ID
5734      , a.CALENDAR_TYPE
5735      , a.RBS_AGGR_LEVEL
5736      , a.WBS_ROLLUP_FLAG
5737      , a.PRG_ROLLUP_FLAG
5738      , a.CURR_RECORD_TYPE_ID
5739      , a.CURRENCY_CODE
5740      , a.RBS_ELEMENT_ID
5741      , a.RBS_VERSION_ID
5742      , a.PLAN_VERSION_ID
5743      , a.PLAN_TYPE_ID
5744      , SUM(a.RAW_COST       )
5745      , SUM(a.BRDN_COST 	)
5746      , SUM(a.REVENUE	)
5747      , SUM(a.BILL_RAW_COST )
5748      , SUM(a.BILL_BRDN_COST )
5749      , SUM(a.BILL_LABOR_RAW_COST )
5750      , SUM(a.BILL_LABOR_BRDN_COST )
5751      , SUM(a.BILL_LABOR_HRS )
5752      , SUM(a.EQUIPMENT_RAW_COST )
5753      , SUM(a.EQUIPMENT_BRDN_COST )
5754      , SUM(a.CAPITALIZABLE_RAW_COST )
5755      , SUM(a.CAPITALIZABLE_BRDN_COST )
5756      , SUM(a.LABOR_RAW_COST )
5757      , SUM(a.LABOR_BRDN_COST)
5758      , SUM(a.LABOR_HRS )
5759      , SUM(a.LABOR_REVENUE )
5760      , SUM(a.EQUIPMENT_HOURS )
5761      , SUM(a.BILLABLE_EQUIPMENT_HOURS)
5762      , SUM(a.SUP_INV_COMMITTED_COST)
5763      , SUM(a.PO_COMMITTED_COST )
5764      , SUM(a.PR_COMMITTED_COST )
5765      , SUM(a.OTH_COMMITTED_COST)
5766        , SUM(a.ACT_LABOR_HRS)
5767 	   , SUM(a.ACT_EQUIP_HRS)
5768 	   , SUM(a.ACT_LABOR_BRDN_COST)
5769 	   , SUM(a.ACT_EQUIP_BRDN_COST)
5770 	   , SUM(a.ACT_BRDN_COST    )
5771 	   , SUM(a.ACT_RAW_COST    )
5772 	   , SUM(a.ACT_REVENUE    )
5773          , SUM(a.ACT_LABOR_RAW_COST)
5774          , SUM(a.ACT_EQUIP_RAW_COST)
5775 	   , SUM(a.ETC_LABOR_HRS         )
5776 	   , SUM(a.ETC_EQUIP_HRS        )
5777 	   , SUM(a.ETC_LABOR_BRDN_COST )
5778 	   , SUM(a.ETC_EQUIP_BRDN_COST)
5779 	   , SUM(a.ETC_BRDN_COST )
5780          , SUM(a.ETC_RAW_COST)
5781          , SUM(a.ETC_LABOR_RAW_COST)
5782          , SUM(a.ETC_EQUIP_RAW_COST)
5783      , SUM(a.CUSTOM1	)
5784      , SUM(a.CUSTOM2	)
5785      , SUM(a.CUSTOM3	)
5786      , SUM(a.CUSTOM4	)
5787      , SUM(a.CUSTOM5	)
5788      , SUM(a.CUSTOM6	)
5789      , SUM(a.CUSTOM7	)
5790      , SUM(a.CUSTOM8	)
5791      , SUM(a.CUSTOM9	)
5792      , SUM(a.CUSTOM10	)
5793      , SUM(a.CUSTOM11	)
5794      , SUM(a.CUSTOM12	)
5795      , SUM(a.CUSTOM13	)
5796      , SUM(a.CUSTOM14	)
5797      , SUM(a.CUSTOM15	)
5798      , a.LINE_TYPE
5799      , a.TIME_DANGLING_FLAG
5800      , a.RATE_DANGLING_FLAG
5801      , g_default_prg_level prg_level
5802    FROM (
5803    SELECT
5804          fact.project_id  project_id
5805    	 , fact.project_ORG_ID project_ORG_ID
5806    	 , fact.project_ORGANIZATION_ID project_ORGANIZATION_ID
5807      -- , fact.PARTITION_ID PARTITION_ID
5808    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
5809    	 , pa_cal.ent_period_id TIME_ID
5810    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
5811    	 , 'E' CALENDAR_TYPE -- fact.CALENDAR_TYPE
5812      , fact.RBS_AGGR_LEVEL
5813      , fact.WBS_ROLLUP_FLAG
5814      , fact.PRG_ROLLUP_FLAG
5815    	 , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
5816    	 , fact.CURRENCY_CODE CURRENCY_CODE
5817    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
5818    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
5819    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
5820 	 , fact.PLAN_TYPE_ID  PLAN_TYPE_ID
5821 	 , ROUND (
5822              NVL (
5826 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (fact.end_date - fact.start_date + 1)
5823             DECODE (
5824                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
5825 			  , '00'   , fact.raw_cost
5827 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (fact.end_date - fact.start_date + 1)
5828 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.raw_cost / (fact.end_date - fact.start_date + 1)
5829 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.raw_cost / (fact.end_date - fact.start_date + 1)
5830 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.raw_cost / (fact.end_date - fact.start_date + 1)
5831 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.raw_cost / (fact.end_date - fact.start_date + 1)
5832 			  , '0-1'  , fact.raw_cost
5833 			  , '1-1'  , fact.raw_cost
5834 			  , 0  ) -- end decode
5835 			    , 0  ) -- end nvl
5836 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5837 						* PJI_UTILS.GET_MAU (fact.currency_code)	raw_cost
5838 	 , ROUND (
5839              NVL (
5840             DECODE (
5841                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
5842 			 , '00'   , fact.brdn_cost
5843 			 , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (fact.end_date - fact.start_date + 1)
5844 			 , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (fact.end_date - fact.start_date + 1)
5845 			 , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.brdn_cost / (fact.end_date - fact.start_date + 1)
5846 			 , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.brdn_cost / (fact.end_date - fact.start_date + 1)
5847 			 , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (fact.end_date - fact.start_date + 1)
5848 			 , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (fact.end_date - fact.start_date + 1)
5849 			 , '0-1'  , fact.brdn_cost
5850 			 , '1-1'  , fact.brdn_cost
5851 			 , 0  ) -- end decode
5852 			  , 0  ) -- end nvl
5853 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5854 						* PJI_UTILS.GET_MAU (fact.currency_code)	brdn_cost
5855 	 , ROUND (
5856              NVL (
5857             DECODE (
5858                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
5859 			 , '00'   , fact.revenue
5860 			 , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (fact.end_date - fact.start_date + 1)
5861 			 , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (fact.end_date - fact.start_date + 1)
5862 			 , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.revenue / (fact.end_date - fact.start_date + 1)
5863 			 , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.revenue / (fact.end_date - fact.start_date + 1)
5864 			 , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.revenue / (fact.end_date - fact.start_date + 1)
5865 			 , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.revenue / (fact.end_date - fact.start_date + 1)
5866 			 , '0-1'  , fact.revenue
5867 			 , '1-1'  , fact.revenue
5868 			 , 0  ) -- end decode
5869 			  , 0  ) -- end nvl
5870 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5871 						* PJI_UTILS.GET_MAU (fact.currency_code)	revenue
5872 	 , ROUND (
5873              NVL (
5874             DECODE (
5875                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
5876 			  , '00'   , fact.bill_raw_cost
5877 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (fact.end_date - fact.start_date + 1)
5878 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (fact.end_date - fact.start_date + 1)
5879 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_raw_cost / (fact.end_date - fact.start_date + 1)
5880 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_raw_cost / (fact.end_date - fact.start_date + 1)
5881 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (fact.end_date - fact.start_date + 1)
5882 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (fact.end_date - fact.start_date + 1)
5883 			  , '0-1'  , fact.bill_raw_cost
5884 			  , '1-1'  , fact.bill_raw_cost
5885 			  , 0  ) -- end decode
5886 			    , 0  ) -- end nvl
5887 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5888 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_raw_cost
5889 	 , ROUND (
5890              NVL (
5891             DECODE (
5892                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
5893 			  , '00'   , fact.bill_brdn_cost
5894 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (fact.end_date - fact.start_date + 1)
5895 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (fact.end_date - fact.start_date + 1)
5896 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_brdn_cost / (fact.end_date - fact.start_date + 1)
5897 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_brdn_cost / (fact.end_date - fact.start_date + 1)
5898 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (fact.end_date - fact.start_date + 1)
5899 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (fact.end_date - fact.start_date + 1)
5900 			  , '0-1'  , fact.bill_brdn_cost
5901 			  , '1-1'  , fact.bill_brdn_cost
5902 			  , 0  ) -- end decode
5903 			    , 0  ) -- end nvl
5904 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5908             DECODE (
5905 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_brdn_cost
5906 	 , ROUND (
5907              NVL (
5909                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
5910 			  , '00'   , fact.bill_labor_raw_cost
5911 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (fact.end_date - fact.start_date + 1)
5912 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (fact.end_date - fact.start_date + 1)
5913 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_labor_raw_cost / (fact.end_date - fact.start_date + 1)
5914 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_labor_raw_cost / (fact.end_date - fact.start_date + 1)
5915 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (fact.end_date - fact.start_date + 1)
5916 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (fact.end_date - fact.start_date + 1)
5917 			  , '0-1'  , fact.bill_labor_raw_cost
5918 			  , '1-1'  , fact.bill_labor_raw_cost
5919 			  , 0  ) -- end decode
5920 			    , 0  ) -- end nvl
5921 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5922 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_raw_cost
5923 	 , ROUND (
5924              NVL (
5925             DECODE (
5926                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
5927 			  , '00'   , fact.bill_labor_brdn_cost
5928 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (fact.end_date - fact.start_date + 1)
5929 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (fact.end_date - fact.start_date + 1)
5930 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_labor_brdn_cost / (fact.end_date - fact.start_date + 1)
5931 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_labor_brdn_cost / (fact.end_date - fact.start_date + 1)
5932 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (fact.end_date - fact.start_date + 1)
5933 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (fact.end_date - fact.start_date + 1)
5934 			  , '0-1'  , fact.bill_labor_brdn_cost
5935 			  , '1-1'  , fact.bill_labor_brdn_cost
5936 			  , 0  ) -- end decode
5937 			    , 0  ) -- end nvl
5938 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5939 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_brdn_cost
5940 	 , ROUND (
5941              NVL (
5942             DECODE (
5943                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
5944 			  , '00'   , fact.bill_labor_hrs
5945 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (fact.end_date - fact.start_date + 1)
5946 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (fact.end_date - fact.start_date + 1)
5947 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_labor_hrs / (fact.end_date - fact.start_date + 1)
5948 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_labor_hrs / (fact.end_date - fact.start_date + 1)
5949 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (fact.end_date - fact.start_date + 1)
5950 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (fact.end_date - fact.start_date + 1)
5951 			  , '0-1'  , fact.bill_labor_hrs
5952 			  , '1-1'  , fact.bill_labor_hrs
5953 			  , 0  ) -- end decode
5954 			    , 0  ) -- end nvl
5955 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5956 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_hrs
5957 	 , ROUND (
5958              NVL (
5959             DECODE (
5960                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
5961 			  , '00'   , fact.equipment_raw_cost
5962 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (fact.end_date - fact.start_date + 1)
5963 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (fact.end_date - fact.start_date + 1)
5964 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.equipment_raw_cost / (fact.end_date - fact.start_date + 1)
5965 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.equipment_raw_cost / (fact.end_date - fact.start_date + 1)
5966 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (fact.end_date - fact.start_date + 1)
5967 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (fact.end_date - fact.start_date + 1)
5968 			  , '0-1'  , fact.equipment_raw_cost
5969 			  , '1-1'  , fact.equipment_raw_cost
5970 			  , 0  ) -- end decode
5971 			    , 0  ) -- end nvl
5972 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5973 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_raw_cost
5974 	 , ROUND (
5975              NVL (
5976             DECODE (
5977                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
5978 			  , '00'   , fact.equipment_brdn_cost
5979 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (fact.end_date - fact.start_date + 1)
5980 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (fact.end_date - fact.start_date + 1)
5981 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.equipment_brdn_cost / (fact.end_date - fact.start_date + 1)
5982 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.equipment_brdn_cost / (fact.end_date - fact.start_date + 1)
5986 			  , '1-1'  , fact.equipment_brdn_cost
5983 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (fact.end_date - fact.start_date + 1)
5984 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (fact.end_date - fact.start_date + 1)
5985 			  , '0-1'  , fact.equipment_brdn_cost
5987 			  , 0  ) -- end decode
5988 			    , 0  ) -- end nvl
5989 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
5990 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_brdn_cost
5991 	 , ROUND (
5992              NVL (
5993             DECODE (
5994                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
5995 			  , '00'   , fact.capitalizable_raw_cost
5996 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (fact.end_date - fact.start_date + 1)
5997 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (fact.end_date - fact.start_date + 1)
5998 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.capitalizable_raw_cost / (fact.end_date - fact.start_date + 1)
5999 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.capitalizable_raw_cost / (fact.end_date - fact.start_date + 1)
6000 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (fact.end_date - fact.start_date + 1)
6001 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (fact.end_date - fact.start_date + 1)
6002 			  , '0-1'  , fact.capitalizable_raw_cost
6003 			  , '1-1'  , fact.capitalizable_raw_cost
6004 			  , 0  ) -- end decode
6005 			    , 0  ) -- end nvl
6006 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6007 						* PJI_UTILS.GET_MAU (fact.currency_code)	capitalizable_raw_cost
6008 	 , ROUND (
6009              NVL (
6010             DECODE (
6011                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6012 			  , '00'   , fact.capitalizable_brdn_cost
6013 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (fact.end_date - fact.start_date + 1)
6014 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (fact.end_date - fact.start_date + 1)
6015 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.capitalizable_brdn_cost / (fact.end_date - fact.start_date + 1)
6016 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.capitalizable_brdn_cost / (fact.end_date - fact.start_date + 1)
6017 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (fact.end_date - fact.start_date + 1)
6018 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (fact.end_date - fact.start_date + 1)
6019 			  , '0-1'  , fact.capitalizable_brdn_cost
6020 			  , '1-1'  , fact.capitalizable_brdn_cost
6021 			  , 0  ) -- end decode
6022 			    , 0  ) -- end nvl
6023 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6024 						* PJI_UTILS.GET_MAU (fact.currency_code)	capitalizable_brdn_cost
6025 	 , ROUND (
6026              NVL (
6027             DECODE (
6028                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6029 			  , '00'   , fact.labor_raw_cost
6030 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (fact.end_date - fact.start_date + 1)
6031 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (fact.end_date - fact.start_date + 1)
6032 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_raw_cost / (fact.end_date - fact.start_date + 1)
6033 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_raw_cost / (fact.end_date - fact.start_date + 1)
6034 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (fact.end_date - fact.start_date + 1)
6035 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (fact.end_date - fact.start_date + 1)
6036 			  , '0-1'  , fact.labor_raw_cost
6037 			  , '1-1'  , fact.labor_raw_cost
6038 			  , 0  ) -- end decode
6039 			    , 0  ) -- end nvl
6040 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6041 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_raw_cost
6042 	 , ROUND (
6043              NVL (
6044             DECODE (
6045                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6046 			  , '00'   , fact.labor_brdn_cost
6047 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (fact.end_date - fact.start_date + 1)
6048 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (fact.end_date - fact.start_date + 1)
6049 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_brdn_cost / (fact.end_date - fact.start_date + 1)
6050 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_brdn_cost / (fact.end_date - fact.start_date + 1)
6051 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (fact.end_date - fact.start_date + 1)
6052 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (fact.end_date - fact.start_date + 1)
6053 			  , '0-1'  , fact.labor_brdn_cost
6054 			  , '1-1'  , fact.labor_brdn_cost
6055 			  , 0  ) -- end decode
6056 			    , 0  ) -- end nvl
6057 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6058 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_brdn_cost
6059 	 , ROUND (
6060              NVL (
6061             DECODE (
6062                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6063 			  , '00'   , fact.labor_hrs
6067 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_hrs / (fact.end_date - fact.start_date + 1)
6064 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (fact.end_date - fact.start_date + 1)
6065 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (fact.end_date - fact.start_date + 1)
6066 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_hrs / (fact.end_date - fact.start_date + 1)
6068 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (fact.end_date - fact.start_date + 1)
6069 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (fact.end_date - fact.start_date + 1)
6070 			  , '0-1'  , fact.labor_hrs
6071 			  , '1-1'  , fact.labor_hrs
6072 			  , 0  ) -- end decode
6073 			    , 0  ) -- end nvl
6074 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6075 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_hrs
6076 	 , ROUND (
6077              NVL (
6078             DECODE (
6079                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6080 			  , '00'   , fact.labor_revenue
6081 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (fact.end_date - fact.start_date + 1)
6082 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (fact.end_date - fact.start_date + 1)
6083 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_revenue / (fact.end_date - fact.start_date + 1)
6084 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_revenue / (fact.end_date - fact.start_date + 1)
6085 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (fact.end_date - fact.start_date + 1)
6086 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (fact.end_date - fact.start_date + 1)
6087 			  , '0-1'  , fact.labor_revenue
6088 			  , '1-1'  , fact.labor_revenue
6089 			  , 0  ) -- end decode
6090 			    , 0  ) -- end nvl
6091 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6092 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_revenue
6093 	 , ROUND (
6094              NVL (
6095             DECODE (
6096                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6097 			  , '00'   , fact.equipment_hours
6098 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (fact.end_date - fact.start_date + 1)
6099 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (fact.end_date - fact.start_date + 1)
6100 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.equipment_hours / (fact.end_date - fact.start_date + 1)
6101 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.equipment_hours / (fact.end_date - fact.start_date + 1)
6102 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (fact.end_date - fact.start_date + 1)
6103 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (fact.end_date - fact.start_date + 1)
6104 			  , '0-1'  , fact.equipment_hours
6105 			  , '1-1'  , fact.equipment_hours
6106 			  , 0  ) -- end decode
6107 			    , 0  ) -- end nvl
6108 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6109 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_hours
6110 	 , ROUND (
6111              NVL (
6112             DECODE (
6113                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6114 			  , '00'   , fact.billable_equipment_hours
6115 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (fact.end_date - fact.start_date + 1)
6116 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (fact.end_date - fact.start_date + 1)
6117 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.billable_equipment_hours / (fact.end_date - fact.start_date + 1)
6118 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.billable_equipment_hours / (fact.end_date - fact.start_date + 1)
6119 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (fact.end_date - fact.start_date + 1)
6120 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (fact.end_date - fact.start_date + 1)
6121 			  , '0-1'  , fact.billable_equipment_hours
6122 			  , '1-1'  , fact.billable_equipment_hours
6123 			  , 0  ) -- end decode
6124 			    , 0  ) -- end nvl
6125 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6126 						* PJI_UTILS.GET_MAU (fact.currency_code)	billable_equipment_hours
6127 	 , ROUND (
6128              NVL (
6129             DECODE (
6130                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6131 			  , '00'   , fact.sup_inv_committed_cost
6132 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (fact.end_date - fact.start_date + 1)
6133 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (fact.end_date - fact.start_date + 1)
6134 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.sup_inv_committed_cost / (fact.end_date - fact.start_date + 1)
6135 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.sup_inv_committed_cost / (fact.end_date - fact.start_date + 1)
6136 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (fact.end_date - fact.start_date + 1)
6137 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (fact.end_date - fact.start_date + 1)
6138 			  , '0-1'  , fact.sup_inv_committed_cost
6142 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6139 			  , '1-1'  , fact.sup_inv_committed_cost
6140 			  , 0  ) -- end decode
6141 			    , 0  ) -- end nvl
6143 						* PJI_UTILS.GET_MAU (fact.currency_code)	sup_inv_committed_cost
6144 	 , ROUND (
6145              NVL (
6146             DECODE (
6147                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6148 			  , '00'   , fact.po_committed_cost
6149 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (fact.end_date - fact.start_date + 1)
6150 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (fact.end_date - fact.start_date + 1)
6151 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.po_committed_cost / (fact.end_date - fact.start_date + 1)
6152 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.po_committed_cost / (fact.end_date - fact.start_date + 1)
6153 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (fact.end_date - fact.start_date + 1)
6154 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (fact.end_date - fact.start_date + 1)
6155 			  , '0-1'  , fact.po_committed_cost
6156 			  , '1-1'  , fact.po_committed_cost
6157 			  , 0  ) -- end decode
6158 			    , 0  ) -- end nvl
6159 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6160 						* PJI_UTILS.GET_MAU (fact.currency_code)	po_committed_cost
6161 	 , ROUND (
6162              NVL (
6163             DECODE (
6164                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6165 			  , '00'   , fact.pr_committed_cost
6166 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (fact.end_date - fact.start_date + 1)
6167 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (fact.end_date - fact.start_date + 1)
6168 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.pr_committed_cost / (fact.end_date - fact.start_date + 1)
6169 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.pr_committed_cost / (fact.end_date - fact.start_date + 1)
6170 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (fact.end_date - fact.start_date + 1)
6171 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (fact.end_date - fact.start_date + 1)
6172 			  , '0-1'  , fact.pr_committed_cost
6173 			  , '1-1'  , fact.pr_committed_cost
6174 			  , 0  ) -- end decode
6175 			    , 0  ) -- end nvl
6176 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6177 						* PJI_UTILS.GET_MAU (fact.currency_code)	pr_committed_cost
6178 	 , ROUND (
6179              NVL (
6180             DECODE (
6181                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6182 			  , '00'   , fact.oth_committed_cost
6183 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (fact.end_date - fact.start_date + 1)
6184 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (fact.end_date - fact.start_date + 1)
6185 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.oth_committed_cost / (fact.end_date - fact.start_date + 1)
6186 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.oth_committed_cost / (fact.end_date - fact.start_date + 1)
6187 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (fact.end_date - fact.start_date + 1)
6188 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (fact.end_date - fact.start_date + 1)
6189 			  , '0-1'  , fact.oth_committed_cost
6190 			  , '1-1'  , fact.oth_committed_cost
6191 			  , 0  ) -- end decode
6192 			    , 0  ) -- end nvl
6193 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6194 						* PJI_UTILS.GET_MAU (fact.currency_code)	oth_committed_cost
6195 	 , ROUND (
6196              NVL (
6197             DECODE (
6198                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6199 			  , '00'   , fact.ACT_LABOR_HRS
6200 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (fact.end_date - fact.start_date + 1)
6201 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (fact.end_date - fact.start_date + 1)
6202 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_LABOR_HRS / (fact.end_date - fact.start_date + 1)
6203 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_LABOR_HRS / (fact.end_date - fact.start_date + 1)
6204 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (fact.end_date - fact.start_date + 1)
6205 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (fact.end_date - fact.start_date + 1)
6206 			  , '0-1'  , fact.ACT_LABOR_HRS
6207 			  , '1-1'  , fact.ACT_LABOR_HRS
6208 			  , 0  ) -- end decode
6209 			    , 0  ) -- end nvl
6210 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6211 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_HRS
6212 	 , ROUND (
6213              NVL (
6214             DECODE (
6215                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6216 			  , '00'   , fact.ACT_EQUIP_HRS
6217 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
6218 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
6219 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
6220 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
6224 			  , '1-1'  , fact.ACT_EQUIP_HRS
6221 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
6222 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
6223 			  , '0-1'  , fact.ACT_EQUIP_HRS
6225 			  , 0  ) -- end decode
6226 			    , 0  ) -- end nvl
6227 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6228 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_HRS
6229 	 , ROUND (
6230              NVL (
6231             DECODE (
6232                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6233 			  , '00'   , fact.ACT_LABOR_BRDN_COST
6234 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
6235 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
6236 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
6237 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
6238 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
6239 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
6240 			  , '0-1'  , fact.ACT_LABOR_BRDN_COST
6241 			  , '1-1'  , fact.ACT_LABOR_BRDN_COST
6242 			  , 0  ) -- end decode
6243 			    , 0  ) -- end nvl
6244 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6245 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_BRDN_COST
6246 	 , ROUND (
6247              NVL (
6248             DECODE (
6249                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6250 			  , '00'   , fact.ACT_EQUIP_BRDN_COST
6251 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
6252 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
6253 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
6254 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
6255 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
6256 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
6257 			  , '0-1'  , fact.ACT_EQUIP_BRDN_COST
6258 			  , '1-1'  , fact.ACT_EQUIP_BRDN_COST
6259 			  , 0  ) -- end decode
6260 			    , 0  ) -- end nvl
6261 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6262 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_BRDN_COST
6263 	 , ROUND (
6264              NVL (
6265             DECODE (
6266                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6267 			  , '00'   , fact.ACT_BRDN_COST
6268 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (fact.end_date - fact.start_date + 1)
6269 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (fact.end_date - fact.start_date + 1)
6270 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_BRDN_COST / (fact.end_date - fact.start_date + 1)
6271 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_BRDN_COST / (fact.end_date - fact.start_date + 1)
6272 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (fact.end_date - fact.start_date + 1)
6273 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (fact.end_date - fact.start_date + 1)
6274 			  , '0-1'  , fact.ACT_BRDN_COST
6275 			  , '1-1'  , fact.ACT_BRDN_COST
6276 			  , 0  ) -- end decode
6277 			    , 0  ) -- end nvl
6278 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6279 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_BRDN_COST
6280 	 , ROUND (
6281              NVL (
6282             DECODE (
6283                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6284 			  , '00'   , fact.ACT_RAW_COST
6285 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (fact.end_date - fact.start_date + 1)
6286 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (fact.end_date - fact.start_date + 1)
6287 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_RAW_COST / (fact.end_date - fact.start_date + 1)
6288 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_RAW_COST / (fact.end_date - fact.start_date + 1)
6289 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (fact.end_date - fact.start_date + 1)
6290 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (fact.end_date - fact.start_date + 1)
6291 			  , '0-1'  , fact.ACT_RAW_COST
6292 			  , '1-1'  , fact.ACT_RAW_COST
6293 			  , 0  ) -- end decode
6294 			    , 0  ) -- end nvl
6295 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6296 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_RAW_COST
6297 	 , ROUND (
6298              NVL (
6299             DECODE (
6300                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6301 			  , '00'   , fact.ACT_REVENUE
6302 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (fact.end_date - fact.start_date + 1)
6306 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (fact.end_date - fact.start_date + 1)
6303 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (fact.end_date - fact.start_date + 1)
6304 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_REVENUE / (fact.end_date - fact.start_date + 1)
6305 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_REVENUE / (fact.end_date - fact.start_date + 1)
6307 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (fact.end_date - fact.start_date + 1)
6308 			  , '0-1'  , fact.ACT_REVENUE
6309 			  , '1-1'  , fact.ACT_REVENUE
6310 			  , 0  ) -- end decode
6311 			    , 0  ) -- end nvl
6312 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6313 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_REVENUE
6314 	 , ROUND (
6315              NVL (
6316             DECODE (
6317                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6318 			  , '00'   , fact.ACT_LABOR_RAW_COST
6319 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
6320 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
6321 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
6322 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
6323 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
6324 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
6325 			  , '0-1'  , fact.ACT_LABOR_RAW_COST
6326 			  , '1-1'  , fact.ACT_LABOR_RAW_COST
6327 			  , 0  ) -- end decode
6328 			    , 0  ) -- end nvl
6329 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6330 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_RAW_COST
6331 	 , ROUND (
6332              NVL (
6333             DECODE (
6334                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6335 			  , '00'   , fact.ACT_EQUIP_RAW_COST
6336 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
6337 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
6338 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
6339 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
6340 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
6341 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
6342 			  , '0-1'  , fact.ACT_EQUIP_RAW_COST
6343 			  , '1-1'  , fact.ACT_EQUIP_RAW_COST
6344 			  , 0  ) -- end decode
6345 			    , 0  ) -- end nvl
6346 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6347 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_RAW_COST
6348 	 , ROUND (
6349              NVL (
6350             DECODE (
6351                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6352 			  , '00'   , fact.ETC_LABOR_HRS
6353 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (fact.end_date - fact.start_date + 1)
6354 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (fact.end_date - fact.start_date + 1)
6355 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_LABOR_HRS / (fact.end_date - fact.start_date + 1)
6356 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_LABOR_HRS / (fact.end_date - fact.start_date + 1)
6357 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (fact.end_date - fact.start_date + 1)
6358 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (fact.end_date - fact.start_date + 1)
6359 			  , '0-1'  , fact.ETC_LABOR_HRS
6360 			  , '1-1'  , fact.ETC_LABOR_HRS
6361 			  , 0  ) -- end decode
6362 			    , 0  ) -- end nvl
6363 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6364 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_HRS
6365 	 , ROUND (
6366              NVL (
6367             DECODE (
6368                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6369 			  , '00'   , fact.ETC_EQUIP_HRS
6370 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
6371 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
6372 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
6373 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
6374 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
6375 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
6376 			  , '0-1'  , fact.ETC_EQUIP_HRS
6377 			  , '1-1'  , fact.ETC_EQUIP_HRS
6378 			  , 0  ) -- end decode
6379 			    , 0  ) -- end nvl
6380 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6384             DECODE (
6381 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_HRS
6382 	 , ROUND (
6383              NVL (
6385                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6386 			  , '00'   , fact.ETC_LABOR_BRDN_COST
6387 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
6388 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
6389 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
6390 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
6391 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
6392 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
6393 			  , '0-1'  , fact.ETC_LABOR_BRDN_COST
6394 			  , '1-1'  , fact.ETC_LABOR_BRDN_COST
6395 			  , 0  ) -- end decode
6396 			    , 0  ) -- end nvl
6397 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6398 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_BRDN_COST
6399 	 , ROUND (
6400              NVL (
6401             DECODE (
6402                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6403 			  , '00'   , fact.ETC_EQUIP_BRDN_COST
6404 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
6405 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
6406 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
6407 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
6408 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
6409 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
6410 			  , '0-1'  , fact.ETC_EQUIP_BRDN_COST
6411 			  , '1-1'  , fact.ETC_EQUIP_BRDN_COST
6412 			  , 0  ) -- end decode
6413 			    , 0  ) -- end nvl
6414 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6415 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_BRDN_COST
6416 	 , ROUND (
6417              NVL (
6418             DECODE (
6419                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6420 			  , '00'   , fact.ETC_BRDN_COST
6421 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (fact.end_date - fact.start_date + 1)
6422 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (fact.end_date - fact.start_date + 1)
6423 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_BRDN_COST / (fact.end_date - fact.start_date + 1)
6424 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_BRDN_COST / (fact.end_date - fact.start_date + 1)
6425 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (fact.end_date - fact.start_date + 1)
6426 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (fact.end_date - fact.start_date + 1)
6427 			  , '0-1'  , fact.ETC_BRDN_COST
6428 			  , '1-1'  , fact.ETC_BRDN_COST
6429 			  , 0  ) -- end decode
6430 			    , 0  ) -- end nvl
6431 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6432 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_BRDN_COST
6433 	 , ROUND (
6434              NVL (
6435             DECODE (
6436                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6437 			  , '00'   , fact.ETC_RAW_COST
6438 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (fact.end_date - fact.start_date + 1)
6439 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (fact.end_date - fact.start_date + 1)
6440 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_RAW_COST / (fact.end_date - fact.start_date + 1)
6441 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_RAW_COST / (fact.end_date - fact.start_date + 1)
6442 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (fact.end_date - fact.start_date + 1)
6443 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (fact.end_date - fact.start_date + 1)
6444 			  , '0-1'  , fact.ETC_RAW_COST
6445 			  , '1-1'  , fact.ETC_RAW_COST
6446 			  , 0  ) -- end decode
6447 			    , 0  ) -- end nvl
6448 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6449 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_RAW_COST
6450 	 , ROUND (
6451              NVL (
6452             DECODE (
6453                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6454 			  , '00'   , fact.ETC_LABOR_RAW_COST
6455 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
6456 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
6457 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
6458 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
6462 			  , '1-1'  , fact.ETC_LABOR_RAW_COST
6459 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
6460 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
6461 			  , '0-1'  , fact.ETC_LABOR_RAW_COST
6463 			  , 0  ) -- end decode
6464 			    , 0  ) -- end nvl
6465 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6466 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_RAW_COST
6467 	 , ROUND (
6468              NVL (
6469             DECODE (
6470                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6471 			  , '00'   , fact.ETC_EQUIP_RAW_COST
6472 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
6473 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
6474 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
6475 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
6476 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
6477 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
6478 			  , '0-1'  , fact.ETC_EQUIP_RAW_COST
6479 			  , '1-1'  , fact.ETC_EQUIP_RAW_COST
6480 			  , 0  ) -- end decode
6481 			    , 0  ) -- end nvl
6482 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6483 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_RAW_COST
6484 	 , ROUND (
6485              NVL (
6486             DECODE (
6487                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6488 			  , '00'   , fact.custom1
6489 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (fact.end_date - fact.start_date + 1)
6490 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (fact.end_date - fact.start_date + 1)
6491 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom1 / (fact.end_date - fact.start_date + 1)
6492 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom1 / (fact.end_date - fact.start_date + 1)
6493 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom1 / (fact.end_date - fact.start_date + 1)
6494 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom1 / (fact.end_date - fact.start_date + 1)
6495 			  , '0-1'  , fact.custom1
6496 			  , '1-1'  , fact.custom1
6497 			  , 0  ) -- end decode
6498 			    , 0  ) -- end nvl
6499 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6500 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom1
6501 	 , ROUND (
6502              NVL (
6503             DECODE (
6504                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6505 			  , '00'   , fact.custom2
6506 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (fact.end_date - fact.start_date + 1)
6507 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (fact.end_date - fact.start_date + 1)
6508 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom2 / (fact.end_date - fact.start_date + 1)
6509 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom2 / (fact.end_date - fact.start_date + 1)
6510 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom2 / (fact.end_date - fact.start_date + 1)
6511 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom2 / (fact.end_date - fact.start_date + 1)
6512 			  , '0-1'  , fact.custom2
6513 			  , '1-1'  , fact.custom2
6514 			  , 0  ) -- end decode
6515 			    , 0  ) -- end nvl
6516 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6517 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom2
6518 	 , ROUND (
6519              NVL (
6520             DECODE (
6521                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6522 			  , '00'   , fact.custom3
6523 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (fact.end_date - fact.start_date + 1)
6524 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (fact.end_date - fact.start_date + 1)
6525 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom3 / (fact.end_date - fact.start_date + 1)
6526 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom3 / (fact.end_date - fact.start_date + 1)
6527 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom3 / (fact.end_date - fact.start_date + 1)
6528 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom3 / (fact.end_date - fact.start_date + 1)
6529 			  , '0-1'  , fact.custom3
6530 			  , '1-1'  , fact.custom3
6531 			  , 0  ) -- end decode
6532 			    , 0  ) -- end nvl
6533 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6534 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom3
6535 	 , ROUND (
6536              NVL (
6537             DECODE (
6538                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6539 			  , '00'   , fact.custom4
6540 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (fact.end_date - fact.start_date + 1)
6541 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (fact.end_date - fact.start_date + 1)
6542 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom4 / (fact.end_date - fact.start_date + 1)
6543 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom4 / (fact.end_date - fact.start_date + 1)
6544 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom4 / (fact.end_date - fact.start_date + 1)
6548 			  , 0  ) -- end decode
6545 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom4 / (fact.end_date - fact.start_date + 1)
6546 			  , '0-1'  , fact.custom4
6547 			  , '1-1'  , fact.custom4
6549 			    , 0  ) -- end nvl
6550 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6551 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom4
6552 	 , ROUND (
6553              NVL (
6554             DECODE (
6555                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6556 			  , '00'   , fact.custom5
6557 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (fact.end_date - fact.start_date + 1)
6558 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (fact.end_date - fact.start_date + 1)
6559 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom5 / (fact.end_date - fact.start_date + 1)
6560 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom5 / (fact.end_date - fact.start_date + 1)
6561 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom5 / (fact.end_date - fact.start_date + 1)
6562 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom5 / (fact.end_date - fact.start_date + 1)
6563 			  , '0-1'  , fact.custom5
6564 			  , '1-1'  , fact.custom5
6565 			  , 0  ) -- end decode
6566 			    , 0  ) -- end nvl
6567 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6568 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom5
6569 	 , ROUND (
6570              NVL (
6571             DECODE (
6572                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6573 			  , '00'   , fact.custom6
6574 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (fact.end_date - fact.start_date + 1)
6575 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (fact.end_date - fact.start_date + 1)
6576 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom6 / (fact.end_date - fact.start_date + 1)
6577 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom6 / (fact.end_date - fact.start_date + 1)
6578 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom6 / (fact.end_date - fact.start_date + 1)
6579 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom6 / (fact.end_date - fact.start_date + 1)
6580 			  , '0-1'  , fact.custom6
6581 			  , '1-1'  , fact.custom6
6582 			  , 0  ) -- end decode
6583 			    , 0  ) -- end nvl
6584 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6585 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom6
6586 	 , ROUND (
6587              NVL (
6588             DECODE (
6589                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6590 			  , '00'   , fact.custom7
6591 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (fact.end_date - fact.start_date + 1)
6592 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (fact.end_date - fact.start_date + 1)
6593 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom7 / (fact.end_date - fact.start_date + 1)
6594 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom7 / (fact.end_date - fact.start_date + 1)
6595 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom7 / (fact.end_date - fact.start_date + 1)
6596 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom7 / (fact.end_date - fact.start_date + 1)
6597 			  , '0-1'  , fact.custom7
6598 			  , '1-1'  , fact.custom7
6599 			  , 0  ) -- end decode
6600 			    , 0  ) -- end nvl
6601 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6602 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom7
6603 	 , ROUND (
6604              NVL (
6605             DECODE (
6606                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6607 			  , '00'   , fact.custom8
6608 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (fact.end_date - fact.start_date + 1)
6609 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (fact.end_date - fact.start_date + 1)
6610 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom8 / (fact.end_date - fact.start_date + 1)
6611 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom8 / (fact.end_date - fact.start_date + 1)
6612 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom8 / (fact.end_date - fact.start_date + 1)
6613 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom8 / (fact.end_date - fact.start_date + 1)
6614 			  , '0-1'  , fact.custom8
6615 			  , '1-1'  , fact.custom8
6616 			  , 0  ) -- end decode
6617 			    , 0  ) -- end nvl
6618 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6619 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom8
6620 	 , ROUND (
6621              NVL (
6622             DECODE (
6623                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6624 			  , '00'   , fact.custom9
6625 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (fact.end_date - fact.start_date + 1)
6626 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (fact.end_date - fact.start_date + 1)
6627 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom9 / (fact.end_date - fact.start_date + 1)
6628 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom9 / (fact.end_date - fact.start_date + 1)
6629 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom9 / (fact.end_date - fact.start_date + 1)
6633 			  , 0  ) -- end decode
6630 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom9 / (fact.end_date - fact.start_date + 1)
6631 			  , '0-1'  , fact.custom9
6632 			  , '1-1'  , fact.custom9
6634 			    , 0  ) -- end nvl
6635 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6636 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom9
6637 	 , ROUND (
6638              NVL (
6639             DECODE (
6640                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6641 			  , '00'   , fact.custom10
6642 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (fact.end_date - fact.start_date + 1)
6643 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (fact.end_date - fact.start_date + 1)
6644 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom10 / (fact.end_date - fact.start_date + 1)
6645 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom10 / (fact.end_date - fact.start_date + 1)
6646 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom10 / (fact.end_date - fact.start_date + 1)
6647 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom10 / (fact.end_date - fact.start_date + 1)
6648 			  , '0-1'  , fact.custom10
6649 			  , '1-1'  , fact.custom10
6650 			  , 0  ) -- end decode
6651 			    , 0  ) -- end nvl
6652 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6653 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom10
6654 	 , ROUND (
6655              NVL (
6656             DECODE (
6657                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6658 			  , '00'   , fact.custom11
6659 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (fact.end_date - fact.start_date + 1)
6660 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (fact.end_date - fact.start_date + 1)
6661 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom11 / (fact.end_date - fact.start_date + 1)
6662 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom11 / (fact.end_date - fact.start_date + 1)
6663 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom11 / (fact.end_date - fact.start_date + 1)
6664 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom11 / (fact.end_date - fact.start_date + 1)
6665 			  , '0-1'  , fact.custom11
6666 			  , '1-1'  , fact.custom11
6667 			  , 0  ) -- end decode
6668 			    , 0  ) -- end nvl
6669 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6670 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom11
6671 	 , ROUND (
6672              NVL (
6673             DECODE (
6674                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6675 			  , '00'   , fact.custom12
6676 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (fact.end_date - fact.start_date + 1)
6677 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (fact.end_date - fact.start_date + 1)
6678 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom12 / (fact.end_date - fact.start_date + 1)
6679 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom12 / (fact.end_date - fact.start_date + 1)
6680 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom12 / (fact.end_date - fact.start_date + 1)
6681 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom12 / (fact.end_date - fact.start_date + 1)
6682 			  , '0-1'  , fact.custom12
6683 			  , '1-1'  , fact.custom12
6684 			  , 0  ) -- end decode
6685 			    , 0  ) -- end nvl
6686 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6687 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom12
6688 	 , ROUND (
6689              NVL (
6690             DECODE (
6691                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6692 			  , '00'   , fact.custom13
6693 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (fact.end_date - fact.start_date + 1)
6694 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (fact.end_date - fact.start_date + 1)
6695 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom13 / (fact.end_date - fact.start_date + 1)
6696 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom13 / (fact.end_date - fact.start_date + 1)
6697 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom13 / (fact.end_date - fact.start_date + 1)
6698 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom13 / (fact.end_date - fact.start_date + 1)
6699 			  , '0-1'  , fact.custom13
6700 			  , '1-1'  , fact.custom13
6701 			  , 0  ) -- end decode
6702 			    , 0  ) -- end nvl
6703 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6704 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom13
6705 	 , ROUND (
6706              NVL (
6707             DECODE (
6708                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6709 			  , '00'   , fact.custom14
6710 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (fact.end_date - fact.start_date + 1)
6711 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (fact.end_date - fact.start_date + 1)
6712 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom14 / (fact.end_date - fact.start_date + 1)
6713 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom14 / (fact.end_date - fact.start_date + 1)
6714 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom14 / (fact.end_date - fact.start_date + 1)
6715 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom14 / (fact.end_date - fact.start_date + 1)
6716 			  , '0-1'  , fact.custom14
6720 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6717 			  , '1-1'  , fact.custom14
6718 			  , 0  ) -- end decode
6719 			    , 0  ) -- end nvl
6721 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom14
6722 	 , ROUND (
6723              NVL (
6724             DECODE (
6725                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
6726 			  , '00'   , fact.custom15
6727 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (fact.end_date - fact.start_date + 1)
6728 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (fact.end_date - fact.start_date + 1)
6729 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom15 / (fact.end_date - fact.start_date + 1)
6730 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom15 / (fact.end_date - fact.start_date + 1)
6731 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom15 / (fact.end_date - fact.start_date + 1)
6732 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom15 / (fact.end_date - fact.start_date + 1)
6733 			  , '0-1'  , fact.custom15
6734 			  , '1-1'  , fact.custom15
6735 			  , 0  ) -- end decode
6736 			    , 0  ) -- end nvl
6737 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
6738 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom15
6739        , 'CN'   line_type
6740 	 , fact.time_dangling_flag time_dangling_flag
6741 	 , fact.rate_dangling_flag rate_dangling_flag
6742        , g_default_prg_level prg_level
6743    FROM   pji_fp_aggr_pjp1_t fact
6744         , pji_time_ent_period  pa_cal
6745         , pji_fm_extr_plnver3_t  ver
6746    WHERE  1=1
6747       AND fact.CALENDAR_TYPE = 'A'
6748       AND fact.worker_id = g_worker_id
6749       AND fact.start_date IS NOT NULL
6750       AND fact.end_date IS NOT NULL
6751 	AND fact.time_dangling_flag IS NULL
6752 	AND fact.rate_dangling_flag IS NULL
6753       AND (
6754 	       (     pa_cal.start_date >= fact.start_date
6755                AND pa_cal.end_date <= fact.end_date ) -- fsps,pefe
6756 	    OR (     pa_cal.start_date <= fact.start_date
6757                AND pa_cal.end_date >= fact.end_date ) -- psfs,fepe
6758 	    OR (     pa_cal.start_date <= fact.start_date
6759                AND pa_cal.end_date <= fact.end_date
6760                AND pa_cal.end_date >= fact.start_date ) -- psfspefe
6761 	    OR (     pa_cal.start_date >= fact.start_date
6762                AND pa_cal.end_date >= fact.end_date
6763                AND pa_cal.start_date <= fact.end_date )  -- fspsfepe
6764           )
6765       AND fact.line_type = 'NTP'
6766       AND fact.period_type_id = 2048
6767       AND fact.plan_version_id = ver.plan_version_id
6768       AND ver.wp_flag = 'N'
6769       AND ver.baselined_flag = 'Y'
6770       AND ver.time_phased_type_code = 'N'
6771 	-- AND ( ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
6772       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
6773 	  ) a
6774 	  GROUP BY
6775 	   a.PROJECT_ID
6776      , a.PROJECT_ORG_ID
6777      , a.PROJECT_ORGANIZATION_ID
6778      , a.PROJECT_ELEMENT_ID
6779      , a.TIME_ID
6780      , a.PERIOD_TYPE_ID
6781      , a.CALENDAR_TYPE
6782      , a.RBS_AGGR_LEVEL
6783      , a.WBS_ROLLUP_FLAG
6784      , a.PRG_ROLLUP_FLAG
6785      , a.CURR_RECORD_TYPE_ID
6786      , a.CURRENCY_CODE
6787      , a.RBS_ELEMENT_ID
6788      , a.RBS_VERSION_ID
6789      , a.PLAN_VERSION_ID
6790      , a.PLAN_TYPE_ID
6791 	 , a.LINE_TYPE
6792 	 , a.TIME_DANGLING_FLAG
6793 	 , a.RATE_DANGLING_FLAG;
6794  End of 4005006*/
6795 
6796     INSERT INTO pji_fp_aggr_pjp1_t   -- Non time phased entries in pjp1 table.
6797     (
6798        WORKER_ID
6799      , PROJECT_ID
6800      , PROJECT_ORG_ID
6801      , PROJECT_ORGANIZATION_ID
6802      , PROJECT_ELEMENT_ID
6803      , TIME_ID
6804      , PERIOD_TYPE_ID
6805      , CALENDAR_TYPE
6806      , RBS_AGGR_LEVEL
6807      , WBS_ROLLUP_FLAG
6808      , PRG_ROLLUP_FLAG
6809      , CURR_RECORD_TYPE_ID
6810      , CURRENCY_CODE
6811      , RBS_ELEMENT_ID
6812      , RBS_VERSION_ID
6813      , PLAN_VERSION_ID
6814      , PLAN_TYPE_ID
6815      , RAW_COST
6816      , BRDN_COST
6817      , REVENUE
6818      , BILL_RAW_COST
6819      , BILL_BRDN_COST
6820      , BILL_LABOR_RAW_COST
6821      , BILL_LABOR_BRDN_COST
6822      , BILL_LABOR_HRS
6823      , EQUIPMENT_RAW_COST
6824      , EQUIPMENT_BRDN_COST
6825      , CAPITALIZABLE_RAW_COST
6826      , CAPITALIZABLE_BRDN_COST
6827      , LABOR_RAW_COST
6828      , LABOR_BRDN_COST
6829      , LABOR_HRS
6830      , LABOR_REVENUE
6831      , EQUIPMENT_HOURS
6832      , BILLABLE_EQUIPMENT_HOURS
6833      , SUP_INV_COMMITTED_COST
6834      , PO_COMMITTED_COST
6835      , PR_COMMITTED_COST
6836      , OTH_COMMITTED_COST
6837      , ACT_LABOR_HRS
6838      , ACT_EQUIP_HRS
6839      , ACT_LABOR_BRDN_COST
6840      , ACT_EQUIP_BRDN_COST
6841      , ACT_BRDN_COST
6842      , ACT_RAW_COST
6843      , ACT_REVENUE
6844      , ACT_LABOR_RAW_COST
6845      , ACT_EQUIP_RAW_COST
6846      , ETC_LABOR_HRS
6847      , ETC_EQUIP_HRS
6848      , ETC_LABOR_BRDN_COST
6849      , ETC_EQUIP_BRDN_COST
6850      , ETC_BRDN_COST
6851      , ETC_RAW_COST
6852      , ETC_LABOR_RAW_COST
6853      , ETC_EQUIP_RAW_COST
6854      , CUSTOM1
6855      , CUSTOM2
6856      , CUSTOM3
6857      , CUSTOM4
6858      , CUSTOM5
6859      , CUSTOM6
6863      , CUSTOM10
6860      , CUSTOM7
6861      , CUSTOM8
6862      , CUSTOM9
6864      , CUSTOM11
6865      , CUSTOM12
6866      , CUSTOM13
6867      , CUSTOM14
6868      , CUSTOM15
6869      , TIME_DANGLING_FLAG
6870      , RATE_DANGLING_FLAG
6871      , PRG_LEVEL
6872      , PLAN_TYPE_CODE    /* 4471527 */
6873    )
6874    SELECT
6875            g_worker_id worker_id
6876          , a.PROJECT_ID
6877          , a.PROJECT_ORG_ID
6878          , a.PROJECT_ORGANIZATION_ID
6879          , a.PROJECT_ELEMENT_ID
6880          , a.TIME_ID
6881          , 32 -- a.PERIOD_TYPE_ID
6882          , a.CALENDAR_TYPE
6883          , a.RBS_AGGR_LEVEL
6884          , a.WBS_ROLLUP_FLAG
6885          , a.PRG_ROLLUP_FLAG
6886          , a.CURR_RECORD_TYPE_ID
6887          , a.CURRENCY_CODE
6888          , a.RBS_ELEMENT_ID
6889          , a.RBS_VERSION_ID
6890          , a.PLAN_VERSION_ID
6891          , a.PLAN_TYPE_ID
6892 	 , SUM(ROUND (nvl(a.raw_cost,0)*a.factor/a.mau)*a.mau) raw_cost
6893 	 , SUM(ROUND (nvl(a.brdn_cost,0)*a.factor/a.mau)*a.mau) brdn_cost
6894 	 , SUM(ROUND (nvl(a.revenue,0)*a.factor/a.mau)*a.mau) revenue
6895 	 , SUM(ROUND (nvl(a.bill_raw_cost,0)*a.factor/a.mau)*a.mau) bill_raw_cost
6896 	 , SUM(ROUND (nvl(a.bill_brdn_cost,0)*a.factor/a.mau)*a.mau) bill_brdn_cost
6897 	 , SUM(ROUND (nvl(a.bill_labor_raw_cost,0)*a.factor/a.mau)*a.mau) bill_labor_raw_cost
6898 	 , SUM(ROUND (nvl(a.bill_labor_brdn_cost,0)*a.factor/a.mau)*a.mau) bill_labor_brdn_cost
6899 	 , SUM(ROUND (nvl(a.bill_labor_hrs,0)*a.factor/a.mau)*a.mau) bill_labor_hrs
6900 	 , SUM(ROUND (nvl(a.equipment_raw_cost,0)*a.factor/a.mau)*a.mau) equipment_raw_cost
6901 	 , SUM(ROUND (nvl(a.equipment_brdn_cost,0)*a.factor/a.mau)*a.mau) equipment_brdn_cost
6902 	 , SUM(ROUND (nvl(a.capitalizable_raw_cost,0)*a.factor/a.mau)*a.mau) capitalizable_raw_cost
6903 	 , SUM(ROUND (nvl(a.capitalizable_brdn_cost,0)*a.factor/a.mau)*a.mau) capitalizable_brdn_cost
6904 	 , SUM(ROUND (nvl(a.labor_raw_cost,0)*a.factor/a.mau)*a.mau) labor_raw_cost
6905 	 , SUM(ROUND (nvl(a.labor_brdn_cost,0)*a.factor/a.mau)*a.mau) labor_brdn_cost
6906 	 , SUM(ROUND (nvl(a.labor_hrs,0)*a.factor/a.mau)*a.mau) labor_hrs
6907 	 , SUM(ROUND (nvl(a.labor_revenue,0)*a.factor/a.mau)*a.mau) labor_revenue
6908 	 , SUM(ROUND (nvl(a.equipment_hours,0)*a.factor/a.mau)*a.mau) equipment_hours
6909 	 , SUM(ROUND (nvl(a.billable_equipment_hours,0)*a.factor/a.mau)*a.mau) billable_equipment_hours
6910 	 , SUM(ROUND (nvl(a.sup_inv_committed_cost,0)*a.factor/a.mau)*a.mau) sup_inv_committed_cost
6911 	 , SUM(ROUND (nvl(a.po_committed_cost,0)*a.factor/a.mau)*a.mau) po_committed_cost
6912 	 , SUM(ROUND (nvl(a.pr_committed_cost,0)*a.factor/a.mau)*a.mau) pr_committed_cost
6913 	 , SUM(ROUND (nvl(a.oth_committed_cost,0)*a.factor/a.mau)*a.mau) oth_committed_cost
6914 	 , SUM(ROUND (nvl(a.ACT_LABOR_HRS,0)*a.factor/a.mau)*a.mau) ACT_LABOR_HRS
6915 	 , SUM(ROUND (nvl(a.ACT_EQUIP_HRS,0)*a.factor/a.mau)*a.mau) ACT_EQUIP_HRS
6916 	 , SUM(ROUND (nvl(a.ACT_LABOR_BRDN_COST,0)*a.factor/a.mau)*a.mau) ACT_LABOR_BRDN_COST
6917 	 , SUM(ROUND (nvl(a.ACT_EQUIP_BRDN_COST,0)*a.factor/a.mau)*a.mau) ACT_EQUIP_BRDN_COST
6918 	 , SUM(ROUND (nvl(a.ACT_BRDN_COST,0)*a.factor/a.mau)*a.mau) ACT_BRDN_COST
6919 	 , SUM(ROUND (nvl(a.ACT_RAW_COST,0)*a.factor/a.mau)*a.mau) ACT_RAW_COST
6920 	 , SUM(ROUND (nvl(a.ACT_REVENUE,0)*a.factor/a.mau)*a.mau) ACT_REVENUE
6921 	 , SUM(ROUND (nvl(a.ACT_LABOR_RAW_COST,0)*a.factor/a.mau)*a.mau) ACT_LABOR_RAW_COST
6922 	 , SUM(ROUND (nvl(a.ACT_EQUIP_RAW_COST,0)*a.factor/a.mau)*a.mau) ACT_EQUIP_RAW_COST
6923 	 , SUM(ROUND (nvl(a.ETC_LABOR_HRS,0)*a.factor/a.mau)*a.mau) ETC_LABOR_HRS
6924 	 , SUM(ROUND (nvl(a.ETC_EQUIP_HRS,0)*a.factor/a.mau)*a.mau) ETC_EQUIP_HRS
6925 	 , SUM(ROUND (nvl(a.ETC_LABOR_BRDN_COST,0)*a.factor/a.mau)*a.mau) ETC_LABOR_BRDN_COST
6926 	 , SUM(ROUND (nvl(a.ETC_EQUIP_BRDN_COST,0)*a.factor/a.mau)*a.mau) ETC_EQUIP_BRDN_COST
6927 	 , SUM(ROUND (nvl(a.ETC_BRDN_COST,0)*a.factor/a.mau)*a.mau) ETC_BRDN_COST
6928 	 , SUM(ROUND (nvl(a.ETC_RAW_COST,0)*a.factor/a.mau)*a.mau) ETC_RAW_COST
6929 	 , SUM(ROUND (nvl(a.ETC_LABOR_RAW_COST,0)*a.factor/a.mau)*a.mau) ETC_LABOR_RAW_COST
6930 	 , SUM(ROUND (nvl(a.ETC_EQUIP_RAW_COST,0)*a.factor/a.mau)*a.mau) ETC_EQUIP_RAW_COST
6931 	 , SUM(ROUND (nvl(a.custom1,0)*a.factor/a.mau)*a.mau) custom1
6932 	 , SUM(ROUND (nvl(a.custom2,0)*a.factor/a.mau)*a.mau) custom2
6933 	 , SUM(ROUND (nvl(a.custom3,0)*a.factor/a.mau)*a.mau) custom3
6934 	 , SUM(ROUND (nvl(a.custom4,0)*a.factor/a.mau)*a.mau) custom4
6935 	 , SUM(ROUND (nvl(a.custom5,0)*a.factor/a.mau)*a.mau) custom5
6936 	 , SUM(ROUND (nvl(a.custom6,0)*a.factor/a.mau)*a.mau) custom6
6937 	 , SUM(ROUND (nvl(a.custom7,0)*a.factor/a.mau)*a.mau) custom7
6938 	 , SUM(ROUND (nvl(a.custom8,0)*a.factor/a.mau)*a.mau) custom8
6939 	 , SUM(ROUND (nvl(a.custom9,0)*a.factor/a.mau)*a.mau) custom9
6940 	 , SUM(ROUND (nvl(a.custom10,0)*a.factor/a.mau)*a.mau) custom10
6941 	 , SUM(ROUND (nvl(a.custom11,0)*a.factor/a.mau)*a.mau) custom11
6942 	 , SUM(ROUND (nvl(a.custom12,0)*a.factor/a.mau)*a.mau) custom12
6943 	 , SUM(ROUND (nvl(a.custom13,0)*a.factor/a.mau)*a.mau) custom13
6944 	 , SUM(ROUND (nvl(a.custom14,0)*a.factor/a.mau)*a.mau) custom14
6945 	 , SUM(ROUND (nvl(a.custom15,0)*a.factor/a.mau)*a.mau) custom15
6946          , a.TIME_DANGLING_FLAG
6947          , a.RATE_DANGLING_FLAG
6948          , g_default_prg_level prg_level
6949          , a.plan_type_code plan_type_code    /* 4471527   */
6950    FROM (
6951    SELECT /*+ NO_MERGE */
6952            fact.project_id  project_id
6953    	 , fact.project_ORG_ID project_ORG_ID
6954    	 , fact.project_ORGANIZATION_ID project_ORGANIZATION_ID
6955    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
6956    	 , entCal.ent_period_id TIME_ID
6957    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
6958    	 , 'E' CALENDAR_TYPE -- fact.CALENDAR_TYPE
6959          , fact.RBS_AGGR_LEVEL
6960          , fact.WBS_ROLLUP_FLAG
6964    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
6961          , fact.PRG_ROLLUP_FLAG
6962    	 , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
6963    	 , fact.CURRENCY_CODE CURRENCY_CODE
6965    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
6966    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
6967 	 , fact.PLAN_TYPE_ID  PLAN_TYPE_ID
6968 	 , fact.raw_cost
6969 	 , fact.brdn_cost
6970 	 , fact.revenue
6971 	 , fact.bill_raw_cost
6972 	 , fact.bill_brdn_cost
6973 	 , fact.bill_labor_raw_cost
6974 	 , fact.bill_labor_brdn_cost
6975 	 , fact.bill_labor_hrs
6976 	 , fact.equipment_raw_cost
6977 	 , fact.equipment_brdn_cost
6978 	 , fact.capitalizable_raw_cost
6979 	 , fact.capitalizable_brdn_cost
6980 	 , fact.labor_raw_cost
6981 	 , fact.labor_brdn_cost
6982 	 , fact.labor_hrs
6983 	 , fact.labor_revenue
6984 	 , fact.equipment_hours
6985 	 , fact.billable_equipment_hours
6986 	 , fact.sup_inv_committed_cost
6987 	 , fact.po_committed_cost
6988 	 , fact.pr_committed_cost
6989 	 , fact.oth_committed_cost
6990 	 , fact.ACT_LABOR_HRS
6991 	 , fact.ACT_EQUIP_HRS
6992 	 , fact.ACT_LABOR_BRDN_COST
6993 	 , fact.ACT_EQUIP_BRDN_COST
6994 	 , fact.ACT_BRDN_COST
6995 	 , fact.ACT_RAW_COST
6996 	 , fact.ACT_REVENUE
6997 	 , fact.ACT_LABOR_RAW_COST
6998 	 , fact.ACT_EQUIP_RAW_COST
6999 	 , fact.ETC_LABOR_HRS
7000 	 , fact.ETC_EQUIP_HRS
7001 	 , fact.ETC_LABOR_BRDN_COST
7002 	 , fact.ETC_EQUIP_BRDN_COST
7003 	 , fact.ETC_BRDN_COST
7004 	 , fact.ETC_RAW_COST
7005 	 , fact.ETC_LABOR_RAW_COST
7006 	 , fact.ETC_EQUIP_RAW_COST
7007 	 , fact.custom1
7008 	 , fact.custom2
7009 	 , fact.custom3
7010 	 , fact.custom4
7011 	 , fact.custom5
7012 	 , fact.custom6
7013 	 , fact.custom7
7014 	 , fact.custom8
7015 	 , fact.custom9
7016 	 , fact.custom10
7017 	 , fact.custom11
7018 	 , fact.custom12
7019 	 , fact.custom13
7020 	 , fact.custom14
7021 	 , fact.custom15
7022 	 , fact.time_dangling_flag time_dangling_flag
7023 	 , fact.rate_dangling_flag rate_dangling_flag
7024          , cur.mau mau
7025          , (LEAST(fact.end_date,entCal.end_date) - Greatest(fact.start_date,entCal.start_date)+1)
7026                               / (fact.end_date - fact.start_date+1) factor
7027          , fact.plan_type_code   plan_type_code     /* 4471527 */
7028    FROM   pji_fp_aggr_pjp1_t fact
7029         , pji_time_ent_period_v  entCal
7030         , pji_fm_extr_plnver3_t  ver
7031         , (SELECT currency_code,
7032                    decode(nvl(MINIMUM_ACCOUNTABLE_UNIT, power(10, (-1 * PRECISION))),
7033                       null, 0.01,
7034                          0, 1,
7035                          nvl(MINIMUM_ACCOUNTABLE_UNIT, power(10, (-1 * PRECISION)))) mau
7036               FROM FND_CURRENCIES) cur
7037    WHERE  1=1
7038       AND fact.CALENDAR_TYPE = 'A'
7039       AND fact.worker_id = g_worker_id
7040       AND fact.start_date IS NOT NULL
7041       AND fact.end_date IS NOT NULL
7042       AND fact.time_dangling_flag IS NULL
7043       AND fact.rate_dangling_flag IS NULL
7044       AND fact.line_type = 'NTP'
7045       AND fact.period_type_id = 2048
7046       AND fact.plan_version_id = ver.plan_version_id
7047       AND fact.plan_type_code = ver.plan_type_code    /* 4471527 */
7048       AND ver.wp_flag = 'N'
7049       AND ver.baselined_flag = 'Y'
7050       AND ver.time_phased_type_code = 'N'
7051       -- AND ( ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
7052       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
7053       AND cur.currency_code = fact.currency_code
7054       AND ( fact.start_date <= entCal.end_date AND fact.end_date >= entCal.start_date )
7055 	  ) a
7056    WHERE a.factor>0
7057   GROUP BY
7058        a.PROJECT_ID
7059      , a.PROJECT_ORG_ID
7060      , a.PROJECT_ORGANIZATION_ID
7061      , a.PROJECT_ELEMENT_ID
7062      , a.TIME_ID
7063      , a.PERIOD_TYPE_ID
7064      , a.CALENDAR_TYPE
7065      , a.RBS_AGGR_LEVEL
7066      , a.WBS_ROLLUP_FLAG
7067      , a.PRG_ROLLUP_FLAG
7068      , a.CURR_RECORD_TYPE_ID
7069      , a.CURRENCY_CODE
7070      , a.RBS_ELEMENT_ID
7071      , a.RBS_VERSION_ID
7072      , a.PLAN_VERSION_ID
7073      , a.PLAN_TYPE_ID
7074      , a.PLAN_TYPE_CODE   /* 4471527   */
7075      , a.TIME_DANGLING_FLAG
7076      , a.RATE_DANGLING_FLAG;
7077 
7078 EXCEPTION
7079   WHEN OTHERS THEN
7080     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
7081                              p_procedure_name => ' PRORATE_TO_ENT_N_PJP1_D ');
7082     RAISE;
7083 END;
7084 
7085 
7086 PROCEDURE PRORATE_TO_ENT_PG_PJP1_SE( p_prorating_format varchar2) IS
7087 BEGIN
7088 
7089     -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
7090 
7091 /* Commented for bug 4005006
7092     INSERT INTO pji_fp_aggr_pjp1_t   -- PA, GL calendar entries.
7093     (
7094        WORKER_ID
7095      , PROJECT_ID
7096      , PROJECT_ORG_ID
7097      , PROJECT_ORGANIZATION_ID
7098      -- , PARTITION_ID
7099      , PROJECT_ELEMENT_ID
7100      , TIME_ID
7101      , PERIOD_TYPE_ID
7102      , CALENDAR_TYPE
7103      , RBS_AGGR_LEVEL
7104      , WBS_ROLLUP_FLAG
7105      , PRG_ROLLUP_FLAG
7106      , CURR_RECORD_TYPE_ID
7107      , CURRENCY_CODE
7108      , RBS_ELEMENT_ID
7109      , RBS_VERSION_ID
7110      , PLAN_VERSION_ID
7111      , PLAN_TYPE_ID
7112      , RAW_COST
7113      , BRDN_COST
7114      , REVENUE
7115      , BILL_RAW_COST
7119      , BILL_LABOR_HRS
7116      , BILL_BRDN_COST
7117      , BILL_LABOR_RAW_COST
7118      , BILL_LABOR_BRDN_COST
7120      , EQUIPMENT_RAW_COST
7121      , EQUIPMENT_BRDN_COST
7122      , CAPITALIZABLE_RAW_COST
7123      , CAPITALIZABLE_BRDN_COST
7124      , LABOR_RAW_COST
7125      , LABOR_BRDN_COST
7126      , LABOR_HRS
7127      , LABOR_REVENUE
7128      , EQUIPMENT_HOURS
7129      , BILLABLE_EQUIPMENT_HOURS
7130      , SUP_INV_COMMITTED_COST
7131      , PO_COMMITTED_COST
7132      , PR_COMMITTED_COST
7133      , OTH_COMMITTED_COST
7134        , ACT_LABOR_HRS
7135 	   , ACT_EQUIP_HRS
7136 	   , ACT_LABOR_BRDN_COST
7137 	   , ACT_EQUIP_BRDN_COST
7138 	   , ACT_BRDN_COST
7139 	   , ACT_RAW_COST
7140 	   , ACT_REVENUE
7141          , ACT_LABOR_RAW_COST
7142          , ACT_EQUIP_RAW_COST
7143 	   , ETC_LABOR_HRS
7144 	   , ETC_EQUIP_HRS
7145 	   , ETC_LABOR_BRDN_COST
7146 	   , ETC_EQUIP_BRDN_COST
7147 	   , ETC_BRDN_COST
7148          , ETC_RAW_COST
7149          , ETC_LABOR_RAW_COST
7150          , ETC_EQUIP_RAW_COST
7151      , CUSTOM1
7152      , CUSTOM2
7153      , CUSTOM3
7154      , CUSTOM4
7155      , CUSTOM5
7156      , CUSTOM6
7157      , CUSTOM7
7158      , CUSTOM8
7159      , CUSTOM9
7160      , CUSTOM10
7161      , CUSTOM11
7162      , CUSTOM12
7163      , CUSTOM13
7164      , CUSTOM14
7165      , CUSTOM15
7166      , LINE_TYPE
7167      , TIME_DANGLING_FLAG
7168      , RATE_DANGLING_FLAG
7169      , PRG_LEVEL
7170    )
7171    SELECT
7172          g_worker_id WORKER_ID
7173        , fact.project_id  project_id
7174 	 , fact.PROJECT_ORG_ID project_org_id
7175 	 , fact.PROJECT_ORGANIZATION_ID project_organization_id
7176      -- , fact.PARTITION_ID PARTITION_ID
7177    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
7178    	 , pa_cal.ent_period_id TIME_ID
7179    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
7180    	 , 'E' CALENDAR_TYPE -- fact.CALENDAR_TYPE
7181      , fact.RBS_AGGR_LEVEL RBS_AGGR_LEVEL
7182      , fact.WBS_ROLLUP_FLAG WBS_ROLLUP_FLAG
7183      , fact.PRG_ROLLUP_FLAG PRG_ROLLUP_FLAG
7184      , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
7185    	 , fact.CURRENCY_CODE CURRENCY_CODE
7186    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
7187    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
7188    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
7189    	 , fact.PLAN_TYPE_ID PLAN_TYPE_ID
7190    	 , MAX(fact.RAW_COST)	 raw_cost
7191    	 , MAX(fact.BRDN_COST) BRDN_COST
7192    	 , MAX(fact.REVENUE) REVENUE
7193    	 , MAX(fact.BILL_RAW_COST) BILL_RAW_COST
7194    	 , MAX(fact.BILL_BRDN_COST) BILL_BRDN_COST
7195    	 , MAX(fact.BILL_LABOR_RAW_COST) BILL_LABOR_RAW_COST
7196    	 , MAX(fact.BILL_LABOR_BRDN_COST) BILL_LABOR_BRDN_COST
7197    	 , MAX(fact.BILL_LABOR_HRS) BILL_LABOR_HRS
7198    	 , MAX(fact.EQUIPMENT_RAW_COST) EQUIPMENT_RAW_COST
7199    	 , MAX(fact.EQUIPMENT_BRDN_COST) EQUIPMENT_BRDN_COST
7200    	 , MAX(fact.CAPITALIZABLE_RAW_COST) CAPITALIZABLE_RAW_COST
7201    	 , MAX(fact.CAPITALIZABLE_BRDN_COST) CAPITALIZABLE_BRDN_COST
7202    	 , MAX(fact.LABOR_RAW_COST) LABOR_RAW_COST
7203    	 , MAX(fact.LABOR_BRDN_COST) LABOR_BRDN_COST
7204    	 , MAX(fact.LABOR_HRS) LABOR_HRS
7205    	 , MAX(fact.LABOR_REVENUE) LABOR_REVENUE
7206    	 , MAX(fact.EQUIPMENT_HOURS) EQUIPMENT_HOURS
7207    	 , MAX(fact.BILLABLE_EQUIPMENT_HOURS) BILLABLE_EQUIPMENT_HOURS
7208    	 , MAX(fact.SUP_INV_COMMITTED_COST) SUP_INV_COMMITTED_COST
7209    	 , MAX(fact.PO_COMMITTED_COST) PO_COMMITTED_COST
7210    	 , MAX(fact.PR_COMMITTED_COST) PR_COMMITTED_COST
7211    	 , MAX(fact.OTH_COMMITTED_COST) OTH_COMMITTED_COST
7212        , MAX(fact.ACT_LABOR_HRS )
7213 	 , MAX(fact.ACT_EQUIP_HRS )
7214 	 , MAX(fact.ACT_LABOR_BRDN_COST )
7215 	 , MAX(fact.ACT_EQUIP_BRDN_COST )
7216 	 , MAX(fact.ACT_BRDN_COST )
7217 	 , MAX(fact.ACT_RAW_COST )
7218 	 , MAX(fact.ACT_REVENUE )
7219        , MAX(fact.ACT_LABOR_RAW_COST)
7220        , MAX(fact.ACT_EQUIP_RAW_COST)
7221 	 , MAX(fact.ETC_LABOR_HRS )
7222 	 , MAX(fact.ETC_EQUIP_HRS )
7223 	 , MAX(fact.ETC_LABOR_BRDN_COST )
7224 	 , MAX(fact.ETC_EQUIP_BRDN_COST )
7225 	 , MAX(fact.ETC_BRDN_COST )
7226        , MAX(fact.ETC_RAW_COST )
7227        , MAX(fact.ETC_LABOR_RAW_COST)
7228        , MAX(fact.ETC_EQUIP_RAW_COST)
7229    	 , MAX(fact.CUSTOM1) CUSTOM1
7230    	 , MAX(fact.CUSTOM2) CUSTOM2
7231    	 , MAX(fact.CUSTOM3) CUSTOM3
7232    	 , MAX(fact.CUSTOM4) CUSTOM4
7233    	 , MAX(fact.CUSTOM5) CUSTOM5
7234    	 , MAX(fact.CUSTOM6) CUSTOM6
7235    	 , MAX(fact.CUSTOM7) CUSTOM7
7236    	 , MAX(fact.CUSTOM8) CUSTOM8
7237    	 , MAX(fact.CUSTOM9) CUSTOM9
7238    	 , MAX(fact.CUSTOM10) CUSTOM10
7239    	 , MAX(fact.CUSTOM11) CUSTOM11
7240    	 , MAX(fact.CUSTOM12) CUSTOM12
7241    	 , MAX(fact.CUSTOM13) CUSTOM13
7242    	 , MAX(fact.CUSTOM14) CUSTOM14
7243    	 , MAX(fact.CUSTOM15) CUSTOM15
7244    	 -- , DECODE ('E', 'E', MAX(pa_cal.start_date), 'S', MIN(pa_cal.start_date)) start_date
7245    	 -- , DECODE ('E', 'E', MAX(pa_cal.end_date), 'S', MIN(pa_cal.end_date))	 end_date
7246        , 'CF'   line_type
7247 	 , fact.TIME_DANGLING_FLAG  TIME_DANGLING_FLAG
7248 	 , fact.RATE_DANGLING_FLAG  RATE_DANGLING_FLAG
7249        , g_default_prg_level prg_level
7250    FROM   pji_fp_aggr_pjp1_t fact
7251         , pji_time_cal_period  non_pa_cal
7252         -- , pji_org_extr_info  orginfo
7253    	  , pji_time_ent_period  pa_cal
7254         , pji_fm_extr_plnver3_t  ver
7255    WHERE  fact.CALENDAR_TYPE IN ('P', 'G')
7256       AND fact.worker_id = g_worker_id
7257       AND non_pa_cal.cal_period_id = fact.time_id
7261       AND ( non_pa_cal.start_date <= pa_cal.end_date AND non_pa_cal.end_date >= pa_cal.start_date )
7258       AND fact.line_type like 'OF%'
7259 	AND fact.TIME_DANGLING_FLAG  IS NULL
7260 	AND fact.RATE_DANGLING_FLAG  IS NULL
7262       AND fact.period_type_id = 32
7263       AND fact.plan_version_id = ver.plan_version_id
7264       AND ver.wp_flag = 'N'
7265       AND ver.baselined_flag = 'Y'
7266 	-- AND (ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
7267       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
7268    GROUP BY
7269        fact.project_id
7270 	 , fact.PROJECT_ORG_ID
7271 	 , fact.PROJECT_ORGANIZATION_ID
7272      -- , fact.PARTITION_ID
7273    	 , fact.PROJECT_ELEMENT_ID
7274    	 , pa_cal.ent_period_id
7275    	 , fact.PERIOD_TYPE_ID
7276    	 , fact.CALENDAR_TYPE
7277      , fact.RBS_AGGR_LEVEL
7278      , fact.WBS_ROLLUP_FLAG
7279      , fact.PRG_ROLLUP_FLAG
7280      , fact.CURR_RECORD_TYPE_ID
7281    	 , fact.CURRENCY_CODE
7282    	 , fact.RBS_ELEMENT_ID
7283    	 , fact.RBS_VERSION_ID
7284    	 , fact.PLAN_VERSION_ID
7285    	 , fact.PLAN_TYPE_ID
7286 	 , fact.TIME_DANGLING_FLAG
7287 	 , fact.RATE_DANGLING_FLAG;
7288 End of bug 4005006*/
7289 
7290     INSERT INTO pji_fp_aggr_pjp1_t   -- PA, GL calendar entries.
7291     (
7292        WORKER_ID
7293      , PROJECT_ID
7294      , PROJECT_ORG_ID
7295      , PROJECT_ORGANIZATION_ID
7296      , PROJECT_ELEMENT_ID
7297      , TIME_ID
7298      , PERIOD_TYPE_ID
7299      , CALENDAR_TYPE
7300      , RBS_AGGR_LEVEL
7301      , WBS_ROLLUP_FLAG
7302      , PRG_ROLLUP_FLAG
7303      , CURR_RECORD_TYPE_ID
7304      , CURRENCY_CODE
7305      , RBS_ELEMENT_ID
7306      , RBS_VERSION_ID
7307      , PLAN_VERSION_ID
7308      , PLAN_TYPE_ID
7309      , RAW_COST
7310      , BRDN_COST
7311      , REVENUE
7312      , BILL_RAW_COST
7313      , BILL_BRDN_COST
7314      , BILL_LABOR_RAW_COST
7315      , BILL_LABOR_BRDN_COST
7316      , BILL_LABOR_HRS
7317      , EQUIPMENT_RAW_COST
7318      , EQUIPMENT_BRDN_COST
7319      , CAPITALIZABLE_RAW_COST
7320      , CAPITALIZABLE_BRDN_COST
7321      , LABOR_RAW_COST
7322      , LABOR_BRDN_COST
7323      , LABOR_HRS
7324      , LABOR_REVENUE
7325      , EQUIPMENT_HOURS
7326      , BILLABLE_EQUIPMENT_HOURS
7327      , SUP_INV_COMMITTED_COST
7328      , PO_COMMITTED_COST
7329      , PR_COMMITTED_COST
7330      , OTH_COMMITTED_COST
7331      , ACT_LABOR_HRS
7332      , ACT_EQUIP_HRS
7333      , ACT_LABOR_BRDN_COST
7334      , ACT_EQUIP_BRDN_COST
7335      , ACT_BRDN_COST
7336      , ACT_RAW_COST
7337      , ACT_REVENUE
7338      , ACT_LABOR_RAW_COST
7339      , ACT_EQUIP_RAW_COST
7340      , ETC_LABOR_HRS
7341      , ETC_EQUIP_HRS
7342      , ETC_LABOR_BRDN_COST
7343      , ETC_EQUIP_BRDN_COST
7344      , ETC_BRDN_COST
7345      , ETC_RAW_COST
7346      , ETC_LABOR_RAW_COST
7347      , ETC_EQUIP_RAW_COST
7348      , CUSTOM1
7349      , CUSTOM2
7350      , CUSTOM3
7351      , CUSTOM4
7352      , CUSTOM5
7353      , CUSTOM6
7354      , CUSTOM7
7355      , CUSTOM8
7356      , CUSTOM9
7357      , CUSTOM10
7358      , CUSTOM11
7359      , CUSTOM12
7360      , CUSTOM13
7361      , CUSTOM14
7362      , CUSTOM15
7363      , TIME_DANGLING_FLAG
7364      , RATE_DANGLING_FLAG
7365      , PRG_LEVEL
7366      , PLAN_TYPE_CODE    /* 4471527 */
7367    )
7368    SELECT
7369            g_worker_id WORKER_ID
7370          , fact.project_id  project_id
7371 	 , fact.PROJECT_ORG_ID project_org_id
7372 	 , fact.PROJECT_ORGANIZATION_ID project_organization_id
7373    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
7374    	 , pa_cal.ent_period_id TIME_ID
7375    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
7376    	 , 'E' CALENDAR_TYPE -- fact.CALENDAR_TYPE
7377          , fact.RBS_AGGR_LEVEL RBS_AGGR_LEVEL
7378          , fact.WBS_ROLLUP_FLAG WBS_ROLLUP_FLAG
7379          , fact.PRG_ROLLUP_FLAG PRG_ROLLUP_FLAG
7380          , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
7381    	 , fact.CURRENCY_CODE CURRENCY_CODE
7382    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
7383    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
7384    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
7385    	 , fact.PLAN_TYPE_ID PLAN_TYPE_ID
7386    	 , SUM(fact.RAW_COST)	 raw_cost
7387    	 , SUM(fact.BRDN_COST) BRDN_COST
7388    	 , SUM(fact.REVENUE) REVENUE
7389    	 , SUM(fact.BILL_RAW_COST) BILL_RAW_COST
7390    	 , SUM(fact.BILL_BRDN_COST) BILL_BRDN_COST
7391    	 , SUM(fact.BILL_LABOR_RAW_COST) BILL_LABOR_RAW_COST
7392    	 , SUM(fact.BILL_LABOR_BRDN_COST) BILL_LABOR_BRDN_COST
7393    	 , SUM(fact.BILL_LABOR_HRS) BILL_LABOR_HRS
7394    	 , SUM(fact.EQUIPMENT_RAW_COST) EQUIPMENT_RAW_COST
7395    	 , SUM(fact.EQUIPMENT_BRDN_COST) EQUIPMENT_BRDN_COST
7396    	 , SUM(fact.CAPITALIZABLE_RAW_COST) CAPITALIZABLE_RAW_COST
7397    	 , SUM(fact.CAPITALIZABLE_BRDN_COST) CAPITALIZABLE_BRDN_COST
7398    	 , SUM(fact.LABOR_RAW_COST) LABOR_RAW_COST
7399    	 , SUM(fact.LABOR_BRDN_COST) LABOR_BRDN_COST
7400    	 , SUM(fact.LABOR_HRS) LABOR_HRS
7401    	 , SUM(fact.LABOR_REVENUE) LABOR_REVENUE
7402    	 , SUM(fact.EQUIPMENT_HOURS) EQUIPMENT_HOURS
7403    	 , SUM(fact.BILLABLE_EQUIPMENT_HOURS) BILLABLE_EQUIPMENT_HOURS
7404    	 , SUM(fact.SUP_INV_COMMITTED_COST) SUP_INV_COMMITTED_COST
7405    	 , SUM(fact.PO_COMMITTED_COST) PO_COMMITTED_COST
7406    	 , SUM(fact.PR_COMMITTED_COST) PR_COMMITTED_COST
7407    	 , SUM(fact.OTH_COMMITTED_COST) OTH_COMMITTED_COST
7411 	 , SUM(fact.ACT_EQUIP_BRDN_COST )
7408          , SUM(fact.ACT_LABOR_HRS )
7409 	 , SUM(fact.ACT_EQUIP_HRS )
7410 	 , SUM(fact.ACT_LABOR_BRDN_COST )
7412 	 , SUM(fact.ACT_BRDN_COST )
7413 	 , SUM(fact.ACT_RAW_COST )
7414 	 , SUM(fact.ACT_REVENUE )
7415          , SUM(fact.ACT_LABOR_RAW_COST)
7416          , SUM(fact.ACT_EQUIP_RAW_COST)
7417 	 , SUM(fact.ETC_LABOR_HRS )
7418 	 , SUM(fact.ETC_EQUIP_HRS )
7419 	 , SUM(fact.ETC_LABOR_BRDN_COST )
7420 	 , SUM(fact.ETC_EQUIP_BRDN_COST )
7421 	 , SUM(fact.ETC_BRDN_COST )
7422          , SUM(fact.ETC_RAW_COST )
7423          , SUM(fact.ETC_LABOR_RAW_COST)
7424          , SUM(fact.ETC_EQUIP_RAW_COST)
7425    	 , SUM(fact.CUSTOM1) CUSTOM1
7426    	 , SUM(fact.CUSTOM2) CUSTOM2
7427    	 , SUM(fact.CUSTOM3) CUSTOM3
7428    	 , SUM(fact.CUSTOM4) CUSTOM4
7429    	 , SUM(fact.CUSTOM5) CUSTOM5
7430    	 , SUM(fact.CUSTOM6) CUSTOM6
7431    	 , SUM(fact.CUSTOM7) CUSTOM7
7432    	 , SUM(fact.CUSTOM8) CUSTOM8
7433    	 , SUM(fact.CUSTOM9) CUSTOM9
7434    	 , SUM(fact.CUSTOM10) CUSTOM10
7435    	 , SUM(fact.CUSTOM11) CUSTOM11
7436    	 , SUM(fact.CUSTOM12) CUSTOM12
7437    	 , SUM(fact.CUSTOM13) CUSTOM13
7438    	 , SUM(fact.CUSTOM14) CUSTOM14
7439    	 , SUM(fact.CUSTOM15) CUSTOM15
7440 	 , fact.TIME_DANGLING_FLAG  TIME_DANGLING_FLAG
7441 	 , fact.RATE_DANGLING_FLAG  RATE_DANGLING_FLAG
7442          , g_default_prg_level prg_level
7443          , fact.plan_type_code plan_type_code    /* 4471527 */
7444    FROM   pji_fp_aggr_pjp1_t fact
7445         , pji_time_cal_period_v  non_pa_cal
7446    	, pji_time_ent_period_v  pa_cal
7447         , pji_fm_extr_plnver3_t  ver
7448    WHERE  fact.CALENDAR_TYPE IN ('P', 'G')
7449       AND fact.worker_id = g_worker_id
7450       AND non_pa_cal.cal_period_id = fact.time_id
7451       AND fact.line_type like 'OF%'
7452       AND fact.TIME_DANGLING_FLAG  IS NULL
7453       AND fact.RATE_DANGLING_FLAG  IS NULL
7454       AND ( non_pa_cal.start_date <= pa_cal.end_date AND non_pa_cal.end_date >= pa_cal.start_date )
7455       AND fact.period_type_id = 32
7456       AND fact.plan_version_id = ver.plan_version_id
7457       AND fact.plan_type_code = ver.plan_type_code   /* 4471527 */
7458       AND ver.wp_flag = 'N'
7459       AND ver.baselined_flag = 'Y'
7460       -- AND (ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
7461       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
7462       AND DECODE(p_prorating_format,'S',
7463              DECODE(SIGN(non_pa_cal.start_Date-pa_cal.start_date),-1,0,1),
7464              DECODE(SIGN(non_pa_cal.end_Date - pa_cal.end_date), 1,0,1))=1
7465    GROUP BY
7466            fact.project_id
7467 	 , fact.PROJECT_ORG_ID
7468 	 , fact.PROJECT_ORGANIZATION_ID
7469    	 , fact.PROJECT_ELEMENT_ID
7470    	 , pa_cal.ent_period_id
7471    	 , fact.PERIOD_TYPE_ID
7472    	 , fact.CALENDAR_TYPE
7473          , fact.RBS_AGGR_LEVEL
7474          , fact.WBS_ROLLUP_FLAG
7475          , fact.PRG_ROLLUP_FLAG
7476          , fact.CURR_RECORD_TYPE_ID
7477    	 , fact.CURRENCY_CODE
7478    	 , fact.RBS_ELEMENT_ID
7479    	 , fact.RBS_VERSION_ID
7480    	 , fact.PLAN_VERSION_ID
7481    	 , fact.PLAN_TYPE_ID
7482               , fact.PLAN_TYPE_CODE     /*4471527 */
7483 	 , fact.TIME_DANGLING_FLAG
7484 	 , fact.RATE_DANGLING_FLAG;
7485 
7486 EXCEPTION
7487   WHEN OTHERS THEN
7488     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
7489                              p_procedure_name => 'PRORATE_TO_ENT_PG_PJP1_SE');
7490     RAISE;
7491 END;
7492 
7493 
7494 PROCEDURE PRORATE_TO_ENT_PG_FPRL_SE IS
7495 BEGIN
7496 
7500     (
7497     -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
7498 
7499     INSERT INTO pji_fp_aggr_pjp1_t   -- PA, GL calendar entries.
7501        WORKER_ID
7502      , PROJECT_ID
7503      , PROJECT_ORG_ID
7504      , PROJECT_ORGANIZATION_ID
7505      -- , PARTITION_ID
7506      , PROJECT_ELEMENT_ID
7507      , TIME_ID
7508      , PERIOD_TYPE_ID
7509      , CALENDAR_TYPE
7510      , RBS_AGGR_LEVEL
7511      , WBS_ROLLUP_FLAG
7512      , PRG_ROLLUP_FLAG
7513      , CURR_RECORD_TYPE_ID
7514      , CURRENCY_CODE
7515      , RBS_ELEMENT_ID
7516      , RBS_VERSION_ID
7517      , PLAN_VERSION_ID
7518      , PLAN_TYPE_ID
7519      , RAW_COST
7520      , BRDN_COST
7521      , REVENUE
7522      , BILL_RAW_COST
7523      , BILL_BRDN_COST
7524      , BILL_LABOR_RAW_COST
7525      , BILL_LABOR_BRDN_COST
7526      , BILL_LABOR_HRS
7527      , EQUIPMENT_RAW_COST
7528      , EQUIPMENT_BRDN_COST
7529      , CAPITALIZABLE_RAW_COST
7530      , CAPITALIZABLE_BRDN_COST
7531      , LABOR_RAW_COST
7532      , LABOR_BRDN_COST
7533      , LABOR_HRS
7534      , LABOR_REVENUE
7535      , EQUIPMENT_HOURS
7536      , BILLABLE_EQUIPMENT_HOURS
7537      , SUP_INV_COMMITTED_COST
7538      , PO_COMMITTED_COST
7539      , PR_COMMITTED_COST
7540      , OTH_COMMITTED_COST
7541        , ACT_LABOR_HRS
7542 	   , ACT_EQUIP_HRS
7543 	   , ACT_LABOR_BRDN_COST
7544 	   , ACT_EQUIP_BRDN_COST
7545 	   , ACT_BRDN_COST
7546 	   , ACT_RAW_COST
7547 	   , ACT_REVENUE
7548          , ACT_LABOR_RAW_COST
7549          , ACT_EQUIP_RAW_COST
7550 	   , ETC_LABOR_HRS
7551 	   , ETC_EQUIP_HRS
7552 	   , ETC_LABOR_BRDN_COST
7553 	   , ETC_EQUIP_BRDN_COST
7554 	   , ETC_BRDN_COST
7555          , ETC_RAW_COST
7556          , ETC_LABOR_RAW_COST
7557          , ETC_EQUIP_RAW_COST
7558      , CUSTOM1
7559      , CUSTOM2
7560      , CUSTOM3
7561      , CUSTOM4
7562      , CUSTOM5
7563      , CUSTOM6
7564      , CUSTOM7
7565      , CUSTOM8
7566      , CUSTOM9
7567      , CUSTOM10
7568      , CUSTOM11
7569      , CUSTOM12
7570      , CUSTOM13
7571      , CUSTOM14
7572      , CUSTOM15
7573      , PRG_LEVEL
7574      , PLAN_TYPE_CODE    /* 4471527 */
7575    )
7576    SELECT
7577          g_worker_id WORKER_ID
7578        , fact.project_id  project_id
7579 	 , fact.PROJECT_ORG_ID project_org_id
7580 	 , fact.PROJECT_ORGANIZATION_ID project_organization_id
7581      -- , fact.PARTITION_ID PARTITION_ID
7582    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
7583    	 , pa_cal.ent_period_id TIME_ID
7584    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
7585    	 , 'E' CALENDAR_TYPE -- fact.CALENDAR_TYPE
7586      , fact.RBS_AGGR_LEVEL RBS_AGGR_LEVEL
7587      , fact.WBS_ROLLUP_FLAG WBS_ROLLUP_FLAG
7588      , fact.PRG_ROLLUP_FLAG PRG_ROLLUP_FLAG
7589      , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
7590    	 , fact.CURRENCY_CODE CURRENCY_CODE
7591    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
7592    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
7593    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
7594    	 , fact.PLAN_TYPE_ID PLAN_TYPE_ID
7595    	 , MAX(fact.RAW_COST)	 raw_cost
7596    	 , MAX(fact.BRDN_COST) BRDN_COST
7597    	 , MAX(fact.REVENUE) REVENUE
7598    	 , MAX(fact.BILL_RAW_COST) BILL_RAW_COST
7599    	 , MAX(fact.BILL_BRDN_COST) BILL_BRDN_COST
7600    	 , MAX(fact.BILL_LABOR_RAW_COST) BILL_LABOR_RAW_COST
7601    	 , MAX(fact.BILL_LABOR_BRDN_COST) BILL_LABOR_BRDN_COST
7602    	 , MAX(fact.BILL_LABOR_HRS) BILL_LABOR_HRS
7603    	 , MAX(fact.EQUIPMENT_RAW_COST) EQUIPMENT_RAW_COST
7604    	 , MAX(fact.EQUIPMENT_BRDN_COST) EQUIPMENT_BRDN_COST
7605    	 , MAX(fact.CAPITALIZABLE_RAW_COST) CAPITALIZABLE_RAW_COST
7606    	 , MAX(fact.CAPITALIZABLE_BRDN_COST) CAPITALIZABLE_BRDN_COST
7607    	 , MAX(fact.LABOR_RAW_COST) LABOR_RAW_COST
7608    	 , MAX(fact.LABOR_BRDN_COST) LABOR_BRDN_COST
7609    	 , MAX(fact.LABOR_HRS) LABOR_HRS
7610    	 , MAX(fact.LABOR_REVENUE) LABOR_REVENUE
7611    	 , MAX(fact.EQUIPMENT_HOURS) EQUIPMENT_HOURS
7612    	 , MAX(fact.BILLABLE_EQUIPMENT_HOURS) BILLABLE_EQUIPMENT_HOURS
7613    	 , MAX(fact.SUP_INV_COMMITTED_COST) SUP_INV_COMMITTED_COST
7614    	 , MAX(fact.PO_COMMITTED_COST) PO_COMMITTED_COST
7615    	 , MAX(fact.PR_COMMITTED_COST) PR_COMMITTED_COST
7616    	 , MAX(fact.OTH_COMMITTED_COST) OTH_COMMITTED_COST
7617        , MAX(fact.ACT_LABOR_HRS )
7618 	 , MAX(fact.ACT_EQUIP_HRS )
7619 	 , MAX(fact.ACT_LABOR_BRDN_COST )
7620 	 , MAX(fact.ACT_EQUIP_BRDN_COST )
7621 	 , MAX(fact.ACT_BRDN_COST )
7622 	 , MAX(fact.ACT_RAW_COST )
7623 	 , MAX(fact.ACT_REVENUE )
7624        , MAX(fact.ACT_LABOR_RAW_COST)
7625        , MAX(fact.ACT_EQUIP_RAW_COST)
7626 	 , MAX(fact.ETC_LABOR_HRS )
7627 	 , MAX(fact.ETC_EQUIP_HRS )
7628 	 , MAX(fact.ETC_LABOR_BRDN_COST )
7629 	 , MAX(fact.ETC_EQUIP_BRDN_COST )
7630 	 , MAX(fact.ETC_BRDN_COST )
7631        , MAX(fact.ETC_RAW_COST )
7632        , MAX(fact.ETC_LABOR_RAW_COST)
7633        , MAX(fact.ETC_EQUIP_RAW_COST)
7634    	 , MAX(fact.CUSTOM1) CUSTOM1
7635    	 , MAX(fact.CUSTOM2) CUSTOM2
7636    	 , MAX(fact.CUSTOM3) CUSTOM3
7637    	 , MAX(fact.CUSTOM4) CUSTOM4
7638    	 , MAX(fact.CUSTOM5) CUSTOM5
7639    	 , MAX(fact.CUSTOM6) CUSTOM6
7640    	 , MAX(fact.CUSTOM7) CUSTOM7
7641    	 , MAX(fact.CUSTOM8) CUSTOM8
7642    	 , MAX(fact.CUSTOM9) CUSTOM9
7643    	 , MAX(fact.CUSTOM10) CUSTOM10
7644    	 , MAX(fact.CUSTOM11) CUSTOM11
7645    	 , MAX(fact.CUSTOM12) CUSTOM12
7646    	 , MAX(fact.CUSTOM13) CUSTOM13
7647    	 , MAX(fact.CUSTOM14) CUSTOM14
7651        , g_default_prg_level prg_level
7648    	 , MAX(fact.CUSTOM15) CUSTOM15
7649    	 -- , DECODE ('E', 'E', MAX(pa_cal.start_date), 'S', MIN(pa_cal.start_date)) start_date
7650    	 -- , DECODE ('E', 'E', MAX(pa_cal.end_date), 'S', MIN(pa_cal.end_date))	 end_date
7652        , fact.plan_type_code   plan_type_code    /* 4471527 */
7653    FROM   pji_fp_xbs_accum_f  fact
7654        , PJI_FM_EXTR_PLNVER3_T ver
7655         , pji_time_cal_period  non_pa_cal
7656         -- , pji_org_extr_info  orginfo
7657    	  , pji_time_ent_period  pa_cal
7658    WHERE  non_pa_cal.cal_period_id = fact.time_id
7659       AND fact.period_type_id = 32
7660       AND ver.project_id = fact.project_id
7661       AND ver.plan_version_id = fact.plan_version_id
7662       AND ver.plan_type_code = fact.plan_type_code     /* 4471527 */
7663       AND ( non_pa_cal.start_date <= pa_cal.end_date AND non_pa_cal.end_date >= pa_cal.start_date )
7664       AND fact.period_type_id = 32
7665       AND ver.wp_flag = 'N'
7666       AND ver.baselined_flag = 'Y'
7667 	-- AND (ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
7668       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
7669    GROUP BY
7670        fact.project_id
7671 	 , fact.PROJECT_ORG_ID
7672 	 , fact.PROJECT_ORGANIZATION_ID
7673      -- , fact.PARTITION_ID
7674    	 , fact.PROJECT_ELEMENT_ID
7675    	 , pa_cal.ent_period_id
7676    	 , fact.PERIOD_TYPE_ID
7677    	 , fact.CALENDAR_TYPE
7678      , fact.RBS_AGGR_LEVEL
7679      , fact.WBS_ROLLUP_FLAG
7680      , fact.PRG_ROLLUP_FLAG
7681      , fact.CURR_RECORD_TYPE_ID
7682    	 , fact.CURRENCY_CODE
7683    	 , fact.RBS_ELEMENT_ID
7684    	 , fact.RBS_VERSION_ID
7685    	 , fact.PLAN_VERSION_ID
7686    	 , fact.PLAN_TYPE_ID
7687               , fact.PLAN_TYPE_CODE ;   /* 4471527 */
7688 
7689 EXCEPTION
7690   WHEN OTHERS THEN
7691     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
7692                              p_procedure_name => 'PRORATE_TO_ENT_PG_FPRL_SE');
7693     RAISE;
7694 END;
7695 
7696 
7697 PROCEDURE PRORATE_TO_ENT_N_PJP1_SE( p_prorating_format varchar2) IS
7698 BEGIN
7699 
7700     -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
7701 
7702 /* Commented for bug 4005006
7703 
7704     INSERT INTO pji_fp_aggr_pjp1_t  -- Non time phased entries.
7705     (
7706        WORKER_ID
7707      , PROJECT_ID
7708      , PROJECT_ORG_ID
7709      , PROJECT_ORGANIZATION_ID
7710      -- , PARTITION_ID
7711      , PROJECT_ELEMENT_ID
7712      , TIME_ID
7713      , PERIOD_TYPE_ID
7714      , CALENDAR_TYPE
7715      , RBS_AGGR_LEVEL
7716      , WBS_ROLLUP_FLAG
7717      , PRG_ROLLUP_FLAG
7718      , CURR_RECORD_TYPE_ID
7719      , CURRENCY_CODE
7720      , RBS_ELEMENT_ID
7721      , RBS_VERSION_ID
7722      , PLAN_VERSION_ID
7723      , PLAN_TYPE_ID
7724      , RAW_COST
7725      , BRDN_COST
7726      , REVENUE
7727      , BILL_RAW_COST
7728      , BILL_BRDN_COST
7729      , BILL_LABOR_RAW_COST
7730      , BILL_LABOR_BRDN_COST
7731      , BILL_LABOR_HRS
7732      , EQUIPMENT_RAW_COST
7733      , EQUIPMENT_BRDN_COST
7734      , CAPITALIZABLE_RAW_COST
7735      , CAPITALIZABLE_BRDN_COST
7736      , LABOR_RAW_COST
7737      , LABOR_BRDN_COST
7738      , LABOR_HRS
7739      , LABOR_REVENUE
7740      , EQUIPMENT_HOURS
7741      , BILLABLE_EQUIPMENT_HOURS
7742      , SUP_INV_COMMITTED_COST
7743      , PO_COMMITTED_COST
7744      , PR_COMMITTED_COST
7745      , OTH_COMMITTED_COST
7749 	   , ACT_EQUIP_BRDN_COST
7746        , ACT_LABOR_HRS
7747 	   , ACT_EQUIP_HRS
7748 	   , ACT_LABOR_BRDN_COST
7750 	   , ACT_BRDN_COST
7751 	   , ACT_RAW_COST
7752 	   , ACT_REVENUE
7753          , ACT_LABOR_RAW_COST
7754          , ACT_EQUIP_RAW_COST
7755 	   , ETC_LABOR_HRS
7756 	   , ETC_EQUIP_HRS
7757 	   , ETC_LABOR_BRDN_COST
7758 	   , ETC_EQUIP_BRDN_COST
7759 	   , ETC_BRDN_COST
7760          , ETC_RAW_COST
7761          , ETC_LABOR_RAW_COST
7762          , ETC_EQUIP_RAW_COST
7763      , CUSTOM1
7764      , CUSTOM2
7765      , CUSTOM3
7766      , CUSTOM4
7767      , CUSTOM5
7768      , CUSTOM6
7769      , CUSTOM7
7770      , CUSTOM8
7771      , CUSTOM9
7772      , CUSTOM10
7773      , CUSTOM11
7774      , CUSTOM12
7775      , CUSTOM13
7776      , CUSTOM14
7777      , CUSTOM15
7778      , LINE_TYPE
7779      , TIME_DANGLING_FLAG
7780      , RATE_DANGLING_FLAG
7781      , PRG_LEVEL
7782    )
7783    SELECT
7784          g_worker_id WORKER_ID
7785        , fact.project_id  project_id
7786 	 , fact.PROJECT_ORG_ID project_org_id
7787 	 , fact.PROJECT_ORGANIZATION_ID project_organization_id
7788      -- , fact.PARTITION_ID PARTITION_ID
7789    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
7790    	 , pa_cal.ent_period_id TIME_ID
7791    	 , 32 -- fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
7792    	 , 'E' CALENDAR_TYPE -- fact.CALENDAR_TYPE
7793      , fact.RBS_AGGR_LEVEL RBS_AGGR_LEVEL
7794      , fact.WBS_ROLLUP_FLAG WBS_ROLLUP_FLAG
7795      , fact.PRG_ROLLUP_FLAG PRG_ROLLUP_FLAG
7796      , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
7797    	 , fact.CURRENCY_CODE CURRENCY_CODE
7798    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
7799    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
7800    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
7801    	 , fact.PLAN_TYPE_ID PLAN_TYPE_ID
7802    	 , MAX(fact.RAW_COST)	 raw_cost
7803    	 , MAX(fact.BRDN_COST) BRDN_COST
7804    	 , MAX(fact.REVENUE) REVENUE
7805    	 , MAX(fact.BILL_RAW_COST) BILL_RAW_COST
7806    	 , MAX(fact.BILL_BRDN_COST) BILL_BRDN_COST
7807    	 , MAX(fact.BILL_LABOR_RAW_COST) BILL_LABOR_RAW_COST
7808    	 , MAX(fact.BILL_LABOR_BRDN_COST) BILL_LABOR_BRDN_COST
7809    	 , MAX(fact.BILL_LABOR_HRS) BILL_LABOR_HRS
7810    	 , MAX(fact.EQUIPMENT_RAW_COST) EQUIPMENT_RAW_COST
7811    	 , MAX(fact.EQUIPMENT_BRDN_COST) EQUIPMENT_BRDN_COST
7812    	 , MAX(fact.CAPITALIZABLE_RAW_COST) CAPITALIZABLE_RAW_COST
7813    	 , MAX(fact.CAPITALIZABLE_BRDN_COST) CAPITALIZABLE_BRDN_COST
7814    	 , MAX(fact.LABOR_RAW_COST) LABOR_RAW_COST
7815    	 , MAX(fact.LABOR_BRDN_COST) LABOR_BRDN_COST
7816    	 , MAX(fact.LABOR_HRS) LABOR_HRS
7817    	 , MAX(fact.LABOR_REVENUE) LABOR_REVENUE
7818    	 , MAX(fact.EQUIPMENT_HOURS) EQUIPMENT_HOURS
7819    	 , MAX(fact.BILLABLE_EQUIPMENT_HOURS) BILLABLE_EQUIPMENT_HOURS
7820    	 , MAX(fact.SUP_INV_COMMITTED_COST) SUP_INV_COMMITTED_COST
7821    	 , MAX(fact.PO_COMMITTED_COST) PO_COMMITTED_COST
7822    	 , MAX(fact.PR_COMMITTED_COST) PR_COMMITTED_COST
7823    	 , MAX(fact.OTH_COMMITTED_COST) OTH_COMMITTED_COST
7824        , MAX(fact.ACT_LABOR_HRS )
7825 	 , MAX(fact.ACT_EQUIP_HRS )
7826 	 , MAX(fact.ACT_LABOR_BRDN_COST )
7827 	 , MAX(fact.ACT_EQUIP_BRDN_COST )
7828 	 , MAX(fact.ACT_BRDN_COST )
7829 	 , MAX(fact.ACT_RAW_COST )
7830 	 , MAX(fact.ACT_REVENUE )
7831        , MAX(fact.ACT_LABOR_RAW_COST)
7832        , MAX(fact.ACT_EQUIP_RAW_COST)
7833 	 , MAX(fact.ETC_LABOR_HRS )
7834 	 , MAX(fact.ETC_EQUIP_HRS )
7835 	 , MAX(fact.ETC_LABOR_BRDN_COST )
7836 	 , MAX(fact.ETC_EQUIP_BRDN_COST )
7837 	 , MAX(fact.ETC_BRDN_COST )
7838        , MAX(fact.ETC_RAW_COST )
7839        , MAX(fact.ETC_LABOR_RAW_COST)
7840        , MAX(fact.ETC_EQUIP_RAW_COST)
7841    	 , MAX(fact.CUSTOM1) CUSTOM1
7842    	 , MAX(fact.CUSTOM2) CUSTOM2
7843    	 , MAX(fact.CUSTOM3) CUSTOM3
7844    	 , MAX(fact.CUSTOM4) CUSTOM4
7845    	 , MAX(fact.CUSTOM5) CUSTOM5
7846    	 , MAX(fact.CUSTOM6) CUSTOM6
7847    	 , MAX(fact.CUSTOM7) CUSTOM7
7848    	 , MAX(fact.CUSTOM8) CUSTOM8
7849    	 , MAX(fact.CUSTOM9) CUSTOM9
7850    	 , MAX(fact.CUSTOM10) CUSTOM10
7851    	 , MAX(fact.CUSTOM11) CUSTOM11
7852    	 , MAX(fact.CUSTOM12) CUSTOM12
7853    	 , MAX(fact.CUSTOM13) CUSTOM13
7854    	 , MAX(fact.CUSTOM14) CUSTOM14
7855    	 , MAX(fact.CUSTOM15) CUSTOM15
7856        , 'CN'   line_type
7857 	 , fact.TIME_DANGLING_FLAG  TIME_DANGLING_FLAG
7858 	 , fact.RATE_DANGLING_FLAG  RATE_DANGLING_FLAG
7859        , g_default_prg_level prg_level
7860    FROM   pji_fp_aggr_pjp1_t fact
7861    	  , pji_time_ent_period  pa_cal
7862         , pji_fm_extr_plnver3_t  ver
7863    WHERE  fact.CALENDAR_TYPE = 'A'
7864       AND fact.worker_id = g_worker_id
7865       AND fact.line_type = 'NTP'
7866       AND fact.start_date IS NOT NULL
7867       AND fact.end_date IS NOT NULL
7868 	AND fact.TIME_DANGLING_FLAG  IS NULL
7869 	AND fact.RATE_DANGLING_FLAG  IS NULL
7870       AND (
7871 	       (     pa_cal.start_date >= fact.start_date
7872                AND pa_cal.end_date <= fact.end_date ) -- fsps,pefe
7873 	    OR (     pa_cal.start_date <= fact.start_date
7874                AND pa_cal.end_date >= fact.end_date ) -- psfs,fepe
7875 	    OR (     pa_cal.start_date <= fact.start_date
7876                AND pa_cal.end_date <= fact.end_date
7877                AND pa_cal.end_date >= fact.start_date ) -- psfspefe
7878 	    OR (     pa_cal.start_date >= fact.start_date
7879                AND pa_cal.end_date >= fact.end_date
7880                AND pa_cal.start_date <= fact.end_date )  -- fspsfepe
7881           )
7882       AND fact.period_type_id = 2048
7886       AND ver.time_phased_type_code = 'N'
7883       AND fact.plan_version_id = ver.plan_version_id
7884       AND ver.wp_flag = 'N'
7885       AND ver.baselined_flag = 'Y'
7887   	-- AND (ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
7888       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
7889    GROUP BY
7890        fact.project_id
7891 	 , fact.PROJECT_ORG_ID
7892 	 , fact.PROJECT_ORGANIZATION_ID
7893      -- , fact.PARTITION_ID
7894    	 , fact.PROJECT_ELEMENT_ID
7895    	 , pa_cal.ent_period_id
7896    	 , fact.PERIOD_TYPE_ID
7897    	 , fact.CALENDAR_TYPE
7898      , fact.RBS_AGGR_LEVEL
7899      , fact.WBS_ROLLUP_FLAG
7900      , fact.PRG_ROLLUP_FLAG
7901      , fact.CURR_RECORD_TYPE_ID
7902    	 , fact.CURRENCY_CODE
7903    	 , fact.RBS_ELEMENT_ID
7904    	 , fact.RBS_VERSION_ID
7905    	 , fact.PLAN_VERSION_ID
7906    	 , fact.PLAN_TYPE_ID
7907 	 , fact.TIME_DANGLING_FLAG
7908 	 , fact.RATE_DANGLING_FLAG;
7909 
7910 End of bug 4005006*/
7911 
7912     INSERT INTO pji_fp_aggr_pjp1_t  -- Non time phased entries.
7913     (
7914        WORKER_ID
7915      , PROJECT_ID
7916      , PROJECT_ORG_ID
7917      , PROJECT_ORGANIZATION_ID
7918      , PROJECT_ELEMENT_ID
7919      , TIME_ID
7920      , PERIOD_TYPE_ID
7921      , CALENDAR_TYPE
7922      , RBS_AGGR_LEVEL
7923      , WBS_ROLLUP_FLAG
7924      , PRG_ROLLUP_FLAG
7925      , CURR_RECORD_TYPE_ID
7926      , CURRENCY_CODE
7927      , RBS_ELEMENT_ID
7928      , RBS_VERSION_ID
7929      , PLAN_VERSION_ID
7930      , PLAN_TYPE_ID
7931      , RAW_COST
7932      , BRDN_COST
7933      , REVENUE
7934      , BILL_RAW_COST
7935      , BILL_BRDN_COST
7936      , BILL_LABOR_RAW_COST
7937      , BILL_LABOR_BRDN_COST
7938      , BILL_LABOR_HRS
7939      , EQUIPMENT_RAW_COST
7940      , EQUIPMENT_BRDN_COST
7941      , CAPITALIZABLE_RAW_COST
7942      , CAPITALIZABLE_BRDN_COST
7943      , LABOR_RAW_COST
7944      , LABOR_BRDN_COST
7945      , LABOR_HRS
7946      , LABOR_REVENUE
7947      , EQUIPMENT_HOURS
7948      , BILLABLE_EQUIPMENT_HOURS
7949      , SUP_INV_COMMITTED_COST
7950      , PO_COMMITTED_COST
7951      , PR_COMMITTED_COST
7952      , OTH_COMMITTED_COST
7953      , ACT_LABOR_HRS
7954      , ACT_EQUIP_HRS
7955      , ACT_LABOR_BRDN_COST
7956      , ACT_EQUIP_BRDN_COST
7957      , ACT_BRDN_COST
7958      , ACT_RAW_COST
7959      , ACT_REVENUE
7960      , ACT_LABOR_RAW_COST
7961      , ACT_EQUIP_RAW_COST
7962      , ETC_LABOR_HRS
7963      , ETC_EQUIP_HRS
7964      , ETC_LABOR_BRDN_COST
7965      , ETC_EQUIP_BRDN_COST
7966      , ETC_BRDN_COST
7967      , ETC_RAW_COST
7968      , ETC_LABOR_RAW_COST
7969      , ETC_EQUIP_RAW_COST
7970      , CUSTOM1
7971      , CUSTOM2
7972      , CUSTOM3
7973      , CUSTOM4
7974      , CUSTOM5
7975      , CUSTOM6
7976      , CUSTOM7
7977      , CUSTOM8
7978      , CUSTOM9
7979      , CUSTOM10
7980      , CUSTOM11
7981      , CUSTOM12
7982      , CUSTOM13
7983      , CUSTOM14
7984      , CUSTOM15
7985      , TIME_DANGLING_FLAG
7986      , RATE_DANGLING_FLAG
7987      , PRG_LEVEL
7988      , PLAN_TYPE_CODE     /* 4471527 */
7989    )
7990    SELECT
7991            g_worker_id WORKER_ID
7992          , fact.project_id  project_id
7993 	 , fact.PROJECT_ORG_ID project_org_id
7994 	 , fact.PROJECT_ORGANIZATION_ID project_organization_id
7995    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
7996    	 , pa_cal.ent_period_id TIME_ID
7997    	 , 32 -- fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
7998    	 , 'E' CALENDAR_TYPE -- fact.CALENDAR_TYPE
7999          , fact.RBS_AGGR_LEVEL RBS_AGGR_LEVEL
8000          , fact.WBS_ROLLUP_FLAG WBS_ROLLUP_FLAG
8001          , fact.PRG_ROLLUP_FLAG PRG_ROLLUP_FLAG
8002          , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
8003    	 , fact.CURRENCY_CODE CURRENCY_CODE
8004    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
8005    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
8006    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
8007    	 , fact.PLAN_TYPE_ID PLAN_TYPE_ID
8008    	 , SUM(fact.RAW_COST)	 raw_cost
8009    	 , SUM(fact.BRDN_COST) BRDN_COST
8010    	 , SUM(fact.REVENUE) REVENUE
8011    	 , SUM(fact.BILL_RAW_COST) BILL_RAW_COST
8012    	 , SUM(fact.BILL_BRDN_COST) BILL_BRDN_COST
8013    	 , SUM(fact.BILL_LABOR_RAW_COST) BILL_LABOR_RAW_COST
8014    	 , SUM(fact.BILL_LABOR_BRDN_COST) BILL_LABOR_BRDN_COST
8015    	 , SUM(fact.BILL_LABOR_HRS) BILL_LABOR_HRS
8016    	 , SUM(fact.EQUIPMENT_RAW_COST) EQUIPMENT_RAW_COST
8017    	 , SUM(fact.EQUIPMENT_BRDN_COST) EQUIPMENT_BRDN_COST
8018    	 , SUM(fact.CAPITALIZABLE_RAW_COST) CAPITALIZABLE_RAW_COST
8019    	 , SUM(fact.CAPITALIZABLE_BRDN_COST) CAPITALIZABLE_BRDN_COST
8020    	 , SUM(fact.LABOR_RAW_COST) LABOR_RAW_COST
8021    	 , SUM(fact.LABOR_BRDN_COST) LABOR_BRDN_COST
8022    	 , SUM(fact.LABOR_HRS) LABOR_HRS
8023    	 , SUM(fact.LABOR_REVENUE) LABOR_REVENUE
8024    	 , SUM(fact.EQUIPMENT_HOURS) EQUIPMENT_HOURS
8025    	 , SUM(fact.BILLABLE_EQUIPMENT_HOURS) BILLABLE_EQUIPMENT_HOURS
8026    	 , SUM(fact.SUP_INV_COMMITTED_COST) SUP_INV_COMMITTED_COST
8027    	 , SUM(fact.PO_COMMITTED_COST) PO_COMMITTED_COST
8031 	 , SUM(fact.ACT_EQUIP_HRS )
8028    	 , SUM(fact.PR_COMMITTED_COST) PR_COMMITTED_COST
8029    	 , SUM(fact.OTH_COMMITTED_COST) OTH_COMMITTED_COST
8030          , SUM(fact.ACT_LABOR_HRS )
8032 	 , SUM(fact.ACT_LABOR_BRDN_COST )
8033 	 , SUM(fact.ACT_EQUIP_BRDN_COST )
8034 	 , SUM(fact.ACT_BRDN_COST )
8035 	 , SUM(fact.ACT_RAW_COST )
8036 	 , SUM(fact.ACT_REVENUE )
8037          , SUM(fact.ACT_LABOR_RAW_COST)
8038          , SUM(fact.ACT_EQUIP_RAW_COST)
8039 	 , SUM(fact.ETC_LABOR_HRS )
8040 	 , SUM(fact.ETC_EQUIP_HRS )
8041 	 , SUM(fact.ETC_LABOR_BRDN_COST )
8042 	 , SUM(fact.ETC_EQUIP_BRDN_COST )
8043 	 , SUM(fact.ETC_BRDN_COST )
8044          , SUM(fact.ETC_RAW_COST )
8045          , SUM(fact.ETC_LABOR_RAW_COST)
8046          , SUM(fact.ETC_EQUIP_RAW_COST)
8047    	 , SUM(fact.CUSTOM1) CUSTOM1
8048    	 , SUM(fact.CUSTOM2) CUSTOM2
8049    	 , SUM(fact.CUSTOM3) CUSTOM3
8050    	 , SUM(fact.CUSTOM4) CUSTOM4
8051    	 , SUM(fact.CUSTOM5) CUSTOM5
8052    	 , SUM(fact.CUSTOM6) CUSTOM6
8053    	 , SUM(fact.CUSTOM7) CUSTOM7
8054    	 , SUM(fact.CUSTOM8) CUSTOM8
8055    	 , SUM(fact.CUSTOM9) CUSTOM9
8056    	 , SUM(fact.CUSTOM10) CUSTOM10
8057    	 , SUM(fact.CUSTOM11) CUSTOM11
8058    	 , SUM(fact.CUSTOM12) CUSTOM12
8059    	 , SUM(fact.CUSTOM13) CUSTOM13
8060    	 , SUM(fact.CUSTOM14) CUSTOM14
8061    	 , SUM(fact.CUSTOM15) CUSTOM15
8062 	 , fact.TIME_DANGLING_FLAG  TIME_DANGLING_FLAG
8063 	 , fact.RATE_DANGLING_FLAG  RATE_DANGLING_FLAG
8064          , g_default_prg_level prg_level
8065              , fact.plan_type_code  plan_type_code   /* 4471527 */
8066    FROM    pji_fp_aggr_pjp1_t fact
8067    	 , pji_time_ent_period_v  pa_cal
8068          , pji_fm_extr_plnver3_t  ver
8069    WHERE  fact.CALENDAR_TYPE = 'A'
8070       AND fact.worker_id = g_worker_id
8071       AND fact.line_type = 'NTP'
8072       AND fact.start_date IS NOT NULL
8073       AND fact.end_date IS NOT NULL
8074       AND fact.TIME_DANGLING_FLAG  IS NULL
8075       AND fact.RATE_DANGLING_FLAG  IS NULL
8076       AND ( fact.start_date <= pa_cal.end_date AND fact.end_date >= pa_cal.start_date )
8077       AND DECODE(p_prorating_format,'S',
8078              DECODE(SIGN(fact.start_Date-pa_cal.start_date),-1,0,1),
8079              DECODE(SIGN(fact.end_Date - pa_cal.end_date), 1,0,1))=1
8080       AND fact.period_type_id = 2048
8081       AND fact.plan_version_id = ver.plan_version_id
8082       AND fact.plan_type_code = ver.plan_type_code   /* 4471527 */
8083       AND ver.wp_flag = 'N'
8084       AND ver.baselined_flag = 'Y'
8085       AND ver.time_phased_type_code = 'N'
8086   	-- AND (ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
8087       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
8088    GROUP BY
8089            fact.project_id
8090 	 , fact.PROJECT_ORG_ID
8091 	 , fact.PROJECT_ORGANIZATION_ID
8092    	 , fact.PROJECT_ELEMENT_ID
8093    	 , pa_cal.ent_period_id
8094    	 , fact.PERIOD_TYPE_ID
8095  	 , fact.CALENDAR_TYPE
8096          , fact.RBS_AGGR_LEVEL
8097          , fact.WBS_ROLLUP_FLAG
8098          , fact.PRG_ROLLUP_FLAG
8099          , fact.CURR_RECORD_TYPE_ID
8100    	 , fact.CURRENCY_CODE
8101    	 , fact.RBS_ELEMENT_ID
8102    	 , fact.RBS_VERSION_ID
8103    	 , fact.PLAN_VERSION_ID
8104    	 , fact.PLAN_TYPE_ID
8105               , fact.PLAN_TYPE_CODE   /* 4471527 */
8106 	 , fact.TIME_DANGLING_FLAG
8107 	 , fact.RATE_DANGLING_FLAG;
8108 
8109 
8110 EXCEPTION
8111   WHEN OTHERS THEN
8112     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
8113                              p_procedure_name => 'PRORATE_TO_ENT_N_PJP1_SE');
8114     RAISE;
8115 END;
8116 
8117 
8118 PROCEDURE PRORATE_TO_PAGL_PGE_PJP1_D (p_calendar_type   IN   VARCHAR2 := NULL) IS
8119 BEGIN
8120 
8121     -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
8122 
8123 /* Commented for bug 4005006
8124     INSERT INTO pji_fp_aggr_pjp1_t
8125     (
8126        worker_id
8127      , PROJECT_ID
8128      , PROJECT_ORG_ID
8129      , PROJECT_ORGANIZATION_ID
8130      -- , PARTITION_ID
8131      , PROJECT_ELEMENT_ID
8132      , TIME_ID
8133      , PERIOD_TYPE_ID
8134      , CALENDAR_TYPE
8135      , RBS_AGGR_LEVEL
8136      , WBS_ROLLUP_FLAG
8137      , PRG_ROLLUP_FLAG
8138      , CURR_RECORD_TYPE_ID
8139      , CURRENCY_CODE
8140      , RBS_ELEMENT_ID
8141      , RBS_VERSION_ID
8142      , PLAN_VERSION_ID
8143      , PLAN_TYPE_ID
8144      , RAW_COST
8145      , BRDN_COST
8146      , REVENUE
8147      , BILL_RAW_COST
8148      , BILL_BRDN_COST
8149      , BILL_LABOR_RAW_COST
8150      , BILL_LABOR_BRDN_COST
8151      , BILL_LABOR_HRS
8152      , EQUIPMENT_RAW_COST
8153      , EQUIPMENT_BRDN_COST
8154      , CAPITALIZABLE_RAW_COST
8155      , CAPITALIZABLE_BRDN_COST
8156      , LABOR_RAW_COST
8157      , LABOR_BRDN_COST
8158      , LABOR_HRS
8159      , LABOR_REVENUE
8160      , EQUIPMENT_HOURS
8161      , BILLABLE_EQUIPMENT_HOURS
8162      , SUP_INV_COMMITTED_COST
8163      , PO_COMMITTED_COST
8164      , PR_COMMITTED_COST
8165      , OTH_COMMITTED_COST
8166      , ACT_LABOR_HRS
8167 	   , ACT_EQUIP_HRS
8168 	   , ACT_LABOR_BRDN_COST
8169 	   , ACT_EQUIP_BRDN_COST
8173          , ACT_LABOR_RAW_COST
8170 	   , ACT_BRDN_COST
8171 	   , ACT_RAW_COST
8172 	   , ACT_REVENUE
8174          , ACT_EQUIP_RAW_COST
8175 	   , ETC_LABOR_HRS
8176 	   , ETC_EQUIP_HRS
8177 	   , ETC_LABOR_BRDN_COST
8178 	   , ETC_EQUIP_BRDN_COST
8179 	   , ETC_BRDN_COST
8180          , ETC_RAW_COST
8181          , ETC_LABOR_RAW_COST
8182          , ETC_EQUIP_RAW_COST
8183      , CUSTOM1
8184      , CUSTOM2
8185      , CUSTOM3
8186      , CUSTOM4
8187      , CUSTOM5
8188      , CUSTOM6
8189      , CUSTOM7
8190      , CUSTOM8
8191      , CUSTOM9
8192      , CUSTOM10
8193      , CUSTOM11
8194      , CUSTOM12
8195      , CUSTOM13
8196      , CUSTOM14
8197      , CUSTOM15
8198      , LINE_TYPE
8199      , TIME_DANGLING_FLAG
8200      , RATE_DANGLING_FLAG
8201      , PRG_LEVEL
8202 	)
8203    SELECT
8204        g_worker_id worker_id
8205      , a.PROJECT_ID
8206      , a.PROJECT_ORG_ID
8207      , a.PROJECT_ORGANIZATION_ID
8208      , a.PROJECT_ELEMENT_ID
8209      , a.TIME_ID
8210      , a.PERIOD_TYPE_ID
8211      , a.CALENDAR_TYPE
8212      , a.RBS_AGGR_LEVEL
8213      , a.WBS_ROLLUP_FLAG
8214      , a.PRG_ROLLUP_FLAG
8215      , a.CURR_RECORD_TYPE_ID
8216      , a.CURRENCY_CODE
8217      , a.RBS_ELEMENT_ID
8218      , a.RBS_VERSION_ID
8219      , a.PLAN_VERSION_ID
8220      , a.PLAN_TYPE_ID
8221      , SUM(a.RAW_COST       )
8222      , SUM(a.BRDN_COST 	)
8223      , SUM(a.REVENUE	)
8224      , SUM(a.BILL_RAW_COST )
8225      , SUM(a.BILL_BRDN_COST )
8226      , SUM(a.BILL_LABOR_RAW_COST )
8227      , SUM(a.BILL_LABOR_BRDN_COST )
8228      , SUM(a.BILL_LABOR_HRS )
8229      , SUM(a.EQUIPMENT_RAW_COST )
8230      , SUM(a.EQUIPMENT_BRDN_COST )
8231      , SUM(a.CAPITALIZABLE_RAW_COST )
8232      , SUM(a.CAPITALIZABLE_BRDN_COST )
8233      , SUM(a.LABOR_RAW_COST )
8234      , SUM(a.LABOR_BRDN_COST)
8235      , SUM(a.LABOR_HRS )
8236      , SUM(a.LABOR_REVENUE )
8237      , SUM(a.EQUIPMENT_HOURS )
8238      , SUM(a.BILLABLE_EQUIPMENT_HOURS)
8239      , SUM(a.SUP_INV_COMMITTED_COST)
8240      , SUM(a.PO_COMMITTED_COST )
8241      , SUM(a.PR_COMMITTED_COST )
8242      , SUM(a.OTH_COMMITTED_COST)
8243        , SUM(a.ACT_LABOR_HRS)
8244 	   , SUM(a.ACT_EQUIP_HRS)
8245 	   , SUM(a.ACT_LABOR_BRDN_COST)
8246 	   , SUM(a.ACT_EQUIP_BRDN_COST)
8247 	   , SUM(a.ACT_BRDN_COST    )
8248 	   , SUM(a.ACT_RAW_COST    )
8249 	   , SUM(a.ACT_REVENUE    )
8250          , SUM(a.ACT_LABOR_RAW_COST)
8251          , SUM(a.ACT_EQUIP_RAW_COST)
8252 	   , SUM(a.ETC_LABOR_HRS         )
8253 	   , SUM(a.ETC_EQUIP_HRS        )
8254 	   , SUM(a.ETC_LABOR_BRDN_COST )
8255 	   , SUM(a.ETC_EQUIP_BRDN_COST)
8256 	   , SUM(a.ETC_BRDN_COST )
8257          , SUM(a.ETC_RAW_COST)
8258          , SUM(a.ETC_LABOR_RAW_COST)
8259          , SUM(a.ETC_EQUIP_RAW_COST)
8260      , SUM(a.CUSTOM1	)
8261      , SUM(a.CUSTOM2	)
8262      , SUM(a.CUSTOM3	)
8263      , SUM(a.CUSTOM4	)
8264      , SUM(a.CUSTOM5	)
8265      , SUM(a.CUSTOM6	)
8266      , SUM(a.CUSTOM7	)
8267      , SUM(a.CUSTOM8	)
8268      , SUM(a.CUSTOM9	)
8269      , SUM(a.CUSTOM10	)
8270      , SUM(a.CUSTOM11	)
8271      , SUM(a.CUSTOM12	)
8272      , SUM(a.CUSTOM13	)
8273      , SUM(a.CUSTOM14	)
8274      , SUM(a.CUSTOM15	)
8275 	 , a.LINE_TYPE
8276 	 , a.TIME_DANGLING_FLAG
8277 	 , a.RATE_DANGLING_FLAG
8278        , g_default_prg_level prg_level
8279    FROM (
8280    SELECT
8281          fact.project_id  project_id
8282    	 , fact.project_ORG_ID project_ORG_ID
8283    	 , fact.project_ORGANIZATION_ID project_ORGANIZATION_ID
8284      -- , fact.PARTITION_ID PARTITION_ID
8285    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
8286    	 , pa_cal.cal_period_id TIME_ID
8287    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
8288    	 , DECODE(fact.CALENDAR_TYPE, 'P', 'G', 'G', 'P') CALENDAR_TYPE
8289      , fact.RBS_AGGR_LEVEL
8290      , fact.WBS_ROLLUP_FLAG
8291      , fact.PRG_ROLLUP_FLAG
8292    	 , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
8293    	 , fact.CURRENCY_CODE CURRENCY_CODE
8294    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
8295    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
8296    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
8297 	 , fact.PLAN_TYPE_ID  PLAN_TYPE_ID
8298 	 , ROUND (
8299              NVL (
8300             DECODE (
8301                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8302 			  , '00'   , fact.raw_cost
8303 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8304 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8305 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8306 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8307 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8308 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8309 			  , '0-1'  , fact.raw_cost
8310 			  , '1-1'  , fact.raw_cost
8311 			  , 0  ) -- end decode
8312 			    , 0  ) -- end nvl
8313 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8314 						* PJI_UTILS.GET_MAU (fact.currency_code)	raw_cost
8315 	 , ROUND (
8316              NVL (
8317             DECODE (
8321 			 , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8318                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8319 			 , '00'   , fact.brdn_cost
8320 			 , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8322 			 , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8323 			 , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8324 			 , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8325 			 , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8326 			 , '0-1'  , fact.brdn_cost
8327 			 , '1-1'  , fact.brdn_cost
8328 			 , 0  ) -- end decode
8329 			  , 0  ) -- end nvl
8330 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8331 						* PJI_UTILS.GET_MAU (fact.currency_code)	brdn_cost
8332 	 , ROUND (
8333              NVL (
8334             DECODE (
8335                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8336 			 , '00'   , fact.revenue
8337 			 , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8338 			 , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8339 			 , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8340 			 , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8341 			 , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8342 			 , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8343 			 , '0-1'  , fact.revenue
8344 			 , '1-1'  , fact.revenue
8345 			 , 0  ) -- end decode
8346 			  , 0  ) -- end nvl
8347 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8348 						* PJI_UTILS.GET_MAU (fact.currency_code)	revenue
8349 	 , ROUND (
8350              NVL (
8351             DECODE (
8352                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8353 			  , '00'   , fact.bill_raw_cost
8354 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8355 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8356 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8357 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8358 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8359 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8360 			  , '0-1'  , fact.bill_raw_cost
8361 			  , '1-1'  , fact.bill_raw_cost
8362 			  , 0  ) -- end decode
8363 			    , 0  ) -- end nvl
8364 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8365 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_raw_cost
8366 	 , ROUND (
8367              NVL (
8368             DECODE (
8369                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8370 			  , '00'   , fact.bill_brdn_cost
8371 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8372 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8373 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8374 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8375 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8376 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8377 			  , '0-1'  , fact.bill_brdn_cost
8378 			  , '1-1'  , fact.bill_brdn_cost
8379 			  , 0  ) -- end decode
8380 			    , 0  ) -- end nvl
8381 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8382 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_brdn_cost
8383 	 , ROUND (
8384              NVL (
8385             DECODE (
8386                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8387 			  , '00'   , fact.bill_labor_raw_cost
8388 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8389 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8390 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8391 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8392 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8396 			  , 0  ) -- end decode
8393 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8394 			  , '0-1'  , fact.bill_labor_raw_cost
8395 			  , '1-1'  , fact.bill_labor_raw_cost
8397 			    , 0  ) -- end nvl
8398 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8399 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_raw_cost
8400 	 , ROUND (
8401              NVL (
8402             DECODE (
8403                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8404 			  , '00'   , fact.bill_labor_brdn_cost
8405 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8406 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8407 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8408 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8409 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8410 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8411 			  , '0-1'  , fact.bill_labor_brdn_cost
8412 			  , '1-1'  , fact.bill_labor_brdn_cost
8413 			  , 0  ) -- end decode
8414 			    , 0  ) -- end nvl
8415 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8416 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_brdn_cost
8417 	 , ROUND (
8418              NVL (
8419             DECODE (
8420                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8421 			  , '00'   , fact.bill_labor_hrs
8422 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8423 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8424 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8425 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8426 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8427 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8428 			  , '0-1'  , fact.bill_labor_hrs
8429 			  , '1-1'  , fact.bill_labor_hrs
8430 			  , 0  ) -- end decode
8431 			    , 0  ) -- end nvl
8432 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8433 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_hrs
8434 	 , ROUND (
8435              NVL (
8436             DECODE (
8437                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8438 			  , '00'   , fact.equipment_raw_cost
8439 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8440 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8441 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8442 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8443 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8444 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8445 			  , '0-1'  , fact.equipment_raw_cost
8446 			  , '1-1'  , fact.equipment_raw_cost
8447 			  , 0  ) -- end decode
8448 			    , 0  ) -- end nvl
8449 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8450 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_raw_cost
8451 	 , ROUND (
8452              NVL (
8453             DECODE (
8454                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8455 			  , '00'   , fact.equipment_brdn_cost
8456 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8457 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8458 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8459 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8460 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8461 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8462 			  , '0-1'  , fact.equipment_brdn_cost
8463 			  , '1-1'  , fact.equipment_brdn_cost
8464 			  , 0  ) -- end decode
8465 			    , 0  ) -- end nvl
8466 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8467 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_brdn_cost
8468 	 , ROUND (
8469              NVL (
8470             DECODE (
8471                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8475 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8472 			  , '00'   , fact.capitalizable_raw_cost
8473 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8474 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8476 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8477 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8478 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8479 			  , '0-1'  , fact.capitalizable_raw_cost
8480 			  , '1-1'  , fact.capitalizable_raw_cost
8481 			  , 0  ) -- end decode
8482 			    , 0  ) -- end nvl
8483 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8484 						* PJI_UTILS.GET_MAU (fact.currency_code)	capitalizable_raw_cost
8485 	 , ROUND (
8486              NVL (
8487             DECODE (
8488                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8489 			  , '00'   , fact.capitalizable_brdn_cost
8490 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8491 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8492 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8493 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8494 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8495 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8496 			  , '0-1'  , fact.capitalizable_brdn_cost
8497 			  , '1-1'  , fact.capitalizable_brdn_cost
8498 			  , 0  ) -- end decode
8499 			    , 0  ) -- end nvl
8500 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8501 						* PJI_UTILS.GET_MAU (fact.currency_code)	capitalizable_brdn_cost
8502 	 , ROUND (
8503              NVL (
8504             DECODE (
8505                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8506 			  , '00'   , fact.labor_raw_cost
8507 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8508 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8509 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8510 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8511 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8512 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8513 			  , '0-1'  , fact.labor_raw_cost
8514 			  , '1-1'  , fact.labor_raw_cost
8515 			  , 0  ) -- end decode
8516 			    , 0  ) -- end nvl
8517 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8518 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_raw_cost
8519 	 , ROUND (
8520              NVL (
8521             DECODE (
8522                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8523 			  , '00'   , fact.labor_brdn_cost
8524 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8525 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8526 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8527 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8528 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8529 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8530 			  , '0-1'  , fact.labor_brdn_cost
8531 			  , '1-1'  , fact.labor_brdn_cost
8532 			  , 0  ) -- end decode
8533 			    , 0  ) -- end nvl
8534 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8535 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_brdn_cost
8536 	 , ROUND (
8537              NVL (
8538             DECODE (
8539                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8540 			  , '00'   , fact.labor_hrs
8541 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8542 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8543 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8544 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8548 			  , '1-1'  , fact.labor_hrs
8545 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8546 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8547 			  , '0-1'  , fact.labor_hrs
8549 			  , 0  ) -- end decode
8550 			    , 0  ) -- end nvl
8551 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8552 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_hrs
8553 	 , ROUND (
8554              NVL (
8555             DECODE (
8556                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8557 			  , '00'   , fact.labor_revenue
8558 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8559 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8560 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8561 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8562 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8563 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8564 			  , '0-1'  , fact.labor_revenue
8565 			  , '1-1'  , fact.labor_revenue
8566 			  , 0  ) -- end decode
8567 			    , 0  ) -- end nvl
8568 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8569 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_revenue
8570 	 , ROUND (
8571              NVL (
8572             DECODE (
8573                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8574 			  , '00'   , fact.equipment_hours
8575 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8576 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8577 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8578 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8579 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8580 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8581 			  , '0-1'  , fact.equipment_hours
8582 			  , '1-1'  , fact.equipment_hours
8583 			  , 0  ) -- end decode
8584 			    , 0  ) -- end nvl
8585 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8586 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_hours
8587 	 , ROUND (
8588              NVL (
8589             DECODE (
8590                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8591 			  , '00'   , fact.billable_equipment_hours
8592 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8593 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8594 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8595 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8596 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8597 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8598 			  , '0-1'  , fact.billable_equipment_hours
8599 			  , '1-1'  , fact.billable_equipment_hours
8600 			  , 0  ) -- end decode
8601 			    , 0  ) -- end nvl
8602 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8603 						* PJI_UTILS.GET_MAU (fact.currency_code)	billable_equipment_hours
8604 	 , ROUND (
8605              NVL (
8606             DECODE (
8607                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8608 			  , '00'   , fact.sup_inv_committed_cost
8609 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8610 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8611 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8612 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8613 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8614 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8615 			  , '0-1'  , fact.sup_inv_committed_cost
8616 			  , '1-1'  , fact.sup_inv_committed_cost
8617 			  , 0  ) -- end decode
8618 			    , 0  ) -- end nvl
8619 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8620 						* PJI_UTILS.GET_MAU (fact.currency_code)	sup_inv_committed_cost
8621 	 , ROUND (
8622              NVL (
8623             DECODE (
8627 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8624                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8625 			  , '00'   , fact.po_committed_cost
8626 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8628 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8629 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8630 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8631 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8632 			  , '0-1'  , fact.po_committed_cost
8633 			  , '1-1'  , fact.po_committed_cost
8634 			  , 0  ) -- end decode
8635 			    , 0  ) -- end nvl
8636 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8637 						* PJI_UTILS.GET_MAU (fact.currency_code)	po_committed_cost
8638 	 , ROUND (
8639              NVL (
8640             DECODE (
8641                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8642 			  , '00'   , fact.pr_committed_cost
8643 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8644 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8645 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8646 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8647 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8648 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8649 			  , '0-1'  , fact.pr_committed_cost
8650 			  , '1-1'  , fact.pr_committed_cost
8651 			  , 0  ) -- end decode
8652 			    , 0  ) -- end nvl
8653 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8654 						* PJI_UTILS.GET_MAU (fact.currency_code)	pr_committed_cost
8655 	 , ROUND (
8656              NVL (
8657             DECODE (
8658                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8659 			  , '00'   , fact.oth_committed_cost
8660 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8661 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8662 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8663 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8664 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8665 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8666 			  , '0-1'  , fact.oth_committed_cost
8667 			  , '1-1'  , fact.oth_committed_cost
8668 			  , 0  ) -- end decode
8669 			    , 0  ) -- end nvl
8670 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8671 						* PJI_UTILS.GET_MAU (fact.currency_code)	oth_committed_cost
8672 	 , ROUND (
8673              NVL (
8674             DECODE (
8675                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8676 			  , '00'   , fact.ACT_LABOR_HRS
8677 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8678 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8679 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8680 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8681 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8682 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8683 			  , '0-1'  , fact.ACT_LABOR_HRS
8684 			  , '1-1'  , fact.ACT_LABOR_HRS
8685 			  , 0  ) -- end decode
8686 			    , 0  ) -- end nvl
8687 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8688 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_HRS
8689 	 , ROUND (
8690              NVL (
8691             DECODE (
8692                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8693 			  , '00'   , fact.ACT_EQUIP_HRS
8694 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8695 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8696 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8697 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8698 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8699 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8700 			  , '0-1'  , fact.ACT_EQUIP_HRS
8701 			  , '1-1'  , fact.ACT_EQUIP_HRS
8702 			  , 0  ) -- end decode
8703 			    , 0  ) -- end nvl
8704 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8705 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_HRS
8706 	 , ROUND (
8707              NVL (
8708             DECODE (
8709                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8710 			  , '00'   , fact.ACT_LABOR_BRDN_COST
8711 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8712 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8713 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8714 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8715 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8716 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8717 			  , '0-1'  , fact.ACT_LABOR_BRDN_COST
8718 			  , '1-1'  , fact.ACT_LABOR_BRDN_COST
8719 			  , 0  ) -- end decode
8720 			    , 0  ) -- end nvl
8721 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8722 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_BRDN_COST
8723 	 , ROUND (
8724              NVL (
8725             DECODE (
8726                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8727 			  , '00'   , fact.ACT_EQUIP_BRDN_COST
8728 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8729 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8730 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8731 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8732 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8733 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8734 			  , '0-1'  , fact.ACT_EQUIP_BRDN_COST
8735 			  , '1-1'  , fact.ACT_EQUIP_BRDN_COST
8736 			  , 0  ) -- end decode
8737 			    , 0  ) -- end nvl
8738 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8739 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_BRDN_COST
8740 	 , ROUND (
8741              NVL (
8742             DECODE (
8743                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8744 			  , '00'   , fact.ACT_BRDN_COST
8745 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8746 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8747 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8748 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8749 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8750 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8751 			  , '0-1'  , fact.ACT_BRDN_COST
8752 			  , '1-1'  , fact.ACT_BRDN_COST
8753 			  , 0  ) -- end decode
8754 			    , 0  ) -- end nvl
8755 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8756 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_BRDN_COST
8757 	 , ROUND (
8758              NVL (
8759             DECODE (
8760                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8761 			  , '00'   , fact.ACT_RAW_COST
8762 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8763 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8764 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8765 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8766 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8767 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8768 			  , '0-1'  , fact.ACT_RAW_COST
8769 			  , '1-1'  , fact.ACT_RAW_COST
8770 			  , 0  ) -- end decode
8771 			    , 0  ) -- end nvl
8772 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8773 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_RAW_COST
8774 	 , ROUND (
8775              NVL (
8776             DECODE (
8777                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8778 			  , '00'   , fact.ACT_REVENUE
8779 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8780 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8781 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8782 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8783 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8784 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8785 			  , '0-1'  , fact.ACT_REVENUE
8786 			  , '1-1'  , fact.ACT_REVENUE
8787 			  , 0  ) -- end decode
8788 			    , 0  ) -- end nvl
8789 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8790 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_REVENUE
8791 	 , ROUND (
8792              NVL (
8793             DECODE (
8794                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8795 			  , '00'   , fact.ACT_LABOR_RAW_COST
8796 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8797 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8798 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8799 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8800 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8801 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8802 			  , '0-1'  , fact.ACT_LABOR_RAW_COST
8803 			  , '1-1'  , fact.ACT_LABOR_RAW_COST
8804 			  , 0  ) -- end decode
8805 			    , 0  ) -- end nvl
8806 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8807 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_RAW_COST
8808 	 , ROUND (
8809              NVL (
8810             DECODE (
8811                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8812 			  , '00'   , fact.ACT_EQUIP_RAW_COST
8813 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8814 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8815 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8816 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8817 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8818 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8819 			  , '0-1'  , fact.ACT_EQUIP_RAW_COST
8820 			  , '1-1'  , fact.ACT_EQUIP_RAW_COST
8821 			  , 0  ) -- end decode
8822 			    , 0  ) -- end nvl
8823 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8824 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_RAW_COST
8825 	 , ROUND (
8826              NVL (
8827             DECODE (
8828                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8829 			  , '00'   , fact.ETC_LABOR_HRS
8830 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8831 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8832 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8833 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8834 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8838 			  , 0  ) -- end decode
8835 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8836 			  , '0-1'  , fact.ETC_LABOR_HRS
8837 			  , '1-1'  , fact.ETC_LABOR_HRS
8839 			    , 0  ) -- end nvl
8840 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8841 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_HRS
8842 	 , ROUND (
8843              NVL (
8844             DECODE (
8845                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8846 			  , '00'   , fact.ETC_EQUIP_HRS
8847 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8848 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8849 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8850 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8851 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8852 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8853 			  , '0-1'  , fact.ETC_EQUIP_HRS
8854 			  , '1-1'  , fact.ETC_EQUIP_HRS
8855 			  , 0  ) -- end decode
8856 			    , 0  ) -- end nvl
8857 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8858 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_HRS
8859 	 , ROUND (
8860              NVL (
8861             DECODE (
8862                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8863 			  , '00'   , fact.ETC_LABOR_BRDN_COST
8864 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8865 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8866 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8867 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8868 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8869 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8870 			  , '0-1'  , fact.ETC_LABOR_BRDN_COST
8871 			  , '1-1'  , fact.ETC_LABOR_BRDN_COST
8872 			  , 0  ) -- end decode
8873 			    , 0  ) -- end nvl
8874 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8875 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_BRDN_COST
8876 	 , ROUND (
8877              NVL (
8878             DECODE (
8879                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8880 			  , '00'   , fact.ETC_EQUIP_BRDN_COST
8881 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8882 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8883 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8884 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8885 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8886 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8887 			  , '0-1'  , fact.ETC_EQUIP_BRDN_COST
8888 			  , '1-1'  , fact.ETC_EQUIP_BRDN_COST
8889 			  , 0  ) -- end decode
8890 			    , 0  ) -- end nvl
8891 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8892 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_BRDN_COST
8893 	 , ROUND (
8894              NVL (
8895             DECODE (
8896                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8897 			  , '00'   , fact.ETC_BRDN_COST
8898 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8899 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8900 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8901 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8902 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8903 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8904 			  , '0-1'  , fact.ETC_BRDN_COST
8905 			  , '1-1'  , fact.ETC_BRDN_COST
8906 			  , 0  ) -- end decode
8907 			    , 0  ) -- end nvl
8908 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8909 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_BRDN_COST
8910 	 , ROUND (
8911              NVL (
8912             DECODE (
8913                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8914 			  , '00'   , fact.ETC_RAW_COST
8918 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8915 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8916 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8917 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8919 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8920 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8921 			  , '0-1'  , fact.ETC_RAW_COST
8922 			  , '1-1'  , fact.ETC_RAW_COST
8923 			  , 0  ) -- end decode
8924 			    , 0  ) -- end nvl
8925 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8926 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_RAW_COST
8927 	 , ROUND (
8928              NVL (
8929             DECODE (
8930                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8931 			  , '00'   , fact.ETC_LABOR_RAW_COST
8932 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8933 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8934 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8935 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8936 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8937 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8938 			  , '0-1'  , fact.ETC_LABOR_RAW_COST
8939 			  , '1-1'  , fact.ETC_LABOR_RAW_COST
8940 			  , 0  ) -- end decode
8941 			    , 0  ) -- end nvl
8942 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8943 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_RAW_COST
8944 	 , ROUND (
8945              NVL (
8946             DECODE (
8947                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8948 			  , '00'   , fact.ETC_EQUIP_RAW_COST
8949 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8950 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8951 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8952 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8953 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8954 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8955 			  , '0-1'  , fact.ETC_EQUIP_RAW_COST
8956 			  , '1-1'  , fact.ETC_EQUIP_RAW_COST
8957 			  , 0  ) -- end decode
8958 			    , 0  ) -- end nvl
8959 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8960 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_RAW_COST
8961 	 , ROUND (
8962              NVL (
8963             DECODE (
8964                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8965 			  , '00'   , fact.custom1
8966 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8967 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8968 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8969 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8970 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8971 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8972 			  , '0-1'  , fact.custom1
8973 			  , '1-1'  , fact.custom1
8974 			  , 0  ) -- end decode
8975 			    , 0  ) -- end nvl
8976 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8977 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom1
8978 	 , ROUND (
8979              NVL (
8980             DECODE (
8981                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8982 			  , '00'   , fact.custom2
8983 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8984 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8985 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8986 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8987 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8991 			  , 0  ) -- end decode
8988 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
8989 			  , '0-1'  , fact.custom2
8990 			  , '1-1'  , fact.custom2
8992 			    , 0  ) -- end nvl
8993 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
8994 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom2
8995 	 , ROUND (
8996              NVL (
8997             DECODE (
8998                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
8999 			  , '00'   , fact.custom3
9000 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9001 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9002 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9003 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9004 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9005 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9006 			  , '0-1'  , fact.custom3
9007 			  , '1-1'  , fact.custom3
9008 			  , 0  ) -- end decode
9009 			    , 0  ) -- end nvl
9010 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9011 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom3
9012 	 , ROUND (
9013              NVL (
9014             DECODE (
9015                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9016 			  , '00'   , fact.custom4
9017 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9018 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9019 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9020 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9021 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9022 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9023 			  , '0-1'  , fact.custom4
9024 			  , '1-1'  , fact.custom4
9025 			  , 0  ) -- end decode
9026 			    , 0  ) -- end nvl
9027 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9028 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom4
9029 	 , ROUND (
9030              NVL (
9031             DECODE (
9032                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9033 			  , '00'   , fact.custom5
9034 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9035 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9036 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9037 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9038 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9039 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9040 			  , '0-1'  , fact.custom5
9041 			  , '1-1'  , fact.custom5
9042 			  , 0  ) -- end decode
9043 			    , 0  ) -- end nvl
9044 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9045 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom5
9046 	 , ROUND (
9047              NVL (
9048             DECODE (
9049                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9050 			  , '00'   , fact.custom6
9051 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9052 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9053 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9054 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9055 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9056 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9057 			  , '0-1'  , fact.custom6
9058 			  , '1-1'  , fact.custom6
9059 			  , 0  ) -- end decode
9060 			    , 0  ) -- end nvl
9061 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9062 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom6
9063 	 , ROUND (
9064              NVL (
9065             DECODE (
9066                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9067 			  , '00'   , fact.custom7
9071 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9068 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9069 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9070 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9072 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9073 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9074 			  , '0-1'  , fact.custom7
9075 			  , '1-1'  , fact.custom7
9076 			  , 0  ) -- end decode
9077 			    , 0  ) -- end nvl
9078 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9079 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom7
9080 	 , ROUND (
9081              NVL (
9082             DECODE (
9083                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9084 			  , '00'   , fact.custom8
9085 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9086 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9087 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9088 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9089 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9090 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9091 			  , '0-1'  , fact.custom8
9092 			  , '1-1'  , fact.custom8
9093 			  , 0  ) -- end decode
9094 			    , 0  ) -- end nvl
9095 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9096 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom8
9097 	 , ROUND (
9098              NVL (
9099             DECODE (
9100                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9101 			  , '00'   , fact.custom9
9102 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9103 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9104 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9105 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9106 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9107 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9108 			  , '0-1'  , fact.custom9
9109 			  , '1-1'  , fact.custom9
9110 			  , 0  ) -- end decode
9111 			    , 0  ) -- end nvl
9112 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9113 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom9
9114 	 , ROUND (
9115              NVL (
9116             DECODE (
9117                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9118 			  , '00'   , fact.custom10
9119 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9120 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9121 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9122 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9123 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9124 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9125 			  , '0-1'  , fact.custom10
9126 			  , '1-1'  , fact.custom10
9127 			  , 0  ) -- end decode
9128 			    , 0  ) -- end nvl
9129 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9130 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom10
9131 	 , ROUND (
9132              NVL (
9133             DECODE (
9134                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9135 			  , '00'   , fact.custom11
9136 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9137 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9138 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9139 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9140 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9141 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9142 			  , '0-1'  , fact.custom11
9143 			  , '1-1'  , fact.custom11
9144 			  , 0  ) -- end decode
9148 	 , ROUND (
9145 			    , 0  ) -- end nvl
9146 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9147 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom11
9149              NVL (
9150             DECODE (
9151                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9152 			  , '00'   , fact.custom12
9153 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9154 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9155 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9156 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9157 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9158 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9159 			  , '0-1'  , fact.custom12
9160 			  , '1-1'  , fact.custom12
9161 			  , 0  ) -- end decode
9162 			    , 0  ) -- end nvl
9163 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9164 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom12
9165 	 , ROUND (
9166              NVL (
9167             DECODE (
9168                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9169 			  , '00'   , fact.custom13
9170 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9171 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9172 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9173 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9174 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9175 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9176 			  , '0-1'  , fact.custom13
9177 			  , '1-1'  , fact.custom13
9178 			  , 0  ) -- end decode
9179 			    , 0  ) -- end nvl
9180 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9181 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom13
9182 	 , ROUND (
9183              NVL (
9184             DECODE (
9185                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9186 			  , '00'   , fact.custom14
9187 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9188 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9189 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9190 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9191 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9192 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9193 			  , '0-1'  , fact.custom14
9194 			  , '1-1'  , fact.custom14
9195 			  , 0  ) -- end decode
9196 			    , 0  ) -- end nvl
9197 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9198 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom14
9199 	 , ROUND (
9200              NVL (
9201             DECODE (
9202                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9203 			  , '00'   , fact.custom15
9204 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9205 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9206 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9207 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9208 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9209 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9210 			  , '0-1'  , fact.custom15
9211 			  , '1-1'  , fact.custom15
9212 			  , 0  ) -- end decode
9213 			    , 0  ) -- end nvl
9214 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9215 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom15
9216      , 'CF'   line_type
9217 	 , fact.time_dangling_flag time_dangling_flag
9218 	 , fact.rate_dangling_flag rate_dangling_flag
9219                 FROM   pji_fp_aggr_pjp1_t fact
9220         , pji_time_cal_period  non_pa_cal
9221    	 , pji_org_extr_info  orginfo
9222    	 , pji_time_cal_period  pa_cal
9223        , pji_fm_extr_plnver3_t  ver
9224    WHERE  1=1
9225       AND fact.CALENDAR_TYPE <> p_calendar_type
9226       AND fact.worker_id = g_worker_id
9227       AND fact.CALENDAR_TYPE IN ('P', 'G')
9231       AND (
9228       AND non_pa_cal.cal_period_id = fact.time_id
9229       AND orginfo.org_id = fact.PROJECT_ORG_ID
9230       AND DECODE(fact.calendar_type, 'P', orginfo.gl_calendar_id, 'G', orginfo.pa_calendar_id) = pa_cal.calendar_id
9232 	       ( pa_cal.start_date >= non_pa_cal.start_date  AND pa_cal.end_date <= non_pa_cal.end_date )
9233 	    OR ( pa_cal.start_date <= non_pa_cal.start_date  AND pa_cal.end_date >= non_pa_cal.end_date )
9234 	    OR ( pa_cal.start_date <= non_pa_cal.start_date  AND pa_cal.end_date <= non_pa_cal.end_date AND pa_cal.end_date >= non_pa_cal.start_date )
9235 	    OR ( pa_cal.start_date >= non_pa_cal.start_date  AND pa_cal.end_date >= non_pa_cal.end_date AND pa_cal.start_date <= non_pa_cal.end_date )
9236           )
9237 	AND fact.time_dangling_flag IS NULL
9238 	AND fact.rate_dangling_flag IS NULL
9239       AND fact.period_type_id = 32
9240       AND fact.line_type like 'OF%'
9241       AND fact.plan_version_id = ver.plan_version_id
9242       AND ver.wp_flag = 'N'
9243       AND ver.baselined_flag = 'Y'
9244 	-- AND (ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
9245       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
9246 	  ) a
9247 	  GROUP BY
9248 	   a.PROJECT_ID
9249      , a.PROJECT_ORG_ID
9250      , a.PROJECT_ORGANIZATION_ID
9251      , a.PROJECT_ELEMENT_ID
9252      , a.TIME_ID
9253      , a.PERIOD_TYPE_ID
9254      , a.CALENDAR_TYPE
9255      , a.RBS_AGGR_LEVEL
9256      , a.WBS_ROLLUP_FLAG
9257      , a.PRG_ROLLUP_FLAG
9258      , a.CURR_RECORD_TYPE_ID
9259      , a.CURRENCY_CODE
9260      , a.RBS_ELEMENT_ID
9261      , a.RBS_VERSION_ID
9262      , a.PLAN_VERSION_ID
9263      , a.PLAN_TYPE_ID
9264 	 , a.LINE_TYPE
9265 	 , a.TIME_DANGLING_FLAG
9266 	 , a.RATE_DANGLING_FLAG;
9267   End for 4005006*/
9268 
9269     INSERT INTO pji_fp_aggr_pjp1_t
9270     (
9271        worker_id
9272      , PROJECT_ID
9273      , PROJECT_ORG_ID
9274      , PROJECT_ORGANIZATION_ID
9275      -- , PARTITION_ID
9276      , PROJECT_ELEMENT_ID
9277      , TIME_ID
9278      , PERIOD_TYPE_ID
9279      , CALENDAR_TYPE
9280      , RBS_AGGR_LEVEL
9281      , WBS_ROLLUP_FLAG
9282      , PRG_ROLLUP_FLAG
9283      , CURR_RECORD_TYPE_ID
9284      , CURRENCY_CODE
9285      , RBS_ELEMENT_ID
9286      , RBS_VERSION_ID
9287      , PLAN_VERSION_ID
9288      , PLAN_TYPE_ID
9289      , RAW_COST
9290      , BRDN_COST
9291      , REVENUE
9292      , BILL_RAW_COST
9293      , BILL_BRDN_COST
9294      , BILL_LABOR_RAW_COST
9295      , BILL_LABOR_BRDN_COST
9296      , BILL_LABOR_HRS
9297      , EQUIPMENT_RAW_COST
9298      , EQUIPMENT_BRDN_COST
9299      , CAPITALIZABLE_RAW_COST
9300      , CAPITALIZABLE_BRDN_COST
9301      , LABOR_RAW_COST
9302      , LABOR_BRDN_COST
9303      , LABOR_HRS
9304      , LABOR_REVENUE
9305      , EQUIPMENT_HOURS
9306      , BILLABLE_EQUIPMENT_HOURS
9307      , SUP_INV_COMMITTED_COST
9308      , PO_COMMITTED_COST
9309      , PR_COMMITTED_COST
9310      , OTH_COMMITTED_COST
9311      , ACT_LABOR_HRS
9312      , ACT_EQUIP_HRS
9313      , ACT_LABOR_BRDN_COST
9314      , ACT_EQUIP_BRDN_COST
9315      , ACT_BRDN_COST
9316      , ACT_RAW_COST
9317      , ACT_REVENUE
9318      , ACT_LABOR_RAW_COST
9319      , ACT_EQUIP_RAW_COST
9320      , ETC_LABOR_HRS
9321      , ETC_EQUIP_HRS
9322      , ETC_LABOR_BRDN_COST
9323      , ETC_EQUIP_BRDN_COST
9324      , ETC_BRDN_COST
9325      , ETC_RAW_COST
9326      , ETC_LABOR_RAW_COST
9327      , ETC_EQUIP_RAW_COST
9328      , CUSTOM1
9329      , CUSTOM2
9330      , CUSTOM3
9331      , CUSTOM4
9332      , CUSTOM5
9333      , CUSTOM6
9334      , CUSTOM7
9335      , CUSTOM8
9336      , CUSTOM9
9337      , CUSTOM10
9338      , CUSTOM11
9339      , CUSTOM12
9340      , CUSTOM13
9341      , CUSTOM14
9342      , CUSTOM15
9343      , TIME_DANGLING_FLAG
9344      , RATE_DANGLING_FLAG
9345      , PRG_LEVEL
9346      , PLAN_TYPE_CODE        /* 4471527 */
9347 	)
9348    SELECT
9349        g_worker_id worker_id
9350      , a.PROJECT_ID
9351      , a.PROJECT_ORG_ID
9352      , a.PROJECT_ORGANIZATION_ID
9353      , a.PROJECT_ELEMENT_ID
9354      , a.TIME_ID
9355      , a.PERIOD_TYPE_ID
9356      , a.CALENDAR_TYPE
9357      , a.RBS_AGGR_LEVEL
9358      , a.WBS_ROLLUP_FLAG
9359      , a.PRG_ROLLUP_FLAG
9360      , a.CURR_RECORD_TYPE_ID
9361      , a.CURRENCY_CODE
9362      , a.RBS_ELEMENT_ID
9363      , a.RBS_VERSION_ID
9364      , a.PLAN_VERSION_ID
9365      , a.PLAN_TYPE_ID
9366      , SUM(a.RAW_COST       )
9367      , SUM(a.BRDN_COST 	)
9368      , SUM(a.REVENUE	)
9369      , SUM(a.BILL_RAW_COST )
9370      , SUM(a.BILL_BRDN_COST )
9371      , SUM(a.BILL_LABOR_RAW_COST )
9372      , SUM(a.BILL_LABOR_BRDN_COST )
9373      , SUM(a.BILL_LABOR_HRS )
9374      , SUM(a.EQUIPMENT_RAW_COST )
9375      , SUM(a.EQUIPMENT_BRDN_COST )
9376      , SUM(a.CAPITALIZABLE_RAW_COST )
9377      , SUM(a.CAPITALIZABLE_BRDN_COST )
9378      , SUM(a.LABOR_RAW_COST )
9379      , SUM(a.LABOR_BRDN_COST)
9380      , SUM(a.LABOR_HRS )
9381      , SUM(a.LABOR_REVENUE )
9382      , SUM(a.EQUIPMENT_HOURS )
9383      , SUM(a.BILLABLE_EQUIPMENT_HOURS)
9384      , SUM(a.SUP_INV_COMMITTED_COST)
9385      , SUM(a.PO_COMMITTED_COST )
9386      , SUM(a.PR_COMMITTED_COST )
9387      , SUM(a.OTH_COMMITTED_COST)
9388      , SUM(a.ACT_LABOR_HRS)
9392      , SUM(a.ACT_BRDN_COST    )
9389      , SUM(a.ACT_EQUIP_HRS)
9390      , SUM(a.ACT_LABOR_BRDN_COST)
9391      , SUM(a.ACT_EQUIP_BRDN_COST)
9393      , SUM(a.ACT_RAW_COST    )
9394      , SUM(a.ACT_REVENUE    )
9395      , SUM(a.ACT_LABOR_RAW_COST)
9396      , SUM(a.ACT_EQUIP_RAW_COST)
9397      , SUM(a.ETC_LABOR_HRS         )
9398      , SUM(a.ETC_EQUIP_HRS        )
9399      , SUM(a.ETC_LABOR_BRDN_COST )
9400      , SUM(a.ETC_EQUIP_BRDN_COST)
9401      , SUM(a.ETC_BRDN_COST )
9402      , SUM(a.ETC_RAW_COST)
9403      , SUM(a.ETC_LABOR_RAW_COST)
9404      , SUM(a.ETC_EQUIP_RAW_COST)
9405      , SUM(a.CUSTOM1	)
9406      , SUM(a.CUSTOM2	)
9407      , SUM(a.CUSTOM3	)
9408      , SUM(a.CUSTOM4	)
9409      , SUM(a.CUSTOM5	)
9410      , SUM(a.CUSTOM6	)
9411      , SUM(a.CUSTOM7	)
9412      , SUM(a.CUSTOM8	)
9413      , SUM(a.CUSTOM9	)
9414      , SUM(a.CUSTOM10	)
9415      , SUM(a.CUSTOM11	)
9416      , SUM(a.CUSTOM12	)
9417      , SUM(a.CUSTOM13	)
9418      , SUM(a.CUSTOM14	)
9419      , SUM(a.CUSTOM15	)
9420      , a.TIME_DANGLING_FLAG
9421      , a.RATE_DANGLING_FLAG
9422      , g_default_prg_level prg_level
9423      , a.plan_type_code plan_type_code   /* 4471527 */
9424    FROM (
9425    SELECT
9426            fact.project_id  project_id
9427    	 , fact.project_ORG_ID project_ORG_ID
9428    	 , fact.project_ORGANIZATION_ID project_ORGANIZATION_ID
9429       -- , fact.PARTITION_ID PARTITION_ID
9430    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
9431    	 , calDet.sec_cal_period_id TIME_ID
9432    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
9433    	 , DECODE(fact.CALENDAR_TYPE, 'P', 'G', 'G', 'P') CALENDAR_TYPE
9434          , fact.RBS_AGGR_LEVEL
9435          , fact.WBS_ROLLUP_FLAG
9436          , fact.PRG_ROLLUP_FLAG
9437    	 , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
9438    	 , fact.CURRENCY_CODE CURRENCY_CODE
9439    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
9440    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
9441    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
9442 	 , fact.PLAN_TYPE_ID  PLAN_TYPE_ID
9443 	 , ROUND (nvl(fact.raw_cost,0)*calDet.factor/cur.mau)*cur.mau raw_cost
9444 	 , ROUND (nvl(fact.brdn_cost,0)*calDet.factor/cur.mau)*cur.mau brdn_cost
9445 	 , ROUND (nvl(fact.revenue,0)*calDet.factor/cur.mau)*cur.mau revenue
9446 	 , ROUND (nvl(fact.bill_raw_cost,0)*calDet.factor/cur.mau)*cur.mau bill_raw_cost
9447 	 , ROUND (nvl(fact.bill_brdn_cost,0)*calDet.factor/cur.mau)*cur.mau bill_brdn_cost
9448 	 , ROUND (nvl(fact.bill_labor_raw_cost,0)*calDet.factor/cur.mau)*cur.mau bill_labor_raw_cost
9449 	 , ROUND (nvl(fact.bill_labor_brdn_cost,0)*calDet.factor/cur.mau)*cur.mau bill_labor_brdn_cost
9450 	 , ROUND (nvl(fact.bill_labor_hrs,0)*calDet.factor/cur.mau)*cur.mau bill_labor_hrs
9451 	 , ROUND (nvl(fact.equipment_raw_cost,0)*calDet.factor/cur.mau)*cur.mau equipment_raw_cost
9452 	 , ROUND (nvl(fact.equipment_brdn_cost,0)*calDet.factor/cur.mau)*cur.mau equipment_brdn_cost
9453 	 , ROUND (nvl(fact.capitalizable_raw_cost,0)*calDet.factor/cur.mau)*cur.mau capitalizable_raw_cost
9454 	 , ROUND (nvl(fact.capitalizable_brdn_cost,0)*calDet.factor/cur.mau)*cur.mau capitalizable_brdn_cost
9455 	 , ROUND (nvl(fact.labor_raw_cost,0)*calDet.factor/cur.mau)*cur.mau labor_raw_cost
9456 	 , ROUND (nvl(fact.labor_brdn_cost,0)*calDet.factor/cur.mau)*cur.mau labor_brdn_cost
9457 	 , ROUND (nvl(fact.labor_hrs,0)*calDet.factor/cur.mau)*cur.mau labor_hrs
9458 	 , ROUND (nvl(fact.labor_revenue,0)*calDet.factor/cur.mau)*cur.mau labor_revenue
9459 	 , ROUND (nvl(fact.equipment_hours,0)*calDet.factor/cur.mau)*cur.mau equipment_hours
9460 	 , ROUND (nvl(fact.billable_equipment_hours,0)*calDet.factor/cur.mau)*cur.mau billable_equipment_hours
9461 	 , ROUND (nvl(fact.sup_inv_committed_cost,0)*calDet.factor/cur.mau)*cur.mau sup_inv_committed_cost
9462 	 , ROUND (nvl(fact.po_committed_cost,0)*calDet.factor/cur.mau)*cur.mau po_committed_cost
9463 	 , ROUND (nvl(fact.pr_committed_cost,0)*calDet.factor/cur.mau)*cur.mau pr_committed_cost
9464 	 , ROUND (nvl(fact.oth_committed_cost,0)*calDet.factor/cur.mau)*cur.mau oth_committed_cost
9465 	 , ROUND (nvl(fact.ACT_LABOR_HRS,0)*calDet.factor/cur.mau)*cur.mau ACT_LABOR_HRS
9466 	 , ROUND (nvl(fact.ACT_EQUIP_HRS,0)*calDet.factor/cur.mau)*cur.mau ACT_EQUIP_HRS
9467 	 , ROUND (nvl(fact.ACT_LABOR_BRDN_COST,0)*calDet.factor/cur.mau)*cur.mau ACT_LABOR_BRDN_COST
9468 	 , ROUND (nvl(fact.ACT_EQUIP_BRDN_COST,0)*calDet.factor/cur.mau)*cur.mau ACT_EQUIP_BRDN_COST
9469 	 , ROUND (nvl(fact.ACT_BRDN_COST,0)*calDet.factor/cur.mau)*cur.mau ACT_BRDN_COST
9470 	 , ROUND (nvl(fact.ACT_RAW_COST,0)*calDet.factor/cur.mau)*cur.mau ACT_RAW_COST
9471 	 , ROUND (nvl(fact.ACT_REVENUE,0)*calDet.factor/cur.mau)*cur.mau ACT_REVENUE
9472 	 , ROUND (nvl(fact.ACT_LABOR_RAW_COST,0)*calDet.factor/cur.mau)*cur.mau ACT_LABOR_RAW_COST
9473 	 , ROUND (nvl(fact.ACT_EQUIP_RAW_COST,0)*calDet.factor/cur.mau)*cur.mau ACT_EQUIP_RAW_COST
9474 	 , ROUND (nvl(fact.ETC_LABOR_HRS,0)*calDet.factor/cur.mau)*cur.mau ETC_LABOR_HRS
9475 	 , ROUND (nvl(fact.ETC_EQUIP_HRS,0)*calDet.factor/cur.mau)*cur.mau ETC_EQUIP_HRS
9476 	 , ROUND (nvl(fact.ETC_LABOR_BRDN_COST,0)*calDet.factor/cur.mau)*cur.mau ETC_LABOR_BRDN_COST
9477 	 , ROUND (nvl(fact.ETC_EQUIP_BRDN_COST,0)*calDet.factor/cur.mau)*cur.mau ETC_EQUIP_BRDN_COST
9478 	 , ROUND (nvl(fact.ETC_BRDN_COST,0)*calDet.factor/cur.mau)*cur.mau ETC_BRDN_COST
9479 	 , ROUND (nvl(fact.ETC_RAW_COST,0)*calDet.factor/cur.mau)*cur.mau ETC_RAW_COST
9480 	 , ROUND (nvl(fact.ETC_LABOR_RAW_COST,0)*calDet.factor/cur.mau)*cur.mau ETC_LABOR_RAW_COST
9481 	 , ROUND (nvl(fact.ETC_EQUIP_RAW_COST,0)*calDet.factor/cur.mau)*cur.mau ETC_EQUIP_RAW_COST
9482 	 , ROUND (nvl(fact.custom1,0)*calDet.factor/cur.mau)*cur.mau custom1
9483 	 , ROUND (nvl(fact.custom2,0)*calDet.factor/cur.mau)*cur.mau custom2
9484 	 , ROUND (nvl(fact.custom3,0)*calDet.factor/cur.mau)*cur.mau custom3
9485 	 , ROUND (nvl(fact.custom4,0)*calDet.factor/cur.mau)*cur.mau custom4
9489 	 , ROUND (nvl(fact.custom8,0)*calDet.factor/cur.mau)*cur.mau custom8
9486 	 , ROUND (nvl(fact.custom5,0)*calDet.factor/cur.mau)*cur.mau custom5
9487 	 , ROUND (nvl(fact.custom6,0)*calDet.factor/cur.mau)*cur.mau custom6
9488 	 , ROUND (nvl(fact.custom7,0)*calDet.factor/cur.mau)*cur.mau custom7
9490 	 , ROUND (nvl(fact.custom9,0)*calDet.factor/cur.mau)*cur.mau custom9
9491 	 , ROUND (nvl(fact.custom10,0)*calDet.factor/cur.mau)*cur.mau custom10
9492 	 , ROUND (nvl(fact.custom11,0)*calDet.factor/cur.mau)*cur.mau custom11
9493 	 , ROUND (nvl(fact.custom12,0)*calDet.factor/cur.mau)*cur.mau custom12
9494 	 , ROUND (nvl(fact.custom13,0)*calDet.factor/cur.mau)*cur.mau custom13
9495 	 , ROUND (nvl(fact.custom14,0)*calDet.factor/cur.mau)*cur.mau custom14
9496 	 , ROUND (nvl(fact.custom15,0)*calDet.factor/cur.mau)*cur.mau custom15
9497 	 , fact.time_dangling_flag time_dangling_flag
9498 	 , fact.rate_dangling_flag rate_dangling_flag
9499               , fact.plan_type_code  plan_type_code    /* 4471527 */
9500    FROM   pji_fp_aggr_pjp1_t fact,
9501          (SELECT /*+ NO_MERGE */ (LEAST(pri.end_date,sec.end_date) - Greatest(pri.start_date,sec.start_date)+1)
9502 	                      / (pri.end_date - pri.start_date+1) factor,
9503 	         ppa.project_id,
9504 	         ver.rbs_struct_Version_id rbs_struct_version_id,
9505 		 ver.plan_version_id plan_Version_id,
9506                            ver.plan_type_code   plan_type_code,   /* 4471527 */
9507 		 pri.cal_period_id pri_cal_period_id,
9508 		 sec.cal_period_id sec_cal_period_id,
9509 		 orginfo.org_id
9510 	    FROM
9511                  pji_time_cal_period_v  pri
9512                , pji_org_extr_info  orginfo
9513                , pji_time_cal_period_v  sec
9514                , pji_fm_extr_plnver3_t  ver
9515 	       , pa_projects_all ppa
9516            WHERE  1=1
9517              AND ppa.org_id=orginfo.org_id
9518              AND pri.calendar_id in (orginfo.gl_calendar_id,orginfo.pa_calendar_id)
9519              AND sec.calendar_id in (orginfo.gl_calendar_id,orginfo.pa_calendar_id)
9520              AND ppa.project_id=ver.project_id
9521              AND decode(ver.time_phased_type_code,
9522                        'P',orginfo.pa_calendar_id,'G',orginfo.gl_calendar_id)=pri.calendar_id
9523              AND decode(ver.time_phased_type_code,
9524                        'G',orginfo.pa_calendar_id,'P',orginfo.gl_calendar_id)=sec.calendar_id
9525              AND ver.wp_flag = 'N'
9526              AND ( sec.start_date <= pri.end_date AND sec.end_date >= pri.start_date )
9527              AND ver.baselined_flag = 'Y') calDet,
9528 	   (SELECT currency_code,
9529 	           decode(nvl(MINIMUM_ACCOUNTABLE_UNIT, power(10, (-1 * PRECISION))),
9530 		      null, 0.01,
9531 		         0, 1,
9532 			 nvl(MINIMUM_ACCOUNTABLE_UNIT, power(10, (-1 * PRECISION)))) mau
9533 	      FROM FND_CURRENCIES) cur
9534     WHERE 1=1
9535       AND calDet.factor > 0
9536       -- AND (calDet.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
9537       AND NVL(calDet.rbs_struct_version_id, -1) = fact.rbs_version_id
9538       AND fact.CALENDAR_TYPE <> p_calendar_type
9539       AND fact.worker_id = g_worker_id
9540       AND fact.CALENDAR_TYPE IN ('P', 'G')
9541       AND CalDet.pri_cal_period_id = fact.time_id
9542       AND calDet.org_id = fact.PROJECT_ORG_ID
9543       AND fact.time_dangling_flag IS NULL
9544       AND fact.rate_dangling_flag IS NULL
9545       AND fact.period_type_id = 32
9546       AND fact.line_type like 'OF%' -- 4518721
9547       AND fact.plan_version_id = calDet.plan_version_id
9548       AND fact.plan_type_code = calDet.plan_type_code    /* 4471527 */
9549       AND cur.currency_code = fact.currency_code
9550 	  ) a
9551 	  GROUP BY
9552 	   a.PROJECT_ID
9553      , a.PROJECT_ORG_ID
9554      , a.PROJECT_ORGANIZATION_ID
9555      , a.PROJECT_ELEMENT_ID
9556      , a.TIME_ID
9557      , a.PERIOD_TYPE_ID
9558      , a.CALENDAR_TYPE
9559      , a.RBS_AGGR_LEVEL
9560      , a.WBS_ROLLUP_FLAG
9561      , a.PRG_ROLLUP_FLAG
9562      , a.CURR_RECORD_TYPE_ID
9563      , a.CURRENCY_CODE
9564      , a.RBS_ELEMENT_ID
9565      , a.RBS_VERSION_ID
9566      , a.PLAN_VERSION_ID
9567      , a.PLAN_TYPE_ID
9568      , a.PLAN_TYPE_CODE    /* 4471527 */
9569      , a.TIME_DANGLING_FLAG
9570      , a.RATE_DANGLING_FLAG;
9571 
9572 
9573 
9574 
9575 EXCEPTION
9576   WHEN OTHERS THEN
9577     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
9578                              p_procedure_name => ' PRORATE_TO_PAGL_PGE_PJP1_D ');
9579     RAISE;
9580 END;
9581 
9582 
9583 PROCEDURE PRORATE_TO_PAGL_PGE_FPRL_D (p_calendar_type   IN   VARCHAR2 := NULL) IS
9584 BEGIN
9585 
9586     -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
9587 
9588     INSERT INTO pji_fp_aggr_pjp1_t
9589     (
9590        worker_id
9591      , PROJECT_ID
9592      , PROJECT_ORG_ID
9593      , PROJECT_ORGANIZATION_ID
9594      -- , PARTITION_ID
9595      , PROJECT_ELEMENT_ID
9596      , TIME_ID
9597      , PERIOD_TYPE_ID
9598      , CALENDAR_TYPE
9599      , RBS_AGGR_LEVEL
9600      , WBS_ROLLUP_FLAG
9601      , PRG_ROLLUP_FLAG
9602      , CURR_RECORD_TYPE_ID
9603      , CURRENCY_CODE
9604      , RBS_ELEMENT_ID
9605      , RBS_VERSION_ID
9606      , PLAN_VERSION_ID
9607      , PLAN_TYPE_ID
9608      , RAW_COST
9609      , BRDN_COST
9610      , REVENUE
9611      , BILL_RAW_COST
9612      , BILL_BRDN_COST
9613      , BILL_LABOR_RAW_COST
9614      , BILL_LABOR_BRDN_COST
9615      , BILL_LABOR_HRS
9616      , EQUIPMENT_RAW_COST
9617      , EQUIPMENT_BRDN_COST
9621      , LABOR_BRDN_COST
9618      , CAPITALIZABLE_RAW_COST
9619      , CAPITALIZABLE_BRDN_COST
9620      , LABOR_RAW_COST
9622      , LABOR_HRS
9623      , LABOR_REVENUE
9624      , EQUIPMENT_HOURS
9625      , BILLABLE_EQUIPMENT_HOURS
9626      , SUP_INV_COMMITTED_COST
9627      , PO_COMMITTED_COST
9628      , PR_COMMITTED_COST
9629      , OTH_COMMITTED_COST
9630        , ACT_LABOR_HRS
9631 	   , ACT_EQUIP_HRS
9632 	   , ACT_LABOR_BRDN_COST
9633 	   , ACT_EQUIP_BRDN_COST
9634 	   , ACT_BRDN_COST
9635 	   , ACT_RAW_COST
9636 	   , ACT_REVENUE
9637          , ACT_LABOR_RAW_COST
9638          , ACT_EQUIP_RAW_COST
9639 	   , ETC_LABOR_HRS
9640 	   , ETC_EQUIP_HRS
9641 	   , ETC_LABOR_BRDN_COST
9642 	   , ETC_EQUIP_BRDN_COST
9643 	   , ETC_BRDN_COST
9644          , ETC_RAW_COST
9645          , ETC_LABOR_RAW_COST
9646          , ETC_EQUIP_RAW_COST
9647      , CUSTOM1
9648      , CUSTOM2
9649      , CUSTOM3
9650      , CUSTOM4
9651      , CUSTOM5
9652      , CUSTOM6
9653      , CUSTOM7
9654      , CUSTOM8
9655      , CUSTOM9
9656      , CUSTOM10
9657      , CUSTOM11
9658      , CUSTOM12
9659      , CUSTOM13
9660      , CUSTOM14
9661      , CUSTOM15
9662      , LINE_TYPE
9663      , TIME_DANGLING_FLAG
9664      , RATE_DANGLING_FLAG
9665      , PRG_LEVEL
9666      , PLAN_TYPE_CODE   /* 4471527 */
9667    )
9668    SELECT
9669        g_worker_id worker_id
9670      , a.PROJECT_ID
9671      , a.PROJECT_ORG_ID
9672      , a.PROJECT_ORGANIZATION_ID
9673      , a.PROJECT_ELEMENT_ID
9674      , a.TIME_ID
9675      , a.PERIOD_TYPE_ID
9676      , a.CALENDAR_TYPE
9677      , a.RBS_AGGR_LEVEL
9678      , a.WBS_ROLLUP_FLAG
9679      , a.PRG_ROLLUP_FLAG
9680      , a.CURR_RECORD_TYPE_ID
9681      , a.CURRENCY_CODE
9682      , a.RBS_ELEMENT_ID
9683      , a.RBS_VERSION_ID
9684      , a.PLAN_VERSION_ID
9685      , a.PLAN_TYPE_ID
9686      , SUM(a.RAW_COST       )
9687      , SUM(a.BRDN_COST 	)
9688      , SUM(a.REVENUE	)
9689      , SUM(a.BILL_RAW_COST )
9690      , SUM(a.BILL_BRDN_COST )
9691      , SUM(a.BILL_LABOR_RAW_COST )
9692      , SUM(a.BILL_LABOR_BRDN_COST )
9693      , SUM(a.BILL_LABOR_HRS )
9694      , SUM(a.EQUIPMENT_RAW_COST )
9695      , SUM(a.EQUIPMENT_BRDN_COST )
9696      , SUM(a.CAPITALIZABLE_RAW_COST )
9697      , SUM(a.CAPITALIZABLE_BRDN_COST )
9698      , SUM(a.LABOR_RAW_COST )
9699      , SUM(a.LABOR_BRDN_COST)
9700      , SUM(a.LABOR_HRS )
9701      , SUM(a.LABOR_REVENUE )
9702      , SUM(a.EQUIPMENT_HOURS )
9703      , SUM(a.BILLABLE_EQUIPMENT_HOURS)
9704      , SUM(a.SUP_INV_COMMITTED_COST)
9705      , SUM(a.PO_COMMITTED_COST )
9706      , SUM(a.PR_COMMITTED_COST )
9707      , SUM(a.OTH_COMMITTED_COST)
9708        , SUM(a.ACT_LABOR_HRS)
9709 	   , SUM(a.ACT_EQUIP_HRS)
9710 	   , SUM(a.ACT_LABOR_BRDN_COST)
9711 	   , SUM(a.ACT_EQUIP_BRDN_COST)
9712 	   , SUM(a.ACT_BRDN_COST    )
9713 	   , SUM(a.ACT_RAW_COST    )
9714 	   , SUM(a.ACT_REVENUE    )
9715          , SUM(a.ACT_LABOR_RAW_COST)
9716          , SUM(a.ACT_EQUIP_RAW_COST)
9717 	   , SUM(a.ETC_LABOR_HRS         )
9718 	   , SUM(a.ETC_EQUIP_HRS        )
9719 	   , SUM(a.ETC_LABOR_BRDN_COST )
9720 	   , SUM(a.ETC_EQUIP_BRDN_COST)
9721 	   , SUM(a.ETC_BRDN_COST )
9722          , SUM(a.ETC_RAW_COST)
9723          , SUM(a.ETC_LABOR_RAW_COST)
9724          , SUM(a.ETC_EQUIP_RAW_COST)
9725      , SUM(a.CUSTOM1	)
9726      , SUM(a.CUSTOM2	)
9727      , SUM(a.CUSTOM3	)
9728      , SUM(a.CUSTOM4	)
9729      , SUM(a.CUSTOM5	)
9730      , SUM(a.CUSTOM6	)
9731      , SUM(a.CUSTOM7	)
9732      , SUM(a.CUSTOM8	)
9733      , SUM(a.CUSTOM9	)
9734      , SUM(a.CUSTOM10	)
9735      , SUM(a.CUSTOM11	)
9736      , SUM(a.CUSTOM12	)
9737      , SUM(a.CUSTOM13	)
9738      , SUM(a.CUSTOM14	)
9739      , SUM(a.CUSTOM15	)
9740 	 , a.LINE_TYPE
9741 	 , a.TIME_DANGLING_FLAG
9742 	 , a.RATE_DANGLING_FLAG
9743        , g_default_prg_level prg_level
9744        , a.plan_type_code plan_type_code    /* 4471527 */
9745    FROM (
9746    SELECT
9747          fact.project_id  project_id
9748    	 , fact.project_ORG_ID project_ORG_ID
9749    	 , fact.project_ORGANIZATION_ID project_ORGANIZATION_ID
9750      -- , fact.PARTITION_ID PARTITION_ID
9751    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
9752    	 , pa_cal.cal_period_id TIME_ID
9753    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
9754    	 , DECODE(fact.CALENDAR_TYPE, 'P', 'G', 'G', 'P') CALENDAR_TYPE
9755      , fact.RBS_AGGR_LEVEL
9756      , fact.WBS_ROLLUP_FLAG
9757      , fact.PRG_ROLLUP_FLAG
9758    	 , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
9759    	 , fact.CURRENCY_CODE CURRENCY_CODE
9760    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
9761    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
9762    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
9763 	 , fact.PLAN_TYPE_ID  PLAN_TYPE_ID
9764 	 , ROUND (
9765              NVL (
9766             DECODE (
9767                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9768 			  , '00'   , fact.raw_cost
9769 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9770 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9771 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9775 			  , '0-1'  , fact.raw_cost
9772 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9773 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9774 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9776 			  , '1-1'  , fact.raw_cost
9777 			  , 0  ) -- end decode
9778 			    , 0  ) -- end nvl
9779 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9780 						* PJI_UTILS.GET_MAU (fact.currency_code)	raw_cost
9781 	 , ROUND (
9782              NVL (
9783             DECODE (
9784                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9785 			 , '00'   , fact.brdn_cost
9786 			 , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9787 			 , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9788 			 , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9789 			 , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9790 			 , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9791 			 , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9792 			 , '0-1'  , fact.brdn_cost
9793 			 , '1-1'  , fact.brdn_cost
9794 			 , 0  ) -- end decode
9795 			  , 0  ) -- end nvl
9796 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9797 						* PJI_UTILS.GET_MAU (fact.currency_code)	brdn_cost
9798 	 , ROUND (
9799              NVL (
9800             DECODE (
9801                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9802 			 , '00'   , fact.revenue
9803 			 , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9804 			 , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9805 			 , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9806 			 , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9807 			 , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9808 			 , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9809 			 , '0-1'  , fact.revenue
9810 			 , '1-1'  , fact.revenue
9811 			 , 0  ) -- end decode
9812 			  , 0  ) -- end nvl
9813 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9814 						* PJI_UTILS.GET_MAU (fact.currency_code)	revenue
9815 	 , ROUND (
9816              NVL (
9817             DECODE (
9818                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9819 			  , '00'   , fact.bill_raw_cost
9820 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9821 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9822 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9823 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9824 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9825 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9826 			  , '0-1'  , fact.bill_raw_cost
9827 			  , '1-1'  , fact.bill_raw_cost
9828 			  , 0  ) -- end decode
9829 			    , 0  ) -- end nvl
9830 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9831 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_raw_cost
9832 	 , ROUND (
9833              NVL (
9834             DECODE (
9835                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9836 			  , '00'   , fact.bill_brdn_cost
9837 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9838 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9839 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9840 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9841 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9842 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9843 			  , '0-1'  , fact.bill_brdn_cost
9844 			  , '1-1'  , fact.bill_brdn_cost
9845 			  , 0  ) -- end decode
9846 			    , 0  ) -- end nvl
9847 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9848 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_brdn_cost
9849 	 , ROUND (
9850              NVL (
9851             DECODE (
9852                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9853 			  , '00'   , fact.bill_labor_raw_cost
9857 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9854 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9855 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9856 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9858 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9859 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9860 			  , '0-1'  , fact.bill_labor_raw_cost
9861 			  , '1-1'  , fact.bill_labor_raw_cost
9862 			  , 0  ) -- end decode
9863 			    , 0  ) -- end nvl
9864 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9865 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_raw_cost
9866 	 , ROUND (
9867              NVL (
9868             DECODE (
9869                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9870 			  , '00'   , fact.bill_labor_brdn_cost
9871 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9872 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9873 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9874 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9875 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9876 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9877 			  , '0-1'  , fact.bill_labor_brdn_cost
9878 			  , '1-1'  , fact.bill_labor_brdn_cost
9879 			  , 0  ) -- end decode
9880 			    , 0  ) -- end nvl
9881 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9882 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_brdn_cost
9883 	 , ROUND (
9884              NVL (
9885             DECODE (
9886                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9887 			  , '00'   , fact.bill_labor_hrs
9888 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9889 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9890 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9891 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9892 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9893 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9894 			  , '0-1'  , fact.bill_labor_hrs
9895 			  , '1-1'  , fact.bill_labor_hrs
9896 			  , 0  ) -- end decode
9897 			    , 0  ) -- end nvl
9898 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9899 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_hrs
9900 	 , ROUND (
9901              NVL (
9902             DECODE (
9903                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9904 			  , '00'   , fact.equipment_raw_cost
9905 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9906 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9907 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9908 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9909 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9910 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9911 			  , '0-1'  , fact.equipment_raw_cost
9912 			  , '1-1'  , fact.equipment_raw_cost
9913 			  , 0  ) -- end decode
9914 			    , 0  ) -- end nvl
9915 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9916 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_raw_cost
9917 	 , ROUND (
9918              NVL (
9919             DECODE (
9920                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9921 			  , '00'   , fact.equipment_brdn_cost
9922 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9923 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9924 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9925 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9929 			  , '1-1'  , fact.equipment_brdn_cost
9926 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9927 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9928 			  , '0-1'  , fact.equipment_brdn_cost
9930 			  , 0  ) -- end decode
9931 			    , 0  ) -- end nvl
9932 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9933 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_brdn_cost
9934 	 , ROUND (
9935              NVL (
9936             DECODE (
9937                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9938 			  , '00'   , fact.capitalizable_raw_cost
9939 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9940 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9941 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9942 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9943 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9944 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9945 			  , '0-1'  , fact.capitalizable_raw_cost
9946 			  , '1-1'  , fact.capitalizable_raw_cost
9947 			  , 0  ) -- end decode
9948 			    , 0  ) -- end nvl
9949 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9950 						* PJI_UTILS.GET_MAU (fact.currency_code)	capitalizable_raw_cost
9951 	 , ROUND (
9952              NVL (
9953             DECODE (
9954                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9955 			  , '00'   , fact.capitalizable_brdn_cost
9956 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9957 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9958 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9959 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9960 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9961 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9962 			  , '0-1'  , fact.capitalizable_brdn_cost
9963 			  , '1-1'  , fact.capitalizable_brdn_cost
9964 			  , 0  ) -- end decode
9965 			    , 0  ) -- end nvl
9966 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9967 						* PJI_UTILS.GET_MAU (fact.currency_code)	capitalizable_brdn_cost
9968 	 , ROUND (
9969              NVL (
9970             DECODE (
9971                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9972 			  , '00'   , fact.labor_raw_cost
9973 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9974 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9975 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9976 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9977 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9978 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9979 			  , '0-1'  , fact.labor_raw_cost
9980 			  , '1-1'  , fact.labor_raw_cost
9981 			  , 0  ) -- end decode
9982 			    , 0  ) -- end nvl
9983 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
9984 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_raw_cost
9985 	 , ROUND (
9986              NVL (
9987             DECODE (
9988                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
9989 			  , '00'   , fact.labor_brdn_cost
9990 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9991 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9992 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9993 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9994 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9995 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
9996 			  , '0-1'  , fact.labor_brdn_cost
9997 			  , '1-1'  , fact.labor_brdn_cost
9998 			  , 0  ) -- end decode
9999 			    , 0  ) -- end nvl
10000 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10001 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_brdn_cost
10002 	 , ROUND (
10006 			  , '00'   , fact.labor_hrs
10003              NVL (
10004             DECODE (
10005                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10007 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10008 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10009 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10010 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10011 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10012 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10013 			  , '0-1'  , fact.labor_hrs
10014 			  , '1-1'  , fact.labor_hrs
10015 			  , 0  ) -- end decode
10016 			    , 0  ) -- end nvl
10017 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10018 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_hrs
10019 	 , ROUND (
10020              NVL (
10021             DECODE (
10022                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10023 			  , '00'   , fact.labor_revenue
10024 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10025 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10026 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10027 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10028 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10029 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10030 			  , '0-1'  , fact.labor_revenue
10031 			  , '1-1'  , fact.labor_revenue
10032 			  , 0  ) -- end decode
10033 			    , 0  ) -- end nvl
10034 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10035 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_revenue
10036 	 , ROUND (
10037              NVL (
10038             DECODE (
10039                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10040 			  , '00'   , fact.equipment_hours
10041 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10042 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10043 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10044 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10045 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10046 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10047 			  , '0-1'  , fact.equipment_hours
10048 			  , '1-1'  , fact.equipment_hours
10049 			  , 0  ) -- end decode
10050 			    , 0  ) -- end nvl
10051 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10052 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_hours
10053 	 , ROUND (
10054              NVL (
10055             DECODE (
10056                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10057 			  , '00'   , fact.billable_equipment_hours
10058 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10059 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10060 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10061 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10062 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10063 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10064 			  , '0-1'  , fact.billable_equipment_hours
10065 			  , '1-1'  , fact.billable_equipment_hours
10066 			  , 0  ) -- end decode
10067 			    , 0  ) -- end nvl
10068 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10069 						* PJI_UTILS.GET_MAU (fact.currency_code)	billable_equipment_hours
10070 	 , ROUND (
10071              NVL (
10072             DECODE (
10073                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10074 			  , '00'   , fact.sup_inv_committed_cost
10075 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10076 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10077 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10081 			  , '0-1'  , fact.sup_inv_committed_cost
10078 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10079 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10080 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10082 			  , '1-1'  , fact.sup_inv_committed_cost
10083 			  , 0  ) -- end decode
10084 			    , 0  ) -- end nvl
10085 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10086 						* PJI_UTILS.GET_MAU (fact.currency_code)	sup_inv_committed_cost
10087 	 , ROUND (
10088              NVL (
10089             DECODE (
10090                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10091 			  , '00'   , fact.po_committed_cost
10092 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10093 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10094 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10095 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10096 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10097 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10098 			  , '0-1'  , fact.po_committed_cost
10099 			  , '1-1'  , fact.po_committed_cost
10100 			  , 0  ) -- end decode
10101 			    , 0  ) -- end nvl
10102 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10103 						* PJI_UTILS.GET_MAU (fact.currency_code)	po_committed_cost
10104 	 , ROUND (
10105              NVL (
10106             DECODE (
10107                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10108 			  , '00'   , fact.pr_committed_cost
10109 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10110 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10111 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10112 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10113 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10114 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10115 			  , '0-1'  , fact.pr_committed_cost
10116 			  , '1-1'  , fact.pr_committed_cost
10117 			  , 0  ) -- end decode
10118 			    , 0  ) -- end nvl
10119 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10120 						* PJI_UTILS.GET_MAU (fact.currency_code)	pr_committed_cost
10121 	 , ROUND (
10122              NVL (
10123             DECODE (
10124                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10125 			  , '00'   , fact.oth_committed_cost
10126 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10127 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10128 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10129 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10130 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10131 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10132 			  , '0-1'  , fact.oth_committed_cost
10133 			  , '1-1'  , fact.oth_committed_cost
10134 			  , 0  ) -- end decode
10135 			    , 0  ) -- end nvl
10136 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10137 						* PJI_UTILS.GET_MAU (fact.currency_code)	oth_committed_cost
10138 	 , ROUND (
10139              NVL (
10140             DECODE (
10141                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10142 			  , '00'   , fact.ACT_LABOR_HRS
10143 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10144 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10145 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10146 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10147 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10148 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10149 			  , '0-1'  , fact.ACT_LABOR_HRS
10150 			  , '1-1'  , fact.ACT_LABOR_HRS
10151 			  , 0  ) -- end decode
10152 			    , 0  ) -- end nvl
10153 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10157             DECODE (
10154 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_HRS
10155 	 , ROUND (
10156              NVL (
10158                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10159 			  , '00'   , fact.ACT_EQUIP_HRS
10160 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10161 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10162 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10163 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10164 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10165 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10166 			  , '0-1'  , fact.ACT_EQUIP_HRS
10167 			  , '1-1'  , fact.ACT_EQUIP_HRS
10168 			  , 0  ) -- end decode
10169 			    , 0  ) -- end nvl
10170 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10171 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_HRS
10172 	 , ROUND (
10173              NVL (
10174             DECODE (
10175                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10176 			  , '00'   , fact.ACT_LABOR_BRDN_COST
10177 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10178 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10179 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10180 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10181 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10182 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10183 			  , '0-1'  , fact.ACT_LABOR_BRDN_COST
10184 			  , '1-1'  , fact.ACT_LABOR_BRDN_COST
10185 			  , 0  ) -- end decode
10186 			    , 0  ) -- end nvl
10187 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10188 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_BRDN_COST
10189 	 , ROUND (
10190              NVL (
10191             DECODE (
10192                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10193 			  , '00'   , fact.ACT_EQUIP_BRDN_COST
10194 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10195 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10196 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10197 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10198 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10199 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10200 			  , '0-1'  , fact.ACT_EQUIP_BRDN_COST
10201 			  , '1-1'  , fact.ACT_EQUIP_BRDN_COST
10202 			  , 0  ) -- end decode
10203 			    , 0  ) -- end nvl
10204 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10205 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_BRDN_COST
10206 	 , ROUND (
10207              NVL (
10208             DECODE (
10209                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10210 			  , '00'   , fact.ACT_BRDN_COST
10211 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10212 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10213 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10214 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10215 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10216 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10217 			  , '0-1'  , fact.ACT_BRDN_COST
10218 			  , '1-1'  , fact.ACT_BRDN_COST
10219 			  , 0  ) -- end decode
10220 			    , 0  ) -- end nvl
10221 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10222 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_BRDN_COST
10223 	 , ROUND (
10224              NVL (
10225             DECODE (
10226                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10227 			  , '00'   , fact.ACT_RAW_COST
10228 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10229 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10233 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10230 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10231 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10232 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10234 			  , '0-1'  , fact.ACT_RAW_COST
10235 			  , '1-1'  , fact.ACT_RAW_COST
10236 			  , 0  ) -- end decode
10237 			    , 0  ) -- end nvl
10238 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10239 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_RAW_COST
10240 	 , ROUND (
10241              NVL (
10242             DECODE (
10243                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10244 			  , '00'   , fact.ACT_REVENUE
10245 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10246 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10247 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10248 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10249 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10250 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10251 			  , '0-1'  , fact.ACT_REVENUE
10252 			  , '1-1'  , fact.ACT_REVENUE
10253 			  , 0  ) -- end decode
10254 			    , 0  ) -- end nvl
10255 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10256 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_REVENUE
10257 	 , ROUND (
10258              NVL (
10259             DECODE (
10260                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10261 			  , '00'   , fact.ACT_LABOR_RAW_COST
10262 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10263 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10264 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10265 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10266 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10267 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10268 			  , '0-1'  , fact.ACT_LABOR_RAW_COST
10269 			  , '1-1'  , fact.ACT_LABOR_RAW_COST
10270 			  , 0  ) -- end decode
10271 			    , 0  ) -- end nvl
10272 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10273 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_RAW_COST
10274 	 , ROUND (
10275              NVL (
10276             DECODE (
10277                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10278 			  , '00'   , fact.ACT_EQUIP_RAW_COST
10279 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10280 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10281 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10282 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10283 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10284 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10285 			  , '0-1'  , fact.ACT_EQUIP_RAW_COST
10286 			  , '1-1'  , fact.ACT_EQUIP_RAW_COST
10287 			  , 0  ) -- end decode
10288 			    , 0  ) -- end nvl
10289 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10290 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_RAW_COST
10291 	 , ROUND (
10292              NVL (
10293             DECODE (
10294                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10295 			  , '00'   , fact.ETC_LABOR_HRS
10296 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10297 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10298 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10299 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10300 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10301 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10302 			  , '0-1'  , fact.ETC_LABOR_HRS
10303 			  , '1-1'  , fact.ETC_LABOR_HRS
10304 			  , 0  ) -- end decode
10305 			    , 0  ) -- end nvl
10309              NVL (
10306 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10307 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_HRS
10308 	 , ROUND (
10310             DECODE (
10311                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10312 			  , '00'   , fact.ETC_EQUIP_HRS
10313 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10314 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10315 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10316 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10317 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10318 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10319 			  , '0-1'  , fact.ETC_EQUIP_HRS
10320 			  , '1-1'  , fact.ETC_EQUIP_HRS
10321 			  , 0  ) -- end decode
10322 			    , 0  ) -- end nvl
10323 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10324 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_HRS
10325 	 , ROUND (
10326              NVL (
10327             DECODE (
10328                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10329 			  , '00'   , fact.ETC_LABOR_BRDN_COST
10330 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10331 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10332 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10333 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10334 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10335 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10336 			  , '0-1'  , fact.ETC_LABOR_BRDN_COST
10337 			  , '1-1'  , fact.ETC_LABOR_BRDN_COST
10338 			  , 0  ) -- end decode
10339 			    , 0  ) -- end nvl
10340 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10341 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_BRDN_COST
10342 	 , ROUND (
10343              NVL (
10344             DECODE (
10345                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10346 			  , '00'   , fact.ETC_EQUIP_BRDN_COST
10347 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10348 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10349 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10350 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10351 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10352 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10353 			  , '0-1'  , fact.ETC_EQUIP_BRDN_COST
10354 			  , '1-1'  , fact.ETC_EQUIP_BRDN_COST
10355 			  , 0  ) -- end decode
10356 			    , 0  ) -- end nvl
10357 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10358 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_BRDN_COST
10359 	 , ROUND (
10360              NVL (
10361             DECODE (
10362                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10363 			  , '00'   , fact.ETC_BRDN_COST
10364 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10365 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10366 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10367 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10368 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10369 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10370 			  , '0-1'  , fact.ETC_BRDN_COST
10371 			  , '1-1'  , fact.ETC_BRDN_COST
10372 			  , 0  ) -- end decode
10373 			    , 0  ) -- end nvl
10374 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10375 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_BRDN_COST
10376 	 , ROUND (
10377              NVL (
10378             DECODE (
10379                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10380 			  , '00'   , fact.ETC_RAW_COST
10381 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10382 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10386 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10383 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10384 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10385 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10387 			  , '0-1'  , fact.ETC_RAW_COST
10388 			  , '1-1'  , fact.ETC_RAW_COST
10389 			  , 0  ) -- end decode
10390 			    , 0  ) -- end nvl
10391 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10392 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_RAW_COST
10393 	 , ROUND (
10394              NVL (
10395             DECODE (
10396                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10397 			  , '00'   , fact.ETC_LABOR_RAW_COST
10398 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10399 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10400 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10401 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10402 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10403 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10404 			  , '0-1'  , fact.ETC_LABOR_RAW_COST
10405 			  , '1-1'  , fact.ETC_LABOR_RAW_COST
10406 			  , 0  ) -- end decode
10407 			    , 0  ) -- end nvl
10408 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10409 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_RAW_COST
10410 	 , ROUND (
10411              NVL (
10412             DECODE (
10413                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10414 			  , '00'   , fact.ETC_EQUIP_RAW_COST
10415 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10416 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10417 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10418 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10419 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10420 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10421 			  , '0-1'  , fact.ETC_EQUIP_RAW_COST
10422 			  , '1-1'  , fact.ETC_EQUIP_RAW_COST
10423 			  , 0  ) -- end decode
10424 			    , 0  ) -- end nvl
10425 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10426 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_RAW_COST
10427 	 , ROUND (
10428              NVL (
10429             DECODE (
10430                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10431 			  , '00'   , fact.custom1
10432 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10433 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10434 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10435 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10436 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10437 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10438 			  , '0-1'  , fact.custom1
10439 			  , '1-1'  , fact.custom1
10440 			  , 0  ) -- end decode
10441 			    , 0  ) -- end nvl
10442 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10443 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom1
10444 	 , ROUND (
10445              NVL (
10446             DECODE (
10447                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10448 			  , '00'   , fact.custom2
10449 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10450 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10451 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10452 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10453 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10457 			  , 0  ) -- end decode
10454 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10455 			  , '0-1'  , fact.custom2
10456 			  , '1-1'  , fact.custom2
10458 			    , 0  ) -- end nvl
10459 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10460 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom2
10461 	 , ROUND (
10462              NVL (
10463             DECODE (
10464                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10465 			  , '00'   , fact.custom3
10466 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10467 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10468 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10469 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10470 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10471 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10472 			  , '0-1'  , fact.custom3
10473 			  , '1-1'  , fact.custom3
10474 			  , 0  ) -- end decode
10475 			    , 0  ) -- end nvl
10476 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10477 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom3
10478 	 , ROUND (
10479              NVL (
10480             DECODE (
10481                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10482 			  , '00'   , fact.custom4
10483 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10484 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10485 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10486 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10487 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10488 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10489 			  , '0-1'  , fact.custom4
10490 			  , '1-1'  , fact.custom4
10491 			  , 0  ) -- end decode
10492 			    , 0  ) -- end nvl
10493 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10494 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom4
10495 	 , ROUND (
10496              NVL (
10497             DECODE (
10498                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10499 			  , '00'   , fact.custom5
10500 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10501 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10502 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10503 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10504 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10505 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10506 			  , '0-1'  , fact.custom5
10507 			  , '1-1'  , fact.custom5
10508 			  , 0  ) -- end decode
10509 			    , 0  ) -- end nvl
10510 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10511 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom5
10512 	 , ROUND (
10513              NVL (
10514             DECODE (
10515                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10516 			  , '00'   , fact.custom6
10517 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10518 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10519 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10520 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10521 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10522 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10523 			  , '0-1'  , fact.custom6
10524 			  , '1-1'  , fact.custom6
10525 			  , 0  ) -- end decode
10526 			    , 0  ) -- end nvl
10527 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10528 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom6
10529 	 , ROUND (
10530              NVL (
10531             DECODE (
10532                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10533 			  , '00'   , fact.custom7
10534 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10535 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10539 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10536 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10537 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10538 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10540 			  , '0-1'  , fact.custom7
10541 			  , '1-1'  , fact.custom7
10542 			  , 0  ) -- end decode
10543 			    , 0  ) -- end nvl
10544 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10545 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom7
10546 	 , ROUND (
10547              NVL (
10548             DECODE (
10549                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10550 			  , '00'   , fact.custom8
10551 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10552 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10553 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10554 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10555 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10556 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10557 			  , '0-1'  , fact.custom8
10558 			  , '1-1'  , fact.custom8
10559 			  , 0  ) -- end decode
10560 			    , 0  ) -- end nvl
10561 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10562 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom8
10563 	 , ROUND (
10564              NVL (
10565             DECODE (
10566                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10567 			  , '00'   , fact.custom9
10568 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10569 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10570 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10571 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10572 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10573 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10574 			  , '0-1'  , fact.custom9
10575 			  , '1-1'  , fact.custom9
10576 			  , 0  ) -- end decode
10577 			    , 0  ) -- end nvl
10578 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10579 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom9
10580 	 , ROUND (
10581              NVL (
10582             DECODE (
10583                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10584 			  , '00'   , fact.custom10
10585 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10586 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10587 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10588 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10589 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10590 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10591 			  , '0-1'  , fact.custom10
10592 			  , '1-1'  , fact.custom10
10593 			  , 0  ) -- end decode
10594 			    , 0  ) -- end nvl
10595 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10596 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom10
10597 	 , ROUND (
10598              NVL (
10599             DECODE (
10600                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10601 			  , '00'   , fact.custom11
10602 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10603 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10604 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10605 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10606 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10607 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10608 			  , '0-1'  , fact.custom11
10609 			  , '1-1'  , fact.custom11
10610 			  , 0  ) -- end decode
10611 			    , 0  ) -- end nvl
10612 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10613 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom11
10617                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10614 	 , ROUND (
10615              NVL (
10616             DECODE (
10618 			  , '00'   , fact.custom12
10619 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10620 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10621 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10622 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10623 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10624 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10625 			  , '0-1'  , fact.custom12
10626 			  , '1-1'  , fact.custom12
10627 			  , 0  ) -- end decode
10628 			    , 0  ) -- end nvl
10629 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10630 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom12
10631 	 , ROUND (
10632              NVL (
10633             DECODE (
10634                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10635 			  , '00'   , fact.custom13
10636 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10637 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10638 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10639 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10640 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10641 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10642 			  , '0-1'  , fact.custom13
10643 			  , '1-1'  , fact.custom13
10644 			  , 0  ) -- end decode
10645 			    , 0  ) -- end nvl
10646 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10647 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom13
10648 	 , ROUND (
10649              NVL (
10650             DECODE (
10651                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10652 			  , '00'   , fact.custom14
10653 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10654 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10655 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10656 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10657 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10658 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10659 			  , '0-1'  , fact.custom14
10660 			  , '1-1'  , fact.custom14
10661 			  , 0  ) -- end decode
10662 			    , 0  ) -- end nvl
10663 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10664 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom14
10665 	 , ROUND (
10666              NVL (
10667             DECODE (
10668                      ( sign (non_pa_cal.start_date - pa_cal.start_date) || sign (non_pa_cal.end_date - pa_cal.end_date) )
10669 			  , '00'   , fact.custom15
10670 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10671 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10672 			  , '10'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10673 			  , '11'   , (pa_cal.end_date - non_pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10674 			  , '-10'  , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10675 			  , '-1-1' , (non_pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (non_pa_cal.end_date - non_pa_cal.start_date + 1)
10676 			  , '0-1'  , fact.custom15
10677 			  , '1-1'  , fact.custom15
10678 			  , 0  ) -- end decode
10679 			    , 0  ) -- end nvl
10680 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10681 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom15
10682      , 'CF'   line_type
10683 	 , NULL time_dangling_flag
10684 	 , NULL rate_dangling_flag
10685               ,fact.plan_type_code plan_type_code     /*4471527 */
10686    FROM   pji_fp_xbs_accum_f  fact
10687        , PJI_FM_EXTR_PLNVER3_T ver
10688         , pji_time_cal_period  non_pa_cal
10689    	 , pji_org_extr_info  orginfo
10690    	 , pji_time_cal_period  pa_cal
10691    WHERE  1=1
10692       AND fact.CALENDAR_TYPE <> p_calendar_type
10693       AND fact.CALENDAR_TYPE IN ('P', 'G')
10694       AND non_pa_cal.cal_period_id = fact.time_id
10698       AND DECODE(fact.calendar_type, 'P', orginfo.gl_calendar_id, 'G', orginfo.pa_calendar_id) = pa_cal.calendar_id
10695       AND ver.project_id = fact.project_id
10696       AND ver.plan_version_id = fact.plan_version_id
10697       AND orginfo.org_id = fact.PROJECT_ORG_ID
10699       AND (
10700 	       ( pa_cal.start_date >= non_pa_cal.start_date  AND pa_cal.end_date <= non_pa_cal.end_date )
10701 	    OR ( pa_cal.start_date <= non_pa_cal.start_date  AND pa_cal.end_date >= non_pa_cal.end_date )
10702 	    OR ( pa_cal.start_date <= non_pa_cal.start_date  AND pa_cal.end_date <= non_pa_cal.end_date AND pa_cal.end_date >= non_pa_cal.start_date )
10703 	    OR ( pa_cal.start_date >= non_pa_cal.start_date  AND pa_cal.end_date >= non_pa_cal.end_date AND pa_cal.start_date <= non_pa_cal.end_date )
10704           )
10705       AND fact.period_type_id = 32
10706       AND ver.wp_flag = 'N'
10707       AND ver.baselined_flag = 'Y'
10708 	  ) a
10709 	  GROUP BY
10710 	   a.PROJECT_ID
10711      , a.PROJECT_ORG_ID
10712      , a.PROJECT_ORGANIZATION_ID
10713      , a.PROJECT_ELEMENT_ID
10714      , a.TIME_ID
10715      , a.PERIOD_TYPE_ID
10716      , a.CALENDAR_TYPE
10717      , a.RBS_AGGR_LEVEL
10718      , a.WBS_ROLLUP_FLAG
10719      , a.PRG_ROLLUP_FLAG
10720      , a.CURR_RECORD_TYPE_ID
10721      , a.CURRENCY_CODE
10722      , a.RBS_ELEMENT_ID
10723      , a.RBS_VERSION_ID
10724      , a.PLAN_VERSION_ID
10725      , a.PLAN_TYPE_ID
10726 	 , a.LINE_TYPE
10727 	 , a.TIME_DANGLING_FLAG
10728 	 , a.RATE_DANGLING_FLAG;
10729 
10730 
10731 EXCEPTION
10732   WHEN OTHERS THEN
10733     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
10734                              p_procedure_name => 'PRORATE_TO_PAGL_PGE_FPRL_D ');
10735     RAISE;
10736 END;
10737 
10738 
10739 PROCEDURE PRORATE_TO_PAGL_N_PJP1_D (p_calendar_type   IN   VARCHAR2 := NULL) IS
10740 BEGIN
10741 
10742     IF (p_calendar_type NOT IN ('P', 'G')) THEN
10743       RETURN;
10744     END IF;
10745 
10746     -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
10747 
10748 /* Commented for bug 4005006
10749     INSERT INTO pji_fp_aggr_pjp1_t  -- Non time phased entries..
10750     (
10751        worker_id
10752       , PROJECT_ID
10753      , PROJECT_ORG_ID
10754      , PROJECT_ORGANIZATION_ID
10755      -- , PARTITION_ID
10756      , PROJECT_ELEMENT_ID
10757      , TIME_ID
10758      , PERIOD_TYPE_ID
10759      , CALENDAR_TYPE
10760      , RBS_AGGR_LEVEL
10761      , WBS_ROLLUP_FLAG
10762      , PRG_ROLLUP_FLAG
10763      , CURR_RECORD_TYPE_ID
10764      , CURRENCY_CODE
10765      , RBS_ELEMENT_ID
10766      , RBS_VERSION_ID
10767      , PLAN_VERSION_ID
10768      , PLAN_TYPE_ID
10769      , RAW_COST
10770      , BRDN_COST
10771      , REVENUE
10772      , BILL_RAW_COST
10773      , BILL_BRDN_COST
10774      , BILL_LABOR_RAW_COST
10775      , BILL_LABOR_BRDN_COST
10776      , BILL_LABOR_HRS
10777      , EQUIPMENT_RAW_COST
10778      , EQUIPMENT_BRDN_COST
10779      , CAPITALIZABLE_RAW_COST
10780      , CAPITALIZABLE_BRDN_COST
10781      , LABOR_RAW_COST
10782      , LABOR_BRDN_COST
10783      , LABOR_HRS
10784      , LABOR_REVENUE
10785      , EQUIPMENT_HOURS
10786      , BILLABLE_EQUIPMENT_HOURS
10787      , SUP_INV_COMMITTED_COST
10788      , PO_COMMITTED_COST
10789      , PR_COMMITTED_COST
10790      , OTH_COMMITTED_COST
10791        , ACT_LABOR_HRS
10792 	   , ACT_EQUIP_HRS
10793 	   , ACT_LABOR_BRDN_COST
10797 	   , ACT_REVENUE
10794 	   , ACT_EQUIP_BRDN_COST
10795 	   , ACT_BRDN_COST
10796 	   , ACT_RAW_COST
10798          , ACT_LABOR_RAW_COST
10799          , ACT_EQUIP_RAW_COST
10800 	   , ETC_LABOR_HRS
10801 	   , ETC_EQUIP_HRS
10802 	   , ETC_LABOR_BRDN_COST
10803 	   , ETC_EQUIP_BRDN_COST
10804 	   , ETC_BRDN_COST
10805          , ETC_RAW_COST
10806          , ETC_LABOR_RAW_COST
10807          , ETC_EQUIP_RAW_COST
10808      , CUSTOM1
10809      , CUSTOM2
10810      , CUSTOM3
10811      , CUSTOM4
10812      , CUSTOM5
10813      , CUSTOM6
10814      , CUSTOM7
10815      , CUSTOM8
10816      , CUSTOM9
10817      , CUSTOM10
10818      , CUSTOM11
10819      , CUSTOM12
10820      , CUSTOM13
10821      , CUSTOM14
10822      , CUSTOM15
10823      , LINE_TYPE
10824      , TIME_DANGLING_FLAG
10825      , RATE_DANGLING_FLAG
10826      , PRG_LEVEL
10827 	)
10828    SELECT
10829          g_worker_id  worker_id
10830      , a.PROJECT_ID
10831      , a.PROJECT_ORG_ID
10832      , a.PROJECT_ORGANIZATION_ID
10833      , a.PROJECT_ELEMENT_ID
10834      , a.TIME_ID
10835      , 32 -- a.PERIOD_TYPE_ID
10836      , a.CALENDAR_TYPE
10837      , a.RBS_AGGR_LEVEL
10838      , a.WBS_ROLLUP_FLAG
10839      , a.PRG_ROLLUP_FLAG
10840      , a.CURR_RECORD_TYPE_ID
10841      , a.CURRENCY_CODE
10842      , a.RBS_ELEMENT_ID
10843      , a.RBS_VERSION_ID
10844      , a.PLAN_VERSION_ID
10845      , a.PLAN_TYPE_ID
10846      , SUM(a.RAW_COST       )
10847      , SUM(a.BRDN_COST 	)
10848      , SUM(a.REVENUE	)
10849      , SUM(a.BILL_RAW_COST )
10850      , SUM(a.BILL_BRDN_COST )
10851      , SUM(a.BILL_LABOR_RAW_COST )
10852      , SUM(a.BILL_LABOR_BRDN_COST )
10853      , SUM(a.BILL_LABOR_HRS )
10854      , SUM(a.EQUIPMENT_RAW_COST )
10855      , SUM(a.EQUIPMENT_BRDN_COST )
10856      , SUM(a.CAPITALIZABLE_RAW_COST )
10857      , SUM(a.CAPITALIZABLE_BRDN_COST )
10858      , SUM(a.LABOR_RAW_COST )
10859      , SUM(a.LABOR_BRDN_COST)
10860      , SUM(a.LABOR_HRS )
10861      , SUM(a.LABOR_REVENUE )
10862      , SUM(a.EQUIPMENT_HOURS )
10863      , SUM(a.BILLABLE_EQUIPMENT_HOURS)
10864      , SUM(a.SUP_INV_COMMITTED_COST)
10865      , SUM(a.PO_COMMITTED_COST )
10866      , SUM(a.PR_COMMITTED_COST )
10867      , SUM(a.OTH_COMMITTED_COST)
10868        , SUM(a.ACT_LABOR_HRS)
10869 	   , SUM(a.ACT_EQUIP_HRS)
10870 	   , SUM(a.ACT_LABOR_BRDN_COST)
10871 	   , SUM(a.ACT_EQUIP_BRDN_COST)
10872 	   , SUM(a.ACT_BRDN_COST    )
10873 	   , SUM(a.ACT_RAW_COST    )
10874 	   , SUM(a.ACT_REVENUE    )
10875          , SUM(a.ACT_LABOR_RAW_COST)
10876          , SUM(a.ACT_EQUIP_RAW_COST)
10877 	   , SUM(a.ETC_LABOR_HRS         )
10878 	   , SUM(a.ETC_EQUIP_HRS        )
10879 	   , SUM(a.ETC_LABOR_BRDN_COST )
10880 	   , SUM(a.ETC_EQUIP_BRDN_COST)
10881 	   , SUM(a.ETC_BRDN_COST )
10882          , SUM(a.ETC_RAW_COST)
10883          , SUM(a.ETC_LABOR_RAW_COST)
10884          , SUM(a.ETC_EQUIP_RAW_COST)
10885      , SUM(a.CUSTOM1	)
10886      , SUM(a.CUSTOM2	)
10887      , SUM(a.CUSTOM3	)
10888      , SUM(a.CUSTOM4	)
10889      , SUM(a.CUSTOM5	)
10890      , SUM(a.CUSTOM6	)
10891      , SUM(a.CUSTOM7	)
10892      , SUM(a.CUSTOM8	)
10893      , SUM(a.CUSTOM9	)
10894      , SUM(a.CUSTOM10	)
10895      , SUM(a.CUSTOM11	)
10896      , SUM(a.CUSTOM12	)
10897      , SUM(a.CUSTOM13	)
10898      , SUM(a.CUSTOM14	)
10899      , SUM(a.CUSTOM15	)
10900 	 , a.LINE_TYPE
10901 	 , a.TIME_DANGLING_FLAG
10902 	 , a.RATE_DANGLING_FLAG
10903        , g_default_prg_level prg_level
10904   FROM (
10905    SELECT
10906          fact.project_id  project_id
10907    	 , fact.project_ORG_ID project_ORG_ID
10908    	 , fact.project_ORGANIZATION_ID project_ORGANIZATION_ID
10909    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
10910    	 , pa_cal.cal_period_id TIME_ID
10911    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
10912        , p_calendar_type  CALENDAR_TYPE
10913        , fact.RBS_AGGR_LEVEL
10914        , fact.WBS_ROLLUP_FLAG
10915        , fact.PRG_ROLLUP_FLAG
10916    	 , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
10917    	 , fact.CURRENCY_CODE CURRENCY_CODE
10918    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
10919    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
10920    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
10921 	 , fact.PLAN_TYPE_ID  PLAN_TYPE_ID
10922 	 , ROUND (
10923              NVL (
10924             DECODE (
10925                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
10926 			  , '00'   , fact.raw_cost
10927 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (fact.end_date - fact.start_date + 1)
10928 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.raw_cost / (fact.end_date - fact.start_date + 1)
10929 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.raw_cost / (fact.end_date - fact.start_date + 1)
10930 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.raw_cost / (fact.end_date - fact.start_date + 1)
10931 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.raw_cost / (fact.end_date - fact.start_date + 1)
10932 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.raw_cost / (fact.end_date - fact.start_date + 1)
10933 			  , '0-1'  , fact.raw_cost
10937 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10934 			  , '1-1'  , fact.raw_cost
10935 			  , 0  ) -- end decode
10936 			    , 0  ) -- end nvl
10938 						* PJI_UTILS.GET_MAU (fact.currency_code)	raw_cost
10939 	 , ROUND (
10940              NVL (
10941             DECODE (
10942                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
10943 			 , '00'   , fact.brdn_cost
10944 			 , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (fact.end_date - fact.start_date + 1)
10945 			 , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (fact.end_date - fact.start_date + 1)
10946 			 , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.brdn_cost / (fact.end_date - fact.start_date + 1)
10947 			 , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.brdn_cost / (fact.end_date - fact.start_date + 1)
10948 			 , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (fact.end_date - fact.start_date + 1)
10949 			 , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.brdn_cost / (fact.end_date - fact.start_date + 1)
10950 			 , '0-1'  , fact.brdn_cost
10951 			 , '1-1'  , fact.brdn_cost
10952 			 , 0  ) -- end decode
10953 			  , 0  ) -- end nvl
10954 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10955 						* PJI_UTILS.GET_MAU (fact.currency_code)	brdn_cost
10956 	 , ROUND (
10957              NVL (
10958             DECODE (
10959                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
10960 			 , '00'   , fact.revenue
10961 			 , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (fact.end_date - fact.start_date + 1)
10962 			 , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.revenue / (fact.end_date - fact.start_date + 1)
10963 			 , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.revenue / (fact.end_date - fact.start_date + 1)
10964 			 , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.revenue / (fact.end_date - fact.start_date + 1)
10965 			 , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.revenue / (fact.end_date - fact.start_date + 1)
10966 			 , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.revenue / (fact.end_date - fact.start_date + 1)
10967 			 , '0-1'  , fact.revenue
10968 			 , '1-1'  , fact.revenue
10969 			 , 0  ) -- end decode
10970 			  , 0  ) -- end nvl
10971 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10972 						* PJI_UTILS.GET_MAU (fact.currency_code)	revenue
10973 	 , ROUND (
10974              NVL (
10975             DECODE (
10976                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
10977 			  , '00'   , fact.bill_raw_cost
10978 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (fact.end_date - fact.start_date + 1)
10979 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (fact.end_date - fact.start_date + 1)
10980 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_raw_cost / (fact.end_date - fact.start_date + 1)
10981 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_raw_cost / (fact.end_date - fact.start_date + 1)
10982 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (fact.end_date - fact.start_date + 1)
10983 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.bill_raw_cost / (fact.end_date - fact.start_date + 1)
10984 			  , '0-1'  , fact.bill_raw_cost
10985 			  , '1-1'  , fact.bill_raw_cost
10986 			  , 0  ) -- end decode
10987 			    , 0  ) -- end nvl
10988 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
10989 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_raw_cost
10990 	 , ROUND (
10991              NVL (
10992             DECODE (
10993                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
10994 			  , '00'   , fact.bill_brdn_cost
10995 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (fact.end_date - fact.start_date + 1)
10996 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (fact.end_date - fact.start_date + 1)
10997 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_brdn_cost / (fact.end_date - fact.start_date + 1)
10998 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_brdn_cost / (fact.end_date - fact.start_date + 1)
10999 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (fact.end_date - fact.start_date + 1)
11000 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.bill_brdn_cost / (fact.end_date - fact.start_date + 1)
11001 			  , '0-1'  , fact.bill_brdn_cost
11002 			  , '1-1'  , fact.bill_brdn_cost
11003 			  , 0  ) -- end decode
11004 			    , 0  ) -- end nvl
11005 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11006 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_brdn_cost
11007 	 , ROUND (
11008              NVL (
11009             DECODE (
11010                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11011 			  , '00'   , fact.bill_labor_raw_cost
11012 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (fact.end_date - fact.start_date + 1)
11013 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (fact.end_date - fact.start_date + 1)
11014 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_labor_raw_cost / (fact.end_date - fact.start_date + 1)
11018 			  , '0-1'  , fact.bill_labor_raw_cost
11015 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_labor_raw_cost / (fact.end_date - fact.start_date + 1)
11016 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (fact.end_date - fact.start_date + 1)
11017 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.bill_labor_raw_cost / (fact.end_date - fact.start_date + 1)
11019 			  , '1-1'  , fact.bill_labor_raw_cost
11020 			  , 0  ) -- end decode
11021 			    , 0  ) -- end nvl
11022 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11023 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_raw_cost
11024 	 , ROUND (
11025              NVL (
11026             DECODE (
11027                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11028 			  , '00'   , fact.bill_labor_brdn_cost
11029 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (fact.end_date - fact.start_date + 1)
11030 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (fact.end_date - fact.start_date + 1)
11031 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_labor_brdn_cost / (fact.end_date - fact.start_date + 1)
11032 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_labor_brdn_cost / (fact.end_date - fact.start_date + 1)
11033 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (fact.end_date - fact.start_date + 1)
11034 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.bill_labor_brdn_cost / (fact.end_date - fact.start_date + 1)
11035 			  , '0-1'  , fact.bill_labor_brdn_cost
11036 			  , '1-1'  , fact.bill_labor_brdn_cost
11037 			  , 0  ) -- end decode
11038 			    , 0  ) -- end nvl
11039 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11040 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_brdn_cost
11041 	 , ROUND (
11042              NVL (
11043             DECODE (
11044                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11045 			  , '00'   , fact.bill_labor_hrs
11046 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (fact.end_date - fact.start_date + 1)
11047 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (fact.end_date - fact.start_date + 1)
11048 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_labor_hrs / (fact.end_date - fact.start_date + 1)
11049 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.bill_labor_hrs / (fact.end_date - fact.start_date + 1)
11050 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (fact.end_date - fact.start_date + 1)
11051 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.bill_labor_hrs / (fact.end_date - fact.start_date + 1)
11052 			  , '0-1'  , fact.bill_labor_hrs
11053 			  , '1-1'  , fact.bill_labor_hrs
11054 			  , 0  ) -- end decode
11055 			    , 0  ) -- end nvl
11056 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11057 						* PJI_UTILS.GET_MAU (fact.currency_code)	bill_labor_hrs
11058 	 , ROUND (
11059              NVL (
11060             DECODE (
11061                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11062 			  , '00'   , fact.equipment_raw_cost
11063 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (fact.end_date - fact.start_date + 1)
11064 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (fact.end_date - fact.start_date + 1)
11065 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.equipment_raw_cost / (fact.end_date - fact.start_date + 1)
11069 			  , '0-1'  , fact.equipment_raw_cost
11066 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.equipment_raw_cost / (fact.end_date - fact.start_date + 1)
11067 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (fact.end_date - fact.start_date + 1)
11068 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.equipment_raw_cost / (fact.end_date - fact.start_date + 1)
11070 			  , '1-1'  , fact.equipment_raw_cost
11071 			  , 0  ) -- end decode
11072 			    , 0  ) -- end nvl
11073 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11074 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_raw_cost
11075 	 , ROUND (
11076              NVL (
11077             DECODE (
11078                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11079 			  , '00'   , fact.equipment_brdn_cost
11080 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (fact.end_date - fact.start_date + 1)
11081 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (fact.end_date - fact.start_date + 1)
11082 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.equipment_brdn_cost / (fact.end_date - fact.start_date + 1)
11083 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.equipment_brdn_cost / (fact.end_date - fact.start_date + 1)
11084 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (fact.end_date - fact.start_date + 1)
11085 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.equipment_brdn_cost / (fact.end_date - fact.start_date + 1)
11086 			  , '0-1'  , fact.equipment_brdn_cost
11087 			  , '1-1'  , fact.equipment_brdn_cost
11088 			  , 0  ) -- end decode
11089 			    , 0  ) -- end nvl
11090 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11091 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_brdn_cost
11092 	 , ROUND (
11093              NVL (
11094             DECODE (
11095                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11096 			  , '00'   , fact.capitalizable_raw_cost
11097 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (fact.end_date - fact.start_date + 1)
11098 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (fact.end_date - fact.start_date + 1)
11099 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.capitalizable_raw_cost / (fact.end_date - fact.start_date + 1)
11100 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.capitalizable_raw_cost / (fact.end_date - fact.start_date + 1)
11101 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (fact.end_date - fact.start_date + 1)
11102 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.capitalizable_raw_cost / (fact.end_date - fact.start_date + 1)
11103 			  , '0-1'  , fact.capitalizable_raw_cost
11104 			  , '1-1'  , fact.capitalizable_raw_cost
11105 			  , 0  ) -- end decode
11106 			    , 0  ) -- end nvl
11107 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11108 						* PJI_UTILS.GET_MAU (fact.currency_code)	capitalizable_raw_cost
11109 	 , ROUND (
11110              NVL (
11111             DECODE (
11112                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11113 			  , '00'   , fact.capitalizable_brdn_cost
11114 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (fact.end_date - fact.start_date + 1)
11115 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (fact.end_date - fact.start_date + 1)
11116 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.capitalizable_brdn_cost / (fact.end_date - fact.start_date + 1)
11117 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.capitalizable_brdn_cost / (fact.end_date - fact.start_date + 1)
11118 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (fact.end_date - fact.start_date + 1)
11119 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.capitalizable_brdn_cost / (fact.end_date - fact.start_date + 1)
11120 			  , '0-1'  , fact.capitalizable_brdn_cost
11121 			  , '1-1'  , fact.capitalizable_brdn_cost
11122 			  , 0  ) -- end decode
11123 			    , 0  ) -- end nvl
11124 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11125 						* PJI_UTILS.GET_MAU (fact.currency_code)	capitalizable_brdn_cost
11126 	 , ROUND (
11127              NVL (
11128             DECODE (
11129                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11130 			  , '00'   , fact.labor_raw_cost
11131 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (fact.end_date - fact.start_date + 1)
11132 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (fact.end_date - fact.start_date + 1)
11133 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_raw_cost / (fact.end_date - fact.start_date + 1)
11134 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_raw_cost / (fact.end_date - fact.start_date + 1)
11135 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (fact.end_date - fact.start_date + 1)
11136 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.labor_raw_cost / (fact.end_date - fact.start_date + 1)
11137 			  , '0-1'  , fact.labor_raw_cost
11138 			  , '1-1'  , fact.labor_raw_cost
11139 			  , 0  ) -- end decode
11140 			    , 0  ) -- end nvl
11141 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11142 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_raw_cost
11143 	 , ROUND (
11144              NVL (
11145             DECODE (
11149 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (fact.end_date - fact.start_date + 1)
11146                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11147 			  , '00'   , fact.labor_brdn_cost
11148 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (fact.end_date - fact.start_date + 1)
11150 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_brdn_cost / (fact.end_date - fact.start_date + 1)
11151 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_brdn_cost / (fact.end_date - fact.start_date + 1)
11152 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (fact.end_date - fact.start_date + 1)
11153 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.labor_brdn_cost / (fact.end_date - fact.start_date + 1)
11154 			  , '0-1'  , fact.labor_brdn_cost
11155 			  , '1-1'  , fact.labor_brdn_cost
11156 			  , 0  ) -- end decode
11157 			    , 0  ) -- end nvl
11158 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11159 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_brdn_cost
11160 	 , ROUND (
11161              NVL (
11162             DECODE (
11163                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11164 			  , '00'   , fact.labor_hrs
11165 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (fact.end_date - fact.start_date + 1)
11166 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (fact.end_date - fact.start_date + 1)
11167 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_hrs / (fact.end_date - fact.start_date + 1)
11168 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_hrs / (fact.end_date - fact.start_date + 1)
11169 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (fact.end_date - fact.start_date + 1)
11170 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.labor_hrs / (fact.end_date - fact.start_date + 1)
11171 			  , '0-1'  , fact.labor_hrs
11172 			  , '1-1'  , fact.labor_hrs
11173 			  , 0  ) -- end decode
11174 			    , 0  ) -- end nvl
11175 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11176 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_hrs
11177 	 , ROUND (
11178              NVL (
11179             DECODE (
11180                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11181 			  , '00'   , fact.labor_revenue
11182 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (fact.end_date - fact.start_date + 1)
11183 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (fact.end_date - fact.start_date + 1)
11184 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_revenue / (fact.end_date - fact.start_date + 1)
11185 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.labor_revenue / (fact.end_date - fact.start_date + 1)
11186 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (fact.end_date - fact.start_date + 1)
11187 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.labor_revenue / (fact.end_date - fact.start_date + 1)
11188 			  , '0-1'  , fact.labor_revenue
11189 			  , '1-1'  , fact.labor_revenue
11190 			  , 0  ) -- end decode
11191 			    , 0  ) -- end nvl
11192 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11193 						* PJI_UTILS.GET_MAU (fact.currency_code)	labor_revenue
11194 	 , ROUND (
11195              NVL (
11196             DECODE (
11197                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11198 			  , '00'   , fact.equipment_hours
11199 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (fact.end_date - fact.start_date + 1)
11200 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (fact.end_date - fact.start_date + 1)
11201 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.equipment_hours / (fact.end_date - fact.start_date + 1)
11202 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.equipment_hours / (fact.end_date - fact.start_date + 1)
11203 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (fact.end_date - fact.start_date + 1)
11204 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.equipment_hours / (fact.end_date - fact.start_date + 1)
11205 			  , '0-1'  , fact.equipment_hours
11206 			  , '1-1'  , fact.equipment_hours
11207 			  , 0  ) -- end decode
11208 			    , 0  ) -- end nvl
11209 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11210 						* PJI_UTILS.GET_MAU (fact.currency_code)	equipment_hours
11211 	 , ROUND (
11212              NVL (
11213             DECODE (
11214                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11215 			  , '00'   , fact.billable_equipment_hours
11216 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (fact.end_date - fact.start_date + 1)
11217 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (fact.end_date - fact.start_date + 1)
11218 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.billable_equipment_hours / (fact.end_date - fact.start_date + 1)
11219 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.billable_equipment_hours / (fact.end_date - fact.start_date + 1)
11220 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (fact.end_date - fact.start_date + 1)
11221 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.billable_equipment_hours / (fact.end_date - fact.start_date + 1)
11222 			  , '0-1'  , fact.billable_equipment_hours
11223 			  , '1-1'  , fact.billable_equipment_hours
11224 			  , 0  ) -- end decode
11225 			    , 0  ) -- end nvl
11229              NVL (
11226 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11227 						* PJI_UTILS.GET_MAU (fact.currency_code)	billable_equipment_hours
11228 	 , ROUND (
11230             DECODE (
11231                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11232 			  , '00'   , fact.sup_inv_committed_cost
11233 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (fact.end_date - fact.start_date + 1)
11234 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (fact.end_date - fact.start_date + 1)
11235 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.sup_inv_committed_cost / (fact.end_date - fact.start_date + 1)
11236 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.sup_inv_committed_cost / (fact.end_date - fact.start_date + 1)
11237 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (fact.end_date - fact.start_date + 1)
11238 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.sup_inv_committed_cost / (fact.end_date - fact.start_date + 1)
11239 			  , '0-1'  , fact.sup_inv_committed_cost
11240 			  , '1-1'  , fact.sup_inv_committed_cost
11241 			  , 0  ) -- end decode
11242 			    , 0  ) -- end nvl
11243 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11244 						* PJI_UTILS.GET_MAU (fact.currency_code)	sup_inv_committed_cost
11245 	 , ROUND (
11246              NVL (
11247             DECODE (
11248                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11249 			  , '00'   , fact.po_committed_cost
11250 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (fact.end_date - fact.start_date + 1)
11251 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (fact.end_date - fact.start_date + 1)
11252 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.po_committed_cost / (fact.end_date - fact.start_date + 1)
11253 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.po_committed_cost / (fact.end_date - fact.start_date + 1)
11254 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (fact.end_date - fact.start_date + 1)
11255 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.po_committed_cost / (fact.end_date - fact.start_date + 1)
11256 			  , '0-1'  , fact.po_committed_cost
11257 			  , '1-1'  , fact.po_committed_cost
11258 			  , 0  ) -- end decode
11259 			    , 0  ) -- end nvl
11260 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11261 						* PJI_UTILS.GET_MAU (fact.currency_code)	po_committed_cost
11262 	 , ROUND (
11263              NVL (
11264             DECODE (
11265                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11266 			  , '00'   , fact.pr_committed_cost
11267 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (fact.end_date - fact.start_date + 1)
11268 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (fact.end_date - fact.start_date + 1)
11269 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.pr_committed_cost / (fact.end_date - fact.start_date + 1)
11270 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.pr_committed_cost / (fact.end_date - fact.start_date + 1)
11271 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (fact.end_date - fact.start_date + 1)
11272 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.pr_committed_cost / (fact.end_date - fact.start_date + 1)
11273 			  , '0-1'  , fact.pr_committed_cost
11274 			  , '1-1'  , fact.pr_committed_cost
11275 			  , 0  ) -- end decode
11276 			    , 0  ) -- end nvl
11277 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11278 						* PJI_UTILS.GET_MAU (fact.currency_code)	pr_committed_cost
11279 	 , ROUND (
11280              NVL (
11281             DECODE (
11282                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11283 			  , '00'   , fact.oth_committed_cost
11284 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (fact.end_date - fact.start_date + 1)
11285 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (fact.end_date - fact.start_date + 1)
11286 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.oth_committed_cost / (fact.end_date - fact.start_date + 1)
11287 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.oth_committed_cost / (fact.end_date - fact.start_date + 1)
11288 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (fact.end_date - fact.start_date + 1)
11289 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.oth_committed_cost / (fact.end_date - fact.start_date + 1)
11290 			  , '0-1'  , fact.oth_committed_cost
11291 			  , '1-1'  , fact.oth_committed_cost
11292 			  , 0  ) -- end decode
11293 			    , 0  ) -- end nvl
11294 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11295 						* PJI_UTILS.GET_MAU (fact.currency_code)	oth_committed_cost
11296 	 , ROUND (
11297              NVL (
11298             DECODE (
11299                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11300 			  , '00'   , fact.ACT_LABOR_HRS
11301 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (fact.end_date - fact.start_date + 1)
11305 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (fact.end_date - fact.start_date + 1)
11302 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (fact.end_date - fact.start_date + 1)
11303 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_LABOR_HRS / (fact.end_date - fact.start_date + 1)
11304 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_LABOR_HRS / (fact.end_date - fact.start_date + 1)
11306 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_HRS / (fact.end_date - fact.start_date + 1)
11307 			  , '0-1'  , fact.ACT_LABOR_HRS
11308 			  , '1-1'  , fact.ACT_LABOR_HRS
11309 			  , 0  ) -- end decode
11310 			    , 0  ) -- end nvl
11311 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11312 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_HRS
11313 	 , ROUND (
11314              NVL (
11315             DECODE (
11316                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11317 			  , '00'   , fact.ACT_EQUIP_HRS
11318 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
11319 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
11320 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
11321 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
11322 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
11323 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
11324 			  , '0-1'  , fact.ACT_EQUIP_HRS
11325 			  , '1-1'  , fact.ACT_EQUIP_HRS
11326 			  , 0  ) -- end decode
11327 			    , 0  ) -- end nvl
11328 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11329 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_HRS
11330 	 , ROUND (
11331              NVL (
11332             DECODE (
11333                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11334 			  , '00'   , fact.ACT_LABOR_BRDN_COST
11335 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
11336 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
11337 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
11338 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
11339 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
11340 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
11341 			  , '0-1'  , fact.ACT_LABOR_BRDN_COST
11342 			  , '1-1'  , fact.ACT_LABOR_BRDN_COST
11343 			  , 0  ) -- end decode
11344 			    , 0  ) -- end nvl
11345 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11346 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_BRDN_COST
11347 	 , ROUND (
11348              NVL (
11349             DECODE (
11350                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11351 			  , '00'   , fact.ACT_EQUIP_BRDN_COST
11352 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
11353 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
11354 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
11355 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
11356 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
11357 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
11358 			  , '0-1'  , fact.ACT_EQUIP_BRDN_COST
11359 			  , '1-1'  , fact.ACT_EQUIP_BRDN_COST
11360 			  , 0  ) -- end decode
11361 			    , 0  ) -- end nvl
11362 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11363 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_BRDN_COST
11364 	 , ROUND (
11365              NVL (
11366             DECODE (
11367                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11368 			  , '00'   , fact.ACT_BRDN_COST
11369 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (fact.end_date - fact.start_date + 1)
11370 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (fact.end_date - fact.start_date + 1)
11371 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_BRDN_COST / (fact.end_date - fact.start_date + 1)
11372 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_BRDN_COST / (fact.end_date - fact.start_date + 1)
11373 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (fact.end_date - fact.start_date + 1)
11374 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_BRDN_COST / (fact.end_date - fact.start_date + 1)
11375 			  , '0-1'  , fact.ACT_BRDN_COST
11376 			  , '1-1'  , fact.ACT_BRDN_COST
11380 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_BRDN_COST
11377 			  , 0  ) -- end decode
11378 			    , 0  ) -- end nvl
11379 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11381 	 , ROUND (
11382              NVL (
11383             DECODE (
11384                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11385 			  , '00'   , fact.ACT_RAW_COST
11386 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (fact.end_date - fact.start_date + 1)
11387 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (fact.end_date - fact.start_date + 1)
11388 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_RAW_COST / (fact.end_date - fact.start_date + 1)
11389 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_RAW_COST / (fact.end_date - fact.start_date + 1)
11390 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (fact.end_date - fact.start_date + 1)
11391 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_RAW_COST / (fact.end_date - fact.start_date + 1)
11392 			  , '0-1'  , fact.ACT_RAW_COST
11393 			  , '1-1'  , fact.ACT_RAW_COST
11394 			  , 0  ) -- end decode
11395 			    , 0  ) -- end nvl
11396 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11397 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_RAW_COST
11398 	 , ROUND (
11399              NVL (
11400             DECODE (
11401                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11402 			  , '00'   , fact.ACT_REVENUE
11403 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (fact.end_date - fact.start_date + 1)
11404 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (fact.end_date - fact.start_date + 1)
11405 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_REVENUE / (fact.end_date - fact.start_date + 1)
11406 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_REVENUE / (fact.end_date - fact.start_date + 1)
11407 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (fact.end_date - fact.start_date + 1)
11408 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_REVENUE / (fact.end_date - fact.start_date + 1)
11409 			  , '0-1'  , fact.ACT_REVENUE
11410 			  , '1-1'  , fact.ACT_REVENUE
11411 			  , 0  ) -- end decode
11412 			    , 0  ) -- end nvl
11413 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11414 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_REVENUE
11415 	 , ROUND (
11416              NVL (
11417             DECODE (
11418                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11419 			  , '00'   , fact.ACT_LABOR_RAW_COST
11420 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
11421 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
11422 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
11423 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
11424 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
11425 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
11426 			  , '0-1'  , fact.ACT_LABOR_RAW_COST
11427 			  , '1-1'  , fact.ACT_LABOR_RAW_COST
11428 			  , 0  ) -- end decode
11429 			    , 0  ) -- end nvl
11430 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11431 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_LABOR_RAW_COST
11432 	 , ROUND (
11433              NVL (
11434             DECODE (
11435                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11436 			  , '00'   , fact.ACT_EQUIP_RAW_COST
11437 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
11438 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
11439 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
11440 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
11441 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
11442 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ACT_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
11443 			  , '0-1'  , fact.ACT_EQUIP_RAW_COST
11444 			  , '1-1'  , fact.ACT_EQUIP_RAW_COST
11445 			  , 0  ) -- end decode
11446 			    , 0  ) -- end nvl
11447 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11448 						* PJI_UTILS.GET_MAU (fact.currency_code)	ACT_EQUIP_RAW_COST
11449 	 , ROUND (
11450              NVL (
11451             DECODE (
11452                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11453 			  , '00'   , fact.ETC_LABOR_HRS
11454 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (fact.end_date - fact.start_date + 1)
11455 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (fact.end_date - fact.start_date + 1)
11456 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_LABOR_HRS / (fact.end_date - fact.start_date + 1)
11460 			  , '0-1'  , fact.ETC_LABOR_HRS
11457 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_LABOR_HRS / (fact.end_date - fact.start_date + 1)
11458 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (fact.end_date - fact.start_date + 1)
11459 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_HRS / (fact.end_date - fact.start_date + 1)
11461 			  , '1-1'  , fact.ETC_LABOR_HRS
11462 			  , 0  ) -- end decode
11463 			    , 0  ) -- end nvl
11464 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11465 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_HRS
11466 	 , ROUND (
11467              NVL (
11468             DECODE (
11469                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11470 			  , '00'   , fact.ETC_EQUIP_HRS
11471 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
11472 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
11473 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
11474 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
11475 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
11476 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_HRS / (fact.end_date - fact.start_date + 1)
11477 			  , '0-1'  , fact.ETC_EQUIP_HRS
11478 			  , '1-1'  , fact.ETC_EQUIP_HRS
11479 			  , 0  ) -- end decode
11480 			    , 0  ) -- end nvl
11481 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11482 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_HRS
11483 	 , ROUND (
11484              NVL (
11485             DECODE (
11486                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11487 			  , '00'   , fact.ETC_LABOR_BRDN_COST
11488 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
11489 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
11490 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
11491 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
11492 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
11493 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_BRDN_COST / (fact.end_date - fact.start_date + 1)
11494 			  , '0-1'  , fact.ETC_LABOR_BRDN_COST
11495 			  , '1-1'  , fact.ETC_LABOR_BRDN_COST
11496 			  , 0  ) -- end decode
11497 			    , 0  ) -- end nvl
11498 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11499 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_BRDN_COST
11500 	 , ROUND (
11501              NVL (
11502             DECODE (
11503                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11504 			  , '00'   , fact.ETC_EQUIP_BRDN_COST
11505 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
11506 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
11507 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
11508 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
11509 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
11510 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_BRDN_COST / (fact.end_date - fact.start_date + 1)
11511 			  , '0-1'  , fact.ETC_EQUIP_BRDN_COST
11512 			  , '1-1'  , fact.ETC_EQUIP_BRDN_COST
11513 			  , 0  ) -- end decode
11514 			    , 0  ) -- end nvl
11515 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11516 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_BRDN_COST
11517 	 , ROUND (
11518              NVL (
11519             DECODE (
11520                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11521 			  , '00'   , fact.ETC_BRDN_COST
11522 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (fact.end_date - fact.start_date + 1)
11523 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (fact.end_date - fact.start_date + 1)
11524 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_BRDN_COST / (fact.end_date - fact.start_date + 1)
11525 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_BRDN_COST / (fact.end_date - fact.start_date + 1)
11526 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (fact.end_date - fact.start_date + 1)
11527 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_BRDN_COST / (fact.end_date - fact.start_date + 1)
11528 			  , '0-1'  , fact.ETC_BRDN_COST
11529 			  , '1-1'  , fact.ETC_BRDN_COST
11530 			  , 0  ) -- end decode
11534 	 , ROUND (
11531 			    , 0  ) -- end nvl
11532 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11533 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_BRDN_COST
11535              NVL (
11536             DECODE (
11537                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11538 			  , '00'   , fact.ETC_RAW_COST
11539 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (fact.end_date - fact.start_date + 1)
11540 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (fact.end_date - fact.start_date + 1)
11541 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_RAW_COST / (fact.end_date - fact.start_date + 1)
11542 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_RAW_COST / (fact.end_date - fact.start_date + 1)
11543 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (fact.end_date - fact.start_date + 1)
11544 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_RAW_COST / (fact.end_date - fact.start_date + 1)
11545 			  , '0-1'  , fact.ETC_RAW_COST
11546 			  , '1-1'  , fact.ETC_RAW_COST
11547 			  , 0  ) -- end decode
11548 			    , 0  ) -- end nvl
11549 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11550 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_RAW_COST
11551 	 , ROUND (
11552              NVL (
11553             DECODE (
11554                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11555 			  , '00'   , fact.ETC_LABOR_RAW_COST
11556 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
11557 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
11558 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
11559 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
11560 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
11561 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_LABOR_RAW_COST / (fact.end_date - fact.start_date + 1)
11562 			  , '0-1'  , fact.ETC_LABOR_RAW_COST
11563 			  , '1-1'  , fact.ETC_LABOR_RAW_COST
11564 			  , 0  ) -- end decode
11565 			    , 0  ) -- end nvl
11566 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11567 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_LABOR_RAW_COST
11568 	 , ROUND (
11569              NVL (
11570             DECODE (
11571                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11572 			  , '00'   , fact.ETC_EQUIP_RAW_COST
11573 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
11574 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
11575 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
11576 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
11577 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
11578 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.ETC_EQUIP_RAW_COST / (fact.end_date - fact.start_date + 1)
11579 			  , '0-1'  , fact.ETC_EQUIP_RAW_COST
11580 			  , '1-1'  , fact.ETC_EQUIP_RAW_COST
11581 			  , 0  ) -- end decode
11582 			    , 0  ) -- end nvl
11583 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11584 						* PJI_UTILS.GET_MAU (fact.currency_code)	ETC_EQUIP_RAW_COST
11585 	 , ROUND (
11586              NVL (
11587             DECODE (
11588                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11589 			  , '00'   , fact.custom1
11590 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (fact.end_date - fact.start_date + 1)
11591 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom1 / (fact.end_date - fact.start_date + 1)
11592 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom1 / (fact.end_date - fact.start_date + 1)
11593 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom1 / (fact.end_date - fact.start_date + 1)
11594 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom1 / (fact.end_date - fact.start_date + 1)
11595 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom1 / (fact.end_date - fact.start_date + 1)
11596 			  , '0-1'  , fact.custom1
11597 			  , '1-1'  , fact.custom1
11598 			  , 0  ) -- end decode
11599 			    , 0  ) -- end nvl
11600 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11601 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom1
11602 	 , ROUND (
11603              NVL (
11604             DECODE (
11605                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11606 			  , '00'   , fact.custom2
11607 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (fact.end_date - fact.start_date + 1)
11608 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom2 / (fact.end_date - fact.start_date + 1)
11609 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom2 / (fact.end_date - fact.start_date + 1)
11613 			  , '0-1'  , fact.custom2
11610 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom2 / (fact.end_date - fact.start_date + 1)
11611 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom2 / (fact.end_date - fact.start_date + 1)
11612 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom2 / (fact.end_date - fact.start_date + 1)
11614 			  , '1-1'  , fact.custom2
11615 			  , 0  ) -- end decode
11616 			    , 0  ) -- end nvl
11617 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11618 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom2
11619 	 , ROUND (
11620              NVL (
11621             DECODE (
11622                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11623 			  , '00'   , fact.custom3
11624 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (fact.end_date - fact.start_date + 1)
11625 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom3 / (fact.end_date - fact.start_date + 1)
11626 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom3 / (fact.end_date - fact.start_date + 1)
11627 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom3 / (fact.end_date - fact.start_date + 1)
11628 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom3 / (fact.end_date - fact.start_date + 1)
11629 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom3 / (fact.end_date - fact.start_date + 1)
11630 			  , '0-1'  , fact.custom3
11631 			  , '1-1'  , fact.custom3
11632 			  , 0  ) -- end decode
11633 			    , 0  ) -- end nvl
11634 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11635 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom3
11636 	 , ROUND (
11637              NVL (
11638             DECODE (
11639                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11640 			  , '00'   , fact.custom4
11641 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (fact.end_date - fact.start_date + 1)
11642 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom4 / (fact.end_date - fact.start_date + 1)
11643 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom4 / (fact.end_date - fact.start_date + 1)
11644 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom4 / (fact.end_date - fact.start_date + 1)
11645 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom4 / (fact.end_date - fact.start_date + 1)
11646 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom4 / (fact.end_date - fact.start_date + 1)
11647 			  , '0-1'  , fact.custom4
11648 			  , '1-1'  , fact.custom4
11649 			  , 0  ) -- end decode
11650 			    , 0  ) -- end nvl
11651 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11652 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom4
11653 	 , ROUND (
11654              NVL (
11655             DECODE (
11656                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11657 			  , '00'   , fact.custom5
11658 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (fact.end_date - fact.start_date + 1)
11659 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom5 / (fact.end_date - fact.start_date + 1)
11660 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom5 / (fact.end_date - fact.start_date + 1)
11661 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom5 / (fact.end_date - fact.start_date + 1)
11662 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom5 / (fact.end_date - fact.start_date + 1)
11663 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom5 / (fact.end_date - fact.start_date + 1)
11664 			  , '0-1'  , fact.custom5
11665 			  , '1-1'  , fact.custom5
11666 			  , 0  ) -- end decode
11667 			    , 0  ) -- end nvl
11668 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11669 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom5
11670 	 , ROUND (
11671              NVL (
11672             DECODE (
11673                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11674 			  , '00'   , fact.custom6
11675 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (fact.end_date - fact.start_date + 1)
11676 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom6 / (fact.end_date - fact.start_date + 1)
11677 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom6 / (fact.end_date - fact.start_date + 1)
11678 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom6 / (fact.end_date - fact.start_date + 1)
11679 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom6 / (fact.end_date - fact.start_date + 1)
11680 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom6 / (fact.end_date - fact.start_date + 1)
11681 			  , '0-1'  , fact.custom6
11682 			  , '1-1'  , fact.custom6
11683 			  , 0  ) -- end decode
11684 			    , 0  ) -- end nvl
11685 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11686 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom6
11687 	 , ROUND (
11688              NVL (
11689             DECODE (
11690                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11691 			  , '00'   , fact.custom7
11692 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (fact.end_date - fact.start_date + 1)
11693 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom7 / (fact.end_date - fact.start_date + 1)
11694 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom7 / (fact.end_date - fact.start_date + 1)
11698 			  , '0-1'  , fact.custom7
11695 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom7 / (fact.end_date - fact.start_date + 1)
11696 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom7 / (fact.end_date - fact.start_date + 1)
11697 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom7 / (fact.end_date - fact.start_date + 1)
11699 			  , '1-1'  , fact.custom7
11700 			  , 0  ) -- end decode
11701 			    , 0  ) -- end nvl
11702 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11703 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom7
11704 	 , ROUND (
11705              NVL (
11706             DECODE (
11707                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11708 			  , '00'   , fact.custom8
11709 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (fact.end_date - fact.start_date + 1)
11710 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom8 / (fact.end_date - fact.start_date + 1)
11711 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom8 / (fact.end_date - fact.start_date + 1)
11712 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom8 / (fact.end_date - fact.start_date + 1)
11713 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom8 / (fact.end_date - fact.start_date + 1)
11714 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom8 / (fact.end_date - fact.start_date + 1)
11715 			  , '0-1'  , fact.custom8
11716 			  , '1-1'  , fact.custom8
11717 			  , 0  ) -- end decode
11718 			    , 0  ) -- end nvl
11719 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11720 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom8
11721 	 , ROUND (
11722              NVL (
11723             DECODE (
11724                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11725 			  , '00'   , fact.custom9
11726 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (fact.end_date - fact.start_date + 1)
11727 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom9 / (fact.end_date - fact.start_date + 1)
11728 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom9 / (fact.end_date - fact.start_date + 1)
11729 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom9 / (fact.end_date - fact.start_date + 1)
11730 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom9 / (fact.end_date - fact.start_date + 1)
11731 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom9 / (fact.end_date - fact.start_date + 1)
11732 			  , '0-1'  , fact.custom9
11733 			  , '1-1'  , fact.custom9
11734 			  , 0  ) -- end decode
11735 			    , 0  ) -- end nvl
11736 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11737 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom9
11738 	 , ROUND (
11739              NVL (
11740             DECODE (
11741                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11742 			  , '00'   , fact.custom10
11743 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (fact.end_date - fact.start_date + 1)
11744 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom10 / (fact.end_date - fact.start_date + 1)
11745 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom10 / (fact.end_date - fact.start_date + 1)
11746 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom10 / (fact.end_date - fact.start_date + 1)
11747 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom10 / (fact.end_date - fact.start_date + 1)
11748 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom10 / (fact.end_date - fact.start_date + 1)
11749 			  , '0-1'  , fact.custom10
11750 			  , '1-1'  , fact.custom10
11751 			  , 0  ) -- end decode
11752 			    , 0  ) -- end nvl
11753 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11754 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom10
11755 	 , ROUND (
11756              NVL (
11757             DECODE (
11758                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11759 			  , '00'   , fact.custom11
11760 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (fact.end_date - fact.start_date + 1)
11761 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom11 / (fact.end_date - fact.start_date + 1)
11762 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom11 / (fact.end_date - fact.start_date + 1)
11763 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom11 / (fact.end_date - fact.start_date + 1)
11764 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom11 / (fact.end_date - fact.start_date + 1)
11765 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom11 / (fact.end_date - fact.start_date + 1)
11766 			  , '0-1'  , fact.custom11
11767 			  , '1-1'  , fact.custom11
11768 			  , 0  ) -- end decode
11769 			    , 0  ) -- end nvl
11770 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11771 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom11
11772 	 , ROUND (
11773              NVL (
11774             DECODE (
11775                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11776 			  , '00'   , fact.custom12
11777 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (fact.end_date - fact.start_date + 1)
11781 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom12 / (fact.end_date - fact.start_date + 1)
11778 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom12 / (fact.end_date - fact.start_date + 1)
11779 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom12 / (fact.end_date - fact.start_date + 1)
11780 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom12 / (fact.end_date - fact.start_date + 1)
11782 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom12 / (fact.end_date - fact.start_date + 1)
11783 			  , '0-1'  , fact.custom12
11784 			  , '1-1'  , fact.custom12
11785 			  , 0  ) -- end decode
11786 			    , 0  ) -- end nvl
11787 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11788 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom12
11789 	 , ROUND (
11790              NVL (
11791             DECODE (
11792                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11793 			  , '00'   , fact.custom13
11794 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (fact.end_date - fact.start_date + 1)
11795 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom13 / (fact.end_date - fact.start_date + 1)
11796 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom13 / (fact.end_date - fact.start_date + 1)
11797 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom13 / (fact.end_date - fact.start_date + 1)
11798 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom13 / (fact.end_date - fact.start_date + 1)
11799 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom13 / (fact.end_date - fact.start_date + 1)
11800 			  , '0-1'  , fact.custom13
11801 			  , '1-1'  , fact.custom13
11802 			  , 0  ) -- end decode
11803 			    , 0  ) -- end nvl
11804 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11805 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom13
11806 	 , ROUND (
11807              NVL (
11808             DECODE (
11809                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11810 			  , '00'   , fact.custom14
11811 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (fact.end_date - fact.start_date + 1)
11812 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom14 / (fact.end_date - fact.start_date + 1)
11813 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom14 / (fact.end_date - fact.start_date + 1)
11814 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom14 / (fact.end_date - fact.start_date + 1)
11815 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom14 / (fact.end_date - fact.start_date + 1)
11816 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom14 / (fact.end_date - fact.start_date + 1)
11817 			  , '0-1'  , fact.custom14
11818 			  , '1-1'  , fact.custom14
11819 			  , 0  ) -- end decode
11820 			    , 0  ) -- end nvl
11821 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11822 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom14
11823 	 , ROUND (
11824              NVL (
11825             DECODE (
11826                      ( sign (fact.start_date - pa_cal.start_date) || sign (fact.end_date - pa_cal.end_date) )
11827 			  , '00'   , fact.custom15
11828 			  , '01'   , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (fact.end_date - fact.start_date + 1)
11829 			  , '-11'  , (pa_cal.end_date - pa_cal.start_date + 1) * fact.custom15 / (fact.end_date - fact.start_date + 1)
11830 			  , '10'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom15 / (fact.end_date - fact.start_date + 1)
11831 			  , '11'   , (pa_cal.end_date - fact.start_date + 1) * fact.custom15 / (fact.end_date - fact.start_date + 1)
11832 			  , '-10'  , (fact.end_date - pa_cal.start_date + 1) * fact.custom15 / (fact.end_date - fact.start_date + 1)
11833 			  , '-1-1' , (fact.end_date - pa_cal.start_date + 1) * fact.custom15 / (fact.end_date - fact.start_date + 1)
11834 			  , '0-1'  , fact.custom15
11835 			  , '1-1'  , fact.custom15
11836 			  , 0  ) -- end decode
11837 			    , 0  ) -- end nvl
11838 			/ PJI_UTILS.GET_MAU (fact.currency_code) )  -- end round
11839 						* PJI_UTILS.GET_MAU (fact.currency_code)	custom15
11840      , 'CF'   line_type
11841 	 , NULL time_dangling_flag
11842 	 , NULL rate_dangling_flag
11843    FROM   pji_fp_aggr_pjp1_t fact
11844    	 , pji_org_extr_info  orginfo
11845    	 , pji_time_cal_period  pa_cal
11846        , pji_fm_extr_plnver3_t  ver
11847    WHERE  1=1
11848       AND fact.CALENDAR_TYPE = 'A'
11849       AND fact.worker_id = g_worker_id
11850       AND fact.start_date IS NOT NULL
11851       AND fact.end_date IS NOT NULL
11852 	AND fact.time_dangling_flag IS NULL
11853 	AND fact.rate_dangling_flag IS NULL
11854       AND orginfo.org_id = fact.PROJECT_ORG_ID
11855       AND DECODE(p_calendar_type
11856                , 'P', orginfo.pa_calendar_id
11857                , 'G', orginfo.gl_calendar_id) = pa_cal.calendar_id
11858       AND (
11859 	       (     pa_cal.start_date >= fact.start_date
11860                AND pa_cal.end_date <= fact.end_date ) -- fsps,pefe
11861 	    OR (     pa_cal.start_date <= fact.start_date
11862                AND pa_cal.end_date >= fact.end_date ) -- psfs,fepe
11863 	    OR (     pa_cal.start_date <= fact.start_date
11864                AND pa_cal.end_date <= fact.end_date
11865                AND pa_cal.end_date >= fact.start_date ) -- psfspefe
11866 	    OR (     pa_cal.start_date >= fact.start_date
11870       AND fact.line_type = 'NTP'
11867                AND pa_cal.end_date >= fact.end_date
11868                AND pa_cal.start_date <= fact.end_date )  -- fspsfepe
11869           )
11871       AND fact.period_type_id = 2048
11872       AND fact.plan_version_id = ver.plan_version_id
11873       AND ver.wp_flag = 'N'
11874       AND ver.baselined_flag = 'Y'
11875       AND ver.time_phased_type_code = 'N'
11876       -- AND (ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
11877       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
11878 	  ) a
11879 	  GROUP BY
11880 	   a.PROJECT_ID
11881      , a.PROJECT_ORG_ID
11882      , a.PROJECT_ORGANIZATION_ID
11883      , a.PROJECT_ELEMENT_ID
11884      , a.TIME_ID
11885      , a.PERIOD_TYPE_ID
11886      , a.CALENDAR_TYPE
11887      , a.RBS_AGGR_LEVEL
11888      , a.WBS_ROLLUP_FLAG
11889      , a.PRG_ROLLUP_FLAG
11890      , a.CURR_RECORD_TYPE_ID
11891      , a.CURRENCY_CODE
11892      , a.RBS_ELEMENT_ID
11893      , a.RBS_VERSION_ID
11894      , a.PLAN_VERSION_ID
11895      , a.PLAN_TYPE_ID
11896 	 , a.LINE_TYPE
11897 	 , a.TIME_DANGLING_FLAG
11898 	 , a.RATE_DANGLING_FLAG;
11899 
11900 End for 4005006 */
11901 
11902     INSERT INTO pji_fp_aggr_pjp1_t  -- Non time phased entries..
11903     (
11904        worker_id
11905      , PROJECT_ID
11906      , PROJECT_ORG_ID
11907      , PROJECT_ORGANIZATION_ID
11908      -- , PARTITION_ID
11909      , PROJECT_ELEMENT_ID
11910      , TIME_ID
11911      , PERIOD_TYPE_ID
11912      , CALENDAR_TYPE
11913      , RBS_AGGR_LEVEL
11914      , WBS_ROLLUP_FLAG
11915      , PRG_ROLLUP_FLAG
11916      , CURR_RECORD_TYPE_ID
11917      , CURRENCY_CODE
11918      , RBS_ELEMENT_ID
11919      , RBS_VERSION_ID
11920      , PLAN_VERSION_ID
11921      , PLAN_TYPE_ID
11922      , RAW_COST
11923      , BRDN_COST
11924      , REVENUE
11925      , BILL_RAW_COST
11926      , BILL_BRDN_COST
11927      , BILL_LABOR_RAW_COST
11928      , BILL_LABOR_BRDN_COST
11929      , BILL_LABOR_HRS
11930      , EQUIPMENT_RAW_COST
11931      , EQUIPMENT_BRDN_COST
11932      , CAPITALIZABLE_RAW_COST
11933      , CAPITALIZABLE_BRDN_COST
11934      , LABOR_RAW_COST
11935      , LABOR_BRDN_COST
11936      , LABOR_HRS
11937      , LABOR_REVENUE
11938      , EQUIPMENT_HOURS
11939      , BILLABLE_EQUIPMENT_HOURS
11940      , SUP_INV_COMMITTED_COST
11941      , PO_COMMITTED_COST
11942      , PR_COMMITTED_COST
11943      , OTH_COMMITTED_COST
11944      , ACT_LABOR_HRS
11945      , ACT_EQUIP_HRS
11946      , ACT_LABOR_BRDN_COST
11947      , ACT_EQUIP_BRDN_COST
11948      , ACT_BRDN_COST
11949      , ACT_RAW_COST
11950      , ACT_REVENUE
11951      , ACT_LABOR_RAW_COST
11952      , ACT_EQUIP_RAW_COST
11953      , ETC_LABOR_HRS
11954      , ETC_EQUIP_HRS
11955      , ETC_LABOR_BRDN_COST
11956      , ETC_EQUIP_BRDN_COST
11957      , ETC_BRDN_COST
11958      , ETC_RAW_COST
11959      , ETC_LABOR_RAW_COST
11960      , ETC_EQUIP_RAW_COST
11961      , CUSTOM1
11962      , CUSTOM2
11963      , CUSTOM3
11964      , CUSTOM4
11965      , CUSTOM5
11966      , CUSTOM6
11967      , CUSTOM7
11968      , CUSTOM8
11969      , CUSTOM9
11970      , CUSTOM10
11971      , CUSTOM11
11972      , CUSTOM12
11973      , CUSTOM13
11974      , CUSTOM14
11975      , CUSTOM15
11976      , TIME_DANGLING_FLAG
11977      , RATE_DANGLING_FLAG
11978      , PRG_LEVEL
11979      , PLAN_TYPE_CODE
11980 	)
11981    SELECT
11982        g_worker_id  worker_id
11983      , a.PROJECT_ID
11984      , a.PROJECT_ORG_ID
11985      , a.PROJECT_ORGANIZATION_ID
11986      , a.PROJECT_ELEMENT_ID
11987      , a.TIME_ID
11988      , 32 -- a.PERIOD_TYPE_ID
11989      , a.CALENDAR_TYPE
11990      , a.RBS_AGGR_LEVEL
11991      , a.WBS_ROLLUP_FLAG
11992      , a.PRG_ROLLUP_FLAG
11993      , a.CURR_RECORD_TYPE_ID
11994      , a.CURRENCY_CODE
11995      , a.RBS_ELEMENT_ID
11996      , a.RBS_VERSION_ID
11997      , a.PLAN_VERSION_ID
11998      , a.PLAN_TYPE_ID
11999      , SUM(ROUND (nvl(a.raw_cost,0)*a.factor/a.mau)*a.mau) raw_cost
12000      , SUM(ROUND (nvl(a.brdn_cost,0)*a.factor/a.mau)*a.mau) brdn_cost
12001      , SUM(ROUND (nvl(a.revenue,0)*a.factor/a.mau)*a.mau) revenue
12002      , SUM(ROUND (nvl(a.bill_raw_cost,0)*a.factor/a.mau)*a.mau) bill_raw_cost
12003      , SUM(ROUND (nvl(a.bill_brdn_cost,0)*a.factor/a.mau)*a.mau) bill_brdn_cost
12004      , SUM(ROUND (nvl(a.bill_labor_raw_cost,0)*a.factor/a.mau)*a.mau) bill_labor_raw_cost
12005      , SUM(ROUND (nvl(a.bill_labor_brdn_cost,0)*a.factor/a.mau)*a.mau) bill_labor_brdn_cost
12006      , SUM(ROUND (nvl(a.bill_labor_hrs,0)*a.factor/a.mau)*a.mau) bill_labor_hrs
12007      , SUM(ROUND (nvl(a.equipment_raw_cost,0)*a.factor/a.mau)*a.mau) equipment_raw_cost
12008      , SUM(ROUND (nvl(a.equipment_brdn_cost,0)*a.factor/a.mau)*a.mau) equipment_brdn_cost
12009      , SUM(ROUND (nvl(a.capitalizable_raw_cost,0)*a.factor/a.mau)*a.mau) capitalizable_raw_cost
12010      , SUM(ROUND (nvl(a.capitalizable_brdn_cost,0)*a.factor/a.mau)*a.mau) capitalizable_brdn_cost
12011      , SUM(ROUND (nvl(a.labor_raw_cost,0)*a.factor/a.mau)*a.mau) labor_raw_cost
12012      , SUM(ROUND (nvl(a.labor_brdn_cost,0)*a.factor/a.mau)*a.mau) labor_brdn_cost
12013      , SUM(ROUND (nvl(a.labor_hrs,0)*a.factor/a.mau)*a.mau) labor_hrs
12014      , SUM(ROUND (nvl(a.labor_revenue,0)*a.factor/a.mau)*a.mau) labor_revenue
12015      , SUM(ROUND (nvl(a.equipment_hours,0)*a.factor/a.mau)*a.mau) equipment_hours
12016      , SUM(ROUND (nvl(a.billable_equipment_hours,0)*a.factor/a.mau)*a.mau) billable_equipment_hours         , SUM(ROUND (nvl(a.sup_inv_committed_cost,0)*a.factor/a.mau)*a.mau) sup_inv_committed_cost
12017      , SUM(ROUND (nvl(a.po_committed_cost,0)*a.factor/a.mau)*a.mau) po_committed_cost
12018      , SUM(ROUND (nvl(a.pr_committed_cost,0)*a.factor/a.mau)*a.mau) pr_committed_cost
12019      , SUM(ROUND (nvl(a.oth_committed_cost,0)*a.factor/a.mau)*a.mau) oth_committed_cost
12020      , SUM(ROUND (nvl(a.ACT_LABOR_HRS,0)*a.factor/a.mau)*a.mau) ACT_LABOR_HRS
12021      , SUM(ROUND (nvl(a.ACT_EQUIP_HRS,0)*a.factor/a.mau)*a.mau) ACT_EQUIP_HRS
12022      , SUM(ROUND (nvl(a.ACT_LABOR_BRDN_COST,0)*a.factor/a.mau)*a.mau) ACT_LABOR_BRDN_COST
12023      , SUM(ROUND (nvl(a.ACT_EQUIP_BRDN_COST,0)*a.factor/a.mau)*a.mau) ACT_EQUIP_BRDN_COST
12024      , SUM(ROUND (nvl(a.ACT_BRDN_COST,0)*a.factor/a.mau)*a.mau) ACT_BRDN_COST
12025      , SUM(ROUND (nvl(a.ACT_RAW_COST,0)*a.factor/a.mau)*a.mau) ACT_RAW_COST
12026      , SUM(ROUND (nvl(a.ACT_REVENUE,0)*a.factor/a.mau)*a.mau) ACT_REVENUE
12027      , SUM(ROUND (nvl(a.ACT_LABOR_RAW_COST,0)*a.factor/a.mau)*a.mau) ACT_LABOR_RAW_COST
12028      , SUM(ROUND (nvl(a.ACT_EQUIP_RAW_COST,0)*a.factor/a.mau)*a.mau) ACT_EQUIP_RAW_COST
12029      , SUM(ROUND (nvl(a.ETC_LABOR_HRS,0)*a.factor/a.mau)*a.mau) ETC_LABOR_HRS
12030      , SUM(ROUND (nvl(a.ETC_EQUIP_HRS,0)*a.factor/a.mau)*a.mau) ETC_EQUIP_HRS
12031      , SUM(ROUND (nvl(a.ETC_LABOR_BRDN_COST,0)*a.factor/a.mau)*a.mau) ETC_LABOR_BRDN_COST
12035      , SUM(ROUND (nvl(a.ETC_LABOR_RAW_COST,0)*a.factor/a.mau)*a.mau) ETC_LABOR_RAW_COST
12032      , SUM(ROUND (nvl(a.ETC_EQUIP_BRDN_COST,0)*a.factor/a.mau)*a.mau) ETC_EQUIP_BRDN_COST
12033      , SUM(ROUND (nvl(a.ETC_BRDN_COST,0)*a.factor/a.mau)*a.mau) ETC_BRDN_COST
12034      , SUM(ROUND (nvl(a.ETC_RAW_COST,0)*a.factor/a.mau)*a.mau) ETC_RAW_COST
12036      , SUM(ROUND (nvl(a.ETC_EQUIP_RAW_COST,0)*a.factor/a.mau)*a.mau) ETC_EQUIP_RAW_COST
12037      , SUM(ROUND (nvl(a.custom1,0)*a.factor/a.mau)*a.mau) custom1
12038      , SUM(ROUND (nvl(a.custom2,0)*a.factor/a.mau)*a.mau) custom2
12039      , SUM(ROUND (nvl(a.custom3,0)*a.factor/a.mau)*a.mau) custom3
12040      , SUM(ROUND (nvl(a.custom4,0)*a.factor/a.mau)*a.mau) custom4
12041      , SUM(ROUND (nvl(a.custom5,0)*a.factor/a.mau)*a.mau) custom5
12042      , SUM(ROUND (nvl(a.custom6,0)*a.factor/a.mau)*a.mau) custom6
12043      , SUM(ROUND (nvl(a.custom7,0)*a.factor/a.mau)*a.mau) custom7
12044      , SUM(ROUND (nvl(a.custom8,0)*a.factor/a.mau)*a.mau) custom8
12045      , SUM(ROUND (nvl(a.custom9,0)*a.factor/a.mau)*a.mau) custom9
12046      , SUM(ROUND (nvl(a.custom10,0)*a.factor/a.mau)*a.mau) custom10
12047      , SUM(ROUND (nvl(a.custom11,0)*a.factor/a.mau)*a.mau) custom11
12048      , SUM(ROUND (nvl(a.custom12,0)*a.factor/a.mau)*a.mau) custom12
12049      , SUM(ROUND (nvl(a.custom13,0)*a.factor/a.mau)*a.mau) custom13
12050      , SUM(ROUND (nvl(a.custom14,0)*a.factor/a.mau)*a.mau) custom14
12051      , SUM(ROUND (nvl(a.custom15,0)*a.factor/a.mau)*a.mau) custom15
12052      , a.TIME_DANGLING_FLAG
12053      , a.RATE_DANGLING_FLAG
12054      , g_default_prg_level prg_level
12055      , a.plan_type_code plan_type_Code   /* 4471527 */
12056   FROM (
12057    SELECT /*+ NO_MERGE */
12058            fact.project_id  project_id
12059    	 , fact.project_ORG_ID project_ORG_ID
12060    	 , fact.project_ORGANIZATION_ID project_ORGANIZATION_ID
12061    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
12062    	 , pa_cal.cal_period_id TIME_ID
12063    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
12064          , p_calendar_type  CALENDAR_TYPE
12065          , fact.RBS_AGGR_LEVEL
12066          , fact.WBS_ROLLUP_FLAG
12067          , fact.PRG_ROLLUP_FLAG
12068    	 , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
12069    	 , fact.CURRENCY_CODE CURRENCY_CODE
12070    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
12071    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
12072    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
12073 	 , fact.PLAN_TYPE_ID  PLAN_TYPE_ID
12074          , fact.raw_cost
12075          , fact.brdn_cost
12076          , fact.revenue
12077          , fact.bill_raw_cost
12078          , fact.bill_brdn_cost
12079          , fact.bill_labor_raw_cost
12080          , fact.bill_labor_brdn_cost
12081          , fact.bill_labor_hrs
12082          , fact.equipment_raw_cost
12083          , fact.equipment_brdn_cost
12084          , fact.capitalizable_raw_cost
12085          , fact.capitalizable_brdn_cost
12086          , fact.labor_raw_cost
12087          , fact.labor_brdn_cost
12088          , fact.labor_hrs
12089          , fact.labor_revenue
12090          , fact.equipment_hours
12091          , fact.billable_equipment_hours
12092          , fact.sup_inv_committed_cost
12093          , fact.po_committed_cost
12094          , fact.pr_committed_cost
12095          , fact.oth_committed_cost
12096          , fact.ACT_LABOR_HRS
12097          , fact.ACT_EQUIP_HRS
12098          , fact.ACT_LABOR_BRDN_COST
12099          , fact.ACT_EQUIP_BRDN_COST
12100          , fact.ACT_BRDN_COST
12101          , fact.ACT_RAW_COST
12102          , fact.ACT_REVENUE
12103          , fact.ACT_LABOR_RAW_COST
12104          , fact.ACT_EQUIP_RAW_COST
12105          , fact.ETC_LABOR_HRS
12106          , fact.ETC_EQUIP_HRS
12107          , fact.ETC_LABOR_BRDN_COST
12108          , fact.ETC_EQUIP_BRDN_COST
12109          , fact.ETC_BRDN_COST
12110          , fact.ETC_RAW_COST
12111          , fact.ETC_LABOR_RAW_COST
12112          , fact.ETC_EQUIP_RAW_COST
12113          , fact.custom1
12114          , fact.custom2
12115          , fact.custom3
12116          , fact.custom4
12117          , fact.custom5
12118          , fact.custom6
12119          , fact.custom7
12120          , fact.custom8
12121          , fact.custom9
12122          , fact.custom10
12123          , fact.custom11
12124          , fact.custom12
12125          , fact.custom13
12126          , fact.custom14
12127          , fact.custom15
12128 	 , NULL time_dangling_flag
12129 	 , NULL rate_dangling_flag
12130          , cur.mau mau
12131          , (LEAST(fact.end_date,pa_cal.end_date) - Greatest(fact.start_date,pa_cal.start_date)+1)
12132                               / (fact.end_date - fact.start_date+1) factor
12133           , fact.plan_type_code    plan_type_code   /* 4471527 */
12134    FROM    pji_fp_aggr_pjp1_t fact
12135    	 , pji_org_extr_info  orginfo
12136    	 , pji_time_cal_period_v  pa_cal
12137          , pji_fm_extr_plnver3_t  ver
12138          ,(SELECT currency_code,
12139                    decode(nvl(MINIMUM_ACCOUNTABLE_UNIT, power(10, (-1 * PRECISION))),
12140                       null, 0.01,
12141                          0, 1,
12142                          nvl(MINIMUM_ACCOUNTABLE_UNIT, power(10, (-1 * PRECISION)))) mau
12143               FROM FND_CURRENCIES) cur
12144    WHERE  1=1
12145       AND fact.CALENDAR_TYPE = 'A'
12146       AND fact.worker_id = g_worker_id
12147       AND fact.start_date IS NOT NULL
12148       AND fact.end_date IS NOT NULL
12149       AND fact.time_dangling_flag IS NULL
12150       AND fact.rate_dangling_flag IS NULL
12151       AND orginfo.org_id = fact.PROJECT_ORG_ID
12152       AND DECODE(p_calendar_type
12153                , 'P', orginfo.pa_calendar_id
12154                , 'G', orginfo.gl_calendar_id) = pa_cal.calendar_id
12155       AND fact.line_type = 'NTP'
12156       AND fact.period_type_id = 2048
12157       AND fact.plan_version_id = ver.plan_version_id
12161       AND ver.time_phased_type_code = 'N'
12158       ANd fact.plan_type_code = ver.plan_type_code   /* 4471527 */
12159       AND ver.wp_flag = 'N'
12160       AND ver.baselined_flag = 'Y'
12162       AND ( fact.start_date <= pa_cal.end_date AND fact.end_date >= pa_cal.start_date )
12163       -- AND (ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
12164       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
12165       AND cur.currency_code = fact.currency_code
12166 	  ) a
12167       WHERE a.factor >0
12168    GROUP BY
12169        a.PROJECT_ID
12170      , a.PROJECT_ORG_ID
12171      , a.PROJECT_ORGANIZATION_ID
12172      , a.PROJECT_ELEMENT_ID
12173      , a.TIME_ID
12174      , a.PERIOD_TYPE_ID
12175      , a.CALENDAR_TYPE
12176      , a.RBS_AGGR_LEVEL
12177      , a.WBS_ROLLUP_FLAG
12178      , a.PRG_ROLLUP_FLAG
12179      , a.CURR_RECORD_TYPE_ID
12180      , a.CURRENCY_CODE
12181      , a.RBS_ELEMENT_ID
12182      , a.RBS_VERSION_ID
12183      , a.PLAN_VERSION_ID
12184      , a.PLAN_TYPE_ID
12185      , a.PLAN_TYPE_CODE    /* 4471527 */
12186 	 , a.TIME_DANGLING_FLAG
12187 	 , a.RATE_DANGLING_FLAG;
12188 
12189 
12190 EXCEPTION
12191   WHEN OTHERS THEN
12192     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
12193                              p_procedure_name => ' PRORATE_TO_PAGL_N_PJP1_D ');
12194     RAISE;
12195 END;
12196 
12197 
12198 PROCEDURE PRORATE_TO_PAGL_PGE_PJP1_SE (p_calendar_type    IN  VARCHAR2 := NULL,
12199                                        p_prorating_format IN  VARCHAR2) IS
12200 BEGIN
12201 
12202     -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
12203 
12204 /* Commented for bug 4005006
12205     INSERT INTO pji_fp_aggr_pjp1_t -- For PA/GL entries.
12206     (
12207        worker_id
12208      , PROJECT_ID
12209      , PROJECT_ORG_ID
12210      , PROJECT_ORGANIZATION_ID
12211      -- , PARTITION_ID
12212      , PROJECT_ELEMENT_ID
12213      , TIME_ID
12214      , PERIOD_TYPE_ID
12215      , CALENDAR_TYPE
12216      , RBS_AGGR_LEVEL
12217      , WBS_ROLLUP_FLAG
12218      , PRG_ROLLUP_FLAG
12219      , CURR_RECORD_TYPE_ID
12220      , CURRENCY_CODE
12221      , RBS_ELEMENT_ID
12222      , RBS_VERSION_ID
12223      , PLAN_VERSION_ID
12224      , PLAN_TYPE_ID
12225      , RAW_COST
12226      , BRDN_COST
12227      , REVENUE
12228      , BILL_RAW_COST
12229      , BILL_BRDN_COST
12230      , BILL_LABOR_RAW_COST
12231      , BILL_LABOR_BRDN_COST
12232      , BILL_LABOR_HRS
12233      , EQUIPMENT_RAW_COST
12234      , EQUIPMENT_BRDN_COST
12235      , CAPITALIZABLE_RAW_COST
12236      , CAPITALIZABLE_BRDN_COST
12237      , LABOR_RAW_COST
12238      , LABOR_BRDN_COST
12239      , LABOR_HRS
12240      , LABOR_REVENUE
12241      , EQUIPMENT_HOURS
12242      , BILLABLE_EQUIPMENT_HOURS
12243      , SUP_INV_COMMITTED_COST
12244      , PO_COMMITTED_COST
12245      , PR_COMMITTED_COST
12246      , OTH_COMMITTED_COST
12247        , ACT_LABOR_HRS
12248 	   , ACT_EQUIP_HRS
12249 	   , ACT_LABOR_BRDN_COST
12250 	   , ACT_EQUIP_BRDN_COST
12251 	   , ACT_BRDN_COST
12252 	   , ACT_RAW_COST
12253 	   , ACT_REVENUE
12254          , ACT_LABOR_RAW_COST
12255          , ACT_EQUIP_RAW_COST
12256 	   , ETC_LABOR_HRS
12257 	   , ETC_EQUIP_HRS
12258 	   , ETC_LABOR_BRDN_COST
12259 	   , ETC_EQUIP_BRDN_COST
12260 	   , ETC_BRDN_COST
12261          , ETC_RAW_COST
12262          , ETC_LABOR_RAW_COST
12263          , ETC_EQUIP_RAW_COST
12264      , CUSTOM1
12265      , CUSTOM2
12266      , CUSTOM3
12267      , CUSTOM4
12268      , CUSTOM5
12269      , CUSTOM6
12270      , CUSTOM7
12271      , CUSTOM8
12272      , CUSTOM9
12273      , CUSTOM10
12274      , CUSTOM11
12275      , CUSTOM12
12276      , CUSTOM13
12277      , CUSTOM14
12278      , CUSTOM15
12279      , LINE_TYPE
12280      , TIME_DANGLING_FLAG
12281      , RATE_DANGLING_FLAG
12282      , PRG_LEVEL
12283 	)
12284    SELECT
12285          g_worker_id
12286        , fact.project_id  project_id
12287 	 , fact.PROJECT_ORG_ID project_org_id
12288 	 , fact.PROJECT_ORGANIZATION_ID project_organization_id
12289      -- , fact.PARTITION_ID PARTITION_ID
12290    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
12291    	 , pa_cal.cal_period_id TIME_ID
12292    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
12293    	 , DECODE(fact.CALENDAR_TYPE, 'P', 'G', 'G', 'P') CALENDAR_TYPE
12294      , fact.RBS_AGGR_LEVEL RBS_AGGR_LEVEL
12295      , fact.WBS_ROLLUP_FLAG WBS_ROLLUP_FLAG
12296      , fact.PRG_ROLLUP_FLAG PRG_ROLLUP_FLAG
12297      , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
12298    	 , fact.CURRENCY_CODE CURRENCY_CODE
12299    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
12300    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
12301    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
12302    	 , fact.PLAN_TYPE_ID PLAN_TYPE_ID
12303    	 , MAX(fact.RAW_COST)	 raw_cost
12304    	 , MAX(fact.BRDN_COST) BRDN_COST
12305    	 , MAX(fact.REVENUE) REVENUE
12306    	 , MAX(fact.BILL_RAW_COST) BILL_RAW_COST
12307    	 , MAX(fact.BILL_BRDN_COST) BILL_BRDN_COST
12308    	 , MAX(fact.BILL_LABOR_RAW_COST) BILL_LABOR_RAW_COST
12309    	 , MAX(fact.BILL_LABOR_BRDN_COST) BILL_LABOR_BRDN_COST
12310    	 , MAX(fact.BILL_LABOR_HRS) BILL_LABOR_HRS
12311    	 , MAX(fact.EQUIPMENT_RAW_COST) EQUIPMENT_RAW_COST
12312    	 , MAX(fact.EQUIPMENT_BRDN_COST) EQUIPMENT_BRDN_COST
12313    	 , MAX(fact.CAPITALIZABLE_RAW_COST) CAPITALIZABLE_RAW_COST
12314    	 , MAX(fact.CAPITALIZABLE_BRDN_COST) CAPITALIZABLE_BRDN_COST
12315    	 , MAX(fact.LABOR_RAW_COST) LABOR_RAW_COST
12316    	 , MAX(fact.LABOR_BRDN_COST) LABOR_BRDN_COST
12317    	 , MAX(fact.LABOR_HRS) LABOR_HRS
12321    	 , MAX(fact.SUP_INV_COMMITTED_COST) SUP_INV_COMMITTED_COST
12318    	 , MAX(fact.LABOR_REVENUE) LABOR_REVENUE
12319    	 , MAX(fact.EQUIPMENT_HOURS) EQUIPMENT_HOURS
12320    	 , MAX(fact.BILLABLE_EQUIPMENT_HOURS) BILLABLE_EQUIPMENT_HOURS
12322    	 , MAX(fact.PO_COMMITTED_COST) PO_COMMITTED_COST
12323    	 , MAX(fact.PR_COMMITTED_COST) PR_COMMITTED_COST
12324    	 , MAX(fact.OTH_COMMITTED_COST) OTH_COMMITTED_COST
12325        , MAX(fact.ACT_LABOR_HRS )
12326 	 , MAX(fact.ACT_EQUIP_HRS )
12327 	 , MAX(fact.ACT_LABOR_BRDN_COST )
12328 	 , MAX(fact.ACT_EQUIP_BRDN_COST )
12329 	 , MAX(fact.ACT_BRDN_COST )
12330 	 , MAX(fact.ACT_RAW_COST )
12331 	 , MAX(fact.ACT_REVENUE )
12332        , MAX(fact.ACT_LABOR_RAW_COST)
12333        , MAX(fact.ACT_EQUIP_RAW_COST)
12334 	 , MAX(fact.ETC_LABOR_HRS )
12335 	 , MAX(fact.ETC_EQUIP_HRS )
12336 	 , MAX(fact.ETC_LABOR_BRDN_COST )
12337 	 , MAX(fact.ETC_EQUIP_BRDN_COST )
12338 	 , MAX(fact.ETC_BRDN_COST )
12339        , MAX(fact.ETC_RAW_COST )
12340        , MAX(fact.ETC_LABOR_RAW_COST)
12341        , MAX(fact.ETC_EQUIP_RAW_COST)
12342    	 , MAX(fact.CUSTOM1) CUSTOM1
12343    	 , MAX(fact.CUSTOM2) CUSTOM2
12344    	 , MAX(fact.CUSTOM3) CUSTOM3
12345    	 , MAX(fact.CUSTOM4) CUSTOM4
12346    	 , MAX(fact.CUSTOM5) CUSTOM5
12347    	 , MAX(fact.CUSTOM6) CUSTOM6
12348    	 , MAX(fact.CUSTOM7) CUSTOM7
12349    	 , MAX(fact.CUSTOM8) CUSTOM8
12350    	 , MAX(fact.CUSTOM9) CUSTOM9
12351    	 , MAX(fact.CUSTOM10) CUSTOM10
12352    	 , MAX(fact.CUSTOM11) CUSTOM11
12353    	 , MAX(fact.CUSTOM12) CUSTOM12
12354    	 , MAX(fact.CUSTOM13) CUSTOM13
12355    	 , MAX(fact.CUSTOM14) CUSTOM14
12356    	 , MAX(fact.CUSTOM15) CUSTOM15
12357    	 -- , DECODE ('E', 'E', MAX(pa_cal.start_date), 'S', MIN(pa_cal.start_date)) start_date
12358    	 -- , DECODE ('E', 'E', MAX(pa_cal.end_date), 'S', MIN(pa_cal.end_date))	 end_date
12359        , 'CF'   line_type
12360 	 , NULL TIME_DANGLING_FLAG
12361 	 , NULL RATE_DANGLING_FLAG
12362        , g_default_prg_level prg_level
12363    FROM   pji_fp_aggr_pjp1_t fact
12364         , pji_time_cal_period  non_pa_cal
12365    	 , pji_org_extr_info  orginfo
12366    	 , pji_time_cal_period  pa_cal
12367        , pji_fm_extr_plnver3_t  ver
12368    WHERE  fact.CALENDAR_TYPE <> p_calendar_type
12369       AND fact.worker_id = g_worker_id
12370       AND fact.CALENDAR_TYPE IN ('P', 'G')
12371       AND non_pa_cal.cal_period_id = fact.time_id
12372       AND fact.line_type like 'OF%'
12373       AND orginfo.org_id = fact.PROJECT_ORG_ID
12374       AND DECODE(fact.calendar_type, 'P', orginfo.gl_calendar_id, 'G', orginfo.pa_calendar_id) = pa_cal.calendar_id
12375       AND pa_cal.start_date >= non_pa_cal.start_date
12376       AND ( non_pa_cal.end_date <= pa_cal.end_date AND non_pa_cal.end_date >= pa_cal.start_date )
12377       AND fact.period_type_id = 32
12378       AND fact.plan_version_id = ver.plan_version_id
12379       AND ver.wp_flag = 'N'
12380       AND ver.baselined_flag = 'Y'
12381 	-- AND (ver.rbs_struct_version_id = fact.rbs_version_id OR fact.rbs_version_id = -1)
12382       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
12383    GROUP BY
12384        fact.project_id
12385 	 , fact.PROJECT_ORG_ID
12386 	 , fact.PROJECT_ORGANIZATION_ID
12387      -- , fact.PARTITION_ID
12388    	 , fact.PROJECT_ELEMENT_ID
12389    	 , pa_cal.cal_period_id
12390    	 , fact.PERIOD_TYPE_ID
12391    	 , fact.CALENDAR_TYPE
12392      , fact.RBS_AGGR_LEVEL
12393      , fact.WBS_ROLLUP_FLAG
12394      , fact.PRG_ROLLUP_FLAG
12395      , fact.CURR_RECORD_TYPE_ID
12396    	 , fact.CURRENCY_CODE
12397    	 , fact.RBS_ELEMENT_ID
12398    	 , fact.RBS_VERSION_ID
12399    	 , fact.PLAN_VERSION_ID
12400    	 , fact.PLAN_TYPE_ID ;
12401 
12402 End of bug 4005006*/
12403 
12404     INSERT INTO pji_fp_aggr_pjp1_t -- For PA/GL entries.
12405     (
12406        worker_id
12407      , PROJECT_ID
12408      , PROJECT_ORG_ID
12409      , PROJECT_ORGANIZATION_ID
12410      , PROJECT_ELEMENT_ID
12411      , TIME_ID
12412      , PERIOD_TYPE_ID
12413      , CALENDAR_TYPE
12414      , RBS_AGGR_LEVEL
12415      , WBS_ROLLUP_FLAG
12416      , PRG_ROLLUP_FLAG
12417      , CURR_RECORD_TYPE_ID
12418      , CURRENCY_CODE
12419      , RBS_ELEMENT_ID
12420      , RBS_VERSION_ID
12421      , PLAN_VERSION_ID
12422      , PLAN_TYPE_ID
12423      , RAW_COST
12424      , BRDN_COST
12425      , REVENUE
12426      , BILL_RAW_COST
12427      , BILL_BRDN_COST
12428      , BILL_LABOR_RAW_COST
12429      , BILL_LABOR_BRDN_COST
12430      , BILL_LABOR_HRS
12431      , EQUIPMENT_RAW_COST
12432      , EQUIPMENT_BRDN_COST
12433      , CAPITALIZABLE_RAW_COST
12434      , CAPITALIZABLE_BRDN_COST
12435      , LABOR_RAW_COST
12436      , LABOR_BRDN_COST
12437      , LABOR_HRS
12438      , LABOR_REVENUE
12439      , EQUIPMENT_HOURS
12440      , BILLABLE_EQUIPMENT_HOURS
12441      , SUP_INV_COMMITTED_COST
12442      , PO_COMMITTED_COST
12443      , PR_COMMITTED_COST
12444      , OTH_COMMITTED_COST
12445      , ACT_LABOR_HRS
12446      , ACT_EQUIP_HRS
12447      , ACT_LABOR_BRDN_COST
12448      , ACT_EQUIP_BRDN_COST
12449      , ACT_BRDN_COST
12450      , ACT_RAW_COST
12451      , ACT_REVENUE
12452      , ACT_LABOR_RAW_COST
12453      , ACT_EQUIP_RAW_COST
12454      , ETC_LABOR_HRS
12455      , ETC_EQUIP_HRS
12456      , ETC_LABOR_BRDN_COST
12457      , ETC_EQUIP_BRDN_COST
12458      , ETC_BRDN_COST
12459      , ETC_RAW_COST
12460      , ETC_LABOR_RAW_COST
12461      , ETC_EQUIP_RAW_COST
12462      , CUSTOM1
12463      , CUSTOM2
12464      , CUSTOM3
12465      , CUSTOM4
12466      , CUSTOM5
12467      , CUSTOM6
12468      , CUSTOM7
12469      , CUSTOM8
12470      , CUSTOM9
12471      , CUSTOM10
12472      , CUSTOM11
12476      , CUSTOM15
12473      , CUSTOM12
12474      , CUSTOM13
12475      , CUSTOM14
12477      , TIME_DANGLING_FLAG
12478      , RATE_DANGLING_FLAG
12479      , PRG_LEVEL
12480      , PLAN_TYPE_CODE    /* 4471527 */
12481 	)
12482    SELECT
12483            g_worker_id
12484          , fact.project_id  project_id
12485 	 , fact.PROJECT_ORG_ID project_org_id
12486 	 , fact.PROJECT_ORGANIZATION_ID project_organization_id
12487    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
12488    	 , pa_cal.cal_period_id TIME_ID
12489    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
12490    	 , DECODE(fact.CALENDAR_TYPE, 'P', 'G', 'G', 'P') CALENDAR_TYPE
12491          , fact.RBS_AGGR_LEVEL RBS_AGGR_LEVEL
12492          , fact.WBS_ROLLUP_FLAG WBS_ROLLUP_FLAG
12493          , fact.PRG_ROLLUP_FLAG PRG_ROLLUP_FLAG
12494          , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
12495    	 , fact.CURRENCY_CODE CURRENCY_CODE
12496    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
12497    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
12498    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
12499    	 , fact.PLAN_TYPE_ID PLAN_TYPE_ID
12500    	 , SUM(fact.RAW_COST)	 raw_cost
12501    	 , SUM(fact.BRDN_COST) BRDN_COST
12502    	 , SUM(fact.REVENUE) REVENUE
12503    	 , SUM(fact.BILL_RAW_COST) BILL_RAW_COST
12504    	 , SUM(fact.BILL_BRDN_COST) BILL_BRDN_COST
12505    	 , SUM(fact.BILL_LABOR_RAW_COST) BILL_LABOR_RAW_COST
12506    	 , SUM(fact.BILL_LABOR_BRDN_COST) BILL_LABOR_BRDN_COST
12507    	 , SUM(fact.BILL_LABOR_HRS) BILL_LABOR_HRS
12508    	 , SUM(fact.EQUIPMENT_RAW_COST) EQUIPMENT_RAW_COST
12509    	 , SUM(fact.EQUIPMENT_BRDN_COST) EQUIPMENT_BRDN_COST
12510    	 , SUM(fact.CAPITALIZABLE_RAW_COST) CAPITALIZABLE_RAW_COST
12511    	 , SUM(fact.CAPITALIZABLE_BRDN_COST) CAPITALIZABLE_BRDN_COST
12512    	 , SUM(fact.LABOR_RAW_COST) LABOR_RAW_COST
12513    	 , SUM(fact.LABOR_BRDN_COST) LABOR_BRDN_COST
12514    	 , SUM(fact.LABOR_HRS) LABOR_HRS
12515    	 , SUM(fact.LABOR_REVENUE) LABOR_REVENUE
12516    	 , SUM(fact.EQUIPMENT_HOURS) EQUIPMENT_HOURS
12517    	 , SUM(fact.BILLABLE_EQUIPMENT_HOURS) BILLABLE_EQUIPMENT_HOURS
12518    	 , SUM(fact.SUP_INV_COMMITTED_COST) SUP_INV_COMMITTED_COST
12519    	 , SUM(fact.PO_COMMITTED_COST) PO_COMMITTED_COST
12520    	 , SUM(fact.PR_COMMITTED_COST) PR_COMMITTED_COST
12521    	 , SUM(fact.OTH_COMMITTED_COST) OTH_COMMITTED_COST
12522          , SUM(fact.ACT_LABOR_HRS )
12523 	 , SUM(fact.ACT_EQUIP_HRS )
12524 	 , SUM(fact.ACT_LABOR_BRDN_COST )
12525 	 , SUM(fact.ACT_EQUIP_BRDN_COST )
12526 	 , SUM(fact.ACT_BRDN_COST )
12527 	 , SUM(fact.ACT_RAW_COST )
12528 	 , SUM(fact.ACT_REVENUE )
12529          , SUM(fact.ACT_LABOR_RAW_COST)
12530          , SUM(fact.ACT_EQUIP_RAW_COST)
12531 	 , SUM(fact.ETC_LABOR_HRS )
12532 	 , SUM(fact.ETC_EQUIP_HRS )
12533 	 , SUM(fact.ETC_LABOR_BRDN_COST )
12534 	 , SUM(fact.ETC_EQUIP_BRDN_COST )
12535 	 , SUM(fact.ETC_BRDN_COST )
12536          , SUM(fact.ETC_RAW_COST )
12537          , SUM(fact.ETC_LABOR_RAW_COST)
12538          , SUM(fact.ETC_EQUIP_RAW_COST)
12539    	 , SUM(fact.CUSTOM1) CUSTOM1
12540    	 , SUM(fact.CUSTOM2) CUSTOM2
12541    	 , SUM(fact.CUSTOM3) CUSTOM3
12542    	 , SUM(fact.CUSTOM4) CUSTOM4
12543    	 , SUM(fact.CUSTOM5) CUSTOM5
12544    	 , SUM(fact.CUSTOM6) CUSTOM6
12545    	 , SUM(fact.CUSTOM7) CUSTOM7
12546    	 , SUM(fact.CUSTOM8) CUSTOM8
12547    	 , SUM(fact.CUSTOM9) CUSTOM9
12548    	 , SUM(fact.CUSTOM10) CUSTOM10
12549    	 , SUM(fact.CUSTOM11) CUSTOM11
12550    	 , SUM(fact.CUSTOM12) CUSTOM12
12551    	 , SUM(fact.CUSTOM13) CUSTOM13
12552    	 , SUM(fact.CUSTOM14) CUSTOM14
12553    	 , SUM(fact.CUSTOM15) CUSTOM15
12554 	 , NULL TIME_DANGLING_FLAG
12555 	 , NULL RATE_DANGLING_FLAG
12556          , g_default_prg_level prg_level
12557          , fact.PLAN_TYPE_CODE   PLAN_TYPE_CODe   /* 4471527 */
12558      FROM  pji_fp_aggr_pjp1_t fact
12559          , pji_time_cal_period_v  non_pa_cal
12560    	 , pji_org_extr_info  orginfo
12561    	 , pji_time_cal_period_v  pa_cal
12562          , pji_fm_extr_plnver3_t  ver
12563    WHERE  fact.CALENDAR_TYPE <> p_calendar_type
12564       AND fact.worker_id = g_worker_id
12565       AND fact.CALENDAR_TYPE IN ('P', 'G')
12566       AND non_pa_cal.cal_period_id = fact.time_id
12567       AND fact.line_type like 'OF%'
12568       AND orginfo.org_id = fact.PROJECT_ORG_ID
12569       AND DECODE(fact.calendar_type, 'P', orginfo.gl_calendar_id, 'G', orginfo.pa_calendar_id) = pa_cal.calendar_id
12570       AND ( non_pa_cal.start_date <= pa_cal.end_date AND non_pa_cal.end_date >= pa_cal.start_date )
12571       AND fact.period_type_id = 32
12572       AND fact.plan_version_id = ver.plan_version_id
12573       AND fact.plan_type_code = ver.plan_type_code   /* 4471527 */
12574       AND ver.wp_flag = 'N'
12575       AND ver.baselined_flag = 'Y'
12576       -- AND (ver.rbs_struct_version_id = fact.rbs_version_id OR fact.rbs_version_id = -1)
12577       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
12578       AND DECODE(p_prorating_format,'S',
12579              DECODE(SIGN(non_pa_cal.start_Date-pa_cal.start_date),-1,0,1),
12580              DECODE(SIGN(non_pa_cal.end_Date - pa_cal.end_date), 1,0,1))=1
12581    GROUP BY
12582            fact.project_id
12583 	 , fact.PROJECT_ORG_ID
12584 	 , fact.PROJECT_ORGANIZATION_ID
12585    	 , fact.PROJECT_ELEMENT_ID
12586    	 , pa_cal.cal_period_id
12587    	 , fact.PERIOD_TYPE_ID
12588    	 , fact.CALENDAR_TYPE
12589          , fact.RBS_AGGR_LEVEL
12590          , fact.WBS_ROLLUP_FLAG
12591          , fact.PRG_ROLLUP_FLAG
12592          , fact.CURR_RECORD_TYPE_ID
12593    	 , fact.CURRENCY_CODE
12594    	 , fact.RBS_ELEMENT_ID
12595    	 , fact.RBS_VERSION_ID
12596    	 , fact.PLAN_VERSION_ID
12597    	 , fact.PLAN_TYPE_ID
12598               , fact.PLAN_TYPE_CODe  ;   /* 4471527 */
12599 
12600 EXCEPTION
12601   WHEN OTHERS THEN
12602     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
12606 
12603                              p_procedure_name => 'PRORATE_TO_PAGL_PGE_PJP1_SE');
12604     RAISE;
12605 END;
12607 
12608 PROCEDURE PRORATE_TO_PAGL_PGE_FPRL_SE (p_calendar_type   IN   VARCHAR2 := NULL) IS
12609 BEGIN
12610 
12611     -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
12612 
12613     INSERT INTO pji_fp_aggr_pjp1_t -- For PA/GL entries.
12614     (
12615        worker_id
12616      , PROJECT_ID
12617      , PROJECT_ORG_ID
12618      , PROJECT_ORGANIZATION_ID
12619      -- , PARTITION_ID
12620      , PROJECT_ELEMENT_ID
12621      , TIME_ID
12622      , PERIOD_TYPE_ID
12623      , CALENDAR_TYPE
12624      , RBS_AGGR_LEVEL
12625      , WBS_ROLLUP_FLAG
12626      , PRG_ROLLUP_FLAG
12627      , CURR_RECORD_TYPE_ID
12628      , CURRENCY_CODE
12629      , RBS_ELEMENT_ID
12630      , RBS_VERSION_ID
12631      , PLAN_VERSION_ID
12632      , PLAN_TYPE_ID
12633      , RAW_COST
12634      , BRDN_COST
12635      , REVENUE
12636      , BILL_RAW_COST
12637      , BILL_BRDN_COST
12638      , BILL_LABOR_RAW_COST
12639      , BILL_LABOR_BRDN_COST
12640      , BILL_LABOR_HRS
12641      , EQUIPMENT_RAW_COST
12642      , EQUIPMENT_BRDN_COST
12643      , CAPITALIZABLE_RAW_COST
12644      , CAPITALIZABLE_BRDN_COST
12645      , LABOR_RAW_COST
12646      , LABOR_BRDN_COST
12647      , LABOR_HRS
12648      , LABOR_REVENUE
12649      , EQUIPMENT_HOURS
12650      , BILLABLE_EQUIPMENT_HOURS
12651      , SUP_INV_COMMITTED_COST
12652      , PO_COMMITTED_COST
12653      , PR_COMMITTED_COST
12654      , OTH_COMMITTED_COST
12655        , ACT_LABOR_HRS
12656 	   , ACT_EQUIP_HRS
12657 	   , ACT_LABOR_BRDN_COST
12658 	   , ACT_EQUIP_BRDN_COST
12659 	   , ACT_BRDN_COST
12660 	   , ACT_RAW_COST
12661 	   , ACT_REVENUE
12662          , ACT_LABOR_RAW_COST
12663          , ACT_EQUIP_RAW_COST
12664 	   , ETC_LABOR_HRS
12665 	   , ETC_EQUIP_HRS
12666 	   , ETC_LABOR_BRDN_COST
12667 	   , ETC_EQUIP_BRDN_COST
12668 	   , ETC_BRDN_COST
12669          , ETC_RAW_COST
12670          , ETC_LABOR_RAW_COST
12671          , ETC_EQUIP_RAW_COST
12672      , CUSTOM1
12673      , CUSTOM2
12674      , CUSTOM3
12675      , CUSTOM4
12676      , CUSTOM5
12677      , CUSTOM6
12678      , CUSTOM7
12679      , CUSTOM8
12680      , CUSTOM9
12681      , CUSTOM10
12682      , CUSTOM11
12683      , CUSTOM12
12684      , CUSTOM13
12685      , CUSTOM14
12686      , CUSTOM15
12687      , LINE_TYPE
12688      , TIME_DANGLING_FLAG
12689      , RATE_DANGLING_FLAG
12690      , PRG_LEVEL
12691      , PLAN_TYPE_CODE    /* 4471527 */
12692    )
12693    SELECT
12694          g_worker_id
12695        , fact.project_id  project_id
12696 	 , fact.PROJECT_ORG_ID project_org_id
12697 	 , fact.PROJECT_ORGANIZATION_ID project_organization_id
12698      -- , fact.PARTITION_ID PARTITION_ID
12699    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
12700    	 , pa_cal.cal_period_id TIME_ID
12701    	 , fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
12702    	 , DECODE(fact.CALENDAR_TYPE, 'P', 'G', 'G', 'P') CALENDAR_TYPE
12703      , fact.RBS_AGGR_LEVEL RBS_AGGR_LEVEL
12704      , fact.WBS_ROLLUP_FLAG WBS_ROLLUP_FLAG
12705      , fact.PRG_ROLLUP_FLAG PRG_ROLLUP_FLAG
12706      , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
12707    	 , fact.CURRENCY_CODE CURRENCY_CODE
12708    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
12709    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
12710    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
12711    	 , fact.PLAN_TYPE_ID PLAN_TYPE_ID
12712    	 , MAX(fact.RAW_COST)	 raw_cost
12713    	 , MAX(fact.BRDN_COST) BRDN_COST
12714    	 , MAX(fact.REVENUE) REVENUE
12715    	 , MAX(fact.BILL_RAW_COST) BILL_RAW_COST
12716    	 , MAX(fact.BILL_BRDN_COST) BILL_BRDN_COST
12717    	 , MAX(fact.BILL_LABOR_RAW_COST) BILL_LABOR_RAW_COST
12718    	 , MAX(fact.BILL_LABOR_BRDN_COST) BILL_LABOR_BRDN_COST
12719    	 , MAX(fact.BILL_LABOR_HRS) BILL_LABOR_HRS
12720    	 , MAX(fact.EQUIPMENT_RAW_COST) EQUIPMENT_RAW_COST
12721    	 , MAX(fact.EQUIPMENT_BRDN_COST) EQUIPMENT_BRDN_COST
12722    	 , MAX(fact.CAPITALIZABLE_RAW_COST) CAPITALIZABLE_RAW_COST
12723    	 , MAX(fact.CAPITALIZABLE_BRDN_COST) CAPITALIZABLE_BRDN_COST
12724    	 , MAX(fact.LABOR_RAW_COST) LABOR_RAW_COST
12725    	 , MAX(fact.LABOR_BRDN_COST) LABOR_BRDN_COST
12726    	 , MAX(fact.LABOR_HRS) LABOR_HRS
12727    	 , MAX(fact.LABOR_REVENUE) LABOR_REVENUE
12728    	 , MAX(fact.EQUIPMENT_HOURS) EQUIPMENT_HOURS
12729    	 , MAX(fact.BILLABLE_EQUIPMENT_HOURS) BILLABLE_EQUIPMENT_HOURS
12730    	 , MAX(fact.SUP_INV_COMMITTED_COST) SUP_INV_COMMITTED_COST
12731    	 , MAX(fact.PO_COMMITTED_COST) PO_COMMITTED_COST
12732    	 , MAX(fact.PR_COMMITTED_COST) PR_COMMITTED_COST
12733    	 , MAX(fact.OTH_COMMITTED_COST) OTH_COMMITTED_COST
12734        , MAX(fact.ACT_LABOR_HRS )
12735 	 , MAX(fact.ACT_EQUIP_HRS )
12736 	 , MAX(fact.ACT_LABOR_BRDN_COST )
12737 	 , MAX(fact.ACT_EQUIP_BRDN_COST )
12738 	 , MAX(fact.ACT_BRDN_COST )
12739 	 , MAX(fact.ACT_RAW_COST )
12740 	 , MAX(fact.ACT_REVENUE )
12741        , MAX(fact.ACT_LABOR_RAW_COST)
12742        , MAX(fact.ACT_EQUIP_RAW_COST)
12743 	 , MAX(fact.ETC_LABOR_HRS )
12744 	 , MAX(fact.ETC_EQUIP_HRS )
12745 	 , MAX(fact.ETC_LABOR_BRDN_COST )
12746 	 , MAX(fact.ETC_EQUIP_BRDN_COST )
12747 	 , MAX(fact.ETC_BRDN_COST )
12748        , MAX(fact.ETC_RAW_COST )
12749        , MAX(fact.ETC_LABOR_RAW_COST)
12750        , MAX(fact.ETC_EQUIP_RAW_COST)
12751    	 , MAX(fact.CUSTOM1) CUSTOM1
12752    	 , MAX(fact.CUSTOM2) CUSTOM2
12753    	 , MAX(fact.CUSTOM3) CUSTOM3
12754    	 , MAX(fact.CUSTOM4) CUSTOM4
12755    	 , MAX(fact.CUSTOM5) CUSTOM5
12756    	 , MAX(fact.CUSTOM6) CUSTOM6
12757    	 , MAX(fact.CUSTOM7) CUSTOM7
12758    	 , MAX(fact.CUSTOM8) CUSTOM8
12759    	 , MAX(fact.CUSTOM9) CUSTOM9
12763    	 , MAX(fact.CUSTOM13) CUSTOM13
12760    	 , MAX(fact.CUSTOM10) CUSTOM10
12761    	 , MAX(fact.CUSTOM11) CUSTOM11
12762    	 , MAX(fact.CUSTOM12) CUSTOM12
12764    	 , MAX(fact.CUSTOM14) CUSTOM14
12765    	 , MAX(fact.CUSTOM15) CUSTOM15
12766    	 -- , DECODE ('E', 'E', MAX(pa_cal.start_date), 'S', MIN(pa_cal.start_date)) start_date
12767    	 -- , DECODE ('E', 'E', MAX(pa_cal.end_date), 'S', MIN(pa_cal.end_date))	 end_date
12768        , 'CF'   line_type
12769 	 , NULL  TIME_DANGLING_FLAG
12770 	 , NULL RATE_DANGLING_FLAG
12771        , g_default_prg_level prg_level
12772        , fact.plan_type_code  plan_type_code    /* 4471527 */
12773    FROM   pji_fp_xbs_accum_f  fact
12774        , PJI_FM_EXTR_PLNVER3_T ver
12775         , pji_time_cal_period  non_pa_cal
12776    	 , pji_org_extr_info  orginfo
12777    	 , pji_time_cal_period  pa_cal
12778    WHERE  fact.CALENDAR_TYPE <> p_calendar_type
12779       AND fact.CALENDAR_TYPE IN ('P', 'G')
12780       AND non_pa_cal.cal_period_id = fact.time_id
12781       AND ver.project_id = fact.project_id
12782       AND ver.plan_version_id = fact.plan_version_id
12783       ANd ver.plan_type_code = fact.plan_type_code    /*  4471527 */
12784       AND orginfo.org_id = fact.PROJECT_ORG_ID
12785       AND DECODE(fact.calendar_type, 'P', orginfo.gl_calendar_id, 'G', orginfo.pa_calendar_id) = pa_cal.calendar_id
12786       AND pa_cal.start_date >= non_pa_cal.start_date
12787       AND ( non_pa_cal.end_date <= pa_cal.end_date AND non_pa_cal.end_date >= pa_cal.start_date )
12788       AND fact.period_type_id = 32
12789       AND ver.wp_flag = 'N'
12790       AND ver.baselined_flag = 'Y'
12791       -- AND (ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
12792       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
12793    GROUP BY
12794        fact.project_id
12795 	 , fact.PROJECT_ORG_ID
12796 	 , fact.PROJECT_ORGANIZATION_ID
12797      -- , fact.PARTITION_ID
12798    	 , fact.PROJECT_ELEMENT_ID
12799    	 , pa_cal.cal_period_id
12800    	 , fact.PERIOD_TYPE_ID
12801    	 , fact.CALENDAR_TYPE
12802      , fact.RBS_AGGR_LEVEL
12803      , fact.WBS_ROLLUP_FLAG
12804      , fact.PRG_ROLLUP_FLAG
12805      , fact.CURR_RECORD_TYPE_ID
12806    	 , fact.CURRENCY_CODE
12807    	 , fact.RBS_ELEMENT_ID
12808    	 , fact.RBS_VERSION_ID
12809    	 , fact.PLAN_VERSION_ID
12810    	 , fact.PLAN_TYPE_ID
12811               , fact.PLAN_TYPE_CODE ;   /* 4471527 */
12812 
12813 
12814 EXCEPTION
12815   WHEN OTHERS THEN
12816     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
12817                              p_procedure_name => 'PRORATE_TO_PAGL_PGE_FPRL_SE');
12818     RAISE;
12819 END;
12820 
12821 
12822 PROCEDURE PRORATE_TO_PAGL_N_PJP1_SE (p_calendar_type    IN   VARCHAR2 := NULL,
12823                                      p_prorating_format IN   VARCHAR2) IS
12824 BEGIN
12825 
12826     IF (p_calendar_type NOT IN ('P', 'G')) THEN
12827       RETURN;
12828     END IF;
12829 
12830     -- g_worker_id  := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
12831  /* Commented for bug 4005006
12832     INSERT INTO pji_fp_aggr_pjp1_t -- For non time phased entries.
12833     (
12834        worker_id
12835      , PROJECT_ID
12836      , PROJECT_ORG_ID
12837      , PROJECT_ORGANIZATION_ID
12838      -- , PARTITION_ID
12839      , PROJECT_ELEMENT_ID
12840      , TIME_ID
12841      , PERIOD_TYPE_ID
12842      , CALENDAR_TYPE
12843      , RBS_AGGR_LEVEL
12844      , WBS_ROLLUP_FLAG
12845      , PRG_ROLLUP_FLAG
12846      , CURR_RECORD_TYPE_ID
12847      , CURRENCY_CODE
12848      , RBS_ELEMENT_ID
12849      , RBS_VERSION_ID
12850      , PLAN_VERSION_ID
12851      , PLAN_TYPE_ID
12852      , RAW_COST
12853      , BRDN_COST
12854      , REVENUE
12855      , BILL_RAW_COST
12856      , BILL_BRDN_COST
12857      , BILL_LABOR_RAW_COST
12858      , BILL_LABOR_BRDN_COST
12859      , BILL_LABOR_HRS
12860      , EQUIPMENT_RAW_COST
12861      , EQUIPMENT_BRDN_COST
12862      , CAPITALIZABLE_RAW_COST
12863      , CAPITALIZABLE_BRDN_COST
12864      , LABOR_RAW_COST
12865      , LABOR_BRDN_COST
12866      , LABOR_HRS
12867      , LABOR_REVENUE
12868      , EQUIPMENT_HOURS
12869      , BILLABLE_EQUIPMENT_HOURS
12870      , SUP_INV_COMMITTED_COST
12871      , PO_COMMITTED_COST
12872      , PR_COMMITTED_COST
12873      , OTH_COMMITTED_COST
12874        , ACT_LABOR_HRS
12875 	   , ACT_EQUIP_HRS
12876 	   , ACT_LABOR_BRDN_COST
12877 	   , ACT_EQUIP_BRDN_COST
12878 	   , ACT_BRDN_COST
12879 	   , ACT_RAW_COST
12880 	   , ACT_REVENUE
12881          , ACT_LABOR_RAW_COST
12882          , ACT_EQUIP_RAW_COST
12883 	   , ETC_LABOR_HRS
12884 	   , ETC_EQUIP_HRS
12885 	   , ETC_LABOR_BRDN_COST
12886 	   , ETC_EQUIP_BRDN_COST
12887 	   , ETC_BRDN_COST
12888          , ETC_RAW_COST
12889          , ETC_LABOR_RAW_COST
12890          , ETC_EQUIP_RAW_COST
12891      , CUSTOM1
12892      , CUSTOM2
12893      , CUSTOM3
12894      , CUSTOM4
12895      , CUSTOM5
12896      , CUSTOM6
12897      , CUSTOM7
12898      , CUSTOM8
12899      , CUSTOM9
12900      , CUSTOM10
12901      , CUSTOM11
12902      , CUSTOM12
12903      , CUSTOM13
12904      , CUSTOM14
12905      , CUSTOM15
12906      , LINE_TYPE
12907      , TIME_DANGLING_FLAG
12908      , RATE_DANGLING_FLAG
12909      , PRG_LEVEL
12910    )
12911    SELECT
12912          g_worker_id
12913        , fact.project_id  project_id
12914 	 , fact.PROJECT_ORG_ID project_org_id
12915 	 , fact.PROJECT_ORGANIZATION_ID project_organization_id
12916      -- , fact.PARTITION_ID PARTITION_ID
12917    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
12918    	 , pa_cal.cal_period_id TIME_ID
12922       , fact.RBS_AGGR_LEVEL RBS_AGGR_LEVEL
12919    	 , 32 -- fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
12920    --    , fact.CALENDAR_TYPE CALENDAR_TYPE
12921          ,DECODE(pa_cal.calendar_id,orginfo.pa_calendar_id,'P',orginfo.gl_calendar_id,'G')
12923      , fact.WBS_ROLLUP_FLAG WBS_ROLLUP_FLAG
12924      , fact.PRG_ROLLUP_FLAG PRG_ROLLUP_FLAG
12925      , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
12926    	 , fact.CURRENCY_CODE CURRENCY_CODE
12927    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
12928    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
12929    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
12930    	 , fact.PLAN_TYPE_ID PLAN_TYPE_ID
12931    	 , MAX(fact.RAW_COST)	 raw_cost
12932    	 , MAX(fact.BRDN_COST) BRDN_COST
12933    	 , MAX(fact.REVENUE) REVENUE
12934    	 , MAX(fact.BILL_RAW_COST) BILL_RAW_COST
12935    	 , MAX(fact.BILL_BRDN_COST) BILL_BRDN_COST
12936    	 , MAX(fact.BILL_LABOR_RAW_COST) BILL_LABOR_RAW_COST
12937    	 , MAX(fact.BILL_LABOR_BRDN_COST) BILL_LABOR_BRDN_COST
12938    	 , MAX(fact.BILL_LABOR_HRS) BILL_LABOR_HRS
12939    	 , MAX(fact.EQUIPMENT_RAW_COST) EQUIPMENT_RAW_COST
12940    	 , MAX(fact.EQUIPMENT_BRDN_COST) EQUIPMENT_BRDN_COST
12941    	 , MAX(fact.CAPITALIZABLE_RAW_COST) CAPITALIZABLE_RAW_COST
12942    	 , MAX(fact.CAPITALIZABLE_BRDN_COST) CAPITALIZABLE_BRDN_COST
12943    	 , MAX(fact.LABOR_RAW_COST) LABOR_RAW_COST
12944    	 , MAX(fact.LABOR_BRDN_COST) LABOR_BRDN_COST
12945    	 , MAX(fact.LABOR_HRS) LABOR_HRS
12946    	 , MAX(fact.LABOR_REVENUE) LABOR_REVENUE
12947    	 , MAX(fact.EQUIPMENT_HOURS) EQUIPMENT_HOURS
12948    	 , MAX(fact.BILLABLE_EQUIPMENT_HOURS) BILLABLE_EQUIPMENT_HOURS
12949    	 , MAX(fact.SUP_INV_COMMITTED_COST) SUP_INV_COMMITTED_COST
12950    	 , MAX(fact.PO_COMMITTED_COST) PO_COMMITTED_COST
12951    	 , MAX(fact.PR_COMMITTED_COST) PR_COMMITTED_COST
12952    	 , MAX(fact.OTH_COMMITTED_COST) OTH_COMMITTED_COST
12953        , MAX(fact.ACT_LABOR_HRS )
12954 	 , MAX(fact.ACT_EQUIP_HRS )
12955 	 , MAX(fact.ACT_LABOR_BRDN_COST )
12956 	 , MAX(fact.ACT_EQUIP_BRDN_COST )
12957 	 , MAX(fact.ACT_BRDN_COST )
12958 	 , MAX(fact.ACT_RAW_COST )
12959 	 , MAX(fact.ACT_REVENUE )
12960        , MAX(fact.ACT_LABOR_RAW_COST)
12961        , MAX(fact.ACT_EQUIP_RAW_COST)
12962 	 , MAX(fact.ETC_LABOR_HRS )
12963 	 , MAX(fact.ETC_EQUIP_HRS )
12964 	 , MAX(fact.ETC_LABOR_BRDN_COST )
12965 	 , MAX(fact.ETC_EQUIP_BRDN_COST )
12966 	 , MAX(fact.ETC_BRDN_COST )
12967        , MAX(fact.ETC_RAW_COST )
12968        , MAX(fact.ETC_LABOR_RAW_COST)
12969        , MAX(fact.ETC_EQUIP_RAW_COST)
12970    	 , MAX(fact.CUSTOM1) CUSTOM1
12971    	 , MAX(fact.CUSTOM2) CUSTOM2
12972    	 , MAX(fact.CUSTOM3) CUSTOM3
12973    	 , MAX(fact.CUSTOM4) CUSTOM4
12974    	 , MAX(fact.CUSTOM5) CUSTOM5
12975    	 , MAX(fact.CUSTOM6) CUSTOM6
12976    	 , MAX(fact.CUSTOM7) CUSTOM7
12977    	 , MAX(fact.CUSTOM8) CUSTOM8
12978    	 , MAX(fact.CUSTOM9) CUSTOM9
12979    	 , MAX(fact.CUSTOM10) CUSTOM10
12980    	 , MAX(fact.CUSTOM11) CUSTOM11
12981    	 , MAX(fact.CUSTOM12) CUSTOM12
12982    	 , MAX(fact.CUSTOM13) CUSTOM13
12983    	 , MAX(fact.CUSTOM14) CUSTOM14
12984    	 , MAX(fact.CUSTOM15) CUSTOM15
12985    	 -- , DECODE ('E', 'E', MAX(pa_cal.start_date), 'S', MIN(pa_cal.start_date)) start_date
12986    	 -- , DECODE ('E', 'E', MAX(pa_cal.end_date), 'S', MIN(pa_cal.end_date))	 end_date
12987      , 'CN'   line_type
12988 	 , NULL  TIME_DANGLING_FLAG
12989 	 , NULL  RATE_DANGLING_FLAG
12990        , g_default_prg_level prg_level
12991    FROM   pji_fp_aggr_pjp1_t fact
12992    	 , pji_org_extr_info  orginfo
12993    	 , pji_time_cal_period  pa_cal
12994        , pji_fm_extr_plnver3_t  ver
12995    WHERE  1=1
12996       AND fact.CALENDAR_TYPE = 'A'
12997       AND orginfo.org_id = fact.PROJECT_ORG_ID
12998       AND DECODE(p_calendar_type
12999                , 'P', orginfo.pa_calendar_id
13000                , 'G', orginfo.gl_calendar_id) = pa_cal.calendar_id
13001       AND fact.start_date IS NOT NULL
13002       AND fact.end_date IS NOT NULL
13003       AND (
13004 	       (     pa_cal.start_date >= fact.start_date
13005                AND pa_cal.end_date <= fact.end_date ) -- fsps,pefe
13006 	    OR (     pa_cal.start_date <= fact.start_date
13007                AND pa_cal.end_date >= fact.end_date ) -- psfs,fepe
13008 	    OR (     pa_cal.start_date <= fact.start_date
13009                AND pa_cal.end_date <= fact.end_date
13010                AND pa_cal.end_date >= fact.start_date ) -- psfspefe
13011 	    OR (     pa_cal.start_date >= fact.start_date
13012                AND pa_cal.end_date >= fact.end_date
13013                AND pa_cal.start_date <= fact.end_date )  -- fspsfepe
13014           )
13015       AND fact.period_type_id = 2048
13016       AND fact.plan_version_id = ver.plan_version_id
13017       AND ver.wp_flag = 'N'
13018       AND ver.baselined_flag = 'Y'
13019       AND ver.time_phased_type_code = 'N'
13020       AND fact.line_type = 'NTP'
13021       AND fact.worker_id = g_worker_id
13022 	-- AND (ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
13023       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
13024    GROUP BY
13025        fact.project_id
13026 	 , fact.PROJECT_ORG_ID
13027 	 , fact.PROJECT_ORGANIZATION_ID
13028      -- , fact.PARTITION_ID
13029    	 , fact.PROJECT_ELEMENT_ID
13030    	 , pa_cal.cal_period_id
13031    	 , fact.PERIOD_TYPE_ID
13032    	 , fact.CALENDAR_TYPE
13033      , fact.RBS_AGGR_LEVEL
13034      , fact.WBS_ROLLUP_FLAG
13035      , fact.PRG_ROLLUP_FLAG
13036      , fact.CURR_RECORD_TYPE_ID
13037    	 , fact.CURRENCY_CODE
13038    	 , fact.RBS_ELEMENT_ID
13039    	 , fact.RBS_VERSION_ID
13040    	 , fact.PLAN_VERSION_ID
13041    	 , fact.PLAN_TYPE_ID
13042 	 , fact.TIME_DANGLING_FLAG
13043 	 , fact.RATE_DANGLING_FLAG
13044          ,pa_cal.CALENDAR_ID,
13045 	 orginfo.pa_calendar_id,
13046 	 orginfo.gl_calendar_id;
13047  End of bug 4005006*/
13048 
13052      , PROJECT_ID
13049     INSERT INTO pji_fp_aggr_pjp1_t -- For non time phased entries.
13050     (
13051        worker_id
13053      , PROJECT_ORG_ID
13054      , PROJECT_ORGANIZATION_ID
13055      , PROJECT_ELEMENT_ID
13056      , TIME_ID
13057      , PERIOD_TYPE_ID
13058      , CALENDAR_TYPE
13059      , RBS_AGGR_LEVEL
13060      , WBS_ROLLUP_FLAG
13061      , PRG_ROLLUP_FLAG
13062      , CURR_RECORD_TYPE_ID
13063      , CURRENCY_CODE
13064      , RBS_ELEMENT_ID
13065      , RBS_VERSION_ID
13066      , PLAN_VERSION_ID
13067      , PLAN_TYPE_ID
13068      , RAW_COST
13069      , BRDN_COST
13070      , REVENUE
13071      , BILL_RAW_COST
13072      , BILL_BRDN_COST
13073      , BILL_LABOR_RAW_COST
13074      , BILL_LABOR_BRDN_COST
13075      , BILL_LABOR_HRS
13076      , EQUIPMENT_RAW_COST
13077      , EQUIPMENT_BRDN_COST
13078      , CAPITALIZABLE_RAW_COST
13079      , CAPITALIZABLE_BRDN_COST
13080      , LABOR_RAW_COST
13081      , LABOR_BRDN_COST
13082      , LABOR_HRS
13083      , LABOR_REVENUE
13084      , EQUIPMENT_HOURS
13085      , BILLABLE_EQUIPMENT_HOURS
13086      , SUP_INV_COMMITTED_COST
13087      , PO_COMMITTED_COST
13088      , PR_COMMITTED_COST
13089      , OTH_COMMITTED_COST
13090      , ACT_LABOR_HRS
13091      , ACT_EQUIP_HRS
13092      , ACT_LABOR_BRDN_COST
13093      , ACT_EQUIP_BRDN_COST
13094      , ACT_BRDN_COST
13095      , ACT_RAW_COST
13096      , ACT_REVENUE
13097      , ACT_LABOR_RAW_COST
13098      , ACT_EQUIP_RAW_COST
13099      , ETC_LABOR_HRS
13100      , ETC_EQUIP_HRS
13101      , ETC_LABOR_BRDN_COST
13102      , ETC_EQUIP_BRDN_COST
13103      , ETC_BRDN_COST
13104      , ETC_RAW_COST
13105      , ETC_LABOR_RAW_COST
13106      , ETC_EQUIP_RAW_COST
13107      , CUSTOM1
13108      , CUSTOM2
13109      , CUSTOM3
13110      , CUSTOM4
13111      , CUSTOM5
13112      , CUSTOM6
13113      , CUSTOM7
13114      , CUSTOM8
13115      , CUSTOM9
13116      , CUSTOM10
13117      , CUSTOM11
13118      , CUSTOM12
13119      , CUSTOM13
13120      , CUSTOM14
13121      , CUSTOM15
13122      , TIME_DANGLING_FLAG
13123      , RATE_DANGLING_FLAG
13124      , PRG_LEVEL
13125      , PLAN_TYPE_CODE   /* 4471527 */
13126    )
13127    SELECT
13128            g_worker_id
13129          , fact.project_id  project_id
13130 	 , fact.PROJECT_ORG_ID project_org_id
13131 	 , fact.PROJECT_ORGANIZATION_ID project_organization_id
13132    	 , fact.PROJECT_ELEMENT_ID PROJECT_ELEMENT_ID
13133    	 , pa_cal.cal_period_id TIME_ID
13134    	 , 32 -- fact.PERIOD_TYPE_ID PERIOD_TYPE_ID
13135          , DECODE(pa_cal.calendar_id,orginfo.pa_calendar_id,'P',orginfo.gl_calendar_id,'G') CALENDAR_TYPE
13136          , fact.RBS_AGGR_LEVEL RBS_AGGR_LEVEL
13137          , fact.WBS_ROLLUP_FLAG WBS_ROLLUP_FLAG
13138          , fact.PRG_ROLLUP_FLAG PRG_ROLLUP_FLAG
13139          , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
13140    	 , fact.CURRENCY_CODE CURRENCY_CODE
13141    	 , fact.RBS_ELEMENT_ID RBS_ELEMENT_ID
13142    	 , fact.RBS_VERSION_ID RBS_VERSION_ID
13143    	 , fact.PLAN_VERSION_ID PLAN_VERSION_ID
13144    	 , fact.PLAN_TYPE_ID PLAN_TYPE_ID
13145    	 , SUM(fact.RAW_COST)	 raw_cost
13146    	 , SUM(fact.BRDN_COST) BRDN_COST
13147    	 , SUM(fact.REVENUE) REVENUE
13148    	 , SUM(fact.BILL_RAW_COST) BILL_RAW_COST
13149    	 , SUM(fact.BILL_BRDN_COST) BILL_BRDN_COST
13150    	 , SUM(fact.BILL_LABOR_RAW_COST) BILL_LABOR_RAW_COST
13151    	 , SUM(fact.BILL_LABOR_BRDN_COST) BILL_LABOR_BRDN_COST
13152    	 , SUM(fact.BILL_LABOR_HRS) BILL_LABOR_HRS
13153    	 , SUM(fact.EQUIPMENT_RAW_COST) EQUIPMENT_RAW_COST
13154    	 , SUM(fact.EQUIPMENT_BRDN_COST) EQUIPMENT_BRDN_COST
13155    	 , SUM(fact.CAPITALIZABLE_RAW_COST) CAPITALIZABLE_RAW_COST
13156    	 , SUM(fact.CAPITALIZABLE_BRDN_COST) CAPITALIZABLE_BRDN_COST
13157    	 , SUM(fact.LABOR_RAW_COST) LABOR_RAW_COST
13158    	 , SUM(fact.LABOR_BRDN_COST) LABOR_BRDN_COST
13159    	 , SUM(fact.LABOR_HRS) LABOR_HRS
13160    	 , SUM(fact.LABOR_REVENUE) LABOR_REVENUE
13161    	 , SUM(fact.EQUIPMENT_HOURS) EQUIPMENT_HOURS
13162    	 , SUM(fact.BILLABLE_EQUIPMENT_HOURS) BILLABLE_EQUIPMENT_HOURS
13163    	 , SUM(fact.SUP_INV_COMMITTED_COST) SUP_INV_COMMITTED_COST
13164    	 , SUM(fact.PO_COMMITTED_COST) PO_COMMITTED_COST
13165    	 , SUM(fact.PR_COMMITTED_COST) PR_COMMITTED_COST
13166    	 , SUM(fact.OTH_COMMITTED_COST) OTH_COMMITTED_COST
13167          , SUM(fact.ACT_LABOR_HRS )
13168 	 , SUM(fact.ACT_EQUIP_HRS )
13169 	 , SUM(fact.ACT_LABOR_BRDN_COST )
13170 	 , SUM(fact.ACT_EQUIP_BRDN_COST )
13171 	 , SUM(fact.ACT_BRDN_COST )
13172 	 , SUM(fact.ACT_RAW_COST )
13173 	 , SUM(fact.ACT_REVENUE )
13174          , SUM(fact.ACT_LABOR_RAW_COST)
13175          , SUM(fact.ACT_EQUIP_RAW_COST)
13176 	 , SUM(fact.ETC_LABOR_HRS )
13177 	 , SUM(fact.ETC_EQUIP_HRS )
13178 	 , SUM(fact.ETC_LABOR_BRDN_COST )
13179 	 , SUM(fact.ETC_EQUIP_BRDN_COST )
13180 	 , SUM(fact.ETC_BRDN_COST )
13181          , SUM(fact.ETC_RAW_COST )
13182          , SUM(fact.ETC_LABOR_RAW_COST)
13183          , SUM(fact.ETC_EQUIP_RAW_COST)
13184    	 , SUM(fact.CUSTOM1) CUSTOM1
13185    	 , SUM(fact.CUSTOM2) CUSTOM2
13186    	 , SUM(fact.CUSTOM3) CUSTOM3
13187    	 , SUM(fact.CUSTOM4) CUSTOM4
13188    	 , SUM(fact.CUSTOM5) CUSTOM5
13189    	 , SUM(fact.CUSTOM6) CUSTOM6
13190    	 , SUM(fact.CUSTOM7) CUSTOM7
13191    	 , SUM(fact.CUSTOM8) CUSTOM8
13192    	 , SUM(fact.CUSTOM9) CUSTOM9
13193    	 , SUM(fact.CUSTOM10) CUSTOM10
13194    	 , SUM(fact.CUSTOM11) CUSTOM11
13195    	 , SUM(fact.CUSTOM12) CUSTOM12
13196    	 , SUM(fact.CUSTOM13) CUSTOM13
13197    	 , SUM(fact.CUSTOM14) CUSTOM14
13198    	 , SUM(fact.CUSTOM15) CUSTOM15
13199 	 , NULL  TIME_DANGLING_FLAG
13200 	 , NULL  RATE_DANGLING_FLAG
13201          , g_default_prg_level prg_level
13205    	 , pji_time_cal_period_v  pa_cal
13202          , fact.PLAN_TYPE_CODE   PLAN_TYPE_CODE   /* 4471527 */
13203       FROM pji_fp_aggr_pjp1_t fact
13204    	 , pji_org_extr_info  orginfo
13206          , pji_fm_extr_plnver3_t  ver
13207    WHERE  1=1
13208       AND fact.CALENDAR_TYPE = 'A'
13209       AND orginfo.org_id = fact.PROJECT_ORG_ID
13210       AND DECODE(p_calendar_type
13211                , 'P', orginfo.pa_calendar_id
13212                , 'G', orginfo.gl_calendar_id) = pa_cal.calendar_id
13213       AND fact.start_date IS NOT NULL
13214       AND fact.end_date IS NOT NULL
13215       AND fact.period_type_id = 2048
13216       AND fact.plan_version_id = ver.plan_version_id
13217       AND fact.plan_type_code  = ver.plan_type_code   /* 4471527 */
13218       AND ver.wp_flag = 'N'
13219       AND ver.baselined_flag = 'Y'
13220       AND ver.time_phased_type_code = 'N'
13221       AND fact.line_type = 'NTP'
13222       AND fact.worker_id = g_worker_id
13223       -- AND (ver.rbs_struct_version_id = fact.rbs_version_id  OR fact.rbs_version_id = -1)
13224       AND NVL(ver.rbs_struct_version_id, -1) = fact.rbs_version_id
13225       AND ( fact.start_date <= pa_cal.end_date AND fact.end_date >= pa_cal.start_date )
13226       AND DECODE(p_prorating_format,'S',
13227              DECODE(SIGN(fact.start_Date-pa_cal.start_date),-1,0,1),
13228              DECODE(SIGN(fact.end_Date - pa_cal.end_date), 1,0,1))=1
13229    GROUP BY
13230            fact.project_id
13231 	 , fact.PROJECT_ORG_ID
13232 	 , fact.PROJECT_ORGANIZATION_ID
13233    	 , fact.PROJECT_ELEMENT_ID
13234    	 , pa_cal.cal_period_id
13235    	 , fact.PERIOD_TYPE_ID
13236    	 , fact.CALENDAR_TYPE
13237          , fact.RBS_AGGR_LEVEL
13238          , fact.WBS_ROLLUP_FLAG
13239          , fact.PRG_ROLLUP_FLAG
13240          , fact.CURR_RECORD_TYPE_ID
13241    	 , fact.CURRENCY_CODE
13242    	 , fact.RBS_ELEMENT_ID
13243    	 , fact.RBS_VERSION_ID
13244    	 , fact.PLAN_VERSION_ID
13245    	 , fact.PLAN_TYPE_ID
13246               , fact.PLAN_TYPE_CODe    /* 4471527 */
13247 	 , fact.TIME_DANGLING_FLAG
13248 	 , fact.RATE_DANGLING_FLAG
13249 	 ,  DECODE(pa_cal.calendar_id,orginfo.pa_calendar_id,'P',orginfo.gl_calendar_id,'G');
13250 
13251 EXCEPTION
13252   WHEN OTHERS THEN
13253     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
13254                              p_procedure_name => 'PRORATE_TO_PAGL_N_PJP1_SE');
13255     RAISE;
13256 END;
13257 
13258 
13259 ----------
13260 -- Print time API to measure time taken by each api. Also useful for debugging.
13261 ----------
13262 PROCEDURE PRINT_TIME(p_tag IN VARCHAR2) IS
13263 BEGIN
13264   PJI_PJP_FP_CURR_WRAP.print_time(p_tag);
13265 EXCEPTION
13266   WHEN OTHERS THEN
13267     FND_MSG_PUB.add_exc_msg( p_pkg_name       => g_package_name ,
13268                              p_procedure_name => 'PRINT_TIME');
13269     RAISE;
13270 END;
13271 
13272 
13273 END PJI_FM_PLAN_CAL_RLPS_T;