DBA Data[Home] [Help]

APPS.PA_FUND_REVAL_PVT SQL Statements

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

Line: 28

   |                                   Values are 'SINGLE', 'RANGE', 'DELETE'                |
   |     x_return_status       OUT     Return status of this procedure                       |
   |     x_msg_count           OUT     Error message count                                   |
   |     x_msg_data            OUT     Error message                                         |
   |     ==================================================================================  |
   +----------------------------------------------------------------------------------------*/


   PROCEDURE Revaluate_funding(
             p_project_id        IN    NUMBER,
             p_project_type_id   IN    NUMBER,
             p_from_proj_number  IN    VARCHAR2,
             p_to_proj_number    IN    VARCHAR2,
             p_thru_date         IN    DATE,
             p_rate_type         IN    VARCHAR2	,
             p_rate_date         IN    DATE,
             p_baseline_flag     IN    VARCHAR2,
             p_debug_mode        IN    VARCHAR2,
             p_run_mode          IN    VARCHAR2,
             x_return_status     OUT   NOCOPY VARCHAR2,
             x_msg_count         OUT   NOCOPY NUMBER,
             x_msg_data          OUT   NOCOPY VARCHAR2)   IS

         l_FromProjNum              VARCHAR2(25);
Line: 131

         IF p_run_mode = 'DELETE' THEN

            get_delete_projects(
                p_project_type_id   => l_ProjTypeId,
                p_from_proj_number  => l_FromProjNum,
                p_to_proj_number    => l_ToProjNum,
                p_run_mode          => p_run_mode,
                x_return_status     => l_return_status,
                x_msg_count         => l_msg_count,
                x_msg_data          => l_msg_data);
Line: 190

         END IF; /* p_run_mode = DELETE */
Line: 326

            Insert_distribution_warnings(p_project_id     => p_project_id,
                                    p_reason_code    => l_ReasonCode,
                                    x_return_status  => l_return_status,
                                    x_msg_count      => l_msg_count,
                                    x_msg_data       => l_msg_data) ;
Line: 364

               Delete_unbaselined_adjmts(p_project_id     => p_project_id,
                                         p_run_mode       => p_run_mode,
                                         x_return_status  => l_return_status,
                                         x_msg_count      => l_msg_count,
                                         x_msg_data       => l_msg_data) ;
Line: 384

               Insert_distribution_warnings(p_project_id     => p_project_id,
                                       p_reason_code    => l_ReasonCode,
                                       x_return_status  => l_return_status,
                                       x_msg_count      => l_msg_count,
                                       x_msg_data       => l_msg_data) ;
Line: 466

       /* This CURSOR selects all reporting set of books enabled for the primary set of book id
          in PA */

       /* R12 :  Ledger Architecture Changes : The table gl_mc_reporting_options will  obsoleted, replace with
          new table gl_alc_ledger_rships_v and corresponding columns */

       /* CURSOR rsob is SELECT rep.reporting_set_of_books_id reporting_set_of_books_id ,
                             rep.reporting_currency_code, rep.conversion_type
                      FROM   gl_mc_reporting_options rep, pa_implementations imp
                      WHERE  rep.primary_set_of_books_id = imp.set_of_books_id
                      AND    enabled_flag = 'Y'
                      AND    rep.org_id = imp.org_id
                      AND    application_id = 275;  */
Line: 480

          CURSOR rsob is SELECT rep.ledger_id   reporting_set_of_books_id ,
                             rep.currency_code reporting_currency_code,
                             rep.alc_default_conv_rate_type conversion_type
                      FROM   gl_alc_ledger_rships_v rep, pa_implementations imp
                      WHERE  rep.source_ledger_id = imp.set_of_books_id
                      AND    rep.relationship_enabled_flag  = 'Y'
                      AND    (rep.org_id = -99 OR rep.org_id = imp.org_id)
                      AND    rep.application_id = 275;
Line: 492

       /* This CURSOR selects all reporting set of books enabled for the primary set of book id
          in AR */

       /* R12 :  Ledger Architecture Changes : The table gl_mc_reporting_options will  obsoleted, replace with
          new table gl_alc_ledger_rships_v and corresponding columns */


      /*  CURSOR rsob_ar_mc is SELECT rep.reporting_set_of_books_id reporting_set_of_books_id ,
                             rep.reporting_currency_code, rep.conversion_type
                      FROM   gl_mc_reporting_options rep, pa_implementations imp
                      WHERE  rep.primary_set_of_books_id = imp.set_of_books_id
                      AND    enabled_flag = 'Y'
                      AND    rep.org_id = imp.org_id
                      AND    application_id = PA_FUND_REVAL_UTIL.get_ar_application_id;  */
Line: 508

          CURSOR rsob_ar_mc is SELECT rep.ledger_id reporting_set_of_books_id ,
                             rep.currency_code reporting_currency_code,
                             rep.alc_default_conv_rate_type conversion_type
                      FROM   gl_alc_ledger_rships_v  rep, pa_implementations imp
                      WHERE  rep.source_ledger_id  = imp.set_of_books_id
                      AND    rep.relationship_enabled_flag  = 'Y'
                      AND    (rep.org_id = -99 OR rep.org_id = imp.org_id)
                      AND    application_id = PA_FUND_REVAL_UTIL.get_ar_application_id;
Line: 543

         SELECT set_of_books_id, nvl(ENABLE_MRC_FOR_FUND_FLAG , 'N')
         into G_SET_OF_BOOKS_ID, G_MRC_FUND_ENABLED_FLAG FROM pa_implementations;
Line: 547

         SELECT set_of_books_id, 'N' -- nvl(REVAL_MRC_FUNDING_FLAG , 'N')
         into G_SET_OF_BOOKS_ID, G_MRC_FUND_ENABLED_FLAG FROM pa_implementations;
Line: 732

           SELECT p.segment1, pt.project_type_id
           INTO l_FromProjNum, l_ProjTypeId
           FROM pa_projects p, pa_project_types pt
           WHERE p.project_id = p_project_id
           AND pt.project_type = p.project_type;
Line: 746

                 SELECT MIN(P.segment1)
                 INTO l_FromProjNum
                 FROM PA_PROJECTS P , PA_PROJECT_TYPES T
                 WHERE  T.project_type_id (+) = l_ProjTypeId
                 AND    P.Project_type = T.Project_type
                 AND    T.Project_type_class_code = 'CONTRACT';
Line: 755

               SELECT proj.seg1
               INTO l_FromProjNum
               FROM (
                       SELECT t.project_type_class_code, MIN(P.segment1) seg1
                       FROM PA_PROJECTS P , PA_PROJECT_TYPES T
                       WHERE  T.project_type_id  = NVL(l_ProjTypeId,0)
                       AND    P.Project_type  = T.Project_type
                       AND    T.Project_type_class_code = 'CONTRACT'
                       AND    NVL(l_ProjTypeId,0) <> 0
                       GROUP BY t.project_type_class_code
                       UNION
                       SELECT t.project_type_class_code, MIN(P.segment1) seg1
                       FROM PA_PROJECTS P , PA_PROJECT_TYPES T
                       WHERE P.Project_type  = T.Project_type
                       AND    T.Project_type_class_code = 'CONTRACT'
                       AND nvl(l_ProjTypeId,0) = 0
                        group by t.project_type_class_code
                       )  proj;
Line: 786

                 SELECT MAX(P.segment1)
                 INTO l_ToProjNum
                 FROM PA_PROJECTS P , PA_PROJECT_TYPES T
                 WHERE  T.project_type_id (+) = l_ProjTypeId
                 AND    P.Project_type = T.Project_type
                 AND    T.Project_type_class_code = 'CONTRACT';
Line: 795

               SELECT proj.seg1
               INTO l_ToProjNum
               FROM (
                       SELECT t.project_type_class_code, MAX(P.segment1) seg1
                       FROM PA_PROJECTS P , PA_PROJECT_TYPES T
                       WHERE  T.project_type_id  = NVL(l_ProjTypeId,0)
                       AND    P.Project_type  = T.Project_type
                       AND    T.Project_type_class_code = 'CONTRACT'
                       AND    NVL(l_ProjTypeId,0) <> 0
                       GROUP BY t.project_type_class_code
                       UNION
                       SELECT t.project_type_class_code, MAX(P.segment1) seg1
                       FROM PA_PROJECTS P , PA_PROJECT_TYPES T
                       WHERE P.Project_type  = T.Project_type
                       AND    T.Project_type_class_code = 'CONTRACT'
                       AND nvl(l_ProjTypeId,0) = 0
                        group by t.project_type_class_code
                       )  proj;
Line: 922

            SELECT 'T' INTO x_exist_flag
            FROM DUAL
            WHERE EXISTS ( SELECT NULL
                       FROM pa_draft_revenues r
                       WHERE r.project_id = p_project_id
                       AND   r.released_date IS NULL);
Line: 949

               SELECT 'T' INTO x_exist_flag
               FROM DUAL
               WHERE EXISTS ( SELECT NULL
                              FROM   pa_draft_invoices i
                              WHERE  i.project_id = p_project_id
                              and    i.released_by_person_id IS NULL);
Line: 1018

         SELECT 'T' INTO l_ExistFlag
         FROM DUAL
         WHERE EXISTS (SELECT NULL
                       FROM pa_project_fundings
                       WHERE project_id = p_project_id
                       AND funding_category = 'REVALUATION'
                       AND budget_type_code = 'DRAFT');
Line: 1043

   |   Procedure  :   Delete_unbaselined_adjmts                                              |
   |   Purpose    :   To delete (if any) unbaselined revaluation adjutment lines             |
   |   Parameters :                                                                          |
   |     ==================================================================================  |
   |     Name                             Mode    Description                                |
   |     ==================================================================================  |
   |     p_project_id          IN      Project ID                                            |
   |     p_run_mode            IN      Run Mode - SINGLE,RANGE, DELETE                       |
   |     x_return_status       OUT     Return status of this procedure                       |
   |     x_msg_count           OUT     Error message count                                   |
   |     x_msg_data            OUT     Error message                                         |
   |     ==================================================================================  |
   +----------------------------------------------------------------------------------------*/

   PROCEDURE Delete_Unbaselined_Adjmts (
             p_project_id        IN    NUMBER,
             p_run_mode          IN    VARCHAR2,
             x_return_status     OUT   NOCOPY VARCHAR2,
             x_msg_count         OUT   NOCOPY NUMBER,
             x_msg_data          OUT   NOCOPY VARCHAR2)   IS

         CURSOR fund_recs is
                SELECT project_funding_id, agreement_id, project_id, task_id, projfunc_allocated_amount,
                       projfunc_realized_gains_amt, projfunc_realized_losses_amt, invproc_allocated_amount,
                       revproc_allocated_amount
                FROM pa_project_fundings
                WHERE project_id = p_project_id
                AND funding_category = 'REVALUATION'
                AND budget_type_code = 'DRAFT';
Line: 1100

            PA_DEBUG.g_err_stage := '-----------Entering PA_FUND_REVAL_PVT.Delete_Unbaselined_Adjmts-----------' ;
Line: 1124

                        DELETE FROM pa_events
                        WHERE project_funding_id = l_FundingIdTab(i)
			AND   Project_ID         = l_ProjectIdTab(i);
Line: 1129

                        DELETE FROM pa_project_fundings
                        WHERE project_funding_id = l_FundingIdTab(i);
