DBA Data[Home] [Help]

APPS.PA_FP_CALC_PLAN_PKG SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 62

    /* Billabliity and MRC Enhancements: Note declaring table of records cannot be used in Bulk updates / bulk inserts
     * so 9.2.5.0 version donot support the builk-in-bind of table of records with indexes
     * so commenting it out for time being
    TYPE mrc_fpRec IS RECORD  (
        budget_line_id      pa_fp_rollup_tmp.budget_line_id%type
        ,resource_assignment_id pa_fp_rollup_tmp.resource_assignment_id%type
        ,txn_currency_code      pa_fp_rollup_tmp.txn_currency_code%type
        ,start_date     pa_fp_rollup_tmp.start_date%type
            ,end_date       pa_fp_rollup_tmp.start_date%type
            ,period_name        pa_fp_rollup_tmp.period_name%type
            ,quantity       Number
            ,txn_raw_cost       Number
            ,txn_burdened_cost  Number
            ,txn_revenue        Number
            ,project_currency_code  pa_fp_rollup_tmp.txn_currency_code%type
            ,project_raw_cost   Number
            ,project_burden_cost    Number
            ,project_revenue        Number
            ,projfunc_currency_code pa_fp_rollup_tmp.txn_currency_code%type
            ,projfunc_raw_cost      Number
            ,projfunc_burden_cost   Number
            ,projfunc_revenue       Number
        ,delete_flag            pa_fp_rollup_tmp.delete_flag%type
        ,Billable_flag          pa_fp_rollup_tmp.delete_flag%type
        ,project_cost_rate_type        pa_fp_rollup_tmp.project_cost_rate_type%type
            ,project_cost_exchange_rate    pa_fp_rollup_tmp.project_cost_exchange_rate%type
        ,project_cost_rate_date_type   pa_fp_rollup_tmp.project_cost_rate_date_type%type
            ,project_cost_rate_date     pa_fp_rollup_tmp.project_cost_rate_date%type
            ,project_rev_rate_type      pa_fp_rollup_tmp.project_rev_rate_type%type
            ,project_rev_exchange_rate  pa_fp_rollup_tmp.project_rev_exchange_rate%type
            ,project_rev_rate_date_type pa_fp_rollup_tmp.project_rev_rate_date_type%type
            ,project_rev_rate_date      pa_fp_rollup_tmp.project_rev_rate_date%type
            ,projfunc_cost_rate_type    pa_fp_rollup_tmp.projfunc_cost_rate_type%type
            ,projfunc_cost_exchange_rate    pa_fp_rollup_tmp.projfunc_cost_exchange_rate%type
            ,projfunc_cost_rate_date_type   pa_fp_rollup_tmp.projfunc_cost_rate_date_type%type
            ,projfunc_cost_rate_date    pa_fp_rollup_tmp.projfunc_cost_rate_date%type
            ,projfunc_rev_rate_type     pa_fp_rollup_tmp.projfunc_rev_rate_type%type
            ,projfunc_rev_exchange_rate pa_fp_rollup_tmp.projfunc_rev_exchange_rate%type
            ,projfunc_rev_rate_date_type    pa_fp_rollup_tmp.projfunc_rev_rate_date_type%type
            ,projfunc_rev_rate_date     pa_fp_rollup_tmp.projfunc_rev_rate_date%type
        );
Line: 125

        g_mrc_delete_flag_tab               pa_plsql_datatypes.Char1TabTyp;
Line: 245

        SELECT nvl(pfo.use_planning_rates_flag,'N') use_planning_rates_flag
          ,decode(nvl(bv.wp_version_flag,'N'),'Y',NVL(pfo.track_workplan_costs_flag,'N'),'Y') track_workplan_costs_flag
          ,bv.version_type
          ,bv.resource_list_id
          ,bv.approved_rev_plan_type_flag
          ,nvl(pfo.plan_in_multi_curr_flag,'N') plan_in_multi_curr_flag
          ,bv.etc_start_date
          ,nvl(bv.wp_version_flag,'N') wp_version_flag
          ,decode(bv.version_type,
                  'COST',NVL(pfo.cost_time_phased_code,'N'),
                  'REVENUE',NVL(pfo.revenue_time_phased_code,'N'),
                  NVL(pfo.all_time_phased_code,'N')) time_phased_code
          ,bv.project_structure_version_id
          ,bv.project_id
          ,pp.project_currency_code
          ,pp.projfunc_currency_code
          ,pp.segment1  project_Name
          ,bv.ci_id     CiId
          /*Bugfix:4272944 */
          ,NVL(pp.baseline_funding_flag,'N') baseline_funding_flag
      ,decode(fpt.plan_class_code,'BUDGET'
            ,decode(bv.wp_version_flag,'Y','WORKPLAN',fpt.plan_class_code),fpt.plan_class_code) Plan_Class_Type
        FROM pa_proj_fp_options pfo
            ,pa_budget_versions bv
            ,pa_projects_all pp
        ,pa_fin_plan_types_b fpt
        WHERE pfo.fin_plan_version_id = bv.budget_version_id
        AND  bv.project_id = pp.project_id
    AND  fpt.fin_plan_type_id = pfo.fin_plan_type_id
        AND bv.budget_version_id = p_budget_version_id;
Line: 288

    SELECT /*+ INDEX(blavgrt PA_BUDGET_LINES_U1) */
        AVG(DECODE((nvl(blavgrt.quantity,0) - nvl(blavgrt.init_quantity,0)),0,NULL
			,blavgrt.txn_cost_rate_override)) avg_txn_cost_rate_override
               ,AVG(DECODE((nvl(blavgrt.quantity,0) - nvl(blavgrt.init_quantity,0)),0,NULL
			,blavgrt.burden_cost_rate_override))   avg_burden_cost_rate_override
               ,AVG(DECODE((nvl(blavgrt.quantity,0) - nvl(blavgrt.init_quantity,0)),0,NULL
			,blavgrt.txn_bill_rate_override)) avg_txn_bill_rate_override
           /* Bug fix: 5172318 Not required as part of IPM changes
           ,SUM(nvl(blavgrt.quantity,0) - nvl(blavgrt.init_quantity,0)) sum_etc_Qty
           ,SUM(nvl(blavgrt.init_quantity,0)) sum_Actual_Qty
           ,SUM(nvl(blavgrt.quantity,0)) sum_Plan_Qty
	   */
           /*bug fix:4693839 */
           ,AVG(NVL(blavgrt.txn_cost_rate_override,blavgrt.txn_standard_cost_rate)) avg_zero_null_cost_rate
           ,AVG(NVL(blavgrt.burden_cost_rate_override,blavgrt.burden_cost_rate))    avg_zero_null_burden_rate
           ,AVG(NVL(blavgrt.txn_bill_rate_override,blavgrt.txn_standard_bill_rate)) avg_zero_null_bill_rate
             FROM pa_budget_lines blavgrt
             WHERE blavgrt.resource_assignment_id = p_resource_asg_id
             AND blavgrt.txn_currency_code      = p_txn_curr_code
             AND ( (p_line_start_date is NULL AND p_line_end_date is NULL )
                OR
                 (p_line_start_date is NOT NULL AND p_line_end_date is NOT NULL
                  AND blavgrt.start_date BETWEEN p_line_start_date AND p_line_end_date)
                 );
Line: 321

        SELECT /*+ INDEX(BL PA_BUDGET_LINES_U1) */
          decode(sum(bl.quantity),0,NULL,sum(bl.quantity)) quantity
             ,decode( sum(bl.txn_raw_cost),0,NULL,sum(bl.txn_raw_cost)) txn_raw_cost
             ,decode(sum(bl.txn_burdened_cost),0,NULL,sum(bl.txn_burdened_cost)) txn_burdened_cost
             ,decode(sum(bl.txn_revenue),0,NULL,sum(bl.txn_revenue)) txn_revenue
             -- Actuals for ETC calculation
            ,decode(sum(bl.init_quantity),0,NULL,sum(bl.init_quantity)) init_quantity
            ,decode(sum(bl.txn_init_raw_cost),0,NULL,sum(bl.txn_init_raw_cost)) init_raw_cost
            ,decode(sum(bl.txn_init_burdened_cost),0,NULL,sum(bl.txn_init_burdened_cost)) init_burdened_cost
            ,decode(sum(bl.txn_init_revenue),0,NULL,sum(bl.txn_init_revenue)) init_revenue
             ,(sum(decode(p_avg_txn_cost_rate_override,NULL,NULL
                    ,decode((nvl(bl.quantity,0) - nvl(bl.init_quantity,0)),0,NULL
                    ,decode(nvl(bl.txn_cost_rate_override,nvl(bl.txn_standard_cost_rate,0)),0,NULL
                        ,((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)) *
			  nvl(bl.txn_cost_rate_override,nvl(bl.txn_standard_cost_rate,0)))))))
               / DECODE((sum(decode(p_avg_txn_cost_rate_override,NULL,NULL
                    ,decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,NULL
                    ,decode(nvl(bl.txn_cost_rate_override,nvl(bl.txn_standard_cost_rate,0)),0,null
			,(nvl(bl.quantity,0)- nvl(bl.init_quantity,0)))))))
          	,0,NULL,
          	(sum(decode(p_avg_txn_cost_rate_override,NULL,NULL
                    ,decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,NULL
                    ,decode(nvl(bl.txn_cost_rate_override,nvl(bl.txn_standard_cost_rate,0)),0,null
			,(nvl(bl.quantity,0)- nvl(bl.init_quantity,0)))))))
          	)
              ) etc_cost_rate_override
             ,(sum(decode(p_avg_burden_rate_override,NULL,NULL
                    ,decode((nvl(bl.quantity,0) - nvl(bl.init_quantity,0)),0,NULL
                    ,decode(nvl(bl.burden_cost_rate_override,nvl(bl.burden_cost_rate,0)),0,NULL
                        ,((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)) *
			   nvl(bl.burden_cost_rate_override,nvl(bl.burden_cost_rate,0)))))))
               / DECODE((sum(decode(p_avg_burden_rate_override,NULL,NULL
                    ,decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,NULL
                    ,decode(nvl(bl.burden_cost_rate_override,nvl(bl.burden_cost_rate,0)),0,NULL
			,(nvl(bl.quantity,0)- nvl(bl.init_quantity,0)))))))
          		,0,NULL,
           	(sum(decode(p_avg_burden_rate_override,NULL,NULL
                    ,decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,NULL
                    ,decode(nvl(bl.burden_cost_rate_override,nvl(bl.burden_cost_rate,0)),0,NULL
			,(nvl(bl.quantity,0)- nvl(bl.init_quantity,0)))))))
          	)
              ) etc_burden_rate_override
             ,(sum(decode(p_avg_bill_rate_override,NULL,NULL
                    , decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,NULL
                    ,decode(nvl(bl.txn_bill_rate_override,nvl(bl.txn_standard_bill_rate,0)),0,NULL
                        ,((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)) *
			nvl(bl.txn_bill_rate_override,nvl(bl.txn_standard_bill_rate,0)))))))
               / DECODE((sum(decode(p_avg_bill_rate_override,NULL,NULL
                    ,decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,NULL
                    ,decode(nvl(bl.txn_bill_rate_override,nvl(bl.txn_standard_bill_rate,0)),0,null
			,(nvl(bl.quantity,0)- nvl(bl.init_quantity,0)))))))
          	,0,NULL,
           	(sum(decode(p_avg_bill_rate_override,NULL,NULL
                    ,decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,NULL
                    ,decode(nvl(bl.txn_bill_rate_override,nvl(bl.txn_standard_bill_rate,0)),0,null
			,(nvl(bl.quantity,0)- nvl(bl.init_quantity,0)))))))
           	)
              ) etc_bill_rate_override
             ,(sum(( decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,null
                    ,decode(nvl(bl.txn_bill_rate_override,nvl(bl.txn_standard_bill_rate,0)),0,null
                        ,((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)) *
			nvl(bl.txn_bill_rate_override,nvl(bl.txn_standard_bill_rate,0)))))))
               / DECODE((sum(decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,null
                    ,decode(nvl(bl.txn_bill_rate_override,nvl(bl.txn_standard_bill_rate,0)),0,null
			,(nvl(bl.quantity,0)- nvl(bl.init_quantity,0))))))
          	,0,NULL,
           	(sum(decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,null
                    ,decode(nvl(bl.txn_bill_rate_override,nvl(bl.txn_standard_bill_rate,0)),0
			,null,(nvl(bl.quantity,0)- nvl(bl.init_quantity,0))))))
        	)
              ) etc_bill_rate
           	,(sum(( decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,null
                    ,decode(nvl(bl.txn_cost_rate_override,nvl(bl.txn_standard_cost_rate,0)),0,null
                        ,((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)) *
			nvl(bl.txn_cost_rate_override,nvl(bl.txn_standard_cost_rate,0)))))))
               / DECODE((sum(decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,null
                    ,decode(nvl(bl.txn_cost_rate_override,nvl(bl.txn_standard_cost_rate,0)),0,null
			,(nvl(bl.quantity,0)- nvl(bl.init_quantity,0))))))
           	,0,NULL,
            	(sum(decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,null
                    ,decode(nvl(bl.txn_cost_rate_override,nvl(bl.txn_standard_cost_rate,0)),0,null
			,(nvl(bl.quantity,0)- nvl(bl.init_quantity,0))))))
        	)
              ) etc_cost_rate
             ,(sum(( decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,null
                    ,decode(nvl(bl.burden_cost_rate_override,nvl(bl.burden_cost_rate,0)),0,null
                        ,((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)) *
			  nvl(bl.burden_cost_rate_override,nvl(bl.burden_cost_rate,0)))))))
               / DECODE((sum(decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,null
                    ,decode(nvl(bl.burden_cost_rate_override,nvl(bl.burden_cost_rate,0)),0,null
			,(nvl(bl.quantity,0)- nvl(bl.init_quantity,0))))))
          	,0,NULL,
           	(sum(decode((nvl(bl.quantity,0)- nvl(bl.init_quantity,0)),0,null
                    ,decode(nvl(bl.burden_cost_rate_override,nvl(bl.burden_cost_rate,0)),0,null
			,(nvl(bl.quantity,0)- nvl(bl.init_quantity,0))))))
        	)
              ) etc_burden_rate
       		/* Bug fix:4693839 Currently all the UI page shows null instead of zeros, and when they pass to param value
           * will be passed null, representing no change, but some other API like AMG etc, may pass zero in param value.
           * In order to avoid changing all the calling api, this api is modified to handle nulls and zeros carefully */
           ,SUM(bl.quantity)              bl_zero_null_quantity
           ,SUM(bl.txn_raw_cost)          bl_zero_null_rawcost
           ,SUM(bl.txn_burdened_cost)     bl_zero_null_burdencost
           ,SUM(bl.txn_revenue)           bl_zero_null_revenue
           ,SUM(bl.display_quantity)      display_quantity --Bug 6429285
        FROM pa_budget_lines bl
        WHERE bl.resource_assignment_id = p_resource_asg_id
        AND bl.txn_currency_code      = p_txn_curr_code
        AND ( (p_line_start_date is NULL AND p_line_end_date is NULL )
             OR
            (p_line_start_date is NOT NULL AND p_line_end_date is NOT NULL
            AND bl.start_date BETWEEN p_line_start_date AND p_line_end_date)
           ) ;
Line: 438

        SELECT  decode(rtx.total_quantity,0,null,rtx.total_quantity) quantity
                ,decode( rtx.total_txn_raw_cost,0,NULL,rtx.total_txn_raw_cost) txn_raw_cost
                ,decode(rtx.total_txn_burdened_cost,0,NULL,rtx.total_txn_burdened_cost) txn_burdened_cost
                ,decode(rtx.total_txn_revenue,0,NULL,rtx.total_txn_revenue) txn_revenue
                ,decode(rtx.total_init_quantity,0,NULL,rtx.total_init_quantity) init_quantity
                ,decode(rtx.total_txn_init_raw_cost,0,NULL,rtx.total_txn_init_raw_cost) init_raw_cost
                ,decode(rtx.total_txn_init_burdened_cost,0,NULL,rtx.total_txn_init_burdened_cost) init_burdened_cost
                ,decode(rtx.total_txn_init_revenue,0,NULL,rtx.total_txn_init_revenue) init_revenue
                ,rtx.TXN_RAW_COST_RATE_OVERRIDE     etc_cost_rate_override
                ,rtx.TXN_BURDEN_COST_RATE_OVERRIDE  etc_burden_rate_override
                ,rtx.TXN_BILL_RATE_OVERRIDE         etc_bill_rate_override
                ,rtx.TXN_ETC_BILL_RATE          etc_bill_rate
                ,rtx.TXN_ETC_RAW_COST_RATE      etc_cost_rate
                ,rtx.TXN_ETC_BURDEN_COST_RATE       etc_burden_rate
            ,rtx.total_quantity                 bl_zero_null_quantity
            ,rtx.total_txn_raw_cost             bl_zero_null_rawcost
            ,rtx.total_txn_burdened_cost        bl_zero_null_burdencost
            ,rtx.total_txn_revenue              bl_zero_null_revenue
            ,rtx.total_display_quantity         display_quantity --Bug 6429285
    FROM pa_resource_asgn_curr rtx
    WHERE rtx.resource_assignment_id = p_resource_asg_id
    AND  rtx.txn_currency_code = p_txn_curr_code;
Line: 466

            INSERT INTO PA_FP_CALCULATE_LOG
                (SESSIONID
                ,SEQ_NUMBER
                ,LOG_MESSAGE)
            VALUES
                (userenv('sessionid')
                ,HR.PAY_US_GARN_FEE_RULES_S.nextval
                ,substr(P_MSG,1,240)
                );
Line: 518

 * These error message will be cleared upon any manual update to the ETC Rev amount through calculate process
 */
PROCEDURE clear_etc_rev_other_rejectns
	 (p_budget_version_id     	Number
            ,p_source_context       	Varchar2
            ,p_calling_module     	Varchar2
	    ,p_mode               	Varchar2
            ,x_return_status    OUT NOCOPY Varchar2
            ,x_msg_count        OUT NOCOPY number
            ,x_msg_data     	OUT NOCOPY Varchar2
            ) IS

	CURSOR cur_get_rejLines IS
	SELECT /*+ INDEX(BL PA_BUDGET_LINES_U1) */
		bl.resource_assignment_id
	       ,bl.txn_currency_code
	       ,sum(bl.txn_revenue)
	       ,decode(p_source_context,'BUDGET_LINE',tmp.start_date,NULL) start_date
	       ,decode(p_source_context,'BUDGET_LINE',tmp.end_date,NULL) end_date
	FROM PA_BUDGET_LINES bl
	     ,PA_FP_SPREAD_CALC_TMP tmp
	WHERE tmp.budget_version_id = p_budget_version_id
	AND   bl.resource_assignment_id = tmp.resource_assignment_id
	AND   bl.txn_currency_code = tmp.txn_currency_code
	AND   ((p_source_context = 'BUDGET_LINE'
	       and bl.start_date between tmp.start_date and tmp.end_date )
		OR
		p_source_context <> 'BUDGET_LINE'
	      )
	AND   bl.other_rejection_code is NOT NULL
	GROUP BY bl.resource_assignment_id
		,bl.txn_currency_code
		,decode(p_source_context,'BUDGET_LINE',tmp.start_date,NULL)
		,decode(p_source_context,'BUDGET_LINE',tmp.end_date,NULL) ;
Line: 571

			g_etcrevrej_raId_tab.delete;
Line: 572

			g_etcrevrej_txnCur_tab.delete;
Line: 573

			g_etcrevrej_revenue_tab.delete;
Line: 574

			g_etcrevrej_start_date_tab.delete;
Line: 575

			g_etcrevrej_end_date_tab.delete;
Line: 593

				l_etcrevrej_raId_tab.delete;
Line: 594

                        	l_etcrevrej_txnCur_tab.delete;
Line: 595

                        	l_etcrevrej_revenue_tab.delete;
Line: 596

				g_etcrevrej_start_date_tab.delete;
Line: 597

				g_etcrevrej_end_date_tab.delete;
Line: 608

				UPDATE PA_BUDGET_LINES bl
				SET bl.other_rejection_code = NULL
				WHERE bl.resource_assignment_id = l_etcrevrej_raId_tab(i)
				AND   bl.txn_currency_code = l_etcrevrej_txnCur_tab(i)
				AND   nvl(g_etcrevrej_revenue_tab(i),0) <> nvl(l_etcrevrej_revenue_tab(i),0)
				AND   ((p_source_context = 'BUDGET_LINE'
					and bl.start_date between g_etcrevrej_start_date_tab(i) and g_etcrevrej_end_date_tab(i))
					OR
					p_source_context <> 'BUDGET_LINE'
				      )
				RETURN bl.budget_line_id
				BULK COLLECT INTO l_budget_line_id_tab;
Line: 627

				l_etcrevrej_raId_tab.delete;
Line: 628

                                l_etcrevrej_txnCur_tab.delete;
Line: 629

                                l_etcrevrej_revenue_tab.delete;
Line: 630

				l_budget_line_id_tab.delete;
Line: 631

				g_etcrevrej_raId_tab.delete;
Line: 632

                                g_etcrevrej_txnCur_tab.delete;
Line: 633

                                g_etcrevrej_revenue_tab.delete;
Line: 634

                                g_etcrevrej_start_date_tab.delete;
Line: 635

                                g_etcrevrej_end_date_tab.delete;
Line: 647

PROCEDURE delete_raTxn_Tmp IS
BEGIN
    DELETE FROM pa_resource_asgn_curr_tmp;
Line: 650

END delete_raTxn_Tmp;
Line: 655

	SELECT tmp.resource_assignment_id
		,tmp.txn_currency_code
		,tmp.start_date
		,tmp.end_date
		,tmp.quantity
		,tmp.txn_raw_cost
		,tmp.rw_cost_rate_override
		,tmp.txn_burdened_cost
		,tmp.burden_cost_rate_override
		,tmp.txn_revenue
		,tmp.bill_rate_override
		,tmp.budget_line_id
	FROM pa_fp_rollup_tmp tmp
	ORDER BY tmp.resource_assignment_id
                ,tmp.txn_currency_code;
Line: 672

        SELECT tmp.resource_assignment_id
                ,tmp.txn_currency_code
                ,tmp.start_date
		,tmp.end_date
                ,tmp.quantity
                ,tmp.txn_raw_cost
                ,tmp.cost_rate_override
                ,tmp.txn_burdened_cost
                ,tmp.burden_cost_rate_override
                ,tmp.txn_revenue
                ,tmp.bill_rate_override
        FROM pa_fp_spread_calc_tmp tmp
        ORDER BY tmp.resource_assignment_id
                ,tmp.txn_currency_code;
Line: 711

 * and updates the rate overrides
 * Logic: When Refresh rates flag = 'Y'
 *          -- Delete all records from the new entity
 *        When source context = BUDGET LINE
 *          -- rollup the amounts in the new entity
 *        When source context = RESOURCE ASSIGNMENT
 *          -- create a new record or update existing records with rate overrides
 *  This API inserts records into temp table based on various combination of input parameters
 *  and finally make call to maintain_data package
 */
PROCEDURE populate_raTxn_Recs (
            p_budget_version_id     Number
            ,p_source_context       Varchar2
            ,p_calling_mode     Varchar2
            ,p_delete_flag      Varchar2 := 'N'
            ,p_delete_raTxn_flag    Varchar2 := 'N'
            ,p_rollup_flag      Varchar2 := 'N'
            ,p_call_raTxn_rollup_flag Varchar2 := 'N'
            ,p_refresh_rate_flag    Varchar2 := 'N'
	    ,p_resource_assignment_id NUMBER := NULL
	    ,p_txn_currency_code      Varchar2 := NULL
	    ,p_start_date	      DATE := NULL
            ,x_return_status    OUT NOCOPY Varchar2
            ,x_msg_count        OUT NOCOPY number
            ,x_msg_data     OUT NOCOPY Varchar2
            ) IS
    l_rowCount Number := 0;
Line: 751

     SELECT COPY_ETC_FROM_PLAN_FLAG
     FROM PA_PROJ_FP_OPTIONS
     WHERE FIN_PLAN_VERSION_ID = P_BUDGET_VERSION_ID;
Line: 761

    IF NVL(p_delete_flag,'N') = 'N' Then
      IF p_source_context = 'RESOURCE_ASSIGNMENT' Then
           If NVL(p_refresh_rate_flag,'N') = 'Y' Then --{
            --print_msg('Inserting records into pa_resource_asgn_curr_tmp for Refresh rates action');
Line: 765

            INSERT INTO pa_resource_asgn_curr_tmp raTxn
                        (RA_TXN_ID
                        ,BUDGET_VERSION_ID
                        ,RESOURCE_ASSIGNMENT_ID
                        ,TXN_CURRENCY_CODE
                        ,DELETE_FLAG
                        )
                        SELECT /*+ INDEX(RTX PA_RESOURCE_ASGN_CURR_U2) */ 1 ra_txn_id
                        ,p_budget_version_id
                        ,tmp.resource_assignment_id
                        ,tmp.txn_currency_code
                        ,'Y'
                    FROM pa_fp_spread_calc_tmp tmp
                	,pa_resource_asgn_curr rtx
                    WHERE tmp.budget_version_id = p_budget_version_id
            	    AND tmp.resource_assignment_id = rtx.resource_assignment_id
                    AND tmp.txn_currency_code = rtx.txn_currency_code
		    /* bug fix: If no budge Lines exists then donot delete the resource when refresh is done */
		    AND EXISTS ( select /*+ INDEX(RTMP PA_FP_ROLLUP_TMP_N1) */ null
				 from pa_fp_rollup_tmp rtmp
				 where rtmp.resource_assignment_id = tmp.resource_assignment_id
				 and rtmp.txn_currency_code = tmp.txn_currency_code
				);
Line: 794

		    UPDATE /*+ INDEX(RTX PA_RESOURCE_ASGN_CURR_U2) */ pa_resource_asgn_curr rtx
                    SET rtx.TXN_RAW_COST_RATE_OVERRIDE  = null
                            ,rtx.TXN_BURDEN_COST_RATE_OVERRIDE = null
                            ,rtx.TXN_BILL_RATE_OVERRIDE = null
                    WHERE rtx.budget_version_id = p_budget_version_id
		    AND EXISTS ( select null
				 from pa_fp_spread_calc_tmp tmp
				 where tmp.resource_assignment_id = rtx.resource_assignment_id
				 and tmp.txn_currency_code = rtx.txn_currency_code
				)
                    AND NOT EXISTS ( select null
                                        from pa_fp_rollup_tmp rtmp
                                        where rtmp.resource_assignment_id = rtx.resource_assignment_id
                                        and rtmp.txn_currency_code = rtx.txn_currency_code
                                        );
Line: 809

		     --print_msg('Number of records updated directly with null['||sql%rowcount||']');
Line: 816

                        ,P_DELETE_FLAG          => 'Y'
                        ,P_ROLLUP_FLAG          => 'N'
                        ,P_VERSION_LEVEL_FLAG   => 'N'
                        ,X_RETURN_STATUS        => x_return_status
                        ,X_MSG_COUNT            => x_msg_count
                        ,X_MSG_DATA             => x_msg_data
                        );
Line: 828

                        INSERT INTO pa_resource_asgn_curr_tmp
                        (RA_TXN_ID
                        ,BUDGET_VERSION_ID
                        ,RESOURCE_ASSIGNMENT_ID
                        ,TXN_CURRENCY_CODE
                        ,TXN_RAW_COST_RATE_OVERRIDE
                        ,TXN_BURDEN_COST_RATE_OVERRIDE
                        ,TXN_BILL_RATE_OVERRIDE
                        ,DELETE_FLAG
                        )
                        SELECT /*+ INDEX(TMP PA_FP_SPREAD_CALC_TMP_N1) */ pa_resource_asgn_curr_s.nextval
                        ,p_budget_version_id
                        ,tmp.resource_assignment_id
                        ,NVL(tmp.txn_curr_code_override,tmp.txn_currency_code)
                        ,decode(p_refresh_rate_flag, 'N', tmp.cost_rate_override, NULL)
                        ,decode(p_refresh_rate_flag, 'N', tmp.burden_cost_rate_override, NULL)
                        ,decode(p_refresh_rate_flag, 'N', tmp.bill_rate_override, NULL)
                        ,p_delete_raTxn_flag
                        FROM pa_fp_spread_calc_tmp tmp
                        WHERE tmp.budget_version_id = p_budget_version_id
                        AND NVL(tmp.RA_RATES_ONLY_CHANGE_FLAG,'N') = 'Y'
                          OR (NVL(tmp.cost_rate_changed_flag,'N') = 'Y'
                          OR NVL(tmp.burden_rate_changed_flag,'N') = 'Y'
                          OR NVL(tmp.bill_rate_changed_flag,'N') = 'Y'
              OR NVL(tmp.raw_cost_changed_flag,'N') = 'Y'
              OR NVL(tmp.burden_cost_changed_flag,'N') = 'Y'
              OR NVL(tmp.revenue_changed_flag,'N') = 'Y'
              OR tmp.txn_curr_code_override is NOT NULL
                         );
Line: 860

                        /* The following update is required with current logic of the
                        * new maintain entity which always blows out the records and inserts new records */
            		--print_msg('Updating pa_resource_asgn_curr_tmp to set rate overrides derived during calculate');
Line: 863

                        UPDATE pa_resource_asgn_curr_tmp tmp
                        SET (tmp.TXN_RAW_COST_RATE_OVERRIDE
                        ,tmp.TXN_BURDEN_COST_RATE_OVERRIDE
                        ,tmp.TXN_BILL_RATE_OVERRIDE) =
                                (SELECT decode(tmp1.cost_rate_g_miss_num_flag,'Y',NULL
					,NVL(tmp1.cost_rate_override,rtx.TXN_RAW_COST_RATE_OVERRIDE))
                                ,decode(tmp1.burden_rate_g_miss_num_flag,'Y',NULL
					,NVL(tmp1.burden_cost_rate_override,rtx.TXN_BURDEN_COST_RATE_OVERRIDE))
                                ,decode(tmp1.bill_rate_g_miss_num_flag,'Y',NULL
					,NVL(tmp1.bill_rate_override,rtx.TXN_BILL_RATE_OVERRIDE))
                                FROM pa_resource_asgn_curr rtx
                    			,pa_fp_spread_calc_tmp tmp1
                                WHERE rtx.resource_assignment_id = tmp.resource_assignment_id
                                AND rtx.txn_currency_code = tmp.txn_currency_code
                		AND tmp1.resource_assignment_id = tmp.resource_assignment_id
                		AND NVL(tmp1.txn_curr_code_override,tmp1.txn_currency_code) = tmp.txn_currency_code
                                )
                        WHERE tmp.budget_version_id = p_budget_version_id
                        AND EXISTS (select null from pa_resource_asgn_curr rtx2
                    			,pa_fp_spread_calc_tmp tmp2
                                        where rtx2.resource_assignment_id = tmp.resource_assignment_id
                                        and rtx2.txn_currency_code = tmp.txn_currency_code
                    			AND tmp2.resource_assignment_id = tmp.resource_assignment_id
                                        AND NVL(tmp2.txn_curr_code_override,tmp2.txn_currency_code) = tmp.txn_currency_code
                                   );
Line: 888

            		--print_msg('Number of records Updated ['||sql%Rowcount||']');
Line: 891

          	/* If only rates are changed then update the changed override rates on rollup tmp and avoid calling spread
               	* and call rate api */
              IF g_rtChanged_RaId_tab.COUNT > 0 Then
                g_stage := 'update pa_resource_asgn_curr_tmp with OvrRts';
Line: 897

                UPDATE pa_resource_asgn_curr_tmp tmp
                    SET tmp.TXN_RAW_COST_RATE_OVERRIDE       = decode(NVL(g_rtChanged_cstMisNumFlg_tab(i),'N'),'Y',NULL
                                                        ,NVL(g_rtChanged_CostRt_Tab(i),tmp.TXN_RAW_COST_RATE_OVERRIDE))
                            ,tmp.TXN_BURDEN_COST_RATE_OVERRIDE = decode(NVL(g_rtChanged_bdMisNumFlag_tab(i),'N'),'Y',NULL
                                                        ,NVL(g_rtChanged_BurdRt_tab(i),tmp.TXN_BURDEN_COST_RATE_OVERRIDE))
                            ,tmp.TXN_BILL_RATE_OVERRIDE = decode(NVL(g_rtChanged_blMisNumFlag_tab(i),'N'),'Y',NULL
                                                        ,NVL(g_rtChanged_billRt_tab(i),tmp.TXN_BILL_RATE_OVERRIDE))
                WHERE tmp.budget_version_id = p_budget_version_id
                AND   tmp.resource_assignment_id = g_rtChanged_RaId_tab(i)
                AND   tmp.txn_currency_code = g_rtChanged_TxnCur_tab(i);
Line: 913

		 * so whenever override rates are derived and rollup flag is N, directly update the
		 * new entity with override rates
		 */
	      IF G_call_raTxn_rollup_flag = 'N' Then
			--print_msg('Updating new entity with override rates when rollup flag is N');
Line: 918

			UPDATE /*+ INDEX(RTX PA_RESOURCE_ASGN_CURR_U2) */ pa_resource_asgn_curr rtx
                    	SET (rtx.TXN_RAW_COST_RATE_OVERRIDE
                            ,rtx.TXN_BURDEN_COST_RATE_OVERRIDE
                            ,rtx.TXN_BILL_RATE_OVERRIDE) =
					(SELECT tmp.TXN_RAW_COST_RATE_OVERRIDE
                            			,tmp.TXN_BURDEN_COST_RATE_OVERRIDE
                            			,tmp.TXN_BILL_RATE_OVERRIDE
					FROM pa_resource_asgn_curr_tmp tmp
					WHERE tmp.resource_assignment_id = rtx.resource_assignment_id
					AND   tmp.txn_currency_code = rtx.txn_currency_code
					)
                	WHERE rtx.budget_version_id = p_budget_version_id
			AND EXISTS ( select null
					from pa_resource_asgn_curr_tmp tmp1
                                        where tmp1.resource_assignment_id = rtx.resource_assignment_id
                                        and tmp1.txn_currency_code = rtx.txn_currency_code
                                        );
Line: 940

        If NVL(p_calling_mode,'XXX') NOT IN ('CLEAR_CLOSED_PERIOD','RES_ATTRB_CHANGE','DELETE_BL') Then
        --print_msg('Inserting records in pa_resource_asgn_curr_tmp from rollup Tmp for BUDGET_LINE context');
Line: 942

        INSERT INTO pa_resource_asgn_curr_tmp raTxn
                        (RA_TXN_ID
            ,BUDGET_VERSION_ID
            ,RESOURCE_ASSIGNMENT_ID
                        ,TXN_CURRENCY_CODE
                        )
            SELECT 1 ra_txn_id
            ,p_budget_version_id
            ,tmp.resource_assignment_id
                        ,tmp.txn_currency_code
        FROM pa_fp_rollup_tmp tmp
        WHERE tmp.budget_version_id = p_budget_version_id
        GROUP BY p_budget_version_id
            ,tmp.resource_assignment_id
            ,tmp.txn_currency_code,1;
Line: 961

        IF NVL(p_calling_mode,'XXX') IN ('CLEAR_CLOSED_PERIOD','RES_ATTRB_CHANGE','DELETE_BL') and  l_rowCount = 0 Then
            --print_msg('Inserting records in pa_resource_asgn_curr_tmp from sptmp for periodic deletion');
Line: 963

                INSERT INTO pa_resource_asgn_curr_tmp raTxn
                        (RA_TXN_ID
                        ,BUDGET_VERSION_ID
                        ,RESOURCE_ASSIGNMENT_ID
                        ,TXN_CURRENCY_CODE
                        )
                        SELECT 1 ra_txn_id
                        ,p_budget_version_id
                        ,tmp.resource_assignment_id
                        ,tmp.txn_currency_code
                FROM pa_fp_spread_calc_tmp tmp
                WHERE tmp.budget_version_id = p_budget_version_id
		AND tmp.resource_assignment_id = NVL(p_resource_assignment_id,tmp.resource_assignment_id)
		AND tmp.txn_currency_code = NVL(p_txn_currency_code,tmp.txn_currency_code)
		AND NVL(tmp.start_date,trunc(sysdate)) = NVL(p_start_date,nvl(tmp.start_date,trunc(sysdate)))
                AND ( NVL(tmp.delete_bl_flag,'N') = 'Y'
                    	OR NVL(tmp.sp_curve_change_flag,'N') = 'Y'
                	OR NVL(tmp.sp_fix_date_change_flag,'N') = 'Y'
                	OR NVL(tmp.rlm_id_change_flag,'N') = 'Y'
                	OR NVL(tmp.re_spread_amts_flag,'N') = 'Y'
                	OR p_calling_mode = 'CLEAR_CLOSED_PERIOD'
                	OR ((g_wp_version_flag = 'Y' AND NVL(tmp.plan_dates_change_flag,'N') = 'Y')
                   	OR (NVL(tmp.ra_in_multi_cur_flag,'N') = 'N' AND NVL(tmp.plan_dates_change_flag,'N') = 'Y'))
               		);
Line: 993

            /* The following update is required with current logic of the
            * new maintain entity which always blows out the records and inserts new records */
            UPDATE pa_resource_asgn_curr_tmp tmp
            SET (tmp.TXN_RAW_COST_RATE_OVERRIDE
                        ,tmp.TXN_BURDEN_COST_RATE_OVERRIDE
                        ,tmp.TXN_BILL_RATE_OVERRIDE) =
                (SELECT rtx.TXN_RAW_COST_RATE_OVERRIDE
                            ,rtx.TXN_BURDEN_COST_RATE_OVERRIDE
                            ,rtx.TXN_BILL_RATE_OVERRIDE
                FROM pa_resource_asgn_curr rtx
                WHERE rtx.resource_assignment_id = tmp.resource_assignment_id
                AND rtx.txn_currency_code = tmp.txn_currency_code
                )
            WHERE tmp.budget_version_id = p_budget_version_id
            AND EXISTS (select null from pa_resource_asgn_curr rtx2
                    where rtx2.resource_assignment_id = tmp.resource_assignment_id
                                    and rtx2.txn_currency_code = tmp.txn_currency_code
                   );
Line: 1015

        IF gl_cl_roll_up_tmp_rowid_tab.COUNT>0 AND g_time_phased_code='N' AND p_calling_mode = 'UPDATE_PLAN_TRANSACTION' THEN
            FOR zz IN 1..gl_cl_roll_up_tmp_rowid_tab.COUNT  LOOP
                SELECT rw_cost_rate_override,
                       burden_cost_rate_override,
                       bill_rate_override,
                       resource_assignment_id,
                       txn_currency_code
                INTO   l_rw_cost_rate_override,
                       l_burden_cost_rate_override,
                       l_bill_rate_override,
                       l_ra_id,
                       l_txn_currency_code
                FROM   pa_fp_rollup_tmp
                WHERE  rowid=gl_cl_roll_up_tmp_rowid_tab(zz);
Line: 1030

                UPDATE pa_resource_asgn_curr_tmp
                SET    txn_raw_cost_rate_override    = NVL(l_rw_cost_rate_override,txn_raw_cost_rate_override),
                       txn_burden_cost_rate_override = NVL(l_burden_cost_rate_override,txn_burden_cost_rate_override),
                       txn_bill_rate_override        = NVL(l_bill_rate_override,txn_bill_rate_override)
                WHERE  resource_assignment_id     = l_ra_id
                AND    txn_currency_code          = l_txn_currency_code;
Line: 1039

            gl_cl_roll_up_tmp_rowid_tab.delete;
Line: 1044

    ElsIf p_delete_flag = 'Y' Then
        /* when rollup is not required just delete from tmp table */
        DELETE FROM pa_resource_asgn_curr_tmp;
Line: 1050

    	for c in (select tmp.TXN_RAW_COST_RATE_OVERRIDE costRt
                        ,tmp.TXN_BURDEN_COST_RATE_OVERRIDE BurdRt
                        ,tmp.TXN_BILL_RATE_OVERRIDE  BillRt
            ,tmp1.cost_rate_override tmpCostRt
                        ,tmp1.burden_cost_rate_override tmpBurdRt
                        ,tmp1.bill_rate_override  tmpBillRt
            from pa_resource_asgn_curr_tmp tmp
                ,pa_fp_spread_calc_tmp tmp1) LOOP
        print_msg('Rates in Tmp Table CostRt['|| c.costRt||']BurdRt['||c.burdRt||']BillRt['||c.billRt||']');
Line: 1063

    /* When override currency is passed, then delete the records from new entity for the old currency */
    If p_source_context = 'RESOURCE_ASSIGNMENT' and NVL(p_refresh_rate_flag,'N') = 'N' Then
        --print_msg('Inserting records in pa_resource_asgn_curr_tmp from rollup for Override currency code');
Line: 1066

        INSERT INTO pa_resource_asgn_curr_tmp raTxn
                        (RA_TXN_ID
                        ,BUDGET_VERSION_ID
                        ,RESOURCE_ASSIGNMENT_ID
                        ,TXN_CURRENCY_CODE
            		,DELETE_FLAG
                        )
                        SELECT 1 ra_txn_id
                        ,p_budget_version_id
                        ,tmp.resource_assignment_id
                        ,tmp.txn_currency_code
            		,'Y'
        FROM pa_fp_spread_calc_tmp tmp
        WHERE tmp.budget_version_id = p_budget_version_id
        AND tmp.txn_curr_code_override is NOT NULL
        AND tmp.txn_curr_code_override <> tmp.txn_currency_code;
Line: 1096

             UPDATE pa_resource_asgn_curr rtx
             SET rtx.TXN_RAW_COST_RATE_OVERRIDE  = NULL
                  ,rtx.TXN_BURDEN_COST_RATE_OVERRIDE = NULL
             WHERE rtx.budget_version_id = p_budget_version_id;
Line: 1110

                    ,P_DELETE_FLAG          => 'Y'
                    ,P_ROLLUP_FLAG          => 'N'
                    ,P_VERSION_LEVEL_FLAG   => 'N'
                    ,X_RETURN_STATUS        => x_return_status
                    ,X_MSG_COUNT            => x_msg_count
                    ,X_MSG_DATA             => x_msg_data
                    );
Line: 1132

        ,P_DELETE_FLAG      => 'N'
        ,P_ROLLUP_FLAG      => 'Y' --p_rollup_flag
        ,P_VERSION_LEVEL_FLAG   => 'N'
        ,X_RETURN_STATUS        => x_return_status
        ,X_MSG_COUNT            => x_msg_count
        ,X_MSG_DATA             => x_msg_data
        );
Line: 1169

    UPDATE pa_fp_rollup_tmp tmp
    SET (tmp.rw_cost_rate_override
        ,tmp.burden_cost_rate_override
        ,tmp.bill_rate_override ) =
        (SELECT /*+ INDEX(RAX PA_RESOURCE_ASGN_CURR_U2) */
	    decode(nvl(tmp1.cost_rate_g_miss_num_flag,'N'),'Y',NULL,nvl(tmp.rw_cost_rate_override,rax.txn_raw_cost_rate_override))
               ,decode(nvl(tmp1.burden_rate_g_miss_num_flag,'N'),'Y',NULL
		    ,decode(nvl(tmp1.rate_based_flag,'N'),'Y',nvl(tmp.burden_cost_rate_override,rax.txn_burden_cost_rate_override)
		       ,decode(g_fp_budget_version_type,'REVENUE',nvl(tmp.burden_cost_rate_override,rax.txn_burden_cost_rate_override)
			,'COST',nvl(tmp.burden_cost_rate_override,rax.txn_burden_cost_rate_override)
			,'ALL'
			,decode(tmp1.burden_cost_changed_flag,'Y'
			 ,decode(tmp1.burden_cost_rate_override,0,0
			  ,decode(nvl(tmp.burden_cost_rate_override,rax.txn_burden_cost_rate_override),0,NULL
					,nvl(tmp.burden_cost_rate_override,rax.txn_burden_cost_rate_override)))
			  ,decode(tmp1.raw_cost_changed_flag,'Y'
                           ,decode(nvl(tmp.burden_cost_rate_override,rax.txn_burden_cost_rate_override),0,NULL
                                        ,nvl(tmp.burden_cost_rate_override,rax.txn_burden_cost_rate_override))
				,nvl(tmp.burden_cost_rate_override,rax.txn_burden_cost_rate_override))))))
               ,decode(nvl(tmp1.bill_rate_g_miss_num_flag,'N'),'Y',NULL
			,decode(nvl(tmp1.rate_based_flag,'N'),'Y',nvl(tmp.bill_rate_override,rax.txn_bill_rate_override)
			 ,decode(tmp1.revenue_changed_flag,'Y',nvl(tmp.bill_rate_override,rax.txn_bill_rate_override)
			 ,decode(g_fp_budget_version_type,'COST',tmp.bill_rate_override
				,'REVENUE',nvl(tmp.bill_rate_override,rax.txn_bill_rate_override)
				,'ALL',decode(tmp1.raw_cost_changed_flag,'Y'
					,decode(nvl(tmp.bill_rate_override,rax.txn_bill_rate_override),1,NULL
						,0,NULL,nvl(tmp.bill_rate_override,rax.txn_bill_rate_override))
					,decode(tmp1.burden_cost_changed_flag,'Y'
					 ,decode(tmp1.txn_raw_cost,tmp1.txn_burdened_cost
					  ,decode(nvl(tmp.bill_rate_override,rax.txn_bill_rate_override),1,NULL
                                                ,0,NULL,nvl(tmp.bill_rate_override,rax.txn_bill_rate_override))
						,nvl(tmp.bill_rate_override,rax.txn_bill_rate_override))
					  ,nvl(tmp.bill_rate_override,rax.txn_bill_rate_override)))))))
        FROM    pa_resource_asgn_curr rax
               ,pa_fp_spread_calc_tmp tmp1
        WHERE rax.resource_assignment_id = tmp.resource_assignment_id
        AND   rax.txn_currency_code = tmp.txn_currency_code
        AND   tmp1.resource_assignment_id = rax.resource_assignment_id
        AND   tmp1.txn_currency_code = rax.txn_currency_code
        AND   (g_source_context = 'RESOURCE_ASSIGNMENT'
	       OR
		(g_source_context = 'BUDGET_LINE'
		 and tmp.start_date between tmp1.start_date and tmp1.end_date)
	     )
        )
    WHERE tmp.budget_version_id = p_budget_version_id
    AND EXISTS (select /*+ INDEX(RAX1 PA_RESOURCE_ASGN_CURR_U2) */ null
                from   pa_resource_asgn_curr rax1
                      ,pa_fp_spread_calc_tmp tmp2
                where rax1.resource_assignment_id = tmp.resource_assignment_id
                and rax1.txn_currency_code = tmp.txn_currency_code
                and tmp2.resource_assignment_id = rax1.resource_assignment_id
                and tmp2.txn_currency_code = rax1.txn_currency_code
	        and   (g_source_context = 'RESOURCE_ASSIGNMENT'
               		OR
                	(g_source_context = 'BUDGET_LINE'
                 	and tmp.start_date between tmp2.start_date and tmp2.end_date)
              		)
           );
Line: 1230

    		print_msg('Number of rows updated in the rollup tmp with raTxnOvr ['||sql%rowCount||']');
Line: 1248

    SELECT 'Y'
    INTO l_exists_flag
    FROM DUAL
    WHERE EXISTS (select null
            from pa_fp_spread_calc_tmp1 tmp1
            where tmp1.budget_version_id = p_budget_version_id
        );
Line: 1290

    SELECT nvl(multi_currency_flag,'N')
    INTO G_MRC_INSTALLED_FLAG
    FROM fnd_product_groups
    WHERE  product_group_id=1;
Line: 1402

        SELECT v.project_id
            ,v.fin_plan_type_id
            ,o.projfunc_cost_rate_type
            ,o.projfunc_cost_rate_date_type
            ,o.projfunc_cost_rate_date
            ,o.projfunc_rev_rate_type
            ,o.projfunc_rev_rate_date_type
            ,o.projfunc_rev_rate_date
            ,o.project_cost_rate_type
            ,o.project_cost_rate_date_type
            ,o.project_cost_rate_date
            ,o.project_rev_rate_type
            ,o.project_rev_rate_date_type
            ,o.project_rev_rate_date
        FROM    pa_proj_fp_options o
                ,pa_budget_versions v
        WHERE v.budget_version_id   = p_budget_version_id
        AND o.project_id          = v.project_id
        AND nvl(o.fin_plan_type_id,0)    = nvl(v.fin_plan_type_id,0)
        AND o.fin_plan_version_id = v.budget_version_id;
Line: 1424

        SELECT segment1
                ,project_currency_code
                ,projfunc_currency_code
        FROM pa_projects_all
        WHERE project_id = p_project_id;
Line: 1499

	--G_FP_MRC_TAB.DELETE;
Line: 1500

	g_mrc_budget_line_id_tab.delete;
Line: 1501

	g_mrc_res_assignment_id_tab.delete;
Line: 1502

        g_mrc_txn_curr_code_tab.delete;
Line: 1503

        g_mrc_start_date_tab.delete;
Line: 1504

        g_mrc_end_date_tab.delete;
Line: 1505

        g_mrc_period_name_tab.delete;
Line: 1506

        g_mrc_quantity_tab.delete;
Line: 1507

        g_mrc_txn_raw_cost_tab.delete;
Line: 1508

        g_mrc_txn_burden_cost_tab.delete;
Line: 1509

        g_mrc_txn_revenue_tab.delete;
Line: 1510

        g_mrc_project_curr_code_tab.delete;
Line: 1511

        g_mrc_project_raw_cost_tab.delete;
Line: 1512

        g_mrc_project_burden_cost_tab.delete;
Line: 1513

        g_mrc_project_revenue_tab.delete;
Line: 1514

        g_mrc_projfunc_curr_code_tab.delete;
Line: 1515

        g_mrc_projfunc_raw_cost_tab.delete;
Line: 1516

        g_mrc_projfunc_burden_cost_tab.delete;
Line: 1517

        g_mrc_projfunc_revenue_tab.delete;
Line: 1518

        g_mrc_delete_flag_tab.delete;
Line: 1519

        g_mrc_Billable_flag_tab.delete;
Line: 1520

        g_mrc_project_cst_rt_type_tab.delete;
Line: 1521

        g_mrc_project_cst_exg_rt_tab.delete;
Line: 1522

        g_mrc_project_cst_dt_type_tab.delete;
Line: 1523

        g_mrc_project_cst_rt_dt_tab.delete;
Line: 1524

        g_mrc_project_rev_rt_type_tab.delete;
Line: 1525

        g_mrc_project_rev_exg_rt_tab.delete;
Line: 1526

        g_mrc_project_rev_dt_type_tab.delete;
Line: 1527

        g_mrc_project_rev_rt_dt_tab.delete;
Line: 1528

        g_mrc_projfunc_cst_rt_type_tab.delete;
Line: 1529

        g_mrc_projfunc_cst_exg_rt_tab.delete;
Line: 1530

        g_mrc_projfunc_cst_dt_type_tab.delete;
Line: 1531

        g_mrc_projfunc_cst_rt_dt_tab.delete;
Line: 1532

        g_mrc_projfunc_rev_rt_type_tab.delete;
Line: 1533

        g_mrc_projfunc_rev_exg_rt_tab.delete;
Line: 1534

        g_mrc_projfunc_rev_dt_type_tab.delete;
Line: 1535

        g_mrc_projfunc_rev_rt_dt_tab.delete;
Line: 1541

        is to be deleted or not. Frm AMG flow we will pass N and for
        other calls to calculate api it would be yes*/
PROCEDURE Init_SpreadCalc_Tbls(p_del_spread_calc_tmp1_flg IN VARCHAR2 := 'Y')
IS
	l_return_status 	Varchar2(10);
Line: 1550

        DELETE FROM pa_fp_res_assignments_tmp;
Line: 1551

        DELETE FROM pa_fp_rollup_tmp;
Line: 1552

        DELETE FROM pa_fp_spread_calc_tmp;
Line: 1553

	DELETE FROM pa_resource_asgn_curr_tmp;
Line: 1558

            	DELETE FROM pa_fp_spread_calc_tmp1;
Line: 1560

          /* Bug fix:4272944: The following new api call is added to insert zero qty budget lines for Funding baseline */
          IF (NVL(G_baseline_funding_flag,'N') = 'Y'
                AND NVL(g_bv_approved_rev_flag,'N') = 'Y') THEN
		If P_PA_DEBUG_MODE = 'Y' Then
                print_msg('Calling PA_FP_CALC_UTILS.InsertFunding_ReqdLines API');
Line: 1566

                PA_FP_CALC_UTILS.InsertFunding_ReqdLines
                ( p_budget_verson_id      => g_budget_version_id
                ,p_source_context         => g_source_context
                ,p_calling_module         => g_calling_module
                ,p_apply_progress_flag    => 'N'
                ,p_approved_rev_flag      => g_bv_approved_rev_flag
                ,p_autoBaseLine_flag      => G_baseline_funding_flag
                ,x_return_status          => l_return_status
                );
Line: 1578

                DELETE FROM pa_fp_spread_calc_tmp1;
Line: 1583

        DELETE FROM pa_fp_spread_calc_tmp2;
Line: 1584

        g_sprd_raId_tab.delete;
Line: 1585

        g_sprd_txn_cur_tab.delete;
Line: 1586

        g_sprd_sdate_tab.delete;
Line: 1587

        g_sprd_edate_tab.delete;
Line: 1588

        g_sprd_plan_sdate_tab.delete;
Line: 1589

        g_sprd_plan_edate_tab.delete;
Line: 1590

        g_sprd_txn_rev_tab.delete;
Line: 1591

        g_sprd_txn_rev_addl_tab.delete;
Line: 1592

        g_sprd_txn_raw_tab.delete;
Line: 1593

        g_sprd_txn_raw_addl_tab.delete;
Line: 1594

        g_sprd_txn_burd_tab.delete;
Line: 1595

        g_sprd_txn_burd_addl_tab.delete;
Line: 1596

        g_sprd_qty_tab.delete;
Line: 1597

        g_sprd_qty_addl_tab.delete;
Line: 1598

        g_sprd_txn_cur_ovr_tab.delete;
Line: 1599

        g_sprd_txn_init_rev_tab.delete;
Line: 1600

        g_sprd_txn_init_raw_tab.delete;
Line: 1601

        g_sprd_txn_init_burd_tab.delete;
Line: 1602

        g_sprd_txn_init_qty_tab.delete;
Line: 1603

        g_sprd_spread_reqd_flag_tab.delete;
Line: 1604

        g_sprd_costRt_tab.delete;
Line: 1605

        g_sprd_costRt_Ovr_tab.delete;
Line: 1606

        g_sprd_burdRt_Tab.delete;
Line: 1607

        g_sprd_burdRt_Ovr_tab.delete;
Line: 1608

        g_sprd_billRt_tab.delete;
Line: 1609

        g_sprd_billRt_Ovr_tab.delete;
Line: 1610

        g_sprd_ratebase_flag_tab.delete;
Line: 1611

        g_sprd_projCur_tab.delete;
Line: 1612

        g_sprd_projfuncCur_tab.delete;
Line: 1613

    	g_sprd_task_id_tab.delete;
Line: 1614

        g_sprd_rlm_id_tab.delete;
Line: 1615

        g_sprd_sp_fixed_date_tab.delete;
Line: 1616

        g_sprd_spcurve_id_tab.delete;
Line: 1617

	g_sprd_cstRtmissFlag_tab.delete;
Line: 1618

        g_sprd_bdRtmissFlag_tab.delete;
Line: 1619

        g_sprd_bilRtmissFlag_tab.delete;
Line: 1620

        g_sprd_QtymissFlag_tab.delete;
Line: 1621

        g_sprd_RawmissFlag_tab.delete;
Line: 1622

        g_sprd_BurdmissFlag_tab.delete;
Line: 1623

        g_sprd_RevmissFlag_tab.delete;
Line: 1625

 	g_sprd_neg_Qty_Changflag_tab.delete;
Line: 1626

 	g_sprd_neg_Raw_Changflag_tab.delete;
Line: 1627

 	g_sprd_neg_Burd_Changflag_tab.delete;
Line: 1628

 	g_sprd_neg_rev_Changflag_tab.delete;
Line: 1630

        g_plan_raId_tab.delete;
Line: 1631

        g_plan_txnCur_Tab.delete;
Line: 1632

        g_line_sdate_tab.delete;
Line: 1633

        g_line_edate_tab.delete;
Line: 1634

        g_Wp_curCode_tab.delete;
Line: 1635

        g_refresh_rates_tab.delete;
Line: 1636

        g_refresh_conv_rates_tab.delete;
Line: 1637

        g_mass_adjust_flag_tab.delete;
Line: 1638

        g_mfc_cost_refresh_tab.delete;
Line: 1639

        g_skip_record_tab.delete;
Line: 1640

	g_process_skip_CstRevrec_tab.delete;
Line: 1641

        g_mfc_cost_refrsh_Raid_tab.delete;
Line: 1642

        g_mfc_cost_refrsh_txnCur_tab.delete;
Line: 1645

    	g_rtChanged_Ra_Flag_tab.delete;
Line: 1646

    	g_rtChanged_RaId_tab.delete;
Line: 1647

        g_rtChanged_TxnCur_tab.delete;
Line: 1648

    	g_rtChanged_sDate_tab.delete;
Line: 1649

        g_rtChanged_eDate_tab.delete;
Line: 1650

        g_rtChanged_CostRt_Tab.delete;
Line: 1651

        g_rtChanged_BurdRt_tab.delete;
Line: 1652

        g_rtChanged_billRt_tab.delete;
Line: 1653

	g_rtChanged_cstMisNumFlg_tab.delete;
Line: 1654

        g_rtChanged_bdMisNumFlag_tab.delete;
Line: 1655

        g_rtChanged_blMisNumFlag_tab.delete;
Line: 1656

        g_rtChanged_QtyMisNumFlg_tab.delete;
Line: 1657

        g_rtChanged_RwMisNumFlag_tab.delete;
Line: 1658

        g_rtChanged_BrMisNumFlag_tab.delete;
Line: 1659

        g_rtChanged_RvMisNumFlag_tab.delete;
Line: 1661

    	g_applyProg_refreshRts_tab.delete;
Line: 1662

    	g_applyProg_RaId_tab.delete;
Line: 1663

        g_applyProg_TxnCur_tab.delete;
Line: 1675

    g_rep_budget_line_id_tab.delete;
Line: 1676

        g_rep_res_assignment_id_tab .delete;
Line: 1677

        g_rep_start_date_tab.delete;
Line: 1678

        g_rep_end_date_tab.delete;
Line: 1679

        g_rep_period_name_tab.delete;
Line: 1680

        g_rep_txn_curr_code_tab.delete;
Line: 1681

        g_rep_quantity_tab.delete;
Line: 1682

        g_rep_txn_raw_cost_tab.delete;
Line: 1683

        g_rep_txn_burdened_cost_tab.delete;
Line: 1684

        g_rep_txn_revenue_tab.delete;
Line: 1685

        g_rep_project_curr_code_tab.delete;
Line: 1686

        g_rep_project_raw_cost_tab.delete;
Line: 1687

        g_rep_project_burden_cost_tab.delete;
Line: 1688

        g_rep_project_revenue_tab.delete;
Line: 1689

        g_rep_projfunc_curr_code_tab.delete;
Line: 1690

        g_rep_projfunc_raw_cost_tab.delete;
Line: 1691

        g_rep_projfunc_burden_cost_tab.delete;
Line: 1692

        g_rep_projfunc_revenue_tab.delete;
Line: 1693

	g_rep_line_mode_tab.delete;
Line: 1694

        g_rep_rate_base_flag_tab.delete;
Line: 1745

        SELECT 'E'
        FROM DUAL
        WHERE EXISTS (select null
                        from pa_fp_rollup_tmp tmp
                        where ( tmp.cost_rejection_code in ('PA_FP_PROJ_NO_TXNCONVRATE'
                                                        ,'PA_FP_PRJFUNC_CURR_NULL'
                                                        ,'PA_FP_PRJ_CURR_NULL'
                            ,'PA_FP_ERROR_FROM_RATE_API_CALL' )
                                OR tmp.revenue_rejection_code in ('PA_FP_PROJ_NO_TXNCONVRATE'
                                                        ,'PA_FP_PRJFUNC_CURR_NULL'
                                                        ,'PA_FP_PRJ_CURR_NULL'
                            ,'PA_FP_ERROR_FROM_RATE_API_CALL')
                             ));
Line: 1799

		,p_delete_flag                  IN      Varchar2 := 'N'
		,p_billable_flag                IN      Varchar2 := 'Y'
		,p_project_cost_rate_type	IN      Varchar2 default NULL
                ,p_project_cost_exchange_rate	IN      Number   default NULL
                ,p_project_cost_rate_date_type  IN      Varchar2 default NULL
                ,p_project_cost_rate_date	IN      Date     default NULL
                ,p_project_rev_rate_type	IN      Varchar2 default NULL
                ,p_project_rev_exchange_rate	IN      Number   default NULL
                ,p_project_rev_rate_date_type   IN      Varchar2 default NULL
                ,p_project_rev_rate_date	IN      Date     default NULL
                ,p_projfunc_cost_rate_type      IN      Varchar2 default NULL
                ,p_projfunc_cost_exchange_rate	IN      Number   default NULL
                ,p_projfunc_cost_rate_date_type IN      Varchar2 default NULL
                ,p_projfunc_cost_rate_date	IN      Date     default NULL
                ,p_projfunc_rev_rate_type       IN      Varchar2 default NULL
                ,p_projfunc_rev_exchange_rate	IN      Number   default NULL
                ,p_projfunc_rev_rate_date_type  IN      Varchar2 default NULL
                ,p_projfunc_rev_rate_date	IN      Date     default NULL
                ,x_msg_data                     OUT NOCOPY Varchar2
                ,x_return_status                OUT NOCOPY Varchar2
                ) IS

    	l_msg_count   Number :=0;
Line: 1846

        g_mrc_delete_flag_tab(NVL( g_mrc_delete_flag_tab.LAST,0)+1)            := p_delete_flag;
Line: 1875

/* This API inserts mrc plsql table of records into pa_fp_rollup_tmp when mrc conv is required */
PROCEDURE Populate_rollup_WithMrcRecs
	   	(p_budget_version_id            IN      Number
		,x_msg_data                     OUT NOCOPY Varchar2
                ,x_return_status                OUT NOCOPY Varchar2
                ) IS

BEGIN
	x_return_status := 'S';
Line: 1891

	      --print_msg('Number of records inserting into rollupTmp for MRC processing['||g_mrc_budget_line_id_tab.COUNT||']');
Line: 1893

		  INSERT INTO PA_FP_ROLLUP_TMP tmp
			(budget_version_id
       			,budget_line_id
       			,resource_assignment_id
       			,txn_currency_code
       			,start_date
       			,end_date
       			,period_name
       			,quantity
       			,txn_raw_cost
       			,txn_burdened_cost
       			,txn_revenue
       			,project_currency_code
       			,project_raw_cost
       			,project_burdened_cost
       			,project_revenue
       			,project_cost_rate_type
       			,project_cost_exchange_rate
       			,project_cost_rate_date_type
       			,project_cost_rate_date
       			,project_rev_rate_type
       			,project_rev_exchange_rate
       			,project_rev_rate_date_type
       			,project_rev_rate_date
       			,projfunc_currency_code
       			,projfunc_raw_cost
       			,projfunc_burdened_cost
       			,projfunc_revenue
       			,projfunc_cost_rate_type
       			,projfunc_cost_exchange_rate
       			,projfunc_cost_rate_date_type
       			,projfunc_cost_rate_date
       			,projfunc_rev_rate_type
       			,projfunc_rev_exchange_rate
       			,projfunc_rev_rate_date_type
       			,projfunc_rev_rate_date
       			,delete_flag
			)
		SELECT p_budget_version_id
                        ,g_mrc_budget_line_id_tab(i)
                        ,g_mrc_res_assignment_id_tab(i)
                        ,g_mrc_txn_curr_code_tab(i)
                        ,g_mrc_start_date_tab(i)
                        ,g_mrc_end_date_tab(i)
                        ,g_mrc_period_name_tab(i)
                        ,g_mrc_quantity_tab(i)
                        ,g_mrc_txn_raw_cost_tab(i)
                        ,g_mrc_txn_burden_cost_tab(i)
                        ,g_mrc_txn_revenue_tab(i)
                        ,g_mrc_project_curr_code_tab(i)
                        ,g_mrc_project_raw_cost_tab(i)
                        ,g_mrc_project_burden_cost_tab(i)
                        ,g_mrc_project_revenue_tab(i)
                        ,g_mrc_project_cst_rt_type_tab(i)
                        ,g_mrc_project_cst_exg_rt_tab(i)
                        ,g_mrc_project_cst_dt_type_tab(i)
                        ,g_mrc_project_cst_rt_dt_tab(i)
                        ,g_mrc_project_rev_rt_type_tab(i)
                        ,g_mrc_project_rev_exg_rt_tab(i)
                        ,g_mrc_project_rev_dt_type_tab(i)
                        ,g_mrc_project_rev_rt_dt_tab(i)
                        ,g_mrc_projfunc_curr_code_tab(i)
                        ,g_mrc_projfunc_raw_cost_tab(i)
                        ,g_mrc_projfunc_burden_cost_tab(i)
                        ,g_mrc_projfunc_revenue_tab(i)
                        ,g_mrc_projfunc_cst_rt_type_tab(i)
                        ,g_mrc_projfunc_cst_exg_rt_tab(i)
                        ,g_mrc_projfunc_cst_dt_type_tab(i)
                        ,g_mrc_projfunc_cst_rt_dt_tab(i)
                        ,g_mrc_projfunc_rev_rt_type_tab(i)
                        ,g_mrc_projfunc_rev_exg_rt_tab(i)
                        ,g_mrc_projfunc_rev_dt_type_tab(i)
                        ,g_mrc_projfunc_rev_rt_dt_tab(i)
                        ,g_mrc_delete_flag_tab(i)
		FROM DUAL
		WHERE NOT EXISTS (SELECT NULL
				FROM PA_FP_ROLLUP_TMP RLTMP1
				WHERE rltmp1.budget_line_id = g_mrc_budget_line_id_tab(i)
				);
Line: 1998

		Delete pa_fp_spread_calc_tmp1;
Line: 2000

		INSERT INTO pa_fp_spread_calc_tmp1
		(budget_line_id
		,resource_assignment_id
		,start_date
		,end_date
		,period_name
		,txn_currency_code
		,quantity
		,txn_raw_cost
		,txn_burdened_cost
		,txn_revenue
		,project_currency_code
		,project_raw_cost
		,project_burdened_cost
		,project_revenue
		,projfunc_currency_code
		,projfunc_raw_cost
		,projfunc_burdened_cost
		,projfunc_revenue
		,system_reference_var1
		,budget_version_id
		) VALUES
        	(g_rep_budget_line_id_tab(i)
        	,g_rep_res_assignment_id_tab(i)
        	,g_rep_start_date_tab(i)
        	,g_rep_end_date_tab(i)
        	,g_rep_period_name_tab(i)
        	,g_rep_txn_curr_code_tab(i)
        	,g_rep_quantity_tab(i)
        	,g_rep_txn_raw_cost_tab(i)
        	,g_rep_txn_burdened_cost_tab(i)
        	,g_rep_txn_revenue_tab(i)
        	,g_rep_project_curr_code_tab(i)
        	,g_rep_project_raw_cost_tab(i)
        	,g_rep_project_burden_cost_tab(i)
        	,g_rep_project_revenue_tab(i)
        	,g_rep_projfunc_curr_code_tab(i)
        	,g_rep_projfunc_raw_cost_tab(i)
        	,g_rep_projfunc_burden_cost_tab(i)
        	,g_rep_projfunc_revenue_tab(i)
		,g_rep_line_mode_tab(i)
		,p_budget_version_id
		);
Line: 2053

		UPDATE pa_fp_spread_calc_tmp1 tmp1
		SET tmp1.rate_based_flag  =
			(SELECT decode(nvl(tmp.system_reference_var3,'N'),'Y'
				,decode(nvl(tmp1.system_reference_var1,'XXX'),'REVERSAL','N',NULL),NULL)
			FROM pa_fp_spread_calc_tmp tmp
			WHERE tmp.resource_assignment_id = tmp1.resource_assignment_id
			AND ROWNUM = 1
			)
		WHERE tmp1.budget_version_id = p_budget_version_id
		AND EXISTS (select null
			FROM pa_fp_spread_calc_tmp otmp
                        WHERE otmp.resource_assignment_id = tmp1.resource_assignment_id
                        );
Line: 2067

		print_msg('Number of rows updated for ratebasedFlag for Pjirollup['||sql%rowcount||']');
Line: 2070

		SELECT
		tmp1.budget_line_id
                ,tmp1.resource_assignment_id
                ,tmp1.start_date
                ,tmp1.end_date
                ,tmp1.period_name
                ,tmp1.txn_currency_code
                ,tmp1.quantity
                ,tmp1.txn_raw_cost
                ,tmp1.txn_burdened_cost
                ,tmp1.txn_revenue
                ,tmp1.project_currency_code
                ,tmp1.project_raw_cost
                ,tmp1.project_burdened_cost
                ,tmp1.project_revenue
                ,tmp1.projfunc_currency_code
                ,tmp1.projfunc_raw_cost
                ,tmp1.projfunc_burdened_cost
                ,tmp1.projfunc_revenue
		,tmp1.system_reference_var1
		,tmp1.rate_based_flag
                BULK COLLECT INTO
                g_rep_budget_line_id_tab
                ,g_rep_res_assignment_id_tab
                ,g_rep_start_date_tab
                ,g_rep_end_date_tab
                ,g_rep_period_name_tab
                ,g_rep_txn_curr_code_tab
                ,g_rep_quantity_tab
                ,g_rep_txn_raw_cost_tab
                ,g_rep_txn_burdened_cost_tab
                ,g_rep_txn_revenue_tab
                ,g_rep_project_curr_code_tab
                ,g_rep_project_raw_cost_tab
                ,g_rep_project_burden_cost_tab
                ,g_rep_project_revenue_tab
                ,g_rep_projfunc_curr_code_tab
                ,g_rep_projfunc_raw_cost_tab
                ,g_rep_projfunc_burden_cost_tab
                ,g_rep_projfunc_revenue_tab
		,g_rep_line_mode_tab
		,g_rep_rate_base_flag_tab
		FROM pa_fp_spread_calc_tmp1 tmp1
		ORDER BY tmp1.resource_assignment_id
			,tmp1.txn_currency_code;
Line: 2134

                ,p_activity_code                IN      Varchar2 Default 'UPDATE'
                ,p_budget_version_id            IN      Number
                ,p_budget_line_id               IN      Number
                ,p_resource_assignment_id       IN      Number
                ,p_start_date                   IN      Date
                ,p_end_date                     IN      Date
                ,p_period_name                  IN      Varchar2
                ,p_txn_currency_code            IN      Varchar2
                ,p_quantity                     IN      Number
                ,p_txn_raw_cost                 IN      Number
                ,p_txn_burdened_cost            IN      Number
                ,p_txn_revenue                  IN      Number
                ,p_project_currency_code        IN      Varchar2
                ,p_project_raw_cost             IN      Number
                ,p_project_burdened_cost        IN      Number
                ,p_project_revenue              IN      Number
                ,p_projfunc_currency_code       IN      Varchar2
                ,p_projfunc_raw_cost            IN      Number
                ,p_projfunc_burdened_cost       IN      Number
                ,p_projfunc_revenue             IN      Number
		,p_rep_line_mode                IN      Varchar2
                ,x_msg_data                     OUT NOCOPY Varchar2
                ,x_return_status                OUT NOCOPY Varchar2
                ) IS

    l_msg_count   Number :=0;
Line: 2211

        print_msg('Failed in PA_FP_PJI_INTG_PKG.update_reporting_lines API ['||sqlcode||sqlerrm);
Line: 2237

PROCEDURE Update_PCPFC_rounding_diff(
        p_project_id                     IN  pa_budget_versions.project_id%type
                ,p_budget_version_id              IN  pa_budget_versions.budget_version_id%TYPE
                ,p_calling_module                IN  VARCHAR2 DEFAULT NULL
                ,p_source_context                IN  pa_fp_res_assignments_tmp.source_context%TYPE
                ,p_wp_cost_enabled_flag          IN  varchar2
                ,p_budget_version_type           IN  varchar2
                ,x_return_status                 OUT NOCOPY VARCHAR2
                ,x_msg_count                     OUT NOCOPY NUMBER
                ,x_msg_data                      OUT NOCOPY VARCHAR2) IS

    CURSOR cur_round_discrepancy_lines IS
    SELECT resource_assignment_id
                ,txn_currency_code
                ,MAX(start_date)
                ,SUM(quantity)
                ,SUM(init_quantity)
                ,SUM(txn_raw_cost)
                ,SUM(txn_init_raw_cost)
                ,SUM(txn_burdened_cost)
                ,SUM(txn_init_burdened_cost)
                ,SUM(txn_revenue)
                ,SUM(txn_init_revenue)
        ,SUM(txn_raw_cost * project_cost_exchange_rate)   unround_project_raw_cost
        ,SUM(txn_burdened_cost * project_cost_exchange_rate) unround_project_burden_cost
        ,SUM(txn_revenue * project_rev_exchange_rate)   unround_project_revenue
        ,SUM(pa_currency.round_trans_currency_amt1((txn_raw_cost * project_cost_exchange_rate),project_currency_code)) round_project_raw_cost
        ,SUM(pa_currency.round_trans_currency_amt1((txn_burdened_cost * project_cost_exchange_rate),project_currency_code)) round_project_burden_cost
        ,SUM(pa_currency.round_trans_currency_amt1((txn_revenue * project_rev_exchange_rate),project_currency_code)) round_project_revenue
        ,SUM(txn_raw_cost * projfunc_cost_exchange_rate)   unround_projfunc_raw_cost
                ,SUM(txn_burdened_cost * projfunc_cost_exchange_rate) unround_projfunc_burden_cost
                ,SUM(txn_revenue * projfunc_rev_exchange_rate)   unround_projfunc_revenue
                ,SUM(pa_currency.round_trans_currency_amt1((txn_raw_cost * projfunc_cost_exchange_rate),projfunc_currency_code)) round_projfunc_raw_cost
                ,SUM(pa_currency.round_trans_currency_amt1((txn_burdened_cost * projfunc_cost_exchange_rate),projfunc_currency_code)) round_projfunc_burden_cost
                ,SUM(pa_currency.round_trans_currency_amt1((txn_revenue * projfunc_rev_exchange_rate),projfunc_currency_code)) round_projfunc_revenue
        ,to_number(NULL) diff_proj_raw_cost
                ,to_number(NULL) diff_proj_burden_cost
                ,to_number(NULL) diff_proj_revenue
        ,to_number(NULL) diff_projfunc_raw_cost
                ,to_number(NULL) diff_projfunc_burden_cost
                ,to_number(NULL) diff_projfunc_revenue
        ,project_currency_code
        ,projfunc_currency_code
        FROM pa_fp_rollup_tmp tmp
    WHERE tmp.budget_version_id = p_budget_version_id
    AND nvl(quantity,0) <> 0
    AND  ( tmp.txn_currency_code <> tmp.project_currency_code
        OR
        tmp.txn_currency_code <> tmp.projfunc_currency_code
         )
    GROUP BY resource_assignment_id
                ,txn_currency_code
        ,project_currency_code
        ,projfunc_currency_code;
Line: 2340

            pa_debug.init_err_stack('PA_FP_CALC_PLAN_PKG.Update_PCPFCrounding_diff');
Line: 2343

    g_stage := 'Update_PCPFC_rounding_diff:100';
Line: 2344

        pa_debug.g_err_stage := 'Entered Update_PCPFCrounding_diff API';
Line: 2349

        l_resource_assignment_tab.delete;
Line: 2350

            l_txn_currency_code_tab.delete;
Line: 2351

            l_start_date_tab.delete;
Line: 2352

            l_quantity_tab.delete;
Line: 2353

            l_init_quantity_tab.delete;
Line: 2354

            l_txn_raw_cost_tab.delete;
Line: 2355

            l_txn_init_raw_cost_tab.delete;
Line: 2356

            l_txn_burdened_cost_tab.delete;
Line: 2357

            l_txn_init_burdened_cost_tab.delete;
Line: 2358

            l_txn_revenue_tab.delete;
Line: 2359

            l_txn_init_revenue_tab.delete;
Line: 2360

        l_unround_proj_raw_cost_tab.delete;
Line: 2361

            l_unround_proj_burd_cost_tab.delete;
Line: 2362

            l_unround_proj_rev_tab.delete;
Line: 2363

            l_round_proj_raw_cost_tab.delete;
Line: 2364

            l_round_proj_burd_cost_tab.delete;
Line: 2365

            l_round_proj_rev_tab.delete;
Line: 2366

            l_unround_pjfc_raw_cost_tab.delete;
Line: 2367

            l_unround_pjfc_burd_cost_tab.delete;
Line: 2368

            l_unround_pjfc_rev_tab.delete;
Line: 2369

            l_round_pjfc_raw_cost_tab.delete;
Line: 2370

            l_round_pjfc_burd_cost_tab.delete;
Line: 2371

            l_round_pjfc_rev_tab.delete;
Line: 2372

            l_diff_proj_raw_cost_tab.delete;
Line: 2373

            l_diff_proj_burd_cost_tab.delete;
Line: 2374

            l_diff_proj_rev_tab.delete;
Line: 2375

            l_diff_pjfc_raw_cost_tab.delete;
Line: 2376

            l_diff_pjfc_burd_cost_tab.delete;
Line: 2377

            l_diff_pjfc_rev_tab.delete;
Line: 2378

        l_proj_currency_code_tab.delete;
Line: 2379

        l_pjfc_currency_code_tab.delete;
Line: 2418

            g_stage := 'Update_PCPFC_rounding_diff:101';
Line: 2448

            g_stage := 'Update_PCPFC_rounding_diff:102';
Line: 2450

            UPDATE pa_fp_rollup_tmp tmp
                        SET tmp.attribute14 = decode(tmp.txn_currency_code,tmp.project_currency_code,NULL,'PCPFCRoundingDiscrepancyLine')
            /*---Project columns ---*/
            ,tmp.project_raw_cost = decode(p_budget_version_type,'COST',
                            decode(tmp.txn_currency_code,tmp.project_currency_code,tmp.project_raw_cost
                                ,decode((nvl(tmp.project_raw_cost,0)+ NVL(l_diff_proj_raw_cost_tab(i),0)),0,NULL,
                                    (nvl(tmp.project_raw_cost,0)+ NVL(l_diff_proj_raw_cost_tab(i),0))))
                              ,'ALL',
                                                        decode(tmp.txn_currency_code,tmp.project_currency_code,tmp.project_raw_cost
                                                                ,decode((nvl(tmp.project_raw_cost,0)+ NVL(l_diff_proj_raw_cost_tab(i),0)),0,NULL,
                                                                        (nvl(tmp.project_raw_cost,0)+ NVL(l_diff_proj_raw_cost_tab(i),0))))
                              ,'REVENUE',tmp.project_raw_cost)
            ,tmp.project_burdened_cost =decode(p_budget_version_type,'COST',
                                                        decode(tmp.txn_currency_code,tmp.project_currency_code,tmp.project_burdened_cost
                                                                ,decode((nvl(tmp.project_burdened_cost,0)+ NVL(l_diff_proj_burd_cost_tab(i),0)),0,NULL,
                                                                        (nvl(tmp.project_burdened_cost,0)+ NVL(l_diff_proj_burd_cost_tab(i),0))))
                                                      ,'ALL',
                                                        decode(tmp.txn_currency_code,tmp.project_currency_code,tmp.project_burdened_cost
                                                                ,decode((nvl(tmp.project_burdened_cost,0)+ NVL(l_diff_proj_burd_cost_tab(i),0)),0,NULL,
                                                                        (nvl(tmp.project_burdened_cost,0)+ NVL(l_diff_proj_burd_cost_tab(i),0))))
                                                      ,'REVENUE',tmp.project_burdened_cost)
            ,tmp.project_revenue = decode(p_budget_version_type,'COST', tmp.project_revenue
                            ,'ALL',decode(tmp.txn_currency_code,tmp.project_currency_code,tmp.project_revenue
                                ,DECODE(l_null_revenue_amts_flag,'Y',tmp.project_revenue
                                  ,decode((nvl(tmp.project_revenue,0)+nvl(l_diff_proj_rev_tab(i),0)),0,NULL,
                                     (nvl(tmp.project_revenue,0)+nvl(l_diff_proj_rev_tab(i),0)))))
                            ,'REVENUE', decode(tmp.txn_currency_code,tmp.project_currency_code,tmp.project_revenue
                                ,decode((nvl(tmp.project_revenue,0)+nvl(l_diff_proj_rev_tab(i),0)),0,NULL,
                                                                     (nvl(tmp.project_revenue,0)+nvl(l_diff_proj_rev_tab(i),0)))))
            /*---ProjFunc columns ---*/
            ,tmp.projfunc_raw_cost = decode(p_budget_version_type,'COST',
                                                        decode(tmp.txn_currency_code,tmp.projfunc_currency_code,tmp.projfunc_raw_cost
                                                                ,decode((nvl(tmp.projfunc_raw_cost,0)+ NVL(l_diff_pjfc_raw_cost_tab(i),0)),0,NULL,
                                                                        (nvl(tmp.projfunc_raw_cost,0)+ NVL(l_diff_pjfc_raw_cost_tab(i),0))))
                                                      ,'ALL',
                                                        decode(tmp.txn_currency_code,tmp.projfunc_currency_code,tmp.projfunc_raw_cost
                                                                ,decode((nvl(tmp.projfunc_raw_cost,0)+ NVL(l_diff_pjfc_raw_cost_tab(i),0)),0,NULL,
                                                                        (nvl(tmp.projfunc_raw_cost,0)+ NVL(l_diff_pjfc_raw_cost_tab(i),0))))
                                                      ,'REVENUE',tmp.projfunc_raw_cost)
            ,tmp.projfunc_burdened_cost = decode(p_budget_version_type,'COST',
                                                        decode(tmp.txn_currency_code,tmp.projfunc_currency_code,tmp.projfunc_burdened_cost
                                                                ,decode((nvl(tmp.projfunc_burdened_cost,0)+ NVL(l_diff_pjfc_burd_cost_tab(i),0)),0,NULL,
                                                                        (nvl(tmp.projfunc_burdened_cost,0)+ NVL(l_diff_pjfc_burd_cost_tab(i),0))))
                                                      ,'ALL',
                                                        decode(tmp.txn_currency_code,tmp.projfunc_currency_code,tmp.projfunc_burdened_cost
                                                                ,decode((nvl(tmp.projfunc_burdened_cost,0)+ NVL(l_diff_pjfc_burd_cost_tab(i),0)),0,NULL,
                                                                        (nvl(tmp.projfunc_burdened_cost,0)+ NVL(l_diff_pjfc_burd_cost_tab(i),0))))
                                                      ,'REVENUE',tmp.projfunc_burdened_cost)
            ,tmp.projfunc_revenue = decode(p_budget_version_type,'COST', tmp.projfunc_revenue
                                                        ,'ALL',decode(tmp.txn_currency_code,tmp.projfunc_currency_code,tmp.projfunc_revenue
                                                                ,DECODE(l_null_revenue_amts_flag,'Y',tmp.projfunc_revenue
                                                                  ,decode((nvl(tmp.projfunc_revenue,0)+nvl(l_diff_pjfc_rev_tab(i),0)),0,NULL,
                                                                     (nvl(tmp.projfunc_revenue,0)+nvl(l_diff_pjfc_rev_tab(i),0)))))
                                                        ,'REVENUE', decode(tmp.txn_currency_code,tmp.projfunc_currency_code,tmp.projfunc_revenue
                                                                ,decode((nvl(tmp.projfunc_revenue,0)+nvl(l_diff_pjfc_rev_tab(i),0)),0,NULL,
                                                                     (nvl(tmp.projfunc_revenue,0)+nvl(l_diff_pjfc_rev_tab(i),0)))))
                        WHERE tmp.resource_assignment_id = l_resource_assignment_tab(i)
                        AND   tmp.txn_currency_code = l_txn_currency_code_tab(i)
                        AND   tmp.start_date = l_start_date_tab(i)
                        AND   (NVL(l_diff_proj_raw_cost_tab(i),0) <> 0
                     OR NVL(l_diff_proj_burd_cost_tab(i),0) <> 0
                 OR NVL(l_diff_proj_rev_tab(i),0) <> 0
                 OR NVL(l_diff_pjfc_raw_cost_tab(i),0) <> 0
                                 OR NVL(l_diff_pjfc_burd_cost_tab(i),0) <> 0
                                 OR NVL(l_diff_pjfc_rev_tab(i),0) <> 0 );
Line: 2517

                        AND   tmp.rowid in (select max(rowid)
                                            from pa_fp_rollup_tmp tmp2
                                            where tmp2.resource_assignment_id = tmp.resource_assignment_id
                                            and tmp2.txn_currency_code = tmp.txn_currency_code
                                            and tmp2.start_date = tmp.start_date
                                           );
Line: 2531

    g_stage := 'Update_PCPFC_rounding_diff:103';
Line: 2534

    	print_msg('End of Update_PCPFCrounding_diff API return Sts['||x_return_status||']');
Line: 2540

                print_msg('Failed in Update_PCPFCrounding_diff API ['||sqlcode||sqlerrm);
Line: 2545

                 ,p_procedure_name => 'Update_PCPFC_rounding_diff' );
Line: 2546

                print_msg('Failed in Update_PCPFC_rounding_diff substr(SQLERRM,1,240) => '|| substr(SQLERRM,1,240));
Line: 2551

END Update_PCPFC_rounding_diff;
Line: 2554

 * updated with the rounding discrepancy amounts
 */
PROCEDURE Update_rounding_diff(
        p_project_id             IN  pa_budget_versions.project_id%type
        ,p_budget_version_id              IN  pa_budget_versions.budget_version_id%TYPE
        ,p_calling_module                IN  VARCHAR2 DEFAULT NULL
        ,p_source_context                IN  pa_fp_res_assignments_tmp.source_context%TYPE
        ,p_wp_cost_enabled_flag          IN  varchar2
        ,p_budget_version_type           IN  varchar2
                ,x_return_status                 OUT NOCOPY VARCHAR2
                ,x_msg_count                     OUT NOCOPY NUMBER
                ,x_msg_data                      OUT NOCOPY VARCHAR2) IS

    CURSOR cur_round_discrepancy_lines IS
    SELECT resource_assignment_id
                ,txn_currency_code
                ,MAX(start_date)
                ,SUM(quantity)
                ,SUM(init_quantity)
                ,SUM(txn_raw_cost)
                ,SUM(txn_init_raw_cost)
                ,SUM(txn_burdened_cost)
                ,SUM(txn_init_burdened_cost)
                ,SUM(txn_revenue)
                ,SUM(txn_init_revenue)
                ,SUM(((NVL(quantity,0) - nvl(init_quantity,0)) * nvl(rw_cost_rate_override,cost_rate))) unrounded_txn_raw_cost
                ,SUM(((NVL(quantity,0) - nvl(init_quantity,0)) * nvl(burden_cost_rate_override,burden_cost_rate))) unrounded_txn_burdened_cost
                ,SUM(((NVL(quantity,0) - nvl(init_quantity,0)) * nvl(bill_rate_override,bill_rate))) unrounded_txn_revenue
        ,SUM(decode(nvl(rw_cost_rate_override,nvl(cost_rate,0)),0,0
            ,pa_currency.round_trans_currency_amt1((nvl(txn_raw_cost,0) - nvl(txn_init_raw_cost,0)),txn_currency_code))) rounded_txn_raw_cost
        ,SUM(decode(nvl(burden_cost_rate_override,nvl(burden_cost_rate,0)),0,0
            ,pa_currency.round_trans_currency_amt1((nvl(txn_burdened_cost,0) - nvl(txn_init_burdened_cost,0)),txn_currency_code))) rounded_txn_burdened_cost
                ,SUM(decode(nvl(bill_rate_override,nvl(bill_rate,0)),0,0
            ,pa_currency.round_trans_currency_amt1((nvl(txn_revenue,0) - nvl(txn_init_revenue,0)),txn_currency_code))) rounded_txn_revenue
        /**
                ,SUM(pa_currency.round_trans_currency_amt1(((NVL(quantity,0) - nvl(init_quantity,0)) * nvl(rw_cost_rate_override,cost_rate))
            ,txn_currency_code)) rounded_txn_raw_cost
                ,SUM(pa_currency.round_trans_currency_amt1(((NVL(quantity,0) - nvl(init_quantity,0)) * nvl(burden_cost_rate_override,burden_cost_rate))
                        ,txn_currency_code)) rounded_txn_burdened_cost
                ,SUM(pa_currency.round_trans_currency_amt1(((NVL(quantity,0) - nvl(init_quantity,0)) * nvl(bill_rate_override,bill_rate))
            ,txn_currency_code)) rounded_txn_revenue
         **/
        ,to_number(NULL) diff_raw_cost
        ,to_number(NULL) diff_burden_cost
        ,to_number(NULL) diff_revenue
        FROM pa_fp_rollup_tmp tmp
    WHERE tmp.budget_version_id = p_budget_version_id
    AND  nvl(quantity,0) <> 0
    GROUP BY resource_assignment_id
                ,txn_currency_code ;
Line: 2642

            pa_debug.init_err_stack('PA_FP_CALC_PLAN_PKG.Update_rounding_diff');
Line: 2645

    g_stage := 'Update_rounding_diff:100';
Line: 2646

        pa_debug.g_err_stage := 'Entered Update_rounding_diff API';
Line: 2651

        l_resource_assignment_tab.delete;
Line: 2652

            l_txn_currency_code_tab.delete;
Line: 2653

            l_start_date_tab.delete;
Line: 2654

            l_quantity_tab.delete;
Line: 2655

            l_init_quantity_tab.delete;
Line: 2656

            l_txn_raw_cost_tab.delete;
Line: 2657

            l_txn_init_raw_cost_tab.delete;
Line: 2658

            l_txn_burdened_cost_tab.delete;
Line: 2659

            l_txn_init_burdened_cost_tab.delete;
Line: 2660

            l_txn_revenue_tab.delete;
Line: 2661

            l_txn_init_revenue_tab.delete;
Line: 2662

            l_unrounded_txn_raw_cost_tab.delete;
Line: 2663

            l_unround_txn_burden_cost_tab.delete;
Line: 2664

            l_unrounded_txn_revenue_tab.delete;
Line: 2665

            l_rounded_txn_raw_cost_tab.delete;
Line: 2666

            l_rounded_txn_burden_cost_tab.delete;
Line: 2667

            l_rounded_txn_revenue_tab.delete ;
Line: 2668

        l_diff_raw_cost_tab.delete;
Line: 2669

            l_diff_burden_cost_tab.delete;
Line: 2670

            l_diff_revenue_tab.delete;
Line: 2695

        g_stage := 'Update_rounding_diff:101';
Line: 2716

            g_stage := 'Update_rounding_diff:102';
Line: 2719

            UPDATE /*+ INDEX(TMP PA_FP_ROLLUP_TMP_N1) */ pa_fp_rollup_tmp tmp
                        SET tmp.txn_raw_cost = decode(p_budget_version_type,'COST'
                                                                ,DECODE((nvl(tmp.txn_raw_cost,0)+NVL(l_diff_raw_cost_tab(i),0)),0,NULL
                                                                        ,(nvl(tmp.txn_raw_cost,0)+NVL(l_diff_raw_cost_tab(i),0)))
                                                        ,'ALL',DECODE((nvl(tmp.txn_raw_cost,0)+NVL(l_diff_raw_cost_tab(i),0)),0,NULL
                                                                        ,(nvl(tmp.txn_raw_cost,0)+NVL(l_diff_raw_cost_tab(i),0)))
                                                        ,'REVENUE',tmp.txn_raw_cost)
                        ,tmp.txn_burdened_cost = decode(p_budget_version_type,'COST'
                                                                ,DECODE((nvl(tmp.txn_burdened_cost,0)+NVL(l_diff_burden_cost_tab(i),0)),0,NULL
                                                                        ,(nvl(tmp.txn_burdened_cost,0)+NVL(l_diff_burden_cost_tab(i),0)))
                                                        ,'ALL',DECODE((nvl(tmp.txn_burdened_cost,0)+NVL(l_diff_burden_cost_tab(i),0)),0,NULL
                                                                        ,(nvl(tmp.txn_burdened_cost,0)+NVL(l_diff_burden_cost_tab(i),0)))
                                                        ,'REVENUE',tmp.txn_burdened_cost)
                        ,tmp.txn_revenue = decode(p_budget_version_type,'COST',tmp.txn_revenue
                                                        ,'ALL',DECODE(l_null_revenue_amts_flag,'Y',tmp.txn_revenue
                                                                        ,DECODE((nvl(tmp.txn_revenue,0)+NVL(l_diff_revenue_tab(i),0)),0,NULL
                                                                          ,(nvl(tmp.txn_revenue,0)+NVL(l_diff_revenue_tab(i),0))))
                                                        ,'REVENUE',DECODE((nvl(tmp.txn_revenue,0)+NVL(l_diff_revenue_tab(i),0)),0,NULL
                                                                        ,(nvl(tmp.txn_revenue,0)+NVL(l_diff_revenue_tab(i),0))))
                        ,tmp.attribute15 = 'RoundingDiscrepancyLine'
                        WHERE tmp.resource_assignment_id = l_resource_assignment_tab(i)
                        AND   tmp.txn_currency_code = l_txn_currency_code_tab(i)
                        AND   tmp.start_date = l_start_date_tab(i)
                        AND   (NVL(l_diff_raw_cost_tab(i),0) <> 0 OR NVL(l_diff_burden_cost_tab(i),0) <> 0 OR NVL(l_diff_revenue_tab(i),0) <> 0)
            ;
Line: 2746

                        AND   tmp.rowid in (select max(rowid)
                                            from pa_fp_rollup_tmp tmp2
                                            where tmp2.resource_assignment_id = tmp.resource_assignment_id
                                            and tmp2.txn_currency_code = tmp.txn_currency_code
                                            and tmp2.start_date = tmp.start_date
                                           );
Line: 2753

            g_stage := 'Update_rounding_diff:103';
Line: 2761

    g_stage := 'Update_rounding_diff:104';
Line: 2764

    	print_msg('End of Update_rounding_diff API return Sts['||x_return_status||']');
Line: 2770

                print_msg('Failed in Update_rounding_diff API ['||sqlcode||sqlerrm);
Line: 2775

                 ,p_procedure_name => 'Update_rounding_diff' );
Line: 2776

                print_msg('Failed in Update_rounding_diff substr(SQLERRM,1,240) => '|| substr(SQLERRM,1,240));
Line: 2781

END Update_rounding_diff;
Line: 2811

                          ,p_delete_budget_lines_tab       IN  SYSTEM.pa_varchar2_1_tbl_type     DEFAULT SYSTEM.pa_varchar2_1_tbl_type()
                          ,p_spread_amts_flag_tab          IN  SYSTEM.pa_varchar2_1_tbl_type     DEFAULT SYSTEM.pa_varchar2_1_tbl_type()
                          ,p_txn_currency_code_tab         IN  SYSTEM.pa_varchar2_15_tbl_type    DEFAULT SYSTEM.pa_varchar2_15_tbl_type()
                          ,p_txn_currency_override_tab     IN  SYSTEM.pa_varchar2_15_tbl_type    DEFAULT SYSTEM.pa_varchar2_15_tbl_type()
                          ,p_total_qty_tab                 IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                          ,p_addl_qty_tab                  IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                          ,p_total_raw_cost_tab            IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                          ,p_addl_raw_cost_tab             IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                          ,p_total_burdened_cost_tab       IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                          ,p_addl_burdened_cost_tab        IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                          ,p_total_revenue_tab             IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                          ,p_addl_revenue_tab              IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                          ,p_raw_cost_rate_tab             IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                          ,p_rw_cost_rate_override_tab     IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                          ,p_b_cost_rate_tab               IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                          ,p_b_cost_rate_override_tab      IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                          ,p_bill_rate_tab                 IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                          ,p_bill_rate_override_tab        IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                          ,p_line_start_date_tab           IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
                          ,p_line_end_date_tab             IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
              /* for enhancement */
              ,p_spread_curve_id_old_tab       IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
              ,p_spread_curve_id_new_tab       IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
              ,p_sp_fixed_date_old_tab         IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
              ,p_sp_fixed_date_new_tab         IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
              ,p_plan_start_date_old_tab       IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
              ,p_plan_start_date_new_tab       IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
              ,p_plan_end_date_old_tab         IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
              ,p_plan_end_date_new_tab         IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
              ,p_re_spread_flag_tab            IN  SYSTEM.pa_varchar2_1_tbl_type     DEFAULT SYSTEM.pa_varchar2_1_tbl_type()
              ,p_sp_curve_change_flag_tab      IN  SYSTEM.pa_varchar2_1_tbl_type     DEFAULT SYSTEM.pa_varchar2_1_tbl_type()
              ,p_plan_dates_change_flag_tab    IN  SYSTEM.pa_varchar2_1_tbl_type     DEFAULT SYSTEM.pa_varchar2_1_tbl_type()
              ,p_spfix_date_flag_tab           IN  SYSTEM.pa_varchar2_1_tbl_type     DEFAULT SYSTEM.pa_varchar2_1_tbl_type()
              ,p_mfc_cost_change_flag_tab      IN  SYSTEM.pa_varchar2_1_tbl_type     DEFAULT SYSTEM.pa_varchar2_1_tbl_type()
                          ,p_mfc_cost_type_id_old_tab      IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                          ,p_mfc_cost_type_id_new_tab      IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
              ,p_rlm_id_change_flag_tab        IN  SYSTEM.pa_varchar2_1_tbl_type     DEFAULT SYSTEM.pa_varchar2_1_tbl_type()
          ,p_fp_task_billable_flag_tab     IN  SYSTEM.pa_varchar2_1_tbl_type     DEFAULT SYSTEM.pa_varchar2_1_tbl_type()
                          ,x_return_status                 OUT NOCOPY VARCHAR2
                          ,x_msg_count                     OUT NOCOPY NUMBER
                          ,x_msg_data                      OUT NOCOPY VARCHAR2) IS



    l_res_assignment_tab_count NUMBER := 0;
Line: 2865

    SELECT 'Y'
    FROM dual
    WHERE EXISTS (select null
            from pa_budget_lines bl
            Where bl.budget_version_id = p_budget_version_id
            AND   (nvl(bl.init_quantity,0) <> 0
                OR nvl(bl.txn_init_raw_cost,0) <> 0
                OR nvl(bl.txn_init_burdened_cost,0) <> 0
                OR nvl(bl.txn_init_revenue,0) <> 0
                  )
            );
Line: 3007

        IF l_return_status = 'S' AND p_delete_budget_lines_tab.COUNT > 0 THEN
            IF p_delete_budget_lines_tab.COUNT <> l_res_assignment_tab_count THEN
                        l_error_msg_code := 'PA_FP_CALC_DEL_CNT';
Line: 3332

    SELECT sp.spread_curve_id
    FROM pa_spread_curves_b sp
    WHERE sp.spread_curve_code = 'EVEN'
    AND  rownum = 1;
Line: 3353

                UPDATE PA_RESOURCE_ASSIGNMENTS ra
                SET     ra.spread_curve_id = DECODE(ra.spread_curve_id,6
                            ,decode(sign(nvl(ra.sp_fixed_date,p_etc_start_date) - p_etc_start_date),-1,l_evenSpCurveId,ra.spread_curve_id)
                             ,ra.spread_curve_id)
                        ,ra.sp_fixed_date = DECODE(sign(nvl(ra.sp_fixed_date,p_etc_start_date) - p_etc_start_date),-1,NULL,ra.sp_fixed_date)
            /*Bug fix:4122400--,ra.planning_end_date = DECODE(sign(ra.planning_end_date-p_etc_start_date),-1,p_etc_start_date,ra.planning_end_date) */
            ,ra.planning_end_date = DECODE(ra.spread_curve_id,6
                                                 ,decode(sign(nvl(ra.sp_fixed_date,p_etc_start_date) - p_etc_start_date),-1,p_etc_start_date,ra.planning_end_date)
                                                  ,decode(sign(ra.planning_end_date-p_etc_start_date),-1,p_etc_start_date,ra.planning_end_date))
                WHERE ra.budget_version_id = p_budget_version_id
        AND  EXISTS (SELECT null
                 FROM pa_fp_spread_calc_tmp tmp
                 WHERE tmp.budget_version_id = ra.budget_version_id
                 AND   tmp.resource_assignment_id = ra.resource_assignment_id);
Line: 3370

           /* For Non-Time phase budgets, Update the budget lines with planning start and planning end dates */
           g_stage :='Reset_Planning_end_date:101';
Line: 3374

           UPDATE pa_budget_lines bl
           SET ( bl.start_date, bl.end_date ) = (select ra.planning_start_date, ra.planning_end_date
                   From pa_resource_assignments ra
                   Where ra.resource_assignment_id = bl.resource_assignment_id)
           WHERE bl.budget_version_id = p_budget_version_id
           AND EXISTS ( SELECT 'Y'
                 FROM pa_resource_assignments pra
                ,pa_fp_spread_calc_tmp tmp
                 WHERE pra.resource_assignment_id = bl.resource_assignment_id
                 AND   pra.budget_version_id = bl.budget_version_id
                 AND   tmp.budget_version_id = pra.budget_version_id
                 AND   tmp.resource_assignment_id = pra.resource_assignment_id
              );
Line: 3405

/* This api bulk updates the resource assignments table for the fixed date spread curve which are having
 * more than one budget line
 */
PROCEDURE PreProcess_BlkProgress_lines
    (p_budget_version_id      IN Number
    ,p_etc_start_date         IN Date
    ,p_apply_progress_flag    IN Varchar2
    ,x_return_status          OUT NOCOPY Varchar2
        ,x_msg_data               OUT NOCOPY Varchar2
        ) IS

        CURSOR cur_spbl_chk IS
        SELECT tmp.resource_assignment_id
        FROM pa_fp_spread_calc_tmp tmp
             ,pa_resource_assignments ra
        WHERE tmp.budget_version_id = p_budget_version_id
        AND  tmp.resource_assignment_id = ra.resource_assignment_id
    AND  NVL(tmp.sp_curve_change_flag,'N') = 'N'
        /* Bug fix: AND  ra.sp_fixed_date is NOT NULL this is commented as in some ofthe flows,
     * the sp fixed date is null but spread curve is 6 */
        AND  ra.spread_curve_id = 6
        AND  EXISTS ( select null
                        from pa_budget_lines bl
                        where bl.budget_version_id = p_budget_version_id
                        and   bl.resource_assignment_id = ra.resource_assignment_id
                        and   bl.txn_currency_code = tmp.txn_currency_code
                        group by bl.resource_assignment_id
                                ,bl.txn_currency_code
                        having count(*) > 1
                        );
Line: 3442

        SELECT sp.spread_curve_id
        FROM pa_spread_curves_b sp
        WHERE sp.spread_curve_code = 'EVEN'
        AND  rownum = 1;
Line: 3453

        SELECT /*+ NO_UNNEST INDEX (BL,PA_BUDGET_LINES_U1) */ bl.budget_line_id -- bug 4873834
              ,bl.resource_assignment_id
              ,bl.txn_currency_code
              ,bl.start_date
              ,bl.end_date
              ,bl.period_name
              ,bl.quantity
              ,bl.txn_raw_cost
              ,bl.txn_burdened_cost
              ,bl.txn_revenue
              ,bl.project_raw_cost
              ,bl.project_burdened_cost
              ,bl.project_revenue
              ,bl.raw_cost      projfunc_raw_cost
              ,bl.burdened_cost projfunc_burdened_cost
              ,bl.revenue       projfunc_revenue
              ,bl.project_currency_code
              ,bl.projfunc_currency_code
              ,bl.cost_rejection_code
              ,bl.revenue_rejection_code
              ,bl.burden_rejection_code
              ,bl.pfc_cur_conv_rejection_code
              ,bl.pc_cur_conv_rejection_code
              ,bl.init_quantity
              ,bl.txn_init_raw_cost
              ,bl.txn_init_burdened_cost
              ,bl.txn_init_revenue
              ,bl.project_init_raw_cost
              ,bl.project_init_burdened_cost
              ,bl.project_init_revenue
              ,bl.init_raw_cost
              ,bl.init_burdened_cost
              ,bl.init_revenue
        FROM pa_budget_lines bl
         ,pa_fp_spread_calc_tmp tmp
        WHERE tmp.budget_version_id = p_budget_version_id
    AND   bl.budget_version_id = tmp.budget_version_id
    AND   bl.resource_assignment_id = tmp.resource_assignment_id
        AND   bl.txn_currency_code      = tmp.txn_currency_code
        AND g_spread_from_date is NOT NULL
        AND ((bl.start_date >= g_spread_from_date )
             OR (g_spread_from_date BETWEEN bl.start_date AND bl.end_date)
            )
    AND (NVL(bl.quantity,0) - NVL(bl.init_quantity,0)) < 0  --corrupted data
        AND ( NVL(bl.init_quantity,0) <> 0 OR
                 NVL(bl.txn_init_raw_cost ,0) <> 0 OR
                 NVL(bl.txn_init_burdened_cost ,0) <> 0 OR
                 NVL(bl.txn_init_revenue ,0) <> 0
           );
Line: 3517

                l_raId_tab.delete;
Line: 3531

                        /* update the RA and set sp_fixed_date to null so that spread api will spread the amts evenly */
                        UPDATE PA_RESOURCE_ASSIGNMENTS ra
                        SET    ra.spread_curve_id = l_evenSpCurveId
                                ,ra.sp_fixed_date = NULL
                                /* bug fix:4122400 for fixed date spread curve, change the plan end date as ETC start date */
                                /* Bug fix: 4247427 ,ra.planning_end_date = p_etc_start_date
                 * ETc start date can be before plannig end date, then donot change the end date */
                ,ra.planning_end_date = decode(sign(ra.planning_end_date-p_etc_start_date),-1,p_etc_start_date,ra.planning_end_date)
                        WHERE ra.resource_assignment_id = l_raId_tab(i);
Line: 3596

    l_num_rowsdeleted Number;
Line: 3603

    SELECT 'Y'
    FROM DUAL
    WHERE EXISTS (select null
            from pa_budget_lines bl
                 ,pa_resource_assignments ra
            where ra.resource_assignment_id = p_res_ass_id
            and   bl.resource_assignment_id = ra.resource_assignment_id
            and   bl.txn_currency_code = p_txn_currency_code
            and   ra.sp_fixed_date is NOT NULL
            and   ra.spread_curve_id  = 6
            group by bl.resource_assignment_id
                                ,bl.txn_currency_code
                        having count(*) > 1
            );
Line: 3619

        SELECT sp.spread_curve_id
        FROM pa_spread_curves_b sp
        WHERE sp.spread_curve_code = 'EVEN'
        AND  rownum = 1;
Line: 3652

            /* update the RA and set sp_fixed_date to null so that spread api will spread the amts evenly */
            UPDATE PA_RESOURCE_ASSIGNMENTS ra
            SET    ra.spread_curve_id = l_evenSpCurveId
                ,ra.sp_fixed_date = NULL
                /* bug fix:4122400 for fixed date spread curve, change the plan end date as ETC start date */
                                ,ra.planning_end_date = p_etc_start_date
            WHERE ra.resource_assignment_id = p_res_ass_id;
Line: 3661

                /* call delete budget lines to delete all the lines so that spread will respred the ETC qty */
                /* Bug fix: 4142150 When progress is applied, the quantity should be spread based on
                 * exisitng line distribution method, so donot delete the budget lines
                delete_budget_lines
                ( p_budget_version_id         => p_budget_version_id
                ,p_resource_assignment_id    => p_res_ass_id
                ,p_txn_currency_code          => p_txn_currency_code
                ,p_line_start_date            => p_line_start_date
                ,p_line_end_date              => p_line_end_date
                ,p_source_context             => p_source_context
                ,x_return_status              => l_return_status
                ,x_msg_count                  => l_msg_count
                ,x_msg_data                   => l_msg_data
                ,x_num_rowsdeleted            => l_num_rowsdeleted
                );
Line: 3678

                        print_msg('Unexpected error from delete_budget_lines');
Line: 3788

    SELECT /*+ INDEX(BL PA_BUDGET_LINES_U1) */
           bl.budget_line_id
          ,bl.resource_assignment_id
          ,bl.txn_currency_code
          ,bl.start_date
          ,bl.end_date
          ,bl.period_name
          ,bl.quantity
          ,bl.txn_raw_cost
          ,bl.txn_burdened_cost
          ,bl.txn_revenue
          ,bl.project_raw_cost
          ,bl.project_burdened_cost
          ,bl.project_revenue
          ,bl.raw_cost  projfunc_raw_cost
          ,bl.burdened_cost projfunc_burdened_cost
          ,bl.revenue   projfunc_revenue
          ,bl.project_currency_code
          ,bl.projfunc_currency_code
          ,bl.cost_rejection_code
              ,bl.revenue_rejection_code
              ,bl.burden_rejection_code
              ,bl.pfc_cur_conv_rejection_code
              ,bl.pc_cur_conv_rejection_code
    FROM pa_budget_lines bl
        ,pa_fp_spread_calc_tmp tmp
    WHERE tmp.budget_version_id = p_budget_version_id
    AND  bl.resource_assignment_id = tmp.resource_assignment_id
    AND  bl.txn_currency_code = tmp.txn_currency_code
    AND  bl.start_date < p_etc_start_date
    AND  bl.end_date < p_etc_start_date
    AND  ( (NVL(bl.quantity,0) - NVl(bl.init_quantity,0)) <> 0
         OR (Nvl(bl.txn_raw_cost,0) - Nvl(bl.txn_init_raw_cost,0)) <> 0
         OR (Nvl(bl.txn_burdened_cost,0) - nvl(bl.txn_init_burdened_cost,0)) <> 0
         OR (Nvl(bl.txn_revenue,0) - nvl(bl.txn_init_revenue,0)) <> 0
         )
    AND  (  NVL(bl.init_quantity,0) = 0
                and NVL(bl.txn_init_raw_cost ,0) = 0
                and NVL(bl.txn_init_burdened_cost ,0) = 0
                and NVL(bl.txn_init_revenue ,0) = 0
             );
Line: 3834

        SELECT /*+ INDEX(BL PA_BUDGET_LINES_U1) */
        bl.budget_line_id
              ,bl.resource_assignment_id
              ,bl.txn_currency_code
              ,bl.start_date
          --,rl.alias resource_name
          ,bl.end_date
              ,bl.period_name
              ,bl.quantity
              ,bl.txn_raw_cost
              ,bl.txn_burdened_cost
              ,bl.txn_revenue
              ,bl.project_raw_cost
              ,bl.project_burdened_cost
              ,bl.project_revenue
              ,bl.raw_cost      projfunc_raw_cost
              ,bl.burdened_cost projfunc_burdened_cost
              ,bl.revenue       projfunc_revenue
              ,bl.project_currency_code
              ,bl.projfunc_currency_code
              ,bl.cost_rejection_code
              ,bl.revenue_rejection_code
              ,bl.burden_rejection_code
              ,bl.pfc_cur_conv_rejection_code
              ,bl.pc_cur_conv_rejection_code
        FROM pa_budget_lines bl
        ,pa_fp_spread_calc_tmp tmp
        WHERE tmp.budget_version_id = p_budget_version_id
        AND  bl.resource_assignment_id = tmp.resource_assignment_id
        AND  bl.txn_currency_code = tmp.txn_currency_code
        AND  bl.start_date < p_etc_start_date
        AND  bl.end_date < p_etc_start_date
        AND  ( (NVL(bl.quantity,0) - NVl(bl.init_quantity,0)) <> 0
             OR (Nvl(bl.txn_raw_cost,0) - Nvl(bl.txn_init_raw_cost,0)) <> 0
             OR (Nvl(bl.txn_burdened_cost,0) - nvl(bl.txn_init_burdened_cost,0)) <> 0
             OR (Nvl(bl.txn_revenue,0) - nvl(bl.txn_init_revenue,0)) <> 0
             )
    AND  (bl.init_quantity is NOT NULL
        or bl.txn_init_raw_cost is NOT NULL
        or bl.txn_init_burdened_cost is NOT NULL
        or bl.txn_init_revenue is NOT NULL
         );
Line: 3882

        SELECT /*+ INDEX(BL PA_BUDGET_LINES_U1) */
        bl.budget_line_id
              ,bl.resource_assignment_id
              ,bl.txn_currency_code
              ,bl.start_date
              ,null  resource_name  --rl.alias resource_name
              ,bl.end_date
              ,bl.period_name
              ,bl.quantity
              ,bl.txn_raw_cost
              ,bl.txn_burdened_cost
              ,bl.txn_revenue
              ,bl.project_raw_cost
              ,bl.project_burdened_cost
              ,bl.project_revenue
              ,bl.raw_cost      projfunc_raw_cost
              ,bl.burdened_cost projfunc_burdened_cost
              ,bl.revenue       projfunc_revenue
              ,bl.project_currency_code
              ,bl.projfunc_currency_code
              ,bl.cost_rejection_code
              ,bl.revenue_rejection_code
              ,bl.burden_rejection_code
              ,bl.pfc_cur_conv_rejection_code
              ,bl.pc_cur_conv_rejection_code
        FROM pa_budget_lines bl
            ,pa_resource_assignments ra
        ,pa_fp_spread_calc_tmp tmp
        WHERE tmp.budget_version_id = p_budget_version_id
        AND  bl.resource_assignment_id = tmp.resource_assignment_id
        AND  bl.txn_currency_code = tmp.txn_currency_code
        AND  ra.resource_assignment_id = tmp.resource_assignment_id
    AND  NVL(ra.rate_based_flag,'N') = 'N'
        AND  bl.start_date < p_etc_start_date
        AND  bl.end_date < p_etc_start_date
        AND  (bl.init_quantity is NOT NULL
                or bl.txn_init_raw_cost is NOT NULL
                or bl.txn_init_burdened_cost is NOT NULL
                or bl.txn_init_revenue is NOT NULL
             )
    AND (  (g_fp_budget_version_type = 'REVENUE'
        and ( nvl(bl.txn_init_raw_cost,0) <> 0
            OR (decode(round(bl.init_quantity,2)
                   ,decode(decode(nvl(g_wp_version_flag,'N'),'Y',NVL(G_TRACK_WP_COSTS_FLAG,'N'),'Y'),'N'
               ,decode(nvl(bl.txn_init_revenue,0),0,round(bl.init_quantity,2),round(bl.txn_init_revenue,2))
                 ,round(bl.txn_init_revenue,2)),'Y','N') <> 'Y'
                    ))
        )OR
         ( g_fp_budget_version_type ='COST'
           and ( nvl(bl.txn_init_revenue,0) <> 0
            OR (decode(round(bl.init_quantity,2)
                ,decode(decode(nvl(g_wp_version_flag,'N'),'Y',NVL(G_TRACK_WP_COSTS_FLAG,'N'),'Y'),'N'
                ,decode(nvl(bl.txn_init_raw_cost,0),0,round(bl.init_quantity,2),round(bl.txn_init_raw_cost,2))
                  ,round(bl.txn_init_raw_cost,2)),'Y','N') <> 'Y' ))
        ) OR
            ( g_fp_budget_version_type  = 'ALL'
           and (decode(round(bl.init_quantity,2)
            ,decode(decode(nvl(g_wp_version_flag,'N'),'Y',NVL(G_TRACK_WP_COSTS_FLAG,'N'),'Y'),'N'
            ,decode(nvl(bl.txn_init_raw_cost,0),0,round(bl.init_quantity,2),round(bl.txn_init_raw_cost,2))
              ,round(bl.txn_init_raw_cost,2)),'Y','N') <> 'Y' )
        )
          );
Line: 3997

        l_corrupted_bl_update_rows Number := 0;
Line: 4004

        l_budget_Line_id_tab.delete;
Line: 4005

        l_resource_assignment_id_tab.delete;
Line: 4006

        l_txn_currency_code_tab.delete;
Line: 4007

        l_start_date_tab.delete;
Line: 4008

        l_end_date_tab.delete;
Line: 4009

            l_period_name_tab.delete;
Line: 4010

            l_quantity_tab.delete;
Line: 4011

            l_txn_raw_cost_tab.delete;
Line: 4012

            l_txn_burdened_cost_tab.delete;
Line: 4013

            l_txn_revenue_tab.delete;
Line: 4014

            l_project_raw_cost_tab.delete;
Line: 4015

            l_project_burdened_cost_tab.delete;
Line: 4016

            l_project_revenue_tab.delete;
Line: 4017

            l_projfunc_raw_cost_tab.delete;
Line: 4018

            l_projfunc_burdened_cost_tab.delete;
Line: 4019

            l_projfunc_revenue_tab.delete;
Line: 4020

            l_project_curr_code_tab.delete;
Line: 4021

            l_projfunc_curr_code_tab.delete;
Line: 4022

        l_cost_rejection_code_tab.delete;
Line: 4023

            l_revenue_rejection_code_tab.delete;
Line: 4024

            l_burden_rejection_code_tab.delete;
Line: 4025

            l_pfc_cur_conv_rej_code_tab.delete;
Line: 4026

            l_pc_cur_conv_rej_code_tab.delete;
Line: 4033

        l_upd_budget_Line_id_tab.delete;
Line: 4034

            l_upd_ra_id_tab.delete;
Line: 4035

            l_upd_txn_curr_code_tab.delete;
Line: 4036

            l_upd_start_date_tab.delete;
Line: 4037

            l_upd_end_date_tab.delete;
Line: 4038

            l_upd_period_name_tab.delete;
Line: 4039

            l_upd_quantity_tab.delete;
Line: 4040

            l_upd_txn_raw_cost_tab.delete;
Line: 4041

            l_upd_txn_burden_cost_tab.delete;
Line: 4042

            l_upd_txn_revenue_tab.delete;
Line: 4043

            l_upd_project_raw_cost_tab.delete;
Line: 4044

            l_upd_project_burden_cost_tab.delete;
Line: 4045

            l_upd_project_revenue_tab.delete;
Line: 4046

            l_upd_projfunc_raw_cost_tab.delete;
Line: 4047

            l_upd_projfunc_burden_cost_tab.delete;
Line: 4048

            l_upd_projfunc_revenue_tab.delete;
Line: 4049

            l_upd_project_curr_code_tab.delete;
Line: 4050

            l_upd_projfunc_curr_code_tab.delete;
Line: 4051

            l_upd_cost_rejection_tab.delete;
Line: 4052

            l_upd_revenue_rejection_tab.delete;
Line: 4053

            l_upd_burden_rejection_tab.delete;
Line: 4054

            l_upd_pfc_cur_conv_rej_tab.delete;
Line: 4055

            l_upd_pc_cur_conv_rej_tab.delete;
Line: 4109

                    /* update the reporting lines before deleteing the budget lines */
                     Add_Toreporting_Tabls
                                (p_calling_module               => 'CALCULATE_API'
                                ,p_activity_code                => 'UPDATE'
                                ,p_budget_version_id            => p_budget_version_id
                                ,p_budget_line_id               => l_budget_Line_id_tab(i)
                                ,p_resource_assignment_id       => l_resource_assignment_id_tab(i)
                                ,p_start_date                   => l_start_date_tab(i)
                                ,p_end_date                     => l_end_date_tab(i)
                                ,p_period_name                  => l_period_name_tab(i)
                                ,p_txn_currency_code            => l_txn_currency_code_tab(i)
                                ,p_quantity                     => l_quantity_tab(i) * -1
                                ,p_txn_raw_cost                 => l_txn_raw_cost_tab(i) * -1
                                ,p_txn_burdened_cost            => l_txn_burdened_cost_tab(i) * -1
                                ,p_txn_revenue                  => l_txn_revenue_tab(i) * -1
                                ,p_project_currency_code        => l_project_curr_code_tab(i)
                                ,p_project_raw_cost             => l_project_raw_cost_tab(i) * -1
                                ,p_project_burdened_cost        => l_project_burdened_cost_tab(i) * -1
                                ,p_project_revenue              => l_project_revenue_tab(i) * -1
                                ,p_projfunc_currency_code       => l_projfunc_curr_code_tab(i)
                                ,p_projfunc_raw_cost            => l_projfunc_raw_cost_tab(i) * -1
                                ,p_projfunc_burdened_cost       => l_projfunc_burdened_cost_tab(i) * -1
                                ,p_projfunc_revenue             => l_projfunc_revenue_tab(i) * -1
				,p_rep_line_mode               => 'REVERSAL'
                                ,x_msg_data                     => l_msg_data
                                ,x_return_status                => l_return_status
                                );
Line: 4162

                ,p_delete_flag                  => 'Y'
                                ,x_msg_data                     => l_msg_data
                                ,x_return_status                => l_return_status
                                );
Line: 4172

         * so delete all the budget lines instead of updating it to null
         **/
        DELETE FROM pa_budget_lines bl
        WHERE bl.budget_line_id  = l_budget_Line_id_tab(i);
Line: 4265

                                ,p_activity_code                => 'UPDATE'
                                ,p_budget_version_id            => p_budget_version_id
                                ,p_budget_line_id               => l_budget_Line_id_tab(i)
                                ,p_resource_assignment_id       => l_resource_assignment_id_tab(i)
                                ,p_start_date                   => l_start_date_tab(i)
                                ,p_end_date                     => l_end_date_tab(i)
                                ,p_period_name                  => l_period_name_tab(i)
                                ,p_txn_currency_code            => l_txn_currency_code_tab(i)
                                ,p_quantity                     => l_quantity_tab(i) * -1
                                ,p_txn_raw_cost                 => l_txn_raw_cost_tab(i) * -1
                                ,p_txn_burdened_cost            => l_txn_burdened_cost_tab(i) * -1
                                ,p_txn_revenue                  => l_txn_revenue_tab(i) * -1
                                ,p_project_currency_code        => l_project_curr_code_tab(i)
                                ,p_project_raw_cost             => l_project_raw_cost_tab(i) * -1
                                ,p_project_burdened_cost        => l_project_burdened_cost_tab(i) * -1
                                ,p_project_revenue              => l_project_revenue_tab(i) * -1
                                ,p_projfunc_currency_code       => l_projfunc_curr_code_tab(i)
                                ,p_projfunc_raw_cost            => l_projfunc_raw_cost_tab(i) * -1
                                ,p_projfunc_burdened_cost       => l_projfunc_burdened_cost_tab(i) * -1
                                ,p_projfunc_revenue             => l_projfunc_revenue_tab(i) * -1
				,p_rep_line_mode               => 'REVERSAL'
                                ,x_msg_data                     => l_msg_data
                                ,x_return_status                => l_return_status
                                );
Line: 4298

         l_corrupted_bl_update_rows := 0;
Line: 4300

         UPDATE pa_budget_lines bl
         SET bl.quantity = bl.init_quantity
	   -- Bug 15928585
 	   , bl.display_quantity = bl.init_quantity
 	   -- End bug 15928585
           ,bl.txn_raw_cost = bl.txn_init_raw_cost
           ,bl.txn_burdened_cost = bl.txn_init_burdened_cost
           ,bl.txn_revenue = bl.txn_init_revenue
           /* Bug fix: 4071198 As discussed with sanjay, for closed periods, instead of setting the Etc rates as null
            * derive the plan rates. so that the copy version functionality when copies the budget versions
            * proper rates will be copied*/
           ,bl.txn_standard_cost_rate = DECODE(nvl(bl.init_quantity,0),0,NULL,(bl.txn_init_raw_cost/bl.init_quantity))
           ,bl.txn_cost_rate_override = DECODE(nvl(bl.init_quantity,0),0,NULL,(bl.txn_init_raw_cost/bl.init_quantity))
           ,bl.burden_cost_rate = DECODE(nvl(bl.init_quantity,0),0,NULL,(bl.txn_init_burdened_cost/bl.init_quantity))
           ,bl.burden_cost_rate_override = DECODE(nvl(bl.init_quantity,0),0,NULL,(bl.txn_init_burdened_cost/bl.init_quantity))
           ,bl.txn_standard_bill_rate = DECODE(nvl(bl.init_quantity,0),0,NULL,(bl.txn_init_revenue/bl.init_quantity))
           ,bl.txn_bill_rate_override = DECODE(nvl(bl.init_quantity,0),0,NULL,(bl.txn_init_revenue/bl.init_quantity))
           ,bl.raw_cost = bl.init_raw_cost
           ,bl.burdened_cost = bl.init_burdened_cost
           ,bl.revenue = bl.init_revenue
           ,bl.project_raw_cost = bl.project_init_raw_cost
           ,bl.project_burdened_cost = bl.project_init_burdened_cost
           ,bl.project_revenue = bl.project_init_revenue
                   ,bl.projfunc_cost_rate_type         = null
                   ,bl.projfunc_cost_exchange_rate     = null
                   ,bl.projfunc_cost_rate_date_type    = null
                   ,bl.projfunc_cost_rate_date         = null
                   ,bl.projfunc_rev_rate_type          = null
                   ,bl.projfunc_rev_exchange_rate      = null
                   ,bl.projfunc_rev_rate_date_type     = null
                   ,bl.projfunc_rev_rate_date          = null
                   ,bl.project_cost_rate_type          = null
                   ,bl.project_cost_exchange_rate      = null
                   ,bl.project_cost_rate_date_type     = null
                   ,bl.project_cost_rate_date          = null
                   ,bl.project_rev_rate_type           = null
                   ,bl.project_rev_exchange_rate       = null
                   ,bl.project_rev_rate_date_type      = null
                   ,bl.project_rev_rate_date           = null
           ,bl.pfc_cur_conv_rejection_code     = null
                   ,bl.pc_cur_conv_rejection_code      = null
           ,bl.cost_rejection_code             = null
           ,bl.burden_rejection_code           = null
           ,bl.revenue_rejection_code          = null
                   ,bl.last_update_date                = sysdate
                   ,bl.last_updated_by                 = fnd_global.user_id
                   ,bl.last_update_login               = fnd_global.login_id
           /* Bug fix:4257059 storing this value just for tracking purpose is causing
            * issues in the generation flow
            *,bl.other_rejection_code            = 'PA_BLAMT_EXISTS_PRIOR_ETC'
            */
             WHERE bl.budget_line_id = l_budget_Line_id_tab(i)
         /*Bug fix:4257059 Added this returning clause to avoid one-select and one-update*/
         RETURNING
            bl.budget_line_id
                        ,bl.resource_assignment_id
                        ,bl.txn_currency_code
                        ,bl.start_date
                        --,rl.alias resource_name
                        ,bl.end_date
                        ,bl.period_name
                        ,bl.quantity
                        ,bl.txn_raw_cost
                        ,bl.txn_burdened_cost
                        ,bl.txn_revenue
                        ,bl.project_raw_cost
                        ,bl.project_burdened_cost
                        ,bl.project_revenue
                        ,bl.raw_cost      --projfunc_raw_cost
                        ,bl.burdened_cost --projfunc_burdened_cost
                        ,bl.revenue       --projfunc_revenue
                        ,bl.project_currency_code
                        ,bl.projfunc_currency_code
                        ,bl.cost_rejection_code
                        ,bl.revenue_rejection_code
                        ,bl.burden_rejection_code
                        ,bl.pfc_cur_conv_rejection_code
                        ,bl.pc_cur_conv_rejection_code
        BULK COLLECT INTO
                        l_upd_budget_Line_id_tab
                        ,l_upd_ra_id_tab
                        ,l_upd_txn_curr_code_tab
                        ,l_upd_start_date_tab
                        ,l_upd_end_date_tab
                        ,l_upd_period_name_tab
                        ,l_upd_quantity_tab
                        ,l_upd_txn_raw_cost_tab
                        ,l_upd_txn_burden_cost_tab
                        ,l_upd_txn_revenue_tab
                        ,l_upd_project_raw_cost_tab
                        ,l_upd_project_burden_cost_tab
                        ,l_upd_project_revenue_tab
                        ,l_upd_projfunc_raw_cost_tab
                        ,l_upd_projfunc_burden_cost_tab
                        ,l_upd_projfunc_revenue_tab
                        ,l_upd_project_curr_code_tab
                        ,l_upd_projfunc_curr_code_tab
                        ,l_upd_cost_rejection_tab
                        ,l_upd_revenue_rejection_tab
                        ,l_upd_burden_rejection_tab
                        ,l_upd_pfc_cur_conv_rej_tab
                        ,l_upd_pc_cur_conv_rej_tab ;
Line: 4404

         l_corrupted_bl_update_rows := l_upd_budget_Line_id_tab.COUNT;
Line: 4408

        /** Bug fix:4257059 adding returning clause in the above update
                 * no need to hit the db again , so commentingout the code
        IF (NVL(l_corrupted_bl_update_rows,0) > 0 AND l_upd_budget_Line_id_tab.COUNT > 0 ) Then --{
            BEGIN
                g_stage := 'clear_closed_period_etcs:106';
Line: 4413

                 SELECT bl.budget_line_id
                            ,bl.resource_assignment_id
                            ,bl.txn_currency_code
                            ,bl.start_date
                            --,rl.alias resource_name
                            ,bl.end_date
                            ,bl.period_name
                            ,bl.quantity
                            ,bl.txn_raw_cost
                            ,bl.txn_burdened_cost
                            ,bl.txn_revenue
                            ,bl.project_raw_cost
                            ,bl.project_burdened_cost
                            ,bl.project_revenue
                            ,bl.raw_cost      projfunc_raw_cost
                            ,bl.burdened_cost projfunc_burdened_cost
                            ,bl.revenue       projfunc_revenue
                            ,bl.project_currency_code
                            ,bl.projfunc_currency_code
                            ,bl.cost_rejection_code
                            ,bl.revenue_rejection_code
                            ,bl.burden_rejection_code
                            ,bl.pfc_cur_conv_rejection_code
                            ,bl.pc_cur_conv_rejection_code
                BULK COLLECT INTO
                            l_upd_budget_Line_id_tab
                            ,l_upd_ra_id_tab
                            ,l_upd_txn_curr_code_tab
                            ,l_upd_start_date_tab
                            ,l_upd_end_date_tab
                            ,l_upd_period_name_tab
                            ,l_upd_quantity_tab
                            ,l_upd_txn_raw_cost_tab
                            ,l_upd_txn_burden_cost_tab
                            ,l_upd_txn_revenue_tab
                            ,l_upd_project_raw_cost_tab
                            ,l_upd_project_burden_cost_tab
                            ,l_upd_project_revenue_tab
                            ,l_upd_projfunc_raw_cost_tab
                            ,l_upd_projfunc_burden_cost_tab
                            ,l_upd_projfunc_revenue_tab
                            ,l_upd_project_curr_code_tab
                            ,l_upd_projfunc_curr_code_tab
                            ,l_upd_cost_rejection_tab
                            ,l_upd_revenue_rejection_tab
                            ,l_upd_burden_rejection_tab
                            ,l_upd_pfc_cur_conv_rej_tab
                            ,l_upd_pc_cur_conv_rej_tab
                FROM pa_budget_lines bl
                    ,pa_fp_spread_calc_tmp tmp
                        WHERE bl.budget_version_id = p_budget_version_id
                AND  tmp.budget_version_id = bl.budget_version_id
                        AND  bl.resource_assignment_id = tmp.resource_assignment_id
                        AND  bl.txn_currency_code = tmp.txn_currency_code
                        AND  bl.start_date < p_etc_start_date
                        AND  bl.end_date < p_etc_start_date
                AND  bl.other_rejection_code = 'PA_BLAMT_EXISTS_PRIOR_ETC'
                AND  (bl.init_quantity is NOT NULL
                                or bl.txn_init_raw_cost is NOT NULL
                                or bl.txn_init_burdened_cost is NOT NULL
                                or bl.txn_init_revenue is NOT NULL
                                 );
Line: 4483

        IF (NVL(l_corrupted_bl_update_rows,0) > 0 AND l_upd_budget_Line_id_tab.COUNT > 0 ) Then --{
            --Now pass the corrected plan amounts to the PJI reporting apis
            IF l_upd_budget_Line_id_tab.COUNT > 0 THEN
                    FOR i IN l_upd_budget_Line_id_tab.FIRST .. l_upd_budget_Line_id_tab.LAST LOOP
                         IF NVL(g_rollup_required_flag,'N') = 'Y' Then  --{
				/* bug fix:5031388
                                IF (l_upd_cost_rejection_tab(i) is NULL AND
                                    l_upd_revenue_rejection_tab(i) is NULL AND
                                    l_upd_burden_rejection_tab(i) is NULL AND
                                    l_upd_pfc_cur_conv_rej_tab(i) is NULL AND
                                    l_upd_pc_cur_conv_rej_tab(i) is NULL )  THEN
				*/
                        	--print_msg('Passing +ve of blCorrupt:LnId['||l_upd_budget_Line_id_tab(i)||']Qty['||l_upd_quantity_tab(i)||']');
Line: 4500

                                        ,p_activity_code                => 'UPDATE'
                                        ,p_budget_version_id            => p_budget_version_id
                                        ,p_budget_line_id               => l_upd_budget_Line_id_tab(i)
                                        ,p_resource_assignment_id       => l_upd_ra_id_tab(i)
                                        ,p_start_date                   => l_upd_start_date_tab(i)
                                        ,p_end_date                     => l_upd_end_date_tab(i)
                                        ,p_period_name                  => l_upd_period_name_tab(i)
                                        ,p_txn_currency_code            => l_upd_txn_curr_code_tab(i)
                                        ,p_quantity                     => l_upd_quantity_tab(i)
                                        ,p_txn_raw_cost                 => l_upd_txn_raw_cost_tab(i)
                                        ,p_txn_burdened_cost            => l_upd_txn_burden_cost_tab(i)
                                        ,p_txn_revenue                  => l_upd_txn_revenue_tab(i)
                                        ,p_project_currency_code        => l_upd_project_curr_code_tab(i)
                                        ,p_project_raw_cost             => l_upd_project_raw_cost_tab(i)
                                        ,p_project_burdened_cost        => l_upd_project_burden_cost_tab(i)
                                        ,p_project_revenue              => l_upd_project_revenue_tab(i)
                                        ,p_projfunc_currency_code       => l_upd_projfunc_curr_code_tab(i)
                                        ,p_projfunc_raw_cost            => l_upd_projfunc_raw_cost_tab(i)
                                        ,p_projfunc_burdened_cost       => l_upd_projfunc_burden_cost_tab(i)
                                        ,p_projfunc_revenue             => l_upd_projfunc_revenue_tab(i)
					,p_rep_line_mode               => 'POSITIVE_ENTRY'
                                        ,x_msg_data                     => l_msg_data
                                        ,x_return_status                => l_return_status
                                        );
Line: 4550

                    			,p_delete_flag                  => 'N'
                                        ,x_msg_data                     => l_msg_data
                                        ,x_return_status                => l_return_status
                                        );
Line: 4583

/* This API updates the required flags in the spread calc tmp table to process in the bulk mode */
PROCEDURE Upd_spread_calc_tmp(
        p_budget_version_id     IN NUMBER
        ,p_source_context   IN VARCHAR2
        ,x_return_status        OUT NOCOPY VARCHAR2
                ) IS
BEGIN
    x_return_status := 'S';
Line: 4597

        print_msg('Number Of rowsUpdated['||g_plan_raId_tab.COUNT||']');
Line: 4600

            UPDATE /*+ INDEX(TMP PA_FP_SPREAD_CALC_TMP_N1) */ PA_FP_SPREAD_CALC_TMP tmp -- bug 4873834
            SET tmp.skip_record_flag    = NVL(g_skip_record_tab(i),'N')
		,tmp.processed_flag  = NVL(g_process_skip_CstRevrec_tab(i),'N')
               ,tmp.REFRESH_RATES_FLAG   = NVL(g_refresh_rates_tab(i),'N')
               ,tmp.REFRESH_CONV_RATES_FLAG  = NVL(g_refresh_conv_rates_tab(i),'N')
               ,tmp.MASS_ADJUST_FLAG    = NVL(g_mass_adjust_flag_tab(i),'N')
               ,tmp.G_WPRABL_CURRENCY_CODE = g_Wp_curCode_tab(i)
               ,tmp.RA_RATES_ONLY_CHANGE_FLAG = NVL(g_rtChanged_Ra_Flag_tab(i),'N')
               ,tmp.SYSTEM_REFERENCE_VAR2  = NVL(g_applyProg_refreshRts_tab(i),'N') /*Bug fix:4295967 */
            WHERE tmp.budget_version_id = p_budget_version_id
            AND   tmp.resource_assignment_id = g_plan_raId_tab(i)
            AND   tmp.txn_currency_code = g_plan_txnCur_Tab(i)
            AND   ((p_source_context = 'BUDGET_LINE'
                and tmp.start_date = g_line_Sdate_tab(i))
                OR
                p_source_context <> 'BUDGET_LINE'
                  );
Line: 4624

            UPDATE /*+ INDEX(TMP PA_FP_SPREAD_CALC_TMP_N1) */ PA_FP_SPREAD_CALC_TMP tmp
            SET tmp.mfc_cost_refresh_flag = 'Y'
               ,tmp.REFRESH_RATES_FLAG   = 'Y'
            WHERE tmp.budget_version_id = p_budget_version_id
                        AND   tmp.resource_assignment_id = g_mfc_cost_refrsh_Raid_tab(i)
                        AND   tmp.txn_currency_code = g_mfc_cost_refrsh_txnCur_tab(i) ;
Line: 4637

        UPDATE /*+ INDEX(TMP PA_FP_SPREAD_CALC_TMP_N1) */ PA_FP_SPREAD_CALC_TMP tmp
        SET tmp.cost_rate_override = decode(tmp.COST_RATE_G_MISS_NUM_FLAG,'Y',NULL
                            ,NVL(g_sprd_costRt_Ovr_tab(i),tmp.cost_rate_override))
           ,tmp.burden_cost_rate_override = decode(tmp.burden_rate_g_miss_num_flag,'Y',NULL
                            ,NVL(g_sprd_burdRt_Ovr_tab(i),tmp.burden_cost_rate_override))
           ,tmp.bill_rate_override = decode(tmp.bill_rate_g_miss_num_flag,'Y',NULL
                            ,NVL(g_sprd_billRt_Ovr_tab(i),tmp.bill_rate_override))
        WHERE tmp.resource_assignment_id = g_sprd_raId_tab(i)
        AND   tmp.txn_currency_code = g_sprd_txn_cur_tab(i)
        AND   NVL(g_sprd_qty_addl_tab(i),0) <> 0
	AND   ((g_source_context <> 'BUDGET_LINE')
                OR
                ((g_source_context = 'BUDGET_LINE')
                and tmp.start_date BETWEEN g_sprd_sDate_tab(i) AND g_sprd_eDate_tab(i)
                ))
        AND   (NVL(tmp.cost_rate_changed_flag,'N') = 'Y'
                          OR NVL(tmp.burden_rate_changed_flag,'N') = 'Y'
                          OR NVL(tmp.bill_rate_changed_flag,'N') = 'Y'
                          OR NVL(tmp.raw_cost_changed_flag,'N') = 'Y'
                          OR NVL(tmp.burden_cost_changed_flag,'N') = 'Y'
                          OR NVL(tmp.revenue_changed_flag,'N') = 'Y'
            );
Line: 4666

        	UPDATE /*+ INDEX(TMP PA_FP_SPREAD_CALC_TMP_N1) */ pa_fp_spread_calc_tmp tmp
        	SET tmp.cost_rate_override = decode(NVL(g_rtChanged_cstMisNumFlg_tab(i),'N'),'Y',NULL
                                        ,NVL(g_rtChanged_CostRt_Tab(i),tmp.cost_rate_override))
            	,tmp.burden_cost_rate_override = decode(NVL(g_rtChanged_bdMisNumFlag_tab(i),'N'),'Y',NULL
                                        ,NVL(g_rtChanged_BurdRt_tab(i),tmp.burden_cost_rate_override))
            	,tmp.bill_rate_override  = decode(NVL(g_rtChanged_blMisNumFlag_tab(i),'N'),'Y',NULL
                                        ,NVL(g_rtChanged_billRt_tab(i),tmp.bill_rate_override))
        	WHERE tmp.resource_assignment_id = g_rtChanged_RaId_tab(i)
        	AND   tmp.txn_currency_code = g_rtChanged_TxnCur_tab(i)
        	AND   ((g_source_context <> 'BUDGET_LINE')
              	OR
            	((g_source_context = 'BUDGET_LINE')
             	and tmp.start_date BETWEEN g_rtChanged_sDate_tab(i) AND g_rtChanged_eDate_tab(i)
            	));
Line: 4681

        	print_msg('Number of rows updated for RateChanges['||sql%rowcount||']');
Line: 4697

 * as we delete all the budget lines before the spread call. The purpose of thei API  is to retain the override rates and
 * currency conversion attributes of the periodic line level on the budget lines. updates the rollup tmp table with the override rates
 */
PROCEDURE Update_rollupTmp_OvrRates
          ( p_budget_version_id         IN  pa_budget_lines.budget_version_id%type
           ,p_calling_module            IN  varchar2
       ,p_generation_context        IN  varchar2  default 'SPREAD'
           ,x_return_status             OUT NOCOPY VARCHAR2
           ,x_msg_count                 OUT NOCOPY NUMBER
           ,x_msg_data                  OUT NOCOPY VARCHAR2
           ) IS

    CURSOR periodDetails IS
    SELECT gsb.period_set_name      period_set_name
                ,gsb.accounted_period_type  accounted_period_type
                ,pia.pa_period_type         pa_period_type
        ,pbv.version_type       version_type
                ,decode(pbv.version_type,
                        'COST',ppfo.cost_time_phased_code,
                        'REVENUE',ppfo.revenue_time_phased_code,
                         ppfo.all_time_phased_code) time_phase_code
         FROM gl_sets_of_books          gsb
                ,pa_implementations_all pia
                ,pa_projects_all        ppa
                ,pa_budget_versions     pbv
                ,pa_proj_fp_options     ppfo
        WHERE ppa.project_id        = pbv.project_id
        AND pbv.budget_version_id = ppfo.fin_plan_version_id
        /* MOAC Changes: AND nvl(ppa.org_id,-99)   = nvl(pia.org_id,-99) */
        AND ppa.org_id   = pia.org_id
        AND gsb.set_of_books_id   = pia.set_of_books_id
        AND pbv.budget_version_id = p_budget_version_id;
Line: 4733

    SELECT tmp.rowid
          ,tmp.resource_assignment_id
          ,tmp.txn_currency_code
          ,tmp.start_date
          ,tmp.end_date
          ,fptmp.period_name
          ,decode(perdRec.version_type ,'ALL', NVL(fptmp.raw_cost_rate,tmp.rw_cost_rate_override)
                        ,'COST',NVL(fptmp.raw_cost_rate,tmp.rw_cost_rate_override)
                        ,decode(p_generation_context,'REVENUE_MARKUP' /* bug fix:4213824 added decode to get the cost rt */
                          ,NVL(fptmp.raw_cost_rate,tmp.rw_cost_rate_override),tmp.rw_cost_rate_override)
                        /* bgfix:4250089 having this extra default executes always when version type is revenue
                        ,tmp.rw_cost_rate_override */
                         ) cost_rate_override
              ,decode(perdRec.version_type ,'ALL', NVL(fptmp.burdened_cost_rate,tmp.burden_cost_rate_override)
                                            ,'COST',NVL(fptmp.burdened_cost_rate,tmp.burden_cost_rate_override)
                                            ,decode(p_generation_context,'REVENUE_MARKUP' /* bug fix:4213824 added decode to get the bdRt */
                        ,NVL(fptmp.burdened_cost_rate,tmp.burden_cost_rate_override),tmp.burden_cost_rate_override)
                        /* bug fix:4250089 ,tmp.burden_cost_rate_override */
                        ) burden_rate_override
          ,decode(perdRec.version_type ,'ALL', NVL(fptmp.revenue_bill_rate,tmp.bill_rate_override)
                                            ,'REVENUE',NVL(fptmp.revenue_bill_rate,tmp.bill_rate_override)
                                            ,tmp.bill_rate_override) bill_rate_override
          ,tmp.PROJECT_COST_RATE_TYPE
              ,tmp.PROJECT_COST_EXCHANGE_RATE
              ,tmp.PROJECT_COST_RATE_DATE_TYPE
              ,tmp.PROJECT_COST_RATE_DATE
              ,tmp.PROJECT_REV_RATE_TYPE
              ,tmp.PROJECT_REV_EXCHANGE_RATE
              ,tmp.PROJECT_REV_RATE_DATE_TYPE
              ,tmp.PROJECT_REV_RATE_DATE
              ,tmp.PROJFUNC_COST_RATE_TYPE
              ,tmp.PROJFUNC_COST_EXCHANGE_RATE
              ,tmp.PROJFUNC_COST_RATE_DATE_TYPE
              ,tmp.PROJFUNC_COST_RATE_DATE
              ,tmp.PROJFUNC_REV_RATE_TYPE
              ,tmp.PROJFUNC_REV_EXCHANGE_RATE
              ,tmp.PROJFUNC_REV_RATE_DATE_TYPE
              ,tmp.PROJFUNC_REV_RATE_DATE
        /* Bug fix:4568011: set a flag based on the bill rate override passed from generation process
         * to indicate that revenue should be calculated based on markup or not
         * If bill rate override is passed, then do not calculate markup
         */
        ,decode(p_generation_context,'REVENUE_MARKUP',
                decode(fptmp.revenue_bill_rate,NULL,'Y','N'),'Y') markup_calculation_flag
    FROM  pa_fp_rollup_tmp tmp
          ,pa_fp_gen_rate_tmp fptmp
          ,pa_resource_assignments ra
          ,pa_fp_spread_calc_tmp caltmp
    WHERE  caltmp.budget_version_id = p_budget_version_id
    AND    caltmp.resource_assignment_id = ra.resource_assignment_id
    AND    nvl(caltmp.skip_record_flag,'N') <> 'Y'
    AND    tmp.resource_assignment_id = ra.resource_assignment_id
    AND    tmp.txn_currency_code = caltmp.txn_currency_code
    AND    NVL(tmp.system_reference5,'N') = 'N'  /* donot pick already processed lines */
    AND    fptmp.target_res_asg_id = tmp.resource_assignment_id
    AND    fptmp.txn_currency_code = tmp.txn_currency_code
    AND    NVL(tmp.period_name,'SUMMARY') = nvl(fptmp.period_name,NVL(tmp.period_name,'SUMMARY'))
    /* Bug fix: 4216423 markup should be calculated for both rate and non-rate base resource
    AND    ((p_generation_context = 'SPREAD')
        OR
        ( p_generation_context = 'REVENUE_MARKUP'
          AND NVL(ra.rate_based_flag,'N') = 'N'
        ))
    */
    ;
Line: 4802

    SELECT tmp.rowid
              ,fptmp.target_res_asg_id    RaId
              ,fptmp.txn_currency_code    CurCode
              ,tmp.start_date
              ,tmp.end_date
              ,fptmp.period_name      period_name
          ,fptmp.raw_cost_rate        cost_rate_override
          ,fptmp.burdened_cost_rate   burden_rate_override
          ,fptmp.revenue_bill_rate    bill_rate_override
      ,decode(p_generation_context,'REVENUE_MARKUP',
                                decode(fptmp.revenue_bill_rate,NULL,'Y','N'),'Y') markup_calculation_flag
    FROM  pa_fp_rollup_tmp tmp
              ,pa_fp_gen_rate_tmp fptmp
              ,pa_resource_assignments ra
              ,pa_fp_spread_calc_tmp caltmp
        WHERE  caltmp.budget_version_id = p_budget_version_id
        AND    caltmp.resource_assignment_id = ra.resource_assignment_id
        AND    nvl(caltmp.skip_record_flag,'N') <> 'Y'
        AND    tmp.resource_assignment_id = ra.resource_assignment_id
        AND    tmp.txn_currency_code = caltmp.txn_currency_code
        AND    NVL(tmp.system_reference5,'N') = 'N'  /* donot pick already processed lines */
        AND    fptmp.target_res_asg_id = tmp.resource_assignment_id
        AND    fptmp.txn_currency_code = tmp.txn_currency_code
        AND    NVL(tmp.period_name,'SUMMARY') = nvl(fptmp.period_name,NVL(tmp.period_name,'SUMMARY'))
    /* Bug fix: 4216423 markup should be calculated for both rate and non-rate base resource
        AND    ((p_generation_context = 'SPREAD')
                OR
                ( p_generation_context = 'REVENUE_MARKUP'
                  AND NVL(ra.rate_based_flag,'N') = 'N'
                ))
    */
    ;
Line: 4868

    g_stage :='Update_rollupTmp_OvrRates:100';
Line: 4875

        g_stage :='Update_rollupTmp_OvrRates:101';
Line: 4877

        UPDATE pa_fp_rollup_tmp tmp
            SET tmp.period_name = (select gp.period_name
                               from gl_periods gp
                               where gp.period_set_name = perdRec.period_set_name
                               and gp.adjustment_period_flag = 'N'
                               and gp.period_type = decode(perdRec.time_phase_code,'G',perdRec.accounted_period_type
                                ,'P',perdRec.pa_period_type,gp.period_type)
                               and  tmp.start_date between gp.start_date and gp.end_date
                   and rownum = 1
                               )
            WHERE tmp.period_name is NULL
        AND  tmp.budget_version_id = p_budget_version_id
        AND NVL(tmp.system_reference5,'N') = 'N'
         ;
Line: 4893

        g_stage :='Update_rollupTmp_OvrRates:102';
Line: 4895

        UPDATE pa_fp_rollup_tmp tmp
                SET tmp.period_name = NULL
                WHERE tmp.period_name is NOT NULL
        AND NVL(tmp.system_reference5,'N') = 'N'
        AND  tmp.budget_version_id = p_budget_version_id;
Line: 4900

                print_msg('Number of rows updated['||sql%rowcount||']');
Line: 4907

        l_rowid_tab.delete;
Line: 4908

        l_resource_assignment_id_tab.delete;
Line: 4909

            l_txn_currency_code_tab.delete;
Line: 4910

            l_start_date_tab.delete;
Line: 4911

            l_end_date_tab.delete;
Line: 4912

            l_period_name_tab.delete;
Line: 4913

            l_cost_rate_override_tab.delete;
Line: 4914

            l_burden_rate_override_tab.delete;
Line: 4915

            l_bill_rate_override_tab.delete;
Line: 4916

        l_PROJECT_COST_RATE_TYPE_tab.delete;
Line: 4917

            l_PROJECT_COST_EXG_RATE_tab.delete;
Line: 4918

            l_PROJECT_COST_DATE_TYPE_tab.delete;
Line: 4919

            l_PROJECT_COST_RATE_DATE_tab.delete;
Line: 4920

            l_PROJECT_REV_RATE_TYPE_tab.delete;
Line: 4921

            l_PROJECT_REV_EXG_RATE_tab.delete;
Line: 4922

            l_PROJECT_REV_DATE_TYPE_tab.delete;
Line: 4923

            l_PROJECT_REV_RATE_DATE_tab.delete;
Line: 4924

            l_PROJFUNC_COST_RATE_TYPE_tab.delete;
Line: 4925

            l_PROJFUNC_COST_EXG_RATE_tab.delete;
Line: 4926

            l_PROJFUNC_COST_DATE_TYPE_tab.delete;
Line: 4927

            l_PROJFUNC_COST_RATE_DATE_tab.delete;
Line: 4928

            l_PROJFUNC_REV_RATE_TYPE_tab.delete;
Line: 4929

            l_PROJFUNC_REV_EXG_RATE_tab.delete;
Line: 4930

            l_PROJFUNC_REV_DATE_TYPE_tab.delete;
Line: 4931

            l_PROJFUNC_REV_RATE_DATE_tab.delete;
Line: 4932

        l_markup_calculation_flag_tab.delete;
Line: 4933

        g_stage :='Update_rollupTmp_OvrRates:103';
Line: 4974

            g_stage :='Update_rollupTmp_OvrRates:104';
Line: 4977

            UPDATE pa_fp_rollup_tmp tmp
            SET tmp.rw_cost_rate_override = l_cost_rate_override_tab(i)
               ,tmp.burden_cost_rate_override = l_burden_rate_override_tab(i)
               ,tmp.bill_rate_override = l_bill_rate_override_tab(i)
               ,tmp.PROJECT_COST_RATE_TYPE = nvl(l_PROJECT_COST_RATE_TYPE_tab(i),tmp.PROJECT_COST_RATE_TYPE)
               ,tmp.PROJECT_COST_EXCHANGE_RATE = nvl(l_PROJECT_COST_EXG_RATE_tab(i),tmp.PROJECT_COST_EXCHANGE_RATE)
               ,tmp.PROJECT_COST_RATE_DATE_TYPE = nvl(l_PROJECT_COST_DATE_TYPE_tab(i),tmp.PROJECT_COST_RATE_DATE_TYPE)
               ,tmp.PROJECT_COST_RATE_DATE   = nvl(l_PROJECT_COST_RATE_DATE_tab(i),tmp.PROJECT_COST_RATE_DATE)
               ,tmp.PROJECT_REV_RATE_TYPE    = nvl(l_PROJECT_REV_RATE_TYPE_tab(i),tmp.PROJECT_REV_RATE_TYPE)
               ,tmp.PROJECT_REV_EXCHANGE_RATE  = nvl(l_PROJECT_REV_EXG_RATE_tab(i),tmp.PROJECT_REV_EXCHANGE_RATE)
               ,tmp.PROJECT_REV_RATE_DATE_TYPE = nvl(l_PROJECT_REV_DATE_TYPE_tab(i),tmp.PROJECT_REV_RATE_DATE_TYPE)
               ,tmp.PROJECT_REV_RATE_DATE   = nvl(l_PROJECT_REV_RATE_DATE_tab(i),tmp.PROJECT_REV_RATE_DATE)
               ,tmp.PROJFUNC_COST_RATE_TYPE   = nvl(l_PROJFUNC_COST_RATE_TYPE_tab(i),tmp.PROJFUNC_COST_RATE_TYPE)
               ,tmp.PROJFUNC_COST_EXCHANGE_RATE  = nvl(l_PROJFUNC_COST_EXG_RATE_tab(i),tmp.PROJFUNC_COST_EXCHANGE_RATE)
               ,tmp.PROJFUNC_COST_RATE_DATE_TYPE  = nvl(l_PROJFUNC_COST_DATE_TYPE_tab(i),tmp.PROJFUNC_COST_RATE_DATE_TYPE)
               ,tmp.PROJFUNC_COST_RATE_DATE     = nvl(l_PROJFUNC_COST_RATE_DATE_tab(i),tmp.PROJFUNC_COST_RATE_DATE)
               ,tmp.PROJFUNC_REV_RATE_TYPE    = nvl(l_PROJFUNC_REV_RATE_TYPE_tab(i),tmp.PROJFUNC_REV_RATE_TYPE)
               ,tmp.PROJFUNC_REV_EXCHANGE_RATE  = nvl(l_PROJFUNC_REV_EXG_RATE_tab(i),tmp.PROJFUNC_REV_EXCHANGE_RATE)
               ,tmp.PROJFUNC_REV_RATE_DATE_TYPE   =nvl(l_PROJFUNC_REV_DATE_TYPE_tab(i),tmp.PROJFUNC_REV_RATE_DATE_TYPE)
               ,tmp.PROJFUNC_REV_RATE_DATE = nvl(l_PROJFUNC_REV_RATE_DATE_tab(i),tmp.PROJFUNC_REV_RATE_DATE)
           ,tmp.SYSTEM_REFERENCE6 = nvl(l_markup_calculation_flag_tab(i),'Y')
            WHERE tmp.rowid = l_rowid_tab(i);
Line: 5009

END Update_rollupTmp_OvrRates;
Line: 5012

This API is called when source context is BUDGET_LINE and delete_budget_lines flag is Y
Before deleting budget lines, this api calls Pji reporting apis to update the balances
and then it deletes the budget lines only if there are no actuals exists.
and the budget start date is greater than ETC start date
*/
PROCEDURE delete_budget_lines
    ( p_budget_version_id         IN  pa_budget_lines.budget_version_id%type
     ,p_resource_assignment_id    IN  pa_resource_assignments.resource_assignment_id%TYPE
         ,p_txn_currency_code         IN  pa_budget_lines.txn_currency_code%TYPE
         ,p_line_start_date           IN  pa_budget_lines.start_date%TYPE
         ,p_line_end_date             IN  pa_budget_lines.end_date%TYPE
     ,p_source_context            IN  varchar2
         ,x_return_status             OUT NOCOPY VARCHAR2
         ,x_msg_count                 OUT NOCOPY NUMBER
         ,x_msg_data                  OUT NOCOPY VARCHAR2
     ,x_num_rowsdeleted       OUT NOCOPY Number
         ) IS

    l_debug_mode               VARCHAR2(30);
Line: 5036

    CURSOR get_delete_bl_id IS
    SELECT bl.budget_line_id
              ,bl.resource_assignment_id
              ,bl.txn_currency_code
              ,bl.start_date
              ,bl.end_date
              ,bl.period_name
              ,bl.quantity
              ,bl.txn_raw_cost
              ,bl.txn_burdened_cost
              ,bl.txn_revenue
              ,bl.project_raw_cost
              ,bl.project_burdened_cost
              ,bl.project_revenue
              ,bl.raw_cost      projfunc_raw_cost
              ,bl.burdened_cost projfunc_burdened_cost
              ,bl.revenue       projfunc_revenue
              ,bl.project_currency_code
              ,bl.projfunc_currency_code
          ,bl.cost_rejection_code
              ,bl.revenue_rejection_code
              ,bl.burden_rejection_code
              ,bl.pfc_cur_conv_rejection_code
              ,bl.pc_cur_conv_rejection_code
        FROM pa_budget_lines bl
    WHERE bl.resource_assignment_id = p_resource_assignment_id
    AND   bl.txn_currency_code      = p_txn_currency_code
        AND ((p_line_start_date is NULL AND p_line_end_date is NULL )
             OR (p_line_start_date is NOT NULL AND p_line_end_date is NOT NULL
                and bl.start_date BETWEEN p_line_start_date AND p_line_end_date
        )
        )
/* Bug 4344112 -- Actuals can be stamped as null or zero, in both cases
   we need to delete the lines. In case of this bug actuals are getting
   stamped as ZERO so we are not deleting this line, the spread logic
   breaks becoz of the zero in actuals.
   Lines with zero actuals can be deleted as lines with NULL actuals. */
 /****** AND (bl.init_quantity          IS NULL AND
              bl.txn_init_raw_cost      IS NULL AND
              bl.txn_init_burdened_cost IS NULL AND
              bl.txn_init_revenue       IS NULL);   ******/
Line: 5083

    /* This cursor picks all the budget lines where ETC start date falls and updates the
    * plan = Actuals so that remaining ETC will be spread forward
    */
        CURSOR cur_UpdBlWithZeroEtc IS
        SELECT bl.budget_line_id
              ,bl.resource_assignment_id
              ,bl.txn_currency_code
              ,bl.start_date
              ,bl.end_date
              ,bl.period_name
              ,bl.quantity
              ,bl.txn_raw_cost
              ,bl.txn_burdened_cost
              ,bl.txn_revenue
              ,bl.project_raw_cost
              ,bl.project_burdened_cost
              ,bl.project_revenue
              ,bl.raw_cost      projfunc_raw_cost
              ,bl.burdened_cost projfunc_burdened_cost
              ,bl.revenue       projfunc_revenue
              ,bl.project_currency_code
              ,bl.projfunc_currency_code
              ,bl.cost_rejection_code
              ,bl.revenue_rejection_code
              ,bl.burden_rejection_code
              ,bl.pfc_cur_conv_rejection_code
              ,bl.pc_cur_conv_rejection_code
          ,bl.init_quantity
          ,bl.txn_init_raw_cost
          ,bl.txn_init_burdened_cost
          ,bl.txn_init_revenue
          ,bl.project_init_raw_cost
          ,bl.project_init_burdened_cost
          ,bl.project_init_revenue
          ,bl.init_raw_cost
          ,bl.init_burdened_cost
          ,bl.init_revenue
        FROM pa_budget_lines bl
        WHERE bl.resource_assignment_id = p_resource_assignment_id
        AND   bl.txn_currency_code      = p_txn_currency_code
        AND ((p_line_start_date is NULL AND p_line_end_date is NULL )
             OR (p_line_start_date is NOT NULL AND p_line_end_date is NOT NULL
                and bl.start_date BETWEEN p_line_start_date AND p_line_end_date
                )
            )
        AND g_spread_from_date is NOT NULL
        AND ((bl.start_date >= g_spread_from_date )
             /* bug fix: 4139354 and (g_spread_from_date BETWEEN bl.start_date AND bl.end_date)*/
             OR (g_spread_from_date BETWEEN bl.start_date AND bl.end_date)
            )
        AND ( NVL(bl.init_quantity,0) <> 0 OR
                 NVL(bl.txn_init_raw_cost ,0) <> 0 OR
                 NVL(bl.txn_init_burdened_cost ,0) <> 0 OR
                 NVL(bl.txn_init_revenue ,0) <> 0
       );
Line: 5178

    g_stage := 'delete_budget_lines:100';
Line: 5180

            pa_debug.init_err_stack('PA_FP_CALC_PLAN_PKG.delete_budget_lines');
Line: 5181

        print_msg('Entered PA_FP_CALC_PLAN_PKG.delete_budget_lines ResAssId['||p_resource_assignment_id||']spreadDate['||g_spread_from_date||']');
Line: 5184

        OPEN  get_delete_bl_id ;
Line: 5185

        FETCH get_delete_bl_id BULK COLLECT INTO
                l_budget_Line_id_tab
                ,l_resource_assignment_id_tab
                ,l_txn_currency_code_tab
                ,l_start_date_tab
                ,l_end_date_tab
                ,l_period_name_tab
                ,l_quantity_tab
                ,l_txn_raw_cost_tab
                ,l_txn_burdened_cost_tab
                ,l_txn_revenue_tab
                ,l_project_raw_cost_tab
                ,l_project_burdened_cost_tab
                ,l_project_revenue_tab
                ,l_projfunc_raw_cost_tab
                ,l_projfunc_burdened_cost_tab
                ,l_projfunc_revenue_tab
                ,l_project_curr_code_tab
                ,l_projfunc_curr_code_tab
        ,l_cost_rejection_code_tab
                ,l_revenue_rejection_code_tab
                ,l_burden_rejection_code_tab
                ,l_pfc_cur_conv_rej_code_tab
                ,l_pc_cur_conv_rej_code_tab;
Line: 5209

        CLOSE get_delete_bl_id;
Line: 5215

                g_stage := 'delete_budget_lines:101';
Line: 5225

                        /* update the reporting lines before deleteing the budget lines */
                        Add_Toreporting_Tabls
                                (p_calling_module               => 'CALCULATE_API'
                                ,p_activity_code                => 'UPDATE'
                                ,p_budget_version_id            => p_budget_version_id
                                ,p_budget_line_id               => l_budget_Line_id_tab(i)
                                ,p_resource_assignment_id       => l_resource_assignment_id_tab(i)
                                ,p_start_date                   => l_start_date_tab(i)
                                ,p_end_date                     => l_end_date_tab(i)
                                ,p_period_name                  => l_period_name_tab(i)
                                ,p_txn_currency_code            => l_txn_currency_code_tab(i)
                                ,p_quantity                     => l_quantity_tab(i) * -1
                                ,p_txn_raw_cost                 => l_txn_raw_cost_tab(i) * -1
                                ,p_txn_burdened_cost            => l_txn_burdened_cost_tab(i) * -1
                                ,p_txn_revenue                  => l_txn_revenue_tab(i) * -1
                                ,p_project_currency_code        => l_project_curr_code_tab(i)
                                ,p_project_raw_cost             => l_project_raw_cost_tab(i) * -1
                                ,p_project_burdened_cost        => l_project_burdened_cost_tab(i) * -1
                                ,p_project_revenue              => l_project_revenue_tab(i) * -1
                                ,p_projfunc_currency_code       => l_projfunc_curr_code_tab(i)
                                ,p_projfunc_raw_cost            => l_projfunc_raw_cost_tab(i) * -1
                                ,p_projfunc_burdened_cost       => l_projfunc_burdened_cost_tab(i) * -1
                                ,p_projfunc_revenue             => l_projfunc_revenue_tab(i) * -1
				,p_rep_line_mode               => 'REVERSAL'
                                ,x_msg_data                     => x_msg_data
                                ,x_return_status                => l_return_status
                                );
Line: 5261

                        /* add the deleted budget lines to mrc plsql tabs */
                        Populate_MRC_plsqlTabs
                                (p_calling_module               => 'CALCULATE_API'
                                ,p_budget_version_id            => p_budget_version_id
                                ,p_budget_line_id               => l_budget_Line_id_tab(i)
                                ,p_resource_assignment_id       => l_resource_assignment_id_tab(i)
                                ,p_start_date                   => l_start_date_tab(i)
                                ,p_end_date                     => l_end_date_tab(i)
                                ,p_period_name                  => l_period_name_tab(i)
                                ,p_txn_currency_code            => l_txn_currency_code_tab(i)
                                ,p_quantity                     => l_quantity_tab(i)
                                ,p_txn_raw_cost                 => l_txn_raw_cost_tab(i)
                                ,p_txn_burdened_cost            => l_txn_burdened_cost_tab(i)
                                ,p_txn_revenue                  => l_txn_revenue_tab(i)
                                ,p_project_currency_code        => l_project_curr_code_tab(i)
                                ,p_project_raw_cost             => l_project_raw_cost_tab(i)
                                ,p_project_burdened_cost        => l_project_burdened_cost_tab(i)
                                ,p_project_revenue              => l_project_revenue_tab(i)
                                ,p_projfunc_currency_code       => l_projfunc_curr_code_tab(i)
                                ,p_projfunc_raw_cost            => l_projfunc_raw_cost_tab(i)
                                ,p_projfunc_burdened_cost       => l_projfunc_burdened_cost_tab(i)
                                ,p_projfunc_revenue             => l_projfunc_revenue_tab(i)
                ,p_delete_flag                  => 'Y'
                                ,x_msg_data                     => x_msg_data
                                ,x_return_status                => l_return_status
                                );
Line: 5294

           g_stage := 'delete_budget_lines:102';
Line: 5297

               DELETE FROM pa_budget_lines bl
               WHERE bl.budget_line_id = l_budget_Line_id_tab(i) ;
Line: 5299

           x_num_rowsdeleted := sql%rowcount;
Line: 5307

        l_budget_Line_id_tab.delete;
Line: 5308

                l_resource_assignment_id_tab.delete;
Line: 5309

                l_txn_currency_code_tab.delete;
Line: 5310

                l_start_date_tab.delete;
Line: 5311

                l_end_date_tab.delete;
Line: 5312

                l_period_name_tab.delete;
Line: 5313

                l_quantity_tab.delete;
Line: 5314

                l_txn_raw_cost_tab.delete;
Line: 5315

                l_txn_burdened_cost_tab.delete;
Line: 5316

                l_txn_revenue_tab.delete;
Line: 5317

                l_project_raw_cost_tab.delete;
Line: 5318

                l_project_burdened_cost_tab.delete;
Line: 5319

                l_project_revenue_tab.delete;
Line: 5320

                l_projfunc_raw_cost_tab.delete;
Line: 5321

                l_projfunc_burdened_cost_tab.delete;
Line: 5322

                l_projfunc_revenue_tab.delete;
Line: 5323

                l_project_curr_code_tab.delete;
Line: 5324

                l_projfunc_curr_code_tab.delete;
Line: 5325

                l_cost_rejection_code_tab.delete;
Line: 5326

                l_revenue_rejection_code_tab.delete;
Line: 5327

                l_burden_rejection_code_tab.delete;
Line: 5328

                l_pfc_cur_conv_rej_code_tab.delete;
Line: 5329

                l_pc_cur_conv_rej_code_tab.delete;
Line: 5330

                l_init_quantity_tab.delete;
Line: 5331

                l_txn_init_raw_cost_tab.delete;
Line: 5332

                l_txn_init_burdened_cost_tab.delete;
Line: 5333

                l_txn_init_revenue_tab.delete;
Line: 5334

        l_pj_init_raw_cost_tab.delete;
Line: 5335

            l_pj_init_burdened_cost_tab.delete;
Line: 5336

            l_pj_init_revenue_tab.delete;
Line: 5337

            l_pjf_init_raw_cost_tab.delete;
Line: 5338

            l_pjf_init_burdened_cost_tab.delete;
Line: 5339

            l_pjf_init_revenue_tab.delete;
Line: 5340

        g_stage := 'delete_budget_lines:103';
Line: 5381

            g_stage := 'delete_budget_lines:104';
Line: 5392

                            /* update the reporting lines before deleteing the budget lines */
                            Add_Toreporting_Tabls
                                (p_calling_module               => 'CALCULATE_API'
                                ,p_activity_code                => 'UPDATE'
                                ,p_budget_version_id            => p_budget_version_id
                                ,p_budget_line_id               => l_budget_Line_id_tab(i)
                                ,p_resource_assignment_id       => l_resource_assignment_id_tab(i)
                                ,p_start_date                   => l_start_date_tab(i)
                                ,p_end_date                     => l_end_date_tab(i)
                                ,p_period_name                  => l_period_name_tab(i)
                                ,p_txn_currency_code            => l_txn_currency_code_tab(i)
                                ,p_quantity                     => l_quantity_tab(i) * -1
                                ,p_txn_raw_cost                 => l_txn_raw_cost_tab(i) * -1
                                ,p_txn_burdened_cost            => l_txn_burdened_cost_tab(i) * -1
                                ,p_txn_revenue                  => l_txn_revenue_tab(i) * -1
                                ,p_project_currency_code        => l_project_curr_code_tab(i)
                                ,p_project_raw_cost             => l_project_raw_cost_tab(i) * -1
                                ,p_project_burdened_cost        => l_project_burdened_cost_tab(i) * -1
                                ,p_project_revenue              => l_project_revenue_tab(i) * -1
                                ,p_projfunc_currency_code       => l_projfunc_curr_code_tab(i)
                                ,p_projfunc_raw_cost            => l_projfunc_raw_cost_tab(i) * -1
                                ,p_projfunc_burdened_cost       => l_projfunc_burdened_cost_tab(i) * -1
                                ,p_projfunc_revenue             => l_projfunc_revenue_tab(i) * -1
				,p_rep_line_mode               => 'REVERSAL'
                                ,x_msg_data                     => x_msg_data
                                ,x_return_status                => l_return_status
                                );
Line: 5430

            g_stage := 'delete_budget_lines:105';
Line: 5432

                UPDATE pa_budget_lines bl
                SET bl.quantity = l_init_quantity_tab(i)
                  ,bl.txn_raw_cost = l_txn_init_raw_cost_tab(i)
                  ,bl.txn_burdened_cost = l_txn_init_burdened_cost_tab(i)
                  ,bl.txn_revenue = l_txn_init_revenue_tab(i)
                  ,bl.project_raw_cost = l_pj_init_raw_cost_tab(i)
                          ,bl.project_burdened_cost = l_pj_init_burdened_cost_tab(i)
                              ,bl.project_revenue = l_pj_init_revenue_tab(i)
                          ,bl.raw_cost = l_pjf_init_raw_cost_tab(i)
                          ,bl.burdened_cost = l_pjf_init_burdened_cost_tab(i)
                          ,bl.revenue = l_pjf_init_revenue_tab(i)
                WHERE bl.budget_line_id = l_budget_Line_id_tab(i);
Line: 5445

            /* Now pass +ve budget line values (Updated values) to PJI reporting api */
            l_stage := 7840;
Line: 5447

                    l_budget_Line_id_tab.delete;
Line: 5448

                    l_resource_assignment_id_tab.delete;
Line: 5449

                    l_txn_currency_code_tab.delete;
Line: 5450

                    l_start_date_tab.delete;
Line: 5451

                    l_end_date_tab.delete;
Line: 5452

                    l_period_name_tab.delete;
Line: 5453

                    l_quantity_tab.delete;
Line: 5454

                    l_txn_raw_cost_tab.delete;
Line: 5455

                    l_txn_burdened_cost_tab.delete;
Line: 5456

                    l_txn_revenue_tab.delete;
Line: 5457

                    l_project_raw_cost_tab.delete;
Line: 5458

                    l_project_burdened_cost_tab.delete;
Line: 5459

                    l_project_revenue_tab.delete;
Line: 5460

                    l_projfunc_raw_cost_tab.delete;
Line: 5461

                    l_projfunc_burdened_cost_tab.delete;
Line: 5462

                    l_projfunc_revenue_tab.delete;
Line: 5463

                    l_project_curr_code_tab.delete;
Line: 5464

                    l_projfunc_curr_code_tab.delete;
Line: 5465

                    l_cost_rejection_code_tab.delete;
Line: 5466

                    l_revenue_rejection_code_tab.delete;
Line: 5467

                    l_burden_rejection_code_tab.delete;
Line: 5468

                    l_pfc_cur_conv_rej_code_tab.delete;
Line: 5469

                    l_pc_cur_conv_rej_code_tab.delete;
Line: 5470

                    l_init_quantity_tab.delete;
Line: 5471

                    l_txn_init_raw_cost_tab.delete;
Line: 5472

                    l_txn_init_burdened_cost_tab.delete;
Line: 5473

                    l_txn_init_revenue_tab.delete;
Line: 5474

                    l_pj_init_raw_cost_tab.delete;
Line: 5475

                    l_pj_init_burdened_cost_tab.delete;
Line: 5476

                    l_pj_init_revenue_tab.delete;
Line: 5477

                    l_pjf_init_raw_cost_tab.delete;
Line: 5478

                    l_pjf_init_burdened_cost_tab.delete;
Line: 5479

                    l_pjf_init_revenue_tab.delete;
Line: 5480

            g_stage := 'delete_budget_lines:106';
Line: 5521

               g_stage := 'delete_budget_lines:107';
Line: 5532

                                /* update the reporting lines after updating the budget lines */
                                Add_Toreporting_Tabls
                                (p_calling_module               => 'CALCULATE_API'
                                ,p_activity_code                => 'UPDATE'
                                ,p_budget_version_id            => p_budget_version_id
                                ,p_budget_line_id               => l_budget_Line_id_tab(i)
                                ,p_resource_assignment_id       => l_resource_assignment_id_tab(i)
                                ,p_start_date                   => l_start_date_tab(i)
                                ,p_end_date                     => l_end_date_tab(i)
                                ,p_period_name                  => l_period_name_tab(i)
                                ,p_txn_currency_code            => l_txn_currency_code_tab(i)
                                ,p_quantity                     => l_quantity_tab(i)
                                ,p_txn_raw_cost                 => l_txn_raw_cost_tab(i)
                                ,p_txn_burdened_cost            => l_txn_burdened_cost_tab(i)
                                ,p_txn_revenue                  => l_txn_revenue_tab(i)
                                ,p_project_currency_code        => l_project_curr_code_tab(i)
                                ,p_project_raw_cost             => l_project_raw_cost_tab(i)
                                ,p_project_burdened_cost        => l_project_burdened_cost_tab(i)
                                ,p_project_revenue              => l_project_revenue_tab(i)
                                ,p_projfunc_currency_code       => l_projfunc_curr_code_tab(i)
                                ,p_projfunc_raw_cost            => l_projfunc_raw_cost_tab(i)
                                ,p_projfunc_burdened_cost       => l_projfunc_burdened_cost_tab(i)
                                ,p_projfunc_revenue             => l_projfunc_revenue_tab(i)
				,p_rep_line_mode               => 'POSITIVE_ENTRY'
                                ,x_msg_data                     => x_msg_data
                                ,x_return_status                => l_return_status
                                );
Line: 5589

        	print_msg('Leaving delete_budget_lines');
Line: 5620

                ,p_procedure_name => 'delete_budget_lines' );
Line: 5625

END delete_budget_lines;
Line: 5774

      for i in (select * from pa_fp_spread_calc_tmp ) LOOP
       print_msg('IN params ResId['||i.resource_assignment_id||']TxnCur['||i.txn_currency_code||']RefrFlag['||i.refresh_rates_flag||']');
Line: 5782

       INSERT INTO pa_fp_rollup_tmp (
    budget_version_id
        ,resource_assignment_id
       ,start_date
       ,end_date
       ,period_name
       ,quantity
       ,projfunc_raw_cost
       ,projfunc_burdened_cost
       ,projfunc_revenue
       ,cost_rejection_code
       ,revenue_rejection_code
       ,burden_rejection_code
       ,projfunc_currency_code
       ,projfunc_cost_rate_type
       ,projfunc_cost_exchange_rate
       ,projfunc_cost_rate_date_type
       ,projfunc_cost_rate_date
       ,projfunc_rev_rate_type
       ,projfunc_rev_exchange_rate
       ,projfunc_rev_rate_date_type
       ,projfunc_rev_rate_date
       ,project_currency_code
       ,project_cost_rate_type
       ,project_cost_exchange_rate
       ,project_cost_rate_date_type
       ,project_cost_rate_date
       ,project_raw_cost
       ,project_burdened_cost
       ,project_rev_rate_type
       ,project_rev_exchange_rate
       ,project_rev_rate_date_type
       ,project_rev_rate_date
       ,project_revenue
       ,txn_currency_code
       ,txn_raw_cost
       ,txn_burdened_cost
       ,txn_revenue
       ,budget_line_id
       ,init_quantity
       ,txn_init_raw_cost
       ,txn_init_burdened_cost
       ,txn_init_revenue
       ,bill_markup_percentage
       ,bill_rate
       ,cost_rate
       ,rw_cost_rate_override
       ,burden_cost_rate
       ,bill_rate_override
       ,burden_cost_rate_override
       ,cost_ind_compiled_set_id
       ,init_raw_cost
       ,init_burdened_cost
       ,init_revenue
       ,project_init_raw_cost
       ,project_init_burdened_cost
       ,project_init_revenue
       ,billable_flag
       ,rate_based_flag
       ,system_reference4  -- version all revenue only entered
       )
       ( SELECT /*+ INDEX(BL PA_BUDGET_LINES_U1) */
    bl.budget_version_id
        ,bl.resource_assignment_id
       ,bl.start_date
       ,bl.end_date
       ,bl.period_name
       ,bl.quantity
        /* Bug Fix 4332086
           When ever currency is overridden in the workplan flow the exchange rates of old currency
           are used to derive the PFC amounts.
           This is happening due to the following piece of code.
           In the following code we are storing the pa_budget_lines attributes in pa_fp_rollup_tmp
           and then we are using the same in the later part of the code.
           This is resulting in the bug.

           As a fix now we added another decode condition to see if the currency is iverridden.
           If it is then we nullify all the currency related attributes, so they can be retrieved
           for the latest currency instead of caching the old currency's attrs.
        */
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(ra.rate_based_flag,'N',bl.raw_cost
        ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.raw_cost,NULL)
                ,'C',decode(bl.quantity,null,bl.raw_cost,NULL)
                ,'R',bl.raw_cost
                    ,bl.raw_cost
            )
          ),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(ra.rate_based_flag,'N',bl.burdened_cost
        ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.burdened_cost,NULL)
            ,'C',decode(bl.quantity,null,bl.burdened_cost,NULL)
            ,'R',bl.burdened_cost
            ,bl.burdened_cost
            )
          ),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(ra.rate_based_flag,'N',bl.revenue
        ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.revenue,NULL)
                ,'C',bl.revenue
                ,'R',decode(bl.quantity,null,bl.revenue,NULL)
                ,bl.revenue
            )
          ),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_rates_flag,'Y' ,decode(bl.quantity,null,bl.cost_rejection_code,NULL)
            ,'C',decode(bl.quantity,null,bl.cost_rejection_code,NULL)
            ,'R',bl.cost_rejection_code
        ,bl.cost_rejection_code
          ),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.revenue_rejection_code,NULL)
            ,'C',bl.revenue_rejection_code
            ,'R',decode(bl.quantity,null,bl.revenue_rejection_code,NULL)
        ,bl.revenue_rejection_code
          ),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_rates_flag,'Y' ,decode(bl.quantity,null,bl.burden_rejection_code,NULL)
            ,'C',decode(bl.quantity,null,bl.burden_rejection_code,NULL)
            ,'R',bl.burden_rejection_code
        ,bl.burden_rejection_code
          ),NULL)
       ,bl.projfunc_currency_code
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.projfunc_cost_rate_type,NULL),bl.projfunc_cost_rate_type),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.projfunc_cost_exchange_rate,NULL),bl.projfunc_cost_exchange_rate),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.projfunc_cost_rate_date_type,NULL),bl.projfunc_cost_rate_date_type),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.projfunc_cost_rate_date,NULL),bl.projfunc_cost_rate_date),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.projfunc_rev_rate_type,NULL),bl.projfunc_rev_rate_type),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.projfunc_rev_exchange_rate,NULL),bl.projfunc_rev_exchange_rate),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.projfunc_rev_rate_date_type,NULL),bl.projfunc_rev_rate_date_type),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.projfunc_rev_rate_date,NULL),bl.projfunc_rev_rate_date),NULL)
       ,bl.project_currency_code
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.project_cost_rate_type,NULL),bl.project_cost_rate_type),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.project_cost_exchange_rate,NULL),bl.project_cost_exchange_rate),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.project_cost_rate_date_type,NULL),bl.project_cost_rate_date_type),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.project_cost_rate_date,NULL),bl.project_cost_rate_date),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(ra.rate_based_flag,'N',bl.project_raw_cost
        ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.project_raw_cost,NULL)
                ,'C',decode(bl.quantity,null,bl.project_raw_cost,NULL)
                ,'R',bl.project_raw_cost
            ,bl.project_raw_cost
            )
            ),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(ra.rate_based_flag,'N',bl.project_burdened_cost
        ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.project_burdened_cost,NULL)
                ,'C',decode(bl.quantity,null,bl.project_burdened_cost,NULL)
                ,'R',bl.project_burdened_cost
            ,bl.project_burdened_cost
            )
            ),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.project_rev_rate_type,NULL),bl.project_rev_rate_type),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.project_rev_exchange_rate,NULL),bl.project_rev_exchange_rate),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.project_rev_rate_date_type,NULL),bl.project_rev_rate_date_type),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_conv_rates_flag,'Y'
        ,decode(g_source_context,'BUDGET_LINE',bl.project_rev_rate_date,NULL),bl.project_rev_rate_date),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(ra.rate_based_flag,'N',bl.project_revenue
        ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.project_revenue,NULL)
                ,'C',bl.project_revenue
                ,'R',decode(bl.quantity,null,bl.project_revenue,NULL)
            ,bl.project_revenue
               )
          ),NULL)
       ,bl.txn_currency_code
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(ra.rate_based_flag,'N',bl.txn_raw_cost
        ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.txn_raw_cost,NULL)
                ,'C',decode(bl.quantity,null,bl.txn_raw_cost,NULL)
                ,'R',bl.txn_raw_cost
            ,bl.txn_raw_cost
            )
        ),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(ra.rate_based_flag,'N',bl.txn_burdened_cost
        ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.txn_burdened_cost,NULL)
                ,'C',decode(bl.quantity,null,bl.txn_burdened_cost,NULL)
                ,'R',bl.txn_burdened_cost
            ,bl.txn_burdened_cost
            )
        ),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(ra.rate_based_flag,'N',bl.txn_revenue
        ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.txn_revenue,NULL)
                ,'C',bl.txn_revenue
                ,'R',decode(bl.quantity,null,bl.txn_revenue,NULL)
            ,bl.txn_revenue
               )
        ),NULL)
       ,bl.budget_line_id
       ,bl.init_quantity
       ,bl.txn_init_raw_cost
       ,bl.txn_init_burdened_cost
       ,bl.txn_init_revenue
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(NVL(tmp.billable_flag,'N'),'N',bl.txn_markup_percent /* Added for billablity enhancements */
       ,decode(tmp.refresh_rates_flag,'Y'
                /*Bug fix: 4294287 Starts ,decode(bl.quantity,null,bl.txn_markup_percent,NULL) */
                 ,decode(g_fp_budget_version_type ,'REVENUE'
                                    ,decode(NVL(bl.txn_markup_percent,0),0,decode(bl.quantity,null,bl.txn_markup_percent,NULL)
                       ,bl.txn_markup_percent),decode(bl.quantity,null,bl.txn_markup_percent,NULL))
                /* Bug fix: 4294287 ends */
            ,'C',bl.txn_markup_percent
            ,'R'/*Bug fix: 4294287 Starts ,decode(bl.quantity,null,bl.txn_markup_percent,NULL) */
                 ,decode(g_fp_budget_version_type ,'REVENUE'
                                    ,decode(NVL(bl.txn_markup_percent,0),0,decode(bl.quantity,null,bl.txn_markup_percent,NULL)
                                      ,bl.txn_markup_percent),decode(bl.quantity,null,bl.txn_markup_percent,NULL))
                              /* Bug fix: 4294287 ends */
            ,bl.txn_markup_percent
        )),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(ra.rate_based_flag,'N',bl.txn_standard_bill_rate
        ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.txn_standard_bill_rate,NULL)
                ,'C',bl.txn_standard_bill_rate
                ,'R',decode(bl.quantity,null,bl.txn_standard_bill_rate,NULL)
                ,bl.txn_standard_bill_rate
            )
        ),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(ra.rate_based_flag,'N',bl.txn_standard_cost_rate
        ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.txn_standard_cost_rate,NULL)
                ,'C',decode(bl.quantity,null,bl.txn_standard_cost_rate,NULL)
                ,'R',bl.txn_standard_cost_rate
                ,bl.txn_standard_cost_rate
            )
        ),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(ra.rate_based_flag,'N',bl.txn_cost_rate_override
        ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.txn_cost_rate_override,NULL)
                ,'C',decode(bl.quantity,null,bl.txn_cost_rate_override,NULL)
                ,'R',bl.txn_cost_rate_override
                ,bl.txn_cost_rate_override
            )
        ),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(ra.rate_based_flag,'N',bl.burden_cost_rate
        ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.burden_cost_rate,NULL)
                ,'C',decode(bl.quantity,null,bl.burden_cost_rate,NULL)
                ,'R',bl.burden_cost_rate
                ,bl.burden_cost_rate
            )
        ),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(NVL(tmp.billable_flag,'N'),'N',bl.txn_bill_rate_override /* Added for billablity enhancements */
     	  ,decode(ra.rate_based_flag,'N',
               /*Bug:5056986 */
                decode(g_fp_budget_version_type,'ALL'
                	,decode(tmp.refresh_rates_flag,'Y',decode(bl.txn_cost_rate_override,0,bl.txn_bill_rate_override,NULL)
					,'R',decode(bl.txn_cost_rate_override,0,bl.txn_bill_rate_override,NULL)
					, bl.txn_bill_rate_override),bl.txn_bill_rate_override)
           ,decode(tmp.refresh_rates_flag,'Y' /*Bug fix: 4294287 Starts decode(bl.quantity,null,bl.txn_bill_rate_override,NULL)*/
                    ,decode(g_fp_budget_version_type ,'REVENUE'
                        ,decode(NVL(bl.txn_markup_percent,0),0,decode(bl.quantity,null,bl.txn_bill_rate_override,NULL)
                          ,bl.txn_bill_rate_override),decode(bl.quantity,null,bl.txn_bill_rate_override,NULL))
                        /*end bug fix:4294287*/
                ,'C',bl.txn_bill_rate_override
                ,'R' /*Bug fix: 4294287 Starts,decode(bl.quantity,null,bl.txn_bill_rate_override,NULL) */
                    ,decode(g_fp_budget_version_type ,'REVENUE'
                                                ,decode(NVL(bl.txn_markup_percent,0),0,decode(bl.quantity,null,bl.txn_bill_rate_override,NULL)
                                                  ,bl.txn_bill_rate_override),decode(bl.quantity,null,bl.txn_bill_rate_override,NULL))
                     /*end bug fix:4294287*/
                ,bl.txn_bill_rate_override
            )
        )),NULL)
        /** Bug fix:4119950 reverted back the changes made for if raw cost = burden cost then retain burden overrides
     --for non-rate base, if raw cost = burden cost then retain the burden overrides

       ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.burden_cost_rate_override
               ,decode(ra.rate_based_flag,'Y',NULL,decode(bl.txn_raw_cost,bl.txn_burdened_cost,bl.burden_cost_rate_override,NULL)))
        ,'C',decode(bl.quantity,null,bl.burden_cost_rate_override
                       ,decode(ra.rate_based_flag,'Y',NULL,decode(bl.txn_raw_cost,bl.txn_burdened_cost,bl.burden_cost_rate_override,NULL)))
        ,'R',bl.burden_cost_rate_override
        ,bl.burden_cost_rate_override
          )
       ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.cost_ind_compiled_set_id
            ,decode(ra.rate_based_flag,'Y',NULL,decode(bl.txn_raw_cost,bl.txn_burdened_cost,bl.cost_ind_compiled_set_id,NULL)))
         ,'C',decode(bl.quantity,null,bl.cost_ind_compiled_set_id
                        ,decode(ra.rate_based_flag,'Y',NULL,decode(bl.txn_raw_cost,bl.txn_burdened_cost,bl.cost_ind_compiled_set_id,NULL)))
         ,'R',bl.cost_ind_compiled_set_id
         ,bl.cost_ind_compiled_set_id
        )
    **/
    /* Added this for Bug fix:4119950 Refresh burden rate override always
    Note: If user enters a burden cost only, then on refresh user entered burden cost will be lost.  This is acceptable
    as compared to bug 4119950 not refreshing the burden cost at all
    */
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.burden_cost_rate_override,NULL)
                ,'C',decode(bl.quantity,null,bl.burden_cost_rate_override,NULL)
                ,'R',bl.burden_cost_rate_override
                ,bl.burden_cost_rate_override
              ),NULL)
       ,DECODE(tmp.TXN_CURR_CODE_OVERRIDE,NULL
       ,decode(tmp.refresh_rates_flag,'Y',decode(bl.quantity,null,bl.cost_ind_compiled_set_id,NULL)
                 ,'C',decode(bl.quantity,null,bl.cost_ind_compiled_set_id,NULL)
                 ,'R',bl.cost_ind_compiled_set_id
                 ,bl.cost_ind_compiled_set_id
                ),NULL)
       ,bl.init_raw_cost
       ,bl.init_burdened_cost
       ,bl.init_revenue
       ,bl.project_init_raw_cost
       ,bl.project_init_burdened_cost
       ,bl.project_init_revenue
       ,tmp.billable_flag
    /* bug fix:4657962 */
    ,NVL(ra.rate_based_flag,'N')
	,decode(g_mass_adjust_flag,'N','N'
		,decode(NVL(g_wp_version_flag,'N'),'Y','N'
		     ,decode(nvl(ra.rate_based_flag,'N'),'Y','N'
			 ,'N',decode(bl.txn_cost_rate_override,0,'Y','N'))))
       FROM pa_budget_lines bl
           ,pa_resource_assignments ra
       ,pa_fp_spread_calc_tmp tmp
       WHERE tmp.budget_version_id = p_budget_version_id
    AND (NVL(tmp.refresh_rates_flag,'N') in ('Y','R','C')
        OR NVL(tmp.refresh_conv_rates_flag,'N') = 'Y'
        OR NVL(tmp.mass_adjust_flag,'N') = 'Y'
        OR NVL(tmp.mfc_cost_refresh_flag,'N') = 'Y'
        OR NVL(tmp.ra_rates_only_change_flag,'N') = 'Y'
        OR NVL(tmp.system_reference_var2,'N') = 'Y'  /* Bug fix:4295967 to populate rollupt tmp in apply progress mode*/
       )
    AND NVL(tmp.skip_record_flag,'N') <> 'Y'
    AND tmp.resource_assignment_id = ra.resource_assignment_id
        AND bl.resource_assignment_id = ra.resource_assignment_id
        AND bl.txn_currency_code      = tmp.txn_currency_code
        AND ((g_spread_from_date IS NULL)
           OR (g_spread_from_date IS NOT NULL
                   AND ((bl.start_date > g_spread_from_date )
                        OR (g_spread_from_date between bl.start_date and bl.end_date)
                       )
              )
        )
        AND ( (g_source_context <> 'BUDGET_LINE' )
        OR
        (g_source_context = 'BUDGET_LINE'
         AND tmp.start_date IS NOT NULL AND tmp.end_date IS NOT NULL
                 AND bl.start_date BETWEEN tmp.start_date AND tmp.end_date
            )
         )
    );
Line: 6155

    g_stage := 'populate_rollup_tmp:101: Number of rows Inserted['||sql%rowcount||']';
Line: 6156

    /* Now update rollup tmp override with any override rates passed along with currency code overrides */
    IF (NVL(g_refresh_rates_flag,'N') = 'N'
        AND NVL(g_mass_adjust_flag,'N') = 'N'
        AND NVL(g_refresh_conv_rates_flag,'N') = 'N'
        AND g_applyProg_RaId_tab.COUNT = 0 ) Then
       g_stage := 'populate_rollup_tmp:102';
Line: 6162

       UPDATE /*+ INDEX(TMP PA_FP_ROLLUP_TMP_N1) */ pa_fp_rollup_tmp tmp
       SET (tmp.rw_cost_rate_override
        ,tmp.burden_cost_rate_override
        ,tmp.bill_rate_override) =
        (SELECT  decode(caltmp.txn_curr_code_override,NULL,decode(caltmp.mfc_cost_change_flag,'Y',caltmp.cost_rate_override
                        ,tmp.rw_cost_rate_override),caltmp.cost_rate_override)
            ,decode(caltmp.txn_curr_code_override,NULL,decode(caltmp.mfc_cost_change_flag,'Y',caltmp.burden_cost_rate_override
                        ,tmp.burden_cost_rate_override),caltmp.burden_cost_rate_override)
            ,decode(caltmp.txn_curr_code_override,NULL,decode(caltmp.mfc_cost_change_flag,'Y',caltmp.bill_rate_override
                        ,tmp.bill_rate_override),caltmp.bill_rate_override)
        FROM pa_fp_spread_calc_tmp caltmp
        WHERE caltmp.budget_version_id = tmp.budget_version_id
        AND   caltmp.resource_assignment_id = tmp.resource_assignment_id
        AND   caltmp.txn_currency_code = tmp.txn_currency_code
        AND   NVL(caltmp.skip_record_flag,'N') <> 'Y'
        AND  (NVL(g_refresh_rates_flag,'N') = 'N'
                    AND NVL(caltmp.refresh_conv_rates_flag,'N') = 'N'
                    AND NVL(caltmp.mass_adjust_flag,'N') = 'N'
                    AND NVL(caltmp.mfc_cost_refresh_flag,'N') = 'Y'
                 ))
       WHERE tmp.budget_version_id = p_budget_version_id
       AND EXISTS ( select null
            FROM pa_fp_spread_calc_tmp caltmp
                    WHERE caltmp.budget_version_id = tmp.budget_version_id
                    AND   caltmp.resource_assignment_id = tmp.resource_assignment_id
                    AND   caltmp.txn_currency_code = tmp.txn_currency_code
                    AND   NVL(caltmp.skip_record_flag,'N') <> 'Y'
                    AND  (NVL(g_refresh_rates_flag,'N') = 'N'
                            AND NVL(caltmp.refresh_conv_rates_flag,'N') = 'N'
                            AND NVL(caltmp.mass_adjust_flag,'N') = 'N'
                            AND NVL(caltmp.mfc_cost_refresh_flag,'N') = 'Y'
                        ));
Line: 6200

    /* If only rates are changed then update the changed override rates on rollup tmp and avoid calling spread
     * and call rate api
     */
    IF g_rtChanged_RaId_tab.COUNT > 0 Then
        g_stage := 'populate_rollup_tmp:103';
Line: 6209

        UPDATE /*+ INDEX(TMP PA_FP_ROLLUP_TMP_N1) */ pa_fp_rollup_tmp tmp
        SET (tmp.rw_cost_rate_override
	    ,tmp.burden_cost_rate_override
	    ,tmp.bill_rate_override ) =
		  (SELECT   decode(NVL(g_rtChanged_cstMisNumFlg_tab(i),'N'),'Y',NULL
                            ,NVL(g_rtChanged_CostRt_Tab(i),tmp.rw_cost_rate_override))
                    ,decode(NVL(g_rtChanged_bdMisNumFlag_tab(i),'N'),'Y',NULL
                            ,decode(tmp.rate_based_flag,'Y',NVL(g_rtChanged_BurdRt_tab(i),tmp.burden_cost_rate_override)
			      ,decode(g_fp_budget_version_type,'ALL'
				,decode(caltmp.burden_cost_changed_flag,'Y',NVL(g_rtChanged_BurdRt_tab(i),tmp.burden_cost_rate_override)
				   ,decode(caltmp.raw_cost_changed_flag,'Y'
					,decode(tmp.rw_cost_rate_override,NULL,tmp.burden_cost_rate_override
					  ,0,NVL(g_rtChanged_BurdRt_tab(i),tmp.burden_cost_rate_override), tmp.burden_cost_rate_override)
						,NVL(g_rtChanged_BurdRt_tab(i),tmp.burden_cost_rate_override)))
				 ,NVL(g_rtChanged_BurdRt_tab(i),tmp.burden_cost_rate_override))))
                    ,decode(NVL(g_rtChanged_blMisNumFlag_tab(i),'N'),'Y',NULL
                            ,NVL(g_rtChanged_billRt_tab(i),tmp.bill_rate_override))
		  FROM pa_fp_spread_calc_tmp caltmp
		  WHERE caltmp.resource_assignment_id = tmp.resource_assignment_id
		  AND   caltmp.txn_currency_code = tmp.txn_currency_code
		  AND   ((g_source_context <> 'BUDGET_LINE')
              		OR
            		 ((g_source_context = 'BUDGET_LINE')
             		  and tmp.start_date BETWEEN caltmp.start_date and caltmp.end_date)
			)
		)
        WHERE tmp.budget_version_id = p_budget_version_id
        AND   tmp.resource_assignment_id = g_rtChanged_RaId_tab(i)
        AND   tmp.txn_currency_code = g_rtChanged_TxnCur_tab(i)
        AND   ((g_source_context <> 'BUDGET_LINE')
              OR
            ((g_source_context = 'BUDGET_LINE')
             and tmp.start_date IS NOT NULL
             and tmp.start_date BETWEEN g_rtChanged_sDate_tab(i) AND g_rtChanged_eDate_tab(i)
            )
              );
Line: 6246

        print_msg('Number of rows updated for RateChanges['||sql%rowcount||']');
Line: 6253

            SELECT count(*)
            INTO l_count
            FROM pa_fp_rollup_tmp ;
Line: 6257

            print_msg('Num of rows inserted into rollup Temp['||l_count||']');
Line: 6330

        SELECT tmp.resource_assignment_id
            ,tmp.txn_currency_code
            ,max(tmp.start_date)
            ,MAX(tmp.budget_line_id)
            ,NVL(tmp.rate_based_flag,'N') rate_based_flag
            ,decode(g_wp_version_flag,'Y',(sum(nvl(tmp.old_quantity,0) - nvl(tmp.init_quantity,0)) * ((l_quantity_adj_pct + 100)/100))
		, decode(NVL(tmp.rate_based_flag,'N'),'N',0
			,((sum(nvl(tmp.old_quantity,0) - nvl(tmp.init_quantity,0)) * ((l_quantity_adj_pct + 100)/100))))) unRndOldQty
            ,decode(g_wp_version_flag,'Y',(sum(nvl(tmp.quantity,0) - nvl(tmp.init_quantity,0)))
		,decode(NVL(tmp.rate_based_flag,'N'),'N',0,(sum(nvl(tmp.quantity,0) - nvl(tmp.init_quantity,0))))) RndNewQty
            ,to_number(null) Quantity_diff
	    /* amount adjustments is allowed only for financial side */
	    ,decode(g_wp_version_flag,'Y',0
		,decode(NVL(tmp.rate_based_flag,'N'),'Y',0
		  ,((sum(nvl(tmp.old_txn_raw_cost,0) - nvl(tmp.txn_init_raw_cost,0)) * ((l_raw_cost_adj_pct + 100)/100))))) unRndRawCost
	    ,decode(g_wp_version_flag,'Y',0
                ,decode(NVL(tmp.rate_based_flag,'N'),'Y',0
                  ,(sum(nvl(tmp.txn_raw_cost,0) - nvl(tmp.txn_init_raw_cost,0))))) RndRawCost
            ,to_number(null) RawCostDiff
	    ,decode(g_wp_version_flag,'Y',0
                ,decode(NVL(tmp.rate_based_flag,'N'),'Y',0
		  ,((sum(nvl(tmp.old_txn_revenue,0) - nvl(tmp.txn_init_revenue,0)) * ((l_revenue_adj_pct + 100)/100))))) unRndrevenue
	    ,decode(g_wp_version_flag,'Y',0
                ,decode(NVL(tmp.rate_based_flag,'N'),'Y',0
                  ,(sum(nvl(tmp.txn_revenue,0) - nvl(tmp.txn_init_revenue,0))))) RndRevenue
            ,to_number(null) RevenueDiff
        FROM  pa_fp_rollup_tmp tmp
         ,pa_fp_spread_calc_tmp caltmp
        WHERE caltmp.budget_version_id = p_budget_version_id
        AND  caltmp.resource_assignment_id = tmp.resource_assignment_id
        AND  tmp.txn_currency_code      = caltmp.txn_currency_code
        AND  nvl(caltmp.skip_record_flag,'N') <> 'Y'
        AND  nvl(caltmp.mass_adjust_flag,'N') = 'Y'
        GROUP BY tmp.resource_assignment_id,tmp.txn_currency_code,tmp.rate_based_flag
        ORDER BY tmp.resource_assignment_id,tmp.txn_currency_code;
Line: 6391

     	UPDATE /*+ INDEX(TMP PA_FP_ROLLUP_TMP_N1) */ pa_fp_rollup_tmp tmp
     	SET    tmp.old_quantity = decode(l_quantity_adj_pct,NULL,to_number(NULL),tmp.quantity)
            ,tmp.quantity = decode(l_quantity_adj_pct,NULL,tmp.quantity
                   ,decode(NVL(tmp.rate_based_flag,'N'),'N'
                     ,(NVL(tmp.init_quantity,0)+ pa_currency.round_trans_currency_amt1 (
                    ((NVL(tmp.quantity,0) - nvl(tmp.init_quantity,0))
                         * ((l_quantity_adj_pct + 100)/100)),tmp.txn_currency_code))
                        ,(NVL(tmp.init_quantity,0)+ Round(((NVL(tmp.quantity,0) - nvl(tmp.init_quantity,0))
                       * ((l_quantity_adj_pct + 100)/100)),5)))
                    )
            ,tmp.rw_cost_rate_override =
                decode(NVL(tmp.rate_based_flag,'N'),'N',tmp.rw_cost_rate_override
                                   ,Decode(l_cost_rate_adj_pct,NULL,tmp.rw_cost_rate_override
                           ,(NVL(tmp.rw_cost_rate_override,tmp.cost_rate)
                            * ((l_cost_rate_adj_pct + 100)/100)))
                    )
            ,tmp.burden_cost_rate_override =
                Decode(l_burdened_rate_adj_pct,NULL
			,Decode(l_cost_rate_adj_pct,NULL,tmp.burden_cost_rate_override
                           ,Decode(tmp.burden_cost_rate_override,NULL,tmp.burden_cost_rate_override
                              ,decode(NVL(tmp.rw_cost_rate_override,nvl(tmp.cost_rate,0)),0,tmp.burden_cost_rate_override
                                    ,((tmp.burden_cost_rate_override / NVL(tmp.rw_cost_rate_override,tmp.cost_rate))
                                        * (NVL(tmp.rw_cost_rate_override,tmp.cost_rate)* ((l_cost_rate_adj_pct + 100)/100))))))
                        , (NVL(tmp.burden_cost_rate_override,tmp.burden_cost_rate)
                            * ((l_burdened_rate_adj_pct + 100)/100))
                        )
        WHERE tmp.budget_version_id = p_budget_version_id
    	AND  EXISTS ( select null
            from pa_fp_spread_calc_tmp caltmp
                WHERE  caltmp.resource_assignment_id = tmp.resource_assignment_id
                AND  caltmp.txn_currency_code      = tmp.txn_currency_code
                AND  nvl(caltmp.skip_record_flag,'N') <> 'Y'
                AND  nvl(caltmp.mass_adjust_flag,'N') = 'Y'
           );
Line: 6425

        g_stage := 'mass_adjust:102: Number of rows Updated['||sql%rowcount||']';
Line: 6434

           UPDATE /*+ INDEX(TMP PA_FP_ROLLUP_TMP_N1) */ pa_fp_rollup_tmp tmp
           SET    tmp.old_quantity = decode(NVL(tmp.rate_based_flag,'N'),'N',tmp.quantity
						,decode(l_quantity_adj_pct,NULL,to_number(NULL),tmp.quantity))
            ,tmp.quantity = decode(NVL(tmp.rate_based_flag,'N'),'N',tmp.quantity
				,decode(l_quantity_adj_pct,NULL,tmp.quantity
                   		  ,decode(NVL(tmp.rate_based_flag,'N'),'N'
                     		     ,(NVL(tmp.init_quantity,0)+ pa_currency.round_trans_currency_amt1 (
                    				((NVL(tmp.quantity,0) - nvl(tmp.init_quantity,0))
                         			* ((l_quantity_adj_pct + 100)/100)),tmp.txn_currency_code))
                        		,(NVL(tmp.init_quantity,0)+ Round(((NVL(tmp.quantity,0) - nvl(tmp.init_quantity,0))
                       				* ((l_quantity_adj_pct + 100)/100)),5)))
                    		 ))
            ,tmp.rw_cost_rate_override =
                decode(NVL(tmp.rate_based_flag,'N'),'N',tmp.rw_cost_rate_override
                                   ,Decode(l_cost_rate_adj_pct,NULL,tmp.rw_cost_rate_override
                           ,(NVL(tmp.rw_cost_rate_override,tmp.cost_rate)
                            * ((l_cost_rate_adj_pct + 100)/100)))
                    )
            ,tmp.burden_cost_rate_override =
                Decode(l_burdened_rate_adj_pct,NULL,decode(NVL(tmp.rate_based_flag,'N'),'N',tmp.burden_cost_rate_override
				,Decode(l_cost_rate_adj_pct,NULL,tmp.burden_cost_rate_override
				   ,Decode(tmp.burden_cost_rate_override,NULL,tmp.burden_cost_rate_override,1,NULL
					  ,decode(NVL(tmp.rw_cost_rate_override,nvl(tmp.cost_rate,0)),0,tmp.burden_cost_rate_override
					     ,((tmp.burden_cost_rate_override / NVL(tmp.rw_cost_rate_override,tmp.cost_rate))
						* (NVL(tmp.rw_cost_rate_override,tmp.cost_rate)* ((l_cost_rate_adj_pct + 100)/100)))))))
                                      , (NVL(tmp.burden_cost_rate_override,tmp.burden_cost_rate)
                        * ((l_burdened_rate_adj_pct + 100)/100))
                        )
            ,tmp.bill_rate_override  =
                DECODE(l_bill_rate_adj_pct ,NULL,decode(l_cost_rate_adj_pct,NULL,tmp.bill_rate_override
			,decode(g_fp_budget_version_type,'COST',tmp.bill_rate_override,'REVENUE',tmp.bill_rate_override
			     ,decode(NVL(tmp.rate_based_flag,'N'),'N',tmp.bill_rate_override
				,decode(NVL(tmp.rw_cost_rate_override,nvl(tmp.cost_rate,0)),0,tmp.bill_rate_override
				  ,decode(tmp.bill_rate_override,1,NULL,NULL,NULL
					,((tmp.bill_rate_override / NVL(tmp.rw_cost_rate_override,tmp.cost_rate))
					  * (NVL(tmp.rw_cost_rate_override,tmp.cost_rate)* ((l_cost_rate_adj_pct + 100)/100))))))))
                           ,Decode(g_fp_budget_version_type,'COST',tmp.bill_rate_override
                    ,'REVENUE',Decode(NVL(tmp.rate_based_flag,'N'),'N',tmp.bill_rate_override
                        ,Decode(NVL(tmp.billable_flag,'N'),'Y'
                          ,(NVL(tmp.bill_rate_override,tmp.bill_rate) *
                            ((l_bill_rate_adj_pct + 100)/100))
                            ,(nvl(tmp.bill_rate_override,tmp.bill_rate) * ((l_bill_rate_adj_pct + 100)/100))))
                    ,'ALL',Decode(NVL(tmp.rate_based_flag,'N'),'N',tmp.bill_rate_override
			  ,Decode(NVL(tmp.billable_flag,'N'),'Y'
                        , (NVL(tmp.bill_rate_override,tmp.bill_rate) *
                        ((l_bill_rate_adj_pct + 100)/100))
                        ,(nvl(tmp.bill_rate_override,tmp.bill_rate) * ((l_bill_rate_adj_pct + 100)/100))))
                    ))
           WHERE tmp.budget_version_id = p_budget_version_id
           AND  EXISTS ( select null
            	from pa_fp_spread_calc_tmp caltmp
                WHERE  caltmp.resource_assignment_id = tmp.resource_assignment_id
                AND  caltmp.txn_currency_code      = tmp.txn_currency_code
                AND  nvl(caltmp.skip_record_flag,'N') <> 'Y'
                AND  nvl(caltmp.mass_adjust_flag,'N') = 'Y'
           );
Line: 6490

           g_stage := 'mass_adjust:104: Number of rows Updated['||sql%rowcount||']';
Line: 6493

		UPDATE /*+ INDEX(TMP PA_FP_ROLLUP_TMP_N1) */ pa_fp_rollup_tmp tmp
           	SET    tmp.old_txn_raw_cost =
				decode(l_raw_cost_adj_pct,NULL,to_number(null),tmp.txn_raw_cost)
		       ,tmp.old_txn_revenue =
				decode(l_revenue_adj_pct,NULL,to_number(null),tmp.txn_revenue)
		       ,tmp.txn_raw_cost =
				decode(l_raw_cost_adj_pct,NULL,tmp.txn_raw_cost
				   ,decode(tmp.txn_raw_cost,NULL,NULL,0,0
					,(NVL(tmp.txn_init_raw_cost,0)+ pa_currency.round_trans_currency_amt1 (
                                           ((NVL(tmp.txn_raw_cost,0) - nvl(tmp.txn_init_raw_cost,0))
                                             * ((l_raw_cost_adj_pct + 100)/100)),tmp.txn_currency_code))))
		       ,tmp.txn_revenue =
				decode(l_revenue_adj_pct,NULL,tmp.txn_revenue
                                   ,decode(tmp.txn_revenue,NULL,NULL,0,0
                                        ,(NVL(tmp.txn_init_revenue,0)+ pa_currency.round_trans_currency_amt1 (
                                           ((NVL(tmp.txn_revenue,0) - nvl(tmp.txn_init_revenue,0))
                                             * ((l_revenue_adj_pct + 100)/100)),tmp.txn_currency_code))))
		       ,tmp.quantity = decode(NVL(tmp.rate_based_flag,'N'),'Y',tmp.quantity
					 ,decode(l_raw_cost_adj_pct,NULL
					 ,decode(l_revenue_adj_pct, NULL, tmp.quantity
					    ,decode(g_fp_budget_version_type,'COST',tmp.quantity
						 ,'REVENUE', (NVL(tmp.txn_init_revenue,0)+ pa_currency.round_trans_currency_amt1 (
                                           			((NVL(tmp.txn_revenue,0) - nvl(tmp.txn_init_revenue,0))
                                             				* ((l_revenue_adj_pct + 100)/100)),tmp.txn_currency_code))
						,'ALL',decode(nvl(tmp.rw_cost_rate_override,0),0
								,(NVL(tmp.txn_init_revenue,0)+ pa_currency.round_trans_currency_amt1 (
                                                                ((NVL(tmp.txn_revenue,0) - nvl(tmp.txn_init_revenue,0))
                                                                        * ((l_revenue_adj_pct + 100)/100)),tmp.txn_currency_code))
							       ,tmp.quantity)))
					    ,decode(g_fp_budget_version_type,'REVENUE',tmp.quantity
						,'COST',(NVL(tmp.txn_init_raw_cost,0)+ pa_currency.round_trans_currency_amt1 (
                                           		   ((NVL(tmp.txn_raw_cost,0) - nvl(tmp.txn_init_raw_cost,0))
                                             		    * ((l_raw_cost_adj_pct + 100)/100)),tmp.txn_currency_code))
						,'ALL',decode(nvl(tmp.rw_cost_rate_override,0),0,tmp.quantity
							,(NVL(tmp.txn_init_raw_cost,0)+ pa_currency.round_trans_currency_amt1 (
                                                           ((NVL(tmp.txn_raw_cost,0) - nvl(tmp.txn_init_raw_cost,0))
                                                            * ((l_raw_cost_adj_pct + 100)/100)),tmp.txn_currency_code))))))
		       ,tmp.burden_cost_rate_override =
                		Decode(g_fp_budget_version_type,'REVENUE',tmp.burden_cost_rate_override
				 ,Decode(l_burden_cost_adj_pct,NULL
				 ,Decode(l_raw_cost_adj_pct,NULL,tmp.burden_cost_rate_override
                                   ,decode(NVL(tmp.rate_based_flag,'N'),'N',tmp.burden_cost_rate_override
				      ,Decode(tmp.burden_cost_rate_override,NULL,tmp.burden_cost_rate_override,1,NULL
					,decode((nvl(tmp.quantity,0) - nvl(tmp.init_quantity,0)),0,tmp.burden_cost_rate_override
                                          ,decode(NVL(tmp.rw_cost_rate_override,nvl(tmp.cost_rate,0)),0,tmp.burden_cost_rate_override
                                             ,((tmp.burden_cost_rate_override / NVL(tmp.rw_cost_rate_override,tmp.cost_rate))
                                                * (NVL(tmp.rw_cost_rate_override,tmp.cost_rate)* ((l_raw_cost_adj_pct+ 100)/100))))))))
                                      	,(NVL(tmp.burden_cost_rate_override,tmp.burden_cost_rate)
                        			* ((l_burden_cost_adj_pct + 100)/100))
                        		))
		       ,tmp.bill_rate_override =
				decode(g_fp_budget_version_type,'COST', tmp.bill_rate_override
				 ,'REVENUE', decode(l_revenue_adj_pct,NULL,tmp.bill_rate_override
					,decode(NVL(tmp.rate_based_flag,'N'),'N',tmp.bill_rate_override
					 ,(NVL(tmp.bill_rate_override,tmp.bill_rate) * ((l_revenue_adj_pct + 100)/100))))
				,'ALL' , Decode(l_raw_cost_adj_pct,NULL
					  ,decode(l_revenue_adj_pct,NULL,tmp.bill_rate_override
					   ,decode(NVL(tmp.rate_based_flag,'N'),'Y'
						,(NVL(tmp.bill_rate_override,tmp.bill_rate) * ((l_revenue_adj_pct + 100)/100))
						,decode(NVL(tmp.rw_cost_rate_override,0),0,tmp.bill_rate_override
						 ,(NVL(tmp.bill_rate_override,tmp.bill_rate) * ((l_revenue_adj_pct + 100)/100)))))
					  ,decode(NVL(tmp.rate_based_flag,'N'),'N',tmp.bill_rate_override
					   ,decode((nvl(tmp.quantity,0) - nvl(tmp.init_quantity,0)),0,tmp.bill_rate_override
					    ,decode(NVL(tmp.rw_cost_rate_override,nvl(tmp.cost_rate,0)),0,tmp.bill_rate_override
						,((tmp.bill_rate_override / NVL(tmp.rw_cost_rate_override,tmp.cost_rate))
                                                * (NVL(tmp.rw_cost_rate_override,tmp.cost_rate)* ((l_raw_cost_adj_pct+ 100)/100)))))))
					)
		       ,tmp.rw_cost_rate_override =
                                decode(l_raw_cost_adj_pct,NULL,tmp.rw_cost_rate_override
				 ,decode((nvl(tmp.quantity,0) - nvl(tmp.init_quantity,0)),0,tmp.rw_cost_rate_override
                                  ,decode(NVL(tmp.rate_based_flag,'N'),'N',tmp.rw_cost_rate_override
                                   ,Decode(l_raw_cost_adj_pct,NULL,tmp.rw_cost_rate_override
                                     ,(NVL(tmp.rw_cost_rate_override,tmp.cost_rate)
                                       * ((l_raw_cost_adj_pct + 100)/100))))))
		WHERE tmp.budget_version_id = p_budget_version_id
                AND  EXISTS ( select null
                		from pa_fp_spread_calc_tmp caltmp
                		WHERE  caltmp.resource_assignment_id = tmp.resource_assignment_id
                		AND  caltmp.txn_currency_code      = tmp.txn_currency_code
                		AND  nvl(caltmp.skip_record_flag,'N') <> 'Y'
                		AND  nvl(caltmp.mass_adjust_flag,'N') = 'Y' );
Line: 6580

            l_raId_tab.delete;
Line: 6581

            l_txn_cur_tab.delete;
Line: 6582

            l_sdate_tab.delete;
Line: 6583

            l_blId_tab.delete;
Line: 6584

            l_ratebase_tab.delete;
Line: 6585

            l_quantity_old_tab.delete;
Line: 6586

        l_quantity_new_tab.delete;
Line: 6587

        l_quantity_diff_tab.delete;
Line: 6588

	l_rawCost_new_tab.delete;
Line: 6589

        l_rawcost_old_tab.delete;
Line: 6590

        l_rawcost_diff_tab.delete;
Line: 6591

	l_revenue_new_tab.delete;
Line: 6592

        l_revenue_old_tab.delete;
Line: 6593

        l_revenue_diff_tab.delete;
Line: 6630

            UPDATE pa_fp_rollup_tmp tmp
            SET tmp.quantity = tmp.quantity + nvl(l_quantity_diff_tab(i),0)
            WHERE tmp.budget_line_id = l_blId_tab(i)
            AND NVL(l_quantity_diff_tab(i),0) <> 0;
Line: 6651

            UPDATE pa_fp_rollup_tmp tmp
            SET tmp.quantity = decode(g_fp_budget_version_type,'REVENUE', tmp.quantity
				,'COST', (tmp.txn_raw_cost + nvl(l_rawcost_diff_tab(i),0))
				,'ALL',decode(tmp.rw_cost_rate_override,0,tmp.quantity,NULL,tmp.quantity
					,(tmp.txn_raw_cost + nvl(l_rawcost_diff_tab(i),0))))
	       ,tmp.txn_raw_cost = decode(g_fp_budget_version_type,'REVENUE', tmp.txn_raw_cost
                                ,'COST', (tmp.txn_raw_cost + nvl(l_rawcost_diff_tab(i),0))
                                ,'ALL',decode(tmp.rw_cost_rate_override,0,tmp.txn_raw_cost,NULL,tmp.txn_raw_cost
                                        ,(tmp.txn_raw_cost + nvl(l_rawcost_diff_tab(i),0))))
            WHERE tmp.budget_line_id = l_blId_tab(i)
            AND NVL(l_rawcost_diff_tab(i),0) <> 0
	    AND l_ratebase_tab(i) = 'N' ;
Line: 6680

            UPDATE pa_fp_rollup_tmp tmp
            SET tmp.quantity = decode(g_fp_budget_version_type,'COST', tmp.quantity
                                ,'REVENUE', (tmp.txn_revenue + nvl(l_revenue_diff_tab(i),0))
                                ,'ALL',decode(nvl(tmp.rw_cost_rate_override,0),0
					,(tmp.txn_revenue + nvl(l_revenue_diff_tab(i),0)),tmp.quantity))
               ,tmp.txn_revenue = decode(g_fp_budget_version_type,'COST',tmp.txn_revenue
				,'REVENUE', (tmp.txn_revenue + nvl(l_revenue_diff_tab(i),0))
                                ,'ALL', decode(nvl(tmp.rw_cost_rate_override,0),0
                                        ,(tmp.txn_revenue + nvl(l_revenue_diff_tab(i),0)),tmp.quantity))
            WHERE tmp.budget_line_id = l_blId_tab(i)
            AND NVL(l_revenue_diff_tab(i),0) <> 0
            AND l_ratebase_tab(i) = 'N' ;
Line: 6727

    SELECT resource_list_member_id
        FROM pa_resource_assignments
        WHERE resource_assignment_id = p_resource_assignment_id;
Line: 6772

    SELECT /*+ INDEX(PBL PA_BUDGET_LINES_U1) */
	   pbl.resource_assignment_id
           ,DECODE(sum(pbl.quantity),0,NULL,sum(pbl.quantity))                                      pfc_quantity
           ,DECODE(sum(pbl.raw_cost),0,NULL,sum(pbl.raw_cost))                                      pfc_raw_cost
           ,DECODE(sum(pbl.burdened_cost),0,NULL,sum(pbl.burdened_cost))                            pfc_burdened_cost
           ,DECODE(sum(pbl.revenue),0,NULL,sum(pbl.revenue))                                        pfc_revenue
           ,DECODE(sum(pbl.project_raw_cost),0,NULL,sum(pbl.project_raw_cost))                      project_raw_cost
           ,DECODE(sum(pbl.project_burdened_cost),0,NULL,sum(pbl.project_burdened_cost))            project_burdened_cost
           ,DECODE(sum(pbl.project_revenue),0,NULL,sum(pbl.project_revenue))                        project_revenue
           ,DECODE(sum(pbl.init_quantity),0,NULL,sum(pbl.init_quantity))                            pfc_init_quantity
           ,DECODE(sum(pbl.init_raw_cost),0,NULL,sum(pbl.init_raw_cost))                            pfc_init_raw_cost
           ,DECODE(sum(pbl.init_burdened_cost),0,NULL,sum(pbl.init_burdened_cost))                  pfc_init_burdened_cost
           ,DECODE(sum(pbl.init_revenue),0,NULL,sum(pbl.init_revenue))                              pfc_init_revenue
           ,DECODE(sum(pbl.project_init_raw_cost),0,NULL,sum(pbl.project_init_raw_cost))            project_init_raw_cost
           ,DECODE(sum(pbl.project_init_burdened_cost),0,NULL,sum(pbl.project_init_burdened_cost))  project_init_burdened_cost
           ,DECODE(sum(pbl.project_init_revenue),0,NULL,sum(pbl.project_init_revenue))              project_init_revenue
        FROM pa_budget_lines pbl
	WHERE pbl.budget_version_id = p_budget_version_id
    	AND EXISTS (SELECT NULL
                    FROM pa_fp_spread_calc_tmp tmp
                    WHERE tmp.budget_version_id = p_budget_version_id
                    AND   tmp.resource_assignment_id = pbl.resource_assignment_id
                   )
     GROUP BY pbl.resource_assignment_id;
Line: 6802

    SELECT
           pbl.resource_assignment_id
           ,DECODE(sum(pbl.quantity),0,NULL,sum(pbl.quantity))                                      pfc_quantity
           ,DECODE(sum(pbl.raw_cost),0,NULL,sum(pbl.raw_cost))                                      pfc_raw_cost
           ,DECODE(sum(pbl.burdened_cost),0,NULL,sum(pbl.burdened_cost))                            pfc_burdened_cost
           ,DECODE(sum(pbl.revenue),0,NULL,sum(pbl.revenue))                                        pfc_revenue
           ,DECODE(sum(pbl.project_raw_cost),0,NULL,sum(pbl.project_raw_cost))                      project_raw_cost
           ,DECODE(sum(pbl.project_burdened_cost),0,NULL,sum(pbl.project_burdened_cost))            project_burdened_cost
           ,DECODE(sum(pbl.project_revenue),0,NULL,sum(pbl.project_revenue))                        project_revenue
           ,DECODE(sum(pbl.init_quantity),0,NULL,sum(pbl.init_quantity))                            pfc_init_quantity
           ,DECODE(sum(pbl.init_raw_cost),0,NULL,sum(pbl.init_raw_cost))                            pfc_init_raw_cost
           ,DECODE(sum(pbl.init_burdened_cost),0,NULL,sum(pbl.init_burdened_cost))                  pfc_init_burdened_cost
           ,DECODE(sum(pbl.init_revenue),0,NULL,sum(pbl.init_revenue))                              pfc_init_revenue
           ,DECODE(sum(pbl.project_init_raw_cost),0,NULL,sum(pbl.project_init_raw_cost))            project_init_raw_cost
           ,DECODE(sum(pbl.project_init_burdened_cost),0,NULL,sum(pbl.project_init_burdened_cost))  project_init_burdened_cost
           ,DECODE(sum(pbl.project_init_revenue),0,NULL,sum(pbl.project_init_revenue))              project_init_revenue
        FROM pa_budget_lines pbl
        WHERE pbl.budget_version_id = p_budget_version_id
     GROUP BY pbl.resource_assignment_id;
Line: 6849

    UPDATE PA_RESOURCE_ASSIGNMENTS ra
        SET ra.total_plan_quantity = null
              ,ra.total_plan_raw_cost = null
              ,ra.total_plan_burdened_cost = null
              ,ra.total_plan_revenue = null
              ,ra.total_project_raw_cost = null
              ,ra.total_project_burdened_cost = null
              ,ra.total_project_revenue = null
              ,ra.last_updated_by = l_user_id
              ,ra.last_update_date = sysdate
              ,ra.last_update_login =  l_login_id
        WHERE EXISTS (SELECT NULL
                    FROM pa_fp_spread_calc_tmp tmp
                    WHERE tmp.budget_version_id = p_budget_version_id
                    AND   tmp.resource_assignment_id = ra.resource_assignment_id
            /* Bug fix: 4322568 AND  NVL(tmp.skip_record_flag,'N') = 'Y' */
                   );
Line: 6911

       UPDATE PA_RESOURCE_ASSIGNMENTS ra
       SET ra.total_plan_quantity = l_pfc_quantity_tab(i)
                    ,ra.total_plan_raw_cost = l_pfc_raw_cost_tab(i)
                    ,ra.total_plan_burdened_cost = l_pfc_burden_cost_tab(i)
                    ,ra.total_plan_revenue = l_pfc_revenue_tab(i)
                    ,ra.total_project_raw_cost = l_project_raw_cost_tab(i)
                    ,ra.total_project_burdened_cost = l_project_burden_cost_tab(i)
                    ,ra.total_project_revenue = l_project_revenue_tab(i)
            ,ra.last_updated_by = l_user_id
            ,ra.last_update_date = sysdate
            ,ra.last_update_login =  l_login_id
       WHERE ra.resource_assignment_id = l_resource_assignment_id_tab(i);
Line: 6959

      SELECT DECODE(sum(total_plan_revenue),0,NULL,
                        sum(total_plan_revenue))                             total_plan_revenue
            ,DECODE(sum(total_plan_raw_cost),0,NULL,
                        sum(total_plan_raw_cost))                            total_plan_raw_cost
            ,DECODE(sum(total_plan_burdened_cost),0,NULL,
                        sum(total_plan_burdened_cost))                       total_plan_burdened_cost
        /* Bug fix: 3968340. rollup the labor and equipment effort only if the uom is HOURS
         * the following code is commented out and added the new decode
            ,DECODE(sum(decode(resource_class_code,'PEOPLE',total_plan_quantity,to_number(null))),0,NULL,
                        sum(decode(resource_class_code,'PEOPLE',total_plan_quantity,to_number(null))))
                                                                             total_labor_quantity
            ,DECODE(sum(decode(resource_class_code,'EQUIPMENT',total_plan_quantity,to_number(null))),0,NULL,
                        sum(decode(resource_class_code,'EQUIPMENT',total_plan_quantity,to_number(null))))
                                                                             total_equipment_quantity
        */
            ,DECODE(sum(decode(resource_class_code,'PEOPLE'
                ,decode(pra.unit_of_measure,'HOURS',total_plan_quantity,to_number(null))
                               ,to_number(null))),0,NULL
                        ,sum(decode(resource_class_code,'PEOPLE'
                     ,decode(pra.unit_of_measure,'HOURS',total_plan_quantity,to_number(null))
                          ,to_number(null))
            )) total_labor_quantity
            ,DECODE(sum(decode(resource_class_code,'EQUIPMENT'
                       ,decode(pra.unit_of_measure,'HOURS',total_plan_quantity,to_number(null))
                           ,to_number(null))),0,NULL
                        ,sum(decode(resource_class_code,'EQUIPMENT'
                     ,decode(pra.unit_of_measure,'HOURS',total_plan_quantity,to_number(null))
                  ,to_number(null))
               ))total_equipment_quantity
            ,DECODE(sum(total_project_raw_cost),0,NULL,
                        sum(total_project_raw_cost))                         total_project_raw_cost
            ,DECODE(sum(total_project_burdened_cost),0,NULL,
                        sum(total_project_burdened_cost))                    total_project_burdened_cost
            ,DECODE(sum(total_project_revenue),0,NULL,
                        sum(total_project_revenue))                          total_project_revenue
        FROM pa_resource_assignments pra
        WHERE pra.budget_version_id = p_budget_version_id
    AND  pra.project_id = g_project_id;
Line: 7018

        UPDATE  pa_budget_versions SET
                raw_cost                      = to_number(NULL)
               ,burdened_cost                 = to_number(NULL)
               ,revenue                       = to_number(NULL)
               ,total_project_raw_cost        = to_number(NULL)
               ,total_project_burdened_cost   = to_number(NULL)
               ,total_project_revenue         = to_number(NULL)
               ,labor_quantity                = to_number(NULL)
               ,equipment_quantity            = to_number(NULL)
               ,record_version_number         = NVL(record_version_number,0) + 1
               ,last_update_date              = sysdate
               ,last_updated_by               = fnd_global.user_id
               ,creation_date                 = sysdate
               ,created_by                    = fnd_global.user_id
               ,last_update_login             = fnd_global.login_id
         WHERE budget_version_id = p_budget_version_id;
Line: 7042

            SELECT TO_CHAR(SYSDATE,'DD-MON-YYYY HH:MI:SS') INTO g_session_time
            FROM DUAL;
Line: 7049

    /*print_msg(to_char(l_stage)||'UPDATE pa_budget_versions with the following:');
Line: 7062

        UPDATE  pa_budget_versions
    SET raw_cost                      = rollup_ra_rec.total_plan_raw_cost
               ,burdened_cost                 = rollup_ra_rec.total_plan_burdened_cost
               ,revenue                       = rollup_ra_rec.total_plan_revenue
               ,total_project_raw_cost        = rollup_ra_rec.total_project_raw_cost
               ,total_project_burdened_cost   = rollup_ra_rec.total_project_burdened_cost
               ,total_project_revenue         = rollup_ra_rec.total_project_revenue
               ,labor_quantity                = rollup_ra_rec.total_labor_quantity
               ,equipment_quantity            = rollup_ra_rec.total_equipment_quantity
               ,record_version_number         = NVL(record_version_number,0) + 1
               ,last_update_date              = sysdate
               ,last_updated_by               = fnd_global.user_id
               ,creation_date                 = sysdate
               ,created_by                    = fnd_global.user_id
               ,last_update_login             = fnd_global.login_id
         WHERE budget_version_id = p_budget_version_id;
Line: 7086

            SELECT TO_CHAR(SYSDATE,'DD-MON-YYYY HH:MI:SS') INTO g_session_time
            FROM DUAL;
Line: 7125

    print_msg('Inserting records into fp_res_assignment_tmp table count['||g_sprd_raId_tab.COUNT||']fst['||g_sprd_raId_tab.first||']Lst['||g_sprd_raId_tab.last||']');
Line: 7129

    INSERT INTO PA_FP_RES_ASSIGNMENTS_TMP
            (BUDGET_VERSION_ID
                ,PROJECT_ID
                ,TASK_ID
                ,RESOURCE_LIST_MEMBER_ID
        ,SPREAD_CURVE_ID
        ,SP_FIXED_DATE
        ,SOURCE_CONTEXT
        ,RATE_BASED_FLAG
        ,RESOURCE_ASSIGNMENT_ID
                ,TXN_CURRENCY_CODE
            ,LINE_START_DATE
            ,LINE_END_DATE
            ,PLANNING_START_DATE
        ,PLANNING_END_DATE
            ,TXN_REVENUE
            ,TXN_REVENUE_ADDL
            ,TXN_RAW_COST
            ,TXN_RAW_COST_ADDL
            ,TXN_BURDENED_COST
            ,TXN_BURDENED_COST_ADDL
            ,TXN_PLAN_QUANTITY
            ,TXN_PLAN_QUANTITY_ADDL
            ,TXN_CURRENCY_CODE_OVERRIDE
            ,TXN_INIT_REVENUE
            ,TXN_INIT_RAW_COST
            ,TXN_INIT_BURDENED_COST
            ,INIT_QUANTITY
            ,SPREAD_AMOUNTS_FLAG
            ,RAW_COST_RATE
                ,RW_COST_RATE_OVERRIDE
                ,BURDEN_COST_RATE
                ,BURDEN_COST_RATE_OVERRIDE
                ,BILL_RATE
                ,BILL_RATE_OVERRIDE
        ,PROJECT_CURRENCY_CODE
                ,PROJFUNC_CURRENCY_CODE
		/* bug fix:5726773 : store the value in the sprd table*/
 	        ,NEG_QUANTITY_CHANGE_FLAG --neg_Qty_Change_flag
 	        ,NEG_RAWCOST_CHANGE_FLAG --neg_RawCst_Change_flag
 	        ,NEG_BURDEN_CHANGE_FALG  --neg_BurdCst_Change_flag
 	        ,NEG_REVENUE_CHANGE_FLAG --neg_rev_Change_flag
         )
    VALUES ( p_budget_version_id
        ,g_project_id
        ,g_sprd_task_id_tab(i)
        ,g_sprd_rlm_id_tab(i)
        ,g_sprd_spcurve_id_tab(i)
        ,g_sprd_sp_fixed_date_tab(i)
        ,p_source_context
        ,NVL(g_sprd_ratebase_flag_tab(i),'N')
        ,g_sprd_raId_tab(i)
            ,g_sprd_txn_cur_tab(i)
            ,g_sprd_sdate_tab(i)
            ,g_sprd_edate_tab(i)
            ,g_sprd_plan_sdate_tab(i)
            ,g_sprd_plan_edate_tab(i)
            ,g_sprd_txn_rev_tab(i)
            ,g_sprd_txn_rev_addl_tab(i)
            ,g_sprd_txn_raw_tab(i)
            ,g_sprd_txn_raw_addl_tab(i)
            ,g_sprd_txn_burd_tab(i)
            ,g_sprd_txn_burd_addl_tab(i)
            ,g_sprd_qty_tab(i)
            ,g_sprd_qty_addl_tab(i)
            ,g_sprd_txn_cur_ovr_tab(i)
            ,g_sprd_txn_init_rev_tab(i)
            ,g_sprd_txn_init_raw_tab(i)
            ,g_sprd_txn_init_burd_tab(i)
            ,g_sprd_txn_init_qty_tab(i)
            ,g_sprd_spread_reqd_flag_tab(i)
            ,g_sprd_costRt_tab(i)
            ,g_sprd_costRt_Ovr_tab(i)
            ,g_sprd_burdRt_Tab(i)
            ,g_sprd_burdRt_Ovr_tab(i)
            ,g_sprd_billRt_tab(i)
            ,g_sprd_billRt_Ovr_tab(i)
            ,g_sprd_projCur_tab(i)
            ,g_sprd_projfuncCur_tab(i)
	    /* Bug fix:5463690 */
 	    ,g_sprd_neg_Qty_Changflag_tab(i)
 	    ,g_sprd_neg_Raw_Changflag_tab(i)
 	    ,g_sprd_neg_Burd_Changflag_tab(i)
 	    ,g_sprd_neg_rev_Changflag_tab(i)
        );
Line: 7215

    print_msg('Number of SpreadRecords Inserted['||sql%rowcount||']');
Line: 7315

    Select c.projfunc_cost_exchange_rate
        ,c.projfunc_rev_exchange_rate
        ,c.project_cost_exchange_rate
        ,c.project_rev_exchange_rate
    From pa_fp_txn_currencies c
        where  c.fin_plan_version_id = p_budget_version_id
        and c.txn_currency_code = p_txn_currency_code;
Line: 7326

    select p_budget_line_id
        ,p_resource_assignment_id
        ,r.start_date
        ,r.end_date
        ,p_txn_currency_code
        ,nvl(p_txn_raw_cost,0)
        ,nvl(p_txn_burdened_cost,0)
        ,nvl(p_txn_revenue,0)
        ,nvl(r.projfunc_currency_code,pa_fp_multi_currency_pkg.g_projfunc_currency_code)
        ,nvl(r.projfunc_cost_rate_type,pa_fp_multi_currency_pkg.g_projfunc_cost_rate_type)
        ,DECODE(r.projfunc_cost_exchange_rate,null,
                                            DECODE(nvl(r.projfunc_cost_rate_type,pa_fp_multi_currency_pkg.g_projfunc_cost_rate_type),'User',
                                                                          fp_cur_rec.projfunc_cost_exchange_rate,
                                                                          r.projfunc_cost_exchange_rate),
                                            r.projfunc_cost_exchange_rate)
                                                                            projfunc_cost_exchange_rate
        ,DECODE(nvl(r.projfunc_cost_rate_type,pa_fp_multi_currency_pkg.g_projfunc_cost_rate_type),'User',Null,
                nvl(r.projfunc_cost_rate_date_type,pa_fp_multi_currency_pkg.g_projfunc_cost_rate_date_type))
        ,DECODE(nvl(r.projfunc_cost_rate_date_type,
                    pa_fp_multi_currency_pkg.g_projfunc_cost_rate_date_type),
                'START_DATE',r.start_date,
                'END_DATE'  ,r.end_date,
                nvl(r.projfunc_cost_rate_date,pa_fp_multi_currency_pkg.g_projfunc_cost_rate_date))
                                                         projfunc_cost_rate_date
        ,nvl(r.projfunc_rev_rate_type,pa_fp_multi_currency_pkg.g_projfunc_rev_rate_type)
        ,DECODE(r.projfunc_rev_exchange_rate,null,
                                            DECODE(nvl(r.projfunc_rev_rate_type,pa_fp_multi_currency_pkg.g_projfunc_rev_rate_type),'User',
                                                                          fp_cur_rec.projfunc_rev_exchange_rate,
                                                                          r.projfunc_rev_exchange_rate),
                                            r.projfunc_rev_exchange_rate)
                                                                            projfunc_rev_exchange_rate
        ,DECODE(nvl(r.projfunc_rev_rate_type,pa_fp_multi_currency_pkg.g_projfunc_rev_rate_type),'User',NULL,
                nvl(r.projfunc_rev_rate_date_type,pa_fp_multi_currency_pkg.g_projfunc_rev_rate_date_type))
        ,DECODE(nvl(r.projfunc_rev_rate_date_type,pa_fp_multi_currency_pkg.g_projfunc_rev_rate_date_type),
                'START_DATE',r.start_date,
                'END_DATE'  ,r.end_date,
                nvl(r.projfunc_rev_rate_date,pa_fp_multi_currency_pkg.g_projfunc_rev_rate_date))
                                                          projfunc_rev_rate_date
        ,nvl(r.project_currency_code,pa_fp_multi_currency_pkg.g_proj_currency_code)
        ,nvl(r.project_cost_rate_type,pa_fp_multi_currency_pkg.g_proj_cost_rate_type)
        ,DECODE(r.project_cost_exchange_rate,null,
                                            DECODE(nvl(r.project_cost_rate_type,pa_fp_multi_currency_pkg.g_proj_cost_rate_type),'User',
                                                                          fp_cur_rec.project_cost_exchange_rate,
                                                                          r.project_cost_exchange_rate),
                                            r.project_cost_exchange_rate)
                                                                            project_cost_exchange_rate
        ,DECODE(nvl(r.project_cost_rate_type,pa_fp_multi_currency_pkg.g_proj_cost_rate_type),'User',NULL,
                nvl(r.project_cost_rate_date_type,pa_fp_multi_currency_pkg.g_proj_cost_rate_date_type))
        ,DECODE(nvl(r.project_cost_rate_date_type,pa_fp_multi_currency_pkg.g_proj_cost_rate_date_type),
                'START_DATE',r.start_date,
                'END_DATE'  ,r.end_date,
                nvl(r.project_cost_rate_date,pa_fp_multi_currency_pkg.g_proj_cost_rate_date))
                                                          project_cost_rate_date
        ,nvl(r.project_rev_rate_type,pa_fp_multi_currency_pkg.g_proj_rev_rate_type)
        ,DECODE(r.project_rev_exchange_rate,null,
                                            DECODE(nvl(r.project_rev_rate_type,pa_fp_multi_currency_pkg.g_proj_rev_rate_type),'User',
                                                                          fp_cur_rec.project_rev_exchange_rate,
                                                                          r.project_rev_exchange_rate),
                                            r.project_rev_exchange_rate)
                                                                            project_rev_exchange_rate
        ,DECODE(nvl(r.project_rev_rate_type,pa_fp_multi_currency_pkg.g_proj_rev_rate_type),'User',NULL,
                nvl(r.project_rev_rate_date_type,pa_fp_multi_currency_pkg.g_proj_rev_rate_date_type))
        ,DECODE(nvl(r.project_rev_rate_date_type,pa_fp_multi_currency_pkg.g_proj_rev_rate_date_type),
                'START_DATE',r.start_date,
                'END_DATE'  ,r.end_date,
                nvl(r.project_rev_rate_date,pa_fp_multi_currency_pkg.g_proj_rev_rate_date))
                                                           project_rev_rate_date
        from pa_fp_rollup_tmp r
    where nvl(r.delete_flag,'N') = 'N'
        and r.budget_line_id = p_budget_line_id
    order by r.resource_assignment_id,
            r.start_date,
            r.txn_currency_code;
Line: 7431

       l_bl_id_tab.delete;
Line: 7432

       l_resource_assignment_id_tab.delete;
Line: 7433

       l_start_date_tab.delete;
Line: 7434

       l_end_date_tab.delete;
Line: 7435

       l_txn_currency_code_tab.delete;
Line: 7436

       l_txn_raw_cost_tab.delete;
Line: 7437

       l_txn_burdened_cost_tab.delete;
Line: 7438

       l_txn_revenue_tab.delete;
Line: 7439

       l_projfunc_currency_code_tab.delete;
Line: 7440

       l_projfunc_cost_rate_type_tab.delete;
Line: 7441

       l_projfunc_cost_rate_tab.delete;
Line: 7442

       l_projfunc_cost_rt_dt_typ_tab.delete;
Line: 7443

       l_projfunc_cost_rate_date_tab.delete;
Line: 7444

       l_projfunc_rev_rate_type_tab.delete;
Line: 7445

       l_projfunc_rev_rate_tab.delete;
Line: 7446

       l_projfunc_rev_rt_dt_typ_tab.delete;
Line: 7447

       l_projfunc_rev_rate_date_tab.delete;
Line: 7448

       l_projfunc_raw_cost_tab.delete;
Line: 7449

       l_projfunc_burdened_cost_tab.delete;
Line: 7450

       l_projfunc_revenue_tab.delete;
Line: 7451

       l_projfunc_rejection_tab.delete;
Line: 7452

       l_proj_currency_code_tab.delete;
Line: 7453

       l_proj_cost_rate_type_tab.delete;
Line: 7454

       l_proj_cost_rate_tab.delete;
Line: 7455

       l_proj_cost_rt_dt_typ_tab.delete;
Line: 7456

       l_proj_cost_rate_date_tab.delete;
Line: 7457

       l_proj_rev_rate_type_tab.delete;
Line: 7458

       l_proj_rev_rate_tab.delete;
Line: 7459

       l_proj_rev_rt_dt_typ_tab.delete;
Line: 7460

       l_proj_rev_rate_date_tab.delete;
Line: 7461

       l_proj_raw_cost_tab.delete;
Line: 7462

       l_proj_burdened_cost_tab.delete;
Line: 7463

       l_proj_revenue_tab.delete;
Line: 7464

       l_proj_rejection_tab.delete;
Line: 7465

       l_user_validate_flag_tab.delete;
Line: 7466

       l_status_flag_tab.delete;
Line: 7613

    select 'Y'
    from dual
    where EXISTS
        (select null
         from pa_budget_lines bl
         where bl.resource_assignment_id = p_res_ass_id
         and (bl.init_quantity is not null
                     or bl.txn_init_raw_cost is not null
             or bl.txn_init_burdened_cost is not null
             or bl.txn_init_revenue is not null )
        );
Line: 7635

/* This API deletes all the budget lines when no quantiy , amounts exists on the budget lines
 * retaining these budget lines create issues during the workplan mode
 * keeping these budget lines will retain the currency code during the resource assignment updates
 */
PROCEDURE Delete_BL_Where_Nulls
                        ( p_budget_version_id        IN  NUmber
                    	,p_resource_assignment_tab   IN  SYSTEM.pa_num_tbl_type   DEFAULT SYSTEM.pa_num_tbl_type()
                        ,x_return_status             OUT NOCOPY varchar2
                        ,x_msg_data                  OUT NOCOPY varchar2
                         ) IS

    	/*Perf Changes: Removed update and added a cusor to fetch the ra+txn currency
	 *This reduces teh cpu time from 350sec to 11sec tested on pjperf instance
         */
	cursor cur_nullBls is
	select tmp1.resource_assignment_id
        	,tmp1.txn_currency_code
        from pa_fp_spread_calc_tmp tmp1
        	,pa_resource_assignments ra
        where tmp1.budget_version_id = p_budget_version_id
        and ra.resource_assignment_id = tmp1.resource_assignment_id
        and NVL(ra.rate_based_flag,'N') = 'N'
        and NOT EXISTS ( select /*+ INDEX(BL PA_BUDGET_LINES_U1) */ null
        	from pa_budget_lines bl
        	where bl.resource_assignment_id = tmp1.resource_assignment_id
        	and bl.txn_currency_code = tmp1.txn_currency_code
        	)
	group by tmp1.resource_assignment_id
                ,tmp1.txn_currency_code;
Line: 7677

    l_budget_line_id_tab.delete;
Line: 7681

               print_msg('Bug fix:4272944: DONOT DELETE AUTOBASELINE zero qty budget lines');
Line: 7686

        print_msg('Delete all the budget lines where Qty and Amounts are not exists');
Line: 7688

    l_budget_line_id_tab.delete;
Line: 7689

    l_raid_tab.delete;
Line: 7690

    l_txn_cur_code_tab.delete;
Line: 7691

    l_start_date_tab.delete;
Line: 7692

    l_end_date_tab.delete;
Line: 7693

    l_period_name_tab.delete;
Line: 7694

    l_proj_cur_code_tab.delete;
Line: 7695

    l_projfunc_cur_code_tab.delete;
Line: 7697

        DELETE FROM pa_budget_lines bl
        WHERE bl.resource_assignment_id = p_resource_assignment_tab(i)
        AND   bl.budget_version_id = p_budget_version_id
        AND   ( nvl(bl.quantity,0) = 0
              and nvl(bl.txn_raw_cost,0) = 0
              and nvl(bl.txn_burdened_cost,0) = 0
              and nvl(bl.txn_revenue,0) = 0
              and nvl(bl.init_quantity,0) = 0
              and nvl(bl.txn_init_raw_cost,0) = 0
              and nvl(bl.txn_init_burdened_cost,0) = 0
              and nvl(bl.txn_init_revenue,0) = 0
             )
        RETURNING bl.budget_line_id
        ,bl.resource_assignment_id
        ,bl.txn_currency_code
        ,bl.start_date
        ,bl.end_date
        ,bl.period_name
        ,bl.project_currency_code
        ,bl.projfunc_currency_code
        BULK COLLECT INTO
         l_budget_line_id_tab
    ,l_raid_tab
        ,l_txn_cur_code_tab
        ,l_start_date_tab
        ,l_end_date_tab
        ,l_period_name_tab
        ,l_proj_cur_code_tab
        ,l_projfunc_cur_code_tab;
Line: 7728

        print_msg('Number of rows deleted ['||l_budget_line_id_tab.count||']');
Line: 7745

                                ,p_delete_flag                  => 'Y'
                                ,x_msg_data                     => x_msg_data
                                ,x_return_status                => x_return_status
                                );
Line: 7758

		l_raid_tab.delete;
Line: 7759

    		l_txn_cur_code_tab.delete;
Line: 7768

		  UPDATE /*+ INDEX(RTX PA_RESOURCE_ASGN_CURR_U2) */ pa_resource_asgn_curr rtx
        	  SET rtx.TXN_RAW_COST_RATE_OVERRIDE  = null
            		,rtx.TXN_BURDEN_COST_RATE_OVERRIDE = null
            		,rtx.TXN_BILL_RATE_OVERRIDE = null
        	  WHERE rtx.resource_assignment_id = l_raid_tab(i)
		  AND  rtx.txn_currency_code = l_txn_cur_code_tab(i);
Line: 7776

		--print_msg('Number of rows updated for setting null rates['||sql%rowcount||']');
Line: 7781

         * and it updates the passed in the txn currency with the rate scheduel currency.
	 * while rollup the amounts, the maintain data() api should update the existing RA+TXN currency,
	 * instead of deleting the old records and creating the new records.
	 * Fix required: In order to fix this issue, calculate api should keep track of old txn currency and new txn currency
	 * per planning resource and then call the maintain_data() api by passing old txn currency to delete and create
	 * record with new txn currency.
	 * Proposal:
         * since the amount of effort reqd to fix is more. adding simple delete of records from new entity
         * for workplan context where quantity is null, and rates are null.
         * This issue happens only for workplan when PC <> PFC and for initial creation of task assignment
        */
        If nvl(g_wp_version_flag,'N') = 'Y' AND g_calling_module NOT IN ('BUDGET_GENERATION','FORECAST_GENERATION') then
                If g_source_context = 'RESOURCE_ASSIGNMENT' OR g_time_phased_code = 'N'  Then
                 FOR i IN p_resource_assignment_tab.FIRST .. p_resource_assignment_tab.LAST LOOP
                    DELETE FROM pa_resource_asgn_curr rbc
                    WHERE  rbc.budget_version_id = p_budget_version_id
                    AND   rbc.resource_assignment_id = p_resource_assignment_tab(i)
                    AND EXISTS ( SELECT null
                         FROM   pa_budget_lines bl
                         WHERE  bl.resource_assignment_id = rbc.resource_assignment_id
                         AND    bl.txn_currency_code <> rbc.txn_currency_code )
                    AND rbc.total_quantity is NULL
                    AND rbc.total_init_quantity is NULL
                    AND rbc.txn_raw_cost_rate_override is NULL
                    AND rbc.txn_burden_cost_rate_override is NULL
                        ;
Line: 7807

                         print_msg('Number of rows deleted from new entity['||sql%rowcount||']');
Line: 7817

        print_msg('Unexpected error occured in Delete_BL_Where_Nulls['||x_msg_data||']');
Line: 7820

END Delete_BL_Where_Nulls;
Line: 7832

* p_calling_module              Required  possible values are  'UPDATE_PLAN_TRANSACTION' / 'BUDGET_GENERATION','FORECAST_GENERATION'
* p_activity_code       Required  possible values are  'CALCULATE'
* If p_mass_adjust_flag  is passed as 'Y' then following one-of the params must be passed
*   p_quantity_adj_pct
*   p_cost_rate_adj_pct
*   p_burdened_rate_adj_pct
*   p_bill_rate_adj_pct
* The following are the valid values for p_refresh_rates_flag
*      'Y'     -- Refresh all Raw cost,burden cost and revenue amounts
*      'C'     -- Refresh only Raw cost and burden cost amounts but retain the Revenue amounts
*      'R'     -- Refresh only Revenue amounts
*      'N'     -- No Refresh
*  Note: The values ('C' and 'R' is valid only in calling module = 'BUDGET_GENERATION' and 'FORECAST_GENERATION' )
* the following params are only for internal purposes, the values passed from AMG or page will be ignored
*   p_addl_qty_tab,p_addl_raw_cost_tab,p_addl_burdened_cost_tab,p_addl_revenue_tab
*
*/
PROCEDURE calculate (  p_project_id                    IN  pa_projects_all.project_id%TYPE
                      ,p_budget_version_id             IN  pa_budget_versions.budget_version_id%TYPE
                      ,p_refresh_rates_flag            IN  VARCHAR2 := 'N'
                      ,p_refresh_conv_rates_flag       IN  VARCHAR2 := 'N'
                      ,p_spread_required_flag          IN  VARCHAR2 := 'Y'
                      ,p_conv_rates_required_flag      IN  VARCHAR2 := 'Y'
                      ,p_rollup_required_flag          IN  VARCHAR2 := 'Y'
                      ,p_mass_adjust_flag              IN  VARCHAR2 := 'N'
                      ,p_apply_progress_flag           IN  VARCHAR2 := 'N'
                      ,p_wp_cost_changed_flag          IN  VARCHAR2 := 'N'
                      ,p_time_phase_changed_flag       IN  VARCHAR2 := 'N'
                      ,p_quantity_adj_pct              IN  NUMBER   := NULL
                      ,p_cost_rate_adj_pct             IN  NUMBER   := NULL
                      ,p_burdened_rate_adj_pct         IN  NUMBER   := NULL
                      ,p_bill_rate_adj_pct             IN  NUMBER   := NULL
		      ,p_raw_cost_adj_pct              IN  NUMBER   := NULL
                      ,p_burden_cost_adj_pct           IN  NUMBER   := NULL
                      ,p_revenue_adj_pct               IN  NUMBER   := NULL
                      ,p_source_context                IN  pa_fp_res_assignments_tmp.source_context%TYPE
                      ,p_calling_module                IN  VARCHAR2  DEFAULT   'UPDATE_PLAN_TRANSACTION'
                      ,p_activity_code                 IN  VARCHAR2  DEFAULT   'CALCULATE'
                      ,p_resource_assignment_tab       IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_delete_budget_lines_tab       IN  SYSTEM.pa_varchar2_1_tbl_type     DEFAULT SYSTEM.pa_varchar2_1_tbl_type()
                      ,p_spread_amts_flag_tab          IN  SYSTEM.pa_varchar2_1_tbl_type     DEFAULT SYSTEM.pa_varchar2_1_tbl_type()
                      ,p_txn_currency_code_tab         IN  SYSTEM.pa_varchar2_15_tbl_type    DEFAULT SYSTEM.pa_varchar2_15_tbl_type()
                      ,p_txn_currency_override_tab     IN  SYSTEM.pa_varchar2_15_tbl_type    DEFAULT SYSTEM.pa_varchar2_15_tbl_type()
                      ,p_total_qty_tab                 IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_addl_qty_tab                  IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_total_raw_cost_tab            IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_addl_raw_cost_tab             IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_total_burdened_cost_tab       IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_addl_burdened_cost_tab        IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_total_revenue_tab             IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_addl_revenue_tab              IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_raw_cost_rate_tab             IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_rw_cost_rate_override_tab     IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_b_cost_rate_tab               IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_b_cost_rate_override_tab      IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_bill_rate_tab                 IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_bill_rate_override_tab        IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_line_start_date_tab           IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
                      ,p_line_end_date_tab             IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
              /* Added for Spread enhancements */
                      ,p_mfc_cost_type_id_old_tab      IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_mfc_cost_type_id_new_tab      IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_spread_curve_id_old_tab       IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_spread_curve_id_new_tab       IN  SYSTEM.pa_num_tbl_type            DEFAULT SYSTEM.pa_num_tbl_type()
                      ,p_sp_fixed_date_old_tab         IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
                      ,p_sp_fixed_date_new_tab         IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
                      ,p_plan_start_date_old_tab       IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
                      ,p_plan_start_date_new_tab       IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
                      ,p_plan_end_date_old_tab         IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
                      ,p_plan_end_date_new_tab         IN  SYSTEM.pa_date_tbl_type           DEFAULT SYSTEM.pa_date_tbl_type()
                      ,p_re_spread_flag_tab            IN  SYSTEM.pa_varchar2_1_tbl_type     DEFAULT SYSTEM.pa_varchar2_1_tbl_type()
                      ,p_rlm_id_change_flag_tab        IN  SYSTEM.pa_varchar2_1_tbl_type     DEFAULT SYSTEM.pa_varchar2_1_tbl_type()
                      ,p_del_spread_calc_tmp1_flg      IN  VARCHAR2 := 'Y' /* Bug: 4309290.Added the parameter to identify if
                                                                           PA_FP_SPREAD_CALC_TMP1 is to be deleted or not. Frm AMG flow
                                                                           we will pass N and for other calls to calculate api it would
                                                                           be yes */
              ,p_fp_task_billable_flag_tab     IN  SYSTEM.pa_varchar2_1_tbl_type     DEFAULT SYSTEM.pa_varchar2_1_tbl_type() /* default 'D' */
              ,p_clientExtn_api_call_flag      IN  VARCHAR2 DEFAULT 'Y'
              ,p_raTxn_rollup_api_call_flag    IN  VARCHAR2 DEFAULT 'Y' /* Bug fix:4900436 */
                      ,x_return_status                 OUT NOCOPY VARCHAR2
                      ,x_msg_count                     OUT NOCOPY NUMBER
                      ,x_msg_data                      OUT VARCHAR2) IS

    l_tab_count            NUMBER;
Line: 7918

    l_delete_budget_lines  VARCHAR2(1);
Line: 7924

    l_calling_module       Varchar2(240) := NVL(p_calling_module,'UPDATE_PLAN_TRANSACTION');
Line: 7933

  l_delete_budget_lines_tab         SYSTEM.pa_varchar2_1_tbl_type     DEFAULT SYSTEM.pa_varchar2_1_tbl_type();
Line: 8069

    l_num_rowsdeleted    Number := 0;
Line: 8075

    select sum(txn_burdened_cost) l_txn_burdened_cost_total_bl,
    sum(txn_raw_cost) l_txn_raw_cost_total_bl
    from pa_fp_rollup_tmp
    where budget_version_id = p_budget_version_id
    and resource_assignment_id = p_resource_asg_id;
Line: 8082

        SELECT resource_assignment_id
            ,txn_currency_code
        FROM pa_budget_lines bl
        WHERE bl.budget_version_id = p_budget_version_id
    GROUP BY resource_assignment_id,txn_currency_code;
Line: 8089

        SELECT nvl(pfo.use_planning_rates_flag,'N') use_planning_rates_flag
          ,decode(nvl(bv.wp_version_flag,'N'),'Y',NVL(pfo.track_workplan_costs_flag,'N'),'Y') track_workplan_costs_flag
          ,bv.version_type
          ,bv.resource_list_id
          ,bv.approved_rev_plan_type_flag
          ,nvl(pfo.plan_in_multi_curr_flag,'N') plan_in_multi_curr_flag
          ,bv.etc_start_date
          ,nvl(bv.wp_version_flag,'N') wp_version_flag
      ,decode(bv.version_type,
                  'COST',NVL(pfo.cost_time_phased_code,'N'),
                  'REVENUE',NVL(pfo.revenue_time_phased_code,'N'),
                  NVL(pfo.all_time_phased_code,'N')) time_phased_code
      ,bv.project_structure_version_id
      ,bv.project_id
      ,pp.project_currency_code
      ,pp.projfunc_currency_code
      ,pp.segment1  project_Name
      ,bv.ci_id     CiId
      /*Bugfix:4272944 */
          ,NVL(pp.baseline_funding_flag,'N') baseline_funding_flag
        FROM pa_proj_fp_options pfo
            ,pa_budget_versions bv
        ,pa_projects_all pp
        WHERE pfo.fin_plan_version_id = bv.budget_version_id
    AND  bv.project_id = pp.project_id
        AND bv.budget_version_id = p_budget_version_id;
Line: 8119

        SELECT txn_currency_code
        FROM  pa_budget_lines
        WHERE  resource_assignment_id = l_resource_assignment_id
    ORDER BY start_date;
Line: 8125

        SELECT ra.resource_assignment_id
           ,ra.budget_version_id
           ,ra.project_id
           ,ra.task_id
           ,ra.resource_list_member_id
           ,ra.planning_start_date
           ,ra.planning_end_date
           ,ra.spread_curve_id
           ,ra.etc_method_code
           ,ra.resource_class_code
           ,ra.mfc_cost_type_id
           ,ra.sp_fixed_date
           ,ra.rate_based_flag
       ,rl.alias  Resource_Name
        FROM pa_resource_assignments ra
        ,pa_resource_list_members rl
        WHERE ra.resource_assignment_id = p_resource_asg_id
    AND  ra.resource_list_member_id = rl.resource_list_member_id ;
Line: 8147

        SELECT tmp.rowid
           ,tmp.budget_line_id
           ,tmp.resource_assignment_id
           ,tmp.txn_currency_code
           ,tmp.start_date
           ,tmp.end_date
           ,tmp.period_name
           ,tmp.quantity
           ,tmp.txn_raw_cost
       ,tmp.cost_rate
       ,tmp.rw_cost_rate_override
           ,tmp.txn_burdened_cost
       ,tmp.burden_cost_rate
       ,tmp.burden_cost_rate_override
           ,tmp.txn_revenue
       ,tmp.bill_rate
       ,tmp.bill_rate_override
           ,tmp.pm_product_code
       ,bv.version_type
       ,ra.resource_list_member_id
       ,ra.rate_based_flag
       ,ra.task_id
       ,rl.resource_id
        ,tmp.cost_rejection_code
    ,tmp.burden_rejection_code
    ,tmp.revenue_rejection_code
        -- Bug 6781055
        ,tmp.init_quantity
        ,tmp.txn_init_raw_cost
        ,tmp.txn_init_burdened_cost
        ,tmp.txn_init_revenue
        -- End for 6781055
        FROM pa_fp_rollup_tmp tmp
        ,pa_budget_versions bv
        ,pa_resource_assignments ra
        ,pa_resource_list_members rl
    WHERE bv.budget_version_id = p_budget_version_id
    AND   ra.budget_version_id = bv.budget_version_id
    AND   tmp.resource_assignment_id = ra.resource_assignment_id
    AND   ra.resource_list_member_id = rl.resource_list_member_id
        ORDER BY tmp.resource_assignment_id
        ,tmp.start_date
        ,tmp.txn_currency_code;
Line: 8194

        SELECT pt.name task_name
               ,prl.alias resource_name
        FROM pa_proj_elements pt
               ,pa_resource_list_members prl
               ,pa_resource_assignments pra
        WHERE pra.resource_assignment_id = p_resource_assignment_id
        AND pt.proj_element_id(+) = pra.task_id
        AND prl.resource_list_member_id = pra.resource_list_member_id;
Line: 8223

    /* Bug fix:4263265 the following variables declared to keep track of what is changed before deleteing
         * after deleting budget lines. these variables stores the original changed values passed to calculate
         * by comparing with the budget lines */
    l_org_quantity_changed_flag     Varchar2(10) := 'N';
Line: 8245

    /* declared the following tbl for client extn bulk update */
    l_cl_txn_plan_quantity_tab  pa_plsql_datatypes.NumTabTyp;
Line: 8282

g_ipm_ra_id_tab.delete;
Line: 8283

g_ipm_curr_code_tab.delete;
Line: 8284

g_ipm_cost_rate_ovr_tab.delete;
Line: 8285

g_ipm_bill_rate_ovr_tab.delete;
Line: 8286

g_ipm_burden_rate_ovr_tab.delete;
Line: 8288

gl_cl_roll_up_tmp_rowid_tab.delete;
Line: 8341

        l_resource_assignment_tab.delete;
Line: 8342

        l_delete_budget_lines_tab.delete;
Line: 8343

        l_spread_amts_flag_tab.delete;
Line: 8344

        l_txn_currency_code_tab.delete;
Line: 8345

        l_txn_currency_override_tab.delete;
Line: 8346

        l_total_qty_tab.delete;
Line: 8347

        l_addl_qty_tab.delete;
Line: 8348

        l_total_raw_cost_tab.delete;
Line: 8349

        l_addl_raw_cost_tab.delete;
Line: 8350

        l_total_burdened_cost_tab.delete;
Line: 8351

        l_addl_burdened_cost_tab.delete;
Line: 8352

        l_total_revenue_tab.delete;
Line: 8353

        l_addl_revenue_tab.delete;
Line: 8354

        l_raw_cost_rate_tab.delete;
Line: 8355

        l_rw_cost_rate_override_tab.delete;
Line: 8356

        l_b_cost_rate_tab.delete;
Line: 8357

        l_b_cost_rate_override_tab.delete;
Line: 8358

        l_bill_rate_tab.delete;
Line: 8359

        l_bill_rate_override_tab.delete;
Line: 8360

        l_line_start_date_tab.delete;
Line: 8361

        l_line_end_date_tab.delete;
Line: 8362

    g_apply_progress_flag_tab.delete;
Line: 8363

    l_spread_curve_id_old_tab.delete;
Line: 8364

    l_spread_curve_id_new_tab.delete;
Line: 8365

    l_sp_fixed_date_old_tab.delete;
Line: 8366

    l_sp_fixed_date_new_tab.delete;
Line: 8367

    l_plan_start_date_old_tab.delete;
Line: 8368

    l_plan_start_date_new_tab.delete;
Line: 8369

    l_plan_end_date_old_tab.delete;
Line: 8370

    l_plan_end_date_new_tab.delete;
Line: 8371

    l_re_spread_flag_tab.delete;
Line: 8372

    l_sp_curve_change_flag_tab.delete;
Line: 8373

    l_plan_dates_change_flag_tab.delete;
Line: 8374

    l_spfix_date_flag_tab.delete;
Line: 8375

    l_mfc_cost_change_flag_tab.delete;
Line: 8376

    l_mfc_cost_type_id_old_tab.delete;
Line: 8377

    l_mfc_cost_type_id_new_tab.delete;
Line: 8378

    l_rlm_id_change_flag_tab.delete;
Line: 8379

    l_plan_sdate_shrunk_flag_tab.delete;
Line: 8380

    l_plan_edate_shrunk_flag_tab.delete;
Line: 8381

    l_mfc_cost_refresh_flag_tab.delete;
Line: 8382

    l_ra_in_multi_cur_flag_tab.delete;
Line: 8383

    l_quantity_changed_flag_tab.delete;
Line: 8384

    l_raw_cost_changed_flag_tab.delete;
Line: 8385

    l_cost_rate_changed_flag_tab.delete;
Line: 8386

    l_burden_cost_changed_flag_tab.delete;
Line: 8387

    l_burden_rate_changed_flag_tab.delete;
Line: 8388

    l_rev_changed_flag_tab.delete;
Line: 8389

    l_bill_rate_changed_flag_tab.delete;
Line: 8390

    l_multicur_plan_start_date_tab.delete;
Line: 8391

        l_multicur_plan_end_date_tab.delete;
Line: 8392

    l_fp_task_billable_flag_tab.delete;
Line: 8393

    l_cost_rt_miss_num_flag_tab.delete;
Line: 8394

    l_burd_rt_miss_num_flag_tab.delete;
Line: 8395

    l_bill_rt_miss_num_flag_tab.delete;
Line: 8396

    l_Qty_miss_num_flag_tab.delete;
Line: 8397

    l_Rw_miss_num_flag_tab.delete;
Line: 8398

    l_Br_miss_num_flag_tab.delete;
Line: 8399

    l_Rv_miss_num_flag_tab.delete;
Line: 8400

    l_rev_only_entry_flag_tab.delete;
Line: 8403

    l_neg_Qty_Changflag_tab.delete;
Line: 8404

    l_neg_Raw_Changflag_tab.delete;
Line: 8405

    l_neg_Burd_Changflag_tab.delete;
Line: 8406

    l_neg_rev_Changflag_tab.delete;
Line: 8465

        is to be deleted or not. Frm AMG flow we will pass N and for
        other calls to calculate api it would be yes*/
        Init_SpreadCalc_Tbls(p_del_spread_calc_tmp1_flg => p_del_spread_calc_tmp1_flg);
Line: 8518

                ,p_delete_budget_lines_tab       =>  p_delete_budget_lines_tab
                ,p_spread_amts_flag_tab          =>  p_spread_amts_flag_tab
                ,p_txn_currency_code_tab         =>  p_txn_currency_code_tab
                ,p_txn_currency_override_tab     =>  p_txn_currency_override_tab
                ,p_total_qty_tab                 =>  p_total_qty_tab
                ,p_addl_qty_tab                  =>  p_addl_qty_tab
                ,p_total_raw_cost_tab            =>  p_total_raw_cost_tab
                ,p_addl_raw_cost_tab             =>  p_addl_raw_cost_tab
                ,p_total_burdened_cost_tab       =>  p_total_burdened_cost_tab
                ,p_addl_burdened_cost_tab        =>  p_addl_burdened_cost_tab
                ,p_total_revenue_tab             =>  p_total_revenue_tab
                ,p_addl_revenue_tab              =>  p_addl_revenue_tab
                ,p_raw_cost_rate_tab             =>  p_raw_cost_rate_tab
                ,p_rw_cost_rate_override_tab     =>  p_rw_cost_rate_override_tab
                ,p_b_cost_rate_tab               =>  p_b_cost_rate_tab
                ,p_b_cost_rate_override_tab      =>  p_b_cost_rate_override_tab
                ,p_bill_rate_tab                 =>  p_bill_rate_tab
                ,p_bill_rate_override_tab        =>  p_bill_rate_override_tab
                ,p_line_start_date_tab           =>  p_line_start_date_tab
                ,p_line_end_date_tab             =>  p_line_end_date_tab
        /* added for enhancements */
                ,p_spread_curve_id_old_tab       =>  p_spread_curve_id_old_tab
                ,p_spread_curve_id_new_tab       =>  p_spread_curve_id_new_tab
                ,p_sp_fixed_date_old_tab         =>  p_sp_fixed_date_old_tab
                ,p_sp_fixed_date_new_tab         =>  p_sp_fixed_date_new_tab
                ,p_plan_start_date_old_tab       =>  p_plan_start_date_old_tab
                ,p_plan_start_date_new_tab       =>  p_plan_start_date_new_tab
                ,p_plan_end_date_old_tab         =>  p_plan_end_date_old_tab
                ,p_plan_end_date_new_tab         =>  p_plan_end_date_new_tab
                ,p_re_spread_flag_tab            =>  p_re_spread_flag_tab
                ,p_sp_curve_change_flag_tab      =>  l_sp_curve_change_flag_tab
                ,p_plan_dates_change_flag_tab    =>  l_plan_dates_change_flag_tab
                ,p_spfix_date_flag_tab           =>  l_spfix_date_flag_tab
            ,p_mfc_cost_change_flag_tab      =>  l_mfc_cost_change_flag_tab
        ,p_mfc_cost_type_id_old_tab      =>  p_mfc_cost_type_id_old_tab
        ,p_mfc_cost_type_id_new_tab      =>  p_mfc_cost_type_id_new_tab
        ,p_rlm_id_change_flag_tab       =>  p_rlm_id_change_flag_tab
        ,p_fp_task_billable_flag_tab     => p_fp_task_billable_flag_tab
                ,x_return_status                 =>  l_return_status
                ,x_msg_count                     =>  x_msg_count
                ,x_msg_data                      =>  x_msg_data);
Line: 8579

        l_delete_budget_lines_tab         := p_delete_budget_lines_tab;
Line: 8668

     	*is removed and added a new api inside the PAFPCL1B.pls insert_spread_calctmp_records
	**************End of Bug fix:5309529 *****************************************/

	l_pls_end_time := dbms_utility.get_time;
Line: 8702

         * plan update and plan delete pji api. so set the rollup required flag to N */
        /* Bug fix:4189762 discussed with sakthi,saima and sanjay, during apply progress mode no need to call the rollup
         * as the progress API is calling plan_delete and plan_create rollup API to improve the perf
         */
        IF (p_calling_module IN ('BUDGET_GENERATION','FORECAST_GENERATION')
            /* Reverting back:OR NVL(p_apply_progress_flag,'N') = 'Y' as the 4189762 is NOT working properly */
            OR NVL(G_AGR_CONV_REQD_FLAG,'N') = 'Y'  ) Then
                g_rollup_required_flag := 'N';
Line: 8733

                ,x_delete_budget_lines_tab       =>l_delete_budget_lines_tab
                ,x_spread_amts_flag_tab          =>l_spread_amts_flag_tab
                ,x_txn_currency_code_tab         =>l_txn_currency_code_tab
                ,x_txn_currency_override_tab     =>l_txn_currency_override_tab
                ,x_total_qty_tab                 =>l_total_qty_tab
                ,x_addl_qty_tab                  =>l_addl_qty_tab
                ,x_total_raw_cost_tab            =>l_total_raw_cost_tab
                ,x_addl_raw_cost_tab             =>l_addl_raw_cost_tab
                ,x_total_burdened_cost_tab       =>l_total_burdened_cost_tab
                ,x_addl_burdened_cost_tab        =>l_addl_burdened_cost_tab
                ,x_total_revenue_tab             =>l_total_revenue_tab
                ,x_addl_revenue_tab              =>l_addl_revenue_tab
                ,x_raw_cost_rate_tab             =>l_raw_cost_rate_tab
                ,x_rw_cost_rate_override_tab     =>l_rw_cost_rate_override_tab
                ,x_b_cost_rate_tab               =>l_b_cost_rate_tab
                ,x_b_cost_rate_override_tab      =>l_b_cost_rate_override_tab
                ,x_bill_rate_tab                 =>l_bill_rate_tab
                ,x_bill_rate_override_tab        =>l_bill_rate_override_tab
                ,x_line_start_date_tab           =>l_line_start_date_tab
                ,x_line_end_date_tab             =>l_line_end_date_tab
                ,x_apply_progress_flag_tab       =>g_apply_progress_flag_tab
                ,x_spread_curve_id_old_tab       =>l_spread_curve_id_old_tab
                ,x_spread_curve_id_new_tab       =>l_spread_curve_id_new_tab
                ,x_sp_fixed_date_old_tab         =>l_sp_fixed_date_old_tab
                ,x_sp_fixed_date_new_tab         =>l_sp_fixed_date_new_tab
                ,x_plan_start_date_old_tab       =>l_plan_start_date_old_tab
                ,x_plan_start_date_new_tab       =>l_plan_start_date_new_tab
                ,x_plan_end_date_old_tab         =>l_plan_end_date_old_tab
                ,x_plan_end_date_new_tab         =>l_plan_end_date_new_tab
                ,x_re_spread_flag_tab            =>l_re_spread_flag_tab
                ,x_sp_curve_change_flag_tab      =>l_sp_curve_change_flag_tab
                ,x_plan_dates_change_flag_tab    =>l_plan_dates_change_flag_tab
                ,x_spfix_date_flag_tab           =>l_spfix_date_flag_tab
                ,x_mfc_cost_change_flag_tab      =>l_mfc_cost_change_flag_tab
                ,x_mfc_cost_type_id_old_tab      =>l_mfc_cost_type_id_old_tab
                ,x_mfc_cost_type_id_new_tab      =>l_mfc_cost_type_id_new_tab
        ,x_rlm_id_change_flag_tab        =>l_rlm_id_change_flag_tab
            ,x_plan_sdate_shrunk_flag_tab    =>l_plan_sdate_shrunk_flag_tab
            ,x_plan_edate_shrunk_flag_tab    =>l_plan_edate_shrunk_flag_tab
            ,x_mfc_cost_refresh_flag_tab     =>l_mfc_cost_refresh_flag_tab
        ,x_ra_in_multi_cur_flag_tab      =>l_ra_in_multi_cur_flag_tab
        ,x_quantity_changed_flag_tab     =>l_quantity_changed_flag_tab
            ,x_raw_cost_changed_flag_tab     =>l_raw_cost_changed_flag_tab
            ,x_cost_rate_changed_flag_tab    =>l_cost_rate_changed_flag_tab
            ,x_burden_cost_changed_flag_tab  =>l_burden_cost_changed_flag_tab
            ,x_burden_rate_changed_flag_tab  =>l_burden_rate_changed_flag_tab
            ,x_rev_changed_flag_tab          =>l_rev_changed_flag_tab
            ,x_bill_rate_changed_flag_tab    =>l_bill_rate_changed_flag_tab
        ,x_multcur_plan_start_date_tab   =>l_multicur_plan_start_date_tab
        ,x_multcur_plan_end_date_tab     =>l_multicur_plan_end_date_tab
        ,x_fp_task_billable_flag_tab  => l_fp_task_billable_flag_tab
        ,x_cost_rt_miss_num_flag_tab  => l_cost_rt_miss_num_flag_tab
        ,x_burd_rt_miss_num_flag_tab  => l_burd_rt_miss_num_flag_tab
        ,x_bill_rt_miss_num_flag_tab  => l_bill_rt_miss_num_flag_tab
        ,x_Qty_miss_num_flag_tab  => l_Qty_miss_num_flag_tab
        ,x_Rw_miss_num_flag_tab  => l_Rw_miss_num_flag_tab
        ,x_Br_miss_num_flag_tab  => l_Br_miss_num_flag_tab
	,x_Rv_miss_num_flag_tab  => l_Rv_miss_num_flag_tab
	,x_rev_only_entry_flag_tab => l_rev_only_entry_flag_tab
	/* bug fix:5726773 */
 	,x_neg_Qty_Changflag_tab   => l_neg_Qty_Changflag_tab
 	,x_neg_Raw_Changflag_tab  => l_neg_Raw_Changflag_tab
 	,x_neg_Burd_Changflag_tab => l_neg_Burd_Changflag_tab
 	,x_neg_rev_Changflag_tab  => l_neg_rev_Changflag_tab
        ,x_return_status                 => l_return_status
        ,x_msg_data                      => x_msg_data
                );
Line: 8845

        /* update resource assignments set planning end date as etc start date for the fixed date
        * spread curves where more than one budget line exists
        */
            PreProcess_BlkProgress_lines
            (p_budget_version_id      => g_budget_version_id
            ,p_etc_start_date         => g_spread_from_date
        ,p_apply_progress_flag    => p_apply_progress_flag
            ,x_return_status          => l_return_status
            ,x_msg_data               => x_msg_data
            );
Line: 8883

        /* IPM changes: Whenever budget lines get deleted, rollup the amts to new entity
         * otherwise this causes data corruption of amounts and quantity get doubled during apply progress
         */
        IF p_source_context = 'RESOURCE_ASSIGNMENT' AND
                     NVL(p_raTxn_rollup_api_call_flag,'Y') = 'Y' AND nvl(l_entire_return_status,'S') = 'S' Then
			 If P_PA_DEBUG_MODE = 'Y' Then
                         print_msg('Calling populate_raTxn_Recs API for rollup of budgetlines during apply progress');
Line: 8891

                         delete_raTxn_Tmp;
Line: 8896

                         ,p_delete_flag          => 'N'
                         ,p_delete_raTxn_flag    => 'N'
                         ,p_refresh_rate_flag    => 'N'
                         ,p_rollup_flag          => 'Y'
                         ,p_call_raTxn_rollup_flag => 'Y'
                         ,x_return_status        => l_return_status
                         ,x_msg_count            => x_msg_count
                         ,x_msg_data             => x_msg_data
                         );
Line: 8994

        Use BEGIN here to allow for the skip record exception if required parameters needed to update
        budget lines are all null.
        */
        BEGIN
                l_stage := 220;
Line: 9073

            *Select pa_resource_assignment attributes required for the rate API
            */
                l_stage := 250;
Line: 9089

            *Assign local variables values selected from the resource_assignemt cursur
            */
                l_stage := 270;
Line: 9109

                l_delete_budget_lines   := NULL;
Line: 9148

                        IF l_delete_budget_lines_tab.EXISTS(i) Then
                           If NVL(l_delete_budget_lines,'N') = 'N' Then  -- this is set 'Y' at override currency changed
                              --print_msg('l_delete_budget_lines_tab(i) ['||l_delete_budget_lines_tab(i)||']');
Line: 9151

                              l_delete_budget_lines  := l_delete_budget_lines_tab(i);
Line: 9160

                l_delete_budget_lines := 'Y';
Line: 9164

                l_delete_budget_lines := 'Y';
Line: 9168

                If NVL(l_delete_budget_lines,'N') <> 'Y' Then
                    g_mfc_cost_refresh_tab(l_countr) := 'Y';
Line: 9185

        print_msg('l_rlm_id_change_flag['||l_rlm_id_change_flag||']l_delete_budget_lines['||l_delete_budget_lines||']');
Line: 9236

                                ElsIF (NVL(l_delete_budget_lines,'N') <> 'Y' AND l_quantity_changed_flag = 'N'
                    and NVL(p_apply_progress_flag,'N') <> 'Y' ) Then
                   g_mfc_cost_refresh_tab(l_countr) := 'Y';
Line: 9453

                        IF l_delete_budget_lines = 'Y' THEN
				If P_PA_DEBUG_MODE = 'Y' Then
                                print_msg(to_char(l_stage)||' Delete from pa_budget_lines, rollup pfc numbers, and skip record');
Line: 9457

                                pa_fp_calc_plan_pkg.delete_budget_lines
                                        (p_budget_version_id          => p_budget_version_id
                                        ,p_resource_assignment_id     => l_resource_assignment_id
                                        ,p_txn_currency_code          => l_txn_currency_code
                                        ,p_line_start_date            => g_line_start_date
                                        ,p_line_end_date              => g_line_end_date
                                        ,p_source_context             => g_source_context
                                        ,x_return_status              => l_return_status
                                        ,x_msg_count                  => x_msg_count
                                        ,x_msg_data                   => x_msg_data
                                        ,x_num_rowsdeleted            => l_num_rowsdeleted
                                        );
Line: 9470

                                print_msg('Number of budgetLines deleted['||l_num_rowsdeleted||']retSts['||l_return_status||']');
Line: 9480

					l_raTxnRec_mode := 'DELETE_BL';
Line: 9482

                            	--print_msg('Calling populate_raTxn_Recs API for delete of for Resource attribute changes');
Line: 9483

                                delete_raTxn_Tmp;
Line: 9488

                                ,p_delete_flag          => 'N'
                                ,p_delete_raTxn_flag    => 'N'
                                ,p_refresh_rate_flag    => g_refresh_rates_flag
                                ,p_rollup_flag          => 'Y'
                                ,p_call_raTxn_rollup_flag => 'Y'
				,p_resource_assignment_id => l_resource_assignment_id
            			,p_txn_currency_code	 => l_txn_currency_code
				,p_start_date           => g_line_start_date
                                ,x_return_status        => l_return_status
                                ,x_msg_count            => x_msg_count
                                ,x_msg_data             => x_msg_data
                                );
Line: 9508

                                   IF (l_spread_amounts_flag = 'N' OR l_num_rowsdeleted > 0) Then
                                        l_spread_amounts_flag := 'Y';
Line: 9512

                        END IF;  --IF l_delete_budget_lines = 'Y'
Line: 9518

                          the ETC qty should be respread, so delete all the budget lines after the etc start date
                          and respread the given ETC so this shoul go through normal flow.
              so set the g_apply_progress_flag to 'N'.
                          When actuals Exists, by pass the apply precedence rules,
             */
            IF g_apply_progress_flag_tab.EXISTS(i) THEN
                l_apply_progress_flag := g_apply_progress_flag_tab(i);
Line: 9701

               SELECT rtx.txn_burden_cost_rate_override
             ,rtx.txn_bill_rate_override
             ,tmp.bill_markup_percentage
	     ,rtx.txn_raw_cost_rate_override
                 INTO l_curr_burden_rate
            ,l_curr_bill_rate
            ,l_curr_markup_percentage
	    ,l_curr_cost_rate
                 FROM pa_resource_asgn_curr rtx
             ,pa_fp_spread_calc_tmp tmp
                WHERE tmp.resource_assignment_id = l_resource_assignment_id
                  AND tmp.txn_currency_code = l_txn_currency_code
          AND rtx.resource_assignment_id = tmp.resource_assignment_id
          AND rtx.txn_currency_code = tmp.txn_currency_code;
Line: 9728

                  SELECT AVG(bl.burden_cost_rate_override)
            ,AVG(bl.txn_bill_rate_override)
            ,AVG(bl.txn_markup_percent)
	    ,AVG(bl.txn_cost_rate_override)
                    INTO l_curr_burden_rate
            ,l_curr_bill_rate
            ,l_curr_markup_percentage
	    ,l_curr_cost_rate
                    FROM pa_budget_lines bl
                   WHERE bl.resource_assignment_id = l_resource_assignment_id
                     AND bl.txn_currency_code = l_txn_currency_code
             AND bl.start_date between l_bdgt_line_sDate and l_bdgt_line_eDate;
Line: 9913

               * copy budget lines to rollup tmp and update the changed rates
               * doing this will improve performance by 50%
               */
              IF NVL(l_txn_plan_quantity_addl,0) = 0
                 AND ( (l_raw_cost_changed_flag = 'Y' AND
                        l_rate_based_flag = 'Y')
                      OR l_rw_cost_rate_changed_flag = 'Y'
                      OR l_burden_cost_changed_flag = 'Y'
                      OR l_b_cost_rate_changed_flag ='Y'
                      OR l_rev_changed_flag = 'Y'
                      OR l_bill_rate_changed_flag = 'Y'
                      OR l_bill_rt_ovr_changed_flag = 'Y'  ) Then
                g_rtChanged_Ra_Flag_tab(l_countr) := 'Y';
Line: 9957

                   	--print_msg('283: set the rate change flag to Y so that it goes throguh refresh mode and updates');
Line: 9976

        /* If delete flag is passed in budget line context then, spread or refresh should not be called
        * just delete the budget lines */
        IF p_source_context = 'BUDGET_LINE'
           AND l_delete_budget_lines = 'Y' THEN
            	g_rtChanged_Ra_Flag_tab(l_countr) := 'N';
Line: 9998

    print_msg(' l_delete_budget_lines['||l_delete_budget_lines||']l_spread_amounts_flag['||l_spread_amounts_flag||']');
Line: 10142

                    print_msg(to_char(l_stage)||' ***ERROR*** Inserting into pa_fp_res_assignments_tmp');
Line: 10143

                    pa_debug.g_err_stage := to_char(l_stage)||':  ***ERROR*** Inserting into pa_fp_res_assignments_tmp';
Line: 10168

        /* Now update the spread_calc tmp table with the required flags to process in bulk */
	If P_PA_DEBUG_MODE = 'Y' Then
        print_msg('Calling Upd_spread_calc_tmp API');
Line: 10351

            delete_raTxn_Tmp;
Line: 10357

                        ,p_delete_flag          => 'N'
                        ,p_delete_raTxn_flag    => 'Y'
                        ,p_rollup_flag          => 'Y'
                        ,p_call_raTxn_rollup_flag => p_raTxn_rollup_api_call_flag -- Changed from 'Y'
                        ,x_return_status        => l_return_status
                        ,x_msg_count            => x_msg_count
                        ,x_msg_data             => x_msg_data
                        );
Line: 10405

                        print_msg(l_stage||'Calling Update_rollupTmp_OvrRates API with genrationContext['||l_generation_context||']');
Line: 10409

                        Update_rollupTmp_OvrRates
                          ( p_budget_version_id        => g_budget_version_id
                          ,p_calling_module            => l_calling_module
                          ,p_generation_context        => l_generation_context
                          ,x_return_status             => l_return_status
                          ,x_msg_count                 => x_msg_count
                          ,x_msg_data                  => x_msg_data
                          );
Line: 10418

            print_plsql_time('End of Update_rollupTmp_OvrRates:Total time :['||(l_pls_end_time-l_pls_start_time)||']');
Line: 10420

                        print_msg('After calling Update_rollupTmp_OvrRates api retSts['||l_return_status||']msgdata['||x_msg_data||']');
Line: 10462

            delete_raTxn_Tmp;
Line: 10470

                        ,p_delete_flag          => 'N'
                        ,p_delete_raTxn_flag    => 'N'
                        ,p_rollup_flag          => 'N'
                        ,p_call_raTxn_rollup_flag => p_raTxn_rollup_api_call_flag --'Y'
                        ,x_return_status        => l_return_status
                        ,x_msg_count            => x_msg_count
                        ,x_msg_data             => x_msg_data
                        );
Line: 10538

      /*Bug 4224464. This API would be called to insert into pa_fp_rollup_tmp all those budget lines which are not already present in
          pa_fp_rollup_tmp. These lines would be the ones with no changes to qty/amnt and rate columns. The lines with changes to
          qty/amnt and rate columns would not be processed by this API as earlier call to copy_blattributes would have handled these
          lines  Also using the same signature for this API as used for copy_blattributes above.*/
      /* This call to update_dffcols is required for non AMG flows too but currently doing for AMG flow only
       *.as the fix is done for AMG rollup. Will ask Ranga to evaluate this for non-AMG flows and remove the if condition.
       *.This can then be put in FP M rollup with extensive QE testing */
        IF ( p_calling_module = 'AMG_API' )
        THEN
	l_pls_start_time := dbms_utility.get_time;
Line: 10549

                PA_FP_CALC_UTILS.update_dffcols(
                         p_budget_verson_id               => g_budget_version_id
                        ,p_source_context                 => g_source_context
                        ,p_calling_module                 => l_calling_module
                        ,p_apply_progress_flag            => p_apply_progress_flag
                        ,x_return_status                  => l_return_status
                        ,x_msg_count                      => x_msg_count
                        ,x_msg_data                       => x_msg_data
                        );
Line: 10559

            print_plsql_time('End of update_diffcols:Total time :['||(l_pls_end_time-l_pls_start_time)||']');
Line: 10561

                        print_msg('returnSts of PA_FP_CALC_UTILS.update_dff['||l_return_status||']');
Line: 10581

        SELECT decode(nvl(l_return_status,'S'),'E','E'
                              ,'U','U'
                                  ,'S',decode(nvl(l_entire_return_status,'S')
                                ,'E','E'
                                ,'U','U'
                                ,'S','S'),'E')
        INTO l_return_status
        FROM dual;
Line: 10630

        l_cl_txn_plan_quantity_tab.delete;
Line: 10631

            l_cl_txn_raw_cost_tab.delete;
Line: 10632

            l_cl_txn_burdened_cost_tab.delete;
Line: 10633

            l_cl_txn_revenue_tab.delete;
Line: 10634

            l_cl_cost_rate_override_tab.delete;
Line: 10635

            l_cl_burden_rate_override_tab.delete;
Line: 10636

            l_cl_bill_rate_override_tab.delete;
Line: 10637

            l_cl_budget_line_id_tab.delete;
Line: 10638

        l_cl_raw_rejection_code_tab.delete;
Line: 10639

            l_cl_burd_rejection_code_tab.delete;
Line: 10640

            l_cl_rev_rejection_code_tab.delete;
Line: 10866

            /*print_msg(' AFTER client extn Values UPDATE pa_fp_rollup_tmp');
Line: 10891

                UPDATE pa_fp_rollup_tmp tmp
                                SET tmp.quantity       = l_cl_txn_plan_quantity_tab(i)
                                ,tmp.txn_raw_cost      = l_cl_txn_raw_cost_tab(i)
                                ,tmp.txn_burdened_cost = l_cl_txn_burdened_cost_tab(i)
                                ,tmp.txn_revenue       = l_cl_txn_revenue_tab(i)
                                ,tmp.rw_cost_rate_override = NVL(l_cl_cost_rate_override_tab(i),tmp.rw_cost_rate_override)
                                ,tmp.burden_cost_rate_override = nvl(l_cl_burden_rate_override_tab(i),tmp.burden_cost_rate_override)
                                ,tmp.bill_rate_override = nvl(l_cl_bill_rate_override_tab(i),tmp.bill_rate_override)
                ,tmp.cost_rejection_code = l_cl_raw_rejection_code_tab(i)
                ,tmp.burden_rejection_code  = l_cl_burd_rejection_code_tab(i)
                ,tmp.revenue_rejection_code = l_cl_rev_rejection_code_tab(i)
                                WHERE tmp.budget_line_id = l_cl_budget_line_id_tab(i);
Line: 10910

        /* Rounding Enhancements: Update the last rollup tmp line with the rounding discrepancy amounts */
        IF NVL(l_entire_return_status,'S') = 'S' AND NVL(g_track_wp_costs_flag,'Y') = 'Y' THEN
	l_pls_start_time := dbms_utility.get_time;
Line: 10914

               Update_rounding_diff(
                p_project_id                     => p_project_id
                ,p_budget_version_id             => g_budget_version_id
                ,p_calling_module                => l_calling_module
                ,p_source_context                => g_source_context
                ,p_wp_cost_enabled_flag          => g_track_wp_costs_flag
                ,p_budget_version_type           => g_fp_budget_version_type
                ,x_return_status                 => l_return_status
                ,x_msg_count                     => x_msg_count
                ,x_msg_data                      => l_msg_data --5028631
                );
Line: 10926

        print_plsql_time('End of Update_rounding_diff:Total time :['||(l_pls_end_time-l_pls_start_time)||']');
Line: 10953

 	                               update pa_fp_rollup_tmp
 	                               set txn_burdened_cost = (nvl(txn_burdened_cost,0) + nvl(l_txn_burdened_cost_total,0)-nvl(l_txn_burdened_cost_total_bl,0)),
 	                               txn_raw_cost = (nvl(txn_raw_cost,0) + nvl(l_txn_raw_cost_total,0)-nvl(l_txn_raw_cost_total_bl,0))
 	                               where budget_version_id = p_budget_version_id and resource_assignment_id = l_resource_assignment_tab(j)
 	                               and start_date = (select max(start_date) from pa_fp_rollup_tmp where budget_version_id = p_budget_version_id
 	                               and resource_assignment_id = l_resource_assignment_tab(j));
Line: 11001

        Update_PCPFC_rounding_diff(
                p_project_id                     => p_project_id
                ,p_budget_version_id             => g_budget_version_id
                ,p_calling_module                => l_calling_module
                ,p_source_context                => g_source_context
                ,p_wp_cost_enabled_flag          => g_track_wp_costs_flag
                ,p_budget_version_type           => g_fp_budget_version_type
                ,x_return_status                 => l_return_status
                ,x_msg_count                     => x_msg_count
                ,x_msg_data                      => l_msg_data --5028631
                );
Line: 11024

    *table pa_budget_lines is ready to be updated with the values stored in pa_fp_rollup_tmp
    *It will update pa_budget_lines with ALL rows stored in pa_fp_rollup_tmp
    */
    l_stage := 1100;
Line: 11028

        /* Bug fix: 4184159 moved to bulk update pa_fp_calc_plan_pkg.update_budget_lines */
	l_pls_start_time := dbms_utility.get_time;
Line: 11031

            PA_FP_CALC_UTILS.BLK_update_budget_lines
               ( p_budget_version_id           => p_budget_version_id
		,p_calling_module            => l_calling_module -- Added for Bug#5395732
                ,x_return_status              => l_return_status
                ,x_msg_count                  => x_msg_count
                ,x_msg_data                      => l_msg_data --5028631
                );
Line: 11039

            print_plsql_time('End of BLK UpdateBudget Total time :['||(l_pls_end_time-l_pls_start_time)||']');
Line: 11041

        print_msg('AFter calling update_budget_lines retSTst['||l_return_status||']MsgData['||l_msg_data||']');
Line: 11056

            delete_raTxn_Tmp;
Line: 11061

                        ,p_delete_flag          => 'N'
                        ,p_delete_raTxn_flag    => 'N'
                        ,p_refresh_rate_flag    => g_refresh_rates_flag
                        ,p_rollup_flag          => 'Y'
                        ,p_call_raTxn_rollup_flag => 'Y'
                        ,x_return_status        => l_return_status
                        ,x_msg_count            => x_msg_count
                        ,x_msg_data                      => l_msg_data --5028631
                        );
Line: 11106

        PA_FP_PJI_INTG_PKG.blk_update_reporting_lines
            (p_calling_module                => 'CALCULATE_API'
            ,p_activity_code                 => 'UPDATE'
            ,p_budget_version_id             => p_budget_version_id
            ,p_rep_budget_line_id_tab        => g_rep_budget_line_id_tab
            ,p_rep_res_assignment_id_tab     => g_rep_res_assignment_id_tab
            ,p_rep_start_date_tab            => g_rep_start_date_tab
            ,p_rep_end_date_tab              => g_rep_end_date_tab
            ,p_rep_period_name_tab           => g_rep_period_name_tab
            ,p_rep_txn_curr_code_tab         => g_rep_txn_curr_code_tab
            ,p_rep_quantity_tab              => g_rep_quantity_tab
            ,p_rep_txn_raw_cost_tab          => g_rep_txn_raw_cost_tab
            ,p_rep_txn_burdened_cost_tab     => g_rep_txn_burdened_cost_tab
            ,p_rep_txn_revenue_tab           => g_rep_txn_revenue_tab
            ,p_rep_project_curr_code_tab     => g_rep_project_curr_code_tab
            ,p_rep_project_raw_cost_tab      => g_rep_project_raw_cost_tab
            ,p_rep_project_burden_cost_tab   => g_rep_project_burden_cost_tab
            ,p_rep_project_revenue_tab       => g_rep_project_revenue_tab
            ,p_rep_projfunc_curr_code_tab    => g_rep_projfunc_curr_code_tab
            ,p_rep_projfunc_raw_cost_tab     => g_rep_projfunc_raw_cost_tab
            ,p_rep_projfunc_burden_cost_tab  => g_rep_projfunc_burden_cost_tab
            ,p_rep_projfunc_revenue_tab      => g_rep_projfunc_revenue_tab
	    ,p_rep_line_mode_tab             => g_rep_line_mode_tab
	    ,p_rep_rate_base_flag_tab        => g_rep_rate_base_flag_tab
            ,x_msg_data                      => l_msg_data --5028631
            ,x_msg_count                     => x_msg_count
            ,x_return_status                 => l_return_status
            );
Line: 11139

                   SELECT lock_flag INTO l_locked
                   FROM pji_pjp_wbs_header where plan_version_id = p_budget_version_id;
Line: 11204

        /* Bug fix:4250222: when -100% adjustment of qty is made, the budget lines got deleted but
         * RA is not rolled up. so move Delete_BL_Where_Nulls after RA rollup */
        l_stage := 1310;
Line: 11208

                /* Delete all the budget Lines where quantity and amounts are not exists but only the rate
                 * retaining these budget lines will cause issues in reating the currency for workplan version
                 * ideally budget lines with null amounts and null quantity with rate make no sense
                 */
		If P_PA_DEBUG_MODE = 'Y' Then
            	print_msg(l_stage||'Calling Delete_BL_Where_Nulls API');
Line: 11216

		--print_plsql_time('Start of Delete_BL_Where_Nulls :['||l_pls_start_time);
Line: 11217

                Delete_BL_Where_Nulls
                        ( p_budget_version_id        => p_budget_version_id
                          ,p_resource_assignment_tab => l_resource_assignment_tab
                          ,x_return_status           => l_return_status
                          ,x_msg_data                      => l_msg_data --5028631
                         );
Line: 11224

		print_plsql_time('End of Delete_BL_Where_NullsTotal time :['||(l_pls_end_time-l_pls_start_time)||']');
Line: 11226

                print_msg('AFter calling Delete_BL_Where_Nulls retSTst['||l_return_status||']MsgData['||l_msg_data||']');
Line: 11351

            print_msg(to_char(l_stage)||'  Calling insert_txn_currency api');
Line: 11353

            pa_fp_gen_budget_amt_pub.insert_txn_currency
                (p_project_id          => g_project_id,
                    p_budget_version_id   => g_budget_version_id,
                    p_fp_cols_rec         => l_fp_cols_rec,
                    x_return_status       => l_return_status
                    ,x_msg_count           => x_msg_count
                    ,x_msg_data                      => l_msg_data --5028631
            );
Line: 11362

        print_msg('AFter calling pa_fp_gen_budget_amt_pub.insert_txn_currency API retSts['||l_return_status||']x_msg_date['||l_msg_data||']');
Line: 11754

    SELECT /*+ INDEX(CALTMP PA_FP_SPREAD_CALC_TMP_N1) */ caltmp.resource_assignment_id
        ,caltmp.txn_currency_code
        ,caltmp.start_date
        ,caltmp.end_date
        ,caltmp.txn_curr_code_override
        ,caltmp.G_WPRABL_CURRENCY_CODE
        ,ra.project_id
        ,ra.task_id
        ,ra.budget_version_id
        ,NVL(ra.rate_based_flag,'N') rate_based_flag
    ,caltmp.task_name
        ,caltmp.resource_name
    ,caltmp.billable_flag
    FROM pa_fp_spread_calc_tmp caltmp
        ,pa_resource_assignments ra
    WHERE caltmp.budget_version_id = p_budget_version_id
    AND   caltmp.resource_assignment_id = ra.resource_assignment_id
    AND   ( NVL(caltmp.skip_record_flag,'N') <> 'Y'
	    OR
	    ( NVL(caltmp.skip_record_flag,'N') = 'Y'
		and NVL(caltmp.processed_flag,'N') = 'Y'
	     )
	  );
Line: 11784

        SELECT  /*+LEADING(TMP) INDEX(TMP PA_FP_ROLLUP_TMP_N1)*/ ra.resource_assignment_id -- bug 4873834
       ,tmp.txn_currency_code
           ,tmp.quantity
           ,tmp.start_date
           ,tmp.budget_line_id
           ,tmp.burden_cost_rate_override
           ,tmp.rw_cost_rate_override
           ,tmp.bill_rate_override
           ,tmp.txn_raw_cost
           ,tmp.txn_burdened_cost
           ,tmp.txn_revenue
       ,ra.task_id
           ,ra.resource_list_member_id
           ,ra.unit_of_measure
           ,ra.standard_bill_rate
           ,ra.wbs_element_version_id
           ,ra.rbs_element_id
           ,ra.planning_start_date
           ,ra.planning_end_date
           ,ra.spread_curve_id
           ,ra.etc_method_code
           ,ra.res_type_code
           ,ra.fc_res_type_code
           ,ra.resource_class_code
           ,ra.organization_id
           ,ra.job_id
           ,ra.person_id
           ,ra.expenditure_type
           ,ra.expenditure_category
       ,ra.revenue_category_code
           ,ra.event_type
           ,ra.supplier_id
           ,ra.non_labor_resource
           ,ra.bom_resource_id
           ,ra.inventory_item_id
           ,ra.item_category_id
           ,ra.billable_percent
           ,ra.mfc_cost_type_id
           ,ra.incurred_by_res_flag
           ,ra.rate_job_id
           ,ra.rate_expenditure_type
           ,ra.sp_fixed_date
           ,ra.person_type_code
           ,NVL(ra.rate_based_flag,'N') rate_based_flag
           ,ra.rate_exp_func_curr_code
           ,ra.rate_expenditure_org_id
           ,ra.incur_by_res_class_code
           ,ra.incur_by_role_id
           ,ra.project_role_id
       ,ra.resource_class_flag
           ,ra.named_role
       ,rl.res_format_id
       ,tmp.init_quantity
       ,tmp.txn_init_raw_cost
       ,tmp.txn_init_burdened_cost
       ,tmp.txn_init_revenue
       /* Bug fix:4294287 */
       ,tmp.bill_markup_percentage
    ,NVL(tmp.system_reference6,'Y') markup_calculation_flag
        FROM pa_resource_assignments ra
            ,pa_fp_rollup_tmp tmp
        ,pa_resource_list_members rl
        WHERE tmp.resource_assignment_id = p_resource_assignment_id
    AND ra.resource_assignment_id = tmp.resource_assignment_id
    AND rl.resource_list_member_id = ra.resource_list_member_id
        AND tmp.txn_currency_code = decode(p_txn_curr_code_Ovr,NULL,p_txn_currency_code
                    ,decode(p_txn_curr_code_Ovr,tmp.txn_currency_code,p_txn_curr_code_Ovr,p_txn_currency_code))
                /* the decode is added to take care of when override currency changes along with qty the spread api is called
                 * this will create rollup lines with override curr. when rates changes along with ovrride currency change then
                 * refresh rates action performed and rollup lines will be created with original txn curr */
        AND ((g_source_context <> 'BUDGET_LINE' )
       OR
        (g_source_context = 'BUDGET_LINE'
         and p_line_start_date is NOT NULL and p_line_end_date is NOT NULL
         and tmp.start_date BETWEEN p_line_start_date and p_line_end_date)
       )
    /* added this to avoid processing the same record twice. This may happend due to deriving the final
     * currency is moved from update_budget_lines to Rate API.*/
    -- commenting out as rate api is called only once AND NVL(tmp.system_reference5,'N') = 'N'
        ORDER BY ra.resource_assignment_id,tmp.start_date,tmp.txn_currency_code ;
Line: 11867

        SELECT decode(nvl(pfo.use_planning_rates_flag,'N'),'N',pfo.res_class_bill_rate_sch_id,
                          decode(bv.version_type,'REVENUE',pfo.rev_res_class_rate_sch_id,
                                                 'ALL'    ,pfo.rev_res_class_rate_sch_id,
                                                           NULL)) res_class_bill_rate_sch_id
          ,decode(nvl(pfo.use_planning_rates_flag,'N'),'N',pfo.res_class_raw_cost_sch_id,
                          decode(bv.version_type,'COST',pfo.cost_res_class_rate_sch_id,
                                                 'ALL' ,pfo.cost_res_class_rate_sch_id,
                                                           NULL)) res_class_raw_cost_sch_id
          ,nvl(pfo.use_planning_rates_flag,'N') use_planning_rates_flag
          ,decode(nvl(pfo.use_planning_rates_flag,'N'),'N',null,
                          decode(bv.version_type,'REVENUE',pfo.rev_job_rate_sch_id,
                                                 'ALL'    ,pfo.rev_job_rate_sch_id,
                                                 NULL))    rev_job_rate_sch_id
          ,decode(nvl(pfo.use_planning_rates_flag,'N'),'N',null,
                          decode(bv.version_type,'COST'   ,pfo.cost_job_rate_sch_id,
                                                 'ALL'    ,pfo.cost_job_rate_sch_id,
                                                 NULL))     cost_job_rate_sch_id
          ,decode(nvl(pfo.use_planning_rates_flag,'N'),'N',null,
                          decode(bv.version_type,'REVENUE',pfo.rev_emp_rate_sch_id,
                                                 'ALL'    ,pfo.rev_emp_rate_sch_id,
                                                 NULL))    rev_emp_rate_sch_id
          ,decode(nvl(pfo.use_planning_rates_flag,'N'),'N',null,
                          decode(bv.version_type,'COST'   ,pfo.cost_emp_rate_sch_id,
                                                 'ALL'    ,pfo.cost_emp_rate_sch_id,
                                                 NULL))     cost_emp_rate_sch_id
          ,decode(nvl(pfo.use_planning_rates_flag,'N'),'N',null,
                          decode(bv.version_type,'REVENUE',pfo.rev_non_labor_res_rate_sch_id,
                                                 'ALL'    ,pfo.rev_non_labor_res_rate_sch_id,
                                                 NULL))     rev_non_labor_res_rate_sch_id
          ,decode(nvl(pfo.use_planning_rates_flag,'N'),'N',null,
                          decode(bv.version_type,'COST'   ,pfo.cost_non_labor_res_rate_sch_id,
                                                 'ALL'    ,pfo.cost_non_labor_res_rate_sch_id,
                                                 NULL))     cost_non_labor_res_rate_sch_id
          ,decode(nvl(pfo.use_planning_rates_flag,'N'),'N',null,
                          decode(bv.version_type,'COST'   ,pfo.cost_burden_rate_sch_id,
                                                 'ALL'    ,pfo.cost_burden_rate_sch_id,
                                                 NULL))     cost_burden_rate_sch_id
          ,decode(nvl(bv.wp_version_flag,'N'),'Y',NVL(pfo.track_workplan_costs_flag,'N'),'Y') track_workplan_costs_flag
          ,bv.version_type fp_budget_version_type
          ,bv.resource_list_id
          ,nvl(bv.approved_rev_plan_type_flag,'N') approved_rev_plan_type_flag
          ,nvl(pfo.plan_in_multi_curr_flag,'N')    plan_in_multi_curr_flag
          ,bv.etc_start_date
          ,nvl(bv.wp_version_flag,'N') wp_version_flag
      ,pp.assign_precedes_task
          ,pp.bill_job_group_id
          ,pp.carrying_out_organization_id
          ,nvl(pp.multi_currency_billing_flag,'N') multi_currency_billing_flag
          ,pp.org_id
          ,pp.non_labor_bill_rate_org_id
          ,pp.project_currency_code
          ,pp.non_labor_schedule_discount
          ,pp.non_labor_schedule_fixed_date
          ,pp.non_lab_std_bill_rt_sch_id
          ,pp.project_type
          ,pp.projfunc_currency_code
          ,pp.emp_bill_rate_schedule_id
          ,pp.job_bill_rate_schedule_id
          ,pp.labor_bill_rate_org_id
          ,pp.labor_sch_type
          ,pp.non_labor_sch_type
      ,bv.project_structure_version_id
      ,bv.project_id
        FROM pa_proj_fp_options pfo
            ,pa_budget_versions bv
            ,pa_projects_all pp
        WHERE pfo.fin_plan_version_id = bv.budget_version_id
        AND bv.budget_version_id = p_budget_version_id
    AND pp.project_id = bv.project_id
    AND pfo.project_id = pp.project_id;
Line: 11942

        SELECT non_labor_bill_rate_org_id
           ,non_labor_schedule_discount
           ,non_labor_schedule_fixed_date
           ,non_lab_std_bill_rt_sch_id
           ,emp_bill_rate_schedule_id
           ,job_bill_rate_schedule_id
           ,labor_bill_rate_org_id
           ,labor_sch_type
           ,non_labor_sch_type
           ,top_task_id
        FROM pa_tasks t
        WHERE t.task_id = p_task_id
    AND  t.project_id = p_project_id;
Line: 12040

        /* declared for bulk processing of rollup tmp update */
        l_rl_cntr           NUMBER := 0;
Line: 12099

    /* declared for bulk processing of rollup tmp update */
        l_rl_cntr   := 0;
Line: 12101

        l_rlt_budget_line_id_tab.delete;
Line: 12102

        l_rlt_quantity_tab.delete;
Line: 12103

        l_rlt_bill_rate_tab.delete;
Line: 12104

        l_rlt_bill_rate_ovr_tab.delete;
Line: 12105

        l_rlt_cost_rate_tab.delete;
Line: 12106

        l_rlt_rw_cost_rate_ovr_tab.delete;
Line: 12107

        l_rlt_burden_cost_rate_tab.delete;
Line: 12108

        l_rlt_burden_cost_rate_ovr_tab.delete;
Line: 12109

        l_rlt_raw_cost_tab.delete;
Line: 12110

        l_rlt_burden_cost_tab.delete;
Line: 12111

        l_rlt_raw_revenue_tab.delete;
Line: 12112

        l_rlt_bill_markup_percent_tab.delete;
Line: 12113

        l_rlt_txn_curr_code_tab.delete;
Line: 12114

        l_rlt_raw_cost_rejection_tab.delete;
Line: 12115

        l_rlt_burden_rejection_tab.delete;
Line: 12116

        l_rlt_revenue_rejection_tab.delete;
Line: 12117

        l_rlt_projfunc_rejection_tab.delete;
Line: 12118

        l_rlt_project_rejection_tab.delete;
Line: 12119

        l_rlt_ind_compiled_set_tab.delete;
Line: 13376

                                     	* to call an api to update the interface table with the web adi error code
				     	*/
                                    	IF l_webAdi_calling_context = 'WEBADI_CALCULATE' THEN
                                          IF l_error_code = 'PA_FP_PROJ_NO_TXNCONVRATE' THEN
                                            -- populating the error tables.
                                            -- calling pa_fp_webadi_pkg.process_errors
                                            --print_msg('ConvErr:Web ADI context collecting errors');
Line: 13465

                                        * to call an api to update the interface table with the web adi error code
                                        */
                                        IF l_webAdi_calling_context = 'WEBADI_CALCULATE' THEN
                                          IF l_error_code = 'PA_FP_PROJ_NO_TXNCONVRATE' THEN
                                            -- populating the error tables.
                                            -- calling pa_fp_webadi_pkg.process_errors
                                            --print_msg('ConvErr:Web ADI context collecting errors');
Line: 13559

                                        * to call an api to update the interface table with the web adi error code
                                        */
                                        IF l_webAdi_calling_context = 'WEBADI_CALCULATE' THEN
                                          IF l_error_code = 'PA_FP_PROJ_NO_TXNCONVRATE' THEN
                                            -- populating the error tables.
                                            -- calling pa_fp_webadi_pkg.process_errors
                                            --print_msg('ConvErr:Web ADI context collecting errors');
Line: 13661

                                        * to call an api to update the interface table with the web adi error code
                                        */
                                        IF l_webAdi_calling_context = 'WEBADI_CALCULATE' THEN
                                          IF l_error_code = 'PA_FP_PROJ_NO_TXNCONVRATE' THEN
                                            -- populating the error tables.
                                            -- calling pa_fp_webadi_pkg.process_errors
                                            --print_msg('ConvErr:Web ADI context collecting errors');
Line: 13785

                                        * to call an api to update the interface table with the web adi error code
                                        */
                                        IF l_webAdi_calling_context = 'WEBADI_CALCULATE' THEN
                                          IF l_error_code = 'PA_FP_PROJ_NO_TXNCONVRATE' THEN
                                            -- populating the error tables.
                                            -- calling pa_fp_webadi_pkg.process_errors
                                            --print_msg('ConvErr:Web ADI context collecting errors');
Line: 13926

                                        * to call an api to update the interface table with the web adi error code
                                        */
                                        IF l_webAdi_calling_context = 'WEBADI_CALCULATE' THEN
                                          IF l_error_code = 'PA_FP_PROJ_NO_TXNCONVRATE' THEN
                                            -- populating the error tables.
                                            -- calling pa_fp_webadi_pkg.process_errors
                                            --print_msg('ConvErr:Web ADI context collecting errors');
Line: 14234

                print_msg(to_char(l_stage)||'Calling update_rollup_tmp with the following parameters:');
Line: 14265

        /* Now populate plsql tables for bulk update */
        l_rl_cntr := l_rl_cntr + 1;
Line: 14298

        UPDATE PA_FP_ROLLUP_TMP RL
        SET RL.QUANTITY = l_rlt_quantity_tab(i)
                  ,RL.BILL_RATE = l_rlt_bill_rate_tab(i)
                   ,RL.BILL_RATE_OVERRIDE = l_rlt_bill_rate_ovr_tab(i)
                   ,RL.COST_RATE = l_rlt_cost_rate_tab(i)
                   ,RL.RW_COST_RATE_OVERRIDE = l_rlt_rw_cost_rate_ovr_tab(i)
                   ,RL.BURDEN_COST_RATE = l_rlt_burden_cost_rate_tab(i)
                   ,RL.BURDEN_COST_RATE_OVERRIDE = l_rlt_burden_cost_rate_ovr_tab(i)
                   ,RL.TXN_RAW_COST = l_rlt_raw_cost_tab(i)
                   ,RL.TXN_BURDENED_COST = l_rlt_burden_cost_tab(i)
                   ,RL.TXN_REVENUE = l_rlt_raw_revenue_tab(i)
                   ,RL.BILL_MARKUP_PERCENTAGE = l_rlt_bill_markup_percent_tab(i)
                   ,RL.TXN_CURRENCY_CODE = l_rlt_txn_curr_code_tab(i)
                   ,RL.COST_REJECTION_CODE = l_rlt_raw_cost_rejection_tab(i)
                   ,RL.BURDEN_REJECTION_CODE = l_rlt_burden_rejection_tab(i)
                   ,RL.REVENUE_REJECTION_CODE = l_rlt_revenue_rejection_tab(i)
                   ,RL.PFC_CUR_CONV_REJECTION_CODE = l_rlt_projfunc_rejection_tab(i)
                   ,RL.PC_CUR_CONV_REJECTION_CODE = l_rlt_project_rejection_tab(i)
                   ,RL.COST_IND_COMPILED_SET_ID = l_rlt_ind_compiled_set_tab(i)
           ,RL.SYSTEM_REFERENCE5 = 'Y'
        WHERE RL.BUDGET_LINE_ID = l_rlt_budget_line_id_tab(i);
Line: 14340

                ,p_procedure_name => 'Get_Res_Rates:Update_rollupTmp_OvrRates');
Line: 15674

                Select project option attibutes required for RATE API and assign to local variables
                This only needs to be done once during the procedure
                */
                ProjFpOptRec := NULL;
Line: 15791

      for i in (select * from pa_fp_spread_calc_tmp ) LOOP
       print_msg('IN params ResId['||i.resource_assignment_id||']TxnCur['||i.txn_currency_code||']RefrFlag['||i.refresh_rates_flag||']');
Line: 15802

       INSERT INTO pa_fp_rollup_tmp (
    budget_version_id
        ,resource_assignment_id
       ,start_date
       ,end_date
       ,period_name
       ,quantity
       ,projfunc_raw_cost
       ,projfunc_burdened_cost
       ,projfunc_revenue
       ,cost_rejection_code
       ,revenue_rejection_code
       ,burden_rejection_code
       ,projfunc_currency_code
       ,projfunc_cost_rate_type
       ,projfunc_cost_exchange_rate
       ,projfunc_cost_rate_date_type
       ,projfunc_cost_rate_date
       ,projfunc_rev_rate_type
       ,projfunc_rev_exchange_rate
       ,projfunc_rev_rate_date_type
       ,projfunc_rev_rate_date
       ,project_currency_code
       ,project_cost_rate_type
       ,project_cost_exchange_rate
       ,project_cost_rate_date_type
       ,project_cost_rate_date
       ,project_raw_cost
       ,project_burdened_cost
       ,project_rev_rate_type
       ,project_rev_exchange_rate
       ,project_rev_rate_date_type
       ,project_rev_rate_date
       ,project_revenue
       ,txn_currency_code
       ,txn_raw_cost
       ,txn_burdened_cost
       ,txn_revenue
       ,budget_line_id
       ,init_quantity
       ,txn_init_raw_cost
       ,txn_init_burdened_cost
       ,txn_init_revenue
       ,bill_markup_percentage
       ,bill_rate
       ,cost_rate
       ,rw_cost_rate_override
       ,burden_cost_rate
       ,bill_rate_override
       ,burden_cost_rate_override
       ,cost_ind_compiled_set_id
       ,init_raw_cost
       ,init_burdened_cost
       ,init_revenue
       ,project_init_raw_cost
       ,project_init_burdened_cost
       ,project_init_revenue
       ,billable_flag
       )
       ( SELECT /*+ INDEX(BL PA_BUDGET_LINES_U1) */
	bl.budget_version_id
       ,bl.resource_assignment_id
       ,bl.start_date
       ,bl.end_date
       ,bl.period_name
       ,bl.quantity
       ,bl.raw_cost
       ,bl.burdened_cost
       ,bl.revenue
       ,bl.cost_rejection_code
       ,bl.revenue_rejection_code
       ,bl.burden_rejection_code
       ,bl.projfunc_currency_code
       ,bl.projfunc_cost_rate_type
       ,bl.projfunc_cost_exchange_rate
       ,bl.projfunc_cost_rate_date_type
       ,bl.projfunc_cost_rate_date
       ,bl.projfunc_rev_rate_type
       ,bl.projfunc_rev_exchange_rate
       ,bl.projfunc_rev_rate_date_type
       ,bl.projfunc_rev_rate_date
       ,bl.project_currency_code
       ,bl.project_cost_rate_type
       ,bl.project_cost_exchange_rate
       ,bl.project_cost_rate_date_type
       ,bl.project_cost_rate_date
       ,bl.project_raw_cost
       ,bl.project_burdened_cost
       ,bl.project_rev_rate_type
       ,bl.project_rev_exchange_rate
       ,bl.project_rev_rate_date_type
       ,bl.project_rev_rate_date
       ,bl.project_revenue
       ,bl.txn_currency_code
       ,bl.txn_raw_cost
       ,bl.txn_burdened_cost
       ,bl.txn_revenue
       ,bl.budget_line_id
       ,bl.init_quantity
       ,bl.txn_init_raw_cost
       ,bl.txn_init_burdened_cost
       ,bl.txn_init_revenue
       ,bl.txn_markup_percent
       ,bl.txn_standard_bill_rate
       ,bl.txn_standard_cost_rate
       ,bl.txn_cost_rate_override
       ,bl.burden_cost_rate
       ,bl.txn_bill_rate_override
       ,bl.burden_cost_rate_override
       ,bl.cost_ind_compiled_set_id
       ,bl.init_raw_cost
       ,bl.init_burdened_cost
       ,bl.init_revenue
       ,bl.project_init_raw_cost
       ,bl.project_init_burdened_cost
       ,bl.project_init_revenue
       ,tmp.billable_flag
       FROM pa_budget_lines bl
           ,pa_resource_assignments ra
       ,pa_fp_spread_calc_tmp tmp
	,pa_fp_rollup_tmp rlp --Bug 5203868
       WHERE tmp.budget_version_id = p_budget_version_id
           AND tmp.resource_assignment_id = ra.resource_assignment_id
	   AND  bl.resource_assignment_id = tmp.resource_assignment_id
	   AND   bl.txn_currency_code = tmp.txn_currency_code
	   AND   NVL(tmp.skip_record_flag,'N') = 'Y'
	   AND   ((p_calling_mode = 'PROCESS_CST_REV_MIX'
		  and nvl(tmp.processed_flag,'N') = 'Y' )
		  OR
		  p_calling_mode <> 'PROCESS_CST_REV_MIX'
		 )
	   AND  ((p_source_context = 'BUDGET_LINE'
		 and bl.start_date BETWEEN tmp.start_date and tmp.end_date)
		 OR
		 p_source_context <> 'BUDGET_LINE'
		)
	   --Bug 5203868. Replaced the NOT EXISTS with the following
                AND   rlp.resource_assignment_id(+)=tmp.resource_assignment_id
                AND   rlp.txn_currency_code(+)=tmp.txn_currency_code
                AND   rlp.rowid IS NULL
             /* Commenting below code for bug 5203868
               AND   NOT EXISTS
                (select null
                 from pa_fp_rollup_tmp rl1
                 Where rl1.resource_assignment_id = tmp.resource_assignment_id
                 and rl1.txn_currency_code = tmp.txn_currency_code
                )
             */
    	);
Line: 15954

	print_msg('Process_skipped_records :Number of records inserted['||sql%rowcount||']');