124: END IF;
125: /** gets the cost and revenue budget amounts **/
126:
127: IF g1_debug_mode = 'Y' THEN
128: PA_MCB_INVOICE_PKG.log_message('Before pa_billing_extn_params_v select pa_bill_pct.calc_pct_comp_amt :');
129: END IF;
130: /* Added for bug 2649456.Not handling exception intentionaly because if it is coming,
131: it will be data issue */
132: BEGIN
131: it will be data issue */
132: BEGIN
133: SELECT default_cost_plan_type_id,default_rev_plan_type_id
134: INTO l_cost_plan_type_id,l_rev_plan_type_id
135: FROM pa_billing_extn_params_v;
136: EXCEPTION
137: WHEN OTHERS THEN
138: IF g1_debug_mode = 'Y' THEN
139: PA_MCB_INVOICE_PKG.log_message('Error from pa_billing_extn_params_v pa_bill_pct.calc_pct_comp_amt :'||SQLERRM);
135: FROM pa_billing_extn_params_v;
136: EXCEPTION
137: WHEN OTHERS THEN
138: IF g1_debug_mode = 'Y' THEN
139: PA_MCB_INVOICE_PKG.log_message('Error from pa_billing_extn_params_v pa_bill_pct.calc_pct_comp_amt :'||SQLERRM);
140: END IF;
141: RAISE;
142: END;
143: /* till here */
186: /** Get the amount left based on the hard limit set for the projects
187: customers **/
188:
189: IF g1_debug_mode = 'Y' THEN
190: PA_MCB_INVOICE_PKG.log_message('before calling pa_billing_amount.LowestAmountLeft inside pa_bill_pct.calc_pct_comp_amt :');
191: END IF;
192: Amount_Left := pa_billing_amount.LowestAmountLeft(
193: X_project_id,
194: X_top_task_id,
188:
189: IF g1_debug_mode = 'Y' THEN
190: PA_MCB_INVOICE_PKG.log_message('before calling pa_billing_amount.LowestAmountLeft inside pa_bill_pct.calc_pct_comp_amt :');
191: END IF;
192: Amount_Left := pa_billing_amount.LowestAmountLeft(
193: X_project_id,
194: X_top_task_id,
195: X_calling_process);
196:
294: IF g1_debug_mode = 'Y' THEN
295: PA_MCB_INVOICE_PKG.log_message('rev part inside pa_bill_pct.calc_pct_comp_amt event desc :'||Event_Description);
296: PA_MCB_INVOICE_PKG.log_message('rev part Before calling insert_event inside pa_bill_pct.calc_pct_comp_amt Revenue :');
297: END IF;
298: pa_billing_pub.insert_event (
299: X_rev_amt => Revenue,
300: X_bill_amt => 0,
301: X_event_description => event_description,
302: X_audit_amount1 => amount_left,
375: IF g1_debug_mode = 'Y' THEN
376: PA_MCB_INVOICE_PKG.log_message('Inv part inside pa_bill_pct.calc_pct_comp_amt event desc :'||Event_Description);
377: PA_MCB_INVOICE_PKG.log_message('Inv part Before insert event inside pa_bill_pct.calc_pct_comp_amt Invoice :');
378: END IF;
379: pa_billing_pub.insert_event (
380: X_rev_amt => 0,
381: X_bill_amt => Invoice,
382: X_event_description => Event_Description,
383: X_audit_amount1 => amount_left,
493: AND e.project_id = X2_project_id
494: AND nvl(e.task_id,0) = nvl(X2_task_id, nvl(e.task_id,0))
495: AND e.completion_date <= nvl(X2_accrue_through_date, sysdate)
496: AND NOT EXISTS ( select '1'
497: from pa_billing_assignments bea,
498: pa_billing_extensions be
499: where be.billing_extension_id = bea.billing_extension_id
500: and bea.billing_assignment_id = e.billing_assignment_id
501: and be.procedure_name = 'pa_bill_pct.calc_pct_comp_amt');
494: AND nvl(e.task_id,0) = nvl(X2_task_id, nvl(e.task_id,0))
495: AND e.completion_date <= nvl(X2_accrue_through_date, sysdate)
496: AND NOT EXISTS ( select '1'
497: from pa_billing_assignments bea,
498: pa_billing_extensions be
499: where be.billing_extension_id = bea.billing_extension_id
500: and bea.billing_assignment_id = e.billing_assignment_id
501: and be.procedure_name = 'pa_bill_pct.calc_pct_comp_amt');
502:
521: AND e.project_id = X2_project_id
522: AND nvl(e.task_id,0) = nvl(X2_task_id, nvl(e.task_id,0))
523: AND e.completion_date <= nvl(X2_accrue_through_date, sysdate)
524: AND NOT EXISTS ( select '1'
525: from pa_billing_assignments bea,
526: pa_billing_extensions be
527: where be.billing_extension_id = bea.billing_extension_id
528: and bea.billing_assignment_id = e.billing_assignment_id
529: and be.procedure_name = 'pa_bill_pct.calc_pct_comp_amt'); */
522: AND nvl(e.task_id,0) = nvl(X2_task_id, nvl(e.task_id,0))
523: AND e.completion_date <= nvl(X2_accrue_through_date, sysdate)
524: AND NOT EXISTS ( select '1'
525: from pa_billing_assignments bea,
526: pa_billing_extensions be
527: where be.billing_extension_id = bea.billing_extension_id
528: and bea.billing_assignment_id = e.billing_assignment_id
529: and be.procedure_name = 'pa_bill_pct.calc_pct_comp_amt'); */
530:
529: and be.procedure_name = 'pa_bill_pct.calc_pct_comp_amt'); */
530:
531: /* Following code has been added for MCB2 */
532: l_project_id := X2_project_id;
533: l_calling_process := pa_billing.GetCallProcess;
534: PA_MULTI_CURRENCY_BILLING.get_project_defaults (
535: p_project_id => l_project_id,
536: x_multi_currency_billing_flag => l_multi_currency_billing_flag,
537: x_baseline_funding_flag => l_baseline_funding_flag,
561: l_projfunc_currency_code,l_projfunc_rate_type,
562: l_projfunc_rate_date,l_projfunc_exchange_rate;
563: EXIT WHEN pctfunc_rev_inv_amt%NOTFOUND;
564: IF ( l_calling_process = 'Revenue' ) THEN
565: l_projfunc_rate_date := NVL(l_projfunc_rate_date,pa_billing.GetPaDate);
566: l_passd_amt := l_trans_rev_amt;
567: ELSIF ( l_calling_process = 'Invoice' ) THEN
568: l_projfunc_rate_date := NVL(l_projfunc_rate_date,pa_billing.GetInvoiceDate);
569: l_passd_amt := l_trans_bill_amt;
564: IF ( l_calling_process = 'Revenue' ) THEN
565: l_projfunc_rate_date := NVL(l_projfunc_rate_date,pa_billing.GetPaDate);
566: l_passd_amt := l_trans_rev_amt;
567: ELSIF ( l_calling_process = 'Invoice' ) THEN
568: l_projfunc_rate_date := NVL(l_projfunc_rate_date,pa_billing.GetInvoiceDate);
569: l_passd_amt := l_trans_bill_amt;
570: END IF;
571: /* Calling convert amount proc to convert this amount in PFC */
572: PA_MULTI_CURRENCY.convert_amount(
664: CURSOR pctfunc_revenue(X2_project_id Number,X2_task_id Number) IS
665: SELECT NVL(e.bill_trans_rev_amount,0) trans_rev_amount,e.bill_trans_currency_code,
666: e.projfunc_currency_code,e.projfunc_rate_type,e.projfunc_rate_date,e.projfunc_exchange_rate
667: FROM pa_events e,
668: pa_billing_assignments bea,
669: pa_billing_extensions be
670: where be.billing_extension_id = bea.billing_extension_id
671: and e.project_id = X2_project_id
672: and nvl(e.task_id,0) =
665: SELECT NVL(e.bill_trans_rev_amount,0) trans_rev_amount,e.bill_trans_currency_code,
666: e.projfunc_currency_code,e.projfunc_rate_type,e.projfunc_rate_date,e.projfunc_exchange_rate
667: FROM pa_events e,
668: pa_billing_assignments bea,
669: pa_billing_extensions be
670: where be.billing_extension_id = bea.billing_extension_id
671: and e.project_id = X2_project_id
672: and nvl(e.task_id,0) =
673: decode(X2_task_id,
690: AND nvl(dri.task_id,0) = decode(X2_task_id, NULL, nvl(dri.task_id,0), X2_task_id )
691: AND (EXISTS ( select '1'
692: from pa_cust_event_rev_dist_lines erdl,
693: pa_events e,
694: pa_billing_assignments bea,
695: pa_billing_extensions be
696: where be.billing_extension_id = bea.billing_extension_id
697: and bea.billing_assignment_id = e.billing_assignment_id
698: and e.project_id = erdl.project_id
691: AND (EXISTS ( select '1'
692: from pa_cust_event_rev_dist_lines erdl,
693: pa_events e,
694: pa_billing_assignments bea,
695: pa_billing_extensions be
696: where be.billing_extension_id = bea.billing_extension_id
697: and bea.billing_assignment_id = e.billing_assignment_id
698: and e.project_id = erdl.project_id
699: and e.event_num = erdl.event_num
715: /*
716: SELECT sum(nvl(e.revenue_amount,0))
717: INTO pending_pctrev
718: FROM pa_events e,
719: pa_billing_assignments bea,
720: pa_billing_extensions be
721: where be.billing_extension_id = bea.billing_extension_id
722: and e.project_id = X2_project_id
723: and nvl(e.task_id,0) =
716: SELECT sum(nvl(e.revenue_amount,0))
717: INTO pending_pctrev
718: FROM pa_events e,
719: pa_billing_assignments bea,
720: pa_billing_extensions be
721: where be.billing_extension_id = bea.billing_extension_id
722: and e.project_id = X2_project_id
723: and nvl(e.task_id,0) =
724: decode(X2_task_id,
759: FETCH pctfunc_revenue INTO l_trans_rev_amt,l_txn_currency_code,l_projfunc_currency_code,
760: l_projfunc_rate_type,l_projfunc_rate_date,l_projfunc_exchange_rate;
761: EXIT WHEN pctfunc_revenue%NOTFOUND;
762: IF ( l_project_bil_rate_date_code = 'PA_INVOICE_DATE' ) THEN
763: l_projfunc_rate_date := NVL(l_projfunc_rate_date,pa_billing.GetPaDate);
764: END IF;
765:
766: /* Calling convert amount proc to convert this amount in PFC */
767: PA_MULTI_CURRENCY.convert_amount(
855: CURSOR pctfunc_invoice(X2_project_id Number,X2_task_id Number) IS
856: SELECT NVL(e.bill_trans_bill_amount,0) trans_bill_amount,e.bill_trans_currency_code,e.projfunc_currency_code,
857: e.projfunc_rate_type,e.projfunc_rate_date,e.projfunc_exchange_rate
858: FROM pa_events e,
859: pa_billing_assignments bea,
860: pa_billing_extensions be
861: WHERE be.billing_extension_id = bea.billing_extension_id
862: AND bea.billing_assignment_id = e.billing_assignment_id
863: AND e.project_id = X2_project_id
856: SELECT NVL(e.bill_trans_bill_amount,0) trans_bill_amount,e.bill_trans_currency_code,e.projfunc_currency_code,
857: e.projfunc_rate_type,e.projfunc_rate_date,e.projfunc_exchange_rate
858: FROM pa_events e,
859: pa_billing_assignments bea,
860: pa_billing_extensions be
861: WHERE be.billing_extension_id = bea.billing_extension_id
862: AND bea.billing_assignment_id = e.billing_assignment_id
863: AND e.project_id = X2_project_id
864: AND be.procedure_name = 'pa_bill_pct.calc_pct_comp_amt'
883: /*
884: SELECT sum(nvl(e.bill_amount,0))
885: INTO pending_ccinv
886: from pa_events e,
887: pa_billing_assignments bea,
888: pa_billing_extensions be
889: where be.billing_extension_id = bea.billing_extension_id
890: and bea.billing_assignment_id = e.billing_assignment_id
891: and e.project_id = X2_project_id
884: SELECT sum(nvl(e.bill_amount,0))
885: INTO pending_ccinv
886: from pa_events e,
887: pa_billing_assignments bea,
888: pa_billing_extensions be
889: where be.billing_extension_id = bea.billing_extension_id
890: and bea.billing_assignment_id = e.billing_assignment_id
891: and e.project_id = X2_project_id
892: and be.procedure_name = 'pa_bill_pct.calc_pct_comp_amt'
931: FETCH pctfunc_invoice INTO l_trans_bill_amt,l_txn_currency_code,l_projfunc_currency_code,
932: l_projfunc_rate_type,l_projfunc_rate_date,l_projfunc_exchange_rate;
933: EXIT WHEN pctfunc_invoice%NOTFOUND;
934: IF ( l_project_bil_rate_date_code = 'PA_INVOICE_DATE' ) THEN
935: l_projfunc_rate_date := NVL(l_projfunc_rate_date,pa_billing.GetInvoiceDate);
936: END IF;
937: /* Calling convert amount proc to convert this amount in PFC */
938: PA_MULTI_CURRENCY.convert_amount(
939: P_FROM_CURRENCY => l_txn_currency_code,
972: FROM pa_draft_invoice_items dii
973: WHERE dii.project_id = X2_project_id
974: AND (EXISTS (select '1'
975: from pa_events e,
976: pa_billing_assignments bea,
977: pa_billing_extensions be
978: where be.billing_extension_id = bea.billing_extension_id
979: and bea.billing_assignment_id = e.billing_assignment_id
980: and dii.project_id = e.project_id
973: WHERE dii.project_id = X2_project_id
974: AND (EXISTS (select '1'
975: from pa_events e,
976: pa_billing_assignments bea,
977: pa_billing_extensions be
978: where be.billing_extension_id = bea.billing_extension_id
979: and bea.billing_assignment_id = e.billing_assignment_id
980: and dii.project_id = e.project_id
981: and dii.event_num = e.event_num
1017: WHERE pdii.event_task_id = X2_task_id
1018: AND pdii.Project_ID = X2_Project_ID -- Perf Bug 2695332
1019: AND EXISTS (select '1'
1020: from pa_events e,
1021: pa_billing_assignments bea,
1022: pa_billing_extensions be
1023: where be.billing_extension_id = bea.billing_extension_id
1024: and bea.billing_assignment_id = e.billing_assignment_id
1025: and pdii.project_id = e.project_id
1018: AND pdii.Project_ID = X2_Project_ID -- Perf Bug 2695332
1019: AND EXISTS (select '1'
1020: from pa_events e,
1021: pa_billing_assignments bea,
1022: pa_billing_extensions be
1023: where be.billing_extension_id = bea.billing_extension_id
1024: and bea.billing_assignment_id = e.billing_assignment_id
1025: and pdii.project_id = e.project_id
1026: and pdii.event_num = e.event_num
1174: DECODE(P_rev_plan_type_id,NULL,default_rev_plan_type_id,
1175: P_rev_plan_type_id) /* Added for fin plan type id */
1176: INTO l_rev_budget_type_code,
1177: l_rev_plan_type_id
1178: FROM pa_billing_extensions
1179: WHERE billing_extension_id=pa_billing.GetBillingExtensionId;
1180:
1181: IF g1_debug_mode = 'Y' THEN
1182: PA_MCB_INVOICE_PKG.log_message(' getting l_rev_budget_type_code inside pa_bill_pct.get_rev_budget_amount: '||l_rev_budget_type_code);
1175: P_rev_plan_type_id) /* Added for fin plan type id */
1176: INTO l_rev_budget_type_code,
1177: l_rev_plan_type_id
1178: FROM pa_billing_extensions
1179: WHERE billing_extension_id=pa_billing.GetBillingExtensionId;
1180:
1181: IF g1_debug_mode = 'Y' THEN
1182: PA_MCB_INVOICE_PKG.log_message(' getting l_rev_budget_type_code inside pa_bill_pct.get_rev_budget_amount: '||l_rev_budget_type_code);
1183: END IF;
1284: PA_MCB_INVOICE_PKG.log_message(' Exiting pa_bill_pct.get_rev_budget_amount: ');
1285: END IF;
1286: EXCEPTION
1287: WHEN invalid_rev_budget_code THEN
1288: status := pa_billing_values.get_message('INVALID_REV_BUDGET_TYPE');
1289: l_status := 2;
1290: RAISE_APPLICATION_ERROR(-20101,status);
1291: WHEN rev_budget_not_baselined THEN
1292: status := pa_billing_values.get_message('REV_BUDGET_NOT_BASELINED');
1288: status := pa_billing_values.get_message('INVALID_REV_BUDGET_TYPE');
1289: l_status := 2;
1290: RAISE_APPLICATION_ERROR(-20101,status);
1291: WHEN rev_budget_not_baselined THEN
1292: status := pa_billing_values.get_message('REV_BUDGET_NOT_BASELINED');
1293: l_status := 3;
1294: RAISE_APPLICATION_ERROR(-20101,status);
1295: WHEN OTHERS THEN
1296: status := substr(SQLERRM,1,240);
1309:
1310: X_error_message := status;
1311: X_status := l_status;
1312:
1313: pa_billing_pub.insert_message
1314: (X_inserting_procedure_name =>'pa_billing_pct.get_rev_budget_amount',
1315: X_attribute2 => l_rev_budget_type_code,
1316: X_message => status,
1317: X_error_message=>err_msg,
1310: X_error_message := status;
1311: X_status := l_status;
1312:
1313: pa_billing_pub.insert_message
1314: (X_inserting_procedure_name =>'pa_billing_pct.get_rev_budget_amount',
1315: X_attribute2 => l_rev_budget_type_code,
1316: X_message => status,
1317: X_error_message=>err_msg,
1318: X_status=>err_status);