Line: 1133

                        UPDATE pa_summary_project_fundings
                        SET    projfunc_unbaselined_amount =
                                      nvl(projfunc_unbaselined_amount,0) - nvl(l_ProjfuncAllocTab(i),0),
                               invproc_unbaselined_amount =
                                      nvl(invproc_unbaselined_amount,0) - nvl(l_InvprocAllocTab(i),0),
                               revproc_unbaselined_amount =
                                      nvl(revproc_unbaselined_amount,0) - nvl(l_RevprocAllocTab(i),0),
                               projfunc_realized_gains_amt =
                                      nvl(projfunc_realized_gains_amt,0) - nvl(l_ProjfuncGainsTab(i),0),
                               projfunc_realized_losses_amt =
                                      nvl(projfunc_realized_losses_amt,0) - nvl(l_ProjfuncLossTab(i),0)
                        WHERE agreement_id = l_AgreementIdTab(i)
                        AND   project_id = l_ProjectIdTab(i)
                        AND   nvl(task_id,-99) = nvl(l_TaskIdTab(i),-99);
Line: 1148

                 /* Insert the details of project funding line deleted as delete process requires output */

                 IF p_run_mode = 'DELETE' THEN

                    l_ReasonCode := NULL;
Line: 1156

                        Insert_distribution_warnings(
                               p_project_id     => p_project_id,
                               p_task_id        => l_TaskIdTab(j),
                               p_agreement_id   => l_AgreementIdTab(j),
                               p_reason_code    => l_ReasonCode,
                               x_return_status  => l_return_status,
                               x_msg_count      => l_msg_count,
                               x_msg_data       => l_msg_data) ;
Line: 1178

                 END IF; /*p_run_mode = 'DELETE' */
Line: 1183

              l_FundingIdTab.DELETE;
Line: 1184

              l_AgreementIdTab.DELETE;
Line: 1185

              l_ProjectIdTab.DELETE;
Line: 1186

              l_TaskIdTab.DELETE;
Line: 1187

              l_ProjfuncAllocTab.DELETE;
Line: 1188

              l_ProjfuncGainsTab.DELETE;
Line: 1189

              l_ProjfuncLossTab.DELETE;
Line: 1190

              l_InvprocAllocTab.DELETE;
Line: 1191

              l_RevprocAllocTab.DELETE;
Line: 1202

            PA_DEBUG.g_err_stage := '-----------Exiting PA_FUND_REVAL_PVT.Delete_Unbaselined_Adjmts-----------' ;
Line: 1226

                PA_DEBUG.g_err_stage := 'Delete_Unbaselined_Adjmts:' || x_msg_data ;
Line: 1231

   END Delete_Unbaselined_Adjmts;
Line: 1235

   |   Procedure  :   Insert_distribution_warnings                                                |
   |   Purpose    :   To insert rejection reasons in distribution table                      |
   |   Parameters :                                                                          |
   |     ==================================================================================  |
   |     Name                             Mode    Description                                |
   |     ==================================================================================  |
   |     p_project_id          IN      Project ID                                            |
   |     p_agreement_id        IN      Agreement ID                                          |
   |     p_task_id             IN      Task id of summary project funding                    |
   |     p_reason_code         IN      Rejection Reason                                      |
   |     x_return_status       OUT     Return status of this procedure                       |
   |     x_msg_count           OUT     Error message count                                   |
   |     x_msg_data            OUT     Error message                                         |
   |     ==================================================================================  |
   +----------------------------------------------------------------------------------------*/

   PROCEDURE Insert_distribution_warnings(
             p_project_id        IN    NUMBER,
             p_agreement_id      IN    NUMBER DEFAULT NULL,
             p_task_id           IN    NUMBER DEFAULT NULL,
             p_reason_code       IN    VARCHAR2,
             x_return_status     OUT   NOCOPY VARCHAR2,
             x_msg_count         OUT   NOCOPY NUMBER,
             x_msg_data          OUT   NOCOPY VARCHAR2)   IS


         l_return_status             VARCHAR2(30) := NULL;
Line: 1268

         CURSOR rej_reason IS SELECT meaning FROM PA_LOOKUPS
                WHERE lookup_type =  'FUNDING REVAL REJECTION'
                AND   lookup_code = p_reason_code;
Line: 1278

            PA_DEBUG.g_err_stage := '-----------Entering PA_FUND_REVAL_PVT.Insert_distribution_warnings-----------' ;
Line: 1294

         INSERT INTO PA_DISTRIBUTION_WARNINGS
         (
              PROJECT_ID, AGREEMENT_ID, TASK_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY,
              CREATION_DATE, CREATED_BY, REQUEST_ID, PROGRAM_APPLICATION_ID,
              PROGRAM_ID, PROGRAM_UPDATE_DATE, WARNING_MESSAGE_CODE, WARNING_MESSAGE
         )
         VALUES
         (
              p_project_id, p_agreement_id, p_task_id, SYSDATE, G_LAST_UPDATED_BY,
              SYSDATE, G_LAST_UPDATED_BY, G_REQUEST_ID, G_PROGRAM_APPLICATION_ID,
              G_PROGRAM_ID, SYSDATE, p_reason_code, l_reason
         );
Line: 1309

            PA_DEBUG.g_err_stage := '-----------Exiting PA_FUND_REVAL_PVT.Insert_distribution_warnings-----------' ;
Line: 1333

                PA_DEBUG.g_err_stage := 'Insert_distribution_warnings:' || x_msg_data ;
Line: 1338

   END Insert_distribution_warnings;
Line: 1363

         G_LAST_UPDATE_LOGIN := fnd_global.login_id;
Line: 1367

         G_LAST_UPDATED_BY := fnd_global.user_id;
Line: 1413

       /* This CURSOR selects all projects with the following criteria
              a) should be contract  projects
              b) revaluate_funding_flag is enabled
              c) Falls within the given range start/end project numbers */

         CURSOR open_projects IS
                SELECT P.project_id, P.baseline_funding_flag,
                       P.include_gains_losses_flag include_gains_losses_flag,
                       P.carrying_out_organization_id,
                       P.projfunc_bil_rate_type projfunc_bil_rate_type,
                       P.projfunc_bil_exchange_rate projfunc_bil_exchange_rate,
                       DECODE(P.invproc_currency_type,
                              'PROJECT_CURRENCY', P.project_bil_rate_type,
                              'PROJFUNC_CURRENCY', P.projfunc_bil_rate_type,
                              'FUNDING_CURRENCY', P.funding_rate_type) invproc_rate_type,
                       DECODE(P.invproc_currency_type,
                              'PROJECT_CURRENCY', P.project_bil_exchange_rate,
                              'PROJFUNC_CURRENCY', P.projfunc_bil_exchange_rate,
                              'FUNDING_CURRENCY', P.funding_exchange_rate) invproc_exchange_rate,
                       T.RLZD_GAINS_EVENT_TYPE_ID,
                       T.RLZD_LOSSES_EVENT_TYPE_ID
                FROM pa_projects P, pa_project_types T
                WHERE P.segment1 BETWEEN p_from_proj_number
                               AND p_to_proj_number
                AND   P.PROJECT_TYPE = T.PROJECT_TYPE
                AND   T.DIRECT_FLAG = 'Y'
                AND   T.PROJECT_TYPE_ID  = NVL(P_PROJECT_TYPE_ID ,T.project_type_id)
                AND   NVL(P.revaluate_funding_flag, 'N') = 'Y'
                AND   NVL(P.template_flag, 'N') = 'N'
                ORDER BY segment1 ;
Line: 1447

                SELECT event_type, description from pa_event_types
                WHERE event_type_id  = l_EventTypeId;
Line: 1518

                G_InvCompTab.DELETE;
Line: 1519

                G_RetnApplAmtTab.DELETE;
Line: 1520

                G_RevalCompTab.DELETE;
Line: 1578

                      Insert_distribution_warnings(
                             p_project_id     => G_ProjLvlGlobRec.project_id,
                             p_reason_code    => l_ReasonCode,
                             x_return_status  => l_return_status,
                             x_msg_count      => l_msg_count,
                             x_msg_data       => l_msg_data) ;
Line: 1620

                            /*Bug 3986205 : Replaced p_project_id with G_ProjLvlGlobRec.project_id in the following INSERT statement */

                            INSERT INTO PA_DISTRIBUTION_WARNINGS
                            (
                                 PROJECT_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY,
                                 CREATION_DATE, CREATED_BY, REQUEST_ID, PROGRAM_APPLICATION_ID,
                                 PROGRAM_ID, PROGRAM_UPDATE_DATE, WARNING_MESSAGE_CODE, WARNING_MESSAGE
                            )
                            VALUES
                            (
                                 G_ProjLvlGlobRec.project_id, SYSDATE, G_LAST_UPDATED_BY,
                                 SYSDATE, G_LAST_UPDATED_BY, G_REQUEST_ID, G_PROGRAM_APPLICATION_ID,
                                 G_PROGRAM_ID, SYSDATE, 'BASELINE ERROR', l_msg_data
                            );
Line: 1702

         /* This CURSOR selects the summary project funding lines with non-zero baselined amount
            for the given project in primary set of book id only*/

         CURSOR get_spf_lines (l_ProjectId NUMBER) is
                SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                       SPF.agreement_id   agreement_id,
                       SPF.task_id   task_id,
                       SPF.funding_currency_code funding_currency_code,
                       SPF.project_currency_code project_currency_code,
                       SPF.projfunc_currency_code projfunc_currency_code,
                       SPF.invproc_currency_code invproc_currency_code,
                       SPF.total_baselined_amount total_baselined_amount,
                       SPF.projfunc_baselined_amount projfunc_baselined_amount,
                       SPF.invproc_baselined_amount invproc_baselined_amount,
                       SPF.projfunc_realized_gains_amt projfunc_realized_gains_amt,
                       SPF.projfunc_realized_losses_amt projfunc_realized_losses_amt,
                       SPF.projfunc_accrued_amount projfunc_accrued_amount,
                       SPF.invproc_billed_amount invproc_billed_amount,
                       PC.retention_level_code retention_level_code,
                       PC.customer_id customer_id
                FROM   pa_summary_project_fundings SPF, pa_agreements_all A, pa_project_customers PC
                WHERE  SPF.project_id = l_ProjectId
                AND    A.agreement_id = SPF.agreement_id
                AND    PC.customer_id = A.customer_id
                AND    PC.project_id = SPF.project_id
                AND    (NVL(SPF.total_baselined_amount,0) <> 0)
                ORDER BY PC.customer_id, SPF.agreement_id, SPF.task_id , set_of_books_id;
Line: 1730

         /* This CURSOR selects the summary project funding lines with non-zero baselined amount
            for the given project in primary and reporting set of book ids */


        /* R12 :  Ledger Architecture Changes : The table gl_mc_reporting_options will  obsoleted, replace with
           new table gl_alc_ledger_rships_v and corresponding columns */

