212: l_inv_tbl FA_API_TYPES.inv_tbl_type;
213: l_period_rec FA_API_TYPES.period_rec_type;
214:
215: -- used for loop through tax books
216: l_tax_book_tbl FA_CACHE_PKG.fazctbk_tbl_type;
217: l_tax_index number;
218:
219: -- used for tax books when doing cip-in-tax or autocopy
220: lv_trans_rec FA_API_TYPES.trans_rec_type;
341:
342: if l_asset_hdr_rec.book_type_code is not null then
343:
344: -- call the cache for the primary transaction book
345: if not fa_cache_pkg.fazcbc(x_book => l_asset_hdr_rec.book_type_code
346: ,p_log_level_rec => g_log_level_rec) then
347: raise FND_API.G_EXC_UNEXPECTED_ERROR;
348: end if;
349:
346: ,p_log_level_rec => g_log_level_rec) then
347: raise FND_API.G_EXC_UNEXPECTED_ERROR;
348: end if;
349:
350: -- l_book_class := fa_cache_pkg.fazcbc_record.book_class;
351: -- l_set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
352: -- l_distribution_source_book := fa_cache_pkg.fazcbc_record.distribution_source_book;
353: -- l_mc_source_flag := fa_cache_pkg.fazcbc_record.mc_source_flag;
354:
347: raise FND_API.G_EXC_UNEXPECTED_ERROR;
348: end if;
349:
350: -- l_book_class := fa_cache_pkg.fazcbc_record.book_class;
351: -- l_set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
352: -- l_distribution_source_book := fa_cache_pkg.fazcbc_record.distribution_source_book;
353: -- l_mc_source_flag := fa_cache_pkg.fazcbc_record.mc_source_flag;
354:
355: l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
348: end if;
349:
350: -- l_book_class := fa_cache_pkg.fazcbc_record.book_class;
351: -- l_set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
352: -- l_distribution_source_book := fa_cache_pkg.fazcbc_record.distribution_source_book;
353: -- l_mc_source_flag := fa_cache_pkg.fazcbc_record.mc_source_flag;
354:
355: l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
356:
349:
350: -- l_book_class := fa_cache_pkg.fazcbc_record.book_class;
351: -- l_set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
352: -- l_distribution_source_book := fa_cache_pkg.fazcbc_record.distribution_source_book;
353: -- l_mc_source_flag := fa_cache_pkg.fazcbc_record.mc_source_flag;
354:
355: l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
356:
357: fnd_profile.get('GL_SET_OF_BKS_ID',g_orig_set_of_books_id);
351: -- l_set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
352: -- l_distribution_source_book := fa_cache_pkg.fazcbc_record.distribution_source_book;
353: -- l_mc_source_flag := fa_cache_pkg.fazcbc_record.mc_source_flag;
354:
355: l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
356:
357: fnd_profile.get('GL_SET_OF_BKS_ID',g_orig_set_of_books_id);
358: g_orig_currency_context := substrb(userenv('CLIENT_INFO'),45,10);
359:
357: fnd_profile.get('GL_SET_OF_BKS_ID',g_orig_set_of_books_id);
358: g_orig_currency_context := substrb(userenv('CLIENT_INFO'),45,10);
359:
360: -- get the book type code P,R or N
361: if not fa_cache_pkg.fazcsob
362: (x_set_of_books_id => l_asset_hdr_rec.set_of_books_id
363: ,x_mrc_sob_type_code => l_reporting_flag
364: ,p_log_level_rec => g_log_level_rec)
365: then
666:
667: -- FYI: We don't allow unit retirements for TAX book
668: -- probably because TAX book does not have its own distributions
669: -- in DH table.
670: if fa_cache_pkg.fazcbc_record.book_class = 'TAX'
671: and l_asset_retire_rec.units_retired is not null then
672: g_msg_name := 'FA_RET_NO_PART_UNIT_IN_TAX';
673: -- ? can not find this message name in msg table
674: raise FND_API.G_EXC_ERROR;
811:
812: /* if book is a corporate book, process cip assets and autocopy */
813:
814: -- start processing tax books for cip-in-tax and autocopy
815: if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
816:
817: lv_trans_rec := l_trans_rec;
818: lv_asset_hdr_rec := l_asset_hdr_rec;
819:
827: value => l_asset_type_rec.asset_type
828: ,p_log_level_rec => g_log_level_rec);
829: end if;
830:
831: if not fa_cache_pkg.fazctbk
832: (x_corp_book => l_asset_hdr_rec.book_type_code
833: ,x_asset_type => l_asset_type_rec.asset_type
834: ,x_tax_book_tbl => l_tax_book_tbl
835: ,p_log_level_rec => g_log_level_rec) then
854:
855: else
856:
857: -- cache the book information for the tax book
858: if not fa_cache_pkg.fazcbc(x_book => l_tax_book_tbl(l_tax_index)) then
859: raise FND_API.G_EXC_UNEXPECTED_ERROR;
860: end if;
861:
862: -- ? Excerpt from Brad's comment on this part - need more investigation:
1078: l_subcomp_tbl FA_API_TYPES.subcomp_tbl_type;
1079: l_inv_tbl FA_API_TYPES.inv_tbl_type;
1080: l_period_rec FA_API_TYPES.period_rec_type;
1081:
1082: l_sob_tbl FA_CACHE_PKG.fazcrsob_sob_tbl_type;
1083:
1084: lv_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
1085:
1086: -- local individual variables
1125: -- *********************************
1126: -- populate rec_types that were not provided by users
1127:
1128: -- call the cache for the primary transaction book
1129: if not fa_cache_pkg.fazcbc(x_book => l_asset_hdr_rec.book_type_code
1130: ,p_log_level_rec => p_log_level_rec) then
1131: raise FND_API.G_EXC_UNEXPECTED_ERROR;
1132: end if;
1133:
1130: ,p_log_level_rec => p_log_level_rec) then
1131: raise FND_API.G_EXC_UNEXPECTED_ERROR;
1132: end if;
1133:
1134: l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
1135:
1136: -- set the sob_id and currency context
1137: fnd_profile.put('GL_SET_OF_BKS_ID', l_asset_hdr_rec.set_of_books_id);
1138: fnd_client_info.set_currency_context(to_char(l_asset_hdr_rec.set_of_books_id));
1261: -- BUG# 3575340
1262: -- need to prevent the backdate of a retirement not only
1263: -- on the retire date but also the prorate date
1264:
1265: l_prorate_calendar := fa_cache_pkg.fazcbc_record.prorate_calendar;
1266: l_fiscal_year_name := fa_cache_pkg.fazcbc_record.fiscal_year_name;
1267:
1268: if g_log_level_rec.statement_level then
1269: fa_debug_pkg.add
1262: -- need to prevent the backdate of a retirement not only
1263: -- on the retire date but also the prorate date
1264:
1265: l_prorate_calendar := fa_cache_pkg.fazcbc_record.prorate_calendar;
1266: l_fiscal_year_name := fa_cache_pkg.fazcbc_record.fiscal_year_name;
1267:
1268: if g_log_level_rec.statement_level then
1269: fa_debug_pkg.add
1270: (fname => l_calling_fn,
1267:
1268: if g_log_level_rec.statement_level then
1269: fa_debug_pkg.add
1270: (fname => l_calling_fn,
1271: element => 'fa_cache_pkg.fazcbc_record.prorate_calendar',
1272: value => fa_cache_pkg.fazcbc_record.prorate_calendar);
1273: fa_debug_pkg.add
1274: (fname => l_calling_fn,
1275: element => 'l_asset_retire_rec.retirement_prorate_convention',
1268: if g_log_level_rec.statement_level then
1269: fa_debug_pkg.add
1270: (fname => l_calling_fn,
1271: element => 'fa_cache_pkg.fazcbc_record.prorate_calendar',
1272: value => fa_cache_pkg.fazcbc_record.prorate_calendar);
1273: fa_debug_pkg.add
1274: (fname => l_calling_fn,
1275: element => 'l_asset_retire_rec.retirement_prorate_convention',
1276: value => l_asset_retire_rec.retirement_prorate_convention);
1318:
1319: end if;
1320:
1321:
1322: if not fa_cache_pkg.fazccvt
1323: (x_prorate_convention_code => l_asset_retire_rec.retirement_prorate_convention,
1324: x_fiscal_year_name => l_fiscal_year_name
1325: ,p_log_level_rec => p_log_level_rec) then
1326: raise FND_API.G_EXC_ERROR;
1325: ,p_log_level_rec => p_log_level_rec) then
1326: raise FND_API.G_EXC_ERROR;
1327: end if;
1328:
1329: if not fa_cache_pkg.fazcdp
1330: (x_book_type_code => l_asset_hdr_rec.book_type_code
1331: ,p_log_level_rec => p_log_level_rec) then
1332: raise FND_API.G_EXC_ERROR;
1333: end if;
1357: );
1358:
1359: -- added this for bug 3684222
1360: if (l_ret_prorate_date < l_latest_reval_date and
1361: l_ret_prorate_date < fa_cache_pkg.fazcdp_record.calendar_period_open_date) then
1362: g_msg_name := 'FA_SHARED_OTHER_TRX_FOLLOW';
1363: raise FND_API.G_EXC_ERROR;
1364: end if;
1365:
1365:
1366:
1367: end if; -- date_retired
1368:
1369: if (not fa_cache_pkg.fazccmt(l_asset_fin_rec.deprn_method_code,
1370: l_asset_fin_rec.life_in_months
1371: ,p_log_level_rec => p_log_level_rec)) then
1372: if (p_log_level_rec.statement_level) then
1373: fa_debug_pkg.add(l_calling_fn, 'Error calling', 'fa_cache_pkg.fazccmt'
1369: if (not fa_cache_pkg.fazccmt(l_asset_fin_rec.deprn_method_code,
1370: l_asset_fin_rec.life_in_months
1371: ,p_log_level_rec => p_log_level_rec)) then
1372: if (p_log_level_rec.statement_level) then
1373: fa_debug_pkg.add(l_calling_fn, 'Error calling', 'fa_cache_pkg.fazccmt'
1374: ,p_log_level_rec => p_log_level_rec);
1375: end if;
1376:
1377: raise FND_API.G_EXC_UNEXPECTED_ERROR;
1381: -- Bug3254818: Lift this ristriction for FLAT method type
1382: --
1383: -- check if date_retired is valid
1384: if (l_asset_retire_rec.date_retired is not null) and
1385: (fa_cache_pkg.fazccmt_record.rate_source_rule <> fa_std_types.FAD_RSR_FLAT) then
1386:
1387: if l_asset_retire_rec.date_retired < l_period_rec.calendar_period_open_date
1388: and nvl(l_asset_fin_rec.period_counter_fully_reserved,99)
1389: <> nvl(l_asset_fin_rec.period_counter_life_complete,99)
1421: end if;
1422:
1423: end if; -- units_retired
1424:
1425: if (fa_cache_pkg.fazcbc_record.book_class = 'TAX'
1426: and l_asset_retire_rec.units_retired is not null) then
1427:
1428: -- In tax book, treat unit retirement as cost retirement
1429: l_asset_retire_rec.cost_retired
1506: fa_debug_pkg.add(l_calling_fn, 'do_all_books_retirement: retirement_id: ', l_asset_retire_rec.retirement_id, p_log_level_rec);
1507: fa_debug_pkg.add(l_calling_fn, 'do_all_books_retirement: transaction_header_id: ', l_trans_rec.transaction_header_id, p_log_level_rec);
1508: end if;
1509:
1510: if not fa_cache_pkg.fazcbc(x_book => l_asset_hdr_rec.book_type_code
1511: ,p_log_level_rec => p_log_level_rec) then
1512: fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn
1513: ,p_log_level_rec => p_log_level_rec);
1514: return FALSE;
1515: end if;
1516:
1517: -- MRC LOOP
1518: -- if this is a primary book, process reporting books(sobs)
1519: if fa_cache_pkg.fazcbc_record.mc_source_flag = 'Y' then
1520:
1521: g_primary_set_of_books_id := l_asset_hdr_rec.set_of_books_id;
1522:
1523: -- call the sob cache to get the table of sob_ids
1520:
1521: g_primary_set_of_books_id := l_asset_hdr_rec.set_of_books_id;
1522:
1523: -- call the sob cache to get the table of sob_ids
1524: if not FA_CACHE_PKG.fazcrsob
1525: (x_book_type_code => l_asset_hdr_rec.book_type_code,
1526: x_sob_tbl => l_sob_tbl
1527: ,p_log_level_rec => p_log_level_rec) then
1528: raise FND_API.G_EXC_UNEXPECTED_ERROR;
1537: -- set the sob_id and currency context for reporting book(sob)
1538: fnd_profile.put('GL_SET_OF_BKS_ID', l_sob_tbl(l_sob_index));
1539: fnd_client_info.set_currency_context(to_char(l_sob_tbl(l_sob_index)));
1540:
1541: if not fa_cache_pkg.fazcbcs(x_book => l_asset_hdr_rec.book_type_code
1542: ,p_log_level_rec => p_log_level_rec) then
1543: fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn
1544: ,p_log_level_rec => p_log_level_rec);
1545: return FALSE;
1888: -- is handling all MRC part of adjustments table
1889: if (l_asset_dist_tbl.count > 0 )
1890: and
1891: (l_asset_hdr_rec.set_of_books_id
1892: = fa_cache_pkg.fazcbc_record.set_of_books_id)
1893: and
1894: (fa_cache_pkg.fazcbc_record.book_class='CORPORATE') then
1895:
1896: -- Call distribution API to process partial-unit retirement.
1890: and
1891: (l_asset_hdr_rec.set_of_books_id
1892: = fa_cache_pkg.fazcbc_record.set_of_books_id)
1893: and
1894: (fa_cache_pkg.fazcbc_record.book_class='CORPORATE') then
1895:
1896: -- Call distribution API to process partial-unit retirement.
1897: -- do_distribution will handle TH, DH, AD and AH tables for TRANSFER OUT transaction
1898: -- and call 'fautfr' function in it.
1937: -- fix for Bug 4966209
1938: -- call book cache to reset with right book
1939:
1940: -- call the cache for the book
1941: if not fa_cache_pkg.fazcbc(X_book => l_asset_hdr_rec.book_type_code) then
1942: raise FND_API.G_EXC_UNEXPECTED_ERROR;
1943: end if;
1944:
1945: --
2243:
2244: -- In case of TAX book, units_retired must always be NULL
2245: -- so that Calculate Gain/Loss program will not lead to
2246: -- distribution logic.
2247: if fa_cache_pkg.fazcbc_record.book_class='TAX' then
2248: l_asset_retire_rec.units_retired := NULL;
2249: else
2250: l_asset_retire_rec.units_retired := l_asset_desc_rec.current_units;
2251: end if;
2335: l_cost_new := l_asset_fin_rec.cost - l_asset_retire_rec.cost_retired;
2336: l_unrevalued_cost_new := l_asset_fin_rec.unrevalued_cost * l_fraction_remaining;
2337: l_eofy_reserve_new := l_asset_fin_rec.eofy_reserve * l_fraction_remaining;
2338:
2339: if (fa_cache_pkg.fazcbc_record.retire_reval_reserve_flag='YES') and
2340: (l_asset_fin_rec.Reval_Amortization_Basis is not null) then
2341: l_reval_amort_basis_new := l_asset_fin_rec.Reval_Amortization_Basis * l_fraction_remaining;
2342: else
2343: l_reval_amort_basis_new := l_asset_fin_rec.Reval_Amortization_Basis;
2520: ,p_log_level_rec => p_log_level_rec);
2521: fa_debug_pkg.add(l_calling_fn, 'l_asset_fin_rec.tracking_method',
2522: l_asset_fin_rec.tracking_method
2523: ,p_log_level_rec => p_log_level_rec);
2524: fa_debug_pkg.add(l_calling_fn, 'fa_cache_pkg.fazcdrd_record.rule_name',
2525: fa_cache_pkg.fazcdrd_record.rule_name
2526: ,p_log_level_rec => p_log_level_rec);
2527: fa_debug_pkg.add(l_calling_fn, 'l_asset_fin_rec.group_asset_id',
2528: l_asset_fin_rec.group_asset_id
2521: fa_debug_pkg.add(l_calling_fn, 'l_asset_fin_rec.tracking_method',
2522: l_asset_fin_rec.tracking_method
2523: ,p_log_level_rec => p_log_level_rec);
2524: fa_debug_pkg.add(l_calling_fn, 'fa_cache_pkg.fazcdrd_record.rule_name',
2525: fa_cache_pkg.fazcdrd_record.rule_name
2526: ,p_log_level_rec => p_log_level_rec);
2527: fa_debug_pkg.add(l_calling_fn, 'l_asset_fin_rec.group_asset_id',
2528: l_asset_fin_rec.group_asset_id
2529: ,p_log_level_rec => p_log_level_rec);
2736: if g_log_level_rec.statement_level then fa_debug_pkg.add(l_calling_fn, 'retirement_id: ', l_asset_retire_rec.retirement_id, p_log_level_rec); end if;
2737: px_asset_retire_rec := l_asset_retire_rec;
2738:
2739: -- Bug 6665510: FP: Japan Tax Reform Project (Start)
2740: if nvl(fa_cache_pkg.fazccmt_record.GUARANTEE_RATE_METHOD_FLAG,'NO') = 'YES' then
2741:
2742: SELECT nvl(rate_in_use,0)
2743: INTO l_rate_in_use
2744: FROM fa_books
2956: X_Return_Status => l_status,
2957: X_Calling_Fn => l_calling_fn);
2958:
2959: -- Bug 6665510: FP: Japan Tax Reform Project (Start)
2960: if nvl(fa_cache_pkg.fazccmt_record.GUARANTEE_RATE_METHOD_FLAG,'NO') = 'YES' then
2961:
2962: UPDATE fa_books
2963: SET rate_in_use = l_rate_in_use
2964: WHERE asset_id = l_asset_hdr_rec.asset_id
2969: -- Bug 6665510: FP: Japan Tax Reform Project (End)
2970:
2971: -- Full retirement does not update DH table at all
2972: -- since DH table only has distribtuions only for corporate book
2973: if fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE' and
2974: l_trans_rec.transaction_type_code = 'FULL RETIREMENT' then
2975:
2976: -- full retirement
2977: for dh_rec in dh_cursor(l_asset_hdr_rec.asset_id,
3126: l_inv_tbl FA_API_TYPES.inv_tbl_type;
3127: l_period_rec FA_API_TYPES.period_rec_type;
3128:
3129: -- used to loop through tax books
3130: l_tax_book_tbl FA_CACHE_PKG.fazctbk_tbl_type;
3131: l_tax_index number; -- index for tax loop
3132:
3133: l_reporting_flag varchar2(1);
3134:
3204:
3205: if l_asset_hdr_rec.book_type_code is not null then
3206:
3207: -- call the cache for the primary transaction book
3208: if not fa_cache_pkg.fazcbc(x_book => l_asset_hdr_rec.book_type_code
3209: ,p_log_level_rec => g_log_level_rec) then
3210: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3211: end if;
3212:
3209: ,p_log_level_rec => g_log_level_rec) then
3210: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3211: end if;
3212:
3213: l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
3214: lv_asset_hdr_rec := l_asset_hdr_rec;
3215:
3216: -- get the book type code P,R or N
3217: if not fa_cache_pkg.fazcsob
3213: l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
3214: lv_asset_hdr_rec := l_asset_hdr_rec;
3215:
3216: -- get the book type code P,R or N
3217: if not fa_cache_pkg.fazcsob
3218: (x_set_of_books_id => l_asset_hdr_rec.set_of_books_id
3219: ,x_mrc_sob_type_code => l_reporting_flag
3220: ,p_log_level_rec => g_log_level_rec)
3221: then
3291:
3292: /* if book is a corporate book, process cip assets and autocopy */
3293:
3294: -- start processing tax books for cip-in-tax and autocopy
3295: if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
3296:
3297: lv_trans_rec := l_trans_rec;
3298:
3299: if (l_asset_type_rec.asset_type = 'CIP'
3298:
3299: if (l_asset_type_rec.asset_type = 'CIP'
3300: or l_asset_type_rec.asset_type = 'CAPITALIZED') then
3301:
3302: if not fa_cache_pkg.fazctbk
3303: (x_corp_book => l_asset_hdr_rec.book_type_code
3304: ,x_asset_type => l_asset_type_rec.asset_type
3305: ,x_tax_book_tbl => l_tax_book_tbl
3306: ,p_log_level_rec => g_log_level_rec) then
3319:
3320: else
3321:
3322: -- cache the book information for the tax book
3323: if not fa_cache_pkg.fazcbc(x_book => l_tax_book_tbl(l_tax_index)) then
3324: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3325: end if;
3326:
3327: lv_trans_rec.transaction_header_id := null;
3504: l_asset_hdr_rec.asset_id := l_asset_retire_rec.detail_info.asset_id;
3505: l_asset_hdr_rec.book_type_code := l_asset_retire_rec.detail_info.book_type_code;
3506:
3507: -- call the cache for the primary transaction book
3508: if not fa_cache_pkg.fazcbc(x_book => l_asset_hdr_rec.book_type_code
3509: ,p_log_level_rec => p_log_level_rec) then
3510: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3511: end if;
3512:
3509: ,p_log_level_rec => p_log_level_rec) then
3510: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3511: end if;
3512:
3513: l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
3514:
3515:
3516: -- set the sob_id and currency context
3517: fnd_profile.put('GL_SET_OF_BKS_ID', l_asset_hdr_rec.set_of_books_id);
3565: ,p_log_level_rec => p_log_level_rec) then
3566: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3567: end if;
3568:
3569: if not fa_cache_pkg.fazcbc(x_book => l_asset_hdr_rec.book_type_code
3570: ,p_log_level_rec => p_log_level_rec) then
3571: fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn
3572: ,p_log_level_rec => p_log_level_rec);
3573: return FALSE;
3574: end if;
3575:
3576: -- MRC LOOP
3577: -- if this is a primary book, process reporting books(sobs)
3578: if fa_cache_pkg.fazcbc_record.mc_source_flag = 'Y' then
3579:
3580: -- loop thourgh reporting set of books
3581: for sob_rec in sob_cursor(l_asset_hdr_rec.book_type_code
3582: ,l_asset_hdr_rec.set_of_books_id) loop
3588: fnd_client_info.set_currency_context(to_char(sob_rec.sob_id));
3589:
3590: l_asset_hdr_rec.set_of_books_id := sob_rec.sob_id;
3591:
3592: if not fa_cache_pkg.fazcbcs(x_book => l_asset_hdr_rec.book_type_code
3593: ,p_log_level_rec => p_log_level_rec) then
3594: fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn
3595: ,p_log_level_rec => p_log_level_rec);
3596: return FALSE;
3914: if g_log_level_rec.statement_level then
3915: fa_debug_pkg.add(l_calling_fn, 'Asset_Id:', l_asset_hdr_rec.Asset_Id, p_log_level_rec);
3916: fa_debug_pkg.add(l_calling_fn, 'Book_Type_Code:', l_asset_hdr_rec.Book_Type_Code, p_log_level_rec);
3917: fa_debug_pkg.add(l_calling_fn, 'p_mrc_sob_type_code:', p_mrc_sob_type_code, p_log_level_rec);
3918: fa_debug_pkg.add(l_calling_fn, 'book class:', fa_cache_pkg.fazcbc_record.book_class, p_log_level_rec);
3919: end if;
3920:
3921: if (p_mrc_sob_type_code <> 'R') then
3922:
3919: end if;
3920:
3921: if (p_mrc_sob_type_code <> 'R') then
3922:
3923: if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
3924: if g_log_level_rec.statement_level then fa_debug_pkg.add(l_calling_fn, 'before get_transfer_id', '', p_log_level_rec); end if;
3925:
3926: l_partial_unit_ret_flag := 'N';
3927:
4080: ,p_log_level_rec => p_log_level_rec);
4081:
4082: if (p_mrc_sob_type_code <> 'R') then
4083:
4084: if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
4085: if g_log_level_rec.statement_level then fa_debug_pkg.add(l_calling_fn, 'FA_DISTRIBUTION_HISTORY_PKG.REACTIVATE_ROW', '', p_log_level_rec); end if;
4086: FA_DISTRIBUTION_HISTORY_PKG.REACTIVATE_ROW
4087: (X_Asset_Id => l_asset_hdr_rec.asset_id,
4088: X_Book_Type_Code=> l_asset_hdr_rec.book_type_code,
4180: l_inv_tbl FA_API_TYPES.inv_tbl_type;
4181: l_period_rec FA_API_TYPES.period_rec_type;
4182:
4183: -- used for loop through tax books
4184: l_tax_book_tbl FA_CACHE_PKG.fazctbk_tbl_type;
4185: l_tax_index number;
4186:
4187: cursor tde_cursor is
4188: select max(th.transaction_date_entered)
4304: fnd_profile.get('GL_SET_OF_BKS_ID',g_orig_set_of_books_id);
4305: g_orig_currency_context := substrb(userenv('CLIENT_INFO'),45,10);
4306:
4307: -- call the cache for the primary transaction book
4308: if not fa_cache_pkg.fazcbc(x_book => l_asset_hdr_rec.book_type_code
4309: ,p_log_level_rec => g_log_level_rec) then
4310: raise FND_API.G_EXC_UNEXPECTED_ERROR;
4311: end if;
4312:
4309: ,p_log_level_rec => g_log_level_rec) then
4310: raise FND_API.G_EXC_UNEXPECTED_ERROR;
4311: end if;
4312:
4313: -- l_book_class := fa_cache_pkg.fazcbc_record.book_class;
4314: -- l_set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
4315: -- l_distribution_source_book := fa_cache_pkg.fazcbc_record.distribution_source_book;
4316: -- l_mc_source_flag := fa_cache_pkg.fazcbc_record.mc_source_flag;
4317:
4310: raise FND_API.G_EXC_UNEXPECTED_ERROR;
4311: end if;
4312:
4313: -- l_book_class := fa_cache_pkg.fazcbc_record.book_class;
4314: -- l_set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
4315: -- l_distribution_source_book := fa_cache_pkg.fazcbc_record.distribution_source_book;
4316: -- l_mc_source_flag := fa_cache_pkg.fazcbc_record.mc_source_flag;
4317:
4318: l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
4311: end if;
4312:
4313: -- l_book_class := fa_cache_pkg.fazcbc_record.book_class;
4314: -- l_set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
4315: -- l_distribution_source_book := fa_cache_pkg.fazcbc_record.distribution_source_book;
4316: -- l_mc_source_flag := fa_cache_pkg.fazcbc_record.mc_source_flag;
4317:
4318: l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
4319:
4312:
4313: -- l_book_class := fa_cache_pkg.fazcbc_record.book_class;
4314: -- l_set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
4315: -- l_distribution_source_book := fa_cache_pkg.fazcbc_record.distribution_source_book;
4316: -- l_mc_source_flag := fa_cache_pkg.fazcbc_record.mc_source_flag;
4317:
4318: l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
4319:
4320: -- set the sob_id and currency context
4314: -- l_set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
4315: -- l_distribution_source_book := fa_cache_pkg.fazcbc_record.distribution_source_book;
4316: -- l_mc_source_flag := fa_cache_pkg.fazcbc_record.mc_source_flag;
4317:
4318: l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
4319:
4320: -- set the sob_id and currency context
4321: fnd_profile.put('GL_SET_OF_BKS_ID', l_asset_hdr_rec.set_of_books_id);
4322: fnd_client_info.set_currency_context (to_char(l_asset_hdr_rec.set_of_books_id));
4326: fnd_profile.get ('GL_SET_OF_BKS_ID',l_orig_set_of_books_id);
4327: l_orig_currency_context := SUBSTRB(USERENV('CLIENT_INFO'),45,10);
4328:
4329: -- get the book type code P,R or N
4330: if not fa_cache_pkg.fazcsob
4331: (x_set_of_books_id => l_asset_hdr_rec.set_of_books_id
4332: ,x_mrc_sob_type_code => l_reporting_flag
4333: ,p_log_level_rec => g_log_level_rec)
4334: then
4453:
4454: /* if book is a corporate book, process cip assets and autocopy */
4455:
4456: -- start processing tax books for cip-in-tax and autocopy
4457: if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
4458:
4459: lv_trans_rec := l_trans_rec;
4460: lv_asset_hdr_rec := l_asset_hdr_rec;
4461: lv_asset_retire_rec := l_asset_retire_rec;
4464: or l_asset_type_rec.asset_type = 'CAPITALIZED') then
4465:
4466: if g_log_level_rec.statement_level then fa_debug_pkg.add(l_calling_fn, 'Asset type: ', l_asset_type_rec.asset_type, g_log_level_rec); end if;
4467:
4468: if not fa_cache_pkg.fazctbk
4469: (x_corp_book => l_asset_hdr_rec.book_type_code
4470: ,x_asset_type => l_asset_type_rec.asset_type
4471: ,x_tax_book_tbl => l_tax_book_tbl
4472: ,p_log_level_rec => g_log_level_rec) then
4491:
4492: else
4493:
4494: -- cache the book information for the tax book
4495: if not fa_cache_pkg.fazcbc(x_book => l_tax_book_tbl(l_tax_index)) then
4496: raise FND_API.G_EXC_UNEXPECTED_ERROR;
4497: end if;
4498:
4499: -- ? Excerpt from Brad's comment on this part - need more investigation:
4713: -- *********************************
4714: -- populate rec_types that were not provided by users
4715:
4716: -- call the cache for the primary transaction book
4717: if not fa_cache_pkg.fazcbc(x_book => l_asset_hdr_rec.book_type_code
4718: ,p_log_level_rec => p_log_level_rec) then
4719: raise FND_API.G_EXC_UNEXPECTED_ERROR;
4720: end if;
4721:
4718: ,p_log_level_rec => p_log_level_rec) then
4719: raise FND_API.G_EXC_UNEXPECTED_ERROR;
4720: end if;
4721:
4722: l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
4723:
4724: -- set the sob_id and currency context
4725: fnd_profile.put('GL_SET_OF_BKS_ID', l_asset_hdr_rec.set_of_books_id);
4726: fnd_client_info.set_currency_context(to_char(l_asset_hdr_rec.set_of_books_id));
4822: raise FND_API.G_EXC_UNEXPECTED_ERROR;
4823: end if;
4824:
4825:
4826: if not fa_cache_pkg.fazcbc(x_book => l_asset_hdr_rec.book_type_code
4827: ,p_log_level_rec => p_log_level_rec) then
4828: fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn
4829: ,p_log_level_rec => p_log_level_rec);
4830: return FALSE;
4831: end if;
4832:
4833: -- MRC LOOP
4834: -- if this is a primary book, process reporting books(sobs)
4835: if fa_cache_pkg.fazcbc_record.mc_source_flag = 'Y' then
4836:
4837: -- loop thourgh reporting set of books
4838: for sob_rec in sob_cursor(l_asset_hdr_rec.book_type_code
4839: ,l_asset_hdr_rec.set_of_books_id) loop
4845: fnd_client_info.set_currency_context(to_char(sob_rec.sob_id));
4846:
4847: l_asset_hdr_rec.set_of_books_id := sob_rec.sob_id;
4848:
4849: if not fa_cache_pkg.fazcbcs(x_book => l_asset_hdr_rec.book_type_code
4850: ,p_log_level_rec => p_log_level_rec) then
4851: fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn
4852: ,p_log_level_rec => p_log_level_rec);
4853: return FALSE;
4859: -- if l_inv_trans_rec.transaction_type is null then
4860:
4861: /******* routine to get existing rates when invoice trx is involved
4862: -- if (l_inv_rec.source_transaction_header_id is not null)
4863: and (fa_cache_pkg.fazcbc_record.book_class = 'TAX') then
4864:
4865: if g_log_level_rec.statement_level then fa_debug_pkg.add(l_calling_fn, 'calling get_existing_rate', '', p_log_level_rec); end if;
4866:
4867: -- get the exchange rate from the corporate transaction
4880:
4881: if g_log_level_rec.statement_level then fa_debug_pkg.add(l_calling_fn, 'calling get_trx_rate', '', p_log_level_rec); end if;
4882:
4883: if not FA_MC_UTIL_PVT.get_trx_rate
4884: (p_prim_set_of_books_id => fa_cache_pkg.fazcbc_record.set_of_books_id,
4885: p_reporting_set_of_books_id => sob_rec.sob_id,
4886: px_exchange_date => l_exchange_date,
4887: p_book_type_code => l_asset_hdr_rec.book_type_code,
4888: px_rate => l_rate
5093: -- is handling all MRC part of adjustments table
5094: if (l_asset_dist_tbl.count > 0 )
5095: and
5096: (l_asset_hdr_rec.set_of_books_id
5097: = fa_cache_pkg.fazcbc_record.set_of_books_id)
5098: and
5099: (fa_cache_pkg.fazcbc_record.book_class='CORPORATE') then
5100:
5101: -- Call distribution API to process partial-unit reinstatement.
5095: and
5096: (l_asset_hdr_rec.set_of_books_id
5097: = fa_cache_pkg.fazcbc_record.set_of_books_id)
5098: and
5099: (fa_cache_pkg.fazcbc_record.book_class='CORPORATE') then
5100:
5101: -- Call distribution API to process partial-unit reinstatement.
5102: -- do_distribution will handle TH, DH, AD and AH tables for TRANSFER OUT transaction
5103: -- and call 'fautfr' function in it.
5553: l_inv_tbl FA_API_TYPES.inv_tbl_type;
5554: l_period_rec FA_API_TYPES.period_rec_type;
5555:
5556: -- used to loop through tax books
5557: l_tax_book_tbl FA_CACHE_PKG.fazctbk_tbl_type;
5558: l_tax_index number; -- index for tax loop
5559:
5560: l_reporting_flag varchar2(1);
5561:
5625: fnd_profile.get('GL_SET_OF_BKS_ID',g_orig_set_of_books_id);
5626: g_orig_currency_context := substrb(userenv('CLIENT_INFO'),45,10);
5627:
5628: -- call the cache for the primary transaction book
5629: if not fa_cache_pkg.fazcbc(x_book => l_asset_hdr_rec.book_type_code
5630: ,p_log_level_rec => g_log_level_rec) then
5631: raise FND_API.G_EXC_UNEXPECTED_ERROR;
5632: end if;
5633:
5630: ,p_log_level_rec => g_log_level_rec) then
5631: raise FND_API.G_EXC_UNEXPECTED_ERROR;
5632: end if;
5633:
5634: l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
5635: lv_asset_hdr_rec := l_asset_hdr_rec;
5636:
5637: -- set the sob_id and currency context
5638: fnd_profile.put('GL_SET_OF_BKS_ID', l_asset_hdr_rec.set_of_books_id);
5643: fnd_profile.get ('GL_SET_OF_BKS_ID',l_orig_set_of_books_id);
5644: l_orig_currency_context := SUBSTRB(USERENV('CLIENT_INFO'),45,10);
5645:
5646: -- get the book type code P,R or N
5647: if not fa_cache_pkg.fazcsob
5648: (x_set_of_books_id => l_asset_hdr_rec.set_of_books_id
5649: ,x_mrc_sob_type_code => l_reporting_flag
5650: ,p_log_level_rec => g_log_level_rec)
5651: then
5712:
5713: /* if book is a corporate book, process cip assets and autocopy */
5714:
5715: -- start processing tax books for cip-in-tax and autocopy
5716: if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
5717:
5718: lv_trans_rec := l_trans_rec;
5719:
5720: if (l_asset_type_rec.asset_type = 'CIP'
5721: or l_asset_type_rec.asset_type = 'CAPITALIZED') then
5722:
5723: if g_log_level_rec.statement_level then fa_debug_pkg.add(l_calling_fn, 'Asset type: ', l_asset_type_rec.asset_type, g_log_level_rec); end if;
5724:
5725: if not fa_cache_pkg.fazctbk
5726: (x_corp_book => l_asset_hdr_rec.book_type_code
5727: ,x_asset_type => l_asset_type_rec.asset_type
5728: ,x_tax_book_tbl => l_tax_book_tbl
5729: ,p_log_level_rec => g_log_level_rec) then
5747:
5748: else
5749:
5750: -- cache the book information for the tax book
5751: if not fa_cache_pkg.fazcbc(x_book => l_tax_book_tbl(l_tax_index)) then
5752: raise FND_API.G_EXC_UNEXPECTED_ERROR;
5753: end if;
5754:
5755: lv_trans_rec.transaction_header_id := null;
5931: l_asset_hdr_rec.asset_id := l_asset_retire_rec.detail_info.asset_id;
5932: l_asset_hdr_rec.book_type_code := l_asset_retire_rec.detail_info.book_type_code;
5933:
5934: -- call the cache for the primary transaction book
5935: if not fa_cache_pkg.fazcbc(x_book => l_asset_hdr_rec.book_type_code
5936: ,p_log_level_rec => p_log_level_rec) then
5937: raise FND_API.G_EXC_UNEXPECTED_ERROR;
5938: end if;
5939:
5936: ,p_log_level_rec => p_log_level_rec) then
5937: raise FND_API.G_EXC_UNEXPECTED_ERROR;
5938: end if;
5939:
5940: l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
5941:
5942: -- set the sob_id and currency context
5943: fnd_profile.put('GL_SET_OF_BKS_ID', l_asset_hdr_rec.set_of_books_id);
5944: fnd_client_info.set_currency_context(to_char(l_asset_hdr_rec.set_of_books_id));
5990: ,p_log_level_rec => p_log_level_rec) then
5991: raise FND_API.G_EXC_UNEXPECTED_ERROR;
5992: end if;
5993:
5994: if not fa_cache_pkg.fazcbc(x_book => l_asset_hdr_rec.book_type_code
5995: ,p_log_level_rec => p_log_level_rec) then
5996: fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn
5997: ,p_log_level_rec => p_log_level_rec);
5998: return FALSE;
5999: end if;
6000:
6001: -- MRC LOOP
6002: -- if this is a primary book, process reporting books(sobs)
6003: if fa_cache_pkg.fazcbc_record.mc_source_flag = 'Y' then
6004:
6005: -- loop thourgh reporting set of books
6006: for sob_rec in sob_cursor(l_asset_hdr_rec.book_type_code
6007: ,l_asset_hdr_rec.set_of_books_id) loop
6012: fnd_profile.put('GL_SET_OF_BKS_ID', sob_rec.sob_id);
6013: fnd_client_info.set_currency_context(to_char(sob_rec.sob_id));
6014:
6015: l_asset_hdr_rec.set_of_books_id := sob_rec.sob_id;
6016: if not fa_cache_pkg.fazcbcs(x_book => l_asset_hdr_rec.book_type_code
6017: ,p_log_level_rec => p_log_level_rec) then
6018: fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn
6019: ,p_log_level_rec => p_log_level_rec);
6020: return FALSE;
6546: -- Instead retirement of CIP on TAX book can be copied through CORP book only.
6547: if l_validation_type = g_retirement then
6548:
6549: -- call the cache for the transaction book
6550: if not fa_cache_pkg.fazcbc(x_book => l_asset_hdr_rec.book_type_code
6551: ,p_log_level_rec => p_log_level_rec) then
6552: raise FND_API.G_EXC_UNEXPECTED_ERROR;
6553: end if;
6554:
6552: raise FND_API.G_EXC_UNEXPECTED_ERROR;
6553: end if;
6554:
6555: if g_log_level_rec.statement_level then fa_debug_pkg.add(l_calling_fn, 'check to make sure that the transaction is not for CIP on TAX book', '', p_log_level_rec); end if;
6556: if fa_cache_pkg.fazcbc_record.book_class = 'TAX'
6557: and l_asset_type_rec.asset_type = 'CIP' then
6558:
6559: -- we do not support this transaction
6560: if g_log_level_rec.statement_level then fa_debug_pkg.add(l_calling_fn, 'Error: You can not perform this transaction on CIP asset.', '', p_log_level_rec); end if;
6568: ,g_undo_retirement
6569: ,g_undo_reinstatement) then
6570:
6571: -- call the cache for the transaction book
6572: if not fa_cache_pkg.fazcbc(x_book => lv_asset_retire_rec.detail_info.book_type_code
6573: ,p_log_level_rec => p_log_level_rec) then
6574: g_msg_name := null;
6575: g_token1 := null;
6576: raise FND_API.G_EXC_UNEXPECTED_ERROR;
6575: g_token1 := null;
6576: raise FND_API.G_EXC_UNEXPECTED_ERROR;
6577: end if;
6578:
6579: if fa_cache_pkg.fazcbc_record.book_class = 'TAX'
6580: and l_asset_type_rec.asset_type = 'CIP' then
6581:
6582: -- we do not support this transaction
6583: if g_log_level_rec.statement_level then fa_debug_pkg.add(l_calling_fn, 'Error: You can not perform this transaction on CIP asset.', '', p_log_level_rec); end if;
6749: and l_asset_retire_rec.date_retired is not null then
6750:
6751: -- validate retirement_prorate_convention if it is not null
6752: if l_asset_retire_rec.retirement_prorate_convention is not null then
6753: if not fa_cache_pkg.fazccvt
6754: (x_prorate_convention_code => l_asset_retire_rec.retirement_prorate_convention,
6755: x_fiscal_year_name => fa_cache_pkg.fazcbc_record.fiscal_year_name
6756: ,p_log_level_rec => p_log_level_rec) then
6757: g_msg_name := 'FA_RET_CANT_GET_RET_PRO_DATE';
6751: -- validate retirement_prorate_convention if it is not null
6752: if l_asset_retire_rec.retirement_prorate_convention is not null then
6753: if not fa_cache_pkg.fazccvt
6754: (x_prorate_convention_code => l_asset_retire_rec.retirement_prorate_convention,
6755: x_fiscal_year_name => fa_cache_pkg.fazcbc_record.fiscal_year_name
6756: ,p_log_level_rec => p_log_level_rec) then
6757: g_msg_name := 'FA_RET_CANT_GET_RET_PRO_DATE';
6758: g_token1 := null;
6759: