381: INTO l_ren_prd_counter
382: FROM igi_iac_transaction_headers
383: WHERE adjustment_id = x_ren_adj_id;
384:
385: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstate period counter: '||l_ren_prd_counter);
386: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Retire period counter: '||l_ret_prd_counter);
387: -- elapsed period
388: l_diff := l_ren_prd_counter - l_ret_prd_counter;
389: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Difference: '||l_diff);
382: FROM igi_iac_transaction_headers
383: WHERE adjustment_id = x_ren_adj_id;
384:
385: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstate period counter: '||l_ren_prd_counter);
386: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Retire period counter: '||l_ret_prd_counter);
387: -- elapsed period
388: l_diff := l_ren_prd_counter - l_ret_prd_counter;
389: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Difference: '||l_diff);
390:
385: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstate period counter: '||l_ren_prd_counter);
386: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Retire period counter: '||l_ret_prd_counter);
387: -- elapsed period
388: l_diff := l_ren_prd_counter - l_ret_prd_counter;
389: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Difference: '||l_diff);
390:
391: RETURN l_diff;
392: EXCEPTION
393: WHEN OTHERS THEN
390:
391: RETURN l_diff;
392: EXCEPTION
393: WHEN OTHERS THEN
394: igi_iac_debug_pkg.debug_unexpected_msg(l_path);
395: RETURN 0;
396: END elapsed_periods;
397: */
398: -- =======================================================================
447: END IF;
448: RETURN l_ren_dist_id;
449: EXCEPTION
450: WHEN OTHERS THEN
451: igi_iac_debug_pkg.debug_unexpected_msg(l_path);
452: RETURN 0;
453: END Get_Corr_Ren_Dist_Id;
454:
455: -- =======================================================================
553:
554: l_path VARCHAR2(150);
555: BEGIN
556: l_path := g_path||'Full_Reinstatement';
557: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'In Full Reinstatements function');
558: -- get the adjustment_id of the transaction previous to the
559: -- retirement
560: -- OPEN c_trx_prev_ret(p_trxhdr_id_retire);
561: OPEN c_trx_prev_ret(cp_book_type_code => g_book_type_code,
570: CLOSE c_trx_prev_ret;
571:
572: -- calculate the number of periods that have elapsed between the transaction
573: -- previous to the retirement and reinstatement of the asset
574: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstatement period counter: '|| p_period_counter);
575: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Retirement period cntr: '|| p_effective_retire_period_cnt);
576:
577: -- l_elapsed_periods := p_period_counter - l_prev_prd_cnt;
578: l_elapsed_periods := p_period_counter - p_effective_retire_period_cnt;
571:
572: -- calculate the number of periods that have elapsed between the transaction
573: -- previous to the retirement and reinstatement of the asset
574: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstatement period counter: '|| p_period_counter);
575: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Retirement period cntr: '|| p_effective_retire_period_cnt);
576:
577: -- l_elapsed_periods := p_period_counter - l_prev_prd_cnt;
578: l_elapsed_periods := p_period_counter - p_effective_retire_period_cnt;
579: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Elapsed periods: '|| l_elapsed_periods);
575: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Retirement period cntr: '|| p_effective_retire_period_cnt);
576:
577: -- l_elapsed_periods := p_period_counter - l_prev_prd_cnt;
578: l_elapsed_periods := p_period_counter - p_effective_retire_period_cnt;
579: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Elapsed periods: '|| l_elapsed_periods);
580:
581: -- find out NOCOPY if the asset has been fully reserved prior to retirement
582: OPEN c_fully_reserved(g_asset_id, g_book_type_code);
583: FETCH c_fully_reserved INTO l_fully_reserved;
585: CLOSE c_fully_reserved;
586: RETURN FALSE;
587: END IF;
588: CLOSE c_fully_reserved;
589: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Asset fully reserved period counter: '||l_fully_reserved);
590:
591: -- get all the previous balances to reinstate
592: FOR l_det_bal IN c_det_bal(l_prev_adj_id) LOOP
593:
610: -- If asset is fully reserved then catchup is 0
611: IF (l_fully_reserved > 0) THEN
612: l_rsv_catchup_amt := 0;
613: END IF;
614: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Depreciation expense: '||l_det_bal.deprn_period);
615: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Depreciation reserve: '||l_rsv_catchup_amt);
616: -- get the link between the reinstated distribution_ids to the
617: -- retired distribution id
618: l_ren_dist_id := Get_Corr_Ren_Dist_Id(
611: IF (l_fully_reserved > 0) THEN
612: l_rsv_catchup_amt := 0;
613: END IF;
614: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Depreciation expense: '||l_det_bal.deprn_period);
615: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Depreciation reserve: '||l_rsv_catchup_amt);
616: -- get the link between the reinstated distribution_ids to the
617: -- retired distribution id
618: l_ren_dist_id := Get_Corr_Ren_Dist_Id(
619: p_trxhdr_id_reinstate,
622:
623: IF (l_ren_dist_id = 0) THEN
624: RAISE e_no_corr_reinstatement;
625: END IF;
626: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstatement dist id: '||l_ren_dist_id);
627:
628:
629: -- from this the units_assigned can be obtained from fa_distribution_history
630: SELECT units_assigned
663: -- get the deprn values from igi_iac_fa_deprn or fa_deprn_detail
664: OPEN c_get_fa_deprn(l_prev_adj_id, l_det_bal.distribution_id);
665: FETCH c_get_fa_deprn INTO l_fa_deprn_period, l_fa_deprn_ytd, l_fa_deprn_reserve;
666: IF c_get_fa_deprn%NOTFOUND THEN
667: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Record not found in igi_iac_fa_deprn');
668: OPEN c_get_fa_det(g_book_type_code,
669: g_asset_id,
670: l_det_bal.distribution_id,
671: l_det_bal.period_counter);
680: l_fa_deprn_ytd := 0;
681: END IF;
682: CLOSE c_get_fa_ytd;
683: ELSE
684: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Record found in igi_iac_fa_deprn');
685: IF l_fully_reserved > 0 THEN
686: l_fa_deprn_period := 0;
687: END IF;
688: IF (p_transaction_run = 'SECOND') THEN
691: END IF;
692: END IF;
693: CLOSE c_get_fa_deprn;
694:
695: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'FA Depreciation amount: '||l_fa_deprn_period);
696: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn rsv: '||l_fa_deprn_reserve);
697: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn YTD: '||l_fa_deprn_ytd);
698: -- bug 2480915 end(5) modified for bug 2906034
699:
692: END IF;
693: CLOSE c_get_fa_deprn;
694:
695: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'FA Depreciation amount: '||l_fa_deprn_period);
696: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn rsv: '||l_fa_deprn_reserve);
697: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn YTD: '||l_fa_deprn_ytd);
698: -- bug 2480915 end(5) modified for bug 2906034
699:
700: -- keep a running total of the different account amounts after they have
693: CLOSE c_get_fa_deprn;
694:
695: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'FA Depreciation amount: '||l_fa_deprn_period);
696: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn rsv: '||l_fa_deprn_reserve);
697: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn YTD: '||l_fa_deprn_ytd);
698: -- bug 2480915 end(5) modified for bug 2906034
699:
700: -- keep a running total of the different account amounts after they have
701: -- been prorated
799: x_distribution_id => l_ren_dist_id,
800: x_period_counter => p_period_counter,
801: x_mode => 'R',
802: x_event_id => p_event_id );
803: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Done Expense: '||l_rsv_catchup_amt);
804: -- insert RESERVE journal into igi_iac_adjustments with the reserve catchup amount
805: -- get the ccid for the account type
806: IF NOT igi_iac_common_utils.get_account_ccid(g_book_type_code,
807: g_asset_id,
833: x_distribution_id => l_ren_dist_id,
834: x_period_counter => p_period_counter,
835: x_mode => 'R',
836: x_event_id => p_event_id );
837: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Done Deprn Reserve: '||l_rsv_catchup_amt);
838: -- insert GENERAL FUND journal into igi_iac_adjustments with the catchup amount
839: -- only if adjustment amount is greater than zero
840: IF (l_det_bal.adjustment_cost > 0) THEN
841: -- get the ccid for the account type Reval Reserve
909: );
910: END IF; -- adjustment cost > 0
911: END IF; -- elapsed periods > 0
912: END IF; -- second transaction
913: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'End for distribution: '||l_det_bal.distribution_id);
914: END LOOP;
915:
916: -- bring the YTD rows associated to the retirement over with the
917: -- reinstatement adjustment id and current period counter
917: -- reinstatement adjustment id and current period counter
918: FOR l_get_ytd IN c_get_ytd(cp_adjustment_id => l_prev_adj_id,
919: cp_asset_id => g_asset_id,
920: cp_book_type_code => g_book_type_code) LOOP
921: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'In YTD: dist id: '||l_get_ytd.distribution_id);
922:
923: IF nvl(l_get_ytd.active_flag,'Y') = 'Y' THEN
924: l_get_ytd.adjustment_cost := 0;
925: l_get_ytd.net_book_value := 0;
973: -- Bug 2480915, start(7) Modified for 2906034
974: OPEN c_get_fa_deprn(l_get_ytd.adjustment_id, l_get_ytd.distribution_id);
975: FETCH c_get_fa_deprn INTO l_fa_deprn_period, l_fa_deprn_ytd, l_fa_deprn_reserve;
976: IF c_get_fa_deprn%NOTFOUND THEN
977: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Record not found in igi_iac_fa_deprn');
978: OPEN c_get_fa_ytd(g_book_type_code,
979: g_asset_id,
980: l_get_ytd.distribution_id);
981: FETCH c_get_fa_ytd INTO l_fa_deprn_ytd;
984: END IF;
985: CLOSE c_get_fa_ytd;
986: END IF;
987: CLOSE c_get_fa_deprn;
988: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'In YTD: YTD deprn: '||l_fa_deprn_ytd);
989:
990: IF nvl(l_get_ytd.active_flag,'Y') = 'Y' THEN
991: l_fa_deprn_ytd := 0;
992: END IF;
1026: CLOSE c_ret_ass_bal;
1027: RETURN FALSE;
1028: END IF;
1029: CLOSE c_ret_ass_bal;
1030: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Retrieved the asset balance');
1031:
1032: -- update the existing asset balances record
1033: l_ab_net_book_value := l_tot_net_book_value;
1034: l_ab_adjusted_cost := l_tot_adjustment_cost;
1038: l_ab_deprn_reserve := l_tot_deprn_reserve;
1039: l_ab_backlog_deprn_reserve := l_tot_deprn_reserve_backlog;
1040: l_ab_general_fund := l_tot_general_fund_acc;
1041:
1042: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'NBV: '||l_ab_net_book_value);
1043: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
1044: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
1045: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1046: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1039: l_ab_backlog_deprn_reserve := l_tot_deprn_reserve_backlog;
1040: l_ab_general_fund := l_tot_general_fund_acc;
1041:
1042: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'NBV: '||l_ab_net_book_value);
1043: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
1044: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
1045: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1046: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1047: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
1040: l_ab_general_fund := l_tot_general_fund_acc;
1041:
1042: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'NBV: '||l_ab_net_book_value);
1043: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
1044: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
1045: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1046: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1047: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
1048: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
1041:
1042: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'NBV: '||l_ab_net_book_value);
1043: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
1044: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
1045: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1046: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1047: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
1048: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
1049: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
1042: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'NBV: '||l_ab_net_book_value);
1043: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
1044: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
1045: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1046: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1047: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
1048: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
1049: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
1050:
1043: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
1044: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
1045: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1046: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1047: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
1048: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
1049: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
1050:
1051: IF (l_exists > 0) THEN
1044: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
1045: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1046: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1047: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
1048: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
1049: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
1050:
1051: IF (l_exists > 0) THEN
1052: -- update the existing asset balances record
1045: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1046: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1047: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
1048: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
1049: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
1050:
1051: IF (l_exists > 0) THEN
1052: -- update the existing asset balances record
1053: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Updating asset balances');
1049: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
1050:
1051: IF (l_exists > 0) THEN
1052: -- update the existing asset balances record
1053: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Updating asset balances');
1054: IGI_IAC_ASSET_BALANCES_PKG.Update_Row(
1055: X_asset_id => g_asset_id,
1056: X_book_type_code => g_book_type_code,
1057: X_period_counter => p_period_counter,
1070:
1071: ELSE
1072: -- insert a new record for the reinstatement period by bringing forward the record previous to the
1073: -- retired with catchup values adjusted for account type RESERVE and GENERAL FUND
1074: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Inserting into asset balances');
1075: IGI_IAC_ASSET_BALANCES_PKG.Insert_Row(
1076: X_rowid => l_rowid,
1077: X_asset_id => g_asset_id,
1078: X_book_type_code => g_book_type_code,
1089: X_current_reval_factor => l_ret_ass_bal.current_reval_factor,
1090: X_cumulative_reval_factor => l_ret_ass_bal.cumulative_reval_factor
1091: ) ;
1092: END IF;
1093: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Finished reinstating asset balances fully');
1094: RETURN TRUE;
1095: EXCEPTION
1096: WHEN e_no_corr_reinstatement THEN
1097: IF c_get_ytd%ISOPEN THEN
1097: IF c_get_ytd%ISOPEN THEN
1098: CLOSE c_get_ytd;
1099: END IF;
1100: g_message := 'No corresponding reinstatement found for the retirement distribution';
1101: igi_iac_debug_pkg.debug_other_string(g_error_level,l_path,g_message);
1102: FA_SRVR_MSG.add_message(
1103: Calling_Fn => g_calling_fn,
1104: Name => 'IGI_IAC_NO_CORR_REIN_DIST_ID'
1105: );
1109: IF c_get_ytd%ISOPEN THEN
1110: CLOSE c_get_ytd;
1111: END IF;
1112:
1113: igi_iac_debug_pkg.debug_other_string(g_error_level,l_path,g_message);
1114: FA_SRVR_MSG.add_message(
1115: Calling_Fn => g_calling_fn,
1116: Name => 'IGI_IAC_WF_FAILED_CCID'
1117: );
1121: IF c_get_ytd%ISOPEN THEN
1122: CLOSE c_get_ytd;
1123: END IF;
1124: g_message := 'Error:'||SQLERRM;
1125: igi_iac_debug_pkg.debug_unexpected_msg(l_path);
1126: g_calling_fn1 := g_calling_fn||' : Full';
1127: FA_SRVR_MSG.add_sql_error(
1128: Calling_Fn => g_calling_fn1
1129: );
1240: e_no_cost_prorate EXCEPTION;
1241: BEGIN
1242: l_path := g_path||'Cost_Reinstatement';
1243:
1244: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'In reinstatement cost');
1245: -- get the adjustment id and period counter for the transaction previous to retirement
1246: -- OPEN c_trx_prev_ret(p_trxhdr_id_retire);
1247: OPEN c_trx_prev_ret(cp_book_type_code => g_book_type_code,
1248: cp_asset_id => g_asset_id,
1252: CLOSE c_trx_prev_ret;
1253: RETURN FALSE;
1254: END IF;
1255: CLOSE c_trx_prev_ret;
1256: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjustment id previous to retirement: '||l_prev_adj_id);
1257:
1258: -- get the cost retirement factor
1259: IF NOT igi_iac_common_utils.get_cost_retirement_factor(g_book_type_code,
1260: g_asset_id,
1265: END IF;
1266: -- calculate the reinstatement prorate factor from the retirement
1267: -- prorate factor
1268: --l_prorate_factor := 1/(1 - l_prorate_factor);
1269: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Cost prorate factor: '||l_prorate_factor);
1270:
1271: -- calculate the number of periods that have elapsed between the transaction
1272: -- previous to the retirement and reinstatement of the asset
1273: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstatement period counter: '|| p_period_counter);
1269: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Cost prorate factor: '||l_prorate_factor);
1270:
1271: -- calculate the number of periods that have elapsed between the transaction
1272: -- previous to the retirement and reinstatement of the asset
1273: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstatement period counter: '|| p_period_counter);
1274: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Retirement period cntr: '|| p_effective_retire_period_cnt);
1275: -- l_elapsed_periods := p_period_counter - l_prev_prd_cnt;
1276: l_elapsed_periods := p_period_counter - p_effective_retire_period_cnt;
1277: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Elapsed periods: '|| l_elapsed_periods);
1270:
1271: -- calculate the number of periods that have elapsed between the transaction
1272: -- previous to the retirement and reinstatement of the asset
1273: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstatement period counter: '|| p_period_counter);
1274: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Retirement period cntr: '|| p_effective_retire_period_cnt);
1275: -- l_elapsed_periods := p_period_counter - l_prev_prd_cnt;
1276: l_elapsed_periods := p_period_counter - p_effective_retire_period_cnt;
1277: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Elapsed periods: '|| l_elapsed_periods);
1278:
1273: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstatement period counter: '|| p_period_counter);
1274: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Retirement period cntr: '|| p_effective_retire_period_cnt);
1275: -- l_elapsed_periods := p_period_counter - l_prev_prd_cnt;
1276: l_elapsed_periods := p_period_counter - p_effective_retire_period_cnt;
1277: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Elapsed periods: '|| l_elapsed_periods);
1278:
1279: -- find out NOCOPY if the asset has been fully reserved prior to retirement
1280: OPEN c_fully_reserved(g_asset_id, g_book_type_code);
1281: FETCH c_fully_reserved INTO l_fully_reserved;
1283: CLOSE c_fully_reserved;
1284: RETURN FALSE;
1285: END IF;
1286: CLOSE c_fully_reserved;
1287: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Asset fully reserved period counter: '||l_fully_reserved);
1288:
1289: -- get all the previous balances to reinstate
1290: FOR l_det_bal IN c_det_bal(l_prev_adj_id) LOOP
1291: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'getting all previous row for reinstatement');
1287: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Asset fully reserved period counter: '||l_fully_reserved);
1288:
1289: -- get all the previous balances to reinstate
1290: FOR l_det_bal IN c_det_bal(l_prev_adj_id) LOOP
1291: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'getting all previous row for reinstatement');
1292: -- calculate catchup amount if second transaction
1293: -- initialise to zero for each distribution_id
1294: l_rsv_catchup_amt := 0;
1295: l_gf_catchup_amt := 0;
1323: -- If asset is fully reserved then catchup is 0
1324: IF (l_fully_reserved > 0) THEN
1325: l_rsv_catchup_amt := 0;
1326: END IF;
1327: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstated Depreciation expense: '||l_det_bal.deprn_period);
1328: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Depreciation reserve catchup amount: '||l_rsv_catchup_amt);
1329:
1330: -- get account values
1331: -- add the catchup amounts as well
1324: IF (l_fully_reserved > 0) THEN
1325: l_rsv_catchup_amt := 0;
1326: END IF;
1327: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstated Depreciation expense: '||l_det_bal.deprn_period);
1328: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Depreciation reserve catchup amount: '||l_rsv_catchup_amt);
1329:
1330: -- get account values
1331: -- add the catchup amounts as well
1332: l_adjustment_cost := l_det_bal.adjustment_cost;
1358: -- bug 2480915 start(12) Modified for Bug 2906034
1359: OPEN c_get_fa_deprn(l_prev_adj_id, l_det_bal.distribution_id);
1360: FETCH c_get_fa_deprn INTO l_fa_deprn_period, l_fa_deprn_ytd, l_fa_deprn_reserve;
1361: IF c_get_fa_deprn%NOTFOUND THEN
1362: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Record not found in igi_iac_fa_deprn');
1363: OPEN c_get_fa_det(g_book_type_code,
1364: g_asset_id,
1365: l_det_bal.distribution_id,
1366: l_det_bal.period_counter);
1375: l_fa_deprn_ytd := 0;
1376: END IF;
1377: CLOSE c_get_fa_ytd;
1378: ELSE
1379: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Record found in igi_iac_fa_deprn');
1380: IF l_fully_reserved > 0 THEN
1381: l_fa_deprn_period := 0;
1382: END IF;
1383: IF (p_transaction_run = 'SECOND') THEN
1386: END IF;
1387: END IF;
1388: CLOSE c_get_fa_deprn;
1389:
1390: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'FA Depreciation amount: '||l_fa_deprn_period);
1391: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn rsv: '||l_fa_deprn_reserve);
1392: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn YTD: '||l_fa_deprn_ytd);
1393: -- bug 2480915 end(12) Modified for Bug 2906034
1394:
1387: END IF;
1388: CLOSE c_get_fa_deprn;
1389:
1390: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'FA Depreciation amount: '||l_fa_deprn_period);
1391: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn rsv: '||l_fa_deprn_reserve);
1392: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn YTD: '||l_fa_deprn_ytd);
1393: -- bug 2480915 end(12) Modified for Bug 2906034
1394:
1395: -- keep a running total of the different account amounts after they have
1388: CLOSE c_get_fa_deprn;
1389:
1390: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'FA Depreciation amount: '||l_fa_deprn_period);
1391: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn rsv: '||l_fa_deprn_reserve);
1392: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn YTD: '||l_fa_deprn_ytd);
1393: -- bug 2480915 end(12) Modified for Bug 2906034
1394:
1395: -- keep a running total of the different account amounts after they have
1396: -- been prorated
1441: x_active_flag => null,
1442: x_mode => 'R'
1443: );
1444:
1445: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Inserted into det balances dist id '||l_det_bal.distribution_id);
1446: -- Bug 2480915, start(13)
1447: -- insert into igi_iac_fa_deprn with the reinstatement adjustment_id
1448: IGI_IAC_FA_DEPRN_PKG.Insert_Row(
1449: x_rowid => l_rowid,
1465: SELECT units_assigned
1466: INTO l_units_assigned
1467: FROM fa_distribution_history
1468: WHERE distribution_id = l_det_bal.distribution_id;
1469: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Units assigned to distribution '||l_units_assigned);
1470:
1471: -- create the catchup journals only if the catchup amounts are greater than zero,
1472: -- which will be only if the number of elapsed periods is greater than zero
1473: IF (l_elapsed_periods > 0) THEN
1515: x_period_counter => p_period_counter,
1516: x_mode => 'R',
1517: x_event_id => p_event_id
1518: );
1519: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Done Expense: '||l_rsv_catchup);
1520:
1521: -- insert RESERVE journal into igi_iac_adjustments with the reserve catchup amount
1522: -- calculate the catchup amount
1523: --l_de_catchup := l_deprn_reserve - l_latest_dep_rsv;
1554: x_period_counter => p_period_counter,
1555: x_mode => 'R',
1556: x_event_id => p_event_id
1557: );
1558: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Done Reserve: '|| l_rsv_catchup);
1559:
1560: -- insert GENERAL FUND a REVAL RESERVE journal into igi_iac_adjustments with the catchup amount
1561: -- only if adjustment amount is greater than zero
1562: IF (l_det_bal.adjustment_cost > 0) THEN
1595: x_period_counter => p_period_counter,
1596: x_mode => 'R',
1597: x_event_id => p_event_id
1598: );
1599: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Done Reval Reserve: '||l_rsv_catchup);
1600:
1601: -- get the ccid for the account type General Fund
1602: IF NOT igi_iac_common_utils.get_account_ccid(g_book_type_code,
1603: g_asset_id,
1630: x_period_counter => p_period_counter,
1631: x_mode => 'R',
1632: x_event_id => p_event_id
1633: );
1634: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Done General Fund: '||l_rsv_catchup);
1635:
1636: END IF; -- adjustment cost > 0
1637: END IF; -- elapsed periods > 0
1638: END IF; -- second transaction
1642: -- reinstatement adjustment id and current period counter
1643: FOR l_get_ytd IN c_get_ytd(cp_adjustment_id => l_prev_adj_id,
1644: cp_asset_id => g_asset_id,
1645: cp_book_type_code => g_book_type_code) LOOP
1646: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'In YTD: dist id: '||l_get_ytd.distribution_id);
1647: -- insert into igi_iac_det_balances with reinstatement adjustment_id
1648: IGI_IAC_DET_BALANCES_PKG.Insert_Row(
1649: x_rowid => l_rowid,
1650: x_adjustment_id => p_adjust_id_reinstate,
1677: -- Bug 2480915, start(14)
1678: OPEN c_get_fa_deprn(l_get_ytd.adjustment_id, l_get_ytd.distribution_id);
1679: FETCH c_get_fa_deprn INTO l_fa_deprn_period, l_fa_deprn_ytd, l_fa_deprn_reserve;
1680: IF c_get_fa_deprn%NOTFOUND THEN
1681: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Record not found in igi_iac_fa_deprn');
1682: OPEN c_get_fa_ytd(g_book_type_code,
1683: g_asset_id,
1684: l_get_ytd.distribution_id);
1685: FETCH c_get_fa_ytd INTO l_fa_deprn_ytd;
1688: END IF;
1689: CLOSE c_get_fa_ytd;
1690: END IF;
1691: CLOSE c_get_fa_deprn;
1692: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'In YTD: YTD deprn: '||l_fa_deprn_ytd);
1693:
1694: -- insert into igi_iac_fa_deprn with the reinstatement adjustment_id
1695: IGI_IAC_FA_DEPRN_PKG.Insert_Row(
1696: x_rowid => l_rowid,
1706: x_mode => 'R'
1707: );
1708: -- Bug 2480915, end(14)
1709: END LOOP;
1710: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Get the asset balance for the period counter: '||p_effective_retire_period_cnt);
1711: -- update the asset balances table for the asset to reflect the full reinstatement
1712: -- fetch asset balances for the period prior to retirement
1713:
1714: -- if a row exists for the asset for the current period else create a new row
1729: CLOSE c_ret_ass_bal;
1730: RETURN FALSE;
1731: END IF;
1732: CLOSE c_ret_ass_bal;
1733: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Retrieved the asset balance');
1734:
1735: -- update the existing asset balances record
1736: l_ab_net_book_value := l_tot_net_book_value;
1737: l_ab_adjusted_cost := l_tot_adjustment_cost;
1741: l_ab_deprn_reserve := l_tot_deprn_reserve;
1742: l_ab_backlog_deprn_reserve := l_tot_deprn_reserve_backlog;
1743: l_ab_general_fund := l_tot_general_fund_acc;
1744:
1745: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'NBV: '||l_ab_net_book_value);
1746: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
1747: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
1748: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1749: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1742: l_ab_backlog_deprn_reserve := l_tot_deprn_reserve_backlog;
1743: l_ab_general_fund := l_tot_general_fund_acc;
1744:
1745: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'NBV: '||l_ab_net_book_value);
1746: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
1747: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
1748: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1749: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1750: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
1743: l_ab_general_fund := l_tot_general_fund_acc;
1744:
1745: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'NBV: '||l_ab_net_book_value);
1746: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
1747: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
1748: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1749: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1750: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
1751: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
1744:
1745: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'NBV: '||l_ab_net_book_value);
1746: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
1747: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
1748: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1749: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1750: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
1751: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
1752: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
1745: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'NBV: '||l_ab_net_book_value);
1746: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
1747: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
1748: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1749: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1750: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
1751: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
1752: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
1753:
1746: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
1747: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
1748: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1749: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1750: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
1751: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
1752: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
1753:
1754: IF (l_exists > 0) THEN
1747: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
1748: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1749: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1750: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
1751: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
1752: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
1753:
1754: IF (l_exists > 0) THEN
1755: -- update the asset balances to reflect the reinstatement
1748: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
1749: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
1750: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
1751: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
1752: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
1753:
1754: IF (l_exists > 0) THEN
1755: -- update the asset balances to reflect the reinstatement
1756: IGI_IAC_ASSET_BALANCES_PKG.Update_Row(
1789: X_current_reval_factor => l_ret_ass_bal.current_reval_factor,
1790: X_cumulative_reval_factor => l_ret_ass_bal.cumulative_reval_factor
1791: ) ;
1792: END IF;
1793: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'finish asset balance updates');
1794:
1795: RETURN TRUE;
1796: EXCEPTION
1797: WHEN e_no_cost_prorate THEN
1795: RETURN TRUE;
1796: EXCEPTION
1797: WHEN e_no_cost_prorate THEN
1798: g_message := 'Could not get a cost prorate factor';
1799: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,g_message);
1800: FA_SRVR_MSG.add_message(
1801: Calling_Fn => g_calling_fn,
1802: Name => 'IGI_IAC_NO_REINS_PRORATE'
1803: );
1807: IF c_get_ytd%ISOPEN THEN
1808: CLOSE c_get_ytd;
1809: END IF;
1810:
1811: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,g_message);
1812: FA_SRVR_MSG.add_message(
1813: Calling_Fn => g_calling_fn,
1814: Name => 'IGI_IAC_WF_FAILED_CCID'
1815: );
1819: IF c_get_ytd%ISOPEN THEN
1820: CLOSE c_get_ytd;
1821: END IF;
1822: g_message := 'Error:'||SQLERRM;
1823: igi_iac_debug_pkg.debug_unexpected_msg(l_path);
1824:
1825: g_calling_fn1 := g_calling_fn||' : Cost';
1826: FA_SRVR_MSG.add_sql_error(
1827: Calling_Fn => g_calling_fn1
2021: e_no_unit_prorate EXCEPTION;
2022:
2023: BEGIN
2024: l_path := g_path||'Unit_Reinstatement';
2025: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'In Unit Reinstatement function');
2026:
2027: -- get the adjustment_id of the transaction previous to the
2028: -- retirement, for distributions that will need to be fully reinstated
2029: -- OPEN c_trx_prev_ret(p_trxhdr_id_retire);
2035: CLOSE c_trx_prev_ret;
2036: RETURN FALSE;
2037: END IF;
2038: CLOSE c_trx_prev_ret;
2039: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjustment Id previous to retirement:'|| l_prev_adj_id);
2040:
2041: -- count the elapsed periods
2042: --l_elapsed_periods := p_period_counter - l_prev_prd_cnt;
2043: l_elapsed_periods := p_period_counter - p_effective_retire_period_cnt;
2040:
2041: -- count the elapsed periods
2042: --l_elapsed_periods := p_period_counter - l_prev_prd_cnt;
2043: l_elapsed_periods := p_period_counter - p_effective_retire_period_cnt;
2044: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Elapsed periods: '||l_elapsed_periods);
2045:
2046: -- find out NOCOPY if the asset has been fully reserved prior to retirement
2047: OPEN c_fully_reserved(g_asset_id, g_book_type_code);
2048: FETCH c_fully_reserved INTO l_fully_reserved;
2050: CLOSE c_fully_reserved;
2051: RETURN FALSE;
2052: END IF;
2053: CLOSE c_fully_reserved;
2054: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Asset fully reserved period counter: '||l_fully_reserved);
2055:
2056: -- get the active distributions for the transaction
2057: -- from igi_iac_det_balances previous to the retirement
2058: FOR l_det_bal IN c_det_bal(l_prev_adj_id) LOOP
2064: INTO l_retire_effect
2065: FROM fa_distribution_history
2066: WHERE distribution_id = l_det_bal.distribution_id
2067: AND retirement_id = g_retirement_id;
2068: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Retirement effect: '||l_retire_effect);
2069:
2070: -- get the reinstatement distribution id associated to the retired
2071: -- distribution id
2072: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Retirement distribution id: '||l_det_bal.distribution_id);
2068: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Retirement effect: '||l_retire_effect);
2069:
2070: -- get the reinstatement distribution id associated to the retired
2071: -- distribution id
2072: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Retirement distribution id: '||l_det_bal.distribution_id);
2073: IF (l_retire_effect > 0) THEN
2074: l_ren_dist_id := Get_Corr_Ren_Dist_Id(
2075: p_trxhdr_id_reinstate,
2076: l_det_bal.distribution_id -- retirement distribution id
2081: END IF;
2082: ELSE
2083: l_ren_dist_id := l_det_bal.distribution_id;
2084: END IF;
2085: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstate distribution id: '||l_ren_dist_id);
2086:
2087: -- calculate GF catchup for first transaction
2088: l_gf_catchup_amt := 0;
2089: IF (l_fully_reserved <= 0) THEN
2134: -- bug 2480915 start(19) Modified for bug 2906034
2135: OPEN c_get_fa_deprn(l_prev_adj_id, l_det_bal.distribution_id);
2136: FETCH c_get_fa_deprn INTO l_fa_deprn_period, l_fa_deprn_ytd, l_fa_deprn_reserve;
2137: IF c_get_fa_deprn%NOTFOUND THEN
2138: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Record not found in igi_iac_fa_deprn');
2139: OPEN c_get_fa_det(g_book_type_code,
2140: g_asset_id,
2141: l_det_bal.distribution_id,
2142: l_det_bal.period_counter);
2151: l_fa_deprn_ytd := 0;
2152: END IF;
2153: CLOSE c_get_fa_ytd;
2154: ELSE
2155: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Record found in igi_iac_fa_deprn');
2156: IF l_fully_reserved > 0 THEN
2157: l_fa_deprn_period := 0;
2158: END IF;
2159: IF (p_transaction_run = 'SECOND') THEN
2162: END IF;
2163: END IF;
2164: CLOSE c_get_fa_deprn;
2165:
2166: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'FA Depreciation amount: '||l_fa_deprn_period);
2167: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn rsv: '||l_fa_deprn_reserve);
2168: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn YTD: '||l_fa_deprn_ytd);
2169: -- bug 2480915 end(19) Modified for bug 2906034
2170:
2163: END IF;
2164: CLOSE c_get_fa_deprn;
2165:
2166: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'FA Depreciation amount: '||l_fa_deprn_period);
2167: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn rsv: '||l_fa_deprn_reserve);
2168: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn YTD: '||l_fa_deprn_ytd);
2169: -- bug 2480915 end(19) Modified for bug 2906034
2170:
2171: -- keep a sum total for all the amounts
2164: CLOSE c_get_fa_deprn;
2165:
2166: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'FA Depreciation amount: '||l_fa_deprn_period);
2167: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn rsv: '||l_fa_deprn_reserve);
2168: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Detail level FA deprn YTD: '||l_fa_deprn_ytd);
2169: -- bug 2480915 end(19) Modified for bug 2906034
2170:
2171: -- keep a sum total for all the amounts
2172: l_tot_adjustment_cost := l_tot_adjustment_cost + l_adjustment_cost;
2285: x_period_counter => p_period_counter,
2286: x_mode => 'R',
2287: x_event_id => p_event_id
2288: );
2289: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'FULL:Done Expense: '||l_rsv_catchup_amt);
2290: -- insert RESERVE journal into igi_iac_adjustments with the reserve catchup amount
2291: -- get the ccid for the account type
2292: IF NOT igi_iac_common_utils.get_account_ccid(g_book_type_code,
2293: g_asset_id,
2320: x_period_counter => p_period_counter,
2321: x_mode => 'R',
2322: x_event_id => p_event_id
2323: );
2324: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'FULL:Done Deprn Reserve: '||l_rsv_catchup_amt);
2325: -- insert GENERAL FUND journal into igi_iac_adjustments with the catchup amount
2326: -- only if adjustment amount is greater than zero
2327: IF (l_det_bal.adjustment_cost > 0) THEN
2328: -- get the ccid for the account type Reval Reserve
2359: x_distribution_id => l_ren_dist_id,
2360: x_period_counter => p_period_counter,
2361: x_mode => 'R',
2362: x_event_id => p_event_id );
2363: -- igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'FULL:Done Reval Reserve: '||l_gf_catchup_amt);
2364:
2365: -- get the ccid for the account type
2366: IF NOT igi_iac_common_utils.get_account_ccid(g_book_type_code,
2367: g_asset_id,
2393: x_distribution_id => l_ren_dist_id,
2394: x_period_counter => p_period_counter,
2395: x_mode => 'R',
2396: x_event_id => p_event_id );
2397: -- igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'FULL:Done General Fund: '||l_gf_catchup_amt);
2398: END IF; -- adjustment cost > 0
2399: END IF; -- second transaction
2400: ELSE
2401: -- this is a partial retirement
2410: AND NVL(old.assigned_to,-99) = NVL(new.assigned_to,-99)
2411: AND old.transaction_header_id_out = new.transaction_header_id_in
2412: AND old.distribution_id = l_det_bal.distribution_id ;
2413:
2414: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Latest adjustment id: '||p_latest_adjust_id||' dist id: '||l_ret_dist_id);
2415: -- bug 2485778, start 2
2416: -- the retirement distribution needs to be rolled forward as a YTD row
2417: -- for the reinstatement transaction
2418: OPEN c_ret_ytd(l_ret_dist_id);
2453: x_active_flag => 'N',
2454: x_mode => 'R'
2455: );
2456:
2457: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Inserted YTD for partially retired distribution: '||l_ret_dist_id);
2458: -- bug 2485778, end 2
2459:
2460: -- Bug 2480915, start(21) Modified for 2906034
2461: -- insert into igi_iac_fa_deprn with the reinstatement adjustment_id
2461: -- insert into igi_iac_fa_deprn with the reinstatement adjustment_id
2462: OPEN c_get_fa_deprn(l_ret_ytd.adjustment_id, l_ret_ytd.distribution_id);
2463: FETCH c_get_fa_deprn INTO l_fa_deprn_period, l_fa_deprn_ytd, l_fa_deprn_reserve;
2464: IF c_get_fa_deprn%NOTFOUND THEN
2465: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Record not found in igi_iac_fa_deprn');
2466: OPEN c_get_fa_ytd(g_book_type_code,
2467: g_asset_id,
2468: l_ret_ytd.distribution_id);
2469: FETCH c_get_fa_ytd INTO l_fa_deprn_ytd;
2473: CLOSE c_get_fa_ytd;
2474: END IF;
2475: CLOSE c_get_fa_deprn;
2476:
2477: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'In YTD: YTD deprn: '||l_fa_deprn_ytd);
2478: IGI_IAC_FA_DEPRN_PKG.Insert_Row(
2479: x_rowid => l_rowid,
2480: x_book_type_code => g_book_type_code,
2481: x_asset_id => g_asset_id,
2533: x_distribution_id => l_ren_dist_id,
2534: x_period_counter => p_period_counter,
2535: x_mode => 'R',
2536: x_event_id => p_event_id );
2537: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'PARTIAL:Done Expense: '||l_rsv_catchup);
2538: -- insert RESERVE journal into igi_iac_adjustments with the reserve catchup amount
2539: -- get the ccid for the account type
2540: IF NOT igi_iac_common_utils.get_account_ccid(g_book_type_code,
2541: g_asset_id,
2567: x_distribution_id => l_ren_dist_id,
2568: x_period_counter => p_period_counter,
2569: x_mode => 'R',
2570: x_event_id => p_event_id );
2571: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'PARTIAL:Done Dep Reserve: '||l_rsv_catchup);
2572: -- insert GENERAL FUND journal into igi_iac_adjustments with the catchup amount
2573: -- only if adjustment amount is greater than zero
2574: IF (l_det_bal.adjustment_cost > 0) THEN
2575: -- get the ccid for the account type Revaluaion Reserve
2606: x_distribution_id => l_ren_dist_id,
2607: x_period_counter => p_period_counter,
2608: x_mode => 'R',
2609: x_event_id => p_event_id );
2610: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'PARTIAL:Done Reval Reserve: '||l_rsv_catchup);
2611:
2612: -- get the ccid for the account type General Fund
2613: IF NOT igi_iac_common_utils.get_account_ccid(g_book_type_code,
2614: g_asset_id,
2641: x_distribution_id => l_ren_dist_id,
2642: x_period_counter => p_period_counter,
2643: x_mode => 'R',
2644: x_event_id => p_event_id );
2645: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'PARTIAL:Done General Fund: '||l_de_catchup);
2646: END IF; -- adjustment cost > 0
2647: END IF; -- second transaction
2648: END IF; -- partial or full retirement
2649: END IF; -- distribution has retirement effect
2654: -- reinstatement adjustment id and current period counter
2655: FOR l_get_ytd IN c_get_ytd(cp_adjustment_id => l_prev_adj_id,
2656: cp_asset_id => g_asset_id,
2657: cp_book_type_code => g_book_type_code) LOOP
2658: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'In YTD: dist id: '||l_get_ytd.distribution_id);
2659:
2660: IF nvl(l_get_ytd.active_flag,'Y') = 'Y' THEN
2661: -- Set all except deprn_ytd to zeroes
2662: l_get_ytd.adjustment_cost := 0;
2711: -- Bug 2480915, start(22)
2712: OPEN c_get_fa_deprn(l_get_ytd.adjustment_id, l_get_ytd.distribution_id);
2713: FETCH c_get_fa_deprn INTO l_fa_deprn_period, l_fa_deprn_ytd, l_fa_deprn_reserve;
2714: IF c_get_fa_deprn%NOTFOUND THEN
2715: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Record not found in igi_iac_fa_deprn');
2716: OPEN c_get_fa_ytd(g_book_type_code,
2717: g_asset_id,
2718: l_get_ytd.distribution_id);
2719: FETCH c_get_fa_ytd INTO l_fa_deprn_ytd;
2723: CLOSE c_get_fa_ytd;
2724: END IF;
2725: CLOSE c_get_fa_deprn;
2726:
2727: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'In YTD: YTD deprn: '||l_fa_deprn_ytd);
2728: IF nvl(l_get_ytd.active_flag,'Y') = 'Y' THEN
2729: l_fa_deprn_ytd := 0;
2730: END IF;
2731: -- insert into igi_iac_fa_deprn with the reinstatement adjustment_id
2774: l_ab_deprn_reserve := l_tot_deprn_reserve;
2775: l_ab_backlog_deprn_reserve := l_tot_deprn_reserve_backlog;
2776: l_ab_general_fund := l_tot_general_fund_acc;
2777:
2778: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'NBV: '||l_ab_net_book_value);
2779: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
2780: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
2781: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
2782: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
2775: l_ab_backlog_deprn_reserve := l_tot_deprn_reserve_backlog;
2776: l_ab_general_fund := l_tot_general_fund_acc;
2777:
2778: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'NBV: '||l_ab_net_book_value);
2779: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
2780: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
2781: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
2782: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
2783: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
2776: l_ab_general_fund := l_tot_general_fund_acc;
2777:
2778: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'NBV: '||l_ab_net_book_value);
2779: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
2780: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
2781: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
2782: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
2783: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
2784: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
2777:
2778: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'NBV: '||l_ab_net_book_value);
2779: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
2780: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
2781: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
2782: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
2783: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
2784: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
2785: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
2778: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'NBV: '||l_ab_net_book_value);
2779: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
2780: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
2781: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
2782: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
2783: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
2784: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
2785: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
2786:
2779: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Adjusted Cost: '||l_ab_adjusted_cost);
2780: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
2781: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
2782: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
2783: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
2784: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
2785: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
2786:
2787: IF (l_exists > 0) THEN
2780: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Operating acct: '||l_ab_operating_acct);
2781: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
2782: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
2783: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
2784: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
2785: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
2786:
2787: IF (l_exists > 0) THEN
2788: IGI_IAC_ASSET_BALANCES_PKG.Update_Row(
2781: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reval Reserve: '||l_ab_reval_reserve);
2782: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Amount/Expense: '||l_ab_deprn_amount);
2783: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Deprn Reserve: '||l_ab_deprn_reserve);
2784: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Blog deprn reserve: '||l_ab_backlog_deprn_reserve);
2785: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Gen Fund: '||l_ab_general_fund);
2786:
2787: IF (l_exists > 0) THEN
2788: IGI_IAC_ASSET_BALANCES_PKG.Update_Row(
2789: X_asset_id => g_asset_id,
2828: IF c_dist_det_bal%ISOPEN THEN
2829: CLOSE c_dist_det_bal;
2830: END IF;
2831: g_message := 'No corresponding reinstatement found for the retirement distribution';
2832: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,g_message);
2833: FA_SRVR_MSG.add_message(
2834: Calling_Fn => g_calling_fn,
2835: Name => 'IGI_IAC_NO_CORR_REIN_DIST_ID'
2836: );
2840: IF c_dist_det_bal%ISOPEN THEN
2841: CLOSE c_dist_det_bal;
2842: END IF;
2843: g_message := 'Prorate factor for unit reinstatement not found';
2844: igi_iac_debug_pkg.debug_other_string(g_error_level,l_path,g_message);
2845: FA_SRVR_MSG.add_message(
2846: Calling_Fn => g_calling_fn,
2847: Name => 'IGI_IAC_NO_REINS_PRORATE'
2848: );
2851: WHEN e_no_ccid_found THEN
2852: IF c_dist_det_bal%ISOPEN THEN
2853: CLOSE c_dist_det_bal;
2854: END IF;
2855: igi_iac_debug_pkg.debug_other_string(g_error_level,l_path,g_message);
2856: FA_SRVR_MSG.add_message(
2857: Calling_Fn => g_calling_fn,
2858: Name => 'IGI_IAC_WF_FAILED_CCID'
2859: );
2863: IF c_dist_det_bal%ISOPEN THEN
2864: CLOSE c_dist_det_bal;
2865: END IF;
2866: g_message := 'Error:'||SQLERRM;
2867: igi_iac_debug_pkg.debug_unexpected_msg(l_path);
2868: g_calling_fn1 := g_calling_fn||' : Unit';
2869: FA_SRVR_MSG.add_sql_error(
2870: Calling_Fn => g_calling_fn1
2871: );
2961: x_revaluation_type_flag => null,
2962: x_adjustment_status => 'COMPLETE',
2963: x_period_counter => p_fa_reins_rec_info.curr_period_counter,
2964: x_event_id => p_event_id );
2965: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Inserted into headers table');
2966:
2967: -- update the previous active row for the asset in igi_iac_transaction_headers
2968: -- in order to make it inactive by setting adjustment_id_out= adjustment_id of
2969: -- the active row in igi_iac_transaction_headers
2972: x_adjustment_id => l_adjust_id_reinstate
2973: );
2974: g_adj_prior_ret := l_latest_adj_id;
2975:
2976: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Updated Headers table');
2977: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Latest adjustment id: '||l_latest_adj_id);
2978: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstatement adjustment id: '||l_adjust_id_reinstate);
2979:
2980: -- find all the journal entries for the retirement from igi_iac_adjustments
2973: );
2974: g_adj_prior_ret := l_latest_adj_id;
2975:
2976: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Updated Headers table');
2977: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Latest adjustment id: '||l_latest_adj_id);
2978: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstatement adjustment id: '||l_adjust_id_reinstate);
2979:
2980: -- find all the journal entries for the retirement from igi_iac_adjustments
2981: -- and create reverse journal entries for each of them for reinstatement
2974: g_adj_prior_ret := l_latest_adj_id;
2975:
2976: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Updated Headers table');
2977: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Latest adjustment id: '||l_latest_adj_id);
2978: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstatement adjustment id: '||l_adjust_id_reinstate);
2979:
2980: -- find all the journal entries for the retirement from igi_iac_adjustments
2981: -- and create reverse journal entries for each of them for reinstatement
2982: FOR l_reverse_je IN c_reverse_je(p_fa_ret_rec.detail_info.transaction_header_id_in) LOOP
3025: x_event_id => p_event_id
3026: );
3027:
3028: END LOOP;
3029: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Done reversing retirement journals');
3030:
3031: -- action accordingly based on retirement type
3032: IF (p_retirement_type = 'FULL') THEN
3033: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Calling Full Reinstatement');
3029: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Done reversing retirement journals');
3030:
3031: -- action accordingly based on retirement type
3032: IF (p_retirement_type = 'FULL') THEN
3033: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Calling Full Reinstatement');
3034: -- call procedure to do full reinstatement
3035: IF NOT Full_Reinstatement(l_adjust_id_reinstate,
3036: p_fa_ret_rec.detail_info.transaction_header_id_in, -- trx id of the retirement
3037: p_fa_ret_rec.detail_info.transaction_header_id_out, -- trx id for reinstatement
3045: g_message := 'Full reinstatement failure';
3046: RAISE e_reinstate_failed;
3047: END IF;
3048: ELSIF (p_retirement_type = 'COST') THEN
3049: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Calling Cost Reinstatement');
3050: -- call procedure to do partial cost reinstatement
3051: IF NOT Cost_Reinstatement(l_adjust_id_reinstate,
3052: l_latest_adj_id,
3053: p_fa_ret_rec.detail_info.transaction_header_id_in, -- trx id of the retirement
3064: g_message := 'Cost reinstatement failure';
3065: RAISE e_reinstate_failed;
3066: END IF;
3067: ELSIF (p_retirement_type = 'UNIT') THEN
3068: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Calling Unit Reinstatement');
3069: -- call procedure to do partial unit reinstatement
3070: IF NOT Unit_Reinstatement(l_adjust_id_reinstate,
3071: p_fa_ret_rec.detail_info.transaction_header_id_in, -- trx id of the retirement
3072: p_fa_ret_rec.detail_info.transaction_header_id_out, -- trx id for reinstatement
3092: IF c_reverse_je%ISOPEN THEN
3093: CLOSE c_reverse_je;
3094: END IF;
3095: g_message := 'Latest transaction could not be retrieved for the asset';
3096: igi_iac_debug_pkg.debug_other_string(g_error_level,l_path,g_message);
3097: FA_SRVR_MSG.add_message(
3098: Calling_Fn => g_calling_fn,
3099: Name => 'IGI_IAC_NO_LATEST_TRX'
3100: );
3105: IF c_reverse_je%ISOPEN THEN
3106: CLOSE c_reverse_je;
3107: END IF;
3108: g_message := 'Could not get corresponding reinstatement distribution id';
3109: igi_iac_debug_pkg.debug_other_string(g_error_level,l_path,g_message);
3110: FA_SRVR_MSG.add_message(
3111: Calling_Fn => g_calling_fn,
3112: Name => 'IGI_IAC_NO_CORR_REIN_DIST_ID'
3113: );
3117: -- close open cursors
3118: IF c_reverse_je%ISOPEN THEN
3119: CLOSE c_reverse_je;
3120: END IF;
3121: igi_iac_debug_pkg.debug_other_string(g_error_level,l_path,g_message);
3122: FA_SRVR_MSG.add_message(
3123: Calling_Fn => g_calling_fn,
3124: Name => 'IGI_IAC_REINSTATE_FAILED'
3125: );
3130: IF c_reverse_je%ISOPEN THEN
3131: CLOSE c_reverse_je;
3132: END IF;
3133: g_message := 'Error: '||SQLERRM;
3134: igi_iac_debug_pkg.debug_unexpected_msg(l_path);
3135: g_calling_fn1 := g_calling_fn||' : First_Transaction';
3136: FA_SRVR_MSG.add_sql_error(
3137: Calling_Fn => g_calling_fn1
3138: );
3201: x_adjustment_status => 'COMPLETE',
3202: x_period_counter => p_fa_reins_rec_info.curr_period_counter,
3203: x_event_id => p_event_id
3204: );
3205: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Inserted into headers table');
3206:
3207: -- update the previous active row for the asset in igi_iac_transaction_headers
3208: -- in order to make it inactive by setting adjustment_id_out= adjustment_id of
3209: -- the active row in igi_iac_transaction_headers
3210: IGI_IAC_TRANS_HEADERS_PKG.Update_Row(
3211: x_prev_adjustment_id => l_latest_adj_id,
3212: x_adjustment_id => l_adjust_id_reinstate
3213: );
3214: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Updated Headers table');
3215: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Latest adjustment id: '||l_latest_adj_id);
3216: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstatement adjustment id: '||l_adjust_id_reinstate);
3217:
3218: -- action accordingly based on retirement type
3211: x_prev_adjustment_id => l_latest_adj_id,
3212: x_adjustment_id => l_adjust_id_reinstate
3213: );
3214: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Updated Headers table');
3215: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Latest adjustment id: '||l_latest_adj_id);
3216: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstatement adjustment id: '||l_adjust_id_reinstate);
3217:
3218: -- action accordingly based on retirement type
3219: IF (p_retirement_type = 'FULL') THEN
3212: x_adjustment_id => l_adjust_id_reinstate
3213: );
3214: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Updated Headers table');
3215: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Latest adjustment id: '||l_latest_adj_id);
3216: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstatement adjustment id: '||l_adjust_id_reinstate);
3217:
3218: -- action accordingly based on retirement type
3219: IF (p_retirement_type = 'FULL') THEN
3220: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Calling Full Reinstatement');
3216: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Reinstatement adjustment id: '||l_adjust_id_reinstate);
3217:
3218: -- action accordingly based on retirement type
3219: IF (p_retirement_type = 'FULL') THEN
3220: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Calling Full Reinstatement');
3221: -- call procedure to do full reinstatement
3222: IF NOT Full_Reinstatement(l_adjust_id_reinstate,
3223: p_fa_ret_rec.detail_info.transaction_header_id_in, -- trx id of the retirement
3224: p_fa_ret_rec.detail_info.transaction_header_id_out, -- trx id for reinstatement
3232: g_message := 'Full reinstatement failure';
3233: RAISE e_reinstate_failed;
3234: END IF;
3235: ELSIF (p_retirement_type = 'COST') THEN
3236: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Calling Cost Reinstatement');
3237: -- call procedure to do partial cost reinstatement
3238: IF NOT Cost_Reinstatement(l_adjust_id_reinstate,
3239: l_latest_adj_id,
3240: p_fa_ret_rec.detail_info.transaction_header_id_in, -- trx id of the retirement
3251: g_message := 'Cost reinstatement failure';
3252: RAISE e_reinstate_failed;
3253: END IF;
3254: ELSIF (p_retirement_type = 'UNIT') THEN
3255: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Calling Unit Reinstatement');
3256: -- call procedure to do partial unit reinstatement
3257: IF NOT Unit_Reinstatement(l_adjust_id_reinstate,
3258: p_fa_ret_rec.detail_info.transaction_header_id_in, -- trx id of the retirement
3259: p_fa_ret_rec.detail_info.transaction_header_id_out, -- trx id for reinstatement
3274: RETURN TRUE;
3275: EXCEPTION
3276: WHEN e_latest_trx_not_avail THEN
3277: g_message := 'Latest transaction could not be retrieved for the asset';
3278: igi_iac_debug_pkg.debug_other_string(g_error_level,l_path,g_message);
3279: FA_SRVR_MSG.add_message(
3280: Calling_Fn => g_calling_fn,
3281: Name => 'IGI_IAC_NO_LATEST_TRX'
3282: );
3281: Name => 'IGI_IAC_NO_LATEST_TRX'
3282: );
3283: RETURN FALSE;
3284: WHEN e_reinstate_failed THEN
3285: igi_iac_debug_pkg.debug_other_string(g_error_level,l_path,g_message);
3286: FA_SRVR_MSG.add_message(
3287: Calling_Fn => g_calling_fn,
3288: Name => 'IGI_IAC_REINSTATE_FAILED'
3289: );
3289: );
3290: RETURN FALSE;
3291: WHEN others THEN
3292: g_message := 'Error: '||SQLERRM;
3293: igi_iac_debug_pkg.debug_unexpected_msg(l_path);
3294: g_calling_fn1 := g_calling_fn||' : Second_Transaction';
3295: FA_SRVR_MSG.add_sql_error(
3296: Calling_Fn => g_calling_fn1
3297: );
3405: IF NOT igi_gen.is_req_installed('IAC')
3406: THEN
3407: RAISE e_iac_not_enabled;
3408: END IF;
3409: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'IAC is enabled');
3410:
3411: -- check if the FA book is an IAC book
3412: IF NOT igi_iac_common_utils.is_iac_book(p_book_type_code)
3413: THEN
3412: IF NOT igi_iac_common_utils.is_iac_book(p_book_type_code)
3413: THEN
3414: RAISE e_not_iac_book;
3415: END IF;
3416: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,' This is an IAC book: '|| p_book_type_code);
3417:
3418: -- check if there is an IAC effect on the asset
3419: IF NOT igi_iac_common_utils.is_asset_proc(p_book_type_code,
3420: p_asset_id)
3426: SELECT asset_number
3427: INTO l_asset_num
3428: FROM fa_additions_b
3429: WHERE asset_id = p_asset_id;
3430: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'There is an IAC effect on the asset: '||l_asset_num);
3431:
3432: -- bug 2480915 start, call ytd preprocessor to populate igi_iac_fa_deprn
3433: -- if no entries exist for the book in the table
3434: IF NOT igi_iac_common_utils.populate_iac_fa_deprn_data(p_book_type_code,
3433: -- if no entries exist for the book in the table
3434: IF NOT igi_iac_common_utils.populate_iac_fa_deprn_data(p_book_type_code,
3435: 'REINSTATEMENT')
3436: THEN
3437: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Problems creating rows in igi_iac_fa_deprn');
3438: RAISE e_iac_fa_deprn;
3439: END IF;
3440: -- bug 2480915, end
3441:
3459: l_precision)
3460: THEN
3461: RETURN false;
3462: END IF;
3463: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Obtained GL information');
3464:
3465: -- from the p_retirement_id parameter passed in, retrieve the active
3466: -- transaction_header_id and the associated adjustment_id of the asset
3467: -- from igi_iac_transaction_headers
3471: l_mrc_sob_type)
3472: THEN
3473: RAISE e_no_retire_effect;
3474: ELSE
3475: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Have retiremen info from fa_retirements');
3476: -- in fa_retirements, transaction_header_id_in is fa_transaction_headers.transaction_header_id
3477: -- of the retirement
3478: -- transaction_header_id_out is fa_transaction_headers.transaction_header_id of the
3479: -- reinstatement
3514: )
3515: THEN
3516: RAISE e_indef_ret_type;
3517: END IF;
3518: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'retirement type '||l_retirement_type);
3519:
3520: -- bug 2452521 start(2), check if a revaluation has been done
3521: -- after the asset has been partially retired
3522: -- revaluation for fully retired assets can be ignored
3572: RAISE e_second_trans_failed;
3573: END IF;
3574:
3575: END IF;
3576: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,'Inflation Accounting Reinstatement successful');
3577:
3578: --ROLLBACK;
3579: --RETURN FALSE;
3580: RETURN TRUE;
3585: CLOSE c_fa_trx_headers;
3586: END IF;
3587:
3588: g_message := 'IAC is not enabled in IGI options.';
3589: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,g_message);
3590: FA_SRVR_MSG.add_message(
3591: Calling_Fn => g_calling_fn,
3592: Name => 'IGI_IAC_NOT_INSTALLED'
3593: );
3600: CLOSE c_fa_trx_headers;
3601: END IF;
3602:
3603: g_message := 'The book is not an IAC book';
3604: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,g_message);
3605: FA_SRVR_MSG.add_message(
3606: Calling_Fn => g_calling_fn,
3607: Name => 'IGI_IAC_NOT_IAC_BOOK'
3608: );
3615: CLOSE c_fa_trx_headers;
3616: END IF;
3617:
3618: g_message := 'This asset has not been revalued with IAC.';
3619: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,g_message);
3620: FA_SRVR_MSG.add_message(
3621: Calling_Fn => g_calling_fn,
3622: Name => 'IGI_IAC_NO_IAC_EFFECT'
3623: );
3630: CLOSE c_fa_trx_headers;
3631: END IF;
3632:
3633: g_message := 'Could not create the ytd rows in igi_iac_fa_deprn';
3634: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,g_message);
3635: FA_SRVR_MSG.add_message(
3636: Calling_Fn => g_calling_fn,
3637: Name => 'IGI_IAC_FA_DEPR_CREATE_PROB',
3638: Token1 => 'BOOK',
3647: IF c_fa_trx_headers%ISOPEN THEN
3648: CLOSE c_fa_trx_headers;
3649: END IF;
3650: g_message := 'This asset has been revalued atleast once after retirement. Cannot be reinstated.';
3651: igi_iac_debug_pkg.debug_other_string(g_state_level,l_path,g_message);
3652: FA_SRVR_MSG.add_message(
3653: Calling_Fn => g_calling_fn,
3654: Name => 'IGI_IAC_REVAL_POST_RETIRE'
3655: );
3663: CLOSE c_fa_trx_headers;
3664: END IF;
3665:
3666: g_message := 'Retirement information not available for asset';
3667: igi_iac_debug_pkg.debug_other_string(g_error_level,l_path,g_message);
3668: FA_SRVR_MSG.add_message(
3669: Calling_Fn => g_calling_fn,
3670: Name => 'IGI_IAC_NO_RETIRE_EFFECT'
3671: );
3678: CLOSE c_fa_trx_headers;
3679: END IF;
3680:
3681: g_message := 'Period Info Error: '||SQLERRM;
3682: igi_iac_debug_pkg.debug_other_string(g_error_level,l_path,g_message);
3683: FA_SRVR_MSG.add_message(
3684: Calling_Fn => g_calling_fn,
3685: Name => 'IGI_IAC_NO_PERIOD_INFO'
3686: );
3693: CLOSE c_fa_trx_headers;
3694: END IF;
3695:
3696: g_message := 'Cannot define retirement type';
3697: igi_iac_debug_pkg.debug_other_string(g_error_level,l_path,g_message);
3698: FA_SRVR_MSG.add_message(
3699: Calling_Fn => g_calling_fn,
3700: Name => 'IGI_IAC_INDEF_RETIRE_TYPE'
3701: );
3707: IF c_fa_trx_headers%ISOPEN THEN
3708: CLOSE c_fa_trx_headers;
3709: END IF;
3710:
3711: igi_iac_debug_pkg.debug_other_string(g_error_level,l_path,g_message);
3712: FA_SRVR_MSG.add_message(
3713: Calling_Fn => g_calling_fn,
3714: Name => 'IGI_IAC_REINSTATE_FAILED'
3715: );
3721: IF c_fa_trx_headers%ISOPEN THEN
3722: CLOSE c_fa_trx_headers;
3723: END IF;
3724:
3725: igi_iac_debug_pkg.debug_other_string(g_error_level,l_path,g_message);
3726: FA_SRVR_MSG.add_message(
3727: Calling_Fn => g_calling_fn,
3728: Name => 'IGI_IAC_REINSTATE_FAILED'
3729: );
3736: CLOSE c_fa_trx_headers;
3737: END IF;
3738:
3739: g_message := 'Error: '||SQLERRM;
3740: igi_iac_debug_pkg.debug_unexpected_msg(l_path);
3741: g_calling_fn1 := g_calling_fn||' : Main';
3742: FA_SRVR_MSG.add_sql_error(
3743: Calling_Fn => g_calling_fn1
3744: );