/* mrc migration to SLA bug 4571438
         CURSOR get_all_spf_lines (l_ProjectId NUMBER) is
                (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                        SPF.agreement_id   agrmt_id,
                        SPF.task_id   task_id,
                        SPF.funding_currency_code funding_currency_code,
                        SPF.project_currency_code project_currency_code,
                        SPF.projfunc_currency_code projfunc_currency_code,
                        SPF.invproc_currency_code invproc_currency_code,
                        SPF.total_baselined_amount total_baselined_amount,
                        SPF.projfunc_baselined_amount projfunc_baselined_amount,
                        SPF.invproc_baselined_amount invproc_baselined_amount,
                        SPF.projfunc_realized_gains_amt projfunc_realized_gains_amt,
                        SPF.projfunc_realized_losses_amt projfunc_realized_losses_amt,
                        SPF.projfunc_accrued_amount projfunc_accrued_amount,
                        SPF.invproc_billed_amount invproc_billed_amount,
                        PC.retention_level_code retention_level_code,
                        PC.customer_id cust_id
                 FROM   pa_summary_project_fundings SPF, pa_agreements_all A, pa_project_customers PC
                 WHERE  SPF.project_id = l_ProjectId
                 AND    A.agreement_id = SPF.agreement_id
                 AND    PC.customer_id = A.customer_id
                 AND    PC.project_id = SPF.project_id
                 AND    (NVL(SPF.total_baselined_amount,0) <> 0)
                UNION
                 SELECT SPF_mc.set_of_books_id,
                        SPF.agreement_id   agrmt_id,
                        SPF.task_id   task_id,
                        SPF.funding_currency_code funding_currency_code,
                        'NA' project_currency_code,
                        SPF_mc.currency_code projfunc_currency_code,
                        SPF.invproc_currency_code invproc_currency_code,
                        SPF.total_baselined_amount total_baselined_amount,
                        SPF_mc.total_baselined_amount projfunc_baselined_amount,
                        SPF.invproc_baselined_amount invproc_baselined_amount,
                        SPF_mc.realized_gains_amt projfunc_realized_gains_amt,
                        SPF_mc.realized_losses_amt projfunc_realized_losses_amt,
                        SPF_mc.total_accrued_amount projfunc_accrued_amount,
                        SPF.invproc_billed_amount invproc_billed_amount,
                        PC.retention_level_code retention_level_code,
                        PC.customer_id cust_id
                 FROM   pa_mc_sum_proj_fundings SPF_mc,  pa_summary_project_fundings SPF,
                        pa_agreements_all A, pa_project_customers PC,
                        gl_alc_ledger_rships_v  rep, pa_implementations imp
                 WHERE SPF.project_id = l_ProjectId
                 AND   A.agreement_id = SPF.agreement_id
                 AND   PC.customer_id = A.customer_id
                 AND   PC.project_id = SPF.project_id
                 AND   (NVL(SPF.total_baselined_amount,0) <> 0)
                 AND   rep.source_ledger_id = imp.set_of_books_id
                 AND   rep.relationship_enabled_flag  = 'Y'
                 AND   (rep.org_id = -99 OR rep.org_id = imp.org_id)
                 AND   rep.application_id = 275
                 AND   spf_mc.set_of_books_id =rep.ledger_id
                 AND   spf_mc.project_id = spf.project_id
                 AND   spf_mc.agreement_id = spf.agreement_id
                 AND   nvl(spf_mc.task_id,0) = nvl(spf.task_id,0)
                )
                ORDER BY cust_id, agrmt_id, task_id , set_of_books_id; */
Line: 1852

         G_RevalCompTab.DELETE; /* Intialize for each project */
Line: 1908

                      G_RevalCompTab.DELETE; /* Initialize for next SPF record */
Line: 1925

               l_SetOfBookIdTab.DELETE;
Line: 1926

               l_AgreementIdTab.DELETE;
Line: 1927

               l_TaskIdTab.DELETE;
Line: 1928

               l_FCCurrTab.DELETE;
Line: 1929

               l_PCCurrTab.DELETE;
Line: 1930

               l_PFCCurrTab.DELETE;
Line: 1931

               l_IPCCurrTab.DELETE;
Line: 1932

               l_FCBaseAmtTab.DELETE;
Line: 1933

               l_PFCBaseAmtTab.DELETE;
Line: 1934

               l_IPCBaseAmtTab.DELETE;
Line: 1935

               l_PFCGainAmtTab.DELETE;
Line: 1936

               l_PFCLossAmtTab.DELETE;
Line: 1937

               l_PFCAccruedAmtTab.DELETE;
Line: 1938

               l_IPCBilledAmtTab.DELETE;
Line: 1939

               l_RetnLevelTab.DELETE;
Line: 1940

               l_CustomerIdTab.DELETE;
Line: 1996

                          G_RevalCompTab.DELETE;
Line: 2047

                        G_RevalCompTab.DELETE;
Line: 2066

               l_SetOfBookIdTab.DELETE;
Line: 2067

               l_AgreementIdTab.DELETE;
Line: 2068

               l_TaskIdTab.DELETE;
Line: 2069

               l_FCCurrTab.DELETE;
Line: 2070

               l_PCCurrTab.DELETE;
Line: 2071

               l_PFCCurrTab.DELETE;
Line: 2072

               l_IPCCurrTab.DELETE;
Line: 2073

               l_FCBaseAmtTab.DELETE;
Line: 2074

               l_PFCBaseAmtTab.DELETE;
Line: 2075

               l_IPCBaseAmtTab.DELETE;
Line: 2076

               l_PFCGainAmtTab.DELETE;
Line: 2077

               l_PFCLossAmtTab.DELETE;
Line: 2078

               l_PFCAccruedAmtTab.DELETE;
Line: 2079

               l_IPCBilledAmtTab.DELETE;
Line: 2080

               l_RetnLevelTab.DELETE;
Line: 2081

               l_CustomerIdTab.DELETE;
Line: 2115

            Insert_distribution_warnings(
                  p_project_id     => G_ProjLvlGlobRec.project_id,
                  p_reason_code    => l_ReasonCode,
                  x_return_status  => l_return_status,
                  x_msg_count      => l_msg_count,
                  x_msg_data       => l_msg_data) ;
Line: 2257

               G_InvCompTab.DELETE;
Line: 2258

               G_RetnApplAmtTab.DELETE;
Line: 2503

              SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     di.draft_invoice_num,
                     dii.projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference,
                     di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND di.transfer_status_code = 'A'
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num, dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code,
                       di.system_reference,di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y');
Line: 2540

              (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference,
                     di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND di.transfer_status_code = 'A'
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num, dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code,
                       di.system_reference,di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
             UNION
              SELECT dii_mc.set_of_books_id,
                     di.draft_invoice_num drft_inv_num,
                     dii_mc.currency_code projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference,
                     di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii_mc.amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount
              FROM pa_draft_invoice_items dii, pa_mc_draft_inv_items dii_mc, pa_draft_invoices di,
                   gl_alc_ledger_rships_v rep, pa_implementations imp
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND di.transfer_status_code = 'A'
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND rep.source_ledger_id  = imp.set_of_books_id
              AND rep.relationship_enabled_flag = 'Y'
              AND (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = dii.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num, dii_mc.set_of_books_id, dii_mc.currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference,di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
               )
              ORDER BY drft_inv_num, set_of_books_id; */
Line: 2722

                       l_RetnInvTab.DELETE;
Line: 2740

                l_SetOfBookIdTab.DELETE;
Line: 2741

                l_DraftInvNumTab.DELETE;
Line: 2742

                l_PFCCurrTab.DELETE;
Line: 2743

                l_FCCurrTab.DELETE;
Line: 2744

                l_ITCCurrTab.DELETE;
Line: 2745

                l_SysRefTab.DELETE;
Line: 2746

                l_CancelFlgTab.DELETE;
Line: 2747

                l_CrMemoFlgTab.DELETE;
Line: 2748

                l_WrOffFlgTab.DELETE;
Line: 2749

                l_ClCrMemoFlgTab.DELETE;
Line: 2750

                l_BillAmtPFCTab.DELETE;
Line: 2751

                l_BillAmtFCTab.DELETE;
Line: 2752

                l_BillAmtITCTab.DELETE;
Line: 2807

                          l_RetnInvTab.DELETE;
Line: 2862

                     l_RetnInvTab.DELETE;
Line: 2881

                l_SetOfBookIdTab.DELETE;
Line: 2882

                l_DraftInvNumTab.DELETE;
Line: 2883

                l_PFCCurrTab.DELETE;
Line: 2884

                l_FCCurrTab.DELETE;
Line: 2885

                l_ITCCurrTab.DELETE;
Line: 2886

                l_SysRefTab.DELETE;
Line: 2887

                l_CancelFlgTab.DELETE;
Line: 2888

                l_ClCrMemoFlgTab.DELETE;
Line: 2889

                l_WrOffFlgTab.DELETE;
Line: 2890

                l_CrMemoFlgTab.DELETE;
Line: 2891

                l_BillAmtPFCTab.DELETE;
Line: 2892

                l_BillAmtFCTab.DELETE;
Line: 2893

                l_BillAmtITCTab.DELETE;
Line: 3006

         l_ArAmtsTab.DELETE;
Line: 3271

       /* The following CURSOR will select all invoices for given project/agreement for
          primary set of book id and will get executed for
          a) project level funding/project level retention - p_task_id will be zero
          b) project level funding/task level retention    -p_task_id will be zero
                  All task level retention amounts will be summarized to project level funding amounts
       */

       CURSOR get_proj_invoices IS
             (SELECT 'REGULAR-PROJ' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     0 task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code, dii.projfunc_currency_code, dii.funding_currency_code,
                     di.inv_currency_code, di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference, di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'RETENTION-PROJ' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     0 task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code, dii.projfunc_currency_code, dii.funding_currency_code,
                     di.inv_currency_code, di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference, di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y'))
              ORDER BY drft_inv_num;
Line: 3345

       /* The following CURSOR will select all invoices for given project/agreement for
          primary and reporting set of book ids  */


  /* R12 :  Ledger Architecture Changes : The table gl_mc_reporting_options will be  obsolete, replace with
     new table gl_alc_ledger_rships_v and corresponding columns */

/* mrc migration to SLA bug 4571438
       CURSOR get_all_proj_invoices IS
             (SELECT 'REGULAR-PROJ' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     0 task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code, dii.projfunc_currency_code, dii.funding_currency_code,
                     di.inv_currency_code, di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference , di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'RETENTION-PROJ' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     0 task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code,
                     dii.projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference,
                     di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference , di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'REGULAR-PROJ' invoice_type,
                     dii_mc.set_of_books_id,
                     0 task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code,
                     dii_mc.currency_code projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference,
                     di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii_mc.amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_mc_draft_inv_items dii_mc, pa_draft_invoice_items dii, pa_draft_invoices di,
                   gl_alc_ledger_rships_v rep, pa_implementations imp
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND dii.invoice_line_type <> 'RETENTION'
              AND rep.source_ledger_id = imp.set_of_books_id
              AND rep.relationship_enabled_flag  = 'Y'
              AND  (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = dii.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,dii_mc.set_of_books_id,
                       dii.invproc_currency_code, dii_mc.currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference , di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'RETENTION-PROJ' invoice_type,
                     dii_mc.set_of_books_id,
                     0 task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code,
                     dii_mc.currency_code projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference,
                     di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii_mc.amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_mc_draft_inv_items dii_mc, pa_draft_invoice_items dii, pa_draft_invoices di,
                   gl_alc_ledger_rships_v rep, pa_implementations imp
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND rep.source_ledger_id = imp.set_of_books_id
              AND rep.relationship_enabled_flag  = 'Y'
              AND (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = di.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,dii_mc.set_of_books_id,
                       dii.invproc_currency_code, dii_mc.currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference, di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       DECOde(di.draft_invoice_num_credited, NULL, 'N', 'Y')
                )
              ORDER BY drft_inv_num, set_of_books_id; */
Line: 3514

       /* The following CURSOR will select all invoices for given project/agreement for
          primary set of book id and will get executed for
          a) task level funding/task level retention
          In the case of task level funding /project level retention, only the regular invoices will get selected
          Also the retained amount for the task is obtained separately from RDL.DII.ERDL. To eliminate project
          level retention lines from regular invoice, nvl(dii.task_id) <> 0 is added
          Project level Retention invoices are not required as the retained amount will be calculated for each invoice
          from RDL ERDL DII. These are eliminated by the check nvl(dii.task_id,0) <> 0
       */
       CURSOR get_task_invoices IS
             (SELECT 'REGULAR-TASK' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     dii.task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code, dii.projfunc_currency_code, dii.funding_currency_code,
                     di.inv_currency_code, di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,

/*
                     The following is commented and changed as below.

                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount

                     Standard line amount is required to get the billed amount in PA

                     Retention line amount is required to get the Net line amount (standard - retention)

                     Net line amount is required as AR amounts (invoice level)  are for net invoice amount

                     In order to get the task level (line level) AR amounts, invoice level  AR amounts will be
                     prorated.
                            (invoice level AR amount / invoice level net amount) * task level net amount
*/
/*                  Commented for bug 2794334
                     sum(decode(dii.invoice_line_type,'STANDARD',
                              dii.amount,0)) amount,
                     sum(decode(dii.invoice_line_type,'STANDARD',
                              dii.projfunc_bill_amount,0)) projfunc_bill_amount,
                     sum(decode(dii.invoice_line_type,'STANDARD',
                              dii.funding_bill_amount,0)) funding_bill_amount,
                     sum(decode(dii.invoice_line_type,'STANDARD',
                              dii.inv_amount,0)) inv_amount,
*/
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.amount)) amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.projfunc_bill_amount)) projfunc_bill_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.funding_bill_amount)) funding_bill_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.inv_amount)) inv_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.amount,0)) retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.projfunc_bill_amount,0)) projfunc_retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.funding_bill_amount,0))  funding_retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.inv_amount,0)) inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND nvl(dii.task_id,0) <> 0
              -- AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num, dii.task_id,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference , di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'RETENTION-TASK' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     dii.task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code, dii.projfunc_currency_code, dii.funding_currency_code,
                     di.inv_currency_code, di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND NVL(dii.task_id,0) <> 0
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num, dii.task_id,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference, di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y'))
              ORDER BY drft_inv_num, task_id;
