1: PACKAGE BODY PA_UTILS2 AS
2: /* $Header: PAXGUT2B.pls 120.15.12010000.2 2008/08/22 16:16:51 mumohan ship $ */
3:
4: -- FUNCTION get_period_name /*2835063*/
5: FUNCTION get_period_name RETURN pa_cost_distribution_lines_all.pa_period_name%TYPE is
883: -- If control comes here, it means that either the cache is empty or
884: -- the provider Cache is not reusable.
885: -- Access the DB and refresh cache and return pa_date.
886:
887: pa_utils2.refresh_pa_cache( p_org_id , p_ei_date, 'P' );
888: /*
889: * Here we can return g_prvdr_pa_date - because the profile option
890: * is taken care during the refresh_pa_cache.
891: */
908: g_profile_cache_first_time :='N' ;
909: END IF;
910:
911: SELECT decode(nvl(g_profile_value,'N'),
912: 'Y', pa_utils2.get_pa_date( exp_item_date,accounting_date,org_id),
913: 'N', pa_integration.get_raw_cdl_pa_date(exp_item_date,accounting_date,org_id))
914: INTO l_return_date
915: FROM DUAL;
916: RETURN l_return_date;
925: g_profile_cache_first_time :='N' ;
926: END IF;
927:
928: SELECT decode(nvl(g_profile_value,'N'),
929: 'Y', pa_utils2.get_period_name(),
930: 'N', pa_integration.get_period_name())
931: INTO l_return_name
932: FROM DUAL;
933: RETURN l_return_name;
1095: **hence hit the DB and populate/refresh receiver cache.
1096: **then return g_recvr_pa_date.
1097: **/
1098:
1099: pa_utils2.refresh_pa_cache ( p_org_id , p_ei_date , 'R' );
1100: return ( g_recvr_pa_date ) ;
1101: EXCEPTION
1102: WHEN OTHERS THEN
1103: RAISE ;
1353: );
1354:
1355: UPDATE PA_Cost_Distribution_lines CDL
1356: SET CDL.GL_DATE = l_prvdr_accr_date,
1357: CDL.GL_PERIOD_NAME = pa_utils2.get_gl_period_name (l_prvdr_accr_date,CDL.org_id)
1358: WHERE CDL.EXPENDITURE_ITEM_ID = l_exp_item_id
1359: AND CDL.LINE_NUM_REVERSED IS NULL
1360: AND CDL.TRANSFER_STATUS_CODE in ('P','R','G');
1361:
1406: * -- Calling this procedure from pro*C requires some array related processing which
1407: * -- can be avoided if this procedure is not called from pro*C. This change has to
1408: * -- be done - at some point of time.
1409: *
1410: * ,CDL.GL_Date = ( SELECT pa_utils2.get_prvdr_gl_date(
1411: * MAX(CDL.pa_date)
1412: * ,p_application_id(i)
1413: * ,p_prvdr_sob_id(i))
1414: * FROM pa_cost_distribution_lines CDL,
1416: * WHERE ITEM.expenditure_item_id = CDL.expenditure_item_id
1417: * AND CDL.line_type = 'R'
1418: * AND ITEM.expenditure_id = p_expnd_id(i)
1419: * )
1420: * ,CDL.Recvr_Gl_Date = ( SELECT pa_utils2.get_recvr_gl_date(
1421: * MAX(CDL.recvr_pa_date)
1422: * ,p_application_id(i)
1423: * ,p_recvr_sob_id(i))
1424: * FROM pa_cost_distribution_lines CDL,
1469:
1470:
1471: BEGIN
1472: Select
1473: pa_utils2.get_prvdr_gl_date(
1474: CDL.gl_date
1475: ,p_application_id(i)
1476: ,p_prvdr_sob_id(i)) gl_date,
1477: pa_utils2.get_gl_period_name (
1473: pa_utils2.get_prvdr_gl_date(
1474: CDL.gl_date
1475: ,p_application_id(i)
1476: ,p_prvdr_sob_id(i)) gl_date,
1477: pa_utils2.get_gl_period_name (
1478: pa_utils2.get_prvdr_gl_date(
1479: CDL.gl_date
1480: ,p_application_id(i)
1481: ,p_prvdr_sob_id(i))
1474: CDL.gl_date
1475: ,p_application_id(i)
1476: ,p_prvdr_sob_id(i)) gl_date,
1477: pa_utils2.get_gl_period_name (
1478: pa_utils2.get_prvdr_gl_date(
1479: CDL.gl_date
1480: ,p_application_id(i)
1481: ,p_prvdr_sob_id(i))
1482: ,CDL.org_id) gl_period_name,
1479: CDL.gl_date
1480: ,p_application_id(i)
1481: ,p_prvdr_sob_id(i))
1482: ,CDL.org_id) gl_period_name,
1483: pa_utils2.get_recvr_gl_date(
1484: CDL.recvr_gl_date
1485: ,p_application_id(i)
1486: ,p_recvr_sob_id(i)) recvr_gl_date,
1487: pa_utils2.get_gl_period_name (
1483: pa_utils2.get_recvr_gl_date(
1484: CDL.recvr_gl_date
1485: ,p_application_id(i)
1486: ,p_recvr_sob_id(i)) recvr_gl_date,
1487: pa_utils2.get_gl_period_name (
1488: pa_utils2.get_recvr_gl_date(
1489: CDL.recvr_gl_date
1490: ,p_application_id(i)
1491: ,p_recvr_sob_id(i))
1484: CDL.recvr_gl_date
1485: ,p_application_id(i)
1486: ,p_recvr_sob_id(i)) recvr_gl_date,
1487: pa_utils2.get_gl_period_name (
1488: pa_utils2.get_recvr_gl_date(
1489: CDL.recvr_gl_date
1490: ,p_application_id(i)
1491: ,p_recvr_sob_id(i))
1492: ,nvl(EI.recvr_org_id,CDL.org_id)) recvr_gl_period_name,
1986:
1987: /*Added for bug 4277525 -Start */
1988: IF g_prvdr_gl_date IS NULL OR g_prvdr_gl_period_name IS null
1989: then
1990: pa_utils2.refresh_gl_cache( p_reference_date,
1991: p_application_id,
1992: p_set_of_books_id,
1993: 'P'
1994: );
2027: -- 2. cache is empty or
2028: -- 3. the Cache is not reusable.
2029: -- Access the DB and refresh cache and return gl_date.
2030:
2031: pa_utils2.refresh_gl_cache( p_reference_date,
2032: p_application_id,
2033: p_set_of_books_id,
2034: 'P'
2035: );
2152: END IF ; -- sob
2153: END IF; -- g_r_earliest_gl_start_date
2154: END IF ; -- p_set_of_books_id
2155:
2156: pa_utils2.refresh_gl_cache ( p_reference_date,
2157: p_application_id,
2158: p_set_of_books_id,
2159: 'R');
2160: return ( g_recvr_gl_date ) ;
2390: -- 2. cache is empty or
2391: -- 3. the Cache is not reusable.
2392: -- Access the DB and refresh cache and return gl_date.
2393:
2394: pa_utils2.refresh_gl_cache( p_pa_date,
2395: p_application_id,
2396: p_set_of_books_id,
2397: 'P'
2398: );
2495: fnd_profile.get('PA_DEBUG_MODE',l_debug_mode);
2496: l_debug_mode := NVL(l_debug_mode, 'N');
2497: l_stage := 100;
2498: IF (l_debug_mode = 'Y') THEN
2499: pa_debug.init_err_stack('pa_utils2.get_period_information');
2500: pa_debug.set_process('PLSQL','LOG',l_debug_mode);
2501: pa_debug.g_err_stage := TO_CHAR(l_stage) || ':From get_period_information';
2502: pa_debug.write_file(pa_debug.g_err_stage);
2503: END IF;
2591: * gl_date for the burden CDL is derived based on the pa_date in the Raw CDL.
2592: */
2593: IF ( p_calling_module = 'CDL' AND p_prvdr_raw_gl_date IS NOT NULL )
2594: THEN
2595: l_prvdr_gl_date := pa_utils2.get_prvdr_gl_date( p_reference_date => p_prvdr_raw_gl_date
2596: ,p_application_id => l_pa_gl_app_id
2597: ,p_set_of_books_id => p_prvdr_sob_id
2598: );
2599: l_prvdr_gl_period_name := g_prvdr_gl_period_name;
2600: END IF; -- p_calling_module
2601:
2602: IF ( p_calling_module = 'CDL' AND p_recvr_raw_gl_date IS NOT NULL )
2603: THEN
2604: l_recvr_gl_date := pa_utils2.get_recvr_gl_date( p_reference_date => p_recvr_raw_gl_date
2605: ,p_application_id => l_pa_gl_app_id
2606: ,p_set_of_books_id => p_recvr_sob_id
2607: );
2608: l_recvr_gl_period_name := g_recvr_gl_period_name;
2630: THEN
2631: l_app_id := l_pa_gl_app_id; /* Modified l_gl_app_id for Bug 6904977 */
2632: END IF;
2633:
2634: l_prvdr_gl_date := pa_utils2.get_prvdr_gl_date( p_reference_date => p_expenditure_item_date
2635: ,p_application_id => l_app_id
2636: ,p_set_of_books_id => p_prvdr_sob_id
2637: );
2638: l_prvdr_gl_period_name := g_prvdr_gl_period_name;
2638: l_prvdr_gl_period_name := g_prvdr_gl_period_name;
2639:
2640: IF ( derive.receiver <> 'N' AND p_expenditure_item_date IS NOT NULL )
2641: THEN
2642: l_recvr_gl_date := pa_utils2.get_recvr_gl_date( p_reference_date => p_expenditure_item_date
2643: ,p_application_id => l_app_id
2644: ,p_set_of_books_id => p_recvr_sob_id
2645: );
2646: l_recvr_gl_period_name := g_recvr_gl_period_name;
2677: IF (p_line_type <> 'R' AND p_system_linkage_function = 'VI')
2678: THEN
2679: IF ( p_prvdr_raw_pa_date IS NOT NULL )
2680: THEN
2681: l_prvdr_pa_date := pa_utils2.get_pa_date( p_ei_date => p_prvdr_raw_pa_date
2682: ,p_gl_date => SYSDATE
2683: ,p_org_id => p_prvdr_org_id
2684: );
2685: l_prvdr_pa_period_name := g_prvdr_pa_period_name;
2686: END IF;
2687: ELSE
2688: IF ( p_expenditure_item_date IS NOT NULL )
2689: THEN
2690: l_prvdr_pa_date := pa_utils2.get_pa_date( p_ei_date => p_expenditure_item_date
2691: ,p_gl_date => SYSDATE
2692: ,p_org_id => p_prvdr_org_id
2693: );
2694: l_prvdr_pa_period_name := g_prvdr_pa_period_name;
2727: IF (p_line_type <> 'R' AND p_system_linkage_function = 'VI')
2728: THEN
2729: IF ( derive.receiver <> 'N' AND p_recvr_raw_pa_date IS NOT NULL )
2730: THEN
2731: l_recvr_pa_date := pa_utils2.get_recvr_pa_date( p_ei_date => p_recvr_raw_pa_date
2732: ,p_gl_date => SYSDATE
2733: ,p_org_id => p_recvr_org_id
2734: );
2735: l_recvr_pa_period_name := g_recvr_pa_period_name;
2736: END IF;
2737: ELSE
2738: IF ( derive.receiver <> 'N' AND p_expenditure_item_date IS NOT NULL )
2739: THEN
2740: l_recvr_pa_date := pa_utils2.get_recvr_pa_date( p_ei_date => p_expenditure_item_date
2741: ,p_gl_date => SYSDATE
2742: ,p_org_id => p_recvr_org_id
2743: );
2744: l_recvr_pa_period_name := g_recvr_pa_period_name;
2758: THEN
2759: -- this area has to be revisited.
2760: IF ( p_prvdr_raw_pa_date IS NOT NULL )
2761: THEN
2762: l_prvdr_pa_date := pa_utils2.get_pa_date( p_ei_date => p_prvdr_raw_pa_date
2763: ,p_gl_date => SYSDATE
2764: ,p_org_id => p_prvdr_org_id
2765: );
2766: l_prvdr_pa_period_name := g_prvdr_pa_period_name;
2766: l_prvdr_pa_period_name := g_prvdr_pa_period_name;
2767: END IF;
2768: IF ( derive.receiver <> 'N' AND p_recvr_raw_pa_date IS NOT NULL )
2769: THEN
2770: l_recvr_pa_date := pa_utils2.get_recvr_pa_date( p_ei_date => p_recvr_raw_pa_date
2771: ,p_gl_date => SYSDATE
2772: ,p_org_id => p_recvr_org_id
2773: );
2774: l_recvr_pa_period_name := g_recvr_pa_period_name;
2775: END IF; -- p_calling_module
2776: ELSE
2777: IF ( p_expenditure_item_date IS NOT NULL )
2778: THEN
2779: l_prvdr_pa_date := pa_utils2.get_pa_date( p_ei_date => p_expenditure_item_date
2780: ,p_gl_date => SYSDATE
2781: ,p_org_id => p_prvdr_org_id
2782: );
2783: l_prvdr_pa_period_name := g_prvdr_pa_period_name;
2784: END IF;
2785:
2786: IF ( derive.receiver <> 'N' AND p_expenditure_item_date IS NOT NULL )
2787: THEN
2788: l_recvr_pa_date := pa_utils2.get_recvr_pa_date( p_ei_date => p_expenditure_item_date
2789: ,p_gl_date => SYSDATE
2790: ,p_org_id => p_recvr_org_id
2791: );
2792: l_recvr_pa_period_name := g_recvr_pa_period_name;
2830: IF (p_calling_module = 'AR_INSTALLED_INVOICE' OR p_calling_module = 'AR_NOT_INSTALLED_INVOICE')
2831: THEN
2832: IF ( p_expenditure_item_date IS NOT NULL )
2833: THEN
2834: l_prvdr_gl_date := pa_utils2.get_prvdr_gl_date( p_reference_date => p_expenditure_item_date
2835: ,p_application_id => l_app_id
2836: ,p_set_of_books_id => p_prvdr_sob_id
2837: );
2838: l_prvdr_gl_period_name := g_prvdr_gl_period_name;
2839: END IF;
2840:
2841: IF ( derive.receiver <> 'N' AND p_expenditure_item_date IS NOT NULL )
2842: THEN
2843: l_recvr_gl_date := pa_utils2.get_recvr_gl_date( p_reference_date => p_expenditure_item_date
2844: ,p_application_id => l_app_id
2845: ,p_set_of_books_id => p_recvr_sob_id
2846: );
2847: /* Code changes end for bug 2965043 */
2849: END IF;
2850: ELSE /*Bug# 3617395*/
2851: IF ( l_prvdr_pa_date IS NOT NULL )
2852: THEN
2853: l_prvdr_gl_date := pa_utils2.get_prvdr_gl_date( p_reference_date => l_prvdr_pa_date
2854: ,p_application_id => l_app_id
2855: ,p_set_of_books_id => p_prvdr_sob_id
2856: );
2857: l_prvdr_gl_period_name := g_prvdr_gl_period_name;
2858: END IF;
2859:
2860: IF ( derive.receiver <> 'N' AND l_recvr_pa_date IS NOT NULL )
2861: THEN
2862: l_recvr_gl_date := pa_utils2.get_recvr_gl_date( p_reference_date => l_recvr_pa_date
2863: ,p_application_id => l_app_id
2864: ,p_set_of_books_id => p_recvr_sob_id
2865: );
2866: l_recvr_gl_period_name := g_recvr_gl_period_name;
3010: l_date_dummy DATE;
3011: l_name_dummy VARCHAR2(30);
3012: l_calling_module VARCHAR2(30) := NULL ;
3013: BEGIN
3014: pa_debug.init_err_stack('pa_utils2.get_ou_period_information');
3015:
3016: fnd_profile.get('PA_DEBUG_MODE',l_debug_mode);
3017: l_debug_mode := NVL(l_debug_mode, 'N');
3018:
3036:
3037: l_stage := 200 ;
3038: IF ( l_debug_mode = 'Y' )
3039: THEN
3040: pa_debug.g_err_stage := TO_CHAR(l_stage) || ':Calling pa_utils2.get_period_information';
3041: pa_debug.write_file(pa_debug.g_err_stage);
3042: END IF; -- debug
3043:
3044: pa_utils2.get_period_information
3040: pa_debug.g_err_stage := TO_CHAR(l_stage) || ':Calling pa_utils2.get_period_information';
3041: pa_debug.write_file(pa_debug.g_err_stage);
3042: END IF; -- debug
3043:
3044: pa_utils2.get_period_information
3045: ( p_expenditure_item_date => p_reference_date
3046: ,p_prvdr_org_id => l_org_id
3047: ,p_prvdr_sob_id => l_sob_id
3048: ,p_calling_module => l_calling_module
3062:
3063: l_stage := 300 ;
3064: IF ( l_debug_mode = 'Y' )
3065: THEN
3066: pa_debug.g_err_stage := TO_CHAR(l_stage) || ':After call to pa_utils2.get_period_information';
3067: pa_debug.write_file(pa_debug.g_err_stage);
3068: pa_debug.g_err_stage := TO_CHAR(l_stage) || ':PA date [' || to_char(l_pa_date) || '] name [' || l_pa_period_name || ']';
3069: pa_debug.write_file(pa_debug.g_err_stage);
3070: pa_debug.g_err_stage := TO_CHAR(l_stage) || ':GL date [' || to_char(l_gl_date) || '] name [' || l_gl_period_name || ']';
3634: END IF;
3635: return(NULL);
3636: WHEN OTHERS THEN
3637: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
3638: x_error_stage := 'Procedure: Pa_Utils2.Get_Accrual_Period_Information() ::: ' || pa_debug.g_err_stage ||':: '|| SQLERRM;
3639: raise;
3640: END;
3641:
3642:
3697: return(l_rev_accr_dt);
3698: EXCEPTION
3699: WHEN OTHERS THEN
3700: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
3701: x_error_stage := 'Procedure: Pa_Utils2.Get_Accrual_Period_Information() ::: ' || pa_debug.g_err_stage ||':: '|| SQLERRM;
3702: RAISE;
3703: END;
3704: ----------------------------------------------------------------------------------------------------------------
3705: -- API : get_accrual_gl_dt_period
3857: pa_debug.g_err_stage := 'get_accrual_gl_dt_period()-WO for ref dt- ['||to_char(p_reference_date)||']';
3858: IF ( l_debug_mode = 'Y' ) THEN
3859: pa_debug.write_file(pa_debug.g_err_stage);
3860: END IF;
3861: x_error_stage := 'Procedure: Pa_Utils2.Get_Accrual_Period_Information() ::: ' || pa_debug.g_err_stage ||':: '|| SQLERRM;
3862: raise;
3863: END;
3864: -- EPP Derivation.
3865: IF p_epp_flag = 'Y' THEN
3924:
3925: EXCEPTION
3926: WHEN OTHERS THEN
3927: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
3928: x_error_stage := 'Procedure: Pa_Utils2.Get_Accrual_Period_Information() ::: ' || pa_debug.g_err_stage ||':: '|| SQLERRM;
3929: raise;
3930: END;
3931: ----------------------------------------------------------------------------------------------------------------
3932: -- API : get_accrual_period_information
4061: fnd_profile.get('PA_DEBUG_MODE',l_debug_mode);
4062: l_debug_mode := NVL(l_debug_mode, 'N');
4063: pa_debug.g_err_stage :='From get_accrual_period_information';
4064: IF(l_debug_mode = 'Y') THEN
4065: pa_debug.init_err_stack('pa_utils2.get_accrual_period_information');
4066: pa_debug.set_process('PLSQL','LOG',l_debug_mode);
4067:
4068: pa_debug.write_file(pa_debug.g_err_stage);
4069: END IF;
4144: x_error_stage := pa_debug.g_err_stage;
4145:
4146: --- Though this api returns the period name also, we don't make use of it at this stage.
4147: BEGIN
4148: pa_utils2.get_accrual_gl_dt_period( p_calling_module => p_calling_module
4149: ,p_reference_date => p_expenditure_item_date
4150: ,p_application_id => l_pa_gl_app_id
4151: ,p_set_of_books_id => p_prvdr_sob_id
4152: ,p_prvdr_recvr_flg => 'P'
4181:
4182: -- Though we are not deriving the gl_period_name , this api is multi-function.
4183: -- It checks if the ei date is in an O/F period. This check is for RECVR.
4184: BEGIN
4185: pa_utils2.get_accrual_gl_dt_period( p_calling_module => p_calling_module
4186: ,p_reference_date => p_expenditure_item_date
4187: ,p_application_id => l_pa_gl_app_id
4188: ,p_set_of_books_id => p_recvr_sob_id
4189: ,p_prvdr_recvr_flg => 'R'
4212: --- For REV EI, the accrual dates of the
4213: --- ORG EI are passed. Since its an IN OUT parameter, we read and write to the same parameter.
4214: --- For REV EI, the accrual date is the first/last day of the next O,F GL Period depending on EPP.
4215:
4216: l_prvdr_accrual_date := pa_utils2.get_rev_accrual_date(p_calling_module => p_calling_module
4217: ,p_reference_date =>x_prvdr_accrual_date
4218: ,p_application_id => l_pa_gl_app_id
4219: ,p_set_of_books_id => p_prvdr_sob_id
4220: ,p_prvdr_recvr_flg => 'P'
4242: END IF;
4243: x_error_stage := pa_debug.g_err_stage;
4244:
4245: ELSE
4246: l_recvr_accrual_date := pa_utils2.get_rev_accrual_date( p_calling_module => p_calling_module
4247: ,p_reference_date =>x_recvr_accrual_date
4248: ,p_application_id => l_pa_gl_app_id
4249: ,p_set_of_books_id => p_recvr_sob_id
4250: ,p_prvdr_recvr_flg => 'R'
4304:
4305: --- We make use of the GL period name.
4306: --- This is just to check if the accrual date is still in an open period.
4307: BEGIN
4308: pa_utils2.get_accrual_gl_dt_period( p_calling_module => p_calling_module
4309: ,p_reference_date => x_prvdr_accrual_date
4310: ,p_application_id => l_pa_gl_app_id
4311: ,p_set_of_books_id => p_prvdr_sob_id
4312: ,p_prvdr_recvr_flg => 'P'
4348: ELSE ----Do the check for O/F status.
4349:
4350: -- It checks if the accrual date is in an O/F period. This check is for RECVR.
4351: BEGIN
4352: pa_utils2.get_accrual_gl_dt_period( p_calling_module => p_calling_module
4353: ,p_reference_date => x_recvr_accrual_date
4354: ,p_application_id => l_pa_gl_app_id
4355: ,p_set_of_books_id => p_recvr_sob_id
4356: ,p_prvdr_recvr_flg => 'R'
4401: pa_debug.write_file(pa_debug.g_err_stage);
4402: END IF;
4403: -- We need the Period name.
4404: BEGIN
4405: pa_utils2.get_accrual_gl_dt_period( p_calling_module => p_calling_module
4406: ,p_reference_date => l_prvdr_accrual_date
4407: ,p_application_id => l_pa_gl_app_id
4408: ,p_set_of_books_id => p_prvdr_sob_id
4409: ,p_prvdr_recvr_flg => 'P'
4441: l_recvr_gl_period_name := l_prvdr_gl_period_name;
4442: l_recvr_gl_date := l_recvr_accrual_date;
4443: ELSE --- derive the recvr_accrual_date based on the ei date.
4444: BEGIN
4445: pa_utils2.get_accrual_gl_dt_period( p_calling_module => p_calling_module
4446: ,p_reference_date => p_expenditure_item_date
4447: ,p_application_id => l_pa_gl_app_id
4448: ,p_set_of_books_id => p_recvr_sob_id
4449: ,p_prvdr_recvr_flg => 'R'
4466: --- For REV EI, the accrual dates of the
4467: --- ORG EI are passed. Since its an IN OUT parameter, we read and write to the same parameter.
4468: --- For REV EI, the accrual date is the first/last day of the next O,F GL Period depending on EPP.
4469:
4470: l_prvdr_accrual_date := pa_utils2.get_rev_accrual_date(p_calling_module => p_calling_module
4471: ,p_reference_date =>x_prvdr_accrual_date
4472: ,p_application_id => l_pa_gl_app_id
4473: ,p_set_of_books_id => p_prvdr_sob_id
4474: ,p_prvdr_recvr_flg => 'P'
4503: pa_debug.write_file(pa_debug.g_err_stage);
4504: END IF;
4505:
4506: ELSE
4507: l_recvr_accrual_date := pa_utils2.get_rev_accrual_date( p_calling_module => p_calling_module
4508: ,p_reference_date =>x_recvr_accrual_date
4509: ,p_application_id => l_pa_gl_app_id
4510: ,p_set_of_books_id => p_recvr_sob_id
4511: ,p_prvdr_recvr_flg => 'R'
4548: IF p_adj_ei_id IS NULL THEN ------------ORG EI-------------------------{
4549:
4550: BEGIN
4551: --- Derive the org prvdr pa date and pa period.
4552: pa_utils2.get_accrual_pa_dt_period( p_gl_period=>l_prvdr_gl_period_name
4553: ,p_ei_date => p_expenditure_item_date
4554: ,p_org_id =>p_prvdr_org_id
4555: ,p_prvdr_recvr_flg => 'P'
4556: ,p_epp_flag => l_prof_new_gldate_derivation
4583: END IF;
4584: ELSE
4585: --- Derive the org recvr pa date and pa period.
4586: BEGIN
4587: pa_utils2.get_accrual_pa_dt_period( p_gl_period=>l_recvr_gl_period_name
4588: ,p_ei_date => p_expenditure_item_date
4589: ,p_org_id =>p_recvr_org_id
4590: ,p_prvdr_recvr_flg => 'R'
4591: ,p_epp_flag => l_prof_new_gldate_derivation
4618: END IF;
4619: ----For Prvdr
4620: BEGIN
4621: --- Derive the org prvdr pa date and pa period.
4622: pa_utils2.get_accrual_pa_dt_period( p_gl_period=>l_prvdr_gl_period_name
4623: ,p_ei_date => p_expenditure_item_date
4624: ,p_org_id =>p_prvdr_org_id
4625: ,p_prvdr_recvr_flg => 'P'
4626: ,p_epp_flag => l_prof_new_gldate_derivation
4655: END IF;
4656: ELSE
4657: --- Derive the org recvr pa date and pa period.
4658: BEGIN
4659: pa_utils2.get_accrual_pa_dt_period( p_gl_period=>l_recvr_gl_period_name
4660: ,p_ei_date => p_expenditure_item_date
4661: ,p_org_id =>p_recvr_org_id
4662: ,p_prvdr_recvr_flg => 'R'
4663: ,p_epp_flag => l_prof_new_gldate_derivation
4742: BEGIN
4743:
4744: IF ( p_txn_date IS NOT NULL )
4745: THEN
4746: l_pa_date := pa_utils2.get_pa_date( p_ei_date => p_txn_date
4747: ,p_gl_date => SYSDATE
4748: ,p_org_id => p_org_id
4749: );
4750: l_pa_period_name := g_prvdr_pa_period_name;
4764: l_allow_burden_flag pa_transaction_sources.allow_burden_flag%TYPE := 'N';
4765: BEGIN
4766: IF ( p_transaction_source IS NOT NULL )
4767: THEN
4768: If p_transaction_source = pa_utils2.g_transaction_source Then
4769: Return g_ts_allow_burden_flag;
4770:
4771: Else
4772:
4774: into l_allow_burden_flag
4775: from pa_transaction_sources ts
4776: where ts.transaction_source = p_transaction_source;
4777:
4778: pa_utils2.g_ts_allow_burden_flag := l_allow_burden_flag;
4779: pa_utils2.g_transaction_source := p_transaction_source;
4780: RETURN l_allow_burden_flag;
4781: End If;
4782: ELSE
4775: from pa_transaction_sources ts
4776: where ts.transaction_source = p_transaction_source;
4777:
4778: pa_utils2.g_ts_allow_burden_flag := l_allow_burden_flag;
4779: pa_utils2.g_transaction_source := p_transaction_source;
4780: RETURN l_allow_burden_flag;
4781: End If;
4782: ELSE
4783: RETURN 'N';
5025: l_application_id NUMBER := NULL ;
5026:
5027: BEGIN
5028:
5029: pa_debug.write_file('PA_UTILS2.GET_GL_PERIOD: Entering procedure');
5030:
5031: /* Changed from value_specific to value for bug 5472333 */
5032: l_epp_flag := fnd_profile.value('PA_EN_NEW_GLDATE_DERIVATION') ;
5033:
5030:
5031: /* Changed from value_specific to value for bug 5472333 */
5032: l_epp_flag := fnd_profile.value('PA_EN_NEW_GLDATE_DERIVATION') ;
5033:
5034: pa_debug.write_file('PA_UTILS2.GET_GL_PERIOD: EPP Flag status: ' || l_epp_flag);
5035:
5036: l_application_id := l_gl_app_id ;
5037:
5038: SELECT imp.set_of_books_id
5038: SELECT imp.set_of_books_id
5039: INTO l_set_of_books_id
5040: FROM pa_implementations imp;
5041:
5042: pa_debug.write_file('PA_UTILS2.GET_GL_PERIOD: Using (appl_id, sob_id): (' || to_char(l_application_id) || ', ' || to_char(l_set_of_books_id) || ')' );
5043:
5044: ---Initialize the out variables.
5045: x_gl_period_name := NULL;
5046: x_gl_dt := NULL;
5046: x_gl_dt := NULL;
5047: x_return_status := 0;
5048: x_error_code := NULL;
5049:
5050: pa_debug.write_file('PA_UTILS2.GET_GL_PERIOD: Trying reference_date with cached start and end date values' );
5051:
5052: IF ((trunc(p_reference_date) BETWEEN g_gl_dt_period_str_dt AND g_gl_dt_period_end_dt )
5053: AND g_gl_dt_period_str_dt IS NOT NULL) THEN
5054:
5051:
5052: IF ((trunc(p_reference_date) BETWEEN g_gl_dt_period_str_dt AND g_gl_dt_period_end_dt )
5053: AND g_gl_dt_period_str_dt IS NOT NULL) THEN
5054:
5055: pa_debug.write_file('PA_UTILS2.GET_GL_PERIOD: Using cached values' );
5056:
5057: ---From Cache
5058: IF l_epp_flag = 'Y' THEN
5059: l_gl_dt := p_reference_date;
5064: --Assign the out variables.
5065: x_gl_dt := l_gl_dt ;
5066: x_gl_period_name := g_gl_dt_period_name;
5067:
5068: pa_debug.write_file('PA_UTILS2.GET_GL_PERIOD: Leaving procedure');
5069:
5070: return;
5071:
5072: END IF;
5072: END IF;
5073:
5074: --- Either the cache is empty or the reference date is not in the range.
5075:
5076: pa_debug.write_file('PA_UTILS2.GET_GL_PERIOD: Cache values empty/reference date not between cached start and end date values' );
5077:
5078: BEGIN
5079:
5080: SELECT PERIOD.period_name,PERIOD.start_date,PERIOD.end_date,PERIOD.closing_status
5092:
5093: return;
5094: WHEN OTHERS THEN
5095: x_return_status := -1;
5096: x_error_stage := 'PA_UTILS2.GET_GL_PERIOD:: ' || pa_debug.g_err_stage ||':: '|| SQLERRM;
5097:
5098: raise;
5099: END;
5100:
5104: ELSE
5105: l_gl_dt := l_gl_period_end_dt;
5106: END IF;
5107:
5108: pa_debug.write_file('PA_UTILS2.GET_GL_PERIOD: Checking for period status' );
5109:
5110: --Checking for period status.
5111: IF l_period_status NOT IN ('O','F') THEN
5112:
5109:
5110: --Checking for period status.
5111: IF l_period_status NOT IN ('O','F') THEN
5112:
5113: pa_debug.write_file('PA_UTILS2.GET_GL_PERIOD: Period is closed' );
5114:
5115: IF l_epp_flag = 'N' THEN
5116:
5117: pa_debug.g_err_stage := 'EPP = N, Querying next open period'; /* Added Code for Bug 6139975 */
5192: END IF;
5193:
5194: END IF;
5195:
5196: pa_debug.write_file('PA_UTILS2.GET_GL_PERIOD: Caching dates' );
5197:
5198: g_gl_dt_period_name := l_gl_period_name;
5199: g_gl_dt_period_str_dt := l_gl_period_st_dt ;
5200: g_gl_dt_period_end_dt := l_gl_period_end_dt;
5201:
5202: x_gl_dt := l_gl_dt ;
5203: x_gl_period_name := l_gl_period_name ;
5204:
5205: pa_debug.write_file('PA_UTILS2.GET_GL_PERIOD: Leaving procedure');
5206:
5207: EXCEPTION
5208:
5209: /* Start of code added for Bug 6139975 */
5210:
5211: WHEN NO_DATA_FOUND THEN
5212: x_return_status := -1;
5213: x_error_code := 'NO_GL_DATE';
5214: x_error_stage := 'PA_UTILS2.GET_GL_PERIOD:: ' || pa_debug.g_err_stage ||':: '|| SQLERRM;
5215:
5216: return;
5217:
5218: /* End of code added for Bug 6139975 */
5218: /* End of code added for Bug 6139975 */
5219:
5220: WHEN OTHERS THEN
5221: x_return_status := -1;
5222: x_error_stage := 'PA_UTILS2.GET_GL_PERIOD:: ' || pa_debug.g_err_stage ||':: '|| SQLERRM;
5223:
5224: raise;
5225: END get_gl_dt_period ;
5226:
5226:
5227: /* 5374282 ends */
5228:
5229:
5230: END pa_utils2;