Line: 3630

       /* This CURSOR is same as previous CURSOR except that ti will select for both primary and reporting set of
           books isd */

  /* R12 :  Ledger Architecture Changes : The table gl_mc_reporting_options will be  obsolete, replace with
     new table gl_alc_ledger_rships_v and corresponding columns */

 /* mrc migration to SLA bug 4571438      CURSOR get_all_task_invoices IS
             (SELECT 'REGULAR-TASK' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     dii.task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code, dii.projfunc_currency_code, dii.funding_currency_code,
                     di.inv_currency_code, di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.amount)) amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.projfunc_bill_amount)) projfunc_bill_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.funding_bill_amount)) funding_bill_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.inv_amount)) inv_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.amount,0)) retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.projfunc_bill_amount,0)) projfunc_retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.funding_bill_amount,0)) funding_retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.inv_amount,0)) inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND nvl(dii.task_id,0) <> 0
              -- AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num, dii.task_id,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference , di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'RETENTION-TASK' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     dii.task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code, dii.projfunc_currency_code, dii.funding_currency_code,
                     di.inv_currency_code, di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND NVL(dii.task_id,0) <> 0
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num, dii.task_id,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference , di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'REGULAR-TASK' invoice_type,
                     dii_mc.set_of_books_id,
                     dii.task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code,
                     dii_mc.currency_code projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.amount)) amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii_mc.amount)) projfunc_bill_amount,    -- changed dii.projfunc_bill_amount to dii_mc.amount bug2827328
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.funding_bill_amount)) funding_bill_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.inv_amount)) inv_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.amount,0)) retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii_mc.amount,0)) projfunc_retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.funding_bill_amount,0)) funding_retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.inv_amount,0)) inv_retn_amount
              FROM pa_mc_draft_inv_items dii_mc, pa_draft_invoice_items dii, pa_draft_invoices di,
                   gl_alc_ledger_rships_v  rep, pa_implementations imp
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND nvl(dii.task_id,0) <> 0
             --  AND dii.invoice_line_type <> 'RETENTION'
              AND rep.source_ledger_id = imp.set_of_books_id
              AND rep.relationship_enabled_flag  = 'Y'
              AND (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = dii.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,dii.task_id, dii_mc.set_of_books_id,
                       dii.invproc_currency_code, dii_mc.currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference , di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'RETENTION-TASK' invoice_type,
                     dii_mc.set_of_books_id,
                     dii.task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code,
                     dii_mc.currency_code projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii_mc.amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_mc_draft_inv_items dii_mc, pa_draft_invoice_items dii, pa_draft_invoices di,
                   gl_alc_ledger_rships_v  rep, pa_implementations imp
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND NVL(dii.task_id,0) <> 0
              AND rep.source_ledger_id = imp.set_of_books_id
              AND rep.relationship_enabled_flag  = 'Y'
              AND (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = dii.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,dii.task_id, dii_mc.set_of_books_id,
                       dii.invproc_currency_code, dii_mc.currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference, di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
            )
              ORDER BY drft_inv_num, task_id,set_of_books_id; */
Line: 3979

                          l_InvTab.DELETE;
Line: 3996

                  l_SetOfBookIdTab.DELETE;
Line: 3997

                  l_InvTypeTab.DELETE;
Line: 3998

                  l_DraftInvNumTab.DELETE;
Line: 3999

                  l_TaskIdTab.DELETE;
Line: 4000

                  l_IPCCurrTab.DELETE;
Line: 4001

                  l_PFCCurrTab.DELETE;
Line: 4002

                  l_FCCurrTab.DELETE;
Line: 4003

                  l_ITCCurrTab.DELETE;
Line: 4004

                  l_SysRefTab.DELETE;
Line: 4005

                  l_StatusCodeTab.DELETE;
Line: 4006

                  l_CancelFlgTab.DELETE;
Line: 4007

                  l_ClCrMemoFlgTab.DELETE;
Line: 4008

                  l_WrOffFlgTab.DELETE;
Line: 4009

                  l_CrMemoFlgTab.DELETE;
Line: 4010

                  l_BillAmtPFCTab.DELETE;
Line: 4011

                  l_BillAmtFCTab.DELETE;
Line: 4012

                  l_BillAmtITCTab.DELETE;
Line: 4013

                  l_BillAmtIPCTab.DELETE;
Line: 4014

                  l_RetnAmtIPCTab.DELETE;
Line: 4015

                  l_RetnAmtPFCTab.DELETE;
Line: 4016

                  l_RetnAmtFCTab.DELETE;
Line: 4017

                  l_RetnAmtITCTab.DELETE;
Line: 4089

                              l_InvTab.DELETE;
Line: 4160

                          l_InvTab.DELETE;
Line: 4169

                   l_SetOfBookIdTab.DELETE;
Line: 4170

                   l_InvTypeTab.DELETE;
Line: 4171

                   l_DraftInvNumTab.DELETE;
Line: 4172

                   l_TaskIdTab.DELETE;
Line: 4173

                   l_IPCCurrTab.DELETE;
Line: 4174

                   l_PFCCurrTab.DELETE;
Line: 4175

                   l_FCCurrTab.DELETE;
Line: 4176

                   l_ITCCurrTab.DELETE;
Line: 4177

                   l_SysRefTab.DELETE;
Line: 4178

                   l_StatusCodeTab.DELETE;
Line: 4179

                   l_CancelFlgTab.DELETE;
Line: 4180

                   l_ClCrMemoFlgTab.DELETE;
Line: 4181

                   l_WrOffFlgTab.DELETE;
Line: 4182

                   l_CrMemoFlgTab.DELETE;
Line: 4183

                   l_BillAmtPFCTab.DELETE;
Line: 4184

                   l_BillAmtFCTab.DELETE;
Line: 4185

                   l_BillAmtITCTab.DELETE;
Line: 4186

                   l_BillAmtIPCTab.DELETE;
Line: 4187

                   l_RetnAmtIPCTab.DELETE;
Line: 4188

                   l_RetnAmtPFCTab.DELETE;
Line: 4189

                   l_RetnAmtFCTab.DELETE;
Line: 4190

                   l_RetnAmtITCTab.DELETE;
Line: 4261

                              l_InvTab.DELETE;
Line: 4329

                         l_InvTab.DELETE;
Line: 4338

                   l_SetOfBookIdTab.DELETE;
Line: 4339

                   l_InvTypeTab.DELETE;
Line: 4340

                   l_DraftInvNumTab.DELETE;
Line: 4341

                   l_TaskIdTab.DELETE;
Line: 4342

                   l_IPCCurrTab.DELETE;
Line: 4343

                   l_PFCCurrTab.DELETE;
Line: 4344

                   l_FCCurrTab.DELETE;
Line: 4345

                   l_ITCCurrTab.DELETE;
Line: 4346

                   l_SysRefTab.DELETE;
Line: 4347

                   l_StatusCodeTab.DELETE;
Line: 4348

                   l_CancelFlgTab.DELETE;
Line: 4349

                   l_ClCrMemoFlgTab.DELETE;
Line: 4350

                   l_WrOffFlgTab.DELETE;
Line: 4351

                   l_CrMemoFlgTab.DELETE;
Line: 4352

                   l_BillAmtPFCTab.DELETE;
Line: 4353

                   l_BillAmtFCTab.DELETE;
Line: 4354

                   l_BillAmtITCTab.DELETE;
Line: 4355

                   l_BillAmtIPCTab.DELETE;
Line: 4356

                   l_RetnAmtIPCTab.DELETE;
Line: 4357

                   l_RetnAmtPFCTab.DELETE;
Line: 4358

                   l_RetnAmtFCTab.DELETE;
Line: 4359

                   l_RetnAmtITCTab.DELETE;
Line: 4429

                              l_InvTab.DELETE;
Line: 4498

                         l_InvTab.DELETE;
Line: 4507

                   l_SetOfBookIdTab.DELETE;
Line: 4508

                   l_InvTypeTab.DELETE;
Line: 4509

                   l_DraftInvNumTab.DELETE;
Line: 4510

                   l_TaskIdTab.DELETE;
Line: 4511

                   l_IPCCurrTab.DELETE;
Line: 4512

                   l_PFCCurrTab.DELETE;
Line: 4513

                   l_FCCurrTab.DELETE;
Line: 4514

                   l_ITCCurrTab.DELETE;
Line: 4515

                   l_SysRefTab.DELETE;
Line: 4516

                   l_StatusCodeTab.DELETE;
Line: 4517

                   l_CancelFlgTab.DELETE;
Line: 4518

                   l_ClCrMemoFlgTab.DELETE;
Line: 4519

                   l_WrOffFlgTab.DELETE;
Line: 4520

                   l_CrMemoFlgTab.DELETE;
Line: 4521

                   l_BillAmtPFCTab.DELETE;
Line: 4522

                   l_BillAmtFCTab.DELETE;
Line: 4523

                   l_BillAmtITCTab.DELETE;
Line: 4524

                   l_BillAmtIPCTab.DELETE;
Line: 4525

                   l_RetnAmtIPCTab.DELETE;
Line: 4526

                   l_RetnAmtPFCTab.DELETE;
Line: 4527

                   l_RetnAmtFCTab.DELETE;
Line: 4528

                   l_RetnAmtITCTab.DELETE;
Line: 4739

         l_ArAmtsTab.DELETE;
Line: 4787

               l_AdjTotTab.DELETE;
Line: 4846

            l_InvTotTab.DELETE;
Line: 5007

                          l_RetainedAmtTab.DELETE;
Line: 5206

                i_conversion_type_tab.DELETE;
Line: 5207

                i_to_currency_tab.DELETE;
Line: 5208

                i_from_currency_tab.DELETE;
Line: 5209

                i_amount_tab.DELETE;
Line: 5210

                i_user_validate_flag_tab.DELETE;
Line: 5211

                i_converted_amount_tab.DELETE;
Line: 5212

                i_denominator_tab.DELETE;
Line: 5213

                i_numerator_tab.DELETE;
Line: 5214

                i_rate_tab.DELETE;
Line: 5215

                i_status_tab.DELETE;
Line: 5258

                       insert_rejection_reason_spf (
                             p_project_id     => G_ProjLvlGlobRec.project_id,
                             p_agreement_id   => p_agreement_id,
                             p_task_id        => p_task_id,
                             p_reason_code    => i_status_tab(1),
                             x_return_status  => l_return_status,
                             x_msg_count      => l_msg_count,
                             x_msg_data       => l_msg_data) ;
Line: 5626

                i_conversion_type_tab.DELETE;
Line: 5627

                i_to_currency_tab.DELETE;
Line: 5628

                i_from_currency_tab.DELETE;
Line: 5629

                i_amount_tab.DELETE;
Line: 5630

                i_user_validate_flag_tab.DELETE;
Line: 5631

                i_converted_amount_tab.DELETE;
Line: 5632

                i_denominator_tab.DELETE;
Line: 5633

                i_numerator_tab.DELETE;
Line: 5634

                i_rate_tab.DELETE;
Line: 5635

                i_status_tab.DELETE;
Line: 5677

                       insert_rejection_reason_spf (
                             p_project_id     => G_ProjLvlGlobRec.project_id,
                             p_agreement_id   => p_agreement_id,
                             p_task_id        => p_task_id,
                             p_reason_code    => i_status_tab(1),
                             x_return_status  => l_return_status,
                             x_msg_count      => l_msg_count,
                             x_msg_data       => l_msg_data) ;
Line: 5876

              SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount
              FROM pa_draft_invoice_items dii
              WHERE dii.project_id = p_project_id
              AND dii.draft_invoice_num = p_draft_inv_num;
Line: 5894

              (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount
              FROM pa_draft_invoice_items dii
              WHERE dii.project_id = p_project_id
              AND dii.draft_invoice_num = p_draft_inv_num
              --AND dii.invoice_line_type <> 'RETENTION'
              UNION
              SELECT dii_mc.set_of_books_id set_of_books_id,
                     sum(dii.amount) amount,
                     sum(dii_mc.amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount
              FROM pa_mc_draft_inv_items dii_mc, pa_draft_invoice_items dii,
                   gl_alc_ledger_rships_v  rep, pa_implementations imp
              WHERE dii.project_id = p_project_id
              AND dii.draft_invoice_num = p_draft_inv_num
             -- AND dii.invoice_line_type <> 'RETENTION'
              AND rep.source_ledger_id = imp.set_of_books_id
              AND rep.relationship_enabled_flag  = 'Y'
              AND (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = dii.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              GROUP BY dii_mc.set_of_books_id
              )
              ORDER by set_of_books_id;  */
Line: 5990

               l_SetOfBookIdTab.DELETE;
Line: 5991

               l_BillAmtIPCTab.DELETE;
Line: 5992

               l_BillAmtPFCTab.DELETE;
Line: 5993

               l_BillAmtFCTab.DELETE;
Line: 5994

               l_BillAmtITCTab.DELETE;
Line: 6047

               l_SetOfBookIdTab.DELETE;
Line: 6048

               l_BillAmtIPCTab.DELETE;
Line: 6049

               l_BillAmtPFCTab.DELETE;
Line: 6050

               l_BillAmtFCTab.DELETE;
Line: 6051

               l_BillAmtITCTab.DELETE;
Line: 6135

            SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                   SUM((rdl.retained_amount/rdl.bill_amount) * rdl.projfunc_bill_amount) retained_amt_pfc,
                   SUM((rdl.retained_amount/rdl.bill_amount) * rdl.funding_bill_amount) retained_amt_fc
            FROM   pa_cust_rev_dist_lines RDL, pa_draft_invoice_items DII
            WHERE  DII.project_id = p_project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    NVL(DII.task_id,0) = p_task_id
            AND    RDL.project_id = DII.project_id
            AND    RDL.draft_invoice_num = DII.draft_invoice_num
            AND    RDL.draft_invoice_item_line_num = DII.line_num;
Line: 6150

            (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                   SUM((rdl.retained_amount/rdl.bill_amount) * rdl.projfunc_bill_amount) retained_amt_pfc,
                   SUM((rdl.retained_amount/rdl.bill_amount) * rdl.funding_bill_amount) retained_amt_fc
            FROM   pa_cust_rev_dist_lines RDL, pa_draft_invoice_items DII
            WHERE  DII.project_id = p_project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    NVL(DII.task_id,0) = p_task_id
            AND    RDL.project_id = DII.project_id
            AND    RDL.draft_invoice_num = DII.draft_invoice_num
            AND    RDL.draft_invoice_item_line_num = DII.line_num
            UNION
            SELECT RDL_MC.set_of_books_id,
                   SUM((rdl.retained_amount/rdl.bill_amount) * rdl_mc.amount) retained_amt_pfc,
                   SUM((rdl.retained_amount/rdl.bill_amount) * rdl.funding_bill_amount) retained_amt_fc
            FROM   pa_cust_rev_dist_lines RDL, pa_draft_invoice_items DII, pa_mc_cust_rdl_all RDL_MC,
                   gl_alc_ledger_rships_v rep, pa_implementations imp
            WHERE  DII.project_id = p_project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    NVL(DII.task_id,0) = p_task_id
            AND    RDL.project_id = DII.project_id
            AND    RDL.draft_invoice_num = DII.draft_invoice_num
            AND    RDL.draft_invoice_item_line_num = DII.line_num
            AND    rep.source_ledger_id = imp.set_of_books_id
            AND    rep.relationship_enabled_flag  = 'Y'
            AND    (rep.org_id = -99 OR rep.org_id = imp.org_id)
            AND    rep.application_id = 275
            AND    RDL_MC.set_of_books_id =rep.ledger_id
            AND    RDL_MC.expenditure_item_id = RDL.expenditure_item_id
            AND    RDL_MC.line_num            = RDL.line_num
            GROUP by RDL_MC.set_of_books_id
            )
       ORDER by set_of_books_id; */
Line: 6184

            SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                   SUM((erdl.retained_amount/erdl.amount) * erdl.projfunc_bill_amount) retained_amt_pfc,
                   SUM((erdl.retained_amount/erdl.amount) * erdl.funding_bill_amount) retained_amt_fc
            FROM   pa_cust_event_rdl_all ERDL, pa_draft_invoice_items DII
            WHERE  DII.project_id = p_project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    NVL(DII.task_id,0) = p_task_id
            AND    ERDL.project_id = DII.project_id
            AND    ERDL.draft_invoice_num = DII.draft_invoice_num
            AND    ERDL.draft_invoice_item_line_num = DII.line_num;
Line: 6200

            (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                   SUM((erdl.retained_amount/erdl.amount) * erdl.projfunc_bill_amount) retained_amt_pfc,
                   SUM((erdl.retained_amount/erdl.amount) * erdl.funding_bill_amount) retained_amt_fc
            FROM   pa_cust_event_rdl_all ERDL, pa_draft_invoice_items DII
            WHERE  DII.project_id = p_project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    NVL(DII.task_id,0) = p_task_id
            AND    ERDL.project_id = DII.project_id
            AND    ERDL.draft_invoice_num = DII.draft_invoice_num
            AND    ERDL.draft_invoice_item_line_num = DII.line_num
            UNION
            SELECT ERDL_MC.set_of_books_id,
                   SUM((erdl.retained_amount/erdl.amount) * ERDL_MC.amount) retained_amt_pfc,
                   SUM((erdl.retained_amount/erdl.amount) * erdl.funding_bill_amount) retained_amt_fc
            FROM   pa_cust_event_rdl_all ERDL, pa_draft_invoice_items DII,
                   pa_mc_cust_event_rdl_all ERDL_MC,
                   gl_alc_ledger_rships_v  rep, pa_implementations imp
            WHERE  DII.project_id = p_project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    NVL(DII.task_id,0) = p_task_id
            AND    ERDL.project_id = DII.project_id
            AND    ERDL.draft_invoice_num = DII.draft_invoice_num
            AND    ERDL.draft_invoice_item_line_num = DII.line_num
            AND    rep.source_ledger_id = imp.set_of_books_id
            AND    rep.relationship_enabled_flag  = 'Y'
            AND    (rep.org_id = -99 OR rep.org_id = imp.org_id)
            AND    rep.application_id = 275
            AND    ERDL_MC.set_of_books_id =rep.ledger_id
            AND    ERDL_MC.project_id = ERDL.project_id
            AND    ERDL_MC.event_num = ERDL.event_num
            AND    NVL(ERDL_MC.task_id,0) = NVL(ERDL.task_id,0)
            AND    ERDL_MC.line_num      = ERDL.line_num
            GROUP by ERDL_MC.set_of_books_id
            )
       ORDER by set_of_books_id; */
Line: 6237

            SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                   SUM((DII.retained_amount/DII.amount) * DII.projfunc_bill_amount) retained_amt_pfc,
                   SUM((DII.retained_amount/DII.amount) * DII.funding_bill_amount) retained_amt_fc
            FROM   pa_draft_invoice_items DII
            WHERE  DII.project_id = p_project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    DII.task_id = p_task_id
            AND    DII.event_num is not null;
Line: 6250

           (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                   SUM((DII.retained_amount/DII.amount) * DII.projfunc_bill_amount) retained_amt_pfc,
                   SUM((DII.retained_amount/DII.amount) * DII.funding_bill_amount) retained_amt_fc
            FROM   pa_draft_invoice_items DII
            WHERE  DII.project_id = p_project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    DII.event_num is not null
            AND    DII.task_id = p_task_id
            UNION
            SELECT DII_MC.set_of_books_id,
                   SUM((DII.retained_amount/DII.amount) * DII_MC.amount) retained_amt_pfc,
                   SUM((DII.retained_amount/DII.amount) * DII.funding_bill_amount) retained_amt_fc
            FROM   pa_draft_invoice_items DII, pa_mc_draft_inv_items DII_MC,
                   gl_alc_ledger_rships_v  rep, pa_implementations imp
            WHERE  DII.project_id = p_project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    DII.task_id = p_task_id
            AND    rep.source_ledger_id = imp.set_of_books_id
            AND    rep.relationship_enabled_flag  = 'Y'
            AND    (rep.org_id = -99 OR rep.org_id = imp.org_id)
            AND    rep.application_id = 275
            AND    DII_MC.set_of_books_id =rep.ledger_id
            AND    DII_MC.project_id = DII.project_id
            AND    DII_MC.draft_invoice_num = DII.draft_invoice_num
            AND    DII_MC.line_num = DII.line_num
            AND    DII.event_num is not null
            GROUP by DII_MC.set_of_books_id
           )
       ORDER by set_of_books_id; */
Line: 6325

         SELECT 'T' INTO l_RetnExistFlag
         FROM DUAL
         WHERE EXISTS (SELECT NULL
                       FROM pa_draft_invoice_items dii
                       WHERE  dii.project_id = p_project_id
                       AND    dii.draft_invoice_num = p_draft_inv_num
                       AND    dii.invoice_line_type = 'RETENTION');
Line: 6383

                l_SetOfBookIdTab.DELETE;
Line: 6384

                l_RetainedAmtPFCTab.DELETE;
Line: 6385

                l_RetainedAmtFCTab.DELETE;
Line: 6436

                l_SetOfBookIdTab.DELETE;
Line: 6437

                l_RetainedAmtPFCTab.DELETE;
Line: 6438

                l_RetainedAmtFCTab.DELETE;
Line: 6489

                l_SetOfBookIdTab.DELETE;
Line: 6490

                l_RetainedAmtPFCTab.DELETE;
Line: 6491

                l_RetainedAmtFCTab.DELETE;
Line: 6544

                l_SetOfBookIdTab.DELETE;
Line: 6545

                l_RetainedAmtPFCTab.DELETE;
Line: 6546

                l_RetainedAmtFCTab.DELETE;
Line: 6597

                l_SetOfBookIdTab.DELETE;
Line: 6598

                l_RetainedAmtPFCTab.DELETE;
Line: 6599

                l_RetainedAmtFCTab.DELETE;
Line: 6650

                l_SetOfBookIdTab.DELETE;
Line: 6651

                l_RetainedAmtPFCTab.DELETE;
Line: 6652

                l_RetainedAmtFCTab.DELETE;
Line: 7023

       /* The following CURSOR will select all invoices for given project/agreement for
          primary set of book id and will get executed for
          a) project level funding
       */

       CURSOR get_proj_invoices IS
             SELECT  PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     0 task_id,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE;
Line: 7044

       /* The following CURSOR will select all invoices for given project/agreement for
          primary and reporting set of book ids  */

  /* R12 :  Ledger Architecture Changes : The table gl_mc_reporting_options will be  obsolete, replace with
     new table gl_alc_ledger_rships_v and corresponding columns */

   /* mrc migration to SLA bug 4571438    CURSOR get_all_proj_invoices IS
             (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     0 task_id,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              UNION
              SELECT dii_mc.set_of_books_id,
                     0 task_id,
                     sum(dii.amount) amount,
                     sum(dii_mc.amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount
              FROM pa_mc_draft_inv_items dii_mc, pa_draft_invoice_items dii,
                   pa_draft_invoices di,
                   gl_alc_ledger_rships_v rep, pa_implementations imp
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND dii.invoice_line_type <> 'RETENTION'
              AND rep.source_ledger_id = imp.set_of_books_id
              AND rep.relationship_enabled_flag  = 'Y'
              AND (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = dii.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY dii_mc.set_of_books_id
               )
              ORDER BY set_of_books_id; */
Line: 7093

       /* The following CURSOR will select all invoices for given project/agreement for
          primary set of book id and will get executed for
          a) task level funding
       */

       CURSOR get_task_invoices IS
             SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     dii.task_id,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY dii.task_id
              ORDER BY task_id;
Line: 7119

       /* This CURSOR is same as previous CURSOR except that ti will select for both primary and reporting set of
           books isd */
       /* mrc migration to SLA bug 4571438 CURSOR get_all_task_invoices IS
             (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     dii.task_id,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY dii.task_id
              UNION
              SELECT dii_mc.set_of_books_id,
                     dii.task_id,
                     sum(dii.amount) amount,
                     sum(dii_mc.amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount
              FROM pa_mc_draft_inv_items dii_mc, pa_draft_invoice_items dii, pa_draft_invoices di,
                   gl_alc_ledger_rships_v rep, pa_implementations imp
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND dii.invoice_line_type <> 'RETENTION'
              AND rep.source_ledger_id = imp.set_of_books_id
              AND rep.relationship_enabled_flag  = 'Y'
              AND (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = dii.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY dii.task_id, dii_mc.set_of_books_id
              )
              ORDER BY task_id,set_of_books_id; */
Line: 7251

                   l_SetOfBookIdTab.DELETE;
Line: 7252

                   l_TaskIdTab.DELETE;
Line: 7253

                   l_BillAmtPFCTab.DELETE;
Line: 7254

                   l_BillAmtFCTab.DELETE;
Line: 7255

                   l_BillAmtIPCTab.DELETE;
Line: 7314

                   l_SetOfBookIdTab.DELETE;
Line: 7315

                   l_TaskIdTab.DELETE;
Line: 7316

                   l_BillAmtPFCTab.DELETE;
Line: 7317

                   l_BillAmtFCTab.DELETE;
Line: 7318

                   l_BillAmtIPCTab.DELETE;
Line: 7380

                   l_SetOfBookIdTab.DELETE;
Line: 7381

                   l_TaskIdTab.DELETE;
Line: 7382

                   l_BillAmtPFCTab.DELETE;
Line: 7383

                   l_BillAmtFCTab.DELETE;
Line: 7384

                   l_BillAmtIPCTab.DELETE;
Line: 7442

                   l_SetOfBookIdTab.DELETE;
Line: 7443

                   l_TaskIdTab.DELETE;
Line: 7444

                   l_BillAmtPFCTab.DELETE;
Line: 7445

                   l_BillAmtFCTab.DELETE;
Line: 7446

                   l_BillAmtIPCTab.DELETE;
Line: 7874

         SELECT NVL(org_id,-99) INTO l_OrgId FROM PA_IMPLEMENTATIONS;
Line: 7910

         l_from_currency_tab.DELETE;
Line: 7911

         l_to_currency_tab.DELETE;
Line: 7912

         l_conversion_date_tab.DELETE;
Line: 7913

         l_conversion_type_tab.DELETE;
Line: 7914

         l_amount_tab.DELETE;
Line: 7915

         l_user_validate_flag_tab.DELETE;
Line: 7916

         l_converted_amount_tab.DELETE;
Line: 7917

         l_denominator_tab.DELETE;
Line: 7918

         l_numerator_tab.DELETE;
Line: 7919

         l_rate_tab.DELETE;
Line: 7920

         l_status_tab.DELETE;
Line: 7960

            insert_rejection_reason_spf (
                  p_project_id     => G_ProjLvlGlobRec.project_id,
                  p_agreement_id   => p_agreement_id,
                  p_task_id        => p_task_id,
                  p_reason_code    => l_status_tab(1),
                  x_return_status  => l_return_status,
                  x_msg_count      => l_msg_count,
                  x_msg_data       => l_msg_data) ;
Line: 7989

            l_from_currency_tab.DELETE;
Line: 7990

            l_to_currency_tab.DELETE;
Line: 7991

            l_conversion_date_tab.DELETE;
Line: 7992

            l_conversion_type_tab.DELETE;
Line: 7993

            l_amount_tab.DELETE;
Line: 7994

            l_user_validate_flag_tab.DELETE;
Line: 7995

            l_converted_amount_tab.DELETE;
Line: 7996

            l_denominator_tab.DELETE;
Line: 7997

            l_numerator_tab.DELETE;
Line: 7998

            l_rate_tab.DELETE;
Line: 7999

            l_status_tab.DELETE;
Line: 8038

               insert_rejection_reason_spf (
                  p_project_id     => G_ProjLvlGlobRec.project_id,
                  p_agreement_id   => p_agreement_id,
                  p_task_id        => p_task_id,
                  p_reason_code    => l_status_tab(1),
                  x_return_status  => l_return_status,
                  x_msg_count      => l_msg_count,
                  x_msg_data       => l_msg_data) ;
Line: 8520

               l_from_currency_tab.DELETE;
Line: 8521

               l_to_currency_tab.DELETE;
Line: 8522

               l_conversion_date_tab.DELETE;
Line: 8523

               l_conversion_type_tab.DELETE;
Line: 8524

               l_amount_tab.DELETE;
Line: 8525

               l_user_validate_flag_tab.DELETE;
Line: 8526

               l_converted_amount_tab.DELETE;
Line: 8527

               l_denominator_tab.DELETE;
Line: 8528

               l_numerator_tab.DELETE;
Line: 8529

               l_rate_tab.DELETE;
Line: 8530

               l_status_tab.DELETE;
Line: 8594

                  insert_rejection_reason_spf (
                     p_project_id     => G_ProjLvlGlobRec.project_id,
                     p_agreement_id   => p_agreement_id,
                     p_task_id        => p_task_id,
                     p_reason_code    => l_status_tab(1),
                     x_return_status  => l_return_status,
                     x_msg_count      => l_msg_count,
                     x_msg_data       => l_msg_data) ;
Line: 8643

               l_from_currency_tab.DELETE;
Line: 8644

               l_to_currency_tab.DELETE;
Line: 8645

               l_conversion_date_tab.DELETE;
Line: 8646

               l_conversion_type_tab.DELETE;
Line: 8647

               l_amount_tab.DELETE;
Line: 8648

               l_user_validate_flag_tab.DELETE;
Line: 8649

               l_converted_amount_tab.DELETE;
Line: 8650

               l_denominator_tab.DELETE;
Line: 8651

               l_numerator_tab.DELETE;
Line: 8652

               l_rate_tab.DELETE;
Line: 8653

               l_status_tab.DELETE;
Line: 8700

                  insert_rejection_reason_spf (
                        p_project_id     => G_ProjLvlGlobRec.project_id,
                        p_agreement_id   => p_agreement_id,
                        p_task_id        => p_task_id,
                        p_reason_code    => l_status_tab(1),
                        x_return_status  => l_return_status,
                        x_msg_count      => l_msg_count,
                        x_msg_data       => l_msg_data) ;
Line: 8952

			     insert the warning into distributions and
			     update the summary project funding with rejectionr reason as INVOICED_EXCEEDS_FUNDED
	  */

         /*   Changes Start ------------------------------------ Commented for bug 3532963

	   IF (NVL(l_InvOvrFndFlag,'N') ='Y') AND (nvl(l_RevaluationIndex,1)=1)  THEN  /* Added AND condition for bug 3532963

			ROLLBACK;
Line: 8966

                  	insert_rejection_reason_spf (
                     		p_project_id     => G_ProjLvlGlobRec.project_id,
                     		p_agreement_id   => p_agreement_id,
                     		p_task_id        => p_task_id,
                     		p_reason_code    => 'PA_FR_INVOICED_EXCEEDS_FUNDED',
                     		x_return_status  => l_return_status,
                     		x_msg_count      => l_msg_count,
                     		x_msg_data       => l_msg_data) ;
Line: 9029

   |   Procedure  :   insert_rejection_reason_spf                                            |
   |   Purpose    :   To insert rejection reason in SPF                                      |
   |   Parameters :                                                                          |
   |     ==================================================================================  |
   |     Name                             Mode    Description                                |
   |     ==================================================================================  |
   |     p_project_id          IN      Project ID                                            |
   |     p_agreement_id        IN      Agreement_id                                          |
   |     p_task_id             IN      Task Id of summary project funding                    |
   |     p_reason_code         IN      Rejection reason code                                 |
   |     x_return_status       OUT     Return status of this procedure                       |
   |     x_msg_count           OUT     Error message count                                   |
   |     x_msg_data            OUT     Error message                                         |
   |     ==================================================================================  |
   +----------------------------------------------------------------------------------------*/
   PROCEDURE insert_rejection_reason_spf(
             p_project_id        IN    NUMBER,
             p_agreement_id      IN    VARCHAR2,
             p_task_id           IN    VARCHAR2,
             p_reason_code       IN    VARCHAR2,
             x_return_status     OUT   NOCOPY VARCHAR2,
             x_msg_count         OUT   NOCOPY NUMBER,
             x_msg_data          OUT   NOCOPY VARCHAR2)   IS


       l_return_status               VARCHAR2(30) := NULL;
Line: 9066

            PA_DEBUG.g_err_stage := '-----------Entering PA_FUND_REVAL_PVT.insert_rejection_reason_spf-----------' ;
Line: 9071

         UPDATE pa_summary_project_fundings
         SET  reval_rejection_code = p_reason_code,
              last_update_date = sysdate,
              last_updated_by =  G_LAST_UPDATED_BY,
              last_update_login =  G_LAST_UPDATE_LOGIN,
              program_application_id = G_PROGRAM_APPLICATION_ID ,
              program_id = G_PROGRAM_ID,
              program_update_date= SYSDATE,
              request_id= G_REQUEST_ID
         WHERE project_id = p_project_id
         AND   agreement_id = p_agreement_id
         AND   nvl(task_id,0) = nvl(p_task_id,0);
Line: 9084

         Insert_distribution_warnings(
                p_project_id     => p_project_id,
                p_task_id        => p_task_id,
                p_agreement_id   => p_agreement_id,
                p_reason_code    => p_Reason_Code,
                x_return_status  => l_return_status,
                x_msg_count      => l_msg_count,
                x_msg_data       => l_msg_data) ;
Line: 9106

            PA_DEBUG.g_err_stage := '-----------Exiting PA_FUND_REVAL_PVT.insert_rejection_reason_spf-----------' ;
Line: 9125

                PA_DEBUG.g_err_stage := 'insert_rejection_reason_spf:' || x_msg_data ;
Line: 9130

   END insert_rejection_reason_spf;
Line: 9160

                SELECT 'Y' non_zero_amt
                FROM DUAL
                WHERE EXISTS ( SELECT  NULL
                               FROM pa_project_fundings
                               WHERE project_funding_id = l_project_funding_id
                               AND  (  projfunc_allocated_amount <> 0
                                       OR   projfunc_realized_gains_amt <> 0
                                       OR   projfunc_realized_losses_amt <> 0
                                       OR   invproc_allocated_amount <> 0)
                              /* mrc migration to SLA bug 4571438 UNION
                               SELECT  NULL
                               FROM pa_mc_project_fundings
                               WHERE project_funding_id = l_project_funding_id
                               AND  (  allocated_amount <> 0
                                       OR   realized_gains_amt <> 0
                                       OR   realized_losses_amt <> 0) */ );
Line: 9193

         /* Insert into table pa_project_fundings */
         l_SobId := G_SET_OF_BOOKS_ID;
Line: 9215

            PA_PROJECT_FUNDINGS_PKG. Insert_Row (
                 X_Rowid                         => l_RowId ,
                 X_Project_Funding_Id            => l_ProjectFundingId ,
                 X_Last_Update_Date              => SYSDATE,
                 X_Last_Updated_By               => G_LAST_UPDATED_BY ,
                 X_Creation_Date                 => SYSDATE ,
                 X_Created_By                    => G_LAST_UPDATED_BY ,
                 X_Last_Update_Login             => G_LAST_UPDATE_LOGIN ,
                 X_Agreement_Id                  => G_RevalCompTab(l_SobId).agreement_id ,
                 X_Project_Id                    => G_RevalCompTab(l_SobId).project_id ,
                 X_Task_Id                       => G_RevalCompTab(l_SobId).task_id ,
                 X_Budget_Type_Code              => 'DRAFT' ,
                 X_Allocated_Amount              => 0 ,
                 X_Date_Allocated                => G_RATE_DATE,
                 X_Attribute_Category            => NULL ,
                 X_Attribute1                    => NULL ,
                 X_Attribute2                    => NULL ,
                 X_Attribute3                    => NULL ,
                 X_Attribute4                    => NULL ,
                 X_Attribute5                    => NULL ,
                 X_Attribute6                    => NULL ,
                 X_Attribute7                    => NULL ,
                 X_Attribute8                    => NULL ,
                 X_Attribute9                    => NULL ,
                 X_Attribute10                   => NULL ,
                 X_pm_funding_reference          => NULL ,
                 X_pm_product_code               => NULL ,
                 x_funding_currency_code         => G_RevalCompTab(l_SobId).funding_currency_code ,
                 x_project_currency_code         => G_RevalCompTab(l_SobId).project_currency_code ,
                 x_project_rate_type             => NULL,
                 x_project_rate_date             => NULL,
                 x_project_exchange_rate         => NULL,
                 x_project_allocated_amount      => NULL,
                 x_projfunc_currency_code        => G_RevalCompTab(l_SobId).projfunc_currency_code ,
                 x_projfunc_rate_type            => NULL,
                 x_projfunc_rate_date            => NULL,
                 x_projfunc_exchange_rate        => NULL,
                 x_projfunc_allocated_amount     => G_RevalCompTab(l_SobId).projfunc_allocated_amount ,
                 x_invproc_currency_code         => G_RevalCompTab(l_SobId).invproc_currency_code ,
                 x_invproc_rate_type             => NULL,
                 x_invproc_rate_date             => NULL,
                 x_invproc_exchange_rate         => NULL,
                 x_invproc_allocated_amount      => G_RevalCompTab(l_SobId).invproc_allocated_amount ,
                 x_revproc_currency_code         => G_RevalCompTab(l_SobId).projfunc_currency_code ,
                 x_revproc_rate_type             => G_RevalCompTab(l_SobId).reval_projfunc_rate_type ,
                 x_revproc_rate_date             => NULL,
                 x_revproc_exchange_rate         => NULL,
                 x_revproc_allocated_amount      => G_RevalCompTab(l_SobId).projfunc_allocated_amount ,
                 x_funding_category              => 'REVALUATION' ,
                 x_revaluation_through_date      => G_THRU_DATE ,
                 x_revaluation_rate_date         => G_RATE_DATE ,
                 x_reval_projfunc_rate_type      => G_RevalCompTab(l_SobId).reval_projfunc_rate_type ,
                 x_revaluation_projfunc_rate     => G_RevalCompTab(l_SobId).reval_projfunc_rate ,
                 x_reval_invproc_rate_type       => G_RevalCompTab(l_SobId).reval_invproc_rate_type ,
                 x_revaluation_invproc_rate      => G_RevalCompTab(l_SobId).reval_invproc_rate  ,
                 x_funding_inv_applied_amount    => G_RevalCompTab(l_SobId).funding_inv_applied_amount,
                 x_funding_inv_due_amount        => G_RevalCompTab(l_SobId).funding_inv_due_amount,
                 x_funding_backlog_amount        => G_RevalCompTab(l_SobId).funding_backlog_amount,
                 x_projfunc_realized_gains_amt   => G_RevalCompTab(l_SobId).projfunc_realized_gains_amt,
                 x_projfunc_realized_losses_amt  => G_RevalCompTab(l_SobId).projfunc_realized_losses_amt,
                 x_projfunc_inv_applied_amount   => G_RevalCompTab(l_SobId).projfunc_inv_applied_amount,
                 x_projfunc_inv_due_amount       => G_RevalCompTab(l_SobId).projfunc_inv_due_amount,
                 x_projfunc_backlog_amount       => G_RevalCompTab(l_SobId).projfunc_backlog_amount,
                 x_non_updateable_flag           => 'Y',
                 x_invproc_backlog_amount        => G_RevalCompTab(l_SobId).invproc_backlog_amount,
                 x_funding_reval_amount          => G_RevalCompTab(l_SobId).funding_reval_amount,
                 x_projfunc_reval_amount         => G_RevalCompTab(l_SobId).projfunc_reval_amount,
                 x_projfunc_revalued_amount      => G_RevalCompTab(l_SobId).projfunc_revalued_amount,
                 x_invproc_reval_amount          => G_RevalCompTab(l_SobId).invproc_reval_amount,
                 x_invproc_revalued_amount       => G_RevalCompTab(l_SobId).invproc_revalued_amount,
                 x_funding_revaluation_factor    => G_RevalCompTab(l_SobId).funding_revaluation_factor,
                 x_request_id                    => G_REQUEST_ID,
                 x_program_application_id        => G_PROGRAM_APPLICATION_ID,
                 x_program_id                    => G_PROGRAM_ID,
                 x_program_update_date           => SYSDATE);
Line: 9293

               l_LogMsg := 'After Insert Project Funding Id:' || l_ProjectFundingId;
Line: 9321

               UPDATE pa_summary_project_fundings
               SET    projfunc_unbaselined_amount =
                            nvl(projfunc_unbaselined_amount,0) + G_RevalCompTab(l_SobId).projfunc_allocated_amount,
                      revproc_unbaselined_amount =
                            nvl(revproc_unbaselined_amount,0) + G_RevalCompTab(l_SobId).projfunc_allocated_amount,
                      invproc_unbaselined_amount =
                            nvl(invproc_unbaselined_amount,0) + G_RevalCompTab(l_SobId).invproc_allocated_amount,
                      projfunc_realized_gains_amt =
                            nvl(projfunc_realized_gains_amt,0) + G_RevalCompTab(l_SobId).projfunc_realized_gains_amt,
                      projfunc_realized_losses_amt =
                            nvl(projfunc_realized_losses_amt,0) + G_RevalCompTab(l_SobId).projfunc_realized_losses_amt,
                      reval_rejection_code = NULL
               WHERE project_id = G_RevalCompTab(l_SobId).project_id
               AND   agreement_id = G_RevalCompTab(l_SobId).agreement_id
               AND   nvl(task_id,0) = nvl(G_RevalCompTab(l_SobId).task_id,0);
Line: 9375

                  insert_event_record (
                         p_project_id            => G_RevalCompTab(l_SobId).project_id,
                         p_task_id               => G_RevalCompTab(l_SobId).task_id,
                         p_event_type            => G_ProjLvlGlobRec.gain_event_type,
                         p_event_desc            => G_ProjLvlGlobRec.gain_event_type,
                         p_Bill_trans_rev_amount => G_RevalCompTab(l_SobId).projfunc_realized_gains_amt ,
                         p_project_funding_id    => l_ProjectFundingId,
			 p_agreement_id          => G_RevalCompTab(l_SobId).agreement_id,
                         x_return_status         => l_return_status,
                         x_msg_count             => l_msg_count,
                         x_msg_data              => l_msg_data) ;
Line: 9413

                  insert_event_record (
                         p_project_id            => G_RevalCompTab(l_SobId).project_id,
                         p_task_id               => G_RevalCompTab(l_SobId).task_id,
                         p_event_type            => G_ProjLvlGlobRec.loss_event_type,
                         p_event_desc            => G_ProjLvlGlobRec.loss_event_type,
                         p_Bill_trans_rev_amount => G_RevalCompTab(l_SobId).projfunc_realized_losses_amt ,
                         p_project_funding_id    => l_ProjectFundingId,
			 p_agreement_id          => G_RevalCompTab(l_SobId).agreement_id,
                         x_return_status         => l_return_status,
                         x_msg_count             => l_msg_count,
                         x_msg_data              => l_msg_data) ;
Line: 9447

               DELETE FROM pa_project_fundings
               WHERE  project_funding_id = l_ProjectFundingId;
Line: 9489

   |   Procedure  :   insert_event_record                                                    |
   |   Purpose    :   To insert event record for gains/losses amount                         |
   |   Parameters :                                                                          |
   |     ==================================================================================  |
   |     Name                             Mode    Description                                |
   |     ==================================================================================  |
   |     p_project_id              IN      Project ID                                        |
   |     p_task_id                 IN      Task Id of summary project funding                |
   |     p_event_type              IN      Event type (gain/loss event type )                |
   |     p_event_desc              IN      Event description (gain/loss event description )  |
   |     p_bill_trans_rev_amount   IN      Amount (Realized gain/loss amount)                |
   |     p_project_funding_id      IN      Funding line Id for which this event is created   |
   |     x_return_status           OUT     Return status of this procedure                   |
   |     x_msg_count               OUT     Error message count                               |
   |     x_msg_data                OUT     Error message                                     |
   |     ==================================================================================  |
   +----------------------------------------------------------------------------------------*/
   PROCEDURE insert_event_record(
                  p_project_id             IN   NUMBER,
                  p_task_id                IN   NUMBER,
                  p_event_type             IN   VARCHAR2,
                  p_event_desc             IN   VARCHAR2,
                  p_Bill_trans_rev_amount  IN   NUMBER,
                  p_project_funding_id     IN   NUMBER,
		  p_agreement_id           IN   NUMBER,
                  x_return_status          OUT  NOCOPY VARCHAR2,
                  x_msg_count              OUT  NOCOPY NUMBER,
                  x_msg_data               OUT  NOCOPY VARCHAR2) IS

       l_RowId                       VARCHAR2(30);
Line: 9532

                SELECT 'Y' non_zero_amt
                FROM DUAL
                WHERE EXISTS ( SELECT  NULL
                               FROM pa_events
                               WHERE event_id = l_EventId
                               AND  bill_trans_rev_amount <> 0
                             /* mrc migration to SLA bug 4571438  UNION
                               SELECT  NULL
                               FROM pa_mc_events
                               WHERE event_id = l_EventId
                               AND  revenue_amount <> 0 */ );
Line: 9551

            PA_DEBUG.g_err_stage := '-----------Entering PA_FUND_REVAL_PVT.insert_event_record-----------' ;
Line: 9570

            zero dollar events in all reporting set of books. If zero, the record(s) will be deleted */

         IF ((p_bill_trans_rev_amount <> 0)  OR (G_PRIMARY_ONLY = 'N')) THEN

           SELECT nvl(max(event_num),0) into l_EventNum
           FROM   pa_events
           WHERE  project_id = G_RevalCompTab(l_SobId).project_id
           AND    nvl(task_id,0) =  nvl(G_RevalCompTab(l_SobId).task_id,0);
Line: 9588

            pa_events_pkg.insert_row (
                       X_Rowid                      => l_RowId ,
                       X_Event_Id                   => l_EventId ,
                       X_Task_Id                    => p_task_id ,
                       X_Event_Num                  => l_EventNum ,
                       X_Last_Update_Date           => SYSDATE ,
                       X_Last_Updated_By            => G_LAST_UPDATED_BY ,
                       X_Creation_Date              => SYSDATE ,
                       X_Created_By                 => G_LAST_UPDATED_BY ,
                       X_Last_Update_Login          => G_LAST_UPDATE_LOGIN ,
                       X_Event_Type                 => p_event_type ,
                       X_Description                => p_event_desc ,
                       X_Bill_Amount                => 0 ,
                       X_Revenue_Amount             => 0 ,
                       X_Revenue_Distributed_Flag   => 'N' ,
                       X_Zero_Revenue_Amount_Flag   => l_ZeroRevAmtFlag,
                       X_Bill_Hold_Flag             => 'N' ,
                       X_Completion_Date            => G_RATE_DATE ,
                       X_Rev_Dist_Rejection_Code    => NULL ,
                       X_Attribute_Category         => NULL ,
                       X_Attribute1                 => NULL ,
                       X_Attribute2                 => NULL ,
                       X_Attribute3                 => NULL ,
                       X_Attribute4                 => NULL ,
                       X_Attribute5                 => NULL ,
                       X_Attribute6                 => NULL ,
                       X_Attribute7                 => NULL ,
                       X_Attribute8                 => NULL ,
                       X_Attribute9                 => NULL ,
                       X_Attribute10                => NULL ,
                       X_Project_Id                 => p_project_id ,
                       X_Organization_Id            => G_ProjLvlGlobRec.carrying_out_organization_id ,
                       X_Billing_Assignment_Id      => NULL ,
                       X_Event_Num_Reversed         => NULL ,
                       X_Calling_Place              => NULL ,
                       X_Calling_Process            => NULL ,
                       X_Bill_Trans_Currency_Code   => G_RevalCompTab(l_SobId).projfunc_currency_code ,
                       X_Bill_Trans_Bill_Amount     => 0 ,  -- Changed from NULL for bug2829565
                       X_Bill_Trans_rev_Amount      => p_bill_trans_rev_amount ,
                       X_Project_Currency_Code      => G_RevalCompTab(l_SobId).project_currency_code ,
                       X_Project_Rate_Type          => NULL ,
                       X_Project_Rate_Date          => NULL ,
                       X_Project_Exchange_Rate      => NULL ,
                       X_Project_Inv_Rate_Date      => NULL ,
                       X_Project_Inv_Exchange_Rate  => NULL ,
                       X_Project_Bill_Amount        => NULL ,
                       X_Project_Rev_Rate_Date      => NULL ,
                       X_Project_Rev_Exchange_Rate  => NULL ,
                       X_Project_Revenue_Amount     => NULL ,
                       X_ProjFunc_Currency_Code     => G_RevalCompTab(l_SobId).projfunc_currency_code  ,
                       X_ProjFunc_Rate_Type         => NULL ,
                       X_ProjFunc_Rate_Date         => NULL ,
                       X_ProjFunc_Exchange_Rate     => NULL ,
                       X_ProjFunc_Inv_Rate_Date     => NULL ,
                       X_ProjFunc_Inv_Exchange_Rate => NULL ,
                       X_ProjFunc_Bill_Amount       => NULL ,
                       X_ProjFunc_Rev_Rate_Date     => NULL ,
                       X_Projfunc_Rev_Exchange_Rate => NULL ,
                       X_ProjFunc_Revenue_Amount    => NULL ,
                       X_Funding_Rate_Type          => NULL ,
                       X_Funding_Rate_Date          => NULL ,
                       X_Funding_Exchange_Rate      => NULL ,
                       X_Invproc_Currency_Code      => G_RevalCompTab(l_SobId).invproc_currency_code  ,
                       X_Invproc_Rate_Type          => NULL ,
                       X_Invproc_Rate_Date          => NULL ,
                       X_Invproc_Exchange_Rate      => NULL ,
                       X_Revproc_Currency_Code      => G_RevalCompTab(l_SobId).projfunc_currency_code ,
                       X_Revproc_Rate_Type          => NULL ,
                       X_Revproc_Rate_Date          => NULL ,
                       X_Revproc_Exchange_Rate      => NULL ,
                       X_Inv_Gen_Rejection_Code     => NULL ,
                       X_Adjusting_Revenue_Flag     => NULL ,
                       X_non_updateable_flag        => 'Y' ,
                       X_revenue_hold_flag          => 'Y' ,
                       X_project_funding_id         => p_project_funding_id,
		       X_agreement_id               => p_agreement_id);
Line: 9681

                DELETE FROM pa_events
                WHERE  event_id = l_EventId;
Line: 9690

            PA_DEBUG.g_err_stage := '-----------Exiting PA_FUND_REVAL_PVT.insert_event_record-----------' ;
Line: 9713

                PA_DEBUG.g_err_stage := 'insert_event_record:' || x_msg_data ;
Line: 9718

   END insert_event_record;
Line: 9902

   |   Purpose    :   To delete any rejection reason that is logged by revaluation process   |
   |                  for the request id                                                     |
   |   Parameters :                                                                          |
   |     ==================================================================================  |
   |     Name                             Mode    Description                                |
   |     ==================================================================================  |
   |     p_request_id          IN      Request ID                                            |
   |     x_return_status       OUT     Return status of this procedure                       |
   |     x_msg_count           OUT     Error message count                                   |
   |     x_msg_data            OUT     Error message                                         |
   |     ==================================================================================  |
   +----------------------------------------------------------------------------------------*/
   PROCEDURE clear_distribution_warnings(
             p_request_id        IN    NUMBER,
             x_return_status     OUT   NOCOPY VARCHAR2,
             x_msg_count         OUT   NOCOPY NUMBER,
             x_msg_data          OUT   NOCOPY VARCHAR2)   IS


       l_return_status               VARCHAR2(30) := NULL;
Line: 9938

         DELETE from pa_distribution_warnings
         WHERE request_id = p_request_id;
Line: 10034

            Insert_distribution_warnings(
                        p_project_id     => G_RevalCompTab(l_SobId).project_id,
                        p_agreement_id   => G_RevalCompTab(l_SobId).agreement_id,
                        p_task_id        => G_RevalCompTab(l_SobId).task_id,
                        p_reason_code    => l_ReasonCode,
                        x_return_status  => l_return_status,
                        x_msg_count      => l_msg_count,
                        x_msg_data       => l_msg_data) ;
Line: 10068

            Insert_distribution_warnings(
                        p_project_id     => G_RevalCompTab(l_SobId).project_id,
                        p_agreement_id   => G_RevalCompTab(l_SobId).agreement_id,
                        p_task_id        => G_RevalCompTab(l_SobId).task_id,
                        p_reason_code    => l_ReasonCode,
                        x_return_status  => l_return_status,
                        x_msg_count      => l_msg_count,
                        x_msg_data       => l_msg_data) ;
Line: 10124

   |   Procedure  :   Get_Delete_Projects                                                    |
   |   Purpose    :   To open all projects eligible for funding revaluation and has          |
   |                  unbaselined adjustment lines                                           |
   |                  given project numbers                                                  |
   |   Parameters :                                                                          |
   |     ==================================================================================  |
   |     Name                             Mode    Description                                |
   |     ==================================================================================  |
   |     p_project_id          IN      Project ID                                            |
   |     p_project_type_id     IN      Project Type ID                                       |
   |     p_from_proj_number    IN      Start project number                                  |
   |     p_to_proj_number      IN      End project number                                    |
   |     p_run_mode            IN      Run mode                                              |
   |                                   Values are 'SINGLE', 'RANGE'                          |
   |     x_return_status       OUT     Return status of this procedure                       |
   |     x_msg_count           OUT     Error message count                                   |
   |     x_msg_data            OUT     Error message                                         |
   |     ==================================================================================  |
   +----------------------------------------------------------------------------------------*/
   PROCEDURE get_delete_projects(
             p_project_type_id   IN    NUMBER,
             p_from_proj_number  IN    VARCHAR2,
             p_to_proj_number    IN    VARCHAR2,
             p_run_mode          IN    VARCHAR2,
             x_return_status     OUT   NOCOPY VARCHAR2,
             x_msg_count         OUT   NOCOPY NUMBER,
             x_msg_data          OUT   NOCOPY VARCHAR2)   IS


       /* This CURSOR selects all projects with the following criteria
              a) should be contract  projects
              b) revaluate_funding_flag is enabled
              c) has unbaselined adjustments */

         CURSOR open_projects IS
                SELECT P.segment1, P.project_id, P.baseline_funding_flag,
                       P.include_gains_losses_flag include_gains_losses_flag
                FROM pa_projects P, pa_project_types T
                WHERE P.segment1 BETWEEN p_from_proj_number
                               AND p_to_proj_number
                AND   P.PROJECT_TYPE = T.PROJECT_TYPE
                AND   T.DIRECT_FLAG = 'Y'
                AND   T.PROJECT_TYPE_ID  = NVL(P_PROJECT_TYPE_ID ,T.project_type_id)
                AND   NVL(P.revaluate_funding_flag, 'N') = 'Y'
                AND   NVL(P.template_flag, 'N') = 'N'
                AND   exists ( SELECT NULL
                               FROM pa_project_fundings
                               WHERE project_id = P.project_id
                               AND funding_category = 'REVALUATION'
                               AND budget_type_code = 'DRAFT')
                ORDER BY segment1 ;
Line: 10188

            PA_DEBUG.g_err_stage := '-----------Entering PA_FUND_REVAL_PVT.get_delete_projects-----------' ;
Line: 10209

             Delete_unbaselined_adjmts(
                    p_project_id     => proj_rec.project_id,
                    p_run_mode       => p_run_mode,
                    x_return_status  => l_return_status,
                    x_msg_count      => l_msg_count,
                    x_msg_data       => l_msg_data) ;
Line: 10226

             COMMIT; /* Commit delete for the current project */
Line: 10232

            PA_DEBUG.g_err_stage := '-----------Exiting PA_FUND_REVAL_PVT.get_delete_projects-----------' ;
Line: 10261

   END get_delete_projects;