[Home] [Help]
PACKAGE BODY: APPS.OKL_ACTIVATE_ASSET_PVT
Source
1 PACKAGE BODY OKL_ACTIVATE_ASSET_PVT as
2 /* $Header: OKLRACAB.pls 120.49.12010000.3 2009/01/15 20:51:16 smereddy ship $ */
3 G_PKG_NAME VARCHAR2(100) := 'OKL_ACTIVATE_ASSET_PVT';
4 G_CHR_CURRENCY_CODE OKL_K_HEADERS_FULL_V.currency_code%TYPE;
5 G_FUNC_CURRENCY_CODE OKL_K_HEADERS_FULL_V.currency_code%TYPE;
6 G_CHR_AUTHORING_ORG_ID OKL_K_HEADERS_FULL_V.authoring_org_id%TYPE;
7 G_CHR_START_DATE DATE;
8 G_CHR_REPORT_PDT_ID OKL_PRODUCTS_V.reporting_pdt_id%TYPE;
9
10 --------------------------------------------------------------------------------
11 --Global Constants used in the program
12 --------------------------------------------------------------------------------
13 G_TRX_LINE_TYPE_BOOK CONSTANT Varchar2(30) := 'CFA';
14 G_TRX_HDR_TYPE_BOOK CONSTANT Varchar2(30) := 'CFA';
15 G_TRX_LINE_TYPE_REBOOK CONSTANT Varchar2(30) := 'CRB';
16 G_TRX_HDR_TYPE_REBOOK CONSTANT Varchar2(30) := 'CRB';
17 G_TRX_HDR_TYPE_RELEASE CONSTANT Varchar2(30) := 'CRL';
18 G_TRX_LINE_TYPE_RELEASE CONSTANT Varchar2(30) := 'CRL';
19 G_FA_LINE_LTY_CODE CONSTANT VARCHAR2(30) := 'FIXED_ASSET';
20 G_FA_LINE_LTY_ID CONSTANT NUMBER := 42;
21 G_FIN_AST_LINE_LTY_CODE CONSTANT VARCHAR2(30) := 'FREE_FORM1';
22 --G_ADJ_TRX_SUBTYPE CONSTANT VARCHAR2(100) := 'AMORTIZE'; --while adjusting costs to zero whether to amortize or expense
23 G_ADJ_TRX_SUBTYPE CONSTANT VARCHAR2(100) := 'AMORTIZED'; --while adjusting costs to zero whether to amortize or expense
24 G_AMORT_START_DATE CONSTANT DATE := sysdate; -- adjustment amortization start date
25 G_ADJ_TRX_TYPE_CODE CONSTANT VARCHAR2(100) := 'ADJUSTMENT';
26 G_ADD_TRX_TYPE_CODE CONSTANT VARCHAR2(100) := 'ADDITION';
27 G_ADD_ASSET_TYPE CONSTANT VARCHAR2(100) := 'CAPITALIZED'; --Lease assets will always be capitalized
28 G_ADD_RATE_ADJ_FACTOR CONSTANT NUMBER := 1;
29 G_TAX_OWNER_RGP_CODE CONSTANT VARCHAR2(30) := 'LATOWN';
30 G_TAX_OWNER_RUL_CODE CONSTANT VARCHAR2(30) := 'LATOWN';
31 G_TAX_OWNER_RUL_PROMPT CONSTANT VARCHAR2(80) := 'Tax Owner';
32 --Bug# 2525946 start
33 G_TAX_OWNER_RUL_SEG_NUMBER CONSTANT NUMBER := 1;
34 --Bug# 2525946 end
35 G_APPROVED_STS_CODE CONSTANT VARCHAR2(100) := 'APPROVED';
36 G_LEASE_SCS_CODE CONSTANT VARCHAR2(100) := 'LEASE';
37 G_DF_LEASE_BK_CLASS CONSTANT VARCHAR2(30) := 'LEASEDF';
38 G_ST_LEASE_BK_CLASS CONSTANT VARCHAR2(30) := 'LEASEST';
39 G_OP_LEASE_BK_CLASS CONSTANT VARCHAR2(30) := 'LEASEOP';
40 G_LOAN_BK_CLASS CONSTANT VARCHAR2(30) := 'LOAN';
41 G_REVOLVING_LOAN_BK_CLASS CONSTANT VARCHAR2(30) := 'LOAN-REVOLVING';
42 G_FA_CORP_BOOK_CLASS_CODE CONSTANT VARCHAR2(15) := 'CORPORATE';
43 G_FA_TAX_BOOK_CLASS_CODE CONSTANT VARCHAR2(15) := 'TAX';
44 G_TSU_CODE_PROCESSED CONSTANT VARCHAR2(30) := 'PROCESSED';
45 G_TSU_CODE_ENTERED CONSTANT Varchar2(30) := 'ENTERED';
46 --bug# 3143522 : 11.5.10 Subsidies
47 G_FORMULA_LINE_DISCOUNT CONSTANT Varchar2(150) := 'LINE_DISCOUNT';
48 --Bug# 2981308 :
49 G_FORMULA_LINE_TRADEIN CONSTANT Varchar2(150) := 'LINE_TRADEIN';
50 G_FORMULA_LINE_CAPREDUCTION CONSTANT Varchar2(150) := 'LINE_CAPREDUCTION';
51 G_FORMULA_LINE_CAPINTEREST CONSTANT Varchar2(150) := 'LINE_CAPITALIZED_INTEREST';
52 -------------------------------------------------------------------------------
53 --Global Messages
54 -------------------------------------------------------------------------------
55 G_SOB_FETCH_FAILED CONSTANT VARCHAR2(200) := 'OKL_LLA_BK_SOB_NOT_FOUND';
56 G_FA_BOOK_TOKEN CONSTANT VARCHAR2(200) := 'FA_BOOK';
57 G_FA_BOOK_NOT_ENTERED CONSTANT VARCHAR2(200) := 'OKL_LLA_FA_BK_NOT_ENTERED';
58 G_ASSET_NUMBER_TOKEN CONSTANT VARCHAR2(200) := 'ASSET_NUMBER';
59 G_AST_CAT_NOT_ENTERED CONSTANT VARCHAR2(200) := 'OKL_LLA_AST_CAT_NOT_ENTERED';
60 G_AST_LOC_NOT_ENTERED CONSTANT VARCHAR2(200) := 'OKL_LLA_AST_LOC_NOT_ENTERED';
61 G_EXP_ACCT_NOT_ENTERED CONSTANT VARCHAR2(200) := 'OKL_LLA_EXP_ACCT_NOT_ENTERED';
62 G_CONTRACT_NOT_FOUND CONSTANT VARCHAR2(200) := 'OKL_LLA_CONTRACT_NOT_FOUND';
63 G_CONTRACT_ID CONSTANT VARCHAR2(200) := 'CONTRACT_ID';
64 G_CONTRACT_NOT_APPROVED CONSTANT VARCHAR2(200) := 'OKL_LLA_CONTRACT_NOT_APPROVED';
65 G_CONTRACT_NOT_LEASE CONSTANT VARCHAR2(200) := 'OKL_LLA_CONTRACT_NOT_LEASE';
66 G_FA_ITEM_REC_NOT_FOUND CONSTANT VARCHAR2(200) := 'OKL_LLA_FA_ITM_REC_NOT_FOUND';
67 G_FA_LINE_ID CONSTANT VARCHAR2(200) := 'FA_LINE_ID';
68 G_FA_TRX_REC_NOT_FOUND CONSTANT VARCHAR2(200) := 'OKL_LLA_FA_TRX_REC_NOT_FOUND';
69 G_FA_INVALID_BK_CAT CONSTANT VARCHAR2(200) := 'OKL_LLA_FA_INVALID_BOOK_CAT';
70 G_FA_BOOK CONSTANT VARCHAR2(200) := 'FA_BOOK';
71 G_ASSET_CATEGORY CONSTANT VARCHAR2(200) := 'FA_CATEGORY';
72 G_FA_TAX_CPY_NOT_ALLOWED CONSTANT VARCHAR2(200) := 'OKL_LLA_FA_TAX_CPY_NOT_ALLOWED';
73 G_JTF_UNDEF_LINE_SOURCE CONSTANT VARCHAR2(200) := 'OKL_LLA_JTF_LINE_SRC_NOT_FOUND';
74 G_LTY_CODE CONSTANT VARCHAR2(200) := 'G_LTY_CODE';
75 G_STS_UPDATE_TRX_MISSING CONSTANT VARCHAR2(200) := 'OKL_LLA_STS_UPDATE_TRX_MISSING';
76 G_TAS_ID_TOKEN CONSTANT VARCHAR2(100) := 'TAS_ID';
77 G_TRX_ALREADY_PROCESSED CONSTANT VARCHAR2(200) := 'OKL_LLA_TRX_ALREADY_PROCESSED';
78 G_FUTURE_IN_SERVICE_DATE CONSTANT VARCHAR2(200) := 'OKL_LLA_FUTURE_IN_SERVICE_DATE';
79 G_CURRENT_OPEN_PERIOD CONSTANT VARCHAR2(30) := 'OPEN_PERIOD';
80 G_REQUIRED_VALUE CONSTANT VARCHAR2(200) := OKL_API.G_REQUIRED_VALUE;
81 G_COL_NAME_TOKEN CONSTANT VARCHAR2(200) := OKL_API.G_COL_NAME_TOKEN;
82 G_CONV_RATE_NOT_FOUND CONSTANT VARCHAR2(200) := 'OKL_LLA_CONV_RATE_NOT_FOUND';
83 G_FROM_CURRENCY_TOKEN CONSTANT VARCHAR2(200) := 'FROM_CURRENCY';
84 G_TO_CURRENCY_TOKEN CONSTANT VARCHAR2(200) := 'TO_CURRENCY';
85 G_CONV_TYPE_TOKEN CONSTANT VARCHAR2(200) := 'CONVERSION_TYPE';
86 G_CONV_DATE_TOKEN CONSTANT VARCHAR2(200) := 'CONVERSION_DATE';
87 G_SALVAGE_VALUE CONSTANT VARCHAR2(200) := 'OKL_LLA_SALVAGE_VALUE';
88 --Bug# 3143522 : 11.5.10 Subsidies
89 G_SUBSIDY_ADJ_COST_ERROR CONSTANT VARCHAR2(200) := 'OKL_SUBSIDY_ADJ_COST_ERROR';
90 G_BOOK_TYPE_TOKEN CONSTANT VARCHAR2(30) := 'BOOK_TYPE_CODE';
91 G_BULK_BATCH_SIZE CONSTANT NUMBER := 10000;
92
93 ------------------------------------------------------------------------------
94 --Bug# 5946411
95 --Start of comments
96 --
97 --Procedure Name : get_deprn_reserve
98 --Purpose : get_deprn_reserve - used internally
99 --Modification History :
100 --02-May-2007 avsingh Created
101 -- To get accumulated depreciation of an asset
102 -- As per Bug# 6027547 raised on FA, the suggestion
103 -- from FA is to back out depreciation reserve
104 -- if cost is being adjusted in the period of
105 -- of addition.
106 ------------------------------------------------------------------------------
107 PROCEDURE get_deprn_reserve
108 (p_api_version IN NUMBER,
109 p_init_msg_list IN VARCHAR2,
110 x_return_status OUT NOCOPY VARCHAR2,
111 x_msg_count OUT NOCOPY NUMBER,
112 x_msg_data OUT NOCOPY VARCHAR2,
113 p_asset_id IN NUMBER,
114 p_book_type_code IN VARCHAR2,
115 x_asset_deprn_rec OUT NOCOPY FA_API_TYPES.asset_deprn_rec_type) IS
116
117 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
118 l_api_name CONSTANT VARCHAR2(30) := 'GET_DEPRN_RESERVE';
119 l_api_version CONSTANT NUMBER := 1.0;
120
121 l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
122 l_asset_fin_rec FA_API_TYPES.asset_fin_rec_type;
123 l_asset_deprn_rec FA_API_TYPES.asset_deprn_rec_type;
124
125 l_deprn_reserve NUMBER;
126
127 BEGIN
128 --call start activity to set savepoint
129 l_return_status := OKL_API.START_ACTIVITY( substr(l_api_name,1,26),
130 p_init_msg_list,
131 '_PVT',
132 x_return_status);
133 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
134 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
135 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
136 RAISE OKL_API.G_EXCEPTION_ERROR;
137 END IF;
138
139 l_asset_hdr_rec.asset_id := p_asset_id;
140 l_asset_hdr_rec.book_type_code := p_book_type_code;
141
142 if NOT fa_cache_pkg.fazcbc(x_book => l_asset_hdr_rec.book_type_code) then
143 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
144 p_msg_name => 'OKL_LLA_FA_CACHE_ERROR'
145 );
146 Raise OKL_API.G_EXCEPTION_ERROR;
147 end if;
148
149 -- To fetch Depreciation Reserve
150 if not FA_UTIL_PVT.get_asset_deprn_rec
151 (p_asset_hdr_rec => l_asset_hdr_rec ,
152 px_asset_deprn_rec => l_asset_deprn_rec,
153 p_period_counter => NULL,
154 p_mrc_sob_type_code => 'P'
155 ) then
156 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
157 p_msg_name => 'OKL_LLA_FA_DEPRN_REC_ERROR'
158 );
159 Raise OKL_API.G_EXCEPTION_ERROR;
160 end if;
161
162 x_asset_deprn_rec := l_asset_deprn_rec;
163
164 --Call end Activity
165 OKL_API.END_ACTIVITY(x_msg_count, x_msg_data);
166 EXCEPTION
167 WHEN OKL_API.G_EXCEPTION_ERROR Then
168 x_return_status :=OKL_API.HANDLE_EXCEPTIONS
169 (
170 l_api_name,
171 G_PKG_NAME,
172 'OKL_API.G_RET_STS_ERROR',
173 x_msg_count,
174 x_msg_data,
175 '_PVT'
176 );
177 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
178 x_return_status :=OKL_API.HANDLE_EXCEPTIONS
179 (
180 l_api_name,
181 G_PKG_NAME,
182 'OKL_API.G_RET_STS_UNEXP_ERROR',
183 x_msg_count,
184 x_msg_data,
185 '_PVT'
186 );
187 WHEN OTHERS THEN
188 x_return_status :=OKL_API.HANDLE_EXCEPTIONS
189 (
190 l_api_name,
191 G_PKG_NAME,
192 'OTHERS',
193 x_msg_count,
194 x_msg_data,
195 '_PVT'
196 );
197 END get_deprn_reserve;
198 --------------------------------------------------------------------------------------------------------
199 --Bug# 5946411 End
200 ------------------------------------------------------------------------------------------------------
201 ---------------------------------------------------------------------------
202 -- FUNCTION get_rec for: OKC_K_ITEMS_V
203 ---------------------------------------------------------------------------
204 FUNCTION get_cimv_rec (p_cle_id IN NUMBER,
205 x_no_data_found OUT NOCOPY BOOLEAN
206 ) RETURN cimv_rec_type IS
207 CURSOR okc_cimv_csr (p_cle_id IN NUMBER) IS
208 SELECT
209 cim.ID,
210 cim.OBJECT_VERSION_NUMBER,
211 cim.CLE_ID,
212 cim.CHR_ID,
213 cim.CLE_ID_FOR,
214 cim.DNZ_CHR_ID,
215 cim.OBJECT1_ID1,
216 cim.OBJECT1_ID2,
217 cim.JTOT_OBJECT1_CODE,
218 cim.UOM_CODE,
219 cim.EXCEPTION_YN,
220 cim.NUMBER_OF_ITEMS,
221 cim.UPG_ORIG_SYSTEM_REF,
222 cim.UPG_ORIG_SYSTEM_REF_ID,
223 cim.PRICED_ITEM_YN,
224 cim.CREATED_BY,
225 cim.CREATION_DATE,
226 cim.LAST_UPDATED_BY,
227 cim.LAST_UPDATE_DATE,
228 cim.LAST_UPDATE_LOGIN
229 FROM Okc_K_Items_V cim
230 where cle_id = p_cle_id;
231
232 l_cimv_rec cimv_rec_type;
233 BEGIN
234 x_no_data_found := TRUE;
235 -- Get current database values
236 OPEN okc_cimv_csr (p_cle_id);
237 FETCH okc_cimv_csr INTO
238 l_cimv_rec.ID,
239 l_cimv_rec.OBJECT_VERSION_NUMBER,
240 l_cimv_rec.CLE_ID,
241 l_cimv_rec.CHR_ID,
242 l_cimv_rec.CLE_ID_FOR,
243 l_cimv_rec.DNZ_CHR_ID,
244 l_cimv_rec.OBJECT1_ID1,
245 l_cimv_rec.OBJECT1_ID2,
246 l_cimv_rec.JTOT_OBJECT1_CODE,
247 l_cimv_rec.UOM_CODE,
248 l_cimv_rec.EXCEPTION_YN,
249 l_cimv_rec.NUMBER_OF_ITEMS,
250 l_cimv_rec.UPG_ORIG_SYSTEM_REF,
251 l_cimv_rec.UPG_ORIG_SYSTEM_REF_ID,
252 l_cimv_rec.PRICED_ITEM_YN,
253 l_cimv_rec.CREATED_BY,
254 l_cimv_rec.CREATION_DATE,
255 l_cimv_rec.LAST_UPDATED_BY,
256 l_cimv_rec.LAST_UPDATE_DATE,
257 l_cimv_rec.LAST_UPDATE_LOGIN;
258 x_no_data_found := okc_cimv_csr%NOTFOUND;
259 CLOSE okc_cimv_csr;
260 RETURN(l_cimv_rec);
261 END get_cimv_rec;
262 ---------------------------------------------------------------------------
263 -- FUNCTION get_rec for: OKL_TXL_ASSETS_V
264 ---------------------------------------------------------------------------
265 FUNCTION get_talv_rec (
266 p_kle_id IN NUMBER,
267 p_trx_type IN VARCHAR2,
268 x_no_data_found OUT NOCOPY BOOLEAN
269 ) RETURN talv_rec_type IS
270
271 CURSOR okl_talv_csr (p_kle_id IN NUMBER) IS
272 SELECT ID,
273 OBJECT_VERSION_NUMBER,
274 SFWT_FLAG,
275 TAS_ID,
276 ILO_ID,
277 ILO_ID_OLD,
278 IAY_ID,
279 IAY_ID_NEW,
280 KLE_ID,
281 DNZ_KHR_ID,
282 LINE_NUMBER,
283 ORG_ID,
284 TAL_TYPE,
285 ASSET_NUMBER,
286 DESCRIPTION,
287 FA_LOCATION_ID,
288 ORIGINAL_COST,
289 CURRENT_UNITS,
290 MANUFACTURER_NAME,
291 YEAR_MANUFACTURED,
292 SUPPLIER_ID,
293 USED_ASSET_YN,
294 TAG_NUMBER,
295 MODEL_NUMBER,
296 CORPORATE_BOOK,
297 DATE_PURCHASED,
298 DATE_DELIVERY,
299 IN_SERVICE_DATE,
300 LIFE_IN_MONTHS,
301 DEPRECIATION_ID,
302 DEPRECIATION_COST,
303 DEPRN_METHOD,
304 DEPRN_RATE,
305 SALVAGE_VALUE,
306 PERCENT_SALVAGE_VALUE,
307 --Bug# 2981308
308 ASSET_KEY_ID,
309 ATTRIBUTE_CATEGORY,
310 ATTRIBUTE1,
311 ATTRIBUTE2,
312 ATTRIBUTE3,
313 ATTRIBUTE4,
314 ATTRIBUTE5,
315 ATTRIBUTE6,
316 ATTRIBUTE7,
317 ATTRIBUTE8,
318 ATTRIBUTE9,
319 ATTRIBUTE10,
320 ATTRIBUTE11,
321 ATTRIBUTE12,
322 ATTRIBUTE13,
323 ATTRIBUTE14,
324 ATTRIBUTE15,
325 CREATED_BY,
326 CREATION_DATE,
327 LAST_UPDATED_BY,
328 LAST_UPDATE_DATE,
329 LAST_UPDATE_LOGIN,
330 DEPRECIATE_YN,
331 HOLD_PERIOD_DAYS,
332 OLD_SALVAGE_VALUE,
333 NEW_RESIDUAL_VALUE,
334 OLD_RESIDUAL_VALUE,
335 UNITS_RETIRED,
336 COST_RETIRED,
337 SALE_PROCEEDS,
338 REMOVAL_COST,
339 DNZ_ASSET_ID,
340 DATE_DUE,
341 CURRENCY_CODE,
342 CURRENCY_CONVERSION_TYPE,
343 CURRENCY_CONVERSION_RATE,
344 CURRENCY_CONVERSION_DATE
345 FROM Okl_Txl_Assets_V
346 WHERE okl_txl_assets_v.kle_id = p_kle_id
347 and okl_txl_assets_v.tal_type = p_trx_type
348 and exists (select '1' from OKL_TRX_ASSETS
349 where OKL_TRX_ASSETS.TAS_TYPE = p_trx_type
350 and OKL_TRX_ASSETS.TSU_CODE = G_TSU_CODE_ENTERED
351 and OKL_TRX_ASSETS.ID = Okl_txl_assets_v.tas_id);
352 l_talv_rec talv_rec_type;
353 BEGIN
354 x_no_data_found := TRUE;
355 -- Get current database values
356 OPEN okl_talv_csr (p_kle_id);
357 FETCH okl_talv_csr INTO
358 l_talv_rec.ID,
359 l_talv_rec.OBJECT_VERSION_NUMBER,
360 l_talv_rec.SFWT_FLAG,
361 l_talv_rec.TAS_ID,
362 l_talv_rec.ILO_ID,
363 l_talv_rec.ILO_ID_OLD,
364 l_talv_rec.IAY_ID,
365 l_talv_rec.IAY_ID_NEW,
366 l_talv_rec.KLE_ID,
367 l_talv_rec.DNZ_KHR_ID,
368 l_talv_rec.LINE_NUMBER,
369 l_talv_rec.ORG_ID,
370 l_talv_rec.TAL_TYPE,
371 l_talv_rec.ASSET_NUMBER,
372 l_talv_rec.DESCRIPTION,
373 l_talv_rec.FA_LOCATION_ID,
374 l_talv_rec.ORIGINAL_COST,
375 l_talv_rec.CURRENT_UNITS,
376 l_talv_rec.MANUFACTURER_NAME,
377 l_talv_rec.YEAR_MANUFACTURED,
378 l_talv_rec.SUPPLIER_ID,
379 l_talv_rec.USED_ASSET_YN,
380 l_talv_rec.TAG_NUMBER,
381 l_talv_rec.MODEL_NUMBER,
382 l_talv_rec.CORPORATE_BOOK,
383 l_talv_rec.DATE_PURCHASED,
384 l_talv_rec.DATE_DELIVERY,
385 l_talv_rec.IN_SERVICE_DATE,
386 l_talv_rec.LIFE_IN_MONTHS,
387 l_talv_rec.DEPRECIATION_ID,
388 l_talv_rec.DEPRECIATION_COST,
389 l_talv_rec.DEPRN_METHOD,
390 l_talv_rec.DEPRN_RATE,
391 l_talv_rec.SALVAGE_VALUE,
392 l_talv_rec.PERCENT_SALVAGE_VALUE,
393 --Bug# 2981308
394 l_talv_rec.ASSET_KEY_ID,
395 l_talv_rec.ATTRIBUTE_CATEGORY,
396 l_talv_rec.ATTRIBUTE1,
397 l_talv_rec.ATTRIBUTE2,
398 l_talv_rec.ATTRIBUTE3,
399 l_talv_rec.ATTRIBUTE4,
400 l_talv_rec.ATTRIBUTE5,
401 l_talv_rec.ATTRIBUTE6,
402 l_talv_rec.ATTRIBUTE7,
403 l_talv_rec.ATTRIBUTE8,
404 l_talv_rec.ATTRIBUTE9,
405 l_talv_rec.ATTRIBUTE10,
406 l_talv_rec.ATTRIBUTE11,
407 l_talv_rec.ATTRIBUTE12,
408 l_talv_rec.ATTRIBUTE13,
409 l_talv_rec.ATTRIBUTE14,
410 l_talv_rec.ATTRIBUTE15,
411 l_talv_rec.CREATED_BY,
412 l_talv_rec.CREATION_DATE,
413 l_talv_rec.LAST_UPDATED_BY,
414 l_talv_rec.LAST_UPDATE_DATE,
415 l_talv_rec.LAST_UPDATE_LOGIN,
416 l_talv_rec.DEPRECIATE_YN,
417 l_talv_rec.HOLD_PERIOD_DAYS,
418 l_talv_rec.OLD_SALVAGE_VALUE,
419 l_talv_rec.NEW_RESIDUAL_VALUE,
420 l_talv_rec.OLD_RESIDUAL_VALUE,
421 l_talv_rec.UNITS_RETIRED,
422 l_talv_rec.COST_RETIRED,
423 l_talv_rec.SALE_PROCEEDS,
424 l_talv_rec.REMOVAL_COST,
425 l_talv_rec.DNZ_ASSET_ID,
426 l_talv_rec.DATE_DUE,
427 l_talv_rec.CURRENCY_CODE,
428 l_talv_rec.CURRENCY_CONVERSION_TYPE,
429 l_talv_rec.CURRENCY_CONVERSION_RATE,
430 l_talv_rec.CURRENCY_CONVERSION_DATE;
431 x_no_data_found := okl_talv_csr%NOTFOUND;
432 CLOSE okl_talv_csr;
433 RETURN(l_talv_rec);
434 END get_talv_rec;
435
436 ------------------------------------------------------------------------------
437 --Start of comments
438 --
439 --Procedure Name : convert_2functional_currency
440 --Purpose : check to see if the contract currency is same as
441 -- functional currency and convert -- used internally
442 --Modification History :
443 --10-DEC-2002 ssiruvol Created
444 ------------------------------------------------------------------------------
445 PROCEDURE convert_2functional_currency(
446 p_api_version IN NUMBER,
447 p_init_msg_list IN VARCHAR2,
448 x_return_status OUT NOCOPY VARCHAR2,
449 x_msg_count OUT NOCOPY NUMBER,
450 x_msg_data OUT NOCOPY VARCHAR2,
451 p_chr_id IN NUMBER,
452 p_amount IN NUMBER,
453 x_amount OUT NOCOPY NUMBER
454 ) IS
455
456 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
457 l_api_name CONSTANT VARCHAR2(30) := 'CONVERT_2FUNCT_CURRENCY';
458 l_api_version CONSTANT NUMBER := 1.0;
459
460
461 l_func_curr_code OKL_K_HEADERS_FULL_V.CURRENCY_CODE%TYPE;
462 l_chr_curr_code OKL_K_HEADERS_FULL_V.CURRENCY_CODE%TYPE;
463
464 x_contract_currency okl_k_headers_full_v.currency_code%TYPE;
465 x_currency_conversion_type okl_k_headers_full_v.currency_conversion_type%TYPE;
466 x_currency_conversion_rate okl_k_headers_full_v.currency_conversion_rate%TYPE;
467 x_currency_conversion_date okl_k_headers_full_v.currency_conversion_date%TYPE;
468
469 BEGIN
470 x_return_status := OKL_API.G_RET_STS_SUCCESS;
471 --call start activity to set savepoint
472 x_return_status := OKL_API.START_ACTIVITY( substr(l_api_name,1,26),
473 p_init_msg_list,
474 '_PVT',
475 x_return_status);
476 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
477 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
478 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
479 RAISE OKL_API.G_EXCEPTION_ERROR;
480 END IF;
481
482 x_amount := p_amount;
483
484
485 l_chr_curr_code := G_CHR_CURRENCY_CODE;
486 --l_func_curr_code := OKC_CURRENCY_API.GET_OU_CURRENCY(G_CHR_authoring_org_id);
487 l_func_curr_code := G_FUNC_CURRENCY_CODE;
488
489 If ( ( l_func_curr_code IS NOT NULL) AND ( l_chr_curr_code <> l_func_curr_code )) Then
490
491 okl_accounting_util.convert_to_functional_currency(
492 p_khr_id => p_chr_id,
493 p_to_currency => l_func_curr_code,
494 p_transaction_date => G_CHR_START_DATE,
495 p_amount => p_amount,
496 x_contract_currency => x_contract_currency,
497 x_currency_conversion_type => x_currency_conversion_type,
498 x_currency_conversion_rate => x_currency_conversion_rate,
499 x_currency_conversion_date => x_currency_conversion_date,
500 x_converted_amount => x_amount);
501
502 --trap the conversion exception
503 --if conv rate is not found GL API returns negative
504 If (p_amount > 0) and (x_amount < 0) Then
505 --currency conversion rate was not found in Oracle GL
506 OKC_API.set_message(p_app_name => G_APP_NAME,
507 p_msg_name => G_CONV_RATE_NOT_FOUND,
508 p_token1 => G_FROM_CURRENCY_TOKEN,
509 p_token1_value => x_contract_currency,
510 p_token2 => G_TO_CURRENCY_TOKEN,
511 p_token2_value => l_func_curr_code,
512 p_token3 => G_CONV_TYPE_TOKEN,
513 p_token3_value => x_currency_conversion_type,
514 p_token4 => G_CONV_DATE_TOKEN,
515 p_token4_value => to_char(x_currency_conversion_date,'DD-MON-YYYY'));
516 x_return_status := OKC_API.G_RET_STS_ERROR;
517 End If;
518
519
520 End If;
521
522 --Call end Activity
523 OKL_API.END_ACTIVITY(x_msg_count, x_msg_data);
524
525 Exception
526 When OKL_API.G_EXCEPTION_ERROR Then
527
528 x_return_status :=OKL_API.HANDLE_EXCEPTIONS
529 (
530 l_api_name,
531 G_PKG_NAME,
532 'OKL_API.G_RET_STS_ERROR',
533 x_msg_count,
534 x_msg_data,
535 '_PVT'
536 );
537 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
538
539 x_return_status :=OKL_API.HANDLE_EXCEPTIONS
540 (
541 l_api_name,
542 G_PKG_NAME,
543 'OKL_API.G_RET_STS_UNEXP_ERROR',
544 x_msg_count,
545 x_msg_data,
546 '_PVT'
547 );
548 WHEN OTHERS THEN
549
550 x_return_status :=OKL_API.HANDLE_EXCEPTIONS
551 (
552 l_api_name,
553 G_PKG_NAME,
554 'OTHERS',
555 x_msg_count,
556 x_msg_data,
557 '_PVT'
558 );
559
560 END convert_2functional_currency;
561
562
563 ------------------------------------------------------------------------------
564 --Start of comments
565 --
566 --Procedure Name : update_trx_status
567 --Purpose : Update transaction status - used internally
568 --Modification History :
569 --20-Feb-2001 avsingh Created
570 ------------------------------------------------------------------------------
571 PROCEDURE update_trx_status(p_api_version IN NUMBER,
572 p_init_msg_list IN VARCHAR2,
573 x_return_status OUT NOCOPY VARCHAR2,
574 x_msg_count OUT NOCOPY NUMBER,
575 x_msg_data OUT NOCOPY VARCHAR2,
576 p_tas_id IN NUMBER,
577 p_tsu_code IN VARCHAR2) IS
578 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
579 l_api_name CONSTANT VARCHAR2(30) := 'update_trx_status';
580 l_api_version CONSTANT NUMBER := 1.0;
581
582 l_thpv_rec OKL_TRX_ASSETS_PUB.thpv_rec_type;
583 l_thpv_rec_out OKL_TRX_ASSETS_PUB.thpv_rec_type;
584 --cursor to check existing tsu code
585 CURSOR tsu_code_csr (p_tas_id IN NUMBER) is
586 SELECT tsu_code
587 FROM OKL_TRX_ASSETS
588 WHERE id = p_tas_id;
589
590 l_tsu_code OKL_TRX_ASSETS.TSU_CODE%TYPE;
591 BEGIN
592 --call start activity to set savepoint
593 l_return_status := OKL_API.START_ACTIVITY( substr(l_api_name,1,26),
594 p_init_msg_list,
595 '_PVT',
596 x_return_status);
597 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
598 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
599 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
600 RAISE OKL_API.G_EXCEPTION_ERROR;
601 END IF;
602 --check if tsu code has already been updated to processed
603 OPEN tsu_code_csr(p_tas_id => p_tas_id);
604 FETCH tsu_code_csr into l_tsu_code;
605 If tsu_code_csr%NOTFOUND Then
606 --internal error unable to find trransaction record while trying to update status
607 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
608 p_msg_name => G_STS_UPDATE_TRX_MISSING,
609 p_token1 => G_TAS_ID_TOKEN,
610 p_token1_value => p_tas_id
611 );
612 Raise OKL_API.G_EXCEPTION_ERROR;
613 Else
614 If l_tsu_code = p_tsu_code Then
615 --transaction already processed by another user
616 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
617 p_msg_name => G_TRX_ALREADY_PROCESSED
618 );
619 Raise OKL_API.G_EXCEPTION_ERROR;
620 Else
621 l_thpv_rec.id := p_tas_id;
622 l_thpv_rec.tsu_code := p_tsu_code;
623 OKL_TRX_ASSETS_PUB.update_trx_ass_h_def(
624 p_api_version => p_api_version,
625 p_init_msg_list => p_init_msg_list,
626 x_return_status => x_return_status,
627 x_msg_count => x_msg_count,
628 x_msg_data => x_msg_data,
629 p_thpv_rec => l_thpv_rec,
630 x_thpv_rec => l_thpv_rec_out);
631 --dbms_output.put_line('after updating trx status '||x_return_status);
632 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
633 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
634 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
635 RAISE OKL_API.G_EXCEPTION_ERROR;
636 END IF;
637 End If;
638 End If;
639 CLOSE tsu_code_csr;
640 --Call end Activity
641 OKL_API.END_ACTIVITY(x_msg_count, x_msg_data);
642 Exception
643 When OKL_API.G_EXCEPTION_ERROR Then
644 x_return_status :=OKL_API.HANDLE_EXCEPTIONS
645 (
646 l_api_name,
647 G_PKG_NAME,
648 'OKL_API.G_RET_STS_ERROR',
649 x_msg_count,
650 x_msg_data,
651 '_PVT'
652 );
653 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
654 x_return_status :=OKL_API.HANDLE_EXCEPTIONS
655 (
656 l_api_name,
657 G_PKG_NAME,
658 'OKL_API.G_RET_STS_UNEXP_ERROR',
659 x_msg_count,
660 x_msg_data,
661 '_PVT'
662 );
663 WHEN OTHERS THEN
664 x_return_status :=OKL_API.HANDLE_EXCEPTIONS
665 (
666 l_api_name,
667 G_PKG_NAME,
668 'OTHERS',
669 x_msg_count,
670 x_msg_data,
671 '_PVT'
672 );
673 END update_trx_status;
674 --------------------------------------------------------------------------------
675 --Function to calculate Net Book Value of an asset
676 --This function is not being used anywhere for time being
677 --------------------------------------------------------------------------------
678 Procedure Calc_NBV (p_api_version IN NUMBER,
679 p_init_msg_list IN VARCHAR2,
680 x_return_status OUT NOCOPY VARCHAR2,
681 x_msg_count OUT NOCOPY NUMBER,
682 x_msg_data OUT NOCOPY VARCHAR2,
683 p_asset_id IN VARCHAR2,
684 x_nbv OUT NOCOPY Number,
685 x_current_units OUT NOCOPY Number,
686 x_asset_number OUT NOCOPY Varchar2,
687 x_asset_description OUT NOCOPY Varchar2) IS
688
689 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
690 l_api_name CONSTANT varchar2(30) := 'CALC_NBV';
691 l_api_version CONSTANT NUMBER := 1.0;
692
693 l_book_type_code okx_assets_v.Corporate_Book%TYPE;
694
695
696 Cursor asset_cost_csr (p_asset_id IN VARCHAR2) IS
697 Select cost,
698 corporate_book,
699 current_units,
700 name,
701 description
702 from OKX_ASSETS_V
703 where ID1 = p_asset_id
704 and status = 'A'
705 and nvl(start_date_active,sysdate) <= sysdate
706 and nvl(end_date_active,sysdate + 1) > sysdate;
707
708 Cursor Deprn_csr (p_asset_id IN VARCHAR2,
709 p_Book_Type_Code IN VARCHAR2) IS
710 select sum(deprn_amount)
711 from OKX_AST_DPRTNS_V
712 where Asset_id = to_number(p_asset_id)
713 and book_type_code = p_book_type_code
714 and status = 'A'
715 and nvl(start_date_active,sysdate) <= sysdate
716 and nvl(end_date_active,sysdate + 1) > sysdate;
717
718 l_current_asset_cost Number;
719 l_current_units Number;
720 l_corporate_book OKX_ASSETS_V.Corporate_Book%Type;
721 l_total_deprn Number;
722 l_Nbv Number;
723 l_asset_number OKX_ASSETS_V.Name%Type;
724 l_asset_description OKX_ASSETS_V.Description%Type;
725 Begin
726 -----
727 Open asset_cost_csr (p_asset_id);
728 Fetch asset_cost_csr into l_current_asset_cost,
729 l_corporate_book,
730 l_current_units,
731 l_asset_number,
732 l_asset_description;
733 If asset_cost_csr%NOTFOUND Then
734 --dbms_output.put_line('current Cost Not Found');
735 RAISE OKL_API.G_EXCEPTION_ERROR;
736 --error handling
737 End If;
738 Close asset_cost_csr;
739
740 Open Deprn_csr (p_asset_id, l_book_type_code);
741 Fetch Deprn_csr into l_total_deprn;
742 If Deprn_csr%NOTFOUND Then
743 l_total_Deprn := 0;
744 End If;
745 Close Deprn_csr;
746 l_Nbv := l_current_asset_cost - l_total_deprn;
747 x_Nbv := l_Nbv;
748 x_current_units := l_Current_Units;
749 x_asset_number := l_asset_number;
750 x_asset_description := l_asset_description;
751
752 Exception
753 When OKL_API.G_EXCEPTION_ERROR Then
754 Null;
755 --set message and stop
756 -- for testing
757 End Calc_Nbv;
758
759 --Bug# 3783518: start
760 ------------------------------------------------------------------------------
761 --Start of comments
762 --
763 --Procedure Name : validate_release_date
764 --Purpose : Check if Release Contract Start Date
765 -- falls within the current open FA period
766 -- - used internally
767 --Modification History :
768 --08-Jul-2004 rpillay Created
769 ------------------------------------------------------------------------------
770 PROCEDURE validate_release_date
771 (p_api_version IN NUMBER,
772 p_init_msg_list IN VARCHAR2,
773 x_return_status OUT NOCOPY VARCHAR2,
774 x_msg_count OUT NOCOPY NUMBER,
775 x_msg_data OUT NOCOPY VARCHAR2,
776 p_book_type_code IN VARCHAR2,
777 p_release_date IN DATE) IS
778
779 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
780 l_api_name CONSTANT VARCHAR2(30) := 'validate_release_date';
781 l_api_version CONSTANT NUMBER := 1.0;
782
783 CURSOR open_period_cur(p_book_type_code IN VARCHAR2) IS
784 select period_name,
785 calendar_period_open_date,
786 calendar_period_close_date
787 from fa_deprn_periods
788 where book_type_code = p_book_type_code
789 and period_close_date is null;
790
791 open_period_rec open_period_cur%rowtype;
792 l_current_open_period varchar2(240) default null;
793
794 l_icx_date_format varchar2(240);
795 BEGIN
796
797 open open_period_cur(p_book_type_code);
798 fetch open_period_cur into open_period_rec;
799 close open_period_cur;
800
801 IF NOT ( p_release_date BETWEEN open_period_rec.calendar_period_open_date AND
802 open_period_rec.calendar_period_close_date ) THEN
803
804 l_icx_date_format := nvl(fnd_profile.value('ICX_DATE_FORMAT_MASK'),'DD-MON-RRRR');
805
806 l_current_open_period := open_period_rec.period_name||' ('||
807 to_char(open_period_rec.calendar_period_open_date,l_icx_date_format)
808 ||' - '||to_char(open_period_rec.calendar_period_close_date,l_icx_date_format)||')';
809 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
810 p_msg_name => 'OKL_LLA_RELEASE_DATE_INVALID',
811 p_token1 => 'BOOK_TYPE_CODE',
812 p_token1_value => p_book_type_code,
813 p_token2 => 'OPEN_PERIOD',
814 p_token2_value => l_current_open_period
815 );
816 RAISE OKL_API.G_EXCEPTION_ERROR;
817 END IF;
818
819 EXCEPTION
820 WHEN OKL_API.G_EXCEPTION_ERROR Then
821 x_return_status := OKL_API.G_RET_STS_ERROR;
822
823 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
824 x_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
825
826 WHEN OTHERS THEN
827 x_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
828
829 END validate_release_date;
830
831 ------------------------------------------------------------------------------
832 --Start of comments
833 --
834 --Procedure Name : validate_rebook_date
835 --Purpose : Check to ensure that Revision Date does not fall
836 -- after the current open FA period
837 -- - used internally
838 --Modification History :
839 --08-Jul-2004 rpillay Created
840 ------------------------------------------------------------------------------
841 PROCEDURE validate_rebook_date
842 (p_api_version IN NUMBER,
843 p_init_msg_list IN VARCHAR2,
844 x_return_status OUT NOCOPY VARCHAR2,
845 x_msg_count OUT NOCOPY NUMBER,
846 x_msg_data OUT NOCOPY VARCHAR2,
847 p_book_type_code IN VARCHAR2,
848 p_rebook_date IN DATE,
849 p_cost_adjustment IN NUMBER,
850 p_contract_start_date IN DATE) IS
851
852 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
853 l_api_name CONSTANT VARCHAR2(30) := 'validate_rebook_date';
854 l_api_version CONSTANT NUMBER := 1.0;
855
856 CURSOR open_period_cur(p_book_type_code IN VARCHAR2) IS
857 select period_name,
858 calendar_period_open_date,
859 calendar_period_close_date
860 from fa_deprn_periods
861 where book_type_code = p_book_type_code
862 and period_close_date is null;
863
864 open_period_rec open_period_cur%rowtype;
865 l_current_open_period varchar2(240) default null;
866
867 l_icx_date_format varchar2(240);
868 BEGIN
869
870 open open_period_cur(p_book_type_code);
871 fetch open_period_cur into open_period_rec;
872 close open_period_cur;
873
874 -- Revision Date should be in the current or a prior FA period
875 IF (p_rebook_date > open_period_rec.calendar_period_close_date) THEN
876
877 l_icx_date_format := nvl(fnd_profile.value('ICX_DATE_FORMAT_MASK'),'DD-MON-RRRR');
878
879 l_current_open_period := open_period_rec.period_name||' ('||
880 to_char(open_period_rec.calendar_period_open_date,l_icx_date_format)
881 ||' - '||to_char(open_period_rec.calendar_period_close_date,l_icx_date_format)||')';
882 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
883 p_msg_name => 'OKL_LLA_REBOOK_DATE_INVALID',
884 p_token1 => 'BOOK_TYPE_CODE',
885 p_token1_value => p_book_type_code,
886 p_token2 => 'OPEN_PERIOD',
887 p_token2_value => l_current_open_period
888 );
889 RAISE OKL_API.G_EXCEPTION_ERROR;
890 END IF;
891
892 -- Revision Date should be the same as Contract Start Date inorder to make an
893 -- asset cost change
894 IF (p_cost_adjustment IS NOT NULL AND
895 p_contract_start_date <> p_rebook_date) THEN
896
897 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
898 p_msg_name => 'OKL_LLA_VALIDATE_DEPR_COST_CHG'
899 );
900 RAISE OKL_API.G_EXCEPTION_ERROR;
901 END IF;
902
903 EXCEPTION
904 WHEN OKL_API.G_EXCEPTION_ERROR Then
905 x_return_status := OKL_API.G_RET_STS_ERROR;
906
907 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
908 x_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
909
910 WHEN OTHERS THEN
911 x_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
912
913 END validate_rebook_date;
914 --Bug# 3783518: end
915 --------------------------------------------------------------------------------
916 --Start of Comments
917 --Procedure Name : FIXED_ASSET_ADJUST
918 --Description : Calls FA adJUSTMENTS api to adjust the book costs
919 --History :
920 -- 28-Nov-2001 ashish.singh Created
921 -- Notes :
922 -- IN Parameters
923 -- p_asset_id - asset for which cost is to be adjusted
924 -- p_book_type_code - Book in whic cost cost is to be adjusted
925 -- p_adjust_cost - cost to be adjusted
926 -- Bug# 2657558
927 -- p_adj_salvage_value - salvage value to be adjusted
928 --
929 -- Bug# 6373605 (OKL.R12.B SLA CRs
930 -- p_sla_source_header_id IN Number,
931 -- ID of source OKL_TRX_ASSETS record
932 -- p_sla_source_header_table IN Varchar2,
933 -- 'OKL_TRX_ASSETS'
934 -- p_sla_source_try_id IN Number,
935 -- OKL_TRX_ASSETS.try_id (transaction type id)
936 -- p_sla_source_line_id IN Number,
937 -- ID of line table (OKL_TXL_ASSETS_B or
938 -- OKL_TXD_ASSETS_B
939 -- p_sla_source_line_table IN Varchar2,
940 -- OKL_TXL_ASSETS_B or OKL_TXD_ASSETS_B
941 -- p_sla_source_chr_id IN Number,
942 -- Contract id of the contract on which
943 -- source transaction happened
944 -- p_sla_source_kle_id IN Number,
945 -- Financial asset line id (lse_id = 33)
946 -- p_sla_asset_chr_id IN Number,
947 -- Contract on which asset is present
948 -- at the time of transaction (in case of
949 -- online rebook transaction is against the rebook
950 -- copy contract whereas the asset is on
951 -- original contract
952 --
953 -- OUT Parameters
954 -- x_asset_fin_rec - asset financial info record with adjusted
955 -- costs
956 --End of Comments
957 --------------------------------------------------------------------------------
958 PROCEDURE FIXED_ASSET_ADJUST_COST(p_api_version IN NUMBER,
959 p_init_msg_list IN VARCHAR2,
960 x_return_status OUT NOCOPY VARCHAR2,
961 x_msg_count OUT NOCOPY NUMBER,
962 x_msg_data OUT NOCOPY VARCHAR2,
963 p_chr_id IN NUMBER,
964 p_asset_id IN NUMBER,
965 p_book_type_code IN OKX_AST_BKS_V.BOOK_TYPE_CODE%TYPE,
966 p_adjust_cost IN NUMBER,
967 --Bug# 2657558
968 p_adj_salvage_value IN NUMBER,
969 --Bug# 2981308
970 p_adj_percent_sv IN NUMBER,
971 --Bug# 3156924
972 p_trans_number IN VARCHAR2,
973 p_calling_interface IN VARCHAR2,
974 --Bug Fix# 2925461
975 p_adj_date IN DATE,
976 --Bug# 6373605--SLA populate source
977 p_sla_source_header_id IN Number,
978 p_sla_source_header_table IN Varchar2,
979 p_sla_source_try_id IN Number,
980 p_sla_source_line_id IN Number,
981 p_sla_source_line_table IN Varchar2,
982 --source transaction contract id
983 p_sla_source_chr_id IN Number,
984 p_sla_source_kle_id IN Number,
985 --contract id to which the asset belongs
986 p_sla_asset_chr_id IN Number,
987 --Bug# 6373605--SLA populate source
988 --Bug# 4028371
989 x_fa_trx_date OUT NOCOPY DATE,
990 x_asset_fin_rec OUT NOCOPY FA_API_TYPES.asset_fin_rec_type) is
991
992 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
993 l_api_name CONSTANT varchar2(30) := 'FIXED_ASSET_ADJ_CST';
994 l_api_version CONSTANT NUMBER := 1.0;
995
996 l_trans_rec FA_API_TYPES.trans_rec_type;
997 l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
998 l_asset_fin_rec_adj FA_API_TYPES.asset_fin_rec_type;
999 l_asset_fin_rec_new FA_API_TYPES.asset_fin_rec_type;
1000 l_asset_fin_mrc_tbl_new FA_API_TYPES.asset_fin_tbl_type;
1001 l_inv_trans_rec FA_API_TYPES.inv_trans_rec_type;
1002 l_inv_tbl FA_API_TYPES.inv_tbl_type;
1003 l_asset_deprn_rec_adj FA_API_TYPES.asset_deprn_rec_type;
1004 l_asset_deprn_rec_new FA_API_TYPES.asset_deprn_rec_type;
1005 l_asset_deprn_mrc_tbl_new FA_API_TYPES.asset_deprn_tbl_type;
1006 l_inv_rec FA_API_TYPES.inv_rec_type;
1007 l_asset_deprn_rec FA_API_TYPES.asset_deprn_rec_type;
1008 l_group_recalss_option_rec FA_API_TYPES.group_reclass_options_rec_type;
1009
1010 l_asset_id NUMBER;
1011 l_book_type_code OKX_AST_BKS_V.BOOK_TYPE_CODE%TYPE;
1012 l_adjust_cost NUMBER;
1013 --Bug # 2657558
1014 l_adj_salvage_value NUMBER;
1015 --Bug# 2981308
1016 l_adj_percent_sv NUMBER;
1017
1018 --Bug# 5946411: parameters for getting depreciation reserve
1019 l_fa_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
1020 l_fa_asset_deprn_rec FA_API_TYPES.asset_deprn_rec_type;
1021
1022 --Bug# 6373605 begin
1023 l_fxhv_rec okl_sla_acc_sources_pvt.fxhv_rec_type;
1024 l_fxlv_rec okl_sla_acc_sources_pvt.fxlv_rec_type;
1025 --Bug# 6373605 end
1026
1027 Begin
1028
1029 x_return_status := OKL_API.G_RET_STS_SUCCESS;
1030 l_asset_id := p_asset_id;
1031 l_book_type_code := p_book_type_code;
1032 l_adjust_cost := p_adjust_cost;
1033 --Bug # 2657558
1034 l_adj_salvage_value := p_adj_salvage_value;
1035
1036 --Bug# 2981308 :
1037 l_adj_percent_sv := p_adj_percent_sv;
1038
1039 -- Call start_activity to create savepoint, check compatibility
1040 -- and initialize message list
1041 x_return_status := OKL_API.START_ACTIVITY (
1042 l_api_name
1043 ,p_init_msg_list
1044 ,'_PVT'
1045 ,x_return_status);
1046 -- Check if activity started successfully
1047 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
1048 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1049 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
1050 RAISE OKL_API.G_EXCEPTION_ERROR;
1051 END IF;
1052
1053 --dbms_output.enable(1000000);
1054
1055 --Bug# 2726366
1056 --FA_SRVR_MSG.Init_Server_Message;
1057 --FA_DEBUG_PKG.Initialize;
1058
1059 -- asset header info
1060 l_asset_hdr_rec.asset_id := l_asset_id ;
1061 l_asset_hdr_rec.book_type_code := l_book_type_code;
1062
1063 -- Bug# 3783518 - This api will be called only to adjust the
1064 -- the cost and salvage value to zero for assets on
1065 -- DF/ST Lease, immediately after creation of the asset, so
1066 -- the cost adjustment is to be Expensed in the current open period.
1067
1068 --Bug# 3156924 :
1069 l_trans_rec.transaction_name := substr(p_trans_number,1,20); --optional
1070 l_trans_rec.calling_interface := p_calling_interface; --optional
1071
1072 /*
1073 -- fin info
1074 convert_2functional_currency( p_chr_id,
1075 l_adjust_cost,
1076 l_asset_fin_rec_adj.cost);
1077
1078 --l_asset_fin_rec_adj.cost := l_adjust_cost;
1079 convert_2functional_currency( p_chr_id,
1080 l_adj_salvage_value,
1081 l_asset_fin_rec_adj.salvage_value);
1082
1083 */
1084
1085 --Bug # 2657558
1086 l_asset_fin_rec_adj.salvage_value := l_adj_salvage_value;
1087 l_asset_fin_rec_adj.cost := l_adjust_cost;
1088 --Bug# 2981308
1089 l_asset_fin_rec_adj.percent_salvage_value := l_adj_percent_sv;
1090 --Bug# 6373605
1091 l_asset_fin_rec_adj.contract_id := p_sla_asset_chr_id;
1092
1093 --Bug# 6804043: In R12 codeline, do not back out depreciation reserve
1094 -- when cost adjustment is done in period of addition
1095 /*
1096
1097 ---------------------------------------------------------------------------------------------
1098 --Bug# 5946411 :
1099 -- If adjustment being done in period of addition depreciation reserve needs to be backed out
1100 ---------------------------------------------------------------------------------------------
1101 --1. Check if adjustment is being made in the period of addition of the asset
1102 ---------------------------------------------------------------------------------------------
1103 l_fa_asset_hdr_rec.asset_id := l_asset_id;
1104 l_fa_asset_hdr_rec.book_type_code := l_book_type_code;
1105
1106 If NOT fa_cache_pkg.fazcbc(x_book => l_fa_asset_hdr_rec.book_type_code) then
1107 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
1108 p_msg_name => 'OKL_LLA_FA_CACHE_ERROR'
1109 );
1110 Raise OKL_API.G_EXCEPTION_ERROR;
1111 end if;
1112
1113 If not FA_ASSET_VAL_PVT.validate_period_of_addition
1114 (p_asset_id => l_fa_asset_hdr_rec.asset_id,
1115 p_book => l_fa_asset_hdr_rec.book_type_code,
1116 p_mode => 'ABSOLUTE',
1117 px_period_of_addition => l_fa_asset_hdr_rec.period_of_addition
1118 ) then
1119 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
1120 p_msg_name => 'OKL_LLA_FA_POA_ERROR'
1121 );
1122 Raise OKL_API.G_EXCEPTION_ERROR;
1123 end if;
1124
1125
1126 If nvl(l_fa_asset_hdr_rec.period_of_addition,'N') = 'Y' Then
1127 --------------------------------------
1128 --2. Get the depreciation reserve
1129 --------------------------------------
1130 get_deprn_reserve
1131 (p_api_version => p_api_version,
1132 p_init_msg_list => p_init_msg_list,
1133 x_return_status => x_return_status,
1134 x_msg_count => x_msg_count,
1135 x_msg_data => x_msg_data,
1136 p_asset_id => l_asset_id,
1137 p_book_type_code => l_book_type_code,
1138 x_asset_deprn_rec => l_fa_asset_deprn_rec);
1139
1140 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
1141 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1142 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
1143 RAISE OKL_API.G_EXCEPTION_ERROR;
1144 END IF;
1145
1146 If l_fa_asset_deprn_rec.deprn_reserve > 0 then
1147 l_asset_deprn_rec_adj.deprn_reserve := (-1) * l_fa_asset_deprn_rec.deprn_reserve;
1148 End If;
1149 If l_fa_asset_deprn_rec.ytd_deprn > 0 then
1150 l_asset_deprn_rec_adj.ytd_deprn := (-1) * l_fa_asset_deprn_rec.ytd_deprn;
1151 End If;
1152 If l_fa_asset_deprn_rec.prior_fy_expense > 0 then
1153 l_asset_deprn_rec_adj.prior_fy_expense := (-1) * l_fa_asset_deprn_rec.prior_fy_expense;
1154 End If;
1155 If l_fa_asset_deprn_rec.bonus_ytd_deprn > 0 then
1156 l_asset_deprn_rec_adj.bonus_ytd_deprn := (-1) * l_fa_asset_deprn_rec.bonus_ytd_deprn;
1157 End If;
1158 If l_fa_asset_deprn_rec.bonus_deprn_reserve > 0 then
1159 l_asset_deprn_rec_adj.bonus_deprn_reserve := (-1) * l_fa_asset_deprn_rec.bonus_deprn_reserve;
1160 End If;
1161
1162 End If;
1163 --End Bug# 5946411
1164 */
1165 --End Bug# 6804043
1166
1167 FA_ADJUSTMENT_PUB.do_adjustment
1168 (p_api_version => p_api_version,
1169 p_init_msg_list => p_init_msg_list,
1170 p_commit => FND_API.G_FALSE,
1171 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
1172 x_return_status => x_return_status,
1173 x_msg_count => x_msg_count,
1174 x_msg_data => x_msg_data,
1175 --Bug# 3156924
1176 --p_calling_fn => l_api_name,
1177 p_calling_fn => p_calling_interface,
1178 px_trans_rec => l_trans_rec,
1179 px_asset_hdr_rec => l_asset_hdr_rec,
1180 p_asset_fin_rec_adj => l_asset_fin_rec_adj,
1181 x_asset_fin_rec_new => l_asset_fin_rec_new,
1182 x_asset_fin_mrc_tbl_new => l_asset_fin_mrc_tbl_new,
1183 px_inv_trans_rec => l_inv_trans_rec,
1184 px_inv_tbl => l_inv_tbl,
1185 p_asset_deprn_rec_adj => l_asset_deprn_rec_adj,
1186 x_asset_deprn_rec_new => l_asset_deprn_rec_new,
1187 x_asset_deprn_mrc_tbl_new => l_asset_deprn_mrc_tbl_new,
1188 p_group_reclass_options_rec => l_group_recalss_option_rec
1189 );
1190
1191 --dbms_output.put_line('After Call to FA ADJUST API "'||l_return_status||'"');
1192 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
1193 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1194 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
1195 RAISE OKL_API.G_EXCEPTION_ERROR;
1196 END IF;
1197 --Bug# 4028371
1198 x_fa_trx_date := l_trans_rec.transaction_date_entered;
1199 --bug# 6373605 -- call populate sla sources
1200 l_fxhv_rec.source_id := p_sla_source_header_id;
1201 l_fxhv_rec.source_table := p_sla_source_header_table;
1202 l_fxhv_rec.khr_id := p_sla_source_chr_id;
1203 l_fxhv_rec.try_id := p_sla_source_try_id;
1204
1205 l_fxlv_rec.source_id := p_sla_source_line_id;
1206 l_fxlv_rec.source_table := p_sla_source_line_table;
1207 l_fxlv_rec.kle_id := p_sla_source_kle_id;
1208
1209 l_fxlv_rec.asset_id := l_asset_hdr_rec.asset_id;
1210 l_fxlv_rec.fa_transaction_id := l_trans_rec.transaction_header_id;
1211 l_fxlv_rec.asset_book_type_name := l_asset_hdr_rec.book_type_code;
1212
1213
1214
1215 OKL_SLA_ACC_SOURCES_PVT.populate_sources(
1216 p_api_version => p_api_version
1217 ,p_init_msg_list => p_init_msg_list
1218 ,p_fxhv_rec => l_fxhv_rec
1219 ,p_fxlv_rec => l_fxlv_rec
1220 ,x_return_status => x_return_status
1221 ,x_msg_count => x_msg_count
1222 ,x_msg_data => x_msg_data
1223 );
1224 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
1225 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1226 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
1227 RAISE OKL_API.G_EXCEPTION_ERROR;
1228 END IF;
1229
1230 --bug# 6373605 -- call populate SLA sources
1231
1232 OKL_API.END_ACTIVITY (x_msg_count,
1233 x_msg_data );
1234 EXCEPTION
1235 WHEN OKL_API.G_EXCEPTION_ERROR THEN
1236 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
1237 l_api_name,
1238 G_PKG_NAME,
1239 'OKL_API.G_RET_STS_ERROR',
1240 x_msg_count,
1241 x_msg_data,
1242 '_PVT');
1243 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1244 --dbms_output.put_line('Raising unexpected here...');
1245 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
1246 l_api_name,
1247 G_PKG_NAME,
1248 'OKL_API.G_RET_STS_UNEXP_ERROR',
1249 x_msg_count,
1250 x_msg_data,
1251 '_PVT');
1252 WHEN OTHERS THEN
1253 --dbms_output.put_line('Raising when others here...'||SQLERRM);
1254 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
1255 l_api_name,
1256 G_PKG_NAME,
1257 'OTHERS',
1258 x_msg_count,
1259 x_msg_data,
1260 '_PVT');
1261 END FIXED_ASSET_ADJUST_COST;
1262 --------------------------------------------------------------------------------
1263 --Start of Comments
1264 --Procedure Name : FIXED_ASSET_ADJUST
1265 --Description : Calls FA adJUSTMENTS api to adjust the book deprn parameters
1266 --History :
1267 -- 28-Nov-2001 ashish.singh Created
1268 -- Notes :
1269 -- IN Parameters
1270 -- p_asset_id - asset for which cost is to be adjusted
1271 -- p_book_type_code - Book in whic cost cost is to be adjusted
1272 -- p_asset_fin_rec_adj - asset fin rec to adjust
1273 --
1274 -- Bug# 6373605 -R12.B SAL CRs
1275 -- New IN parameters as descriped earlier in
1276 -- FIXED_ASSET_ADJUST_COST
1277 --
1278 -- OUT Parameters
1279 -- x_asset_fin_rec_new - asset financial info record with adjusted
1280 --
1281 --End of Comments
1282 --------------------------------------------------------------------------------
1283 PROCEDURE FIXED_ASSET_ADJUST (p_api_version IN NUMBER,
1284 p_init_msg_list IN VARCHAR2,
1285 x_return_status OUT NOCOPY VARCHAR2,
1286 x_msg_count OUT NOCOPY NUMBER,
1287 x_msg_data OUT NOCOPY VARCHAR2,
1288 p_chr_id IN NUMBER,
1289 p_asset_id IN NUMBER,
1290 p_book_type_code IN OKX_AST_BKS_V.BOOK_TYPE_CODE%TYPE,
1291 p_asset_fin_rec_adj IN FA_API_TYPES.asset_fin_rec_type,
1292 --Bug Fix# 2925461
1293 p_adj_date IN DATE,
1294 --Bug# 3156924
1295 p_trans_number IN VARCHAR2,
1296 p_calling_interface IN VARCHAR2,
1297 --Bug# 3156924
1298 --Bug# 6373605--SLA populate source
1299 p_sla_source_header_id IN Number,
1300 p_sla_source_header_table IN Varchar2,
1301 p_sla_source_try_id IN Number,
1302 p_sla_source_line_id IN Number,
1303 p_sla_source_line_table IN Varchar2,
1304 p_sla_source_chr_id IN Number,
1305 p_sla_source_kle_id IN Number,
1306 --Bug# 6373605--SLA populate source
1307 --Bug# 4028371
1308 x_fa_trx_date OUT NOCOPY DATE,
1309 x_asset_fin_rec_new OUT NOCOPY FA_API_TYPES.asset_fin_rec_type) is
1310
1311 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
1312 l_api_name CONSTANT varchar2(30) := 'FIXED_ASSET_ADJUST';
1313 l_api_version CONSTANT NUMBER := 1.0;
1314
1315 l_trans_rec FA_API_TYPES.trans_rec_type;
1316 l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
1317 l_asset_fin_rec_adj FA_API_TYPES.asset_fin_rec_type;
1318 l_asset_fin_rec_new FA_API_TYPES.asset_fin_rec_type;
1319 l_asset_fin_mrc_tbl_new FA_API_TYPES.asset_fin_tbl_type;
1320 l_inv_trans_rec FA_API_TYPES.inv_trans_rec_type;
1321 l_inv_tbl FA_API_TYPES.inv_tbl_type;
1322 l_asset_deprn_rec_adj FA_API_TYPES.asset_deprn_rec_type;
1323 l_asset_deprn_rec_new FA_API_TYPES.asset_deprn_rec_type;
1324 l_asset_deprn_mrc_tbl_new FA_API_TYPES.asset_deprn_tbl_type;
1325 l_inv_rec FA_API_TYPES.inv_rec_type;
1326 l_asset_deprn_rec FA_API_TYPES.asset_deprn_rec_type;
1327 l_group_recalss_option_rec FA_API_TYPES.group_reclass_options_rec_type;
1328
1329 l_asset_id NUMBER;
1330 l_book_type_code OKX_AST_BKS_V.BOOK_TYPE_CODE%TYPE;
1331
1332 l_mesg_len NUMBER;
1333 l_mesg Varchar2(2000);
1334
1335 --Bug# 5946411: parameters for getting depreciation reserve
1336 l_fa_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
1337 l_fa_asset_deprn_rec FA_API_TYPES.asset_deprn_rec_type;
1338
1339 --Bug# 6373605 begin
1340 l_fxhv_rec okl_sla_acc_sources_pvt.fxhv_rec_type;
1341 l_fxlv_rec okl_sla_acc_sources_pvt.fxlv_rec_type;
1342 --Bug# 6373605 end
1343
1344 Begin
1345
1346 x_return_status := OKL_API.G_RET_STS_SUCCESS;
1347 l_asset_id := p_asset_id;
1348 l_book_type_code := p_book_type_code;
1349
1350 -- Call start_activity to create savepoint, check compatibility
1351 -- and initialize message list
1352 x_return_status := OKL_API.START_ACTIVITY (
1353 l_api_name
1354 ,p_init_msg_list
1355 ,'_PVT'
1356 ,x_return_status);
1357 -- Check if activity started successfully
1358 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
1359 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1360 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
1361 RAISE OKL_API.G_EXCEPTION_ERROR;
1362 END IF;
1363
1364 --dbms_output.enable(1000000);
1365
1366 --bug# 2726366
1367 --FA_SRVR_MSG.Init_Server_Message;
1368 --FA_DEBUG_PKG.Initialize;
1369
1370 -- asset header info
1371 l_asset_hdr_rec.asset_id := l_asset_id ;
1372 l_asset_hdr_rec.book_type_code := l_book_type_code;
1373
1374 --------------
1375 --Bug# 3156924
1376 --------------
1377 l_trans_rec.transaction_name := substr(p_trans_number,1,20);
1378 l_trans_rec.calling_interface := p_calling_interface;
1379
1380 --------------
1381 --Bug# 3783518
1382 --------------
1383 l_trans_rec.transaction_subtype := 'AMORTIZED';
1384 l_trans_rec.amortization_start_date := p_adj_date;
1385
1386 l_asset_fin_rec_adj := p_asset_fin_rec_adj;
1387
1388 /*
1389 -- convert to functional currency if need be.
1390 convert_2functional_currency( p_chr_id,
1391 p_asset_fin_rec_adj.cost,
1392 l_asset_fin_rec_adj.cost);
1393
1394 convert_2functional_currency( p_chr_id,
1395 p_asset_fin_rec_adj.salvage_value,
1396 l_asset_fin_rec_adj.salvage_value);
1397
1398 */
1399
1400 --Bug# 6804043: In R12 codeline, do not back out depreciation reserve
1401 -- when cost adjustment is done in period of addition
1402 /*
1403 ---------------------------------------------------------------------------------------------
1404 --Bug# 5946411 :
1405 -- If adjustment being done in period of addition depreciation reserve needs to be backed out
1406 ---------------------------------------------------------------------------------------------
1407 --1. Check if adjustment is being made in the period of addition of the asset
1408 ---------------------------------------------------------------------------------------------
1409 l_fa_asset_hdr_rec.asset_id := l_asset_id;
1410 l_fa_asset_hdr_rec.book_type_code := l_book_type_code;
1411
1412 If NOT fa_cache_pkg.fazcbc(x_book => l_fa_asset_hdr_rec.book_type_code) then
1413 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
1414 p_msg_name => 'OKL_LLA_FA_CACHE_ERROR'
1415 );
1416 Raise OKL_API.G_EXCEPTION_ERROR;
1417 end if;
1418
1419 If not FA_ASSET_VAL_PVT.validate_period_of_addition
1420 (p_asset_id => l_fa_asset_hdr_rec.asset_id,
1421 p_book => l_fa_asset_hdr_rec.book_type_code,
1422 p_mode => 'ABSOLUTE',
1423 px_period_of_addition => l_fa_asset_hdr_rec.period_of_addition
1424 ) then
1425 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
1426 p_msg_name => 'OKL_LLA_FA_POA_ERROR'
1427 );
1428 Raise OKL_API.G_EXCEPTION_ERROR;
1429 end if;
1430
1431
1432 If nvl(l_fa_asset_hdr_rec.period_of_addition,'N') = 'Y' Then
1433 --------------------------------------
1434 --2. Get the depreciation reserve
1435 --------------------------------------
1436 get_deprn_reserve
1437 (p_api_version => p_api_version,
1438 p_init_msg_list => p_init_msg_list,
1439 x_return_status => x_return_status,
1440 x_msg_count => x_msg_count,
1441 x_msg_data => x_msg_data,
1442 p_asset_id => l_asset_id,
1443 p_book_type_code => l_book_type_code,
1444 x_asset_deprn_rec => l_fa_asset_deprn_rec);
1445
1446 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
1447 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1448 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
1449 RAISE OKL_API.G_EXCEPTION_ERROR;
1450 END IF;
1451
1452 If l_fa_asset_deprn_rec.deprn_reserve > 0 then
1453 l_asset_deprn_rec_adj.deprn_reserve := (-1) * l_fa_asset_deprn_rec.deprn_reserve;
1454 End If;
1455 If l_fa_asset_deprn_rec.ytd_deprn > 0 then
1456 l_asset_deprn_rec_adj.ytd_deprn := (-1) * l_fa_asset_deprn_rec.ytd_deprn;
1457 End If;
1458 If l_fa_asset_deprn_rec.prior_fy_expense > 0 then
1459 l_asset_deprn_rec_adj.prior_fy_expense := (-1) * l_fa_asset_deprn_rec.prior_fy_expense;
1460 End If;
1461 If l_fa_asset_deprn_rec.bonus_ytd_deprn > 0 then
1462 l_asset_deprn_rec_adj.bonus_ytd_deprn := (-1) * l_fa_asset_deprn_rec.bonus_ytd_deprn;
1463 End If;
1464 If l_fa_asset_deprn_rec.bonus_deprn_reserve > 0 then
1465 l_asset_deprn_rec_adj.bonus_deprn_reserve := (-1) * l_fa_asset_deprn_rec.bonus_deprn_reserve;
1466 End If;
1467 End If;
1468 --End Bug# 5946411
1469 */
1470 --End Bug# 6804043
1471
1472 FA_ADJUSTMENT_PUB.do_adjustment
1473 (p_api_version => p_api_version,
1474 p_init_msg_list => p_init_msg_list,
1475 p_commit => FND_API.G_FALSE,
1476 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
1477 x_return_status => x_return_status,
1478 x_msg_count => x_msg_count,
1479 x_msg_data => x_msg_data,
1480 --Bug# 3156924
1481 --p_calling_fn => l_api_name,
1482 p_calling_fn => p_calling_interface,
1483 px_trans_rec => l_trans_rec,
1484 px_asset_hdr_rec => l_asset_hdr_rec,
1485 p_asset_fin_rec_adj => l_asset_fin_rec_adj,
1486 x_asset_fin_rec_new => x_asset_fin_rec_new,
1487 x_asset_fin_mrc_tbl_new => l_asset_fin_mrc_tbl_new,
1488 px_inv_trans_rec => l_inv_trans_rec,
1489 px_inv_tbl => l_inv_tbl,
1490 p_asset_deprn_rec_adj => l_asset_deprn_rec_adj,
1491 x_asset_deprn_rec_new => l_asset_deprn_rec_new,
1492 x_asset_deprn_mrc_tbl_new => l_asset_deprn_mrc_tbl_new,
1493 p_group_reclass_options_rec => l_group_recalss_option_rec
1494 );
1495
1496 --dbms_output.put_line('After Call to FA ADJUST API "'||x_return_status||'"');
1497 -- if (x_return_status <> FND_API.G_RET_STS_SUCCESS) then
1498
1499 -- x_msg_count := fnd_msg_pub.count_msg;
1500
1501 -- if x_msg_count > 0 then
1502
1503 -- l_mesg := chr(10) || substr(fnd_msg_pub.get
1504 -- (fnd_msg_pub.G_FIRST, fnd_api.G_FALSE),
1505 -- 1, 512);
1506
1507 -- for i in 1..2 loop -- (l_mesg_count - 1) loop
1508 -- l_mesg := l_mesg || chr(10) ||
1509 -- substr(fnd_msg_pub.get
1510 -- (fnd_msg_pub.G_NEXT,
1511 -- fnd_api.G_FALSE), 1, 512);
1512 -- end loop;
1513
1514 -- fnd_msg_pub.delete_msg();
1515
1516 -- l_mesg_len := length(l_mesg);
1517 -- for i in 1..ceil(l_mesg_len/255) loop
1518 -- dbms_output.put_line(substr(l_mesg, ((i*255)-254), 255));
1519 -- end loop;
1520 -- end if;
1521
1522 -- else
1523
1524 --dbms_output.put_line('SUCCESS');
1525 --dbms_output.put_line('THID' ||
1526 --to_char(l_trans_rec.transaction_header_id));
1527
1528 -- end if;
1529
1530 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
1531 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1532 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
1533 RAISE OKL_API.G_EXCEPTION_ERROR;
1534 END IF;
1535 --Bug# 4028371
1536 x_fa_trx_date := l_trans_rec.transaction_date_entered;
1537 --bug# 6373605 -- call populate sla sources
1538 l_fxhv_rec.source_id := p_sla_source_header_id;
1539 l_fxhv_rec.source_table := p_sla_source_header_table;
1540 l_fxhv_rec.khr_id := p_sla_source_chr_id;
1541 l_fxhv_rec.try_id := p_sla_source_try_id;
1542
1543 l_fxlv_rec.source_id := p_sla_source_line_id;
1544 l_fxlv_rec.source_table := p_sla_source_line_table;
1545 l_fxlv_rec.kle_id := p_sla_source_kle_id;
1546
1547 l_fxlv_rec.asset_id := l_asset_hdr_rec.asset_id;
1548 l_fxlv_rec.fa_transaction_id := l_trans_rec.transaction_header_id;
1549 l_fxlv_rec.asset_book_type_name := l_asset_hdr_rec.book_type_code;
1550
1551 OKL_SLA_ACC_SOURCES_PVT.populate_sources(
1552 p_api_version => p_api_version
1553 ,p_init_msg_list => p_init_msg_list
1554 ,p_fxhv_rec => l_fxhv_rec
1555 ,p_fxlv_rec => l_fxlv_rec
1556 ,x_return_status => x_return_status
1557 ,x_msg_count => x_msg_count
1558 ,x_msg_data => x_msg_data
1559 );
1560 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
1561 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1562 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
1563 RAISE OKL_API.G_EXCEPTION_ERROR;
1564 END IF;
1565 --bug# 6373605 -- call populate SLA sources
1566
1567 OKL_API.END_ACTIVITY (x_msg_count,
1568 x_msg_data );
1569 EXCEPTION
1570 WHEN OKL_API.G_EXCEPTION_ERROR THEN
1571 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
1572 l_api_name,
1573 G_PKG_NAME,
1574 'OKL_API.G_RET_STS_ERROR',
1575 x_msg_count,
1576 x_msg_data,
1577 '_PVT');
1578 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1579 --dbms_output.put_line('Raising unexpected here...');
1580 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
1581 l_api_name,
1582 G_PKG_NAME,
1583 'OKL_API.G_RET_STS_UNEXP_ERROR',
1584 x_msg_count,
1585 x_msg_data,
1586 '_PVT');
1587 WHEN OTHERS THEN
1588 --dbms_output.put_line('Raising when others here...'||SQLERRM);
1589 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
1590 l_api_name,
1591 G_PKG_NAME,
1592 'OTHERS',
1593 x_msg_count,
1594 x_msg_data,
1595 '_PVT');
1596 END FIXED_ASSET_ADJUST;
1597 --------------------------------------------------------------------------------
1598 --Start of Comments
1599 --Function Name : CALC_DEPRN_COST (Local) Bug fix# 2788745
1600 --Description : Local function to calculate effective depreciation cost
1601 -- for an asset
1602 --History :
1603 -- 05-Feb-2003 ashish.singh Created
1604 -- 11-Sep-2003 avsingh Bug# 3143522 : Converted into procedure for
1605 -- subsidies enhancement
1606 -- 09-Jun-2005 avsingh Bug# 4414408
1607 -- Performance fix-avoid evaluation of formulae
1608 --End of Comments
1609 --------------------------------------------------------------------------------
1610 Procedure Calc_Deprn_Cost ( p_api_version IN NUMBER,
1611 p_init_msg_list IN VARCHAR2,
1612 x_return_status OUT NOCOPY VARCHAR2,
1613 x_msg_count OUT NOCOPY NUMBER,
1614 x_msg_data OUT NOCOPY VARCHAR2,
1615 p_entered_deprn IN NUMBER,
1616 p_fa_cle_id IN NUMBER,
1617 x_calculated_deprn OUT NOCOPY NUMBER) IS
1618
1619 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
1620 l_api_name CONSTANT varchar2(30) := 'CALC_DEPRN_COST';
1621 l_api_version CONSTANT NUMBER := 1.0;
1622
1623 l_entered_deprn Number;
1624 l_cap_interest Number;
1625 l_cle_id Number;
1626 l_chr_id Number;
1627 l_calculated_deprn Number;
1628
1629 l_capital_amount Number;
1630 l_oec Number;
1631
1632 --Bug# 4899328: Start
1633 --cursor to check if the contract is undergoing on-line rebook
1634 cursor l_chk_rbk_csr(p_chr_id IN NUMBER) is
1635 SELECT '!'
1636 FROM okl_trx_contracts ktrx
1637 WHERE ktrx.khr_id_old = p_chr_id
1638 AND ktrx.tsu_code = 'ENTERED'
1639 AND ktrx.rbr_code is NOT NULL
1640 AND ktrx.tcn_type = 'TRBK'
1641 --rkuttiya added for 12.1.1 Multi GAAP Project
1642 AND ktrx.representation_type = 'PRIMARY';
1643 --
1644
1645 l_rbk_khr VARCHAR2(1) DEFAULT '?';
1646 --Bug# 4899328: End
1647
1648 Begin
1649 x_return_status := OKL_API.G_RET_STS_SUCCESS;
1650 l_entered_deprn := p_entered_deprn;
1651
1652 Select cleb_fin.id,
1653 kle_fin.oec,
1654 kle_fin.capital_amount,
1655 cleb_fin.dnz_chr_id
1656 into l_cle_id,
1657 l_oec,
1658 l_capital_amount,
1659 l_chr_id
1660 From
1661 okc_k_lines_b cleb_fa,
1662 okc_k_lines_b cleb_fin,
1663 okl_k_lines kle_fin
1664 where
1665 cleb_fa.id = p_fa_cle_id
1666 and cleb_fin.id = cleb_fa.cle_id
1667 and cleb_fin.dnz_chr_id = cleb_fa.dnz_chr_id
1668 and kle_fin.id = cleb_fin.id;
1669
1670 -- Bug# 4899328: For On-line Rebook, the Depreciation cost
1671 -- will be updated automatically to reflect changes to
1672 -- Capital amount
1673
1674 --check for rebook contract
1675 -- l_chr_id is the original contract
1676 l_rbk_khr := '?';
1677 OPEN l_chk_rbk_csr (p_chr_id => l_chr_id);
1678 FETCH l_chk_rbk_csr INTO l_rbk_khr;
1679 CLOSE l_chk_rbk_csr;
1680
1681 If l_rbk_khr = '!' Then
1682 l_calculated_deprn := l_entered_deprn;
1683 Else
1684
1685 --Bug# 4899328: Capitalized Interest will be added to Line Capital
1686 -- amount at the time it is calculated
1687 /*
1688 OKL_EXECUTE_FORMULA_PUB.execute(p_api_version => p_api_version,
1689 p_init_msg_list => p_init_msg_list,
1690 x_return_status => x_return_status,
1691 x_msg_count => x_msg_count,
1692 x_msg_data => x_msg_data,
1693 p_formula_name => G_FORMULA_LINE_CAPINTEREST,
1694 p_contract_id => l_chr_id,
1695 p_line_id => l_cle_id,
1696 x_value => l_cap_interest);
1697
1698 IF (x_return_status = Okl_Api.G_RET_STS_UNEXP_ERROR) THEN
1699 RAISE Okl_Api.G_EXCEPTION_UNEXPECTED_ERROR;
1700 ELSIF (x_return_status = Okl_Api.G_RET_STS_ERROR) THEN
1701 RAISE Okl_Api.G_EXCEPTION_ERROR;
1702 END IF;
1703
1704 l_calculated_deprn := (l_capital_amount) - (l_oec) + (l_entered_deprn) + nvl(l_cap_interest,0);
1705 */
1706
1707 l_calculated_deprn := (l_capital_amount) - (l_oec) + (l_entered_deprn);
1708 --Bug# 4899328: End
1709 --------------------------------------------------------------
1710 End If;
1711 -- Bug# 4899328: End
1712
1713 x_calculated_deprn := l_calculated_deprn;
1714
1715 Exception
1716 WHEN OKL_API.G_EXCEPTION_ERROR THEN
1717 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
1718 l_api_name,
1719 G_PKG_NAME,
1720 'OKL_API.G_RET_STS_ERROR',
1721 x_msg_count,
1722 x_msg_data,
1723 '_PVT');
1724 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1725 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
1726 l_api_name,
1727 G_PKG_NAME,
1728 'OKL_API.G_RET_STS_UNEXP_ERROR',
1729 x_msg_count,
1730 x_msg_data,
1731 '_PVT');
1732 WHEN OTHERS THEN
1733 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
1734 l_api_name,
1735 G_PKG_NAME,
1736 'OTHERS',
1737 x_msg_count,
1738 x_msg_data,
1739 '_PVT');
1740 End Calc_Deprn_Cost;
1741 --Bug fix# 2788745:End
1742
1743 --------------------------------------------------------------------------------
1744 --Start of Comments
1745 --Function Name : CALC_CAP_FEE_ADJUSTMENT (Local) Bug fix# 3548044
1746 --Description : Local function to calculate capitalized fee adjustment on
1747 -- Re-book
1748 --
1749 --History :
1750 -- 05-May-2004 rpillay Created
1751 --
1752 --End of Comments
1753 --------------------------------------------------------------------------------
1754 Procedure Calc_Cap_Fee_Adjustment(p_api_version IN NUMBER,
1755 p_init_msg_list IN VARCHAR2,
1756 x_return_status OUT NOCOPY VARCHAR2,
1757 x_msg_count OUT NOCOPY NUMBER,
1758 x_msg_data OUT NOCOPY VARCHAR2,
1759 p_rbk_fa_cle_id IN NUMBER,
1760 p_rbk_chr_id IN NUMBER,
1761 x_cap_fee_adjustment OUT NOCOPY NUMBER) IS
1762
1763 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
1764 l_api_name CONSTANT varchar2(30) := 'CALC_CAP_FEE_ADJUSTMENT';
1765 l_api_version CONSTANT NUMBER := 1.0;
1766
1767 --Cursor to get FA line id of original contract
1768 Cursor orig_fa_cle_csr(fa_cle_id IN NUMBER) is
1769 Select orig_system_id1
1770 From okc_k_lines_b
1771 where id = fa_cle_id;
1772
1773 --cursor to get Cap fees added during Re-book for the asset
1774 Cursor cap_fee_csr(fa_cle_id in number
1775 ,rbk_chr_id in number) IS
1776 Select nvl(sum(cov_ast_kle.capital_amount),0) capitalized_fee
1777 From
1778 OKL_K_LINES fee_kle,
1779 OKC_K_LINES_B fee_cle,
1780 OKC_STATUSES_B fee_sts,
1781 OKL_K_LINES cov_ast_kle,
1782 OKC_K_LINES_B cov_ast_cle,
1783 OKC_LINE_STYLES_B cov_ast_lse,
1784 OKC_STATUSES_B cov_ast_sts,
1785 OKC_K_ITEMS cov_ast_cim,
1786 OKC_K_LINES_B fa_cle,
1787 OKC_K_LINES_B src_cle
1788 Where fee_kle.id = fee_cle.id
1789 and fee_kle.fee_type = 'CAPITALIZED'
1790 and fee_cle.id = cov_ast_cle.cle_id
1791 and fee_cle.dnz_chr_id = cov_ast_cle.dnz_chr_id
1792 and fee_cle.sts_code = fee_sts.code
1793 and fee_sts.ste_code not in ('HOLD', 'EXPIRED', 'TERMINATED', 'CANCELLED')
1794 and cov_ast_kle.id = cov_ast_cle.id
1795 and cov_ast_cle.id = cov_ast_cim.cle_id
1796 and cov_ast_cle.lse_id = cov_ast_lse.id
1797 and cov_ast_lse.lty_code = 'LINK_FEE_ASSET'
1798 and cov_ast_cle.sts_code = cov_ast_sts.code
1799 and cov_ast_sts.ste_code not in ('HOLD', 'EXPIRED', 'TERMINATED', 'CANCELLED')
1800 and cov_ast_cle.dnz_chr_id = cov_ast_cim.dnz_chr_id
1801 and cov_ast_cim.object1_id1 = to_char(fa_cle.cle_id)
1802 and cov_ast_cim.object1_id2 = '#'
1803 and cov_ast_cim.jtot_object1_code = 'OKX_COVASST'
1804 and fa_cle.id = fa_cle_id
1805 and fee_cle.orig_system_id1 = src_cle.id
1806 and src_cle.dnz_chr_id = rbk_chr_id;
1807
1808 l_orig_fa_cle_id Number;
1809 l_new_cap_fee Number;
1810
1811 Begin
1812 x_return_status := OKL_API.G_RET_STS_SUCCESS;
1813
1814 open orig_fa_cle_csr(fa_cle_id => p_rbk_fa_cle_id);
1815 fetch orig_fa_cle_csr into l_orig_fa_cle_id;
1816 close orig_fa_cle_csr;
1817
1818 open cap_fee_csr(fa_cle_id => l_orig_fa_cle_id
1819 ,rbk_chr_id => p_rbk_chr_id);
1820 fetch cap_fee_csr into l_new_cap_fee;
1821 close cap_fee_csr;
1822
1823 x_cap_fee_adjustment := NVL(l_new_cap_fee,0);
1824
1825 Exception
1826 WHEN OKL_API.G_EXCEPTION_ERROR THEN
1827 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
1828 l_api_name,
1829 G_PKG_NAME,
1830 'OKL_API.G_RET_STS_ERROR',
1831 x_msg_count,
1832 x_msg_data,
1833 '_PVT');
1834 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1835 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
1836 l_api_name,
1837 G_PKG_NAME,
1838 'OKL_API.G_RET_STS_UNEXP_ERROR',
1839 x_msg_count,
1840 x_msg_data,
1841 '_PVT');
1842 WHEN OTHERS THEN
1843 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
1844 l_api_name,
1845 G_PKG_NAME,
1846 'OTHERS',
1847 x_msg_count,
1848 x_msg_data,
1849 '_PVT');
1850 End Calc_Cap_Fee_Adjustment;
1851 --Bug fix# 3548044:End
1852
1853 --------------------------------------------------------------------------------
1854 --Start of Comments
1855 --Procedure Name : FIXED_ASSET_ADD
1856 --Description : Calls FA additions api to create new assets for
1857 -- and split children
1858 --History :
1859 -- 28-Nov-2001 ashish.singh Created
1860 --
1861 -- Bug# 6373605 -R12.B SAL CRs
1862 -- New IN parameters as descriped earlier in
1863 -- FIXED_ASSET_ADJUST_COST
1864 --
1865 --End of Comments
1866 --------------------------------------------------------------------------------
1867 PROCEDURE FIXED_ASSET_ADD (p_api_version IN NUMBER,
1868 p_init_msg_list IN VARCHAR2,
1869 x_return_status OUT NOCOPY VARCHAR2,
1870 x_msg_count OUT NOCOPY NUMBER,
1871 x_msg_data OUT NOCOPY VARCHAR2,
1872 p_talv_rec IN talv_rec_type,
1873 p_no_curr_conv IN VARCHAR2,
1874 --Bug# 3156924
1875 p_trans_number IN VARCHAR2,
1876 p_calling_interface IN VARCHAR2,
1877 --Bug# 5261704
1878 p_depreciate_flag IN VARCHAR2,
1879 --Bug# 6373605--SLA populate source
1880 p_sla_source_header_id IN Number,
1881 p_sla_source_header_table IN Varchar2,
1882 p_sla_source_try_id IN Number,
1883 p_sla_source_line_id IN Number,
1884 p_sla_source_line_table IN Varchar2,
1885 p_sla_source_chr_id IN Number,
1886 p_sla_source_kle_id IN Number,
1887 p_sla_asset_chr_id IN Number,
1888 --Bug# 6373605--SLA populate source
1889 --Bug# 4028371
1890 x_fa_trx_date OUT NOCOPY DATE,
1891 x_asset_hdr_rec OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type) is
1892
1893 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
1894 l_api_name CONSTANT varchar2(30) := 'FIXED_ASSET_ADD';
1895 l_api_version CONSTANT NUMBER := 1.0;
1896
1897 l_trans_rec FA_API_TYPES.trans_rec_type;
1898 l_dist_trans_rec FA_API_TYPES.trans_rec_type;
1899 l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
1900 l_asset_desc_rec FA_API_TYPES.asset_desc_rec_type;
1901 l_asset_cat_rec FA_API_TYPES.asset_cat_rec_type;
1902 l_asset_type_rec FA_API_TYPES.asset_type_rec_type;
1903 l_asset_hierarchy_rec fa_api_types.asset_hierarchy_rec_type;
1904 l_asset_fin_rec FA_API_TYPES.asset_fin_rec_type;
1905 l_asset_deprn_rec FA_API_TYPES.asset_deprn_rec_type;
1906 l_asset_dist_rec FA_API_TYPES.asset_dist_rec_type;
1907 l_asset_dist_tbl FA_API_TYPES.asset_dist_tbl_type;
1908 l_inv_tbl FA_API_TYPES.inv_tbl_type;
1909
1910 --Bug Fix # 2887948
1911 --CURSOR to fetch expense account id
1912 CURSOR exp_act_csr (p_kle_id IN NUMBER) IS
1913 SELECT msi.expense_account
1914 FROM MTL_SYSTEM_ITEMS msi,
1915 OKC_K_ITEMS cim,
1916 OKC_K_LINES_B mdl,
1917 OKC_K_LINES_B fal
1918 WHERE cim.object1_id1 = msi.inventory_item_id
1919 AND cim.object1_id2 = to_char(msi.organization_id)
1920 AND cim.jtot_object1_code = 'OKX_SYSITEM'
1921 AND cim.dnz_chr_id = mdl.dnz_chr_id
1922 AND cim.cle_id = mdl.id
1923 AND mdl.dnz_chr_id = fal.dnz_chr_id
1924 AND mdl.cle_id = fal.cle_id
1925 AND fal.id = p_kle_id;
1926
1927 l_expense_account NUMBER;
1928
1929 --CURSOR to get SET OF BOOKS
1930 CURSOR sob_csr(p_book_type_code IN VARCHAR2) IS
1931 select set_of_books_id
1932 from OKX_ASST_BK_CONTROLS_V
1933 where book_type_code = p_book_type_code
1934 and status = 'A';
1935
1936 l_sob_id NUMBER;
1937
1938 --Bug#2476805
1939 CURSOR open_period_cur(p_book_type_code IN VARCHAR2) IS
1940 SELECT fcp.start_date,
1941 fcp.end_date,
1942 fbc.book_type_code,
1943 fbc.deprn_calendar,
1944 fbc.prorate_calendar,
1945 fbc.last_period_counter,
1946 fdp.period_name
1947 FROM fa_book_controls fbc,
1948 fa_deprn_periods fdp,
1949 fa_calendar_periods fcp
1950 WHERE fcp.period_name = fdp.period_name
1951 AND fdp.period_counter = (fbc.last_period_counter + 1)
1952 AND fdp.book_type_code = fbc.book_type_code
1953 AND fcp.calendar_type = fbc.deprn_calendar
1954 AND fbc.date_ineffective is null
1955 AND fbc.book_type_code = p_book_type_code;
1956
1957 open_period_rec open_period_cur%rowtype;
1958 l_current_open_period varchar2(100) default null;
1959 --Bug#2476805
1960
1961 l_deprn_cost Number;
1962
1963 --Bug# 6373605 begin
1964 l_fxhv_rec okl_sla_acc_sources_pvt.fxhv_rec_type;
1965 l_fxlv_rec okl_sla_acc_sources_pvt.fxlv_rec_type;
1966
1967 --Bug# 6373605 end
1968
1969 Begin
1970 x_return_status := OKL_API.G_RET_STS_SUCCESS;
1971 -- Call start_activity to create savepoint, check compatibility
1972 -- and initialize message list
1973 x_return_status := OKL_API.START_ACTIVITY (
1974 l_api_name
1975 ,p_init_msg_list
1976 ,'_PVT'
1977 ,x_return_status);
1978 -- Check if activity started successfully
1979 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
1980 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1981 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
1982 RAISE OKL_API.G_EXCEPTION_ERROR;
1983 END IF;
1984
1985 --Bug#2476805
1986 --validate in_service_date
1987 OPEN open_period_cur(p_book_type_code => p_talv_rec.corporate_book);
1988 Fetch open_period_cur into open_period_rec;
1989 If open_period_cur%NotFound Then
1990 Null; --unexpected error
1991 Else
1992 If p_talv_rec.in_service_date > open_period_rec.end_date then
1993 l_current_open_period := open_period_rec.period_name||' ('||to_char(open_period_rec.start_date,'DD-MON-YYYY')||' to '||to_char(open_period_rec.end_date,'DD-MON-YYYY')||')';
1994 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
1995 p_msg_name => G_FUTURE_IN_SERVICE_DATE,
1996 p_token1 => G_ASSET_NUMBER_TOKEN,
1997 p_token1_value => p_talv_rec.asset_number,
1998 p_token2 => G_CURRENT_OPEN_PERIOD,
1999 p_token2_value => l_current_open_period
2000 );
2001 RAISE OKL_API.G_EXCEPTION_ERROR;
2002 elsIf p_talv_rec.in_service_date <= open_period_rec.end_date then
2003 null;
2004 End If;
2005 End If;
2006 --Bug#2476805
2007
2008 --dbms_output.enable(1000000);
2009
2010 --Bug# 2726366
2011 --FA_SRVR_MSG.Init_Server_Message;
2012 --FA_DEBUG_PKG.Initialize;
2013
2014 ----------------
2015 --trans_rec_info
2016 ----------------
2017 l_trans_rec.transaction_type_code := G_ADD_TRX_TYPE_CODE; --optional
2018 --Big# 3156924
2019 --l_trans_rec.transaction_date_entered := p_talv_rec.in_service_date; --optional defaults to in_service_date
2020 l_trans_rec.who_info.last_updated_by := FND_GLOBAL.USER_ID;
2021 --Bug# 3156924 :
2022 --l_trans_rec.calling_interface := l_api_name;
2023 l_trans_rec.calling_interface := p_calling_interface; --optional
2024 l_trans_rec.transaction_name := substr(p_trans_number,1,20);--optional
2025
2026 --------------
2027 --hdr_rec info
2028 --------------
2029 If p_talv_rec.dnz_asset_id is not null Then
2030 l_asset_hdr_rec.asset_id := p_talv_rec.dnz_asset_id;
2031 End If;
2032 l_asset_hdr_rec.book_type_code := p_talv_rec.corporate_book;
2033 If p_talv_rec.corporate_book is Null Then
2034 --dbms_output.put_line('No FA Book Type entered for Transaction..');
2035 --raise error
2036 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
2037 p_msg_name => G_FA_BOOK_NOT_ENTERED,
2038 p_token1 => G_ASSET_NUMBER_TOKEN,
2039 p_token1_value => p_talv_rec.asset_number
2040 );
2041 RAISE OKL_API.G_EXCEPTION_ERROR;
2042 --l_asset_hdr_rec.book_type_code := 'OPS CORP';
2043 End If;
2044
2045 OPEN sob_csr(p_book_type_code => l_asset_hdr_rec.book_type_code);
2046 FETCH sob_csr into l_sob_id;
2047 If sob_csr%NOTFOUND Then
2048 --dbms_output.put_line('Set of books attached to book not found..');
2049 --raise appropriate error
2050 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
2051 p_msg_name => G_SOB_FETCH_FAILED,
2052 p_token1 => G_FA_BOOK_TOKEN,
2053 p_token1_value => l_asset_hdr_rec.book_type_code
2054 );
2055 RAISE OKL_API.G_EXCEPTION_ERROR;
2056 Else
2057 l_asset_hdr_rec.set_of_books_id := l_sob_id; --optional
2058 End If;
2059 CLOSE sob_csr;
2060
2061 -------------
2062 -- desc info
2063 -------------
2064 l_asset_desc_rec.asset_number := p_talv_rec.asset_number;
2065 l_asset_desc_rec.description := p_talv_rec.description;
2066
2067 l_asset_desc_rec.model_number := p_talv_rec.model_number;
2068 --l_asset_desc_rec.manufacturer_name := p_talv_rec.tag_number;
2069 --Bug # 2397777 : Manufacturer Name now getting populated in correct field
2070 l_asset_desc_rec.manufacturer_name := p_talv_rec.manufacturer_name;
2071
2072 If p_talv_rec.used_asset_yn is not null Then
2073 If p_talv_rec.used_asset_yn = 'Y' or upper(p_talv_rec.used_asset_yn) = 'YES' Then
2074 l_asset_desc_rec.new_used := 'USED';
2075 Elsif p_talv_rec.used_asset_yn = 'N' or upper(p_talv_rec.used_asset_yn) = 'NO' Then
2076 l_asset_desc_rec.new_used := 'NEW';
2077 End If;
2078 End If;
2079
2080 -- how to get the asset key ccid??
2081 -- asset key ccid is not mandatory
2082 --l_asset_desc_rec.asset_key_ccid := 2;
2083
2084 /*
2085 select asset_key_ccid
2086 into l_asset_desc_rec.asset_key_ccid
2087 from fa_additions
2088 where asset_id = p_ast_line_rec.asset_id;
2089 */
2090 l_asset_desc_rec.current_units := p_talv_rec.current_units;
2091
2092 ----------------
2093 --Bug# 2981308
2094 ---------------
2095 l_asset_desc_rec.asset_key_ccid := p_talv_rec.asset_key_id;
2096
2097 -----------------------
2098 --asset_type_rec info ??
2099 -----------------------
2100 --assuming okl assets will always be 'CAPITALIZED'
2101 l_asset_type_rec.asset_type := G_ADD_ASSET_TYPE;
2102
2103 ---------------------
2104 --asset_cat_rec_info
2105 --------------------
2106 l_asset_cat_rec.category_id := p_talv_rec.depreciation_id;
2107
2108 ----------------
2109 --asset_fin_rec
2110 ----------------
2111 l_asset_fin_rec.set_of_books_id := l_asset_hdr_rec.set_of_books_id;
2112 l_asset_fin_rec.date_placed_in_service := p_talv_rec.in_service_date;
2113 l_asset_fin_rec.deprn_method_code := p_talv_rec.deprn_method;
2114 l_asset_fin_rec.life_in_months := p_talv_rec.life_in_months;
2115 --Bug# 6373605 start
2116 l_asset_fin_rec.contract_id := p_sla_asset_chr_id;
2117 --Bug# 6373605 end
2118
2119 --Bug fix# 2788745: depreciation cost should be = (deprn cost - tradein - cap reduction + cap fee + cap interest)
2120 --call function to calculate the final depeciation cost to go into FA
2121 --Bug#314352 : Subsidies - local function call changed to local procedure
2122 Calc_Deprn_Cost ( p_api_version => p_api_version,
2123 p_init_msg_list => p_init_msg_list,
2124 x_msg_count => x_msg_count,
2125 x_msg_data => x_msg_data,
2126 x_return_status => x_return_status,
2127 p_entered_deprn => p_talv_rec.depreciation_cost,
2128 p_fa_cle_id => p_talv_rec.kle_id,
2129 x_calculated_deprn => l_deprn_cost);
2130 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2131 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2132 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
2133 RAISE OKL_API.G_EXCEPTION_ERROR;
2134 END IF;
2135 --Bug fix# 2788745: End
2136
2137 --Bug# 2823405 : Raise error if depreciation cost is lesser than salvage value
2138 IF (l_deprn_cost < p_talv_rec.salvage_value) Then
2139 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
2140 p_msg_name => G_SALVAGE_VALUE
2141 );
2142 RAISE OKL_API.G_EXCEPTION_ERROR;
2143 End If;
2144 --End Bug# 2823405
2145
2146 -- Check and convert to functional currency.
2147 If ( p_no_curr_conv = OKL_API.G_FALSE ) Then -- amounts not converted to functional curr need to convert
2148
2149 convert_2functional_currency(p_api_version => p_api_version,
2150 p_init_msg_list => p_init_msg_list,
2151 x_return_status => x_return_status,
2152 x_msg_count => x_msg_count,
2153 x_msg_data => x_msg_data,
2154 p_chr_id => p_talv_rec.dnz_khr_id,
2155 --Bug fix# 2788745
2156 --p_amount => p_talv_rec.depreciation_cost,
2157 p_amount => l_deprn_cost,
2158 x_amount => l_asset_fin_rec.cost);
2159
2160 --dbms_output.put_line('After Calling Fixed Asset ADD api "'||x_return_status||'"');
2161 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2162 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2163 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
2164 RAISE OKL_API.G_EXCEPTION_ERROR;
2165 END IF;
2166
2167 l_asset_fin_rec.original_cost := l_asset_fin_rec.cost;
2168
2169 convert_2functional_currency(p_api_version => p_api_version,
2170 p_init_msg_list => p_init_msg_list,
2171 x_return_status => x_return_status,
2172 x_msg_count => x_msg_count,
2173 x_msg_data => x_msg_data,
2174 p_chr_id => p_talv_rec.dnz_khr_id,
2175 p_amount => p_talv_rec.salvage_value,
2176 x_amount => l_asset_fin_rec.salvage_value);
2177
2178 --dbms_output.put_line('After Calling Fixed Asset ADD api "'||x_return_status||'"');
2179 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2180 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2181 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
2182 RAISE OKL_API.G_EXCEPTION_ERROR;
2183 END IF;
2184
2185 ELSE --amounts already in funtional currency no need to convert
2186 --Bug fix# 2788745
2187 --l_asset_fin_rec.cost := p_talv_rec.depreciation_cost;
2188 --l_asset_fin_rec.original_cost := p_talv_rec.depreciation_cost;
2189 l_asset_fin_rec.cost := l_deprn_cost;
2190 l_asset_fin_rec.original_cost := l_deprn_cost;
2191 l_asset_fin_rec.salvage_value := p_talv_rec.salvage_value;
2192 End If;
2193
2194 --l_asset_fin_rec.cost := p_talv_rec.depreciation_cost;
2195 --l_asset_fin_rec.original_cost := p_talv_rec.depreciation_cost;
2196 --l_asset_fin_rec.salvage_value := p_talv_rec.salvage_value;
2197 --CONFIRM ABOUT RATES
2198 --confirmation : for flat rate methods these rates will be taken
2199 --else default rates for depreciation methods will be taken
2200 l_asset_fin_rec.basic_rate := p_talv_rec.deprn_rate;
2201 l_asset_fin_rec.adjusted_rate := p_talv_rec.deprn_rate;
2202 --confirm about this
2203 --Bug# 3143522 - FA API expects salvage value percent in decimals(divided by 100)
2204 --l_asset_fin_rec.percent_salvage_value := p_talv_rec.percent_salvage_value;
2205 l_asset_fin_rec.percent_salvage_value := (p_talv_rec.percent_salvage_value/100);
2206 l_asset_fin_rec.rate_adjustment_factor := G_ADD_RATE_ADJ_FACTOR; --optional
2207
2208 --Bug# 3156924 :
2209 --l_asset_fin_rec.depreciate_flag := 'YES'; --gets pulled from
2210 --asset book defaults
2211
2212 --Bug# 5261704
2213 If NVL(p_depreciate_flag,OKL_API.G_MISS_CHAR) = 'NO' then
2214 l_asset_fin_rec.depreciate_flag := 'NO';
2215 End If;
2216 --End Bug # 5261704
2217
2218 --asset_deprn_rec
2219 --no need to populate asset depreciation rec as asset has not depreciated
2220
2221 -----------------
2222 --asset_dist_rec
2223 ----------------
2224 l_asset_dist_rec.units_assigned := p_talv_rec.current_units;
2225 l_asset_dist_rec.location_ccid := p_talv_rec.fa_location_id;
2226
2227 -- CONFIRM ABOUT EXPENSE CCID
2228 --how to get the expense ccid ??
2229 --l_asset_dist_rec.code_combination_id := ??
2230 --expence ccid will come from mtl_system_items expense ccid
2231 OPEN exp_act_csr (p_kle_id => p_talv_rec.kle_id);
2232 Fetch exp_act_csr into
2233 l_expense_account;
2234 If exp_act_csr%NOTFOUND Then
2235 --raise appropriate error
2236 --dbms_output.put_line('expense account not found...');
2237 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
2238 p_msg_name => G_EXP_ACCT_NOT_ENTERED,
2239 p_token1 => G_ASSET_NUMBER_TOKEN,
2240 p_token1_value => p_talv_rec.asset_number
2241 );
2242 RAISE OKL_API.G_EXCEPTION_ERROR;
2243 --select code_combination_id
2244 --into l_asset_dist_rec.expense_ccid
2245 --from okx_ast_dst_hst_v
2246 --where book_type_code = 'OPS CORP'
2247 --where book_type_code = l_asset_hdr_rec.book_type_code
2248 --and rownum < 2;
2249 Else
2250 --dbms_output.put_line('Expense ccid found in msi:-)'||to_char(l_expense_account));
2251 l_asset_dist_rec.expense_ccid := l_expense_account;
2252 End If;
2253 Close exp_act_csr;
2254
2255 l_asset_dist_tbl(1) := l_asset_dist_rec;
2256
2257
2258 ---------------
2259 -- call the api
2260 ---------------
2261 fa_addition_pub.do_addition
2262 (p_api_version => p_api_version,
2263 p_init_msg_list => p_init_msg_list,
2264 p_commit => OKL_API.G_FALSE,
2265 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
2266 x_return_status => x_return_status,
2267 x_msg_count => x_msg_count,
2268 x_msg_data => x_msg_data,
2269 --Bug# 3156924
2270 --p_calling_fn => l_api_name,
2271 p_calling_fn => p_calling_interface,
2272 px_trans_rec => l_trans_rec,
2273 px_dist_trans_rec => l_dist_trans_rec,
2274 px_asset_hdr_rec => l_asset_hdr_rec,
2275 px_asset_desc_rec => l_asset_desc_rec,
2276 px_asset_type_rec => l_asset_type_rec,
2277 px_asset_cat_rec => l_asset_cat_rec,
2278 px_asset_hierarchy_rec => l_asset_hierarchy_rec,
2279 px_asset_fin_rec => l_asset_fin_rec,
2280 px_asset_deprn_rec => l_asset_deprn_rec,
2281 px_asset_dist_tbl => l_asset_dist_tbl,
2282 px_inv_tbl => l_inv_tbl
2283 );
2284 --dbms_output.put_line('After Calling Fixed Asset ADD api "'||x_return_status||'"');
2285 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2286 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2287 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
2288 RAISE OKL_API.G_EXCEPTION_ERROR;
2289 END IF;
2290 x_asset_hdr_rec := l_asset_hdr_rec;
2291 --Bug# 4028371:
2292 x_fa_trx_date := l_trans_rec.transaction_date_entered;
2293
2294 --bug# 6373605 -- call populate sla sources
2295 l_fxhv_rec.source_id := p_sla_source_header_id;
2296 l_fxhv_rec.source_table := p_sla_source_header_table;
2297 l_fxhv_rec.khr_id := p_sla_source_chr_id;
2298 l_fxhv_rec.try_id := p_sla_source_try_id;
2299
2300 l_fxlv_rec.source_id := p_sla_source_line_id;
2301 l_fxlv_rec.source_table := p_sla_source_line_table;
2302 l_fxlv_rec.kle_id := p_sla_source_kle_id;
2303
2304 l_fxlv_rec.asset_id := l_asset_hdr_rec.asset_id;
2305 l_fxlv_rec.fa_transaction_id := l_trans_rec.transaction_header_id;
2306 l_fxlv_rec.asset_book_type_name := l_asset_hdr_rec.book_type_code;
2307
2308 OKL_SLA_ACC_SOURCES_PVT.populate_sources(
2309 p_api_version => p_api_version
2310 ,p_init_msg_list => p_init_msg_list
2311 ,p_fxhv_rec => l_fxhv_rec
2312 ,p_fxlv_rec => l_fxlv_rec
2313 ,x_return_status => x_return_status
2314 ,x_msg_count => x_msg_count
2315 ,x_msg_data => x_msg_data
2316 );
2317 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2318 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2319 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
2320 RAISE OKL_API.G_EXCEPTION_ERROR;
2321 END IF;
2322
2323 --bug# 6373605 -- call populate SLA sources
2324 OKL_API.END_ACTIVITY (x_msg_count,
2325 x_msg_data );
2326 EXCEPTION
2327 WHEN OKL_API.G_EXCEPTION_ERROR THEN
2328 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
2329 l_api_name,
2330 G_PKG_NAME,
2331 'OKL_API.G_RET_STS_ERROR',
2332 x_msg_count,
2333 x_msg_data,
2334 '_PVT');
2335 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2336 --dbms_output.put_line('Raising unexpected here...');
2337 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
2338 l_api_name,
2339 G_PKG_NAME,
2340 'OKL_API.G_RET_STS_UNEXP_ERROR',
2341 x_msg_count,
2342 x_msg_data,
2343 '_PVT');
2344 WHEN OTHERS THEN
2345 --dbms_output.put_line('Raising when others here...'||SQLERRM);
2346 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
2347 l_api_name,
2348 G_PKG_NAME,
2349 'OTHERS',
2350 x_msg_count,
2351 x_msg_data,
2352 '_PVT');
2353 END FIXED_ASSET_ADD;
2354
2355 --------------------------------------------------------------------------------
2356 --Start of Comments
2357 --Procedure Name : FIXED_ASSET_ADD
2358 --Description : Calls FA additions api to create new assets for
2359 -- and split children
2360 --History :
2361 -- 28-Nov-2001 ashish.singh Created
2362 --
2363 -- Bug# 6373605 -R12.B SAL CRs
2364 -- New IN parameters as descriped earlier in
2365 -- FIXED_ASSET_ADJUST_COST
2366 --
2367 --End of Comments
2368 --------------------------------------------------------------------------------
2369 PROCEDURE FIXED_ASSET_ADD (p_api_version IN NUMBER,
2370 p_init_msg_list IN VARCHAR2,
2371 x_return_status OUT NOCOPY VARCHAR2,
2372 x_msg_count OUT NOCOPY NUMBER,
2373 x_msg_data OUT NOCOPY VARCHAR2,
2374 p_talv_rec IN talv_rec_type,
2375 --bug# 3156924
2376 p_trans_number IN VARCHAR2,
2377 p_calling_interface IN VARCHAR2,
2378 --Bug# 5261704
2379 p_depreciate_flag IN VARCHAR2,
2380 --Bug# 6373605--SLA populate source
2381 p_sla_source_header_id IN Number,
2382 p_sla_source_header_table IN Varchar2,
2383 p_sla_source_try_id IN Number,
2384 p_sla_source_line_id IN Number,
2385 p_sla_source_line_table IN Varchar2,
2386 p_sla_source_chr_id IN Number,
2387 p_sla_source_kle_id IN Number,
2388 p_sla_asset_chr_id IN Number,
2389 --Bug# 6373605--SLA populate source
2390 --Bug# 4028371
2391 x_fa_trx_date OUT NOCOPY DATE,
2392 x_asset_hdr_rec OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type) is
2393
2394 Begin
2395
2396 FIXED_ASSET_ADD(p_api_version => p_api_version,
2397 p_init_msg_list => p_init_msg_list,
2398 x_return_status => x_return_status,
2399 x_msg_count => x_msg_count,
2400 x_msg_data => x_msg_data,
2401 p_talv_rec => p_talv_rec,
2402 p_no_curr_conv => OKL_API.G_FALSE,
2403 --bug# 3156924
2404 p_trans_number => p_trans_number,
2405 p_calling_interface => p_calling_interface,
2406 --Bug# 5261704
2407 p_depreciate_flag => p_depreciate_flag,
2408 --Bug# 6373605--SLA populate source
2409 p_sla_source_header_id => p_sla_source_header_id,
2410 p_sla_source_header_table => p_sla_source_header_table,
2411 p_sla_source_try_id => p_sla_source_try_id,
2412 p_sla_source_line_id => p_sla_source_line_id,
2413 p_sla_source_line_table => p_sla_source_line_table,
2414 p_sla_source_chr_id => p_sla_source_chr_id,
2415 p_sla_source_kle_id => p_sla_source_kle_id ,
2416 p_sla_asset_chr_id => p_sla_asset_chr_id,
2417 --Bug# 6373605--SLA populate source
2418 --Bug# 4028371
2419 x_fa_trx_date => x_fa_trx_date,
2420 x_asset_hdr_rec => x_asset_hdr_rec);
2421
2422 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2423 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2424 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
2425 RAISE OKL_API.G_EXCEPTION_ERROR;
2426 END IF;
2427
2428 End FIXED_ASSET_ADD;
2429
2430 --Bug# 3533936
2431 --------------------------------------------------------------------------------
2432 --Start of Comments
2433 --Procedure Name : FIXED_ASSET_TRANSFER
2434 --Description : Does location change on a re-lease asset in FA
2435 --History :
2436 -- 25-Mar-2004 rekha.pillay Created
2437 --End of Comments
2438 --------------------------------------------------------------------------------
2439 PROCEDURE FIXED_ASSET_TRANSFER
2440 (p_api_version IN NUMBER,
2441 p_init_msg_list IN VARCHAR2 DEFAULT OKL_API.G_FALSE,
2442 x_return_status OUT NOCOPY VARCHAR2,
2443 x_msg_count OUT NOCOPY NUMBER,
2444 x_msg_data OUT NOCOPY VARCHAR2,
2445 p_asset_id IN NUMBER,
2446 p_book_type_code IN VARCHAR2,
2447 p_location_id IN NUMBER,
2448 p_trx_date IN DATE,
2449 p_trx_number IN VARCHAR2,
2450 --Bug# 6373605--SLA populate source
2451 p_sla_source_header_id IN Number,
2452 p_sla_source_header_table IN Varchar2,
2453 p_sla_source_try_id IN Number,
2454 p_sla_source_line_id IN Number,
2455 p_sla_source_line_table IN Varchar2,
2456 p_sla_source_chr_id IN Number,
2457 p_sla_source_kle_id IN Number,
2458 --Bug# 6373605 End
2459 --Bug# 4028371
2460 x_fa_trx_date OUT NOCOPY DATE,
2461 p_calling_interface IN VARCHAR2) is
2462
2463 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
2464 l_api_name CONSTANT varchar2(30) := 'FIXED_ASSET_TRANSFER';
2465 l_api_version CONSTANT NUMBER := 1.0;
2466
2467
2468 l_trans_rec fa_api_types.trans_rec_type;
2469 l_asset_hdr_rec fa_api_types.asset_hdr_rec_type;
2470 l_asset_dist_tbl fa_api_types.asset_dist_tbl_type;
2471
2472 --cursor to get the distributions
2473 cursor l_dist_curs(p_asset_id IN NUMBER,
2474 p_corporate_book IN VARCHAR2) is
2475 select units_assigned,
2476 location_id,
2477 distribution_id,
2478 code_combination_id
2479 from fa_distribution_history
2480 where asset_id = p_asset_id
2481 and book_type_code = p_corporate_book
2482 and transaction_header_id_out is null
2483 and retirement_id is null;
2484
2485 l_units_assigned NUMBER;
2486 l_location_id NUMBER;
2487 l_distribution_id NUMBER;
2488 l_code_combination_id NUMBER;
2489
2490 --Bug# 6373605 begin
2491 l_fxhv_rec okl_sla_acc_sources_pvt.fxhv_rec_type;
2492 l_fxlv_rec okl_sla_acc_sources_pvt.fxlv_rec_type;
2493 --Bug# 6373605 end
2494
2495
2496 begin
2497 x_return_status := OKL_API.G_RET_STS_SUCCESS;
2498 -- Call start_activity to create savepoint, check compatibility
2499 -- and initialize message list
2500 x_return_status := OKL_API.START_ACTIVITY (
2501 l_api_name
2502 ,p_init_msg_list
2503 ,'_PVT'
2504 ,x_return_status);
2505 -- Check if activity started successfully
2506 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2507 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2508 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
2509 RAISE OKL_API.G_EXCEPTION_ERROR;
2510 END IF;
2511
2512 l_asset_hdr_rec.asset_id := p_asset_id;
2513 l_asset_hdr_rec.book_type_code := p_book_type_code;
2514
2515 -- transaction date must be filled in if performing
2516 -- prior period transfer
2517 l_trans_rec.transaction_date_entered := NULL;
2518 l_trans_rec.transaction_name := substr(p_trx_number,1,20);
2519 l_trans_rec.calling_interface := p_calling_interface;
2520 l_trans_rec.who_info.last_updated_by := FND_GLOBAL.USER_ID;
2521 l_trans_rec.who_info.last_update_login := FND_GLOBAL.LOGIN_ID;
2522
2523 open l_dist_curs(p_asset_id, p_book_type_code);
2524 Loop
2525 Fetch l_dist_curs into l_units_assigned, l_location_id, l_distribution_id, l_code_combination_id;
2526 Exit When l_dist_curs%NOTFOUND;
2527 If l_location_id <> p_location_id Then
2528
2529 l_asset_dist_tbl.delete;
2530
2531 l_asset_dist_tbl(1).distribution_id := l_distribution_id;
2532 l_asset_dist_tbl(1).transaction_units := (-1)*l_units_assigned;
2533
2534 l_asset_dist_tbl(2).transaction_units := l_units_assigned;
2535 l_asset_dist_tbl(2).expense_ccid := l_code_combination_id;
2536 l_asset_dist_tbl(2).location_ccid := p_location_id;
2537
2538 FA_TRANSFER_PUB.do_transfer(
2539 p_api_version => p_api_version,
2540 p_init_msg_list => FND_API.G_FALSE,
2541 p_commit => FND_API.G_FALSE,
2542 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
2543 p_calling_fn => p_calling_interface,
2544 x_return_status => x_return_status,
2545 x_msg_count => x_msg_count,
2546 x_msg_data => x_msg_data,
2547 px_trans_rec => l_trans_rec,
2548 px_asset_hdr_rec => l_asset_hdr_rec,
2549 px_asset_dist_tbl => l_asset_dist_tbl);
2550
2551 --dbms_output.put_line('After calling FA Transfer Api '||x_return_status);
2552 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2553 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2554 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
2555 RAISE OKL_API.G_EXCEPTION_ERROR;
2556 END IF;
2557
2558 --Bug# 6504515 -- moved inside the loop and if clause as
2559 -- SLA sources need to be populated only is
2560 --- FA_TRANSFER_PUB is called i.e. on actual
2561 -- asset location change. If there is no
2562 -- asset location change FA_TRANSFER_PUB will
2563 -- not be called because of the if clause
2564 -- If l_location_id <> p_location_id Then
2565 --bug# 6373605 -- call populate sla sources
2566 l_fxhv_rec.source_id := p_sla_source_header_id;
2567 l_fxhv_rec.source_table := p_sla_source_header_table;
2568 l_fxhv_rec.khr_id := p_sla_source_chr_id;
2569 l_fxhv_rec.try_id := p_sla_source_try_id;
2570
2571 l_fxlv_rec.source_id := p_sla_source_line_id;
2572 l_fxlv_rec.source_table := p_sla_source_line_table;
2573 l_fxlv_rec.kle_id := p_sla_source_kle_id;
2574
2575 l_fxlv_rec.asset_id := l_asset_hdr_rec.asset_id;
2576 l_fxlv_rec.fa_transaction_id := l_trans_rec.transaction_header_id;
2577 l_fxlv_rec.asset_book_type_name := l_asset_hdr_rec.book_type_code;
2578
2579 OKL_SLA_ACC_SOURCES_PVT.populate_sources(
2580 p_api_version => p_api_version
2581 ,p_init_msg_list => p_init_msg_list
2582 ,p_fxhv_rec => l_fxhv_rec
2583 ,p_fxlv_rec => l_fxlv_rec
2584 ,x_return_status => x_return_status
2585 ,x_msg_count => x_msg_count
2586 ,x_msg_data => x_msg_data
2587 );
2588
2589 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2590 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2591 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
2592 RAISE OKL_API.G_EXCEPTION_ERROR;
2593 END IF;
2594 --bug# 6373605 -- call populate SLA sources
2595 --Bug# 6504515 -- end
2596
2597 End If;
2598 End Loop;
2599 close l_dist_curs;
2600
2601 --Bug# 4028371
2602 x_fa_trx_date := l_trans_rec.transaction_date_entered;
2603
2604
2605 OKL_API.END_ACTIVITY (x_msg_count,
2606 x_msg_data );
2607 EXCEPTION
2608 WHEN OKL_API.G_EXCEPTION_ERROR THEN
2609 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
2610 l_api_name,
2611 G_PKG_NAME,
2612 'OKL_API.G_RET_STS_ERROR',
2613 x_msg_count,
2614 x_msg_data,
2615 '_PVT');
2616 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2617 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
2618 l_api_name,
2619 G_PKG_NAME,
2620 'OKL_API.G_RET_STS_UNEXP_ERROR',
2621 x_msg_count,
2622 x_msg_data,
2623 '_PVT');
2624 WHEN OTHERS THEN
2625 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
2626 l_api_name,
2627 G_PKG_NAME,
2628 'OTHERS',
2629 x_msg_count,
2630 x_msg_data,
2631 '_PVT');
2632 END FIXED_ASSET_TRANSFER;
2633 --Bug# 3533936
2634
2635 --Bug#5207066
2636 --------------------------------------------------------------------------------
2637 --Start of Comments
2638 --Procedure Name : FIXED_ASSET_ADJUST_UNIT
2639 --Description :
2640 --History :
2641 --
2642 -- Bug# 6373605 -R12.B SAL CRs
2643 -- New IN parameters as descriped earlier in
2644 -- FIXED_ASSET_ADJUST_COST
2645 --
2646 --
2647 --End of Comments
2648 --------------------------------------------------------------------------------
2649 PROCEDURE FIXED_ASSET_ADJUST_UNIT
2650 (p_api_version IN NUMBER,
2651 p_init_msg_list IN VARCHAR2 DEFAULT OKL_API.G_FALSE,
2652 x_return_status OUT NOCOPY VARCHAR2,
2653 x_msg_count OUT NOCOPY NUMBER,
2654 x_msg_data OUT NOCOPY VARCHAR2,
2655 p_asset_id IN NUMBER,
2656 p_book_type_code IN VARCHAR2,
2657 p_diff_in_units IN NUMBER,
2658 p_trx_date IN DATE,
2659 p_trx_number IN VARCHAR2,
2660 --Bug# 6373605--SLA populate source
2661 p_sla_source_header_id IN Number,
2662 p_sla_source_header_table IN Varchar2,
2663 p_sla_source_try_id IN Number,
2664 p_sla_source_line_id IN Number,
2665 p_sla_source_line_table IN Varchar2,
2666 p_sla_source_chr_id IN Number,
2667 p_sla_source_kle_id IN Number,
2668 --Bug# 6373605--SLA populate source
2669 --Bug# 4028371
2670 x_fa_trx_date OUT NOCOPY DATE,
2671 p_calling_interface IN VARCHAR2) is
2672
2673 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
2674 l_api_name CONSTANT varchar2(30) := 'FIXED_ASSET_ADJUST_UNIT';
2675 l_api_version CONSTANT NUMBER := 1.0;
2676
2677
2678 l_trans_rec fa_api_types.trans_rec_type;
2679 l_asset_hdr_rec fa_api_types.asset_hdr_rec_type;
2680 l_asset_dist_tbl fa_api_types.asset_dist_tbl_type;
2681
2682 l_units_to_adjust NUMBER;
2683 i number;
2684
2685 --cursor to get the distributions
2686 cursor l_dist_curs(p_asset_id IN NUMBER,
2687 p_corporate_book IN VARCHAR2) is
2688 select units_assigned,
2689 distribution_id
2690 from fa_distribution_history
2691 where asset_id = p_asset_id
2692 and book_type_code = p_corporate_book
2693 and transaction_header_id_out is null
2694 and retirement_id is null;
2695
2696
2697 l_units_assigned NUMBER;
2698 l_location_id NUMBER;
2699 l_distribution_id NUMBER;
2700 l_code_combination_id NUMBER;
2701
2702 --Bug# 6373605 begin
2703 l_fxhv_rec okl_sla_acc_sources_pvt.fxhv_rec_type;
2704 l_fxlv_rec okl_sla_acc_sources_pvt.fxlv_rec_type;
2705 --Bug# 6373605 end
2706
2707 begin
2708 x_return_status := OKL_API.G_RET_STS_SUCCESS;
2709 -- Call start_activity to create savepoint, check compatibility
2710 -- and initialize message list
2711 x_return_status := OKL_API.START_ACTIVITY (
2712 l_api_name
2713 ,p_init_msg_list
2714 ,'_PVT'
2715 ,x_return_status);
2716 -- Check if activity started successfully
2717 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2718 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2719 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
2720 RAISE OKL_API.G_EXCEPTION_ERROR;
2721 END IF;
2722
2723 l_asset_hdr_rec.asset_id := p_asset_id;
2724 l_asset_hdr_rec.book_type_code := p_book_type_code;
2725
2726 -- transaction date must be filled in if performing
2727 -- prior period transfer
2728 l_trans_rec.transaction_date_entered := NULL;
2729 l_trans_rec.transaction_name := substr(p_trx_number,1,20);
2730 l_trans_rec.calling_interface := p_calling_interface;
2731 l_trans_rec.who_info.last_updated_by := FND_GLOBAL.USER_ID;
2732 l_trans_rec.who_info.last_update_login := FND_GLOBAL.LOGIN_ID;
2733
2734 l_units_to_adjust := p_diff_in_units;
2735 i := 1;
2736 if (p_diff_in_units > 0) then
2737 OPEN l_dist_curs(p_asset_id, p_book_type_code);
2738 --Loop
2739 FETCH l_dist_curs INTO l_units_assigned, l_distribution_id;
2740 l_asset_dist_tbl(i).distribution_id := l_distribution_id;
2741 l_asset_dist_tbl(i).transaction_units := p_diff_in_units;
2742 l_asset_dist_tbl(i).units_assigned := NULL;
2743 l_asset_dist_tbl(i).assigned_to := NULL;
2744 l_asset_dist_tbl(i).expense_ccid := NULL;
2745 l_asset_dist_tbl(i).location_ccid := NULL;
2746 --EXIT;
2747 --END LOOP;
2748 CLOSE l_dist_curs;
2749 Elsif (p_diff_in_units < 0) then
2750 l_units_to_adjust := (-1) * p_diff_in_units;
2751 OPEN l_dist_curs(p_asset_id, p_book_type_code);
2752 LOOP
2753 FETCH l_dist_curs INTO l_units_assigned, l_distribution_id;
2754 EXIT WHEN l_dist_curs%NOTFOUND;
2755 IF l_units_to_adjust = 0 THEN --input param
2756 EXIT;
2757 ELSIF l_units_to_adjust >= l_units_assigned THEN
2758 l_asset_dist_tbl(i).distribution_id := l_distribution_id;
2759 l_asset_dist_tbl(i).transaction_units := (-1)*l_units_assigned;
2760 --dbms_output.put_line('Units to adjust '||to_char(l_asset_dist_tbl(i).transaction_units));
2761 l_asset_dist_tbl(i).units_assigned := NULL;
2762 l_asset_dist_tbl(i).assigned_to := NULL;
2763 l_asset_dist_tbl(i).expense_ccid := NULL;
2764 l_asset_dist_tbl(i).location_ccid := NULL;
2765 l_units_to_adjust := l_units_to_adjust - l_units_assigned;
2766 i := i + 1;
2767 ELSIF l_units_to_adjust < l_units_assigned THEN
2768 l_asset_dist_tbl(i).distribution_id := l_distribution_id;
2769 l_asset_dist_tbl(i).transaction_units := (-1)*l_units_to_adjust;
2770 --dbms_output.put_line('Units to adjust '||to_char(l_asset_dist_tbl(i).transaction_units));
2771 l_asset_dist_tbl(i).units_assigned := NULL;
2772 l_asset_dist_tbl(i).assigned_to := NULL;
2773 l_asset_dist_tbl(i).expense_ccid := NULL;
2774 l_asset_dist_tbl(i).location_ccid := NULL;
2775 l_units_to_adjust := l_units_to_adjust - l_units_to_adjust;
2776 i := i + 1;
2777 END IF;
2778 END LOOP;
2779 CLOSE l_dist_curs;
2780 end if;
2781 FA_UNIT_ADJ_PUB.do_unit_adjustment(
2782 p_api_version => p_api_version,
2783 p_init_msg_list => FND_API.G_FALSE,
2784 p_commit => FND_API.G_FALSE,
2785 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
2786 --bug# 3156924 :
2787 p_calling_fn => p_calling_interface,
2788 --p_calling_fn => NULL,
2789 x_return_status => x_return_status,
2790 x_msg_count => x_msg_count,
2791 x_msg_data => x_msg_data,
2792 px_trans_rec => l_trans_rec,
2793 px_asset_hdr_rec => l_asset_hdr_rec,
2794 px_asset_dist_tbl => l_asset_dist_tbl);
2795
2796 --dbms_output.put_line('After calling FA unit adjust Api '||x_return_status);
2797 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2798 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2799 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
2800 RAISE OKL_API.G_EXCEPTION_ERROR;
2801 END IF;
2802 x_fa_trx_date := l_trans_rec.transaction_date_entered;
2803 --bug# 6373605 -- call populate sla sources
2804 l_fxhv_rec.source_id := p_sla_source_header_id;
2805 l_fxhv_rec.source_table := p_sla_source_header_table;
2806 l_fxhv_rec.khr_id := p_sla_source_chr_id;
2807 l_fxhv_rec.try_id := p_sla_source_try_id;
2808
2809 l_fxlv_rec.source_id := p_sla_source_line_id;
2810 l_fxlv_rec.source_table := p_sla_source_line_table;
2811 l_fxlv_rec.kle_id := p_sla_source_kle_id;
2812
2813 l_fxlv_rec.asset_id := l_asset_hdr_rec.asset_id;
2814 l_fxlv_rec.fa_transaction_id := l_trans_rec.transaction_header_id;
2815 l_fxlv_rec.asset_book_type_name := l_asset_hdr_rec.book_type_code;
2816
2817 OKL_SLA_ACC_SOURCES_PVT.populate_sources(
2818 p_api_version => p_api_version
2819 ,p_init_msg_list => p_init_msg_list
2820 ,p_fxhv_rec => l_fxhv_rec
2821 ,p_fxlv_rec => l_fxlv_rec
2822 ,x_return_status => x_return_status
2823 ,x_msg_count => x_msg_count
2824 ,x_msg_data => x_msg_data
2825 );
2826
2827 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2828 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2829 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
2830 RAISE OKL_API.G_EXCEPTION_ERROR;
2831 END IF;
2832 --bug# 6373605 -- call populate SLA sources
2833
2834 OKL_API.END_ACTIVITY (x_msg_count,
2835 x_msg_data );
2836 EXCEPTION
2837 WHEN OKL_API.G_EXCEPTION_ERROR THEN
2838 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
2839 l_api_name,
2840 G_PKG_NAME,
2841 'OKL_API.G_RET_STS_ERROR',
2842 x_msg_count,
2843 x_msg_data,
2844 '_PVT');
2845 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2846 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
2847 l_api_name,
2848 G_PKG_NAME,
2849 'OKL_API.G_RET_STS_UNEXP_ERROR',
2850 x_msg_count,
2851 x_msg_data,
2852 '_PVT');
2853 WHEN OTHERS THEN
2854 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
2855 l_api_name,
2856 G_PKG_NAME,
2857 'OTHERS',
2858 x_msg_count,
2859 x_msg_data,
2860 '_PVT');
2861 END FIXED_ASSET_ADJUST_UNIT;
2862 --akrangan Bug# 5362977 start
2863 --------------------------------------------------------------------------------
2864 --Start of Comments
2865 --Procedure Name : FIXED_ASSET_UPDATE_DESC
2866 --Description : Change Asset Description, Model and Manufacturer in FA
2867 --History :
2868 -- 26-May-2006 rekha.pillay Created
2869 --
2870 -- Bug# 6373605 -R12.B SAL CRs
2871 -- New IN parameters as descriped earlier in
2872 -- FIXED_ASSET_ADJUST_COST
2873 --
2874 --End of Comments
2875 --------------------------------------------------------------------------------
2876 PROCEDURE FIXED_ASSET_UPDATE_DESC
2877 (p_api_version IN NUMBER,
2878 p_init_msg_list IN VARCHAR2 DEFAULT OKL_API.G_FALSE,
2879 x_return_status OUT NOCOPY VARCHAR2,
2880 x_msg_count OUT NOCOPY NUMBER,
2881 x_msg_data OUT NOCOPY VARCHAR2,
2882 p_asset_id IN NUMBER,
2883 p_model_number IN VARCHAR2,
2884 p_manufacturer IN VARCHAR2,
2885 p_description IN VARCHAR2,
2886 p_trx_date IN DATE,
2887 p_trx_number IN VARCHAR2,
2888 x_fa_trx_date OUT NOCOPY DATE,
2889 p_calling_interface IN VARCHAR2) is
2890
2891 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
2892 l_api_name CONSTANT varchar2(30) := 'FIXED_ASSET_UPDATE_DESC';
2893 l_api_version CONSTANT NUMBER := 1.0;
2894
2895 l_trans_rec fa_api_types.trans_rec_type;
2896 l_asset_hdr_rec fa_api_types.asset_hdr_rec_type;
2897 l_asset_desc_rec fa_api_types.asset_desc_rec_type;
2898 l_asset_type_rec fa_api_types.asset_type_rec_type;
2899 l_asset_cat_rec fa_api_types.asset_cat_rec_type;
2900
2901 begin
2902 x_return_status := OKL_API.G_RET_STS_SUCCESS;
2903 -- Call start_activity to create savepoint, check compatibility
2904 -- and initialize message list
2905 x_return_status := OKL_API.START_ACTIVITY (
2906 l_api_name
2907 ,p_init_msg_list
2908 ,'_PVT'
2909 ,x_return_status);
2910 -- Check if activity started successfully
2911 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2912 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2913 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
2914 RAISE OKL_API.G_EXCEPTION_ERROR;
2915 END IF;
2916
2917 l_asset_hdr_rec.asset_id := p_asset_id;
2918
2919 -- transaction date must be filled in if performing
2920 -- prior period transfer
2921 l_trans_rec.transaction_date_entered := NULL;
2922 l_trans_rec.transaction_name := substr(p_trx_number,1,20);
2923 l_trans_rec.calling_interface := p_calling_interface;
2924 l_trans_rec.who_info.last_updated_by := FND_GLOBAL.USER_ID;
2925 l_trans_rec.who_info.last_update_login := FND_GLOBAL.LOGIN_ID;
2926
2927 l_asset_desc_rec.model_number := p_model_number;
2928 l_asset_desc_rec.manufacturer_name := p_manufacturer;
2929
2930 If p_description is not null AND p_description <> OKL_API.G_MISS_CHAR THEN
2931 l_asset_desc_rec.description := p_description;
2932 end if;
2933
2934 FA_ASSET_DESC_PUB.update_desc(
2935 p_api_version => p_api_version,
2936 p_init_msg_list => p_init_msg_list,
2937 p_commit => FND_API.G_FALSE,
2938 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
2939 x_return_status => x_return_status,
2940 x_msg_count => x_msg_count,
2941 x_msg_data => x_msg_data,
2942 p_calling_fn => p_calling_interface,
2943 px_trans_rec => l_trans_rec,
2944 px_asset_hdr_rec => l_asset_hdr_rec,
2945 px_asset_desc_rec_new => l_asset_desc_rec,
2946 px_asset_cat_rec_new => l_asset_cat_rec);
2947
2948 IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2949 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2950 ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
2951 RAISE OKC_API.G_EXCEPTION_ERROR;
2952 END IF;
2953
2954 x_fa_trx_date := l_trans_rec.transaction_date_entered;
2955
2956 OKL_API.END_ACTIVITY (x_msg_count,
2957 x_msg_data );
2958 EXCEPTION
2959 WHEN OKL_API.G_EXCEPTION_ERROR THEN
2960 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
2961 l_api_name,
2962 G_PKG_NAME,
2963 'OKL_API.G_RET_STS_ERROR',
2964 x_msg_count,
2965 x_msg_data,
2966 '_PVT');
2967 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2968 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
2969 l_api_name,
2970 G_PKG_NAME,
2971 'OKL_API.G_RET_STS_UNEXP_ERROR',
2972 x_msg_count,
2973 x_msg_data,
2974 '_PVT');
2975 WHEN OTHERS THEN
2976 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
2977 l_api_name,
2978 G_PKG_NAME,
2979 'OTHERS',
2980 x_msg_count,
2981 x_msg_data,
2982 '_PVT');
2983 END FIXED_ASSET_UPDATE_DESC;
2984 --akrangan Bug# 5362977 end
2985
2986 -- bug#5207066
2987
2988 --------------------------------------------------------------------------------
2989 --Start of Comments
2990 --Procedure Name : Process_FA_Line
2991 --Description : Processes FA Line and its transactions to create new asset
2992 --History :
2993 -- 28-April-2002 ashish.singh Created
2994 -- 27-Nov-2002 ashish.singh 11.5.9 enhacements
2995 --End of Comments
2996 --------------------------------------------------------------------------------
2997 Procedure Process_FA_Line (p_api_version IN NUMBER,
2998 p_init_msg_list IN VARCHAR2,
2999 x_return_status OUT NOCOPY VARCHAR2,
3000 x_msg_count OUT NOCOPY NUMBER,
3001 x_msg_data OUT NOCOPY VARCHAR2,
3002 p_chrv_id IN Number,
3003 p_fa_line_id IN Number,
3004 p_fin_ast_line_id IN Number,
3005 p_deal_type IN Varchar2,
3006 p_trx_type IN Varchar2,
3007 P_Multi_GAAP_YN IN Varchar2,
3008 P_rep_pdt_book IN Varchar2,
3009 --Bug# 3574232
3010 p_adjust_asset_to_zero IN Varchar2,
3011 --Bug# 3156924
3012 p_trans_number IN Varchar2,
3013 p_calling_interface IN Varchar2,
3014 --Bug# 6373605--SLA populate source
3015 p_sla_asset_chr_id IN Number,
3016 --Bug# 6373605 end
3017 x_cimv_rec OUT NOCOPY cimv_rec_type) is
3018
3019 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
3020 l_api_name CONSTANT varchar2(30) := 'PROCESS_FA_LINE';
3021 l_api_version CONSTANT NUMBER := 1.0;
3022 l_fa_lty_code Varchar2(30) := G_FA_LINE_LTY_CODE;
3023
3024 --cursor definitions------------------------------------------------------------
3025 --Cursor to fetch residual value from top line for operating leas
3026 CURSOR residual_val_csr(p_fin_ast_line_id IN NUMBER) is
3027 SELECT residual_value
3028 FROM OKL_K_LINES
3029 WHERE id = p_fin_ast_line_id;
3030
3031 l_residual_value NUMBER default 0;
3032
3033 --Cursor to chk book validity for an asset category
3034 CURSOR chk_cat_bk_csr(p_book_type_code IN VARCHAR2,
3035 p_category_id IN NUMBER) is
3036 SELECT '!'
3037 FROM OKX_AST_CAT_BKS_V
3038 WHERE CATEGORY_ID = p_category_id
3039 AND BOOK_TYPE_CODE = p_book_type_code
3040 AND STATUS = 'A';
3041
3042 l_cat_bk_exists Varchar2(1) default '?';
3043
3044
3045 --Cursor to fetch tax book information for transaction
3046 CURSOR okl_tadv_csr (p_tal_id IN NUMBER) IS
3047 SELECT asset_number,
3048 description,
3049 quantity,
3050 cost,
3051 tax_book,
3052 life_in_months_tax,
3053 deprn_method_tax,
3054 deprn_rate_tax,
3055 salvage_value,
3056 --bug# 6373605 start
3057 id asd_id
3058 --bug# 6373605 end
3059 FROM okl_txd_Assets_v
3060 where tal_id = p_tal_id;
3061
3062 okl_tadv_rec okl_tadv_csr%ROWTYPE;
3063
3064
3065 --Cursor to check if asset_id already exists in tax_book
3066 CURSOR chk_ast_bk_csr(p_book_type_code IN Varchar2,
3067 p_asset_id IN Number) is
3068 SELECT '!'
3069 FROM OKX_AST_BKS_V
3070 WHERE asset_id = p_asset_id
3071 AND book_type_code = p_book_type_code
3072 AND status = 'A';
3073
3074 l_ast_bk_exists Varchar2(1) default '?';
3075
3076 --Cursor to fetch line style source
3077 Cursor lse_source_csr(p_lty_code IN VARCHAR2) is
3078 select src.jtot_object_code
3079 from OKC_LINE_STYLE_SOURCES src,
3080 OKC_LINE_STYLES_B lse
3081 where src.lse_id = lse.id
3082 and lse.lty_code = p_lty_code;
3083
3084 --Cursor to fetch book records for an asset
3085 --Bug# 2657558 : select of salvage value added
3086 Cursor ast_bks_csr(p_asset_id IN NUMBER,
3087 p_book_class IN VARCHAR2) is
3088 select book_type_code,
3089 cost,
3090 --Bug# 2657558
3091 salvage_value,
3092 --Bug# 2981308
3093 percent_salvage_value
3094 from okx_ast_bks_v
3095 where asset_id = p_Asset_id
3096 and book_class = p_book_class;
3097
3098 l_book_type_code OKX_AST_BKS_V.BOOK_TYPE_CODE%TYPE;
3099 l_asset_cost NUMBER;
3100 l_adjust_cost NUMBER;
3101 --Bug# 2657558
3102 l_salvage_value NUMBER;
3103 l_adj_salvage_value NUMBER;
3104 --Bug# 2981308
3105 l_percent_sv NUMBER;
3106 l_adj_percent_sv NUMBER;
3107
3108 --Cursor chk if corp book is the mass copy source book
3109 CURSOR chk_mass_cpy_book(p_corp_book IN Varchar2,
3110 p_tax_book IN Varchar2) is
3111 SELECT '!'
3112 FROM OKX_ASST_BK_CONTROLS_V
3113 WHERE book_type_code = p_tax_book
3114 AND book_class = 'TAX'
3115 AND mass_copy_source_book = p_corp_book
3116 AND allow_mass_copy = 'YES'
3117 AND copy_additions_flag = 'YES';
3118
3119 l_mass_cpy_book Varchar2(1) default '?';
3120
3121 -- Bug# : 11.5.9 - Multi-GAAP
3122 -- cursor to get values from Corporate Book for rep Prod Book
3123 -- cursor to get the actual values from FA for the contract
3124 CURSOR okx_ast_csr (p_asset_id IN VARCHAR2,
3125 p_book_type_code IN VARCHAR2) is
3126 SELECT okx.acquisition_date in_service_date,
3127 okx.life_in_months life_in_months,
3128 okx.cost cost,
3129 okx.depreciation_category depreciation_category,
3130 okx.deprn_method_code deprn_method_code,
3131 okx.adjusted_rate adjusted_rate,
3132 okx.basic_rate basic_rate,
3133 okx.salvage_value salvage_value,
3134 okx.percent_salvage_value percent_salvage_value,
3135 okx.book_type_code book_type_code,
3136 okx.book_class book_class,
3137 okx.asset_number asset_number,
3138 okx.asset_id asset_id
3139 FROM okx_ast_bks_v okx
3140 WHERE okx.asset_id = p_asset_id
3141 AND okx.book_type_code = p_book_type_code;
3142
3143 okx_ast_rec okx_ast_csr%RowType;
3144 -- Bug# : 11.5.9 - Multi-GAAP
3145
3146
3147 --end-----------cursor definitions----------------------------------------------
3148
3149 l_deal_type OKL_K_HEADERS.DEAL_TYPE%TYPE;
3150 l_talv_rec_in talv_rec_type;
3151 l_cimv_rec_in cimv_rec_type;
3152 l_cimv_rec_out cimv_rec_type;
3153 l_talv_rec talv_rec_type;
3154 l_cimv_rec cimv_rec_type;
3155 l_no_data_found BOOLEAN DEFAULT TRUE;
3156 l_current_units Number;
3157 l_asset_number OKX_ASSETS_V.NAME%Type;
3158 l_asset_description OKX_ASSETS_V.Description%Type;
3159 l_fa_line_id Number;
3160 l_fin_ast_line_id Number;
3161 l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
3162 l_asset_fin_rec FA_API_TYPES.asset_fin_rec_type;
3163 l_asst_count Number default 0;
3164
3165 --parameters for rule apis
3166 l_rgd_code OKC_RULE_GROUPS_B.RGD_CODE%TYPE default G_TAX_OWNER_RGP_CODE;
3167 l_rdf_code OKC_RG_DEF_RULES.RDF_CODE%TYPE default G_TAX_OWNER_RUL_CODE;
3168 l_rdf_name OKC_RULES_B.RULE_INFORMATION1%TYPE default G_TAX_OWNER_RUL_PROMPT;
3169 --Bug #2525946
3170 l_segment_number NUMBER default G_TAX_OWNER_RUL_SEG_NUMBER;
3171 l_id1 OKC_RULES_B.OBJECT1_ID1%TYPE;
3172 l_id2 OKC_RULES_B.OBJECT1_ID2%TYPE;
3173 l_tax_owner Varchar2(200);
3174 l_description Varchar2(1995);
3175 l_status Varchar2(3);
3176 l_start_date date;
3177 l_end_date date;
3178 l_org_id Number;
3179 l_inv_org_id Number;
3180 --l_book_type_code OKX_ASSETS_V.CORPORATE_BOOK%TYPE;
3181 l_select Varchar2(2000);
3182 --bug #2675391 : to store corporate book code for future
3183 l_corp_book OKX_ASSETS_V.CORPORATE_BOOK%TYPE;
3184 l_orig_cost OKX_ASSETS_V.ORIGINAL_COST%TYPE;
3185 l_corp_salvage_value NUMBER;
3186 --Bug# 3156924 : corporate book salvage value should also be preserved for future use
3187 l_corp_percent_sv NUMBER;
3188 --bug # : 11.5.9 enhancements
3189 l_rep_pdt_book OKX_AST_BKS_V.book_type_code%TYPE;
3190 l_Multi_GAAP_YN Varchar2(1);
3191 l_rep_pdt_bk_done Varchar2(1) default 'N';
3192
3193 l_chrv_rec okl_okc_migration_pvt.chrv_rec_type;
3194 l_khrv_rec okl_contract_pub.khrv_rec_type;
3195 x_chrv_rec okl_okc_migration_pvt.chrv_rec_type;
3196 x_khrv_rec okl_contract_pub.khrv_rec_type;
3197
3198 l_bk_dfs_rec bk_dfs_csr%ROWTYPE;
3199
3200 l_func_curr_code OKL_K_HEADERS_FULL_V.CURRENCY_CODE%TYPE;
3201 l_chr_curr_code OKL_K_HEADERS_FULL_V.CURRENCY_CODE%TYPE;
3202
3203 x_contract_currency okl_k_headers_full_v.currency_code%TYPE;
3204 x_currency_conversion_type okl_k_headers_full_v.currency_conversion_type%TYPE;
3205 x_currency_conversion_rate okl_k_headers_full_v.currency_conversion_rate%TYPE;
3206 x_currency_conversion_date okl_k_headers_full_v.currency_conversion_date%TYPE;
3207
3208 --Bug# 3156924 :
3209 --cursor to fetch transaction number from okl_trx_assets
3210 cursor l_tas_csr(p_tas_id in number) is
3211 select to_char(trans_number),
3212 DATE_TRANS_OCCURRED,
3213 --Bug# 6373605 start
3214 id tas_id,
3215 try_id
3216 --Bug# 6373605 end
3217 from okl_trx_assets
3218 where id = p_tas_id;
3219
3220 l_trans_number okl_trx_contracts.trx_number%TYPE := p_trans_number;
3221 l_trans_date okl_trx_assets.date_trans_occurred%TYPE;
3222 l_calling_interface varchar2(30) := p_calling_interface;
3223 --Bug# 3156924
3224 --Bug# 6373605 start
3225 l_tas_id okl_trx_assets.id%TYPE;
3226 l_try_id okl_trx_assets.try_id%TYPE;
3227 --Bug# 6373605 end
3228
3229 --Bug# 4028371
3230 l_fa_add_date_corp date;
3231 l_fa_add_date_tax date;
3232 l_fa_add_date_mg date;
3233 l_fa_adj_date_corp date;
3234 l_fa_adj_date_tax date;
3235 l_fa_adj_date_mg date;
3236 l_talv_date_rec okl_tal_pvt.talv_rec_type;
3237 lx_talv_date_rec okl_tal_pvt.talv_rec_type;
3238 --Bug# 4028371
3239
3240 --Bug# 3548044
3241 l_corp_cost NUMBER;
3242
3243 --Bug# 3838703
3244 --cursor to get tax owner rule
3245 Cursor town_rul_csr (pchrid number) is
3246 Select rule_information1 tax_owner,
3247 id
3248 From okc_rules_b rul
3249 where rul.dnz_chr_id = pchrid
3250 and rul.rule_information_category = 'LATOWN'
3251 and nvl(rul.STD_TEMPLATE_YN,'N') = 'N';
3252
3253 l_town_rul okc_rules_b.rule_information1%TYPE;
3254 l_town_rul_id okc_rules_b.id%TYPE;
3255
3256 --Bug# 5261704
3257 l_depreciate_flag VARCHAR2(3);
3258 --Bug# 6373605
3259 -- Cursor to fetch txd transaction for a tax book
3260 Cursor l_txd_for_book_csr (p_book_type_code in varchar2,
3261 p_tal_id in number) is
3262 select id
3263 from okl_txd_assets_b txdb
3264 where tal_id = p_tal_id
3265 and tax_book = p_book_type_code;
3266
3267 l_txd_for_book_rec l_txd_for_book_csr%ROWTYPE;
3268
3269 l_sla_source_line_id NUMBER;
3270 l_sla_source_line_table OKL_EXT_FA_LINE_SOURCES_V.SOURCE_TABLE%TYPE;
3271 --Bug# 6373605 end
3272
3273 Begin
3274
3275
3276 x_return_status := OKL_API.G_RET_STS_SUCCESS;
3277 -- Call start_activity to create savepoint, check compatibility
3278 -- and initialize message list
3279 x_return_status := OKL_API.START_ACTIVITY (
3280 l_api_name
3281 ,p_init_msg_list
3282 ,'_PVT'
3283 ,x_return_status);
3284 -- Check if activity started successfully
3285 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
3286 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
3287 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
3288 RAISE OKL_API.G_EXCEPTION_ERROR;
3289 END IF;
3290
3291 --Bug# 5261704 : opened this cursor earlier as tax owner value is required
3292 -- for asset addition for setting depreciation flag to 'NO'
3293 -- with cursor town_rul_csr
3294 Open town_rul_csr(pchrid => p_chrv_id);
3295 Fetch town_rul_csr into l_town_rul, l_town_rul_id;
3296 Close town_rul_csr;
3297
3298 l_tax_owner := rtrim(ltrim(l_town_rul,' '),' ');
3299
3300 l_fa_line_id := p_fa_line_id;
3301 l_fin_ast_line_id := p_fin_ast_line_id;
3302 l_deal_type := p_deal_type;
3303 --Bug # : 11.5.9 - Multi-GAAP
3304 l_rep_pdt_book := p_rep_pdt_book;
3305 l_Multi_GAAP_YN := p_Multi_GAAP_YN;
3306
3307 l_cimv_rec := get_cimv_rec(l_fa_line_id, l_no_data_found);
3308 If l_no_data_found = TRUE Then
3309 --dbms_output.put_line('no fa item (line source) records ...!');
3310 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
3311 p_msg_name => G_FA_ITEM_REC_NOT_FOUND,
3312 p_token1 => G_FA_LINE_ID,
3313 p_token1_value => to_char(l_fa_line_id)
3314 );
3315 RAISE OKL_API.G_EXCEPTION_ERROR;
3316 Else
3317 If (l_cimv_rec.jtot_object1_code is not null) and (l_cimv_rec.object1_id1) is not null Then
3318 Null; --asset is already linked
3319 x_cimv_rec := l_cimv_rec;
3320 l_asst_count := l_asst_count+1;
3321 Elsif (l_cimv_rec.jtot_object1_code is null) OR (l_cimv_rec.object1_id1 is null) Then
3322 --go to txlv to fetch the transaction record
3323 l_talv_rec := get_talv_rec(l_fa_line_id, p_trx_type, l_no_data_found);
3324 If l_no_data_found = TRUE Then
3325 --dbms_output.put_line('no asset creation transaction records ...!');
3326 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
3327 p_msg_name => G_FA_TRX_REC_NOT_FOUND,
3328 p_token1 => G_FA_LINE_ID,
3329 p_token1_value => to_char(l_fa_line_id)
3330 );
3331 RAISE OKL_API.G_EXCEPTION_ERROR;
3332 Else
3333 --bug#2675391 set corp book name for future use
3334 l_corp_book := l_talv_rec.corporate_book;
3335 --check if depreciation category has been entered
3336 if l_talv_rec.depreciation_id is null then
3337 --dbms_output.put_line('Asset category not entered for Asset transaction..');
3338 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
3339 p_msg_name => G_AST_CAT_NOT_ENTERED,
3340 p_token1 => G_ASSET_NUMBER_TOKEN,
3341 p_token1_value => l_talv_rec.asset_number
3342 );
3343 RAISE OKL_API.G_EXCEPTION_ERROR;
3344 end if;
3345
3346 --check if asset category has been entered
3347 If l_talv_rec.fa_location_id is null then
3348 --dbms_output.put_line('FA location not entered for Asset transaction..');
3349 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
3350 p_msg_name => G_AST_LOC_NOT_ENTERED,
3351 p_token1 => G_ASSET_NUMBER_TOKEN,
3352 p_token1_value => l_talv_rec.asset_number
3353 );
3354 RAISE OKL_API.G_EXCEPTION_ERROR;
3355 End If;
3356
3357 --Bug# 3156924 : Fetch transaction details for calling FA interfaces
3358 -----------------
3359 --Bug# 6791359 : Commented the If clause
3360 ----------------
3361 --If nvl(l_trans_number,okl_api.G_MISS_CHAR) = OKL_API.G_MISS_CHAR then
3362 Open l_tas_csr(p_tas_id => l_talv_rec.tas_id);
3363 Fetch l_tas_csr into l_trans_number,
3364 l_trans_date,
3365 --bug# 6373605 start
3366 l_tas_id,
3367 l_try_id;
3368 --Bug# 6373605 end
3369 if l_tas_csr%NOTFOUND then
3370 Null;
3371 end if;
3372 Close l_tas_csr;
3373 --End If;
3374 -----------------
3375 --END Bug# 6791359 : Commented the If clause
3376 ----------------
3377 --Bug# 3156924
3378
3379 --check salvage value for operating Lease
3380
3381 -- Bug# 3103387 - Changed NVL check from 0 to okl_api.G_MISS_NUM
3382 If (nvl(l_talv_rec.salvage_value,okl_api.G_MISS_NUM) = okl_api.G_MISS_NUM and nvl(l_talv_rec.percent_salvage_value,okl_api.G_MISS_NUM) = okl_api.G_MISS_NUM
3383 and l_Deal_Type = G_OP_LEASE_BK_CLASS) Then
3384
3385 --get the residual value from top line
3386 OPEN residual_val_csr(p_fin_ast_line_id => l_fin_ast_line_id);
3387 FETCH residual_val_csr into
3388 l_residual_value;
3389 IF residual_val_csr%NOTFOUND Then
3390 Null;
3391 Else
3392 l_talv_rec.salvage_value :=l_residual_value;
3393 End If;
3394 CLOSE residual_val_csr;
3395 End If;
3396
3397 --Bug# 2967286: store corp book salvage value for future use
3398 l_corp_salvage_value := l_talv_rec.salvage_value;
3399 --Bug# 2967286 end
3400 --Bug# 3156924 : percent sv should also be saved for future use
3401 l_corp_percent_sv := l_talv_rec.percent_salvage_value;
3402 --Bug# 3548044
3403 l_corp_cost := l_talv_rec.depreciation_cost;
3404
3405 --check for category-id book type code validity
3406 l_cat_bk_exists := '?';
3407 open chk_cat_bk_csr(p_book_type_code => l_talv_rec.corporate_book,
3408 p_category_id => l_talv_rec.depreciation_id);
3409 Fetch chk_cat_bk_csr into l_cat_bk_exists;
3410 If chk_cat_bk_csr%NOTFOUND Then
3411 null;
3412 End If;
3413 Close chk_cat_bk_csr;
3414 If l_cat_bk_exists = '?' Then
3415 --dbms_output.put_line('Not a valid corporate book for category..');
3416 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
3417 p_msg_name => G_FA_INVALID_BK_CAT,
3418 p_token1 => G_FA_BOOK,
3419 p_token1_value => l_talv_rec.corporate_book,
3420 p_token2 => G_ASSET_CATEGORY,
3421 p_token2_value => to_char(l_talv_rec.depreciation_id)
3422 );
3423 RAISE OKL_API.G_EXCEPTION_ERROR;
3424 Else
3425 --Bug# 5261704 : Set depreciate flag to 'NO' for
3426 -- deal types where cost will be subsequently adjusted to zero
3427 l_depreciate_flag := 'YES';
3428 If (l_deal_type = 'LOAN') OR
3429 (l_deal_type in (G_ST_LEASE_BK_CLASS,G_DF_LEASE_BK_CLASS)) Then
3430 l_depreciate_flag := 'NO';
3431 End If;
3432 --End Bug# 5261704
3433 FIXED_ASSET_ADD(p_api_version => p_api_version,
3434 p_init_msg_list => p_init_msg_list,
3435 x_return_status => x_return_status,
3436 x_msg_count => x_msg_count,
3437 x_msg_data => x_msg_data,
3438 p_talv_rec => l_talv_rec,
3439 --bug# 3156924
3440 p_trans_number => l_trans_number,
3441 p_calling_interface => l_calling_interface,
3442 --Bug# 5261704
3443 p_depreciate_flag => l_depreciate_flag,
3444 --Bug# 6373605--SLA populate source
3445 p_sla_source_header_id => l_tas_id,
3446 p_sla_source_header_table => 'OKL_TRX_ASSETS',
3447 p_sla_source_try_id => l_try_id,
3448 p_sla_source_line_id => l_talv_rec.id,
3449 p_sla_source_line_table => 'OKL_TXL_ASSETS_B',
3450 p_sla_source_chr_id => p_chrv_id,
3451 p_sla_source_kle_id => p_fin_ast_line_id,
3452 p_sla_asset_chr_id => p_sla_asset_chr_id,
3453 --Bug# 6373605--SLA populate sources
3454 --Bug# 4028371
3455 x_fa_trx_date => l_fa_add_date_corp,
3456 x_asset_hdr_rec => l_asset_hdr_rec);
3457 --dbms_output.put_line('After fixed_asset_add corp book'||x_return_status);
3458 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
3459 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
3460 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
3461 RAISE OKL_API.G_EXCEPTION_ERROR;
3462 END IF;
3463 End If;
3464
3465 --Bug# : 11.5.9 Multi GAAP
3466 l_rep_pdt_bk_done := 'N';
3467 --get the tax book records
3468 open okl_tadv_csr(p_tal_id => l_talv_rec.id);
3469 Loop
3470 Fetch okl_tadv_csr
3471 into okl_tadv_rec;
3472 --check whether correct tax book for asset category
3473 Exit When okl_tadv_csr%NOTFOUND;
3474 l_cat_bk_exists := '?';
3475 open chk_cat_bk_csr(p_book_type_code => okl_tadv_rec.tax_book,
3476 p_category_id => l_talv_rec.depreciation_id);
3477 Fetch chk_cat_bk_csr into l_cat_bk_exists;
3478 If chk_cat_bk_csr%NOTFOUND Then
3479 null;
3480 End If;
3481 Close chk_cat_bk_csr;
3482
3483 If l_cat_bk_exists = '?' Then
3484 --dbms_output.put_line('Not a valid tax book for category..');
3485 --raise appropriate error
3486 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
3487 p_msg_name => G_FA_INVALID_BK_CAT,
3488 p_token1 => G_FA_BOOK,
3489 p_token1_value => okl_tadv_rec.tax_book,
3490 p_token2 => G_ASSET_CATEGORY,
3491 p_token2_value => to_char(l_talv_rec.depreciation_id)
3492 );
3493 RAISE OKL_API.G_EXCEPTION_ERROR;
3494 Else
3495 --check if asset already exists in tax book
3496 l_ast_bk_exists := '?';
3497 Open chk_ast_bk_csr(p_book_type_code => okl_tadv_rec.tax_book,
3498 p_asset_id => l_asset_hdr_rec.asset_id);
3499 Fetch chk_ast_bk_csr into l_ast_bk_exists;
3500 If chk_ast_bk_csr%NOTFOUND Then
3501 Null;
3502 End If;
3503 Close chk_ast_bk_csr;
3504
3505 If l_ast_bk_exists = '!' Then --asset already exists in tax book
3506 null; --do not have to add again
3507 Else
3508 --chk if corp book is the mass copy book for the tax book
3509 l_mass_cpy_book := '?';
3510 OPEN chk_mass_cpy_book(
3511 --bug#2675391 : use previously stored corp book code
3512 --p_corp_book => l_talv_rec.corporate_book,
3513 p_corp_book => l_corp_book,
3514 p_tax_book => okl_tadv_rec.tax_book);
3515 Fetch chk_mass_cpy_book into l_mass_cpy_book;
3516 If chk_mass_cpy_book%NOTFOUND Then
3517 Null;
3518 End If;
3519 Close chk_mass_cpy_book;
3520
3521 If l_mass_cpy_book = '?' Then
3522 --can not mass copy into tax book
3523 --dbms_output.put_line('Can not copy into tax book ...');
3524 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
3525 p_msg_name => G_FA_TAX_CPY_NOT_ALLOWED,
3526 p_token1 => G_FA_BOOK,
3527 p_token1_value => okl_tadv_rec.tax_book
3528 );
3529 RAISE OKL_API.G_EXCEPTION_ERROR;
3530 --raise appropriate error message;
3531 Else
3532 --can masscopy
3533 --intialize talv record for tax book
3534 l_talv_rec.corporate_book := okl_tadv_rec.tax_book;
3535 l_talv_rec.dnz_asset_id := l_asset_hdr_rec.asset_id;
3536 --l_talv_rec.asset_number := okl_tadv_rec.asset_number;
3537 --l_talv_rec.description := okl_tadv_rec.description;
3538 If okl_tadv_rec.cost is not null Then
3539 l_talv_rec.depreciation_cost := okl_tadv_rec.cost;
3540 End If;
3541 l_talv_rec.life_in_months := okl_tadv_rec.life_in_months_tax;
3542 l_talv_rec.deprn_method := okl_tadv_rec.deprn_method_tax;
3543 l_talv_rec.deprn_rate := okl_tadv_rec.deprn_rate_tax;
3544 --Bug#-2397777 : residual value should be salvage value for operating lease if no sal. value given explicitly:
3545 --Bug#2967286 : salvage value should be equal to
3546 --corp book salvage value only for Multi-Gapp tax books.
3547 --For others it should be eqaul to zero
3548
3549 --check salvage value for operating Lease
3550 If l_rep_pdt_book = okl_tadv_rec.tax_book Then
3551
3552 -- Bug# 3103387 - Changed NVL check from 0
3553 -- to okl_api.G_MISS_NUM
3554 If (nvl(l_talv_rec.salvage_value,okl_api.G_MISS_NUM) = okl_api.G_MISS_NUM and nvl(l_talv_rec.percent_salvage_value,okl_api.G_MISS_NUM) = okl_api.G_MISS_NUM
3555 and l_Deal_Type = G_OP_LEASE_BK_CLASS) Then
3556 --null; --salvage value shouldbe residual value as for corp book
3557 --salvage value should be equal to corp book salvage value
3558 l_talv_rec.salvage_value := l_corp_salvage_value;
3559 --Bug# 3156924 :
3560 l_talv_rec.percent_salvage_value := l_corp_percent_sv;
3561 else
3562 --tadv salvage value not getting populated now so
3563 --l_talv_rec.salvage_value := okl_tadv_rec.salvage_value;
3564 l_talv_rec.salvage_value := l_corp_salvage_value;
3565 --Bug# 3156924 :
3566 l_talv_rec.percent_salvage_value := l_corp_percent_sv;
3567 end if;
3568 Else
3569 --bug# 2967286
3570 --l_talv_rec.salvage_value := 0;
3571 --Bug# 3156924
3572 l_talv_rec.salvage_value := null;
3573 --bug# 3156924 :
3574 l_talv_rec.percent_salvage_value := null;
3575 End If;
3576
3577 --Bug# 5261704 : Set depreciate flag to 'NO' for
3578 -- deal types where cost will be subsequently adjusted to zero
3579 -- If LOAN or
3580 -- If DF ST with LESSEE AND
3581 -- Book <> Multi-GAAP Book
3582 l_depreciate_flag := 'YES';
3583 If ((l_deal_type = 'LOAN') OR
3584 (l_deal_type in (G_ST_LEASE_BK_CLASS,G_DF_LEASE_BK_CLASS) AND l_tax_owner = 'LESSEE')
3585 ) AND
3586 l_talv_rec.corporate_book <> nvl(l_rep_pdt_book,okl_api.g_miss_char) Then
3587 l_depreciate_flag := 'NO';
3588 End If;
3589 If (l_Multi_GAAP_YN = 'Y') AND
3590 (l_talv_rec.corporate_book = nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR)) AND
3591 (p_adjust_asset_to_zero = 'Y') Then
3592 l_depreciate_flag := 'NO';
3593 End If;
3594 --End Bug# 5261704
3595 --call mass additions add for tax book
3596 FIXED_ASSET_ADD(p_api_version => p_api_version,
3597 p_init_msg_list => p_init_msg_list,
3598 x_return_status => x_return_status,
3599 x_msg_count => x_msg_count,
3600 x_msg_data => x_msg_data,
3601 p_talv_rec => l_talv_rec,
3602 --Bug# 3156924
3603 p_trans_number => l_trans_number,
3604 p_calling_interface => l_calling_interface,
3605 --Bug# 5261704
3606 p_depreciate_flag => l_depreciate_flag,
3607 --Bug# 6373605--SLA populate source
3608 p_sla_source_header_id => l_tas_id,
3609 p_sla_source_header_table => 'OKL_TRX_ASSETS',
3610 p_sla_source_try_id => l_try_id,
3611 p_sla_source_line_id => okl_tadv_rec.asd_id,
3612 p_sla_source_line_table => 'OKL_TXD_ASSETS_B',
3613 p_sla_source_chr_id => p_chrv_id,
3614 p_sla_source_kle_id => p_fin_ast_line_id,
3615 p_sla_asset_chr_id => p_sla_asset_chr_id,
3616 --Bug# 6373605--SLA populate sources
3617 --Bug# 4028371
3618 x_fa_trx_date => l_fa_add_date_tax,
3619 x_asset_hdr_rec => l_asset_hdr_rec);
3620 --dbms_output.put_line('After tax book "'||okl_tadv_rec.tax_book||'" :'||x_return_status);
3621 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
3622 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
3623 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
3624 RAISE OKL_API.G_EXCEPTION_ERROR;
3625 END IF;
3626 End If; --can mass copy into tax book
3627 End If; --asset does not exist in tax book
3628 End If; -- valid tax book for category
3629
3630 --Bug# : 11.5.9 Multi GAAP Begin
3631
3632 If l_rep_pdt_book = okl_tadv_rec.tax_book Then
3633 l_rep_pdt_bk_done := 'Y';
3634 End If;
3635
3636 End Loop; -- get tax book records
3637
3638 --Bug# : 11.5.9 Multi GAAP End
3639 Close okl_tadv_csr;
3640
3641 --Bug# : 11.5.9 Multi GAAP
3642 If (l_Multi_GAAP_YN = 'Y') and (l_rep_pdt_book is not null) Then
3643 If l_rep_pdt_bk_done = 'Y' Then
3644 Null;
3645 Elsif l_rep_pdt_bk_done = 'N' Then
3646 --add asset to reporting product book
3647 Open okx_ast_csr(p_asset_id => l_asset_hdr_rec.asset_id,
3648 p_book_type_code => l_corp_book);
3649 Fetch okx_ast_csr into okx_ast_rec;
3650 If okx_ast_csr%NotFound Then
3651 null;
3652 --asset should be already in corp book to reach this stage;
3653 --so not raising an error
3654 End if;
3655 Close okx_ast_csr;
3656
3657 l_cat_bk_exists := '?';
3658 open chk_cat_bk_csr(p_book_type_code => l_rep_pdt_book,
3659 p_category_id => okx_ast_rec.depreciation_category);
3660 Fetch chk_cat_bk_csr into l_cat_bk_exists;
3661 If chk_cat_bk_csr%NOTFOUND Then
3662 null;
3663 End If;
3664 Close chk_cat_bk_csr;
3665
3666 If l_cat_bk_exists = '?' Then
3667 --dbms_output.put_line('Not a valid tax book for category..');
3668 --raise appropriate error
3669 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
3670 p_msg_name => G_FA_INVALID_BK_CAT,
3671 p_token1 => G_FA_BOOK,
3672 p_token1_value => l_rep_pdt_book,
3673 p_token2 => G_ASSET_CATEGORY,
3674 p_token2_value => to_char(okx_ast_rec.depreciation_category)
3675 );
3676 RAISE OKL_API.G_EXCEPTION_ERROR;
3677 Else
3678 --check if asset already exists in tax book
3679 l_ast_bk_exists := '?';
3680 Open chk_ast_bk_csr(p_book_type_code => l_rep_pdt_book,
3681 p_asset_id => okx_ast_rec.asset_id);
3682 Fetch chk_ast_bk_csr into l_ast_bk_exists;
3683 If chk_ast_bk_csr%NOTFOUND Then
3684 Null;
3685 End If;
3686 Close chk_ast_bk_csr;
3687
3688 If l_ast_bk_exists = '!' Then --asset already exists in tax book
3689 null; --do not have to add again
3690 Else
3691 --chk if corp book is the mass copy book for the tax book
3692 l_mass_cpy_book := '?';
3693 OPEN chk_mass_cpy_book(
3694 --bug#2675391 : use previously stored corp book code
3695 --p_corp_book => l_talv_rec.corporate_book,
3696 p_corp_book => l_corp_book,
3697 p_tax_book => l_rep_pdt_book);
3698 Fetch chk_mass_cpy_book into l_mass_cpy_book;
3699 If chk_mass_cpy_book%NOTFOUND Then
3700 Null;
3701 End If;
3702 Close chk_mass_cpy_book;
3703
3704 If l_mass_cpy_book = '?' Then
3705 --can not mass copy into tax book
3706 --dbms_output.put_line('Can not copy into tax book ...');
3707 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
3708 p_msg_name => G_FA_TAX_CPY_NOT_ALLOWED,
3709 p_token1 => G_FA_BOOK,
3710 p_token1_value => l_rep_pdt_book
3711 );
3712 RAISE OKL_API.G_EXCEPTION_ERROR;
3713 --raise appropriate error message;
3714 Else
3715
3716 open bk_dfs_csr(ctId => okx_ast_rec.depreciation_category,
3717 effDat => okx_ast_rec.in_service_date,
3718 bk => l_rep_pdt_book);
3719 Fetch bk_dfs_csr into l_bk_dfs_rec;
3720 If bk_dfs_csr%NOTFOUND Then
3721 Close bk_dfs_csr;
3722 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
3723 p_msg_name => G_FA_INVALID_BK_CAT,
3724 p_token1 => G_FA_BOOK,
3725 p_token1_value => l_rep_pdt_book,
3726 p_token2 => G_ASSET_CATEGORY,
3727 p_token2_value => to_char(okx_ast_rec.depreciation_category));
3728 RAISE OKL_API.G_EXCEPTION_ERROR;
3729 End If;
3730 Close bk_dfs_csr;
3731
3732 --can masscopy
3733 --intialize talv record for tax book
3734 l_talv_rec.corporate_book := l_rep_pdt_book;
3735
3736 l_talv_rec.dnz_asset_id := l_asset_hdr_rec.asset_id;
3737 --l_talv_rec.asset_number := okl_tadv_rec.asset_number;
3738 --l_talv_rec.description := okl_tadv_rec.description;
3739
3740 --l_chr_curr_code := l_hdr_rec.CURRENCY_CODE;
3741 --l_func_curr_code := OKC_CURRENCY_API.GET_OU_CURRENCY(l_hdr_rec.authoring_org_id);
3742
3743
3744 --Bug# 3548044 :
3745 l_talv_rec.depreciation_cost := l_corp_cost;
3746 l_talv_rec.salvage_value := l_corp_salvage_value;
3747 l_talv_rec.percent_salvage_value := l_corp_percent_sv;
3748 --l_talv_rec.depreciation_cost := okx_ast_rec.cost;
3749 --l_talv_rec.salvage_value := okx_ast_rec.salvage_value;
3750 --l_talv_rec.percent_salvage_value := okx_ast_rec.percent_salvage_value;
3751
3752 /* --As already adding in Functional currency Following conversion is not required
3753 If ( ( l_func_curr_code IS NOT NULL) AND ( l_chr_curr_code <> l_func_curr_code )) Then
3754
3755 okl_accounting_util.convert_to_contract_currency(
3756 p_khr_id => p_chrv_id,
3757 p_from_currency => l_func_curr_code,
3758 p_transaction_date => l_hdr_rec.start_date,
3759 p_amount => okx_ast_rec.cost,
3760 x_contract_currency => x_contract_currency,
3761 x_currency_conversion_type => x_currency_conversion_type,
3762 x_currency_conversion_rate => x_currency_conversion_rate,
3763 x_currency_conversion_date => x_currency_conversion_date,
3764 x_converted_amount => l_talv_rec.depreciation_cost);
3765
3766 okl_accounting_util.convert_to_contract_currency(
3767 p_khr_id => p_chrv_id,
3768 p_from_currency => l_func_curr_code,
3769 p_transaction_date => G_CHR_START_DATE,
3770 p_amount => okx_ast_rec.salvage_value,
3771 x_contract_currency => x_contract_currency,
3772 x_currency_conversion_type => x_currency_conversion_type,
3773 x_currency_conversion_rate => x_currency_conversion_rate,
3774 x_currency_conversion_date => x_currency_conversion_date,
3775 x_converted_amount => l_talv_rec.salvage_value);
3776
3777 End If;
3778 --As already adding in Functional currency Following conversion is not required */
3779
3780 -----------------------------------------------------------------
3781 --Bug# 2981308 : Multi-Gaap Book should be identical to CORP Book
3782 --Bug# 3548044 : Re-fix on above: Multi-Gaap Book should read from category defaults
3783 -----------------------------------------------------------------
3784 l_talv_rec.life_in_months := l_bk_dfs_rec.life_in_months;
3785 l_talv_rec.deprn_method := l_bk_dfs_rec.deprn_method;
3786 l_talv_rec.deprn_rate := l_bk_dfs_rec.adjusted_rate;
3787 --l_talv_rec.life_in_months := okx_ast_rec.life_in_months;
3788 --l_talv_rec.deprn_method := okx_ast_rec.deprn_method_code;
3789 --l_talv_rec.deprn_rate := okx_ast_rec.adjusted_rate;
3790
3791 --call mass additions add for reporting product tax book
3792 --Bug# 5261704 :
3793 l_depreciate_flag := 'YES';
3794 If p_adjust_asset_to_zero = 'Y' Then
3795 l_depreciate_flag := 'NO';
3796 End If;
3797 FIXED_ASSET_ADD(p_api_version => p_api_version,
3798 p_init_msg_list => p_init_msg_list,
3799 x_return_status => x_return_status,
3800 x_msg_count => x_msg_count,
3801 x_msg_data => x_msg_data,
3802 p_talv_rec => l_talv_rec,
3803 --Bug# 3621663
3804 --p_no_curr_conv => OKL_API.G_TRUE,
3805 --Bug# 3156924
3806 p_trans_number => l_trans_number,
3807 p_calling_interface => l_calling_interface,
3808 --Bug# :5261704
3809 p_depreciate_flag => l_depreciate_flag,
3810 --Bug# 6373605--SLA populate source
3811 p_sla_source_header_id => l_tas_id,
3812 p_sla_source_header_table => 'OKL_TRX_ASSETS',
3813 p_sla_source_try_id => l_try_id,
3814 --as no transaction exists for Multi-Gaap book using the parent
3815 --corporate book transaction as source
3816 p_sla_source_line_id => l_talv_rec.id,
3817 p_sla_source_line_table => 'OKL_TXL_ASSETS_B',
3818 p_sla_source_chr_id => p_chrv_id,
3819 p_sla_source_kle_id => p_fin_ast_line_id,
3820 p_sla_asset_chr_id => p_sla_asset_chr_id,
3821 --Bug# 6373605--SLA populate sources
3822
3823 --Bug# 4028371
3824 x_fa_trx_date => l_fa_add_date_mg,
3825 x_asset_hdr_rec => l_asset_hdr_rec);
3826 --dbms_output.put_line('After tax book "'||okl_tadv_rec.tax_book||'" :'||x_return_status);
3827 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
3828 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
3829 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
3830 RAISE OKL_API.G_EXCEPTION_ERROR;
3831 END IF;
3832 End If; --can mass copy into tax book
3833 End If; --asset does not exist in tax book
3834 End If; -- valid tax book for category
3835 End If; --l_rep_pdt_book_done = 'N'
3836 End If; --l_Multi_GAAP_YN = 'Y'
3837 --Bug# : 11.5.9 Multi GAAP Book creation End
3838
3839 --tie back asset id into fa item record
3840 l_cimv_rec.object1_id1 := to_char(l_asset_hdr_rec.asset_id);
3841 l_cimv_rec.object1_id2 := '#';
3842 Open lse_source_csr(l_fa_lty_code);
3843 Fetch lse_source_csr into l_cimv_rec.jtot_object1_code;
3844 If lse_source_csr%NOTFOUND Then
3845 --dbms_output.put_line('Fatal error due to setup - lse source undefined');
3846 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
3847 p_msg_name => G_JTF_UNDEF_LINE_SOURCE,
3848 p_token1 => G_LTY_CODE,
3849 p_token1_value => l_fa_lty_code
3850 );
3851 RAISE OKL_API.G_EXCEPTION_ERROR;
3852 End If;
3853 Close lse_source_csr;
3854
3855 OKL_OKC_MIGRATION_PVT.update_contract_item
3856 (p_api_version => p_api_version,
3857 p_init_msg_list => p_init_msg_list,
3858 x_return_status => x_return_status,
3859 x_msg_count => x_msg_count,
3860 x_msg_data => x_msg_data,
3861 p_cimv_rec => l_cimv_rec,
3862 x_cimv_rec => l_cimv_rec_out);
3863 --dbms_output.put_line('After calling update item :'||x_return_status);
3864 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
3865 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
3866 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
3867 RAISE OKL_API.G_EXCEPTION_ERROR;
3868 END IF;
3869 x_cimv_rec := l_cimv_rec_out;
3870 l_asst_count := l_asst_count+1;
3871
3872 -- if sales type lease then adjust the costs to zero
3873 --dbms_output.put_line('Deal Type :'||l_deal_type);
3874 --Bug: 11.5.9 - Now will check for 'LOAN' Book Class
3875 --IF l_Deal_Type = G_ST_LEASE_BK_CLASS Then
3876 IF l_Deal_Type = 'LOAN' Then
3877 --call adjustment API to set the costs to zero in
3878 --both types of books
3879 -- 1. for corporate cook
3880 Open ast_bks_csr(p_asset_id => l_asset_hdr_rec.asset_id,
3881 p_book_class => G_FA_CORP_BOOK_CLASS_CODE);
3882 --Bug#2657558 : selecting salvage_value
3883 Fetch ast_bks_csr into
3884 l_book_type_code,
3885 l_asset_cost,
3886 l_salvage_value,
3887 --Bug# 2981308
3888 l_percent_sv;
3889 If ast_bks_csr%NOTFOUND Then
3890 --dbms_output.put_line('Book information not found for asset..');
3891 --no need to raise error here
3892 null;
3893 Else
3894 l_adjust_cost := (-1)* l_asset_cost;
3895 --Bug # 2657558
3896 l_adj_salvage_value := (-1)*l_salvage_value;
3897 --Bug #2774529:
3898 --Bug# 2981308 :
3899 l_adj_percent_sv := (-1)*l_percent_sv;
3900 IF nvl(l_adjust_cost,0) = 0 and nvl(l_adj_salvage_value,0) = 0 and nvl(l_adj_percent_sv,0) = 0 Then
3901 Null;
3902 Else
3903 -- to_make asset cost zero
3904 FIXED_ASSET_ADJUST_COST
3905 (p_api_version => p_api_version,
3906 p_init_msg_list => p_init_msg_list,
3907 x_return_status => x_return_status,
3908 x_msg_count => x_msg_count,
3909 x_msg_data => x_msg_data,
3910 p_chr_id => p_chrv_id,
3911 p_asset_id => l_asset_hdr_rec.asset_id,
3912 p_book_type_code => l_book_type_code,
3913 p_adjust_cost => l_adjust_cost,
3914 --Bug # 2657558
3915 p_adj_salvage_value => l_adj_salvage_value,
3916 -- Bug Fix# 2925461
3917 --Bug# 2981308
3918 p_adj_percent_sv => l_adj_percent_sv,
3919 p_trans_number => l_trans_number,
3920 p_calling_interface => l_calling_interface,
3921 --Bug# 4028371:
3922 x_fa_trx_date => l_fa_adj_date_corp,
3923 --Bug# 3156924
3924 p_adj_date => l_talv_rec.in_service_date,
3925 --Bug# 6373605--SLA populate source
3926 p_sla_source_header_id => l_tas_id,
3927 p_sla_source_header_table => 'OKL_TRX_ASSETS',
3928 p_sla_source_try_id => l_try_id,
3929 p_sla_source_line_id => l_talv_rec.id,
3930 p_sla_source_line_table => 'OKL_TXL_ASSETS_B',
3931 p_sla_source_chr_id => p_chrv_id,
3932 p_sla_source_kle_id => p_fin_ast_line_id,
3933 p_sla_asset_chr_id => p_sla_asset_chr_id,
3934 --Bug# 6373605--SLA populate sources
3935 x_asset_fin_rec => l_asset_fin_rec);
3936 --dbms_output.put_line('After fixed asset adjust Corp Bk for ST Lease :'||x_return_status);
3937 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
3938 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
3939 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
3940 RAISE OKL_API.G_EXCEPTION_ERROR;
3941 END IF;
3942 End If;
3943 --Bug #2774529: End
3944 End If;
3945 Close ast_bks_csr;
3946
3947 --2. for tax books
3948 Open ast_bks_csr(p_asset_id => l_asset_hdr_rec.asset_id,
3949 p_book_class => G_FA_TAX_BOOK_CLASS_CODE);
3950 Loop
3951 --Bug# 2657558 : selecting salvage_value
3952 Fetch ast_bks_csr into
3953 l_book_type_code,
3954 l_asset_cost,
3955 l_salvage_value,
3956 --Bug# 2981308
3957 l_percent_sv;
3958 Exit When ast_bks_csr%NOTFOUND;
3959
3960 --Bug# 11.5.9: Multi-GAAP Check for reporting book added
3961 --cost has to be preserved in Tax Book
3962 If l_book_type_code = nvl(l_rep_pdt_book,'NO_BOOK') Then
3963 Null;
3964 Else
3965 l_adjust_cost := (-1)* l_asset_cost;
3966 --Bug # 2657558
3967 l_adj_salvage_value := (-1)*l_salvage_value;
3968 --Bug# 2774529:
3969 --Bug# 3156924:
3970 l_adj_percent_sv := (-1)*l_percent_sv;
3971 --Bug# 3156924
3972 IF nvl(l_adjust_cost,0) = 0 and nvl(l_adj_salvage_value,0) = 0 and nvl(l_adj_percent_sv,0) = 0 Then
3973 Null;
3974 Else
3975
3976 --Bug# 6373605
3977 Open l_txd_for_book_csr (p_book_type_code =>
3978 l_book_type_code,
3979 p_tal_id =>
3980 l_talv_rec.id);
3981 Fetch l_txd_for_book_csr into
3982 l_txd_for_book_rec;
3983 If l_txd_for_book_csr%NOTFOUND then
3984 l_sla_source_line_table :=
3985 'OKL_TXL_ASSETS_B';
3986 l_sla_source_line_id := l_talv_rec.id;
3987 Else
3988 l_sla_source_line_table :=
3989 'OKL_TXD_ASSETS_B';
3990 l_sla_source_line_id :=
3991 l_txd_for_book_rec.id;
3992 End If;
3993 Close l_txd_for_book_csr;
3994 --Bug # 6373605 end;
3995 -- to_make asset cost zero
3996 FIXED_ASSET_ADJUST_COST
3997 (p_api_version => p_api_version,
3998 p_init_msg_list => p_init_msg_list,
3999 x_return_status => x_return_status,
4000 x_msg_count => x_msg_count,
4001 x_msg_data => x_msg_data,
4002 p_chr_id => p_chrv_id,
4003 p_asset_id => l_asset_hdr_rec.asset_id,
4004 p_book_type_code => l_book_type_code,
4005 p_adjust_cost => l_adjust_cost,
4006 --Bug # 2657558
4007 p_adj_salvage_value => l_adj_salvage_value,
4008 --Bug# 2981308
4009 p_adj_percent_sv => l_adj_percent_sv,
4010 --Bug# 3156924
4011 p_trans_number => l_trans_number,
4012 p_calling_interface => l_calling_interface,
4013 --Bug# 4028371:
4014 x_fa_trx_date => l_fa_adj_date_tax,
4015 -- Bug Fix# 2925461
4016 p_adj_date => l_talv_rec.in_service_date,
4017 --Bug# 6373605--SLA populate source
4018 p_sla_source_header_id => l_tas_id,
4019 p_sla_source_header_table => 'OKL_TRX_ASSETS',
4020 p_sla_source_try_id => l_try_id,
4021 p_sla_source_line_id => l_sla_source_line_id,
4022 p_sla_source_line_table => l_sla_source_line_table,
4023 p_sla_source_chr_id => p_chrv_id,
4024 p_sla_source_kle_id => p_fin_ast_line_id,
4025 p_sla_asset_chr_id => p_sla_asset_chr_id,
4026 --Bug# 6373605--SLA populate sources
4027 x_asset_fin_rec => l_asset_fin_rec);
4028 --dbms_output.put_line('After fixed asset adjust for Tax bk ST Lease :'||x_return_status);
4029 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
4030 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4031 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
4032 RAISE OKL_API.G_EXCEPTION_ERROR;
4033 END IF;
4034 End If;
4035 --Bug# 2774529: End
4036 End If;
4037 End Loop; -- for tax books
4038 Close ast_bks_csr;
4039 --dbms_output.put_line('Deal Type Leasest :'||l_deal_type);
4040
4041 --Bug # : 11.i.9 enhancements - DF an ST lease treatment as to be same
4042 --Elsif l_Deal_Type = G_DF_LEASE_BK_CLASS Then
4043 ElsIf l_Deal_Type in (G_DF_LEASE_BK_CLASS, G_ST_LEASE_BK_CLASS) Then
4044 --Get Tax Owner
4045 --dbms_output.put_line('Deal Type Leasedf :'||l_deal_type);
4046
4047 -- Bug# 3838403
4048 -- Replaced call to OKL_RULE_APIS_PUB.Get_rule_Segment_Value
4049 -- with cursor town_rul_csr
4050 --Bug# 5261704: Moved to the top of this procedure
4051 /*--------------------------------------------
4052 Open town_rul_csr(pchrid => p_chrv_id);
4053 Fetch town_rul_csr into l_town_rul, l_town_rul_id;
4054 Close town_rul_csr;
4055
4056 l_name := rtrim(ltrim(l_town_rul,' '),' ');
4057 ---------------------------------------------*/
4058
4059 /*OKL_RULE_APIS_PUB.Get_rule_Segment_Value
4060 (p_api_version => p_api_version,
4061 p_init_msg_list => p_init_msg_list,
4062 x_return_status => x_return_status,
4063 x_msg_count => x_msg_count,
4064 x_msg_data => x_msg_data,
4065 p_chr_id => p_chrv_id,
4066 p_cle_id => null,
4067 p_rgd_code => l_rgd_code,
4068 p_rdf_code => l_rdf_code,
4069 --Bug#2525946
4070 --p_rdf_name => l_rdf_name,
4071 p_segment_number => l_segment_number,
4072 x_id1 => l_id1,
4073 x_id2 => l_id2,
4074 x_name => l_name,
4075 x_description => l_description,
4076 x_status => l_status,
4077 x_start_date => l_start_date,
4078 x_end_date => l_end_date,
4079 x_org_id => l_org_id,
4080 x_inv_org_id => l_inv_org_id,
4081 x_book_type_code => l_book_type_code,
4082 x_select => l_select);
4083 --dbms_output.put_line('TAX Owner :'||l_name);
4084 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
4085 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4086 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
4087 RAISE OKL_API.G_EXCEPTION_ERROR;
4088 END IF;*/
4089
4090 If upper(l_tax_owner) = 'LESSOR' Then
4091 --call the adjustment api to set the cost to zero in corp book only
4092 Open ast_bks_csr(p_asset_id => l_asset_hdr_rec.asset_id,
4093 p_book_class => G_FA_CORP_BOOK_CLASS_CODE);
4094 --Bug# 2657558 : selecting salvage_value
4095 Fetch ast_bks_csr into
4096 l_book_type_code,
4097 l_asset_cost,
4098 l_salvage_value,
4099 --Bug# 3156924
4100 l_percent_sv;
4101 If ast_bks_csr%NOTFOUND Then
4102 --dbms_output.put_line('Book information not found for asset..');
4103 -- no need to raise error
4104 null;
4105 Else
4106 l_adjust_cost := (-1)* l_asset_cost;
4107 --Bug # 2657558
4108 l_adj_salvage_value := (-1)*l_salvage_value;
4109 --Bug# 2981308
4110 l_adj_percent_sv := (-1)*l_percent_sv;
4111 IF nvl(l_adjust_cost,0) = 0 and nvl(l_adj_salvage_value,0) = 0 and nvl(l_adj_percent_sv,0) = 0 Then
4112 Null;
4113 Else
4114 -- to_make asset cost zero
4115 FIXED_ASSET_ADJUST_COST
4116 (p_api_version => p_api_version,
4117 p_init_msg_list => p_init_msg_list,
4118 x_return_status => x_return_status,
4119 x_msg_count => x_msg_count,
4120 x_msg_data => x_msg_data,
4121 p_chr_id => p_chrv_id,
4122 p_asset_id => l_asset_hdr_rec.asset_id,
4123 p_book_type_code => l_book_type_code,
4124 p_adjust_cost => l_adjust_cost,
4125 --Bug 2657558
4126 p_adj_salvage_value => l_adj_salvage_value,
4127 --Bug# 2981308
4128 p_adj_percent_sv => l_adj_percent_sv,
4129 --Bug# 3156924
4130 p_trans_number => l_trans_number,
4131 p_calling_interface => l_calling_interface,
4132 --Bug# 4028371:
4133 x_fa_trx_date => l_fa_adj_date_corp,
4134 -- Bug Fix# 2925461
4135 p_adj_date => l_talv_rec.in_service_date,
4136 --Bug# 6373605--SLA populate source
4137 p_sla_source_header_id => l_tas_id,
4138 p_sla_source_header_table => 'OKL_TRX_ASSETS',
4139 p_sla_source_try_id => l_try_id,
4140 p_sla_source_line_id => l_talv_rec.id,
4141 p_sla_source_line_table => 'OKL_TXL_ASSETS_B',
4142 p_sla_source_chr_id => p_chrv_id,
4143 p_sla_source_kle_id => p_fin_ast_line_id,
4144 p_sla_asset_chr_id => p_sla_asset_chr_id,
4145 --Bug# 6373605--SLA populate sources
4146 x_asset_fin_rec => l_asset_fin_rec);
4147 --dbms_output.put_line('After fixed asset adjust for Direct Fin Lease :'||x_return_status);
4148 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
4149 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4150 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
4151 RAISE OKL_API.G_EXCEPTION_ERROR;
4152 END IF;
4153 End If;
4154 --Bug# End
4155 End If;
4156 Close ast_bks_csr;
4157 Elsif upper(l_tax_owner) = 'LESSEE' Then
4158 --call the adjustment api to set the cost to zero in corp and tax book
4159 -- 1. for corporate cook
4160 Open ast_bks_csr(p_asset_id => l_asset_hdr_rec.asset_id,
4161 p_book_class => G_FA_CORP_BOOK_CLASS_CODE);
4162 --Bug# 2657558 : selecting salvage_value
4163 Fetch ast_bks_csr into
4164 l_book_type_code,
4165 l_asset_cost,
4166 l_salvage_value,
4167 --Bug# 2981308
4168 l_percent_sv;
4169 If ast_bks_csr%NOTFOUND Then
4170 --dbms_output.put_line('Book information not found for asset..');
4171 --no need to raise error
4172 null;
4173 Else
4174 l_adjust_cost := (-1)* l_asset_cost;
4175 --Bug # 2657558
4176 l_adj_salvage_value := (-1)*l_salvage_value;
4177 --Bug# 2981308
4178 l_adj_percent_sv := (-1)*l_percent_sv;
4179 --Bug 2774529#
4180 IF nvl(l_adjust_cost,0) = 0 and nvl(l_adj_salvage_value,0) = 0 and nvl(l_adj_percent_sv,0) = 0 Then
4181 Null;
4182 Else
4183 -- to_make asset cost zero
4184 FIXED_ASSET_ADJUST_COST
4185 (p_api_version => p_api_version,
4186 p_init_msg_list => p_init_msg_list,
4187 x_return_status => x_return_status,
4188 x_msg_count => x_msg_count,
4189 x_msg_data => x_msg_data,
4190 p_chr_id => p_chrv_id,
4191 p_asset_id => l_asset_hdr_rec.asset_id,
4192 p_book_type_code => l_book_type_code,
4193 p_adjust_cost => l_adjust_cost,
4194 --Bug # 2657558
4195 p_adj_salvage_value => l_adj_salvage_value,
4196 --Bug# 2981308
4197 p_adj_percent_sv => l_adj_percent_sv,
4198 --Bug# 3156924
4199 p_trans_number => l_trans_number,
4200 p_calling_interface => l_calling_interface,
4201 --Bug# 4028371
4202 x_fa_trx_date => l_fa_adj_date_corp,
4203 -- Bug Fix# 2925461
4204 p_adj_date => l_talv_rec.in_service_date,
4205 --Bug# 6373605--SLA populate source
4206 p_sla_source_header_id => l_tas_id,
4207 p_sla_source_header_table => 'OKL_TRX_ASSETS',
4208 p_sla_source_try_id => l_try_id,
4209 p_sla_source_line_id => l_talv_rec.id,
4210 p_sla_source_line_table => 'OKL_TXL_ASSETS_B',
4211 p_sla_source_chr_id => p_chrv_id,
4212 p_sla_source_kle_id => p_fin_ast_line_id,
4213 p_sla_asset_chr_id => p_sla_asset_chr_id,
4214 --Bug# 6373605--SLA populate sources
4215 x_asset_fin_rec => l_asset_fin_rec);
4216 --dbms_output.put_line('After fixed asset adjust Corp Bk for DF Lease :'||x_return_status);
4217 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
4218 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4219 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
4220 RAISE OKL_API.G_EXCEPTION_ERROR;
4221 END IF;
4222 End If;
4223 --Bug#2774529 End
4224 End If;
4225 Close ast_bks_csr;
4226
4227 --2. for tax books
4228 Open ast_bks_csr(p_asset_id => l_asset_hdr_rec.asset_id,
4229 p_book_class => G_FA_TAX_BOOK_CLASS_CODE);
4230 Loop
4231 --Bug# 2657558 : selecting salvage_value
4232 Fetch ast_bks_csr into
4233 l_book_type_code,
4234 l_asset_cost,
4235 l_salvage_value,
4236 --Bug 3156924
4237 l_percent_sv;
4238 Exit When ast_bks_csr%NOTFOUND;
4239 --Bug : 11.i.9 enhanceent
4240 --check if tax book is a reporting product book
4241 -- if t is do not update te cost to zero
4242 If nvl(l_rep_pdt_book,'NO_BOOK') = l_book_type_code Then
4243 Null;
4244 Else
4245 l_adjust_cost := (-1)* l_asset_cost;
4246 --Bug # 2657558
4247 l_adj_salvage_value := (-1)*l_salvage_value;
4248 --Bug# 2774529
4249 --Bug# 2981308
4250 l_adj_percent_sv := (-1) * l_percent_sv;
4251 IF nvl(l_adjust_cost,0) = 0 and nvl(l_adj_salvage_value,0) = 0 and nvl(l_adj_percent_sv,0) = 0 Then
4252 Null;
4253 Else
4254 --Bug# 6373605
4255 Open l_txd_for_book_csr (p_book_type_code =>
4256 l_book_type_code,
4257 p_tal_id =>
4258 l_talv_rec.id);
4259 Fetch l_txd_for_book_csr into
4260 l_txd_for_book_rec;
4261 If l_txd_for_book_csr%NOTFOUND then
4262 l_sla_source_line_table :=
4263 'OKL_TXL_ASSETS_B';
4264 l_sla_source_line_id := l_talv_rec.id;
4265 Else
4266 l_sla_source_line_table :=
4267 'OKL_TXD_ASSETS_B';
4268 l_sla_source_line_id :=
4269 l_txd_for_book_rec.id;
4270 End If;
4271 Close l_txd_for_book_csr;
4272 --Bug # 6373605 end;
4273
4274 FIXED_ASSET_ADJUST_COST
4275 (p_api_version => p_api_version,
4276 p_init_msg_list => p_init_msg_list,
4277 x_return_status => x_return_status,
4278 x_msg_count => x_msg_count,
4279 x_msg_data => x_msg_data,
4280 p_chr_id => p_chrv_id,
4281 p_asset_id => l_asset_hdr_rec.asset_id,
4282 p_book_type_code => l_book_type_code,
4283 p_adjust_cost => l_adjust_cost,
4284 --Bug # 2657558
4285 p_adj_salvage_value => l_adj_salvage_value,
4286 --Bug# 2981308
4287 p_adj_percent_sv => l_adj_percent_sv,
4288 --Bug# 3156924
4289 p_trans_number => l_trans_number,
4290 p_calling_interface => l_calling_interface,
4291 --Bug# 4028371:
4292 x_fa_trx_date => l_fa_adj_date_tax,
4293 -- Bug Fix# 2925461
4294 p_adj_date => l_talv_rec.in_service_date,
4295 --Bug# 6373605--SLA populate source
4296 p_sla_source_header_id => l_tas_id,
4297 p_sla_source_header_table => 'OKL_TRX_ASSETS',
4298 p_sla_source_try_id => l_try_id,
4299 p_sla_source_line_id => l_sla_source_line_id,
4300 p_sla_source_line_table => l_sla_source_line_table,
4301 p_sla_source_chr_id => p_chrv_id,
4302 p_sla_source_kle_id => p_fin_ast_line_id,
4303 p_sla_asset_chr_id => p_sla_asset_chr_id,
4304 --Bug# 6373605--SLA populate sources
4305 x_asset_fin_rec => l_asset_fin_rec);
4306 --dbms_output.put_line('After fixed asset adjust for Tax bk DF Lease :'||x_return_status);
4307 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
4308 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4309 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
4310 RAISE OKL_API.G_EXCEPTION_ERROR;
4311 END IF;
4312 End If;
4313 --Bug# 2774529 End
4314 End If;
4315 End Loop; -- for tax books
4316 Close ast_bks_csr;
4317 End if; -- if LESSEE
4318 Else
4319 --dbms_output.put_line('in else for operating lease');
4320 null;
4321 End If; --if deal_type
4322
4323 --Bug# 3574232 start
4324 -- If the reporting product is DF/ST lease, the asset
4325 -- should be created and written to zero in the reporting
4326 -- book.
4327 If (l_Multi_GAAP_YN = 'Y' and p_adjust_asset_to_zero = 'Y') Then
4328
4329 Open okx_ast_csr(p_asset_id => l_asset_hdr_rec.asset_id,
4330 p_book_type_code => l_rep_pdt_book);
4331 Fetch okx_ast_csr into okx_ast_rec;
4332 If okx_ast_csr%NotFound Then
4333 Close okx_ast_csr;
4334 Else
4335 Close okx_ast_csr;
4336 l_adjust_cost := (-1)* okx_ast_rec.cost;
4337 l_adj_salvage_value := (-1)*okx_ast_rec.salvage_value;
4338 l_adj_percent_sv := (-1)*okx_ast_rec.percent_salvage_value;
4339
4340 IF nvl(l_adjust_cost,0) = 0 and nvl(l_adj_salvage_value,0) = 0
4341 and nvl(l_adj_percent_sv,0) = 0 Then
4342 Null;
4343 ELSE
4344 --Bug# 6373605
4345 Open l_txd_for_book_csr (p_book_type_code =>
4346 l_rep_pdt_book,
4347 p_tal_id =>
4348 l_talv_rec.id);
4349 Fetch l_txd_for_book_csr into
4350 l_txd_for_book_rec;
4351 If l_txd_for_book_csr%NOTFOUND then
4352 l_sla_source_line_table :=
4353 'OKL_TXL_ASSETS_B';
4354 l_sla_source_line_id := l_talv_rec.id;
4355 Else
4356 l_sla_source_line_table :=
4357 'OKL_TXD_ASSETS_B';
4358 l_sla_source_line_id :=
4359 l_txd_for_book_rec.id;
4360 End If;
4361 Close l_txd_for_book_csr;
4362 --Bug # 6373605 end;
4363
4364 FIXED_ASSET_ADJUST_COST
4365 (p_api_version => p_api_version,
4366 p_init_msg_list => p_init_msg_list,
4367 x_return_status => x_return_status,
4368 x_msg_count => x_msg_count,
4369 x_msg_data => x_msg_data,
4370 p_chr_id => p_chrv_id,
4371 p_asset_id => l_asset_hdr_rec.asset_id,
4372 p_book_type_code => l_rep_pdt_book,
4373 p_adjust_cost => l_adjust_cost,
4374 p_adj_salvage_value => l_adj_salvage_value,
4375 p_adj_percent_sv => l_adj_percent_sv,
4376 p_trans_number => l_trans_number,
4377 p_calling_interface => l_calling_interface,
4378 --Bug# 4028371 :
4379 x_fa_trx_date => l_fa_adj_date_mg,
4380 p_adj_date => okx_ast_rec.in_service_date,
4381 --Bug# 6373605--SLA populate source
4382 p_sla_source_header_id => l_tas_id,
4383 p_sla_source_header_table => 'OKL_TRX_ASSETS',
4384 p_sla_source_try_id => l_try_id,
4385 p_sla_source_line_id => l_sla_source_line_id,
4386 p_sla_source_line_table => l_sla_source_line_table,
4387 p_sla_source_chr_id => p_chrv_id,
4388 p_sla_source_kle_id => p_fin_ast_line_id,
4389 p_sla_asset_chr_id => p_sla_asset_chr_id,
4390 --Bug# 6373605--SLA populate sources
4391 x_asset_fin_rec => l_asset_fin_rec);
4392
4393 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
4394 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4395 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
4396 RAISE OKL_API.G_EXCEPTION_ERROR;
4397 END IF;
4398 END IF;
4399 End if;
4400 End if;
4401 --Bug# 3574232 end
4402
4403 If ( (l_Multi_GAAP_YN = 'Y') OR
4404 (G_CHR_REPORT_PDT_ID <> -1 ) ) Then
4405
4406 l_chrv_rec.id := p_chrv_id;
4407 l_khrv_rec.id := p_chrv_id;
4408 l_khrv_rec.multi_gaap_yn := 'Y';
4409
4410 okl_contract_pub.update_contract_header(
4411 p_api_version => p_api_version,
4412 p_init_msg_list => p_init_msg_list,
4413 x_return_status => x_return_status,
4414 x_msg_count => x_msg_count,
4415 x_msg_data => x_msg_data,
4416 p_chrv_rec => l_chrv_rec,
4417 p_khrv_rec => l_khrv_rec,
4418 p_edit_mode => 'N',
4419 x_chrv_rec => x_chrv_rec,
4420 x_khrv_rec => x_khrv_rec);
4421
4422 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
4423 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4424 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
4425 RAISE OKL_API.G_EXCEPTION_ERROR;
4426 END IF;
4427
4428 End If;
4429
4430
4431 --update the trx type for this record to processed
4432 --dbms_output.put_line('transaction id to update '||l_talv_rec.tas_id);
4433 update_trx_status(p_api_version => p_api_version,
4434 p_init_msg_list => p_init_msg_list,
4435 x_return_status => x_return_status,
4436 x_msg_count => x_msg_count,
4437 x_msg_data => x_msg_data,
4438 p_tas_id => l_talv_rec.tas_id,
4439 p_tsu_code => G_TSU_CODE_PROCESSED);
4440
4441 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
4442 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4443 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
4444 RAISE OKL_API.G_EXCEPTION_ERROR;
4445 END IF;
4446
4447 --Bug# 4028371
4448 --update the fa trx date on transaction line
4449 l_talv_date_rec.id := l_talv_rec.id;
4450 l_talv_date_rec.fa_trx_date := l_fa_add_date_corp;
4451
4452 okl_tal_pvt.update_row
4453 (p_api_version => p_api_version,
4454 p_init_msg_list => p_init_msg_list,
4455 x_return_status => x_return_status,
4456 x_msg_count => x_msg_count,
4457 x_msg_data => x_msg_data,
4458 p_talv_rec => l_talv_date_rec,
4459 x_talv_rec => lx_talv_date_rec);
4460 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
4461 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4462 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
4463 RAISE OKL_API.G_EXCEPTION_ERROR;
4464 END IF;
4465 --End Bug# 4028371
4466 End If;--if asset transaction records found
4467 End If; --if unplugged okc_k_items records for fa line
4468 End If; --fa line is found
4469 OKL_API.END_ACTIVITY (x_msg_count,x_msg_data );
4470 EXCEPTION
4471 WHEN OKL_API.G_EXCEPTION_ERROR THEN
4472 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
4473 l_api_name,
4474 G_PKG_NAME,
4475 'OKL_API.G_RET_STS_ERROR',
4476 x_msg_count,
4477 x_msg_data,
4478 '_PVT');
4479 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
4480 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
4481 l_api_name,
4482 G_PKG_NAME,
4483 'OKL_API.G_RET_STS_UNEXP_ERROR',
4484 x_msg_count,
4485 x_msg_data,
4486 '_PVT');
4487 WHEN OTHERS THEN
4488 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
4489 l_api_name,
4490 G_PKG_NAME,
4491 'OTHERS',
4492 x_msg_count,
4493 x_msg_data,
4494 '_PVT');
4495 End Process_FA_Line;
4496 --------------------------------------------------------------------------------
4497 --Start of comments
4498 --Procedure Name : Get_Pdt_Params (local)
4499 --Description : 11.5.9 Enhancement Multi-GAAP - Calls product api to fetch
4500 -- product specific parameters
4501 --History : 27-Nov-2002 ashish.singh Created
4502 --Notes : local procedure
4503 -- IN Parameters-
4504 -- p_pdt_id - product id
4505 -- p_pdt_date - product effective date
4506 -- OUT Parameters -
4507 -- x_rep_pdt_id - Reporting product id
4508 -- x_tax_owner - tax owner
4509 -- x_rep_deal_type - Reporting product deal type
4510 --End of comments
4511 --------------------------------------------------------------------------------
4512 Procedure Get_Pdt_Params (p_api_version IN NUMBER,
4513 p_init_msg_list IN VARCHAR2,
4514 x_return_status OUT NOCOPY VARCHAR2,
4515 x_msg_count OUT NOCOPY NUMBER,
4516 x_msg_data OUT NOCOPY VARCHAR2,
4517 p_pdt_id IN NUMBER,
4518 p_pdt_date IN DATE,
4519 x_rep_pdt_id OUT NOCOPY NUMBER,
4520 x_tax_owner OUT NOCOPY VARCHAR2,
4521 x_rep_deal_type OUT NOCOPY VARCHAR2) is
4522
4523 l_pdtv_rec okl_setupproducts_pub.pdtv_rec_type;
4524 l_pdt_parameter_rec okl_setupproducts_pub.pdt_parameters_rec_type;
4525 l_rep_pdt_parameter_rec okl_setupproducts_pub.pdt_parameters_rec_type;
4526 l_pdt_date DATE;
4527 l_no_data_found BOOLEAN;
4528 l_error_condition Exception;
4529 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
4530 Begin
4531 l_pdtv_rec.id := p_pdt_id;
4532 l_pdt_date := p_pdt_date;
4533 l_no_data_found := TRUE;
4534 x_return_status := OKL_API.G_RET_STS_SUCCESS;
4535
4536 okl_setupproducts_pub.Getpdt_parameters(p_api_version => p_api_version,
4537 p_init_msg_list => p_init_msg_list,
4538 x_return_status => l_return_status,
4539 x_no_data_found => l_no_data_found,
4540 x_msg_count => x_msg_count,
4541 x_msg_data => x_msg_data,
4542 p_pdtv_rec => l_pdtv_rec,
4543 p_product_date => l_pdt_date,
4544 p_pdt_parameter_rec => l_pdt_parameter_rec);
4545
4546 IF l_return_status <> OKL_API.G_RET_STS_SUCCESS Then
4547 x_rep_pdt_id := Null;
4548 x_tax_owner := Null;
4549 --Bug# 4775166
4550 Elsif l_pdt_parameter_rec.reporting_pdt_id IS NULL Then
4551 x_rep_pdt_id := Null;
4552 x_tax_owner := l_pdt_parameter_rec.tax_owner;
4553 x_rep_deal_type := Null;
4554 Else
4555 x_rep_pdt_id := l_pdt_parameter_rec.reporting_pdt_id;
4556 x_tax_owner := l_pdt_parameter_rec.tax_owner;
4557 --get reporting product param values
4558 l_no_data_found := TRUE;
4559 l_pdtv_rec.id := x_rep_pdt_id;
4560 okl_setupproducts_pub.Getpdt_parameters(p_api_version => p_api_version,
4561 p_init_msg_list => p_init_msg_list,
4562 x_return_status => l_return_status,
4563 x_no_data_found => l_no_data_found,
4564 x_msg_count => x_msg_count,
4565 x_msg_data => x_msg_data,
4566 p_pdtv_rec => l_pdtv_rec,
4567 p_product_date => l_pdt_date,
4568 p_pdt_parameter_rec => l_rep_pdt_parameter_rec);
4569
4570 IF l_return_status <> OKL_API.G_RET_STS_SUCCESS Then
4571 x_rep_deal_type := NULL;
4572 Else
4573 x_rep_deal_type := l_rep_pdt_parameter_rec.deal_type;
4574 End If;
4575 End If;
4576
4577 Exception
4578 When l_error_condition Then
4579 Null;
4580 When Others Then
4581 x_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
4582 End Get_Pdt_Params;
4583 --------------------------------------------------------------------------------
4584 --Start of Comments
4585 --Procedure Name : ACTIVATE_ASSET
4586 --Description : Selects the 'CFA' - Create Asset Transaction from a ready to be
4587 -- Booked Contract which has passed Approval
4588 -- and created assets in FA
4589 --
4590 --History :
4591 -- 03-Nov-2001 ashish.singh Created
4592 -- 27-Nov-2002 ashish.singh 11.5.9 enhacements
4593 -- Notes :
4594 -- IN Parameters -
4595 -- p_chr_id - contract id to be activated
4596 -- p_call_mode - 'BOOK' for booking
4597 -- 'REBOOK' for rebooking
4598 -- 'RELEASE' for release
4599 -- x_cimv_tbl - OKC line source table showing
4600 -- fa links in ID1 , ID2 columns
4601 --End of Comments
4602 --------------------------------------------------------------------------------
4603 PROCEDURE ACTIVATE_ASSET(p_api_version IN NUMBER,
4604 p_init_msg_list IN VARCHAR2,
4605 x_return_status OUT NOCOPY VARCHAR2,
4606 x_msg_count OUT NOCOPY NUMBER,
4607 x_msg_data OUT NOCOPY VARCHAR2,
4608 p_chrv_id IN NUMBER,
4609 p_call_mode IN VARCHAR2,
4610 x_cimv_tbl OUT NOCOPY cimv_tbl_type) IS
4611
4612 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
4613 l_api_name CONSTANT varchar2(30) := 'ACTIVATE_ASSET';
4614 l_api_version CONSTANT NUMBER := 1.0;
4615 l_fa_lty_code Varchar2(30) := G_FA_LINE_LTY_CODE;
4616 l_trx_type Varchar2(30) := G_TRX_LINE_TYPE_BOOK;
4617
4618 l_hdr_rec l_hdr_csr%ROWTYPE;
4619
4620 --cursor to verify the subclass code
4621 --contract has to be a 'LEASE' subclass contract to qualify for FA_ADDITION
4622 Cursor chk_subclass_csr(p_chrv_id IN NUMBER) is
4623 SELECT chr.SCS_CODE,
4624 chr.STS_CODE,
4625 khr.DEAL_TYPE,
4626 --11.5.9(Multi GAAP)
4627 khr.PDT_ID,
4628 chr.START_DATE
4629 From OKC_K_HEADERS_B chr,
4630 OKL_K_HEADERS khr
4631 WHERE khr.id = chr.id
4632 AND chr.ID = P_CHRV_ID;
4633
4634 --cursor for fetching passed fixed asset lines
4635 --within the contract
4636 --Bug# 4899328
4637 Cursor fa_line_csr(p_chrv_id IN Number) is
4638 SELECT cle.id,
4639 cle.cle_id
4640 from okc_k_lines_b cle,
4641 okc_statuses_b sts
4642 where cle.lse_id = G_FA_LINE_LTY_ID
4643 and cle.dnz_chr_id = p_chrv_id
4644 and cle.sts_code = sts.code
4645 and sts.ste_code not in ('HOLD','EXPIRED','TERMINATED','CANCELLED');
4646
4647 l_scs_code Varchar2(30);
4648 l_sts_code Varchar2(30);
4649 l_deal_type Varchar2(30);
4650 l_cimv_rec cimv_rec_type;
4651 l_fa_line_id Number;
4652 l_fin_ast_line_id Number;
4653 l_asst_count Number default 0;
4654 --11.5.9 (Multi GAAP)
4655 l_pdt_id Number;
4656 l_start_date Date;
4657 l_rep_pdt_id Number;
4658 l_tax_owner Varchar2(150);
4659 l_rep_deal_type Varchar2(150);
4660 l_Multi_GAAP_YN Varchar2(1);
4661 l_rep_pdt_book OKX_AST_BKS_V.Book_Type_Code%Type;
4662 --cursor to get tax owner rule
4663 Cursor town_rul_csr (pchrid number) is
4664 Select rule_information1 tax_owner,
4665 id
4666 From okc_rules_b rul
4667 where rul.dnz_chr_id = pchrid
4668 and rul.rule_information_category = 'LATOWN'
4669 and nvl(rul.STD_TEMPLATE_YN,'N') = 'N';
4670
4671 l_town_rul okc_rules_b.rule_information1%TYPE;
4672 l_town_rul_id okc_rules_b.id%TYPE;
4673
4674 --Bug# 3156924
4675 l_trans_number okl_trx_assets.trans_number%TYPE := Null;
4676 l_calling_interface varchar2(30) := 'OKLRACAB:Booking';
4677
4678 --Bug# 3574232
4679 l_adjust_asset_to_zero varchar2(30);
4680
4681 TYPE fa_line_id_tbl is table of okc_k_lines_b.id%TYPE INDEX BY BINARY_INTEGER;
4682 l_fa_line_id_tbl fa_line_id_tbl;
4683
4684 TYPE fin_ast_line_id_tbl is table of okc_k_lines_b.cle_id%TYPE INDEX BY BINARY_INTEGER;
4685 l_fin_ast_line_id_tbl fin_ast_line_id_tbl;
4686
4687 TYPE fin_asst_rec_type IS RECORD (
4688 fa_line_id OKC_K_LINES_B.id%TYPE ,
4689 fin_ast_line_id OKC_K_LINES_B.cle_id %TYPE);
4690
4691 TYPE fin_asst_tbl_type IS TABLE OF fin_asst_rec_type INDEX BY BINARY_INTEGER;
4692 l_fin_asst_tbl fin_asst_tbl_type;
4693 l_counter NUMBER;
4694 l_loop_index NUMBER;
4695
4696
4697
4698 BEGIN
4699
4700 x_return_status := OKL_API.G_RET_STS_SUCCESS;
4701 -- Call start_activity to create savepoint, check compatibility
4702 -- and initialize message list
4703 x_return_status := OKL_API.START_ACTIVITY (
4704 l_api_name
4705 ,p_init_msg_list
4706 ,'_PVT'
4707 ,x_return_status);
4708 -- Check if activity started successfully
4709 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
4710 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4711 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
4712 RAISE OKL_API.G_EXCEPTION_ERROR;
4713 END IF;
4714
4715 Open chk_subclass_csr(p_chrv_id);
4716 Fetch chk_subclass_csr into l_scs_code, l_sts_code, l_deal_type, l_pdt_id, l_start_date;
4717 If chk_subclass_csr%NOTFOUND Then
4718 --dbms_output.put_line('Contract Not Found ....!');
4719 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
4720 p_msg_name => G_CONTRACT_NOT_FOUND,
4721 p_token1 => G_CONTRACT_ID,
4722 p_token1_value => to_char(p_chrv_id)
4723 );
4724 RAISE OKL_API.G_EXCEPTION_ERROR;
4725 --Handle error appropriately
4726 ElsIf upper(l_sts_code) <> G_APPROVED_STS_CODE Then
4727 --dbms_output.put_line('Contract has not been approved...!');
4728 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
4729 p_msg_name => G_CONTRACT_NOT_APPROVED
4730 );
4731 RAISE OKL_API.G_EXCEPTION_ERROR;
4732 --Raise appropraite error message
4733 ElsIf l_scs_code <> G_LEASE_SCS_CODE and upper(l_sts_code) = G_APPROVED_STS_CODE Then
4734 --dbms_output.put_line('Contract is not a lease contract...!');
4735 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
4736 p_msg_name => G_CONTRACT_NOT_LEASE
4737 );
4738 RAISE OKL_API.G_EXCEPTION_ERROR;
4739 --Raise appropriate error message or do nothing
4740 ElsIf l_scs_code = G_LEASE_SCS_CODE and upper(l_sts_code) = G_APPROVED_STS_CODE Then
4741 --Bug# : 11.5.9 enhancement Multi-Gaap :to create FA for reporting book
4742 --If l_deal_type in (G_LOAN_BK_CLASS,G_REVOLVING_LOAN_BK_CLASS) Then
4743 If l_deal_type in (G_REVOLVING_LOAN_BK_CLASS) Then
4744 --nothing to be done for these deal types
4745 Null;
4746 Else
4747 --Bug# :11.5.9 : Multi-GAAP Begin
4748 Get_Pdt_Params (p_api_version => p_api_version,
4749 p_init_msg_list => p_init_msg_list,
4750 x_return_status => x_return_status,
4751 x_msg_count => x_msg_count,
4752 x_msg_data => x_msg_data,
4753 p_pdt_id => l_pdt_id,
4754 p_pdt_date => l_start_date,
4755 x_rep_pdt_id => l_rep_pdt_id,
4756 x_tax_owner => l_tax_owner,
4757 x_rep_deal_type => l_rep_deal_type);
4758
4759 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
4760 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4761 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
4762 RAISE OKL_API.G_EXCEPTION_ERROR;
4763 END IF;
4764
4765 If l_tax_owner is null then
4766 Open town_rul_csr(pchrid => p_chrv_id);
4767 Fetch town_rul_csr into l_town_rul,
4768 l_town_rul_id;
4769 If town_rul_csr%NOTFOUND Then
4770 OKC_API.set_message(
4771 p_app_name => G_APP_NAME,
4772 p_msg_name => G_REQUIRED_VALUE,
4773 p_token1 => G_COL_NAME_TOKEN,
4774 p_token1_value => 'Tax Owner');
4775 x_return_status := OKC_API.G_RET_STS_ERROR;
4776 RAISE OKL_API.G_EXCEPTION_ERROR;
4777 Else
4778 l_tax_owner := rtrim(ltrim(l_town_rul,' '),' ');
4779 End If;
4780 Close town_rul_csr;
4781 End If;
4782
4783 OPEN l_hdr_csr( p_chrv_id );
4784 FETCH l_hdr_csr INTO l_hdr_rec;
4785 CLOSE l_hdr_csr;
4786
4787 G_CHR_CURRENCY_CODE := l_hdr_rec.currency_code;
4788 G_FUNC_CURRENCY_CODE := okl_accounting_util.get_func_curr_code;
4789 G_CHR_AUTHORING_ORG_ID := l_hdr_rec.authoring_org_id;
4790 G_CHR_START_DATE := l_hdr_rec.start_date;
4791 G_CHR_REPORT_PDT_ID := l_hdr_rec.report_pdt_id;
4792
4793 l_Multi_GAAP_YN := 'N';
4794 -- Bug# 3574232
4795 l_adjust_asset_to_zero := 'N';
4796 --checks wheter Multi-GAAP processing needs tobe done
4797 If l_rep_pdt_id is not NULL Then
4798
4799 --Bug 7708944. SMEREDDY 01/15/2009.
4800 -- Implemented MG changes based on PM recommendation.
4801 l_Multi_GAAP_YN := 'Y';
4802 /*
4803 If l_deal_type = 'LEASEOP' and
4804 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
4805 nvl(l_tax_owner,'X') = 'LESSOR' Then
4806 l_Multi_GAAP_YN := 'Y';
4807 End If;
4808
4809 If l_deal_type in ('LEASEDF','LEASEST') and
4810 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
4811 nvl(l_tax_owner,'X') = 'LESSOR' Then
4812 l_Multi_GAAP_YN := 'Y';
4813 End If;
4814
4815 If l_deal_type in ('LEASEDF','LEASEST') and
4816 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
4817 nvl(l_tax_owner,'X') = 'LESSEE' Then
4818 l_Multi_GAAP_YN := 'Y';
4819 End If;
4820
4821 If l_deal_type = 'LOAN' and
4822 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
4823 nvl(l_tax_owner,'X') = 'LESSEE' Then
4824 l_Multi_GAAP_YN := 'Y';
4825 End If;
4826 */
4827 -- Bug# 3574232 start
4828 -- If the reporting product is DF/ST lease, the asset should
4829 -- be created and written to zero in the reporting book.
4830
4831 --Bug 7708944. SMEREDDY 01/15/2009.
4832 -- Implemented MG changes based on PM recommendation.
4833
4834
4835 If l_deal_type = 'LEASEOP' and
4836 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
4837 nvl(l_tax_owner,'X') = 'LESSOR' Then
4838 --l_Multi_GAAP_YN := 'Y';
4839 l_adjust_asset_to_zero := 'Y';
4840 End If;
4841
4842 If l_deal_type in ('LEASEDF','LEASEST') and
4843 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
4844 nvl(l_tax_owner,'X') = 'LESSOR' Then
4845 --l_Multi_GAAP_YN := 'Y';
4846 l_adjust_asset_to_zero := 'Y';
4847 End If;
4848
4849 If l_deal_type in ('LEASEDF','LEASEST') and
4850 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
4851 nvl(l_tax_owner,'X') = 'LESSEE' Then
4852 --l_Multi_GAAP_YN := 'Y';
4853 l_adjust_asset_to_zero := 'Y';
4854 End If;
4855 -- Bug# 3574232 end
4856 End If;
4857
4858 If l_Multi_GAAP_YN = 'Y' Then
4859 --get reporting product book type
4860 l_rep_pdt_book := OKL_SYSTEM_PARAMS_ALL_PUB.get_system_param_value(OKL_SYSTEM_PARAMS_ALL_PUB.G_RPT_PROD_BOOK_TYPE_CODE);
4861 End If;
4862
4863 --Bug 7708944. SMEREDDY 01/15/2009.
4864 -- Implemented MG changes based on PM recommendation.
4865
4866
4867 If ((l_deal_type = 'LOAN') --and nvl(l_Multi_GAAP_YN,'N') = 'N')
4868 OR (l_deal_type = 'LOAN_REVOLVING')) Then
4869 Null;
4870 --Assets will not be activatted for LOANS which are not Multi-GAAP
4871 Else
4872 --Bug# :11.5.9 : Multi-GAAP End
4873 -- get the transaction records
4874
4875 l_asst_count := 1;
4876 l_counter := 1;
4877
4878 Open fa_line_csr(p_chrv_id);
4879
4880 Loop
4881 l_fa_line_id_tbl.delete;
4882 l_fin_ast_line_id_tbl.delete;
4883
4884 Fetch fa_line_csr BULK COLLECT
4885 into l_fa_line_id_tbl, l_fin_ast_line_id_tbl
4886 LIMIT G_BULK_BATCH_SIZE;
4887
4888 if (l_fa_line_id_tbl.COUNT > 0) then
4889 for i in l_fa_line_id_tbl.FIRST .. l_fa_line_id_tbl.LAST LOOP
4890 l_fin_asst_tbl(l_counter).fa_line_id := l_fa_line_id_tbl(i);
4891 l_fin_asst_tbl(l_counter).fin_ast_line_id := l_fin_ast_line_id_tbl(i);
4892 l_counter := l_counter + 1;
4893 End Loop;
4894 end if;
4895
4896 Exit When fa_line_csr%NotFound;
4897 End Loop;
4898 CLOSE fa_line_csr;
4899
4900 IF (l_fin_asst_tbl.COUNT > 0) THEN
4901
4902 l_loop_index := l_fin_asst_tbl.FIRST;
4903 LOOP
4904 l_fa_line_id := l_fin_asst_tbl(l_loop_index).fa_line_id;
4905 l_fin_ast_line_id := l_fin_asst_tbl(l_loop_index).fin_ast_line_id;
4906
4907
4908 Process_FA_Line (p_api_version => p_api_version,
4909 p_init_msg_list => p_init_msg_list,
4910 x_return_status => x_return_status,
4911 x_msg_count => x_msg_count,
4912 x_msg_data => x_msg_data,
4913 p_chrv_id => p_chrv_id,
4914 p_fa_line_id => l_fa_line_id,
4915 p_fin_ast_line_id => l_fin_ast_line_id,
4916 p_deal_type => l_deal_type,
4917 p_trx_type => l_trx_type,
4918 --Bug : 11.5.9 Multi GAAP Begin
4919 p_multi_GAAP_YN => l_Multi_GAAP_YN,
4920 p_rep_pdt_book => l_rep_pdt_book,
4921 --Bug : 11.5.9 Multi GAAP end
4922 --Bug# 3574232
4923 p_adjust_asset_to_zero => l_adjust_asset_to_zero,
4924 --Bug# 3156924
4925 p_trans_number => to_char(l_trans_number),
4926 p_calling_interface => l_calling_interface,
4927 --Bug# 6373605 startd
4928 p_sla_asset_chr_id => p_chrv_id,
4929 --Bug# 6373605 end
4930 x_cimv_rec => l_cimv_rec);
4931
4932
4933 --dbms_output.put_line('after process fa line '||x_return_status);
4934 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
4935 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4936 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
4937 RAISE OKL_API.G_EXCEPTION_ERROR;
4938 END IF;
4939 x_cimv_tbl(l_asst_count) := l_cimv_rec;
4940 l_asst_count := l_asst_count+1;
4941
4942 EXIT WHEN l_loop_index = l_fin_asst_tbl.LAST;
4943 l_loop_index := l_fin_asst_tbl.NEXT(l_loop_index);
4944
4945 End Loop; -- fa line csr
4946 End IF;
4947
4948 End if; --for deal type = 'LOAN' and no Multi-GAAP
4949
4950 End If; -- for deal types
4951 Close chk_subclass_csr;
4952 End If;
4953 OKL_API.END_ACTIVITY (x_msg_count,x_msg_data );
4954 EXCEPTION
4955 WHEN OKL_API.G_EXCEPTION_ERROR THEN
4956 If ( l_hdr_csr%ISOPEN ) Then
4957 CLOSE l_hdr_csr;
4958 End If;
4959 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
4960 l_api_name,
4961 G_PKG_NAME,
4962 'OKL_API.G_RET_STS_ERROR',
4963 x_msg_count,
4964 x_msg_data,
4965 '_PVT');
4966 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
4967 If ( l_hdr_csr%ISOPEN ) Then
4968 CLOSE l_hdr_csr;
4969 End If;
4970 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
4971 l_api_name,
4972 G_PKG_NAME,
4973 'OKL_API.G_RET_STS_UNEXP_ERROR',
4974 x_msg_count,
4975 x_msg_data,
4976 '_PVT');
4977 WHEN OTHERS THEN
4978 If ( l_hdr_csr%ISOPEN ) Then
4979 CLOSE l_hdr_csr;
4980 End If;
4981 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
4982 l_api_name,
4983 G_PKG_NAME,
4984 'OTHERS',
4985 x_msg_count,
4986 x_msg_data,
4987 '_PVT');
4988
4989 END ACTIVATE_ASSET;
4990 --------------------------------------------------------------------------------
4991 --Start of Comments
4992 --Procedure Name : REBOOK_ASSET (Activate code branch for rebook)
4993 --Description : Will be called from activate asset and make rebook adjustments
4994 -- in FA
4995 --History :
4996 -- 21-Mar-2002 ashish.singh Created
4997 -- 27-Nov-2002 ashish.singh Bug# : 11.5.9 enhancements
4998 -- 1. Multi-GAAP
4999 -- Notes :
5000 -- IN Parameters -
5001 -- p_rbk_chr_id - contract id of rebook copied contract
5002 --
5003 -- This APi should be called after syncronization of copied k
5004 -- to the original (being re-booked ) K
5005 --End of Comments
5006 --------------------------------------------------------------------------------
5007 PROCEDURE REBOOK_ASSET (p_api_version IN NUMBER,
5008 p_init_msg_list IN VARCHAR2,
5009 x_return_status OUT NOCOPY VARCHAR2,
5010 x_msg_count OUT NOCOPY NUMBER,
5011 x_msg_data OUT NOCOPY VARCHAR2,
5012 p_rbk_chr_id IN NUMBER
5013 ) IS
5014
5015 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
5016 l_api_name CONSTANT varchar2(30) := 'REBOOK_ASSET';
5017 l_api_version CONSTANT NUMBER := 1.0;
5018 l_trx_type Varchar2(30) := G_TRX_LINE_TYPE_REBOOK;
5019
5020 --Cursor to get the rebook transaction reason codes
5021 CURSOR rbr_code_csr (p_rbk_chr_id IN NUMBER) IS
5022 SELECT ktrx.rbr_code,
5023 ktrx.date_transaction_occurred,
5024 khr.deal_type,
5025 chr.id,
5026 chr.sts_code,
5027 rul.rule_information1,
5028 --Bug# : 11.5.9 Multi-GAAP
5029 khr.pdt_id,
5030 chr.start_date,
5031 --Bug# 3156924
5032 ktrx.trx_number
5033 FROM OKC_RULES_B rul,
5034 OKL_K_HEADERS khr,
5035 OKC_K_HEADERS_B chr,
5036 OKL_TRX_CONTRACTS ktrx,
5037 OKC_K_HEADERS_B rbk_chr
5038 WHERE rul.dnz_chr_id = chr.id
5039 AND rul.rule_information_category = 'LATOWN'
5040 AND khr.id = chr.id
5041 AND chr.id = rbk_chr.orig_system_id1
5042 AND exists (select null
5043 from okl_trx_types_tl tl
5044 where tl.language = 'US'
5045 and tl.name = 'Rebook'
5046 and tl.id = ktrx.try_id)
5047 AND ktrx.KHR_ID = chr.id
5048 AND ktrx.KHR_ID_NEW = rbk_chr.id
5049 AND ktrx.tsu_code = G_TSU_CODE_ENTERED
5050 --rkuttiya added for 12.1.1 Multi GAAP Project
5051 AND ktrx.representation_type = 'PRIMARY'
5052 --
5053 AND rbk_chr.orig_system_source_code = 'OKL_REBOOK'
5054 AND rbk_chr.id = p_rbk_chr_id;
5055
5056 l_rbr_code OKL_TRX_CONTRACTS.rbr_code%TYPE;
5057 l_deal_type OKL_K_HEADERS.deal_type%TYPE;
5058 l_chr_id OKC_K_HEADERS_B.ID%TYPE;
5059 l_sts_code OKC_K_HEADERS_B.STS_CODE%TYPE;
5060 l_date_trx_occured OKL_TRX_CONTRACTS.date_transaction_occurred%TYPE;
5061 l_tax_owner OKC_RULES_B.RULE_INFORMATION1%TYPE;
5062 --Bug# : 11.5.9 enhancement Multi GAAP
5063 l_pdt_id OKL_K_HEADERS.pdt_id%TYPE;
5064 l_start_date Date;
5065 l_rep_pdt_id Number;
5066 l_pdt_tax_owner Varchar2(150);
5067 l_rep_deal_type Varchar2(150);
5068 l_Multi_GAAP_YN Varchar2(1) := 'N';
5069 l_rep_pdt_book OKX_AST_BKS_V.Book_Type_Code%Type;
5070 --Bug# 3156924 :
5071 l_trx_number okl_trx_contracts.trx_number%TYPE;
5072 l_calling_interface varchar2(30) := 'OKL: Rebook';
5073
5074 --cursor to get the adjusted residual value and OEC
5075 CURSOR adj_cle_csr (p_chr_id IN NUMBER, p_fa_cle_id IN NUMBER, p_effective_date IN date) IS
5076 SELECT kle.OEC,
5077 kle.RESIDUAL_VALUE,
5078 cle.id,
5079 cle.name
5080 FROM OKC_K_LINES_V cle,
5081 OKC_LINE_STYLES_B lse,
5082 OKL_K_LINES kle,
5083 OKC_K_LINES_B fa_cle,
5084 OKC_LINE_STYLES_B fa_cle_lse
5085 WHERE kle.id = cle.id
5086 AND cle.chr_id = p_chr_id
5087 AND cle.dnz_chr_id = p_chr_id
5088 AND cle.lse_id = lse.id
5089 AND lse.lty_code = G_FIN_AST_LINE_LTY_CODE
5090 AND cle.id = fa_cle.cle_id
5091 AND fa_cle.id = nvl(p_fa_cle_id,fa_cle.id)
5092 AND fa_cle.lse_id = fa_cle_lse.id
5093 AND fa_cle_lse.lty_code = G_FA_LINE_LTY_CODE
5094 --Bug# 2942543 : effectivity should be checked by keeping start and end date as inclusive
5095 --AND nvl(cle.start_date,p_effective_date) <= p_effective_date
5096 --AND nvl(cle.end_date,p_effective_date+1) > p_effective_date
5097 And p_effective_date between cle.start_date and cle.end_date
5098 AND not exists (select '1'
5099 from OKC_STATUSES_B sts
5100 Where sts.code = cle.sts_code
5101 --Bug# 2522268
5102 --And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELED'));
5103 And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELLED'));
5104
5105 l_oec OKL_K_LINES.OEC%TYPE;
5106 l_residual_value OKL_K_LINES.RESIDUAL_VALUE%TYPE;
5107 l_cle_id OKC_K_LINES_V.ID%TYPE;
5108 l_asset_number OKC_K_LINES_V.NAME%TYPE;
5109
5110
5111 --cursor to get the modified transaction values against the rebook contract
5112 CURSOR adj_txl_csr (p_rbk_chr_id IN NUMBER, p_effective_date IN DATE ) IS
5113 SELECT txl.in_service_date in_service_date,
5114 txl.life_in_months life_in_months,
5115 txl.depreciation_cost depreciation_cost,
5116 txl.depreciation_id asset_category_id,
5117 txl.deprn_method deprn_method,
5118 txl.deprn_rate deprn_rate,
5119 txl.salvage_value salvage_value,
5120 txl.corporate_book book_type_code,
5121 txl.asset_number asset_number,
5122 txl.kle_id kle_id,
5123 --bug# 3548044
5124 txl.tas_id tas_id,
5125 txl.salvage_value corp_salvage_value,
5126 --Bug# 4028371
5127 txl.id tal_id,
5128 --Bug# 3950089
5129 txl.percent_salvage_value pct_salvage_value,
5130 txl.percent_salvage_value corp_pct_salvage_value,
5131 --Bug# 5207066
5132 txl.current_units rbk_current_units,
5133 --akrangan bug# 5362977 start
5134 cle.cle_id rbk_fin_ast_cle_id,
5135 txl.model_number model_number,
5136 txl.manufacturer_name manufacturer_name,
5137 txl.description description,
5138 --Bug# 6373605 start
5139 txl.id sla_source_line_id,
5140 txl.tas_id sla_source_header_id,
5141 'OKL_TXL_ASSETS_B' sla_source_line_table,
5142 tas.try_id sla_source_try_id
5143 --Bug# 6373605 end
5144 FROM OKL_TXL_ASSETS_V txl,
5145 --akrangan bug# 5362977 end
5146 --Bug# 6373605 start
5147 OKL_TRX_ASSETS tas,
5148 --Bug# 6373605 end
5149 OKC_K_LINES_B cle,
5150 OKC_LINE_STYLES_B lse
5151 WHERE txl.kle_id = cle.id
5152 --Bug# 6373605 start
5153 AND tas.id = txl.tas_id
5154 --Bug# 6373605 end
5155 AND cle.dnz_chr_id = p_rbk_chr_id
5156 AND cle.lse_id = lse.id
5157 --effectivity
5158 --Bug# 2942543 : effectivity should be checked by keeping start and end date as inclusive
5159 --And nvl(cle.start_date,p_effective_date) <= p_effective_date
5160 --And nvl(cle.end_date,p_effective_date+1) > p_effective_date
5161 And p_effective_date between cle.start_date and cle.end_date
5162 AND not exists (select '1'
5163 from OKC_STATUSES_B sts
5164 Where sts.code = cle.sts_code
5165 --Bug# 2522268
5166 --And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELED')
5167 And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELLED')
5168 )
5169 AND lse.lty_code = G_FA_LINE_LTY_CODE
5170 UNION
5171 SELECT txl.in_service_date in_service_date,
5172 txd.life_in_months_tax life_in_months,
5173 txd.cost depreciation_cost,
5174 txl.depreciation_id asset_category_id,
5175 txd.deprn_method_tax deprn_method,
5176 txd.deprn_rate_tax deprn_rate,
5177 txd.salvage_value salvage_value,
5178 txd.tax_book book_type_code,
5179 txd.asset_number asset_number,
5180 txl.kle_id kle_id,
5181 --BUG# 3548044
5182 null tas_id,
5183 txl.salvage_value corp_salvage_value,
5184 --Bug# 4028371
5185 null tal_id,
5186 --Bug# 3950089
5187 txl.percent_salvage_value pct_salvage_value,
5188 txl.percent_salvage_value corp_pct_salvage_value,
5189 --Bug# 5207066
5190 null,
5191 cle.cle_id rbk_fin_ast_cle_id,
5192 -- akrangan Bug# 5362977 start
5193 null model_number,
5194 null manufacturer_name,
5195 null description,
5196 -- akrangan Bug# 5362977 end
5197 --Bug# 6373605 start
5198 txd.id sla_source_line_id,
5199 txl.tas_id sla_source_header_id,
5200 'OKL_TXD_ASSETS_B' sla_source_line_table,
5201 tas.try_id sla_source_try_id
5202 --Bug# 6373605 end
5203 FROM OKL_TXD_ASSETS_B txd,
5204 OKL_TXL_ASSETS_B txl,
5205 --Bug# 6373605 start
5206 OKL_TRX_ASSETS tas,
5207 --Bug# 6373605 end
5208 OKC_K_LINES_B cle,
5209 OKC_LINE_STYLES_B lse
5210 WHERE txd.tal_id = txl.id
5211 --Bug# 6373605 start
5212 AND tas.id = txl.tas_id
5213 --Bug# 6373605
5214 AND txl.kle_id = cle.id
5215 AND cle.dnz_chr_id = p_rbk_chr_id
5216 AND cle.lse_id = lse.id
5217 --effectivity
5218 --Bug# 2942543 : effectivity should be checked by keeping start and end date as inclusive
5219 --And nvl(cle.start_date,p_effective_date) <= p_effective_date
5220 --And nvl(cle.end_date,p_effective_date+1) > p_effective_date
5221 And p_effective_date between cle.start_date and cle.end_date
5222 AND not exists (select '1'
5223 from OKC_STATUSES_B sts
5224 Where sts.code = cle.sts_code
5225 --Bug# 2522268
5226 --And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELED')
5227 And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELLED')
5228 )
5229 AND lse.lty_code = G_FA_LINE_LTY_CODE;
5230
5231 adj_txl_rec adj_txl_csr%ROWTYPE;
5232 l_corp_bk VARCHAR2(256);
5233
5234 --cursor to get the actual values from FA for the contract
5235 CURSOR okx_ast_csr (p_asset_number IN VARCHAR2,
5236 p_book_type_code IN VARCHAR2) is
5237 SELECT okx.acquisition_date in_service_date,
5238 okx.life_in_months life_in_months,
5239 okx.cost cost,
5240 okx.depreciation_category depreciation_category,
5241 okx.deprn_method_code deprn_method_code,
5242 okx.adjusted_rate adjusted_rate,
5243 okx.basic_rate basic_rate,
5244 okx.salvage_value salvage_value,
5245 okx.book_type_code book_type_code,
5246 okx.book_class book_class,
5247 okx.asset_number asset_number,
5248 okx.asset_id asset_id,
5249 --Bug# 3950089
5250 okx.percent_salvage_value percent_salvage_value,
5251 --Bug# 5207066
5252 okx.current_units fa_current_units
5253 FROM okx_ast_bks_v okx
5254 WHERE okx.asset_number = p_asset_number
5255 AND okx.book_type_code = nvl(p_book_type_code,okx.book_type_code);
5256
5257 okx_ast_rec okx_ast_csr%ROWTYPE;
5258
5259 --Cursor to check if the asset has no been deactivated/canceled on the original contract
5260 Cursor chk_line_csr (p_chr_id IN NUMBER,
5261 p_asset_id1 IN VARCHAR2,
5262 p_asset_id2 IN VARCHAR2,
5263 p_effective_date IN DATE) IS
5264 Select '!'
5265 from OKC_K_LINES_B cle,
5266 OKC_STATUSES_B sts,
5267 OKC_K_ITEMS cim
5268 Where cle.sts_code = sts.CODE
5269 --Bug# 2942543 : effectivity should be checked by keeping start and end date as inclusive
5270 --And nvl(sts.start_date,p_effective_date) <= p_effective_date
5271 --And nvl(sts.end_date,p_effective_date+1) > p_effective_date
5272 --And nvl(cle.start_date,p_effective_date) <= p_effective_date
5273 --And nvl(cle.end_date,p_effective_date+1) > p_effective_date
5274 And p_effective_date between cle.start_date and cle.end_date
5275 And cle.id = cim.cle_id
5276 And cle.dnz_chr_id = p_chr_id
5277 And cim.dnz_chr_id = p_chr_id
5278 And cim.object1_id1 = p_asset_id1
5279 And cim.object1_id2 = p_asset_id2
5280 And cim.jtot_object1_code = 'OKX_ASSET'
5281 --Bug# 2522268
5282 --And sts.ste_code not in ('HOLD','EXPIRED','TERMINATED','CANCELED');
5283 And sts.ste_code not in ('HOLD','EXPIRED','TERMINATED','CANCELLED');
5284
5285 l_chk_cle_effective Varchar2(1) default '?';
5286
5287 l_cost_delta Number;
5288 l_salvage_delta Number;
5289 l_asset_fin_rec_adj FA_API_TYPES.asset_fin_rec_type;
5290 l_asset_fin_rec_new FA_API_TYPES.asset_fin_rec_type;
5291 l_adjust_yn Varchar2(1);
5292
5293 --check if a new line exists on rbk copy contract
5294 --select the fin asset and fixed asset line id
5295 --of the original contract
5296 CURSOR new_ast_csr (p_rbk_chr_id IN NUMBER) is
5297 Select clev.id new_fin_cle_id,
5298 fa_cle.id new_fa_cle_id,
5299 clev.chr_id orig_chr_id
5300 From okc_k_lines_v clev,
5301 okc_line_styles_b lse,
5302 okc_k_lines_b fa_cle,
5303 okc_line_styles_b fa_lse,
5304 okc_k_headers_b chr
5305 where clev.chr_id = chr.orig_system_id1
5306 and clev.dnz_chr_id = chr.orig_system_id1
5307 and chr.id = p_rbk_chr_id
5308 and chr.orig_system_source_code = 'OKL_REBOOK'
5309 and exists (select null
5310 from okc_k_lines_v rbk_line
5311 where rbk_line.chr_id = chr.id
5312 and rbk_line.dnz_chr_id = chr.id
5313 and rbk_line.lse_id = clev.lse_id
5314 and rbk_line.name = clev.name
5315 and rbk_line.id = clev.orig_system_id1)
5316 and clev.lse_id = lse.id
5317 and lse.lty_code = G_FIN_AST_LINE_LTY_CODE
5318 and fa_cle.cle_id = clev.id
5319 and fa_cle.dnz_chr_id = chr.orig_system_id1
5320 and fa_cle.lse_id = fa_lse.id
5321 and fa_lse.lty_code = G_FA_LINE_LTY_CODE;
5322
5323 l_new_fin_cle_id OKC_K_LINES_B.ID%TYPE;
5324 l_new_fa_cle_id OKC_K_LINES_B.ID%TYPE;
5325 l_orig_chr_id OKC_K_HEADERS_B.ID%TYPE;
5326 lx_cimv_rec cimv_rec_type;
5327 lx_cimv_ib_tbl cimv_tbl_type;
5328
5329 l_dummy_amount NUMBER;
5330
5331 --cursor to get tax owner rule
5332 Cursor town_rul_csr (pchrid number) is
5333 Select rule_information1 tax_owner,
5334 id
5335 From okc_rules_b rul
5336 where rul.dnz_chr_id = pchrid
5337 and rul.rule_information_category = 'LATOWN'
5338 and nvl(rul.STD_TEMPLATE_YN,'N') = 'N';
5339
5340 l_town_rul okc_rules_b.rule_information1%TYPE;
5341 l_town_rul_id okc_rules_b.id%TYPE;
5342
5343 --bug# 2942543 :
5344 l_new_salvage_value Number;
5345 l_new_cost Number;
5346
5347
5348 --Bug# 3574232
5349 l_adjust_asset_to_zero varchar2(30);
5350
5351 --Bug# 3548044
5352 l_cap_fee_delta number;
5353 l_cap_fee_delta_converted_amt number;
5354
5355 l_rebook_allowed_on_mg_book varchar2(1);
5356
5357 --Bug# 3783518
5358 l_subsidy_asset_fin_rec_adj FA_API_TYPES.asset_fin_rec_type;
5359
5360 --Bug# 4028371
5361 l_fa_adj_date date;
5362 l_fa_sub_adj_date date;
5363 l_talv_date_rec okl_tal_pvt.talv_rec_type;
5364 lx_talv_date_rec okl_tal_pvt.talv_rec_type;
5365
5366 l_hdr_rec l_hdr_csr%ROWTYPE;
5367
5368 -- Bug# 5174778
5369 l_func_curr_code OKL_K_HEADERS_FULL_V.CURRENCY_CODE%TYPE;
5370
5371 -- Bug# 5207066
5372 l_unit_difference number;
5373
5374 BEGIN
5375
5376 x_return_status := OKL_API.G_RET_STS_SUCCESS;
5377 -- Call start_activity to create savepoint, check compatibility
5378 -- and initialize message list
5379 x_return_status := OKL_API.START_ACTIVITY (
5380 l_api_name
5381 ,p_init_msg_list
5382 ,'_PVT'
5383 ,x_return_status);
5384 -- Check if activity started successfully
5385 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5386 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5387 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
5388 RAISE OKL_API.G_EXCEPTION_ERROR;
5389 END IF;
5390
5391
5392 --get rebook reason code
5393 --dbms_output.put_line('before rebook reason code cursor :');
5394 OPEN rbr_code_csr (p_rbk_chr_id => p_rbk_chr_id);
5395 Fetch rbr_code_csr into l_rbr_code,
5396 l_date_trx_occured,
5397 l_deal_type,
5398 l_chr_id,
5399 l_sts_code,
5400 l_tax_owner,
5401 --Bug# : 11.5.9 enhamcement Multigaap
5402 l_pdt_id,
5403 l_start_date,
5404 --Bug# 3156924
5405 l_trx_number;
5406
5407 If rbr_code_csr%NOTFOUND Then
5408 --rebook transacton not found
5409 --does this call for raising error
5410 Null;
5411 Else
5412 --Bug# :11.5.9 : Multi-GAAP Begin
5413 Get_Pdt_Params (p_api_version => p_api_version,
5414 p_init_msg_list => p_init_msg_list,
5415 x_return_status => x_return_status,
5416 x_msg_count => x_msg_count,
5417 x_msg_data => x_msg_data,
5418 p_pdt_id => l_pdt_id,
5419 p_pdt_date => l_start_date,
5420 x_rep_pdt_id => l_rep_pdt_id,
5421 x_tax_owner => l_tax_owner,
5422 x_rep_deal_type => l_rep_deal_type);
5423
5424 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5425 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5426 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
5427 RAISE OKL_API.G_EXCEPTION_ERROR;
5428 END IF;
5429
5430 If l_tax_owner is null then
5431 Open town_rul_csr(pchrid => l_chr_id);
5432 Fetch town_rul_csr into l_town_rul,
5433 l_town_rul_id;
5434 If town_rul_csr%NOTFOUND Then
5435 OKC_API.set_message(
5436 p_app_name => G_APP_NAME,
5437 p_msg_name => G_REQUIRED_VALUE,
5438 p_token1 => G_COL_NAME_TOKEN,
5439 p_token1_value => 'Tax Owner');
5440 x_return_status := OKC_API.G_RET_STS_ERROR;
5441 RAISE OKL_API.G_EXCEPTION_ERROR;
5442 Else
5443 l_tax_owner := rtrim(ltrim(l_town_rul,' '),' ');
5444 End If;
5445 Close town_rul_csr;
5446 End If;
5447
5448 OPEN l_hdr_csr( p_rbk_chr_id );
5449 FETCH l_hdr_csr INTO l_hdr_rec;
5450 CLOSE l_hdr_csr;
5451
5452 G_CHR_CURRENCY_CODE := l_hdr_rec.currency_code;
5453 G_FUNC_CURRENCY_CODE := okl_accounting_util.get_func_curr_code;
5454 G_CHR_AUTHORING_ORG_ID := l_hdr_rec.authoring_org_id;
5455 G_CHR_START_DATE := l_hdr_rec.start_date;
5456 G_CHR_REPORT_PDT_ID := l_hdr_rec.report_pdt_id;
5457
5458 l_rebook_allowed_on_mg_book := 'Y';
5459 l_Multi_GAAP_YN := 'N';
5460 --checks wheter Multi-GAAP processing needs tobe done
5461 --Bug 7708944. SMEREDDY 01/15/2009.
5462 -- Implemented MG changes based on PM recommendation.
5463
5464
5465 If l_rep_pdt_id is not NULL Then
5466 l_Multi_GAAP_YN := 'Y';
5467
5468 /*
5469 If l_deal_type = 'LEASEOP' and
5470 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
5471 nvl(l_tax_owner,'X') = 'LESSOR' Then
5472 l_Multi_GAAP_YN := 'Y';
5473 End If;
5474
5475 If l_deal_type in ('LEASEDF','LEASEST') and
5476 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
5477 nvl(l_tax_owner,'X') = 'LESSOR' Then
5478 l_Multi_GAAP_YN := 'Y';
5479 End If;
5480
5481 If l_deal_type in ('LEASEDF','LEASEST') and
5482 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
5483 nvl(l_tax_owner,'X') = 'LESSEE' Then
5484 l_Multi_GAAP_YN := 'Y';
5485 End If;
5486
5487 If l_deal_type = 'LOAN' and
5488 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
5489 nvl(l_tax_owner,'X') = 'LESSEE' Then
5490 l_Multi_GAAP_YN := 'Y';
5491 End If;
5492 */
5493 --Bug# 3548044
5494 --Bug# 3621663
5495 --Bug 7708944. SMEREDDY 01/15/2009.
5496 -- Implemented MG changes based on PM recommendation.
5497
5498 If l_deal_type = 'LEASEOP' and
5499 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST')
5500 and nvl(l_tax_owner,'X') = 'LESSOR' then
5501 --l_Multi_GAAP_YN := 'Y';
5502 l_rebook_allowed_on_mg_book := 'N';
5503 End If;
5504 If l_deal_type in ('LEASEDF','LEASEST') and
5505 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
5506 nvl(l_tax_owner,'X') = 'LESSOR' then
5507 --l_Multi_GAAP_YN := 'Y';
5508 l_rebook_allowed_on_mg_book := 'N';
5509 End If;
5510 If l_deal_type in ('LEASEDF','LEASEST') and
5511 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
5512 nvl(l_tax_owner,'X') = 'LESSEE' then
5513 --l_Multi_GAAP_YN := 'Y';
5514 l_rebook_allowed_on_mg_book := 'N';
5515 End If;
5516 --Bug# 3548044
5517
5518 End If;
5519
5520 If l_Multi_GAAP_YN = 'Y' Then
5521 --get reporting product book type
5522 l_rep_pdt_book := OKL_SYSTEM_PARAMS_ALL_PUB.get_system_param_value(OKL_SYSTEM_PARAMS_ALL_PUB.G_RPT_PROD_BOOK_TYPE_CODE);
5523 End If;
5524
5525
5526 --dbms_output.put_line('deal type :'||l_deal_type);
5527 --dbms_output.put_line('rbr code :'||l_rbr_code);
5528 -- If l_rbr_code IN ('ADJUST_COST',
5529 -- 'CHANGE_START_DATE',
5530 -- 'ADJUST_DPRN',
5531 -- 'EXTEND_TERM',
5532 -- 'OTHER') Then
5533 --get the adjusted parameters for all the lines from line transactions
5534 --dbms_output.put_line('deal type :'||l_deal_type);
5535 --get the adjusted parameters for all the lines from line transactions
5536 Open adj_txl_csr(p_rbk_chr_id => p_rbk_chr_id,
5537 p_effective_date => l_date_trx_occured);
5538 Loop
5539 Fetch adj_txl_csr into adj_txl_rec;
5540
5541 IF adj_txl_csr%NOTFOUND Then
5542
5543 ------------------------------------------------------------------
5544 -- Bug# 3103387 : Residual value is only used to default salvage value.
5545 -- Salvage value should not be updated when there is a change in residual
5546 -- value for an Operating Lease. So the following code is not required.
5547
5548 --Bug# 3103387 : End of commented code
5549 -------------------------------------------------------------------------
5550
5551 Exit;-- exit from adj_txl_csr
5552 ---------------------------------------------
5553 Else --adj_txl_csr found
5554 ---------------------------------------------
5555
5556
5557 ---------------------------------------------------------------
5558 -- Bug# 3548044 : A part of this bug the multi-gaap book should
5559 -- not mimic corporate book . It should adjust based on entered
5560 -- parameters. DF/ST(local) vs DF/ST(reporting) MG books are created with cost
5561 -- and SV zero to be untouched till offlease amortization process
5562 ---------------------------------------------------------------
5563 If ( adj_txl_rec.book_type_code = nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR))
5564 and (l_rebook_allowed_on_mg_book = 'N') Then
5565 --Exit;
5566 Null; --do not do anything for reporting book
5567 Else
5568
5569 --get actual parameters from FA to get the Delta
5570 Open okx_ast_csr (p_asset_number => adj_txl_rec.asset_number,
5571 p_book_type_code => adj_txl_rec.book_type_code);
5572 Loop
5573 Fetch okx_ast_csr into okx_ast_rec;
5574 Exit When okx_ast_csr%NOTFOUND;
5575 --dbms_output.put_line('book type code '||okx_ast_rec.book_type_code);
5576 --check if the line is effective on the original contract
5577 l_chk_cle_effective := '?';
5578 Open chk_line_csr(p_chr_id => l_chr_id,
5579 p_asset_id1 => okx_ast_rec.asset_id,
5580 p_asset_id2 => '#',
5581 p_effective_date => l_date_trx_occured);
5582 Fetch chk_line_csr into l_chk_cle_effective;
5583 If chk_line_csr%NOTFOUND Then
5584 Null;
5585 End If;
5586 Close chk_line_csr;
5587 If l_chk_cle_effective = '?' Then
5588 Exit; -- this line is not effective on the original contract
5589 --dbms_output.put_line('not an effective line.');
5590 Else
5591 --initialize
5592 l_adjust_yn := 'N';
5593 l_cost_delta := 0;
5594 l_salvage_delta := 0;
5595
5596 --Bug# 3548044 : removed comments
5597 l_asset_fin_rec_adj.cost := null;
5598 l_asset_fin_rec_adj.salvage_value := null;
5599 l_asset_fin_rec_adj.date_placed_in_service := null;
5600 l_asset_fin_rec_adj.life_in_months := null;
5601 l_asset_fin_rec_adj.deprn_method_code := null;
5602 l_asset_fin_rec_adj.basic_rate := null;
5603 l_asset_fin_rec_adj.adjusted_rate := null;
5604 --Bug# 3950089
5605 l_asset_fin_rec_adj.percent_salvage_value := null;
5606 --Bug# 3548044
5607
5608 -- Bug# 5174778
5609 l_func_curr_code := okl_accounting_util.get_func_curr_code;
5610
5611 l_dummy_amount := null;
5612 convert_2functional_currency(
5613 p_api_version => p_api_version,
5614 p_init_msg_list => p_init_msg_list,
5615 x_return_status => x_return_status,
5616 x_msg_count => x_msg_count,
5617 x_msg_data => x_msg_data,
5618 p_chr_id => p_rbk_chr_id,
5619 p_amount => adj_txl_rec.depreciation_cost,
5620 x_amount => l_dummy_amount);
5621
5622 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5623 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5624 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
5625 RAISE OKL_API.G_EXCEPTION_ERROR;
5626 END IF;
5627
5628 -- Bug# 5174778
5629 l_dummy_amount := okl_accounting_util.cross_currency_round_amount(
5630 p_amount => l_dummy_amount,
5631 p_currency_code => l_func_curr_code
5632 );
5633
5634 --calculate deltas
5635 l_cost_delta := (l_dummy_amount - okx_ast_rec.cost);
5636
5637 -- Bug# 4899328: Cap fee changes are now included in the
5638 -- Depreciation cost. Depreciation cost amount is automatically
5639 -- recalculated whenever there is a change to cap fee.
5640 /*
5641 --Bug# 3548044: Include Cap fee changes when calculating
5642 -- Cost delta
5643 Calc_Cap_Fee_Adjustment
5644 (p_api_version => p_api_version,
5645 p_init_msg_list => p_init_msg_list,
5646 x_msg_count => x_msg_count,
5647 x_msg_data => x_msg_data,
5648 x_return_status => x_return_status,
5649 p_rbk_fa_cle_id => adj_txl_rec.kle_id,
5650 p_rbk_chr_id => p_rbk_chr_id,
5651 x_cap_fee_adjustment => l_cap_fee_delta);
5652
5653 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5654 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5655 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
5656 RAISE OKL_API.G_EXCEPTION_ERROR;
5657 END IF;
5658
5659 l_cap_fee_delta_converted_amt := 0;
5660 convert_2functional_currency(
5661 p_api_version => p_api_version,
5662 p_init_msg_list => p_init_msg_list,
5663 x_return_status => x_return_status,
5664 x_msg_count => x_msg_count,
5665 x_msg_data => x_msg_data,
5666 p_chr_id => p_rbk_chr_id,
5667 p_amount => l_cap_fee_delta,
5668 x_amount => l_cap_fee_delta_converted_amt);
5669
5670 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5671 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5672 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
5673 RAISE OKL_API.G_EXCEPTION_ERROR;
5674 END IF;
5675
5676 l_cost_delta := (l_cost_delta + l_cap_fee_delta_converted_amt);
5677 --Bug# 3548044: End
5678 */
5679 --Bug# 4899328: End
5680
5681 --Bug# 3548044 : Added if-else clause for reporting product books
5682 If okx_ast_rec.book_type_code <> nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) then
5683
5684 --Bug# 3950089
5685 If (okx_ast_rec.percent_salvage_value is not null) Then
5686
5687 If (adj_txl_rec.pct_salvage_value is null) or
5688 (adj_txl_rec.salvage_value is not null) Then
5689
5690 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
5691 p_msg_name => 'OKL_LA_REVISE_SALVAGE_TYPE',
5692 p_token1 => G_ASSET_NUMBER_TOKEN,
5693 p_token1_value => okx_ast_rec.asset_number
5694 );
5695 x_return_status := OKL_API.G_RET_STS_ERROR;
5696 RAISE OKL_API.G_EXCEPTION_ERROR;
5697 End if;
5698
5699 Elsif (okx_ast_rec.salvage_value is not null) Then
5700
5701 If (adj_txl_rec.salvage_value is null) Then
5702
5703 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
5704 p_msg_name => 'OKL_LA_REVISE_SALVAGE_TYPE',
5705 p_token1 => G_ASSET_NUMBER_TOKEN,
5706 p_token1_value => okx_ast_rec.asset_number
5707 );
5708 x_return_status := OKL_API.G_RET_STS_ERROR;
5709 RAISE OKL_API.G_EXCEPTION_ERROR;
5710 End if;
5711 End If;
5712
5713 If (okx_ast_rec.percent_salvage_value is not null) and
5714 (okx_ast_rec.book_class = 'CORPORATE') Then
5715
5716 l_salvage_delta := ((adj_txl_rec.pct_salvage_value/100)
5717 - okx_ast_rec.percent_salvage_value);
5718
5719 Else
5720
5721 l_dummy_amount := null;
5722 convert_2functional_currency(
5723 p_api_version => p_api_version,
5724 p_init_msg_list => p_init_msg_list,
5725 x_return_status => x_return_status,
5726 x_msg_count => x_msg_count,
5727 x_msg_data => x_msg_data,
5728 p_chr_id => p_rbk_chr_id,
5729 p_amount => adj_txl_rec.salvage_value,
5730 x_amount => l_dummy_amount);
5731
5732 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5733 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5734 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
5735 RAISE OKL_API.G_EXCEPTION_ERROR;
5736 END IF;
5737
5738 -- Bug# 5174778
5739 l_dummy_amount := okl_accounting_util.cross_currency_round_amount(
5740 p_amount => l_dummy_amount,
5741 p_currency_code => l_func_curr_code
5742 );
5743
5744 l_salvage_delta := (l_dummy_amount - okx_ast_rec.salvage_value);
5745 End If;
5746
5747 ElsIf okx_ast_rec.book_type_code = nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) then
5748
5749 --Bug# 3950089
5750 If (okx_ast_rec.percent_salvage_value is not null) Then
5751
5752 If (adj_txl_rec.corp_pct_salvage_value is null) or
5753 (adj_txl_rec.corp_salvage_value is not null) Then
5754
5755 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
5756 p_msg_name => 'OKL_LA_REVISE_SALVAGE_TYPE',
5757 p_token1 => G_ASSET_NUMBER_TOKEN,
5758 p_token1_value => okx_ast_rec.asset_number
5759 );
5760 x_return_status := OKL_API.G_RET_STS_ERROR;
5761 RAISE OKL_API.G_EXCEPTION_ERROR;
5762 End if;
5763
5764 Elsif (okx_ast_rec.salvage_value is not null) Then
5765
5766 If (adj_txl_rec.corp_salvage_value is null) Then
5767
5768 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
5769 p_msg_name => 'OKL_LA_REVISE_SALVAGE_TYPE',
5770 p_token1 => G_ASSET_NUMBER_TOKEN,
5771 p_token1_value => okx_ast_rec.asset_number
5772 );
5773 x_return_status := OKL_API.G_RET_STS_ERROR;
5774 RAISE OKL_API.G_EXCEPTION_ERROR;
5775 End if;
5776 End If;
5777
5778 If (okx_ast_rec.percent_salvage_value is not null) Then
5779
5780 l_salvage_delta := ((adj_txl_rec.corp_pct_salvage_value/100)
5781 - okx_ast_rec.percent_salvage_value);
5782
5783 Else
5784 l_dummy_amount := null;
5785 convert_2functional_currency(
5786 p_api_version => p_api_version,
5787 p_init_msg_list => p_init_msg_list,
5788 x_return_status => x_return_status,
5789 x_msg_count => x_msg_count,
5790 x_msg_data => x_msg_data,
5791 p_chr_id => p_rbk_chr_id,
5792 p_amount => adj_txl_rec.corp_salvage_value,
5793 x_amount => l_dummy_amount);
5794
5795 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5796 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5797 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
5798 RAISE OKL_API.G_EXCEPTION_ERROR;
5799 END IF;
5800
5801 -- Bug# 5174778
5802 l_dummy_amount := okl_accounting_util.cross_currency_round_amount(
5803 p_amount => l_dummy_amount,
5804 p_currency_code => l_func_curr_code
5805 );
5806
5807 l_salvage_delta := (l_dummy_amount - okx_ast_rec.salvage_value);
5808 End If;
5809
5810 End If;
5811 --Bug# 3548044 end
5812
5813
5814 ------------------------------------------------------------------
5815 -- Bug# 3103387 : Residual value is only used to default salvage value.
5816 -- Salvage value should not be updated when there is a change in residual
5817 -- value for an Operating Lease. So the following code is not required.
5818
5819 --Bug# 3103387 : End of commented code
5820 ------------------------------------------------------------------------
5821
5822 --Bug# 2942543 : cost updates for DF lease contracts
5823 If (l_cost_delta <> 0) Then
5824 If l_deal_type in (G_DF_LEASE_BK_CLASS,G_ST_LEASE_BK_CLASS) And
5825 l_tax_owner = 'LESSEE' Then
5826 --no cost updates for df/st lease with tax owner 'LESSEE'
5827 Null;
5828 Elsif l_deal_type in (G_DF_LEASE_BK_CLASS,G_ST_LEASE_BK_CLASS) And
5829 okx_ast_rec.book_class = 'CORPORATE' Then
5830 --No cost updates for df/st lease on corporate asset book as
5831 --cost is adjusted to zero there from creation time
5832 Null;
5833 Else
5834 l_asset_fin_rec_adj.cost := l_cost_delta;
5835 l_adjust_yn := 'Y';
5836 End If;
5837 End If;
5838
5839 --Bug# 2942543 : salvage value updates for DF lease contracts
5840 If (l_salvage_delta <> 0) Then
5841 If l_deal_type in (G_DF_LEASE_BK_CLASS,G_ST_LEASE_BK_CLASS) And
5842 l_tax_owner = 'LESSEE' Then
5843 --no sv updates for df/st lease with tax owner 'LESSEE'
5844 Null;
5845 Elsif l_deal_type in (G_DF_LEASE_BK_CLASS,G_ST_LEASE_BK_CLASS) And
5846 okx_ast_rec.book_class = 'CORPORATE' Then
5847 --No cost updates for df/st lease on corporate asset book as
5848 --sv is adjusted to zero there from creation time
5849 Null;
5850 Elsif okx_ast_rec.book_class = 'TAX'
5851 --Bug # 3548044
5852 and okx_ast_rec.book_type_code <> nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR)Then
5853 --Salvage value will be zero in all the tax books as per bug#2967286
5854 --except for Muti-GAAP reporting books --Bug# 3548044
5855 Null;
5856 Else
5857
5858 --Bug# 3950089
5859 If (okx_ast_rec.percent_salvage_value is not null) Then
5860 l_asset_fin_rec_adj.percent_salvage_value := l_salvage_delta;
5861 Else
5862 l_asset_fin_rec_adj.salvage_value := l_salvage_delta;
5863 End if;
5864 l_adjust_yn := 'Y';
5865 End If;
5866 End If;
5867
5868 If trunc(nvl(adj_txl_rec.in_service_date,okx_ast_rec.in_service_date)) <> trunc(okx_ast_rec.in_service_date) Then
5869 l_asset_fin_rec_adj.date_placed_in_service := nvl(adj_txl_rec.in_service_date,okx_ast_rec.in_service_date);
5870 l_adjust_yn := 'Y';
5871 End If;
5872
5873 If nvl(adj_txl_rec.life_in_months,okx_ast_rec.life_in_months) <> okx_ast_rec.life_in_months Then
5874 l_asset_fin_rec_adj.deprn_method_code := nvl(adj_txl_rec.deprn_method,okx_ast_rec.deprn_method_code);
5875 l_asset_fin_rec_adj.life_in_months := nvl(adj_txl_rec.life_in_months,okx_ast_rec.life_in_months);
5876 l_asset_fin_rec_adj.basic_rate := adj_txl_rec.deprn_rate;
5877 l_asset_fin_rec_adj.adjusted_rate := adj_txl_rec.deprn_rate;
5878 l_adjust_yn := 'Y';
5879 End If;
5880
5881 --category updates not supported by API
5882 --If adj_txl_rec.depreciation_id <> okx_ast_rec.depreciation_category Then
5883 If nvl(adj_txl_rec.deprn_method,okx_ast_rec.deprn_method_code) <> okx_ast_rec.deprn_method_code Then
5884 l_asset_fin_rec_adj.deprn_method_code := nvl(adj_txl_rec.deprn_method,okx_ast_rec.deprn_method_code);
5885 l_asset_fin_rec_adj.life_in_months := adj_txl_rec.life_in_months;
5886 l_asset_fin_rec_adj.basic_rate := adj_txl_rec.deprn_rate;
5887 l_asset_fin_rec_adj.adjusted_rate := adj_txl_rec.deprn_rate;
5888 l_adjust_yn := 'Y';
5889 End If;
5890
5891 If nvl(adj_txl_rec.deprn_rate,okx_ast_rec.adjusted_rate) <> okx_ast_rec.adjusted_rate Then
5892 l_asset_fin_rec_adj.deprn_method_code := nvl(adj_txl_rec.deprn_method,okx_ast_rec.deprn_method_code);
5893 l_asset_fin_rec_adj.life_in_months := adj_txl_rec.life_in_months;
5894 l_asset_fin_rec_adj.basic_rate := nvl(adj_txl_rec.deprn_rate,okx_ast_rec.basic_rate);
5895 l_asset_fin_rec_adj.adjusted_rate := nvl(adj_txl_rec.deprn_rate,okx_ast_rec.adjusted_rate);
5896 l_adjust_yn := 'Y';
5897 End If;
5898
5899 If nvl(l_adjust_yn,'N') = 'Y' AND
5900 l_deal_type not in (G_LOAN_BK_CLASS,G_REVOLVING_LOAN_BK_CLASS) then
5901
5902 --bug # 2942543 :
5903 --check if salvage value is becoming more than asset cost
5904 --BUG# 3548044: check for all the books (not only corporate book)
5905 --If okx_ast_rec.book_class = 'CORPORATE' then --salvage value updates only for CORP
5906
5907 --Bug# 3950089
5908 l_new_cost := okx_ast_rec.cost + l_cost_delta;
5909 If (okx_ast_rec.percent_salvage_value is not null) Then
5910 l_new_salvage_value := l_new_cost * (NVL(adj_txl_rec.pct_salvage_value,0)/100);
5911 Else
5912 l_new_salvage_value := okx_ast_rec.salvage_value + l_salvage_delta;
5913 End If;
5914
5915 If (l_new_cost < l_new_salvage_value) Then
5916 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
5917 p_msg_name => G_SALVAGE_VALUE
5918 );
5919 RAISE OKL_API.G_EXCEPTION_ERROR;
5920 End If;
5921 --End If; --Bug# 3548044
5922
5923 -- Bug# 3783518
5924 -- Revision date should be in the current open period or in a
5925 -- prior period in FA
5926 -- Revision date should be equal to Contract Start Date in order
5927 -- to make an asset cost change
5928 validate_rebook_date
5929 (p_api_version => p_api_version,
5930 p_init_msg_list => p_init_msg_list,
5931 x_return_status => x_return_status,
5932 x_msg_count => x_msg_count,
5933 x_msg_data => x_msg_data,
5934 p_book_type_code => okx_ast_rec.book_type_code,
5935 p_rebook_date => l_date_trx_occured,
5936 p_cost_adjustment => l_asset_fin_rec_adj.cost,
5937 p_contract_start_date => l_start_date);
5938
5939 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5940 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5941 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
5942 RAISE OKL_API.G_EXCEPTION_ERROR;
5943 END IF;
5944
5945 -------------------
5946 --Bug# 6373605
5947 l_asset_fin_rec_adj.contract_id := l_orig_chr_id;
5948 ---------------------
5949 --call the adjustment api to do adjustment
5950 FIXED_ASSET_ADJUST
5951 (p_api_version => p_api_version,
5952 p_init_msg_list => p_init_msg_list,
5953 x_return_status => x_return_status,
5954 x_msg_count => x_msg_count,
5955 x_msg_data => x_msg_data,
5956 p_chr_id => p_rbk_chr_id,
5957 p_book_type_code => okx_ast_rec.book_type_code,
5958 p_asset_id => okx_ast_rec.asset_id,
5959 p_asset_fin_rec_adj => l_asset_fin_rec_adj,
5960 -- Bug Fix# 2925461
5961 p_adj_date => l_date_trx_occured,
5962 --Bug# 3156924
5963 p_trans_number => l_trx_number,
5964 p_calling_interface => l_calling_interface,
5965 --Bug# 6373605--SLA populate source
5966 p_sla_source_header_id => adj_txl_rec.sla_source_header_id,
5967 p_sla_source_header_table => 'OKL_TRX_ASSETS',
5968 p_sla_source_try_id => adj_txl_rec.sla_source_try_id,
5969 p_sla_source_line_id => adj_txl_rec.sla_source_line_id,
5970 p_sla_source_line_table => adj_txl_rec.sla_source_line_table,
5971 p_sla_source_chr_id => p_rbk_chr_id,
5972 p_sla_source_kle_id => adj_txl_rec.rbk_fin_ast_cle_id,
5973 --Bug# 6373605--SLA populate sources
5974 --Bug# 4028371
5975 x_fa_trx_date => l_fa_adj_date,
5976 x_asset_fin_rec_new => l_asset_fin_rec_new);
5977
5978 --dbms_output.put_line('After fixed asset adjust for rebook :'||x_return_status);
5979 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5980 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5981 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
5982 RAISE OKL_API.G_EXCEPTION_ERROR;
5983 END IF;
5984
5985 -- Bug# 5207066 start
5986
5987 -- Bug# 5207066 end
5988
5989 --Bug# 4028371
5990 If adj_txl_rec.tal_id is not null Then
5991 --update the fa trx date on transaction line
5992 l_talv_date_rec.id := adj_txl_rec.tal_id;
5993 l_talv_date_rec.fa_trx_date := l_fa_adj_date;
5994
5995 okl_tal_pvt.update_row
5996 (p_api_version => p_api_version,
5997 p_init_msg_list => p_init_msg_list,
5998 x_return_status => x_return_status,
5999 x_msg_count => x_msg_count,
6000 x_msg_data => x_msg_data,
6001 p_talv_rec => l_talv_date_rec,
6002 x_talv_rec => lx_talv_date_rec);
6003 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6004 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6005 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
6006 RAISE OKL_API.G_EXCEPTION_ERROR;
6007 END IF;
6008 End If;
6009 --End Bug# 4028371
6010 --5362977 akrangan start
6011 End If; --l_adjust_yn = 'Y'
6012 --Bug# 5121256/5150355
6013 If (l_deal_type not in (G_LOAN_BK_CLASS,G_REVOLVING_LOAN_BK_CLASS) AND
6014 okx_ast_rec.book_class = 'CORPORATE') Then
6015
6016 l_unit_difference := adj_txl_rec.rbk_current_units - okx_ast_rec.fa_current_units;
6017
6018 if (l_unit_difference <> 0) then
6019 FIXED_ASSET_ADJUST_UNIT
6020 (p_api_version => p_api_version,
6021 p_init_msg_list => p_init_msg_list,
6022 x_return_status => x_return_status,
6023 x_msg_count => x_msg_count,
6024 x_msg_data => x_msg_data,
6025 p_asset_id => okx_ast_rec.asset_id,
6026 p_book_type_code => okx_ast_rec.book_type_code,
6027 p_diff_in_units => l_unit_difference,
6028 p_trx_date => l_date_trx_occured,
6029 p_trx_number => l_trx_number,
6030 p_calling_interface => l_calling_interface,
6031 --Bug# 6373605--SLA populate source
6032 p_sla_source_header_id => adj_txl_rec.sla_source_header_id,
6033 p_sla_source_header_table => 'OKL_TRX_ASSETS',
6034 p_sla_source_try_id => adj_txl_rec.sla_source_try_id,
6035 p_sla_source_line_id => adj_txl_rec.sla_source_line_id,
6036 p_sla_source_line_table => adj_txl_rec.sla_source_line_table,
6037 p_sla_source_chr_id => p_rbk_chr_id,
6038 p_sla_source_kle_id => adj_txl_rec.rbk_fin_ast_cle_id,
6039 --Bug# 6373605--SLA populate sources
6040 --Bug# 4028371
6041 --Bug# 4028371
6042 x_fa_trx_date => l_fa_adj_date);
6043
6044 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6045 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6046 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
6047 RAISE OKL_API.G_EXCEPTION_ERROR;
6048 END IF;
6049
6050 end if;
6051 --Bug# 5362977
6052 -- Update Model number, manufacturer and description
6053 FIXED_ASSET_UPDATE_DESC
6054 (p_api_version => p_api_version,
6055 p_init_msg_list => p_init_msg_list,
6056 x_return_status => x_return_status,
6057 x_msg_count => x_msg_count,
6058 x_msg_data => x_msg_data,
6059 p_asset_id => okx_ast_rec.asset_id,
6060 p_model_number => adj_txl_rec.model_number,
6061 p_manufacturer => adj_txl_rec.manufacturer_name,
6062 p_description => adj_txl_rec.description,
6063 p_trx_date => l_date_trx_occured,
6064 p_trx_number => l_trx_number,
6065 p_calling_interface => l_calling_interface,
6066 --Bug# 4028371
6067 x_fa_trx_date => l_fa_adj_date);
6068 --akrangan bug 5362977 end
6069
6070 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6071 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6072 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
6073 RAISE OKL_API.G_EXCEPTION_ERROR;
6074 END IF;
6075
6076
6077 --akrangan bug 5362977 start
6078 -- Handle updates to serial numbers even when units are not changed
6079 OKL_ACTIVATE_IB_PVT.RBK_SRL_NUM_IB_INSTANCE
6080
6081 (p_api_version => p_api_version,
6082 p_init_msg_list => p_init_msg_list,
6083 x_return_status => x_return_status,
6084 x_msg_count => x_msg_count,
6085 x_msg_data => x_msg_data,
6086 p_rbk_fin_ast_cle_id => adj_txl_rec.rbk_fin_ast_cle_id,
6087 p_rbk_chr_id => p_rbk_chr_id);
6088 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6089 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6090 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
6091 RAISE OKL_API.G_EXCEPTION_ERROR;
6092 END IF;
6093 End If;
6094 --akrangan bug 5362977 end
6095
6096
6097 ---------------------------------------------------------------
6098 --Bug# 3548044 : MultiGaap Book to follow its own changes
6099 --will not mimic corporate book
6100 ---------------------------------------------------------------
6101 --start of comments
6102 -- end of comments
6103 ------------------------------------------------------------------*/
6104 --Bug# 3548044
6105
6106 End If; --chk_cle effective
6107 End Loop;
6108 Close okx_ast_csr;
6109 End If; -- proceed for books other than reporting book in case of local and reporting Tax leases
6110 --BUG# 3548044 : Process status for mass rebook asset transaction
6111 If adj_txl_rec.tas_id is not NULL then
6112
6113 update_trx_status(p_api_version => p_api_version,
6114 p_init_msg_list => p_init_msg_list,
6115 x_return_status => x_return_status,
6116 x_msg_count => x_msg_count,
6117 x_msg_data => x_msg_data,
6118 p_tas_id => adj_txl_rec.tas_id,
6119 p_tsu_code => G_TSU_CODE_PROCESSED);
6120
6121 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6122 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6123 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
6124 RAISE OKL_API.G_EXCEPTION_ERROR;
6125 END IF;
6126 End If;
6127 --BUG# 3548044
6128 End If; --adj_txl_rec found
6129
6130 End Loop;
6131 Close adj_txl_csr;
6132 -- End If; --rebook reason code
6133 End If; --rbr code csr
6134 CLOSE rbr_code_csr;
6135 --to check if new asset has been added and process accordingly
6136 OPEN new_ast_csr (p_rbk_chr_id => p_rbk_chr_id);
6137 Loop
6138 FETCH new_ast_csr into l_new_fin_cle_id,
6139 l_new_fa_cle_id,
6140 l_orig_chr_id;
6141 Exit When new_ast_csr%NOTFOUND;
6142
6143 -- Bug# 3574232 start
6144 l_adjust_asset_to_zero := 'N';
6145 If l_rep_pdt_id is not NULL Then
6146
6147 l_Multi_GAAP_YN := 'Y';
6148 -- If the reporting product is DF/ST lease, the asset should
6149 -- be created and written to zero in the reporting book.
6150 --Bug 7708944. SMEREDDY 01/15/2009.
6151 -- Implemented MG changes based on PM recommendation.
6152
6153
6154 If l_deal_type = 'LEASEOP' and
6155 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
6156 nvl(l_tax_owner,'X') = 'LESSOR' Then
6157 -- l_Multi_GAAP_YN := 'Y';
6158 l_adjust_asset_to_zero := 'Y';
6159 End If;
6160
6161 If l_deal_type in ('LEASEDF','LEASEST') and
6162 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
6163 nvl(l_tax_owner,'X') = 'LESSOR' Then
6164 -- l_Multi_GAAP_YN := 'Y';
6165 l_adjust_asset_to_zero := 'Y';
6166 End If;
6167
6168 If l_deal_type in ('LEASEDF','LEASEST') and
6169 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
6170 nvl(l_tax_owner,'X') = 'LESSEE' Then
6171 -- l_Multi_GAAP_YN := 'Y';
6172 l_adjust_asset_to_zero := 'Y';
6173 End If;
6174 End If;
6175
6176 If l_Multi_GAAP_YN = 'Y' Then
6177 --get reporting product book type
6178 l_rep_pdt_book := OKL_SYSTEM_PARAMS_ALL_PUB.get_system_param_value(OKL_SYSTEM_PARAMS_ALL_PUB.G_RPT_PROD_BOOK_TYPE_CODE);
6179 End If;
6180 -- Bug# 3574232 end
6181
6182 --process new fa line for asset additions
6183 --dbms_output.put_line('Found new line going in to add asset now.');
6184 --Bug 7708944. SMEREDDY 01/15/2009.
6185 -- Implemented MG changes based on PM recommendation.
6186
6187 If ((l_deal_type = 'LOAN') --and nvl(l_Multi_GAAP_YN,'N') = 'N')
6188 OR (l_deal_type = 'LOAN_REVOLVING')) Then
6189 Null;
6190 --Assets will not be activatted for LOANS which are not Multi-GAAP
6191 Else
6192 Process_FA_Line (p_api_version => p_api_version,
6193 p_init_msg_list => p_init_msg_list,
6194 x_return_status => x_return_status,
6195 x_msg_count => x_msg_count,
6196 x_msg_data => x_msg_data,
6197 p_chrv_id => l_orig_chr_id,
6198 p_fa_line_id => l_new_fa_cle_id,
6199 p_fin_ast_line_id => l_new_fin_cle_id,
6200 p_deal_type => l_deal_type,
6201 p_trx_type => l_trx_type,
6202 --Bug# : 11.5.9 enhance ment - Multi GAAP
6203 p_Multi_GAAP_YN => l_Multi_GAAP_YN,
6204 p_rep_pdt_book => l_rep_pdt_book,
6205 --Bug# : 11.5.9 enhance ment - Multi GAAP End
6206 --Bug# 3574232
6207 p_adjust_asset_to_zero => l_adjust_asset_to_zero,
6208 --Bug# 3156924
6209 p_trans_number => l_trx_number,
6210 p_calling_interface => l_calling_interface,
6211 --Bug# 3156924
6212 --Bug# 6373605 start
6213 p_sla_asset_chr_id => l_orig_chr_id,
6214 --Bug# 6373605
6215 x_cimv_rec => lx_cimv_rec);
6216 --dbms_output.put_line('After process FA line. '||x_return_status );
6217 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6218 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6219 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
6220 RAISE OKL_API.G_EXCEPTION_ERROR;
6221 END IF;
6222 End IF;
6223 --Bug# :11.5.9 : Multi-GAAP End
6224
6225 --process new fa line for IB Additions
6226 --dbms_output.put_line('going in to add IB now.');
6227 OKL_ACTIVATE_IB_PVT.ACTIVATE_RBK_IB_INST
6228 (p_api_version => p_api_version,
6229 p_init_msg_list => p_init_msg_list,
6230 x_return_status => x_return_status,
6231 x_msg_count => x_msg_count,
6232 x_msg_data => x_msg_data,
6233 p_fin_ast_cle_id => l_new_fin_cle_id,
6234 x_cimv_tbl => lx_cimv_ib_tbl);
6235 --dbms_output.put_line('After doing IB. '||x_return_status );
6236 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6237 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6238 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
6239 RAISE OKL_API.G_EXCEPTION_ERROR;
6240 END IF;
6241
6242 End Loop;
6243 Close new_ast_csr;
6244
6245 -- Bug# 4899328: Subsidy changes are now included in the
6246 -- Depreciation cost. Depreciation cost amount is automatically
6247 -- recalculated whenever there is a change to subsidies.
6248 /*
6249
6250 */
6251 -- Bug# 4899328: End
6252
6253 OKL_API.END_ACTIVITY (x_msg_count,x_msg_data );
6254 EXCEPTION
6255 WHEN OKL_API.G_EXCEPTION_ERROR THEN
6256 If ( l_hdr_csr%ISOPEN ) Then
6257 CLOSE l_hdr_csr;
6258 End If;
6259 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
6260 l_api_name,
6261 G_PKG_NAME,
6262 'OKL_API.G_RET_STS_ERROR',
6263 x_msg_count,
6264 x_msg_data,
6265 '_PVT');
6266 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
6267 If ( l_hdr_csr%ISOPEN ) Then
6268 CLOSE l_hdr_csr;
6269 End If;
6270 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
6271 l_api_name,
6272 G_PKG_NAME,
6273 'OKL_API.G_RET_STS_UNEXP_ERROR',
6274 x_msg_count,
6275 x_msg_data,
6276 '_PVT');
6277 WHEN OTHERS THEN
6278 If ( l_hdr_csr%ISOPEN ) Then
6279 CLOSE l_hdr_csr;
6280 End If;
6281 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
6282 l_api_name,
6283 G_PKG_NAME,
6284 'OTHERS',
6285 x_msg_count,
6286 x_msg_data,
6287 '_PVT');
6288 END REBOOK_ASSET;
6289 --------------------------------------------------------------------------------
6290 --Start of Comments
6291 --Procedure Name : MASS_REBOOK_ASSET (Activate code branch for mass_rebook)
6292 --Description : Will be called to make mass rebook adjustments in Oracle FA
6293 --History :
6294 -- 30-APR-2002 ashish.singh Created
6295 -- Notes :
6296 -- IN Parameters -
6297 -- p_rbk_chr_id - contract id of rebook contract
6298 -- although similar to rebook_asset processing this is kept
6299 -- separate as there may be differences later between rebook
6300 -- and mass Rebook
6301 --
6302 --End of Comments
6303 --------------------------------------------------------------------------------
6304 PROCEDURE MASS_REBOOK_ASSET (p_api_version IN NUMBER,
6305 p_init_msg_list IN VARCHAR2,
6306 x_return_status OUT NOCOPY VARCHAR2,
6307 x_msg_count OUT NOCOPY NUMBER,
6308 x_msg_data OUT NOCOPY VARCHAR2,
6309 p_rbk_chr_id IN NUMBER
6310 ) IS
6311
6312 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
6313 l_api_name CONSTANT varchar2(30) := 'MASS_REBOOK_ASSET';
6314 l_api_version CONSTANT NUMBER := 1.0;
6315
6316 --Cursor to get the rebook transaction reason codes
6317 CURSOR rbr_code_csr (p_rbk_chr_id IN NUMBER) IS
6318 SELECT ktrx.rbr_code,
6319 ktrx.date_transaction_occurred,
6320 khr.deal_type,
6321 chr.id,
6322 chr.sts_code,
6323 rul.rule_information1,
6324 khr.pdt_id,
6325 chr.start_date,
6326 --Bug# 3156924
6327 ktrx.trx_number
6328 FROM OKC_RULES_B rul,
6329 OKL_K_HEADERS khr,
6330 OKC_K_HEADERS_B chr,
6331 OKL_TRX_CONTRACTS ktrx
6332 WHERE rul.dnz_chr_id = chr.id
6333 AND rul.rule_information_category = 'LATOWN'
6334 AND khr.id = chr.id
6335 AND chr.id = p_rbk_chr_id
6336 AND exists (select null
6337 from okl_trx_types_tl tl
6338 where tl.language = 'US'
6339 and tl.name = 'Rebook'
6340 and tl.id = ktrx.try_id)
6341 AND ktrx.KHR_ID = chr.id
6342 AND ktrx.KHR_ID = rul.dnz_chr_id
6343 --rkuttiya added for 12.1.1 Multi GAAP Project
6344 AND ktrx.representation_type = 'PRIMARY'
6345 --
6346 AND ktrx.KHR_ID_NEW is null
6347 AND ktrx.tsu_code = G_TSU_CODE_ENTERED;
6348
6349 l_rbr_code OKL_TRX_CONTRACTS.rbr_code%TYPE;
6350 l_deal_type OKL_K_HEADERS.deal_type%TYPE;
6351 l_chr_id OKC_K_HEADERS_B.ID%TYPE;
6352 l_sts_code OKC_K_HEADERS_B.STS_CODE%TYPE;
6353 l_date_trx_occured OKL_TRX_CONTRACTS.date_transaction_occurred%TYPE;
6354 l_tax_owner OKC_RULES_B.RULE_INFORMATION1%TYPE;
6355 --Bug# 3156924
6356 l_trans_number OKL_TRX_CONTRACTS.trx_number%TYPE;
6357 l_calling_interface Varchar2(30) := 'OKLRACAB:Mass Rebook';
6358
6359 --cursor to get the adjusted residual value and OEC
6360 CURSOR adj_cle_csr (p_chr_id IN NUMBER, p_fa_cle_id IN NUMBER, p_effective_date IN date) IS
6361 SELECT kle.OEC,
6362 kle.RESIDUAL_VALUE,
6363 cle.id,
6364 cle.name
6365 FROM OKC_K_LINES_V cle,
6366 OKC_LINE_STYLES_B lse,
6367 OKL_K_LINES kle,
6368 OKC_K_LINES_B fa_cle,
6369 OKC_LINE_STYLES_B fa_cle_lse
6370 WHERE kle.id = cle.id
6371 AND cle.chr_id = p_chr_id
6372 AND cle.dnz_chr_id = p_chr_id
6373 AND cle.lse_id = lse.id
6374 AND lse.lty_code = G_FIN_AST_LINE_LTY_CODE
6375 AND cle.id = fa_cle.cle_id
6376 AND fa_cle.id = nvl(p_fa_cle_id,fa_cle.id)
6377 AND fa_cle.lse_id = fa_cle_lse.id
6378 AND fa_cle_lse.lty_code = G_FA_LINE_LTY_CODE
6379 --Bug# 2942543 : effectivity should be checked by keeping start and end date as inclusive
6380 --AND nvl(cle.start_date,p_effective_date) <= p_effective_date
6381 --AND nvl(cle.end_date,p_effective_date+1) > p_effective_date
6382 AND p_effective_date between cle.start_date and cle.end_date
6383 AND not exists (select '1'
6384 from OKC_STATUSES_B sts
6385 Where sts.code = cle.sts_code
6386 --Bug# 2522268
6387 --And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELED'));
6388 And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELLED'));
6389
6390 l_oec OKL_K_LINES.OEC%TYPE;
6391 l_residual_value OKL_K_LINES.RESIDUAL_VALUE%TYPE;
6392 l_cle_id OKC_K_LINES_V.ID%TYPE;
6393 l_asset_number OKC_K_LINES_V.NAME%TYPE;
6394
6395
6396 --cursor to get the modified transaction values against the rebook contract
6397 CURSOR adj_txl_csr (p_rbk_chr_id IN NUMBER, p_effective_date IN DATE ) IS
6398 SELECT txl.in_service_date in_service_date,
6399 txl.life_in_months life_in_months,
6400 txl.depreciation_cost depreciation_cost,
6401 txl.depreciation_id asset_category_id,
6402 txl.deprn_method deprn_method,
6403 txl.deprn_rate deprn_rate,
6404 txl.salvage_value salvage_value,
6405 txl.corporate_book book_type_code,
6406 txl.asset_number asset_number,
6407 txl.kle_id kle_id,
6408 --Bug# 3548044
6409 txl.tas_id tas_id,
6410 txl.salvage_value corp_salvage_value,
6411 --Bug# 4028371
6412 txl.id tal_id,
6413 --Bug# 6373605 start
6414 txl.id sla_source_line_id,
6415 txl.tas_id sla_source_header_id,
6416 'OKL_TXL_ASSETS_B' sla_source_line_table,
6417 tas.try_id sla_source_try_id,
6418 cle.cle_id sla_source_kle_id
6419 --Bug# 6373605 end
6420 FROM OKL_TXL_ASSETS_B txl,
6421 --Bug# 6373605 start
6422 OKL_TRX_ASSETS tas,
6423 --Bug# 6373605 end
6424 OKC_K_LINES_B cle,
6425 OKC_LINE_STYLES_B lse
6426 WHERE txl.kle_id = cle.id
6427 AND txl.tal_type = 'CRB'
6428 --Bug# 6373605 start
6429 AND tas.id = txl.tas_id
6430 --Bug# 6373605 end
6431 AND cle.dnz_chr_id = p_rbk_chr_id
6432 AND cle.lse_id = lse.id
6433 --effectivity
6434 --Bug# 2942543 : effectivity should be checked by keeping start and end date as inclusive
6435 --And nvl(cle.start_date,p_effective_date) <= p_effective_date
6436 --And nvl(cle.end_date,p_effective_date+1) > p_effective_date
6437 AND p_effective_date between cle.start_date and cle.end_date
6438 AND not exists (select '1'
6439 from OKC_STATUSES_B sts
6440 Where sts.code = cle.sts_code
6441 --Bug# 2522268
6442 --And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELED')
6443 And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELLED')
6444 )
6445 AND lse.lty_code = G_FA_LINE_LTY_CODE
6446 AND exists (select '1'
6447 from OKL_TRX_ASSETS TRX
6448 Where TRX.ID = Txl.tas_id
6449 And TRX.tas_type = 'CRB'
6450 And TRX.tsu_code = 'ENTERED')
6451 UNION
6452 SELECT txl.in_service_date in_service_date,
6453 txd.life_in_months_tax life_in_months,
6454 txd.cost depreciation_cost,
6455 txl.depreciation_id asset_category_id,
6456 txd.deprn_method_tax deprn_method,
6457 txd.deprn_rate_tax deprn_rate,
6458 txd.salvage_value salvage_value,
6459 txd.tax_book book_type_code,
6460 txd.asset_number asset_number,
6461 txl.kle_id kle_id,
6462 --bug# 3548044
6463 null tas_id,
6464 txl.salvage_value corp_salvage_value,
6465 --Bgu# 4028371
6466 null tal_id,
6467 --Bug# 6373605 start
6468 txd.id sla_source_line_id,
6469 txl.tas_id sla_source_header_id,
6470 'OKL_TXD_ASSETS_B' sla_source_line_table,
6471 tas.try_id sla_source_try_id,
6472 cle.cle_id sla_source_kle_id
6473 --Bug# 6373605 end
6474 FROM OKL_TXD_ASSETS_B txd,
6475 OKL_TXL_ASSETS_B txl,
6476 --Bug# 6373605 start
6477 OKL_TRX_ASSETS tas,
6478 --Bug# 6373605 end
6479 OKC_K_LINES_B cle,
6480 OKC_LINE_STYLES_B lse
6481 WHERE txd.tal_id = txl.id
6482 --Bug# 6373605 start
6483 AND tas.id = txl.tas_id
6484 --Bug# 6373605
6485 AND txl.kle_id = cle.id
6486 AND cle.dnz_chr_id = p_rbk_chr_id
6487 AND cle.lse_id = lse.id
6488 --effectivity
6489 --Bug# 2942543 : effectivity should be checked by keeping start and end date as inclusive
6490 --And nvl(cle.start_date,p_effective_date) <= p_effective_date
6491 --And nvl(cle.end_date,p_effective_date+1) > p_effective_date
6492 AND p_effective_date between cle.start_date and cle.end_date
6493 AND not exists (select '1'
6494 from OKC_STATUSES_B sts
6495 Where sts.code = cle.sts_code
6496 --Bug# 2522268
6497 --And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELED')
6498 And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELLED')
6499 )
6500 AND lse.lty_code = G_FA_LINE_LTY_CODE
6501 AND exists (select '1'
6502 from OKL_TRX_ASSETS TRX
6503 Where TRX.ID = Txl.tas_id
6504 And TRX.tas_type = 'CRB'
6505 And TRX.tsu_code = 'ENTERED');
6506
6507 adj_txl_rec adj_txl_csr%ROWTYPE;
6508 --Bug# : 11.5.9 enhancement Multi GAAP
6509 l_pdt_id OKL_K_HEADERS.pdt_id%TYPE;
6510 l_start_date Date;
6511 l_rep_pdt_id Number;
6512 l_rep_deal_type Varchar2(150);
6513 l_Multi_GAAP_YN Varchar2(1) := 'N';
6514 l_rep_pdt_book OKX_AST_BKS_V.Book_Type_Code%Type;
6515
6516 l_dummy_amount NUMBER;
6517
6518 --cursor to get the actual values from FA for the contract
6519 CURSOR okx_ast_csr (p_asset_number IN VARCHAR2,
6520 p_book_type_code IN VARCHAR2) is
6521 SELECT okx.acquisition_date in_service_date,
6522 okx.life_in_months life_in_months,
6523 okx.cost cost,
6524 okx.depreciation_category depreciation_category,
6525 okx.deprn_method_code deprn_method_code,
6526 okx.adjusted_rate adjusted_rate,
6527 okx.basic_rate basic_rate,
6528 okx.salvage_value salvage_value,
6529 okx.book_type_code book_type_code,
6530 okx.book_class book_class,
6531 okx.asset_number asset_number,
6532 okx.asset_id asset_id
6533 FROM okx_ast_bks_v okx
6534 WHERE okx.asset_number = p_asset_number
6535 AND okx.book_type_code = nvl(p_book_type_code,okx.book_type_code);
6536
6537 okx_ast_rec okx_ast_csr%ROWTYPE;
6538
6539 --Cursor to check if the asset has no been deactivated/canceled on the original contract
6540 Cursor chk_line_csr (p_chr_id IN NUMBER,
6541 p_asset_id1 IN VARCHAR2,
6542 p_asset_id2 IN VARCHAR2,
6543 p_effective_date IN DATE) IS
6544 Select '!'
6545 from OKC_K_LINES_B cle,
6546 OKC_STATUSES_B sts,
6547 OKC_K_ITEMS cim
6548 Where cle.sts_code = sts.CODE
6549 --Bug# 2942543 : effectivity should be checked by keeping start and end date as inclusive
6550 --And nvl(sts.start_date,p_effective_date) <= p_effective_date
6551 --And nvl(sts.end_date,p_effective_date+1) > p_effective_date
6552 --And nvl(cle.start_date,p_effective_date) <= p_effective_date
6553 --And nvl(cle.end_date,p_effective_date+1) > p_effective_date
6554 And p_effective_date between cle.start_date and cle.end_date
6555 And cle.id = cim.cle_id
6556 And cle.dnz_chr_id = p_chr_id
6557 And cim.dnz_chr_id = p_chr_id
6558 And cim.object1_id1 = p_asset_id1
6559 And cim.object1_id2 = p_asset_id2
6560 And cim.jtot_object1_code = 'OKX_ASSET'
6561 --Bug #2522268
6562 --And sts.ste_code not in ('HOLD','EXPIRED','TERMINATED','CANCELED');
6563 And sts.ste_code not in ('HOLD','EXPIRED','TERMINATED','CANCELLED');
6564
6565 l_chk_cle_effective Varchar2(1) default '?';
6566
6567 l_cost_delta Number;
6568 l_salvage_delta Number;
6569 l_asset_fin_rec_adj FA_API_TYPES.asset_fin_rec_type;
6570 l_asset_fin_rec_new FA_API_TYPES.asset_fin_rec_type;
6571 l_adjust_yn Varchar2(1);
6572
6573 --cursor to get tax owner rule
6574 Cursor town_rul_csr (pchrid number) is
6575 Select rule_information1 tax_owner,
6576 id
6577 From okc_rules_b rul
6578 where rul.dnz_chr_id = pchrid
6579 and rul.rule_information_category = 'LATOWN'
6580 and nvl(rul.STD_TEMPLATE_YN,'N') = 'N';
6581
6582 l_town_rul okc_rules_b.rule_information1%TYPE;
6583 l_town_rul_id okc_rules_b.id%TYPE;
6584
6585 l_mass_rebook_date date default sysdate;
6586
6587 --Bug# 2942543 :
6588 l_new_salvage_value number;
6589 l_new_cost number;
6590
6591 --Bug# 3548044
6592 l_rebook_allowed_on_mg_book varchar2(1);
6593 --Bug# 4028371
6594 l_fa_adj_date date;
6595 l_talv_date_rec okl_tal_pvt.talv_rec_type;
6596 lx_talv_date_rec okl_tal_pvt.talv_rec_type;
6597
6598 l_hdr_rec l_hdr_csr%ROWTYPE;
6599
6600 BEGIN
6601
6602 x_return_status := OKL_API.G_RET_STS_SUCCESS;
6603 -- Call start_activity to create savepoint, check compatibility
6604 -- and initialize message list
6605 x_return_status := OKL_API.START_ACTIVITY (
6606 l_api_name
6607 ,p_init_msg_list
6608 ,'_PVT'
6609 ,x_return_status);
6610 -- Check if activity started successfully
6611 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6612 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6613 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
6614 RAISE OKL_API.G_EXCEPTION_ERROR;
6615 END IF;
6616
6617 --get rebook reason code
6618 --dbms_output.put_line('before rebook reason code cursor :');
6619 OPEN rbr_code_csr (p_rbk_chr_id => p_rbk_chr_id);
6620 Fetch rbr_code_csr into l_rbr_code,
6621 l_date_trx_occured,
6622 l_deal_type,
6623 l_chr_id,
6624 l_sts_code,
6625 l_tax_owner,
6626 l_pdt_id,
6627 l_start_date,
6628 --Bug# 3156924
6629 l_trans_number;
6630
6631
6632 If rbr_code_csr%NOTFOUND Then
6633 --rebook transacton not found
6634 --does this call for raising error
6635 Null;
6636 Else
6637
6638 --Bug# 3156924
6639 l_mass_rebook_date := l_date_trx_occured;
6640 --Bug# 3156924
6641
6642 --almost redundant code here as for mass rebook no changes in scope
6643 -- for the corporate book
6644 Get_Pdt_Params (p_api_version => p_api_version,
6645 p_init_msg_list => p_init_msg_list,
6646 x_return_status => x_return_status,
6647 x_msg_count => x_msg_count,
6648 x_msg_data => x_msg_data,
6649 p_pdt_id => l_pdt_id,
6650 p_pdt_date => l_start_date,
6651 x_rep_pdt_id => l_rep_pdt_id,
6652 x_tax_owner => l_tax_owner,
6653 x_rep_deal_type => l_rep_deal_type);
6654
6655 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6656 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6657 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
6658 RAISE OKL_API.G_EXCEPTION_ERROR;
6659 END IF;
6660
6661 If l_tax_owner is null then
6662 Open town_rul_csr(pchrid => l_chr_id);
6663 Fetch town_rul_csr into l_town_rul,
6664 l_town_rul_id;
6665 If town_rul_csr%NOTFOUND Then
6666 OKC_API.set_message(
6667 p_app_name => G_APP_NAME,
6668 p_msg_name => G_REQUIRED_VALUE,
6669 p_token1 => G_COL_NAME_TOKEN,
6670 p_token1_value => 'Tax Owner');
6671 x_return_status := OKC_API.G_RET_STS_ERROR;
6672 RAISE OKL_API.G_EXCEPTION_ERROR;
6673 Else
6674 l_tax_owner := rtrim(ltrim(l_town_rul,' '),' ');
6675 End If;
6676 Close town_rul_csr;
6677 End If;
6678
6679 OPEN l_hdr_csr( p_rbk_chr_id );
6680 FETCH l_hdr_csr INTO l_hdr_rec;
6681 CLOSE l_hdr_csr;
6682
6683 G_CHR_CURRENCY_CODE := l_hdr_rec.currency_code;
6684 G_FUNC_CURRENCY_CODE := okl_accounting_util.get_func_curr_code;
6685 G_CHR_AUTHORING_ORG_ID := l_hdr_rec.authoring_org_id;
6686 G_CHR_START_DATE := l_hdr_rec.start_date;
6687 G_CHR_REPORT_PDT_ID := l_hdr_rec.report_pdt_id;
6688
6689
6690 --BUG# 3548044
6691 l_rebook_allowed_on_mg_book := 'Y';
6692 l_Multi_GAAP_YN := 'N';
6693 --checks wheter Multi-GAAP processing needs tobe done
6694 If l_rep_pdt_id is not NULL Then
6695
6696 --Bug 7708944. SMEREDDY 01/15/2009.
6697 -- Implemented MG changes based on PM recommendation.
6698
6699 l_Multi_GAAP_YN := 'Y';
6700 /*
6701 If l_deal_type = 'LEASEOP' and
6702 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
6703 nvl(l_tax_owner,'X') = 'LESSOR' Then
6704 l_Multi_GAAP_YN := 'Y';
6705 End If;
6706
6707 If l_deal_type in ('LEASEDF','LEASEST') and
6708 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
6709 nvl(l_tax_owner,'X') = 'LESSOR' Then
6710 l_Multi_GAAP_YN := 'Y';
6711 End If;
6712
6713 If l_deal_type in ('LEASEDF','LEASEST') and
6714 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
6715 nvl(l_tax_owner,'X') = 'LESSEE' Then
6716 l_Multi_GAAP_YN := 'Y';
6717 End If;
6718
6719 If l_deal_type = 'LOAN' and
6720 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
6721 nvl(l_tax_owner,'X') = 'LESSEE' Then
6722 l_Multi_GAAP_YN := 'Y';
6723 End If;
6724 */
6725 --Bug# 3548044
6726 --Bug# 3621663
6727 --Bug 7708944. SMEREDDY 01/15/2009.
6728 -- Implemented MG changes based on PM recommendation.
6729
6730 If l_deal_type = 'LEASEOP' and
6731 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST')
6732 and nvl(l_tax_owner,'X') = 'LESSOR' then
6733 --l_Multi_GAAP_YN := 'Y';
6734 l_rebook_allowed_on_mg_book := 'N';
6735 End If;
6736 If l_deal_type in ('LEASEDF','LEASEST') and
6737 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
6738 nvl(l_tax_owner,'X') = 'LESSOR' then
6739 --l_Multi_GAAP_YN := 'Y';
6740 l_rebook_allowed_on_mg_book := 'N';
6741 End If;
6742 If l_deal_type in ('LEASEDF','LEASEST') and
6743 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
6744 nvl(l_tax_owner,'X') = 'LESSEE' then
6745 --l_Multi_GAAP_YN := 'Y';
6746 l_rebook_allowed_on_mg_book := 'N';
6747 End If;
6748 --Bug# 3548044
6749 End If;
6750
6751 If l_Multi_GAAP_YN = 'Y' Then
6752 --get reporting product book type
6753 l_rep_pdt_book := OKL_SYSTEM_PARAMS_ALL_PUB.get_system_param_value(OKL_SYSTEM_PARAMS_ALL_PUB.G_RPT_PROD_BOOK_TYPE_CODE);
6754 End If;
6755
6756
6757 --dbms_output.put_line('deal type :'||l_deal_type);
6758 --get the adjusted parameters for all the lines from line transactions
6759 Open adj_txl_csr(p_rbk_chr_id => p_rbk_chr_id,
6760 p_effective_date => l_date_trx_occured);
6761 Loop
6762 Fetch adj_txl_csr into adj_txl_rec;
6763
6764 IF adj_txl_csr%NOTFOUND Then
6765
6766 ------------------------------------------------------------------
6767 -- Bug# 3103387 : Residual value is only used to default salvage value.
6768 -- Salvage value should not be updated when there is a change in residual
6769 -- value for an Operating Lease. So the following code is not required.
6770 /*---------------------------------------------------------------
6771
6772 --Process for operating Lease
6773 --for operating lease salvage value = residual value
6774 If l_deal_type = G_OP_LEASE_BK_CLASS Then
6775 --dbms_output.put_line('deal type is operating Lease');
6776 --get the adjusted parameters for all the lines from k lines
6777 OPEN adj_cle_csr (p_chr_id => l_chr_id,
6778 p_fa_cle_id => null,
6779 p_effective_date => l_date_trx_occured);
6780 Loop
6781 FETCH adj_cle_csr into l_oec,
6782 l_residual_value,
6783 l_cle_id,
6784 l_asset_number;
6785 Exit When adj_cle_csr%NOTFOUND;
6786 If (l_residual_value is not null) AND (l_residual_value <> 0) then
6787 --get actual parameters from FA to get the Delta
6788 Open okx_ast_csr (p_asset_number => l_asset_number,
6789 p_book_type_code => NULL);
6790 Loop
6791 Fetch okx_ast_csr into okx_ast_rec;
6792 Exit When okx_ast_csr%NOTFOUND;
6793 --dbms_output.put_line('book type code '||okx_ast_rec.book_type_code);
6794 --check if the line is effective on the original contract
6795
6796
6797 --Bug# 2942543 : Tax book will have salvage valu zero so no
6798 -- updates to salvage value for tax books
6799 If okx_ast_rec.Book_class = 'CORPORATE' then
6800 l_chk_cle_effective := '?';
6801 Open chk_line_csr(p_chr_id => l_chr_id,
6802 p_asset_id1 => okx_ast_rec.asset_id,
6803 p_asset_id2 => '#',
6804 p_effective_date => l_date_trx_occured);
6805 Fetch chk_line_csr into l_chk_cle_effective;
6806 If chk_line_csr%NOTFOUND Then
6807 Null;
6808 End If;
6809 Close chk_line_csr;
6810 If l_chk_cle_effective = '?' Then
6811 Exit; -- this line is not effective on the original contract
6812 --dbms_output.put_line('not an effective line.');
6813 Else
6814 --initialize
6815 l_adjust_yn := 'N';
6816 l_cost_delta := 0;
6817 l_salvage_delta := 0;
6818 --l_asset_fin_rec_adj.cost := null;
6819 --l_asset_fin_rec_adj.salvage_value := null;
6820 --l_asset_fin_rec_adj.date_placed_in_service := null;
6821 --l_asset_fin_rec_adj.life_in_months := null;
6822 --l_asset_fin_rec_adj.deprn_method_code := null;
6823 --l_asset_fin_rec_adj.basic_rate := null;
6824 --l_asset_fin_rec_adj.adjusted_rate := null;
6825
6826 l_dummy_amount := null;
6827 convert_2functional_currency(
6828 p_api_version => p_api_version,
6829 p_init_msg_list => p_init_msg_list,
6830 x_return_status => x_return_status,
6831 x_msg_count => x_msg_count,
6832 x_msg_data => x_msg_data,
6833 p_chr_id => p_rbk_chr_id,
6834 p_amount => l_residual_value,
6835 x_amount => l_dummy_amount);
6836
6837 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6838 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6839 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
6840 RAISE OKL_API.G_EXCEPTION_ERROR;
6841 END IF;
6842
6843 l_salvage_delta := (l_dummy_amount - okx_ast_rec.salvage_value);
6844
6845 --dbms_output.put_line('salvage delta '||to_char(l_salvage_delta));
6846 If l_salvage_delta <> 0 Then
6847 l_asset_fin_rec_adj.salvage_value := l_salvage_delta;
6848 l_adjust_yn := 'Y';
6849 End If;
6850
6851 If l_adjust_yn = 'Y' Then
6852
6853 --bug # 2942543 :
6854 --check if salvage value is becoming more than asset cost
6855 l_new_salvage_value := okx_ast_rec.salvage_value + l_salvage_delta;
6856 l_new_cost := okx_ast_rec.cost;
6857 If (l_new_cost < l_new_salvage_value) Then
6858 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
6859 p_msg_name => G_SALVAGE_VALUE
6860 );
6861 RAISE OKL_API.G_EXCEPTION_ERROR;
6862 End If;
6863
6864 --Bug# 6373605
6865 l_asset_fin_rec_adj.contract_id := p_rbk_chr_id;
6866 FIXED_ASSET_ADJUST
6867 (p_api_version => p_api_version,
6868 p_init_msg_list => p_init_msg_list,
6869 x_return_status => x_return_status,
6870 x_msg_count => x_msg_count,
6871 x_msg_data => x_msg_data,
6872 p_chr_id => p_rbk_chr_id,
6873 p_asset_id => okx_ast_rec.asset_id,
6874 p_book_type_code => okx_ast_rec.book_type_code,
6875 p_asset_fin_rec_adj => l_asset_fin_rec_adj,
6876 -- Bug Fix# 2925461
6877 p_adj_date => l_mass_rebook_date,
6878 --Bug# 3156924
6879 p_trans_number => l_trans_number,
6880 p_calling_interface => l_calling_interface,
6881 --Bug# 6373605--SLA populate source
6882 p_sla_source_header_id => adj_txl_rec.sla_source_header_id,
6883 p_sla_source_header_table => 'OKL_TRX_ASSETS',
6884 p_sla_source_try_id => adj_txl_rec.sla_source_try_id,
6885 p_sla_source_line_id => adj_txl_rec.sla_source_line_id,
6886 p_sla_source_line_table => adj_txl_rec.sla_source_line_table,
6887 p_sla_source_chr_id => p_rbk_chr_id,
6888 p_sla_source_kle_id => adj_txl_rec.sla_source_kle_id,
6889 --Bug# 6373605--SLA populate sources
6890 --Bug# 4028371
6891 x_fa_trx_date => l_fa_adj_date,
6892 --Bug# 3156924
6893 x_asset_fin_rec_new => l_asset_fin_rec_new);
6894 --dbms_output.put_line('After fixed asset adjust for rebook :'||x_return_status);
6895 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6896 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6897 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
6898 RAISE OKL_API.G_EXCEPTION_ERROR;
6899 END IF;
6900
6901 End If; --adjust yn = 'Y'
6902 End If; --cle is effective
6903 End If; --do salvage value adjustments only for Corporate Book
6904 End Loop;
6905 Close okx_ast_csr;
6906 End If; --residual value is not null
6907 End Loop;
6908 CLOSE adj_cle_csr;
6909 End If; -- dela type = operating lease
6910 ------------------------------------------------------------------------*/
6911 --Bug# 3103387 : End of commented code
6912 -------------------------------------------------------------------------
6913 Exit;-- exit from adj_txl_csr
6914 ---------------------------------------------
6915 Else --adj_txl_csr found
6916 ---------------------------------------------
6917
6918 ----------------------------------------------------------------------
6919 --Bug# 3548044: Multi-GAAP reporting Books should not follow CORP book
6920 --changes . But Mass rebook does not support corp book changes
6921 --does not support Multi-GAAP book changes
6922 ----------------------------------------------------------------------
6923 If ( adj_txl_rec.book_type_code = nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR)) Then
6924 --Exit;
6925 Null;
6926 --do not change the reporting tax book
6927 Else
6928 --get actual parameters from FA to get the Delta
6929 Open okx_ast_csr (p_asset_number => adj_txl_rec.asset_number,
6930 p_book_type_code => adj_txl_rec.book_type_code);
6931 Loop
6932 Fetch okx_ast_csr into okx_ast_rec;
6933 Exit When okx_ast_csr%NOTFOUND;
6934 --dbms_output.put_line('book type code '||okx_ast_rec.book_type_code);
6935 --check if the line is effective on the original contract
6936 l_chk_cle_effective := '?';
6937 Open chk_line_csr(p_chr_id => l_chr_id,
6938 p_asset_id1 => okx_ast_rec.asset_id,
6939 p_asset_id2 => '#',
6940 p_effective_date => l_date_trx_occured);
6941 Fetch chk_line_csr into l_chk_cle_effective;
6942 If chk_line_csr%NOTFOUND Then
6943 Null;
6944 End If;
6945 Close chk_line_csr;
6946 If l_chk_cle_effective = '?' Then
6947 Exit; -- this line is not effective on the original contract
6948 --dbms_output.put_line('not an effective line.');
6949 Else
6950 --initialize
6951 l_adjust_yn := 'N';
6952 l_cost_delta := 0;
6953 l_salvage_delta := 0;
6954 -- l_asset_fin_rec_adj.cost := null;
6955 -- l_asset_fin_rec_adj.salvage_value := null;
6956 -- l_asset_fin_rec_adj.date_placed_in_service := null;
6957 -- l_asset_fin_rec_adj.life_in_months := null;
6958 -- l_asset_fin_rec_adj.deprn_method_code := null;
6959 -- l_asset_fin_rec_adj.basic_rate := null;
6960 -- l_asset_fin_rec_adj.adjusted_rate := null;
6961
6962 --change in cost and salvage value(directly) is not
6963 --supported in mass rebook till todate therefor commenting
6964 --the folowing code
6965
6966 --calculate deltas
6967 -- If (adj_txl_rec.depreciation_cost is not null) and
6968 -- (adj_txl_rec.depreciation_cost <> 0) then
6969 -- convert_2functional_currency( p_rbk_chr_id,
6970 -- adj_txl_rec.depreciation_cost,
6971 -- l_dummy_amount);
6972 -- l_cost_delta := (l_dummy_amount - okx_ast_rec.cost);
6973 -- End If;
6974 -- If (adj_txl_rec.salvage_value is not null) and
6975 -- (adj_txl_rec.salvage_value <> 0) then
6976 -- convert_2functional_currency( p_rbk_chr_id,
6977 -- adj_txl_rec.salvage_value,
6978 -- l_dummy_amount);
6979 -- l_salvage_delta := (l_dummy_amount - okx_ast_rec.salvage_value);
6980 -- End If;
6981
6982 ------------------------------------------------------------------
6983 -- Bug# 3103387 : Residual value is only used to default salvage value.
6984 -- Salvage value should not be updated when there is a change in residual
6985 -- value for an Operating Lease. So the following code is not required.
6986 /*---------------------------------------------------------------
6987
6988 --for operating lease salvage value = residual value
6989 If l_deal_type = G_OP_LEASE_BK_CLASS Then
6990
6991 --dbms_output.put_line('deal type is operating Lease');
6992 --get the adjusted parameters for all the lines from k lines
6993 OPEN adj_cle_csr (p_chr_id => l_chr_id,
6994 p_fa_cle_id => adj_txl_rec.kle_id,
6995 p_effective_date => l_date_trx_occured);
6996 FETCH adj_cle_csr into l_oec,
6997 l_residual_value,
6998 l_cle_id,
6999 l_asset_number;
7000 If adj_cle_csr%NOTFOUND Then
7001 l_residual_value := 0;
7002 End If;
7003
7004 If (l_residual_value <> 0) and (l_residual_value is not null) Then
7005 l_dummy_amount := null;
7006 convert_2functional_currency(
7007 p_api_version => p_api_version,
7008 p_init_msg_list => p_init_msg_list,
7009 x_return_status => x_return_status,
7010 x_msg_count => x_msg_count,
7011 x_msg_data => x_msg_data,
7012 p_chr_id => p_rbk_chr_id,
7013 p_amount => l_residual_value,
7014 x_amount => l_dummy_amount);
7015
7016 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
7017 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7018 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
7019 RAISE OKL_API.G_EXCEPTION_ERROR;
7020 END IF;
7021
7022 l_salvage_delta := (l_dummy_amount - okx_ast_rec.salvage_value);
7023 --dbms_output.put_line('salvage delta '||to_char(l_salvage_delta));
7024 End If;
7025 Close adj_cle_csr;
7026
7027 End If;
7028 ------------------------------------------------------------------------*/
7029 --Bug# 3103387 : End of commented code
7030 --------------------------------------------------------------------------
7031
7032 --Bug# 2942543 : cost updates for DF lease contracts
7033 If (l_cost_delta <> 0) Then
7034 If l_deal_type in (G_DF_LEASE_BK_CLASS,G_ST_LEASE_BK_CLASS) And
7035 l_tax_owner = 'LESSEE' Then
7036 --no cost updates for df/st lease with tax owner 'LESSEE'
7037 Null;
7038 Elsif l_deal_type in (G_DF_LEASE_BK_CLASS,G_ST_LEASE_BK_CLASS) And
7039 okx_ast_rec.book_class = 'CORPORATE' Then
7040 --No cost updates for df/st lease on corporate asset book as
7041 --cost is adjusted to zero there from creation time
7042 Null;
7043 --BUG# 3548044 : cost updates on corp book not supported
7044 Elsif okx_ast_rec.Book_class = 'CORPORATE' then
7045 null;
7046 Else
7047 l_asset_fin_rec_adj.cost := l_cost_delta;
7048 l_adjust_yn := 'Y';
7049 End If;
7050 End If;
7051
7052 --Bug# 2942543 : salvage value updates for DF lease contracts
7053 If (l_salvage_delta <> 0) Then
7054 If l_deal_type in (G_DF_LEASE_BK_CLASS,G_ST_LEASE_BK_CLASS) And
7055 l_tax_owner = 'LESSEE' Then
7056 --no sv updates for df/st lease with tax owner 'LESSEE'
7057 Null;
7058 Elsif l_deal_type in (G_DF_LEASE_BK_CLASS,G_ST_LEASE_BK_CLASS) And
7059 okx_ast_rec.book_class = 'CORPORATE' Then
7060 --No cost updates for df/st lease on corporate asset book as
7061 --sv is adjusted to zero there from creation time
7062 Null;
7063 Elsif okx_ast_rec.book_class = 'TAX' Then
7064 --Salvage value will be zero in all the tax books as per bug#2967286
7065 Null;
7066 --BUG# 3548044 : SV updates on corp book not supported
7067 Elsif okx_ast_rec.Book_class = 'CORPORATE' then
7068 null;
7069 Else
7070 l_asset_fin_rec_adj.salvage_value := l_salvage_delta;
7071 l_adjust_yn := 'Y';
7072 End If;
7073 End If;
7074
7075
7076 -- Mass rebook - Other than residual value change no other
7077 --updates are allowed on the CORP Book
7078 If okx_ast_rec.book_class = 'CORPORATE' then
7079 Null;
7080 Else
7081 If trunc(nvl(adj_txl_rec.in_service_date,okx_ast_rec.in_service_date)) <> trunc(okx_ast_rec.in_service_date) Then
7082 l_asset_fin_rec_adj.date_placed_in_service := nvl(adj_txl_rec.in_service_date,okx_ast_rec.in_service_date);
7083 l_adjust_yn := 'Y';
7084 End If;
7085 --dbms_output.put_line('txl life :'|| to_char(adj_txl_rec.life_in_months));
7086 --dbms_output.put_line('okx life :'|| to_char(okx_ast_rec.life_in_months));
7087 --Bug# 3621663
7088 If nvl(adj_txl_rec.life_in_months,okx_ast_rec.life_in_months) <> okx_ast_rec.life_in_months
7089 Then
7090 l_asset_fin_rec_adj.life_in_months := nvl(adj_txl_rec.life_in_months,okx_ast_rec.life_in_months);
7091 l_asset_fin_rec_adj.deprn_method_code := nvl(adj_txl_rec.deprn_method,okx_ast_rec.deprn_method_code);
7092 l_asset_fin_rec_adj.basic_rate := Null;
7093 l_asset_fin_rec_adj.adjusted_rate := Null;
7094 l_adjust_yn := 'Y';
7095 End If;
7096
7097 --category updates not supported by API
7098 --If adj_txl_rec.depreciation_id <> okx_ast_rec.depreciation_category Then
7099 If nvl(adj_txl_rec.deprn_method,okx_ast_rec.deprn_method_code) <> okx_ast_rec.deprn_method_code Then
7100 l_asset_fin_rec_adj.deprn_method_code := nvl(adj_txl_rec.deprn_method,okx_ast_rec.deprn_method_code);
7101 If adj_txl_rec.life_in_months is not null then
7102 l_asset_fin_rec_adj.life_in_months := nvl(adj_txl_rec.life_in_months,okx_ast_rec.life_in_months);
7103 l_asset_fin_rec_adj.basic_rate := null;
7104 l_asset_fin_rec_adj.adjusted_rate := null;
7105 Elsif adj_txl_rec.life_in_months is null then
7106 If adj_txl_rec.deprn_rate is not null then
7107 l_asset_fin_rec_adj.basic_rate := nvl(adj_txl_rec.deprn_rate,okx_ast_rec.basic_rate);
7108 l_asset_fin_rec_adj.adjusted_rate := nvl(adj_txl_rec.deprn_rate,okx_ast_rec.adjusted_rate);
7109 End If;
7110 End If;
7111 l_adjust_yn := 'Y';
7112 End If;
7113
7114 If nvl(adj_txl_rec.deprn_rate,okx_ast_rec.adjusted_rate) <> okx_ast_rec.adjusted_rate Then
7115 If adj_txl_rec.life_in_months is NULL then
7116 l_asset_fin_rec_adj.deprn_method_code := nvl(adj_txl_rec.deprn_method,okx_ast_rec.deprn_method_code);
7117 l_asset_fin_rec_adj.basic_rate := nvl(adj_txl_rec.deprn_rate,okx_ast_rec.basic_rate);
7118 l_asset_fin_rec_adj.adjusted_rate := nvl(adj_txl_rec.deprn_rate,okx_ast_rec.adjusted_rate);
7119 l_asset_fin_rec_adj.life_in_months := NULL;
7120 l_adjust_yn := 'Y';
7121 End If;
7122 End If;
7123 --Bug# 3621663 (BP of Bug 3548044)
7124
7125 End If; --change deprn parameters only for Tax Books
7126
7127 If nvl(l_adjust_yn,'N') = 'Y' AND
7128 l_deal_type not in (G_LOAN_BK_CLASS,G_REVOLVING_LOAN_BK_CLASS) then
7129 --call the adjustment api to do adjustment
7130 --dbms_output.put_line('Cost :'||to_char(l_asset_fin_rec_adj.cost));
7131 --dbms_output.put_line('Sal Val :'||to_char(l_asset_fin_rec_adj.salvage_value));
7132 --dbms_output.put_line('DPIS :'||to_char(l_asset_fin_rec_adj.date_placed_in_service,'dd-mon-yyyy'));
7133 --dbms_output.put_line('life :'||to_char(l_asset_fin_rec_adj.life_in_months));
7134 --dbms_output.put_line('DPRN Method :'||l_asset_fin_rec_adj.deprn_method_code);
7135 --dbms_output.put_line('Rate B :'||to_char(l_asset_fin_rec_adj.basic_rate));
7136 --dbms_output.put_line('Rate A :'||to_char(l_asset_fin_rec_adj.adjusted_rate));
7137
7138 --bug # 2942543 :
7139 --check if salvage value is becoming more than asset cost
7140 --BUG# 3548044: check for all the books (not only corporate book)
7141 --If okx_ast_rec.book_class = 'CORPORATE' then --salvage value updates only for CORP
7142 l_new_salvage_value := okx_ast_rec.salvage_value + l_salvage_delta;
7143 l_new_cost := okx_ast_rec.cost + l_cost_delta;
7144 If (l_new_cost < l_new_salvage_value) Then
7145 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
7146 p_msg_name => G_SALVAGE_VALUE
7147 );
7148 RAISE OKL_API.G_EXCEPTION_ERROR;
7149 End If;
7150 --End If; --Bug# 3548044
7151
7152 -- Bug# 3783518
7153 -- Revision date should be in the current open period or in a
7154 -- prior period in FA
7155 -- Revision date should be equal to Contract Start Date in order
7156 -- to make an asset cost change
7157 validate_rebook_date
7158 (p_api_version => p_api_version,
7159 p_init_msg_list => p_init_msg_list,
7160 x_return_status => x_return_status,
7161 x_msg_count => x_msg_count,
7162 x_msg_data => x_msg_data,
7163 p_book_type_code => okx_ast_rec.book_type_code,
7164 p_rebook_date => l_mass_rebook_date,
7165 p_cost_adjustment => l_asset_fin_rec_adj.cost,
7166 p_contract_start_date => l_start_date);
7167
7168 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
7169 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7170 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
7171 RAISE OKL_API.G_EXCEPTION_ERROR;
7172 END IF;
7173
7174 --Bug# 6373605
7175 l_asset_fin_rec_adj.contract_id := p_rbk_chr_id;
7176 --Bug# 6373605 end
7177 FIXED_ASSET_ADJUST
7178 (p_api_version => p_api_version,
7179 p_init_msg_list => p_init_msg_list,
7180 x_return_status => x_return_status,
7181 x_msg_count => x_msg_count,
7182 x_msg_data => x_msg_data,
7183 p_chr_id => p_rbk_chr_id,
7184 p_asset_id => okx_ast_rec.asset_id,
7185 p_book_type_code => okx_ast_rec.book_type_code,
7186 p_asset_fin_rec_adj => l_asset_fin_rec_adj,
7187 -- Bug Fix# 2925461
7188 p_adj_date => l_mass_rebook_date,
7189 --Bug# 3156924
7190 p_trans_number => l_trans_number,
7191 p_calling_interface => l_calling_interface,
7192 --Bug# 6373605--SLA populate source
7193 p_sla_source_header_id => adj_txl_rec.sla_source_header_id,
7194 p_sla_source_header_table => 'OKL_TRX_ASSETS',
7195 p_sla_source_try_id => adj_txl_rec.sla_source_try_id,
7196 p_sla_source_line_id => adj_txl_rec.sla_source_line_id,
7197 p_sla_source_line_table => adj_txl_rec.sla_source_line_table,
7198 p_sla_source_chr_id => p_rbk_chr_id,
7199 p_sla_source_kle_id => adj_txl_rec.sla_source_kle_id,
7200 --Bug# 6373605--SLA populate sources
7201 --Bug# 4028371
7202 x_fa_trx_date => l_fa_adj_date,
7203 --Bug# 3156924
7204 x_asset_fin_rec_new => l_asset_fin_rec_new);
7205
7206 --dbms_output.put_line('After fixed asset adjust for rebook :'||x_return_status);
7207 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
7208 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7209 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
7210 RAISE OKL_API.G_EXCEPTION_ERROR;
7211 END IF;
7212 --Bug# 4028371
7213 If adj_txl_rec.tal_id is not null Then
7214 --update the fa trx date on transaction line
7215 l_talv_date_rec.id := adj_txl_rec.tal_id;
7216 l_talv_date_rec.fa_trx_date := l_fa_adj_date;
7217
7218 okl_tal_pvt.update_row
7219 (p_api_version => p_api_version,
7220 p_init_msg_list => p_init_msg_list,
7221 x_return_status => x_return_status,
7222 x_msg_count => x_msg_count,
7223 x_msg_data => x_msg_data,
7224 p_talv_rec => l_talv_date_rec,
7225 x_talv_rec => lx_talv_date_rec);
7226 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
7227 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7228 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
7229 RAISE OKL_API.G_EXCEPTION_ERROR;
7230 END IF;
7231 End If;
7232 --End Bug# 4028371
7233 End If; --l_adjust_yn = 'Y'
7234
7235
7236
7237 ---------------------------------------------------------------
7238 --Bug# 3548044 : MultiGaap Book to follow its own changes
7239 --will not mimic corporate book.mass rebook does not support
7240 --changes on multi-gaap and local corporate book
7241 ---------------------------------------------------------------
7242 --start of comments
7243 /*-------------------------------------------------------------
7244 If (( okx_ast_rec.book_class = 'CORPORATE') AND
7245 (nvl(l_adjust_yn, 'N') = 'Y') AND
7246 (l_deal_type <> G_REVOLVING_LOAN_BK_CLASS) AND
7247 (nvl(l_Multi_GAAP_YN, 'N') = 'Y' )
7248 ) then
7249
7250
7251 --bug # 2942543 :
7252 --check if salvage value is becoming more than asset cost
7253 l_new_salvage_value := okx_ast_rec.salvage_value + l_salvage_delta;
7254 l_new_cost := okx_ast_rec.cost + l_cost_delta;
7255 If (l_new_cost < l_new_salvage_value) Then
7256 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
7257 p_msg_name => G_SALVAGE_VALUE
7258 );
7259 RAISE OKL_API.G_EXCEPTION_ERROR;
7260 End If;
7261
7262 FIXED_ASSET_ADJUST
7263 (p_api_version => p_api_version,
7264 p_init_msg_list => p_init_msg_list,
7265 x_return_status => x_return_status,
7266 x_msg_count => x_msg_count,
7267 x_msg_data => x_msg_data,
7268 p_chr_id => p_rbk_chr_id,
7269 p_asset_id => okx_ast_rec.asset_id,
7270 p_book_type_code => l_rep_pdt_book,
7271 p_asset_fin_rec_adj => l_asset_fin_rec_adj,
7272 --Bug Fix# 2925461
7273 p_adj_date => l_mass_rebook_date,
7274 --Bug# 3156924
7275 p_trans_number => l_trans_number,
7276 p_calling_interface => l_calling_interface,
7277 --Bug# 4028371
7278 x_fa_trx_date => l_fa_adj_date,
7279 --Bug# 3156924
7280 x_asset_fin_rec_new => l_asset_fin_rec_new);
7281
7282
7283 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
7284 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7285 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
7286 RAISE OKL_API.G_EXCEPTION_ERROR;
7287 END IF;
7288
7289 End If; --l_corp_bk_changed_yn = 'Y'
7290 --end of comments
7291 ------------------------------------------------------------------*/
7292 --Bug# 3548044
7293
7294
7295 End If; --chk_cle effective
7296 End Loop;
7297 Close okx_ast_csr;
7298 End If; -- tax book is not reporting book
7299
7300 --Bug# 3548044 : set the status of transaction to processed
7301 If adj_txl_rec.tas_id is not NULL then
7302
7303 update_trx_status(p_api_version => p_api_version,
7304 p_init_msg_list => p_init_msg_list,
7305 x_return_status => x_return_status,
7306 x_msg_count => x_msg_count,
7307 x_msg_data => x_msg_data,
7308 p_tas_id => adj_txl_rec.tas_id,
7309 p_tsu_code => G_TSU_CODE_PROCESSED);
7310
7311 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
7312 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7313 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
7314 RAISE OKL_API.G_EXCEPTION_ERROR;
7315 END IF;
7316 End If;
7317 --End Bug# 3548044
7318
7319 End If; --adj_txl_rec found
7320 End Loop;
7321 Close adj_txl_csr;
7322 End If; --rbr code csr
7323 CLOSE rbr_code_csr;
7324 OKL_API.END_ACTIVITY (x_msg_count,x_msg_data );
7325 EXCEPTION
7326 WHEN OKL_API.G_EXCEPTION_ERROR THEN
7327 If ( l_hdr_csr%ISOPEN ) Then
7328 CLOSE l_hdr_csr;
7329 End If;
7330
7331 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
7332 l_api_name,
7333 G_PKG_NAME,
7334 'OKL_API.G_RET_STS_ERROR',
7335 x_msg_count,
7336 x_msg_data,
7337 '_PVT');
7338 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
7339 If ( l_hdr_csr%ISOPEN ) Then
7340 CLOSE l_hdr_csr;
7341 End If;
7342
7343 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
7344 l_api_name,
7345 G_PKG_NAME,
7346 'OKL_API.G_RET_STS_UNEXP_ERROR',
7347 x_msg_count,
7348 x_msg_data,
7349 '_PVT');
7350 WHEN OTHERS THEN
7351 If ( l_hdr_csr%ISOPEN ) Then
7352 CLOSE l_hdr_csr;
7353 End If;
7354
7355 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
7356 l_api_name,
7357 G_PKG_NAME,
7358 'OTHERS',
7359 x_msg_count,
7360 x_msg_data,
7361 '_PVT');
7362 END MASS_REBOOK_ASSET;
7363 --------------------------------------------------------------------------------
7364 --Start of Comments
7365 --Procedure Name : RELEASE_ASSET (Activate code branch for release)
7366 --Description : Will be called from activate asset and make re-lease adjustments
7367 -- in FA
7368 --History :
7369 -- 06-May-2002 ashish.singh Created
7370 -- Notes :
7371 -- IN Parameters -
7372 -- p_rel_chr_id - contract id of released contract
7373 --
7374 --End of Comments
7375 --------------------------------------------------------------------------------
7376 PROCEDURE RELEASE_ASSET (p_api_version IN NUMBER,
7377 p_init_msg_list IN VARCHAR2,
7378 x_return_status OUT NOCOPY VARCHAR2,
7379 x_msg_count OUT NOCOPY NUMBER,
7380 x_msg_data OUT NOCOPY VARCHAR2,
7381 p_rel_chr_id IN NUMBER
7382 ) IS
7383
7384 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
7385 l_api_name CONSTANT varchar2(30) := 'RELEASE_ASSET';
7386 l_api_version CONSTANT NUMBER := 1.0;
7387 l_trx_type Varchar2(30) := G_TRX_LINE_TYPE_RELEASE;
7388
7389 --Cursor to get the k header infor
7390 --do you have records in trx contracts for re-lease - iguess no
7391 CURSOR k_hdr_csr (p_rel_chr_id IN NUMBER) IS
7392 SELECT khr.deal_type,
7393 chr.id,
7394 chr.sts_code,
7395 rul.rule_information1,
7396 chr.orig_system_id1,
7397 khr.pdt_id,
7398 chr.start_date,
7399 --Bug# 4631549
7400 chr.orig_system_source_code
7401 FROM OKC_RULES_B rul,
7402 OKL_K_HEADERS khr,
7403 OKC_K_HEADERS_B chr
7404 WHERE rul.dnz_chr_id = chr.id
7405 AND rul.rule_information_category = 'LATOWN'
7406 AND rul.dnz_chr_id = khr.id
7407 AND khr.id = chr.id
7408 AND chr.id = p_rel_chr_id
7409 --Bug#2522439
7410 --AND chr.orig_system_source_code = 'OKL_RELEASE';
7411 AND exists (SELECT '1'
7412 FROM OKC_RULES_B rul_rel_Ast
7413 WHERE rul_rel_ast.dnz_chr_id = chr.id
7414 AND rul_rel_ast.rule_information_category = 'LARLES'
7415 AND nvl(rule_information1,'N') = 'Y');
7416 --Bug#2522439
7417
7418 l_deal_type OKL_K_HEADERS.deal_type%TYPE;
7419 l_rel_chr_id OKC_K_HEADERS_B.ID%TYPE;
7420 l_sts_code OKC_K_HEADERS_B.STS_CODE%TYPE;
7421 l_tax_owner OKC_RULES_B.RULE_INFORMATION1%TYPE;
7422 l_orig_chr_id OKC_K_HEADERS_B.ID%TYPE;
7423 --Bug# : 11.5.9 enhancement Multi GAAP
7424 l_pdt_id OKL_K_HEADERS.pdt_id%TYPE;
7425 l_start_date Date;
7426 l_rep_pdt_id Number;
7427 l_rep_deal_type Varchar2(150);
7428 l_Multi_GAAP_YN Varchar2(1) := 'N';
7429 l_rep_pdt_book OKX_AST_BKS_V.Book_Type_Code%Type;
7430 --Bug# 4631549
7431 l_orig_system_source_code okc_k_headers_b.orig_system_source_code%TYPE;
7432
7433 ---------------- ---------------------------------------------------------------*/
7434
7435 --cursor to get the modified transaction values against the release contract
7436 CURSOR adj_txl_csr (p_rel_chr_id IN NUMBER ) IS
7437 SELECT txl.in_service_date in_service_date,
7438 txl.life_in_months life_in_months,
7439 txl.depreciation_cost depreciation_cost,
7440 txl.depreciation_id asset_category_id,
7441 txl.deprn_method deprn_method,
7442 txl.deprn_rate deprn_rate,
7443 txl.salvage_value salvage_value,
7444 txl.corporate_book book_type_code,
7445 txl.asset_number asset_number,
7446 txl.kle_id kle_id,
7447 --Bug# 3156924
7448 trx.trans_number,
7449 --Bug# 3533936
7450 txl.fa_location_id fa_location_id,
7451 trx.id tas_id,
7452 txl.salvage_value corp_salvage_value,
7453 --Bug# 3631094
7454 txl.percent_salvage_value corp_percent_sv,
7455 txl.corporate_book corp_book,
7456 fab.book_class book_class,
7457 --Bug# 4028371
7458 txl.id tal_id,
7459 --Bug# 3950089
7460 txl.percent_salvage_value pct_salvage_value,
7461 txl.percent_salvage_value corp_pct_salvage_value,
7462 --Bug# 6373605 start
7463 trx.id sla_source_header_id,
7464 txl.id sla_source_line_id,
7465 'OKL_TXL_ASSETS_B' sla_source_line_table,
7466 trx.try_id sla_source_try_id,
7467 cle.cle_id sla_source_kle_id
7468 --Bug# 6373605 end
7469 FROM OKL_TRX_TYPES_TL ttyp,
7470 OKL_TRX_ASSETS trx,
7471 OKL_TXL_ASSETS_B txl,
7472 OKC_K_LINES_B cle,
7473 OKC_LINE_STYLES_B lse,
7474 -- Bug# 3631094
7475 FA_BOOK_CONTROLS fab
7476 WHERE txl.kle_id = cle.id
7477 AND cle.dnz_chr_id = p_rel_chr_id
7478 AND cle.lse_id = lse.id
7479 --effectivity
7480 --And nvl(cle.start_date,p_effective_date) <= p_effective_date
7481 --And nvl(cle.end_date,p_effective_date+1) > p_effective_date
7482 AND not exists (select '1'
7483 from OKC_STATUSES_B sts
7484 Where sts.code = cle.sts_code
7485 --Bug# 2522268
7486 --And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELED')
7487 And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELLED')
7488 )
7489 AND lse.lty_code = G_FA_LINE_LTY_CODE
7490 --Bug# 3156924:
7491 /*----------------------------------------------------
7492 --AND exists (select null
7493 --from OKL_TRX_ASSETS trx,
7494 --OKL_TRX_TYPES_TL ttyp
7495 --where trx.id = txl.tas_id
7496 --and trx.try_id = ttyp.id
7497 --and ttyp.name = 'Internal Asset Creation'
7498 --and ttyp.language = 'US'
7499 --and trx.tsu_code <> 'PROCESSED'
7500 --Bug#2522439
7501 ----and trx.tas_type = G_TRX_HDR_TYPE_RELEASE)
7502 --and trx.tas_type = G_TRX_HDR_TYPE_BOOK)
7503 -------------------------------------------------------*/
7504 AND trx.id = txl.tas_id
7505 and trx.try_id = ttyp.id
7506 and ttyp.name = 'Internal Asset Creation'
7507 and ttyp.language = 'US'
7508 and trx.tsu_code <> 'PROCESSED'
7509 --Bug#2522439
7510 --and trx.tas_type = G_TRX_HDR_TYPE_RELEASE)
7511 and trx.tas_type = G_TRX_HDR_TYPE_RELEASE
7512 AND txl.tal_type = G_TRX_LINE_TYPE_RELEASE
7513 --Bug# 3631094
7514 AND fab.book_type_code = txl.corporate_book
7515 UNION
7516 SELECT txl.in_service_date in_service_date,
7517 txd.life_in_months_tax life_in_months,
7518 txd.cost depreciation_cost,
7519 txl.depreciation_id asset_category_id,
7520 txd.deprn_method_tax deprn_method,
7521 txd.deprn_rate_tax deprn_rate,
7522 txd.salvage_value salvage_value,
7523 txd.tax_book book_type_code,
7524 txd.asset_number asset_number,
7525 txl.kle_id kle_id,
7526 --Bug# 3156924
7527 trx.trans_number,
7528 --Bug# 3533936
7529 null fa_location_id,
7530 null tas_id,
7531 txl.salvage_value corp_salvage_value,
7532 --Bug# 3631094
7533 txl.percent_salvage_value corp_percent_sv,
7534 txl.corporate_book corp_book,
7535 fab.book_class book_class,
7536 --Bug# 4028371
7537 null tal_id,
7538 --Bug# 3950089
7539 txl.percent_salvage_value pct_salvage_value,
7540 txl.percent_salvage_value corp_pct_salvage_value,
7541 --bug# 6373605 start
7542 trx.id sla_source_header_id,
7543 txd.id sla_source_line_id,
7544 'OKL_TXD_ASSETS_B' sla_source_line_table,
7545 trx.try_id sla_source_try_id,
7546 cle.cle_id sla_source_kle_id
7547 --Bug# 6373605 end
7548 FROM OKL_TRX_TYPES_TL ttyp,
7549 OKL_TRX_ASSETS trx,
7550 OKL_TXD_ASSETS_B txd,
7551 OKL_TXL_ASSETS_B txl,
7552 OKC_K_LINES_B cle,
7553 OKC_LINE_STYLES_B lse,
7554 -- Bug# 3631094
7555 FA_BOOK_CONTROLS fab
7556 WHERE txd.tal_id = txl.id
7557 AND txl.kle_id = cle.id
7558 AND cle.dnz_chr_id = p_rel_chr_id
7559 AND cle.lse_id = lse.id
7560 --effectivity
7561 --And nvl(cle.start_date,p_effective_date) <= p_effective_date
7562 --And nvl(cle.end_date,p_effective_date+1) > p_effective_date
7563 AND not exists (select '1'
7564 from OKC_STATUSES_B sts
7565 Where sts.code = cle.sts_code
7566 --Bug#2522268
7567 --And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELED')
7568 And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELLED')
7569 )
7570 AND lse.lty_code = G_FA_LINE_LTY_CODE
7571 --bug# 3156924
7572 /*-------------------------------------------------------------
7573 --AND exists (select null
7574 --from OKL_TRX_ASSETS trx,
7575 --OKL_TRX_TYPES_TL ttyp
7576 --where trx.id = txl.tas_id
7577 --and trx.try_id = ttyp.id
7578 --and ttyp.name = 'Release'
7579 --and ttyp.language = 'US'
7580 --and trx.tsu_code <> 'PROCESSED'
7581 --and trx.tas_type = G_TRX_HDR_TYPE_RELEASE)
7582 ---------------------------------------------------------------*/
7583 AND trx.id = txl.tas_id
7584 AND trx.try_id = ttyp.id
7585 and ttyp.name = 'Internal Asset Creation'
7586 and ttyp.language = 'US'
7587 and trx.tsu_code <> 'PROCESSED'
7588 and trx.tas_type = G_TRX_HDR_TYPE_RELEASE
7589 --bug# 3156924
7590 AND txl.tal_type = G_TRX_LINE_TYPE_RELEASE
7591 --Bug# 3631094
7592 AND fab.book_type_code = txd.tax_book
7593 ORDER BY asset_number, book_class ;
7594
7595 adj_txl_rec adj_txl_csr%ROWTYPE;
7596
7597 --cursor to get the actual values from FA for the contract
7598 CURSOR okx_ast_csr (p_asset_number IN VARCHAR2,
7599 p_book_type_code IN VARCHAR2) is
7600 SELECT okx.acquisition_date in_service_date,
7601 okx.life_in_months life_in_months,
7602 okx.cost cost,
7603 okx.depreciation_category depreciation_category,
7604 okx.deprn_method_code deprn_method_code,
7605 okx.adjusted_rate adjusted_rate,
7606 okx.basic_rate basic_rate,
7607 okx.salvage_value salvage_value,
7608 --Bug# 3631094
7609 okx.percent_salvage_value percent_salvage_value,
7610 okx.book_type_code book_type_code,
7611 okx.book_class book_class,
7612 okx.asset_number asset_number,
7613 okx.asset_id asset_id
7614 FROM okx_ast_bks_v okx
7615 WHERE okx.asset_number = p_asset_number
7616 AND okx.book_type_code = nvl(p_book_type_code,okx.book_type_code);
7617
7618 okx_ast_rec okx_ast_csr%ROWTYPE;
7619
7620 l_cost_delta Number;
7621 l_salvage_delta Number;
7622 l_asset_fin_rec_adj FA_API_TYPES.asset_fin_rec_type;
7623 l_asset_fin_rec_new FA_API_TYPES.asset_fin_rec_type;
7624 l_adjust_yn Varchar2(1);
7625 l_dummy_amount NUMBER;
7626
7627 --cursor to get tax owner rule
7628 Cursor town_rul_csr (pchrid number) is
7629 Select rule_information1 tax_owner,
7630 id
7631 From okc_rules_b rul
7632 where rul.dnz_chr_id = pchrid
7633 and rul.rule_information_category = 'LATOWN'
7634 and nvl(rul.STD_TEMPLATE_YN,'N') = 'N';
7635
7636 l_town_rul okc_rules_b.rule_information1%TYPE;
7637 l_town_rul_id okc_rules_b.id%TYPE;
7638
7639 --Bug# 2942543 :
7640 l_new_salvage_value number;
7641 l_new_cost number;
7642
7643 ---------------------------------------------------
7644 --Bug# 3143522 : 11.5.10 Subsidies
7645 ---------------------------------------------------
7646 cursor l_allast_csr (p_chr_id in number) is
7647 select cleb.id,
7648 --Bug# 3783518
7649 cleb.orig_system_id1
7650 from okc_k_lines_b cleb,
7651 okc_line_styles_b lseb,
7652 okc_statuses_b stsb
7653 where cleb.chr_id = p_chr_id
7654 and cleb.dnz_chr_id = p_chr_id
7655 and lseb.id = cleb.lse_id
7656 and lseb.lty_code = G_FIN_AST_LINE_LTY_CODE
7657 and stsb.code = cleb.sts_code
7658 and stsb.ste_code not in ('HOLD','EXPIRED','TERMINATED','CANCELLED');
7659
7660 l_asset_cle_id okc_k_lines_b.ID%TYPE;
7661
7662 l_subsidy_exists varchar2(1) default OKL_API.G_FALSE;
7663 l_total_discount number;
7664 l_cost_adjustment number;
7665
7666 --cursor to get asset id
7667 cursor l_asset_csr (p_asset_cle_id in number) is
7668 select fab.asset_id asset_id,
7669 ast_clet.name asset_number,
7670 fab.cost asset_cost,
7671 fab.book_type_code book_type_code,
7672 txl.in_service_date in_service_date,
7673 --bug# 3156924
7674 trx.trans_number,
7675 --Bug# 6373605 start
7676 trx.id sla_source_header_id,
7677 txl.id sla_source_line_id,
7678 trx.try_id sla_source_try_id,
7679 fa_cleb.cle_id sla_source_kle_id,
7680 fbc.book_class
7681 --Bug# 6373605 end
7682 from
7683 fa_books fab,
7684 --Bug# 6373605 start
7685 fa_book_controls fbc,
7686 --Bug# 6373605 end
7687 okc_k_items fa_cim,
7688 okl_trx_types_tl ttyp,
7689 okl_trx_assets trx,
7690 okl_txl_assets_b txl,
7691 okc_k_lines_b fa_cleb,
7692 okc_line_styles_b fa_lseb,
7693 okc_k_lines_tl ast_clet
7694 where
7695 fab.asset_id = to_number(fa_cim.object1_id1)
7696 and fab.transaction_header_id_out is NULL
7697 --Bug# 6373605 start
7698 and fab.book_type_code = fbc.book_type_code
7699 --bug# 6373605 end
7700 and fa_cim.object1_id2 = '#'
7701 and fa_cim.jtot_object1_code = 'OKX_ASSET'
7702 and fa_cim.dnz_chr_id = fa_cleb.dnz_chr_id
7703 and fa_cim.cle_id = fa_cleb.id
7704 and txl.kle_id = fa_cleb.id
7705 and txl.tal_type = G_TRX_LINE_TYPE_RELEASE
7706 and trx.id = txl.tas_id
7707 and trx.try_id = ttyp.id
7708 --Bug# 2981308
7709 and ttyp.name = 'Internal Asset Creation'
7710 --and ttyp.name = 'Release'
7711 and ttyp.language = 'US'
7712 and trx.tsu_code <> 'PROCESSED'
7713 --Bug# 2981308
7714 and trx.tas_type = G_TRX_HDR_TYPE_RELEASE
7715 --and trx.tas_type = G_TRX_HDR_TYPE_RELEASE
7716 and fa_cleb.cle_id = p_asset_cle_id
7717 and fa_lseb.id = fa_cleb.lse_id
7718 and fa_lseb.lty_code = G_FA_LINE_LTY_CODE
7719 and ast_clet.id = p_asset_cle_id
7720 and ast_clet.language = userenv('LANG');
7721
7722 l_asset_rec l_asset_csr%RowType;
7723
7724 --Bug# 6373605 start
7725 Cursor l_txd_from_book_type_csr (p_book_type_code in varchar2,
7726 p_tal_id in number) is
7727 select id sla_source_line_id,
7728 tax_book
7729 from okl_txd_Assets_b
7730 where tal_id = p_tal_id
7731 and tax_book = p_book_type_code;
7732
7733 l_txd_from_book_type_rec l_txd_from_book_type_csr%ROWTYPE;
7734
7735 l_sla_source_line_id number;
7736 l_sla_source_line_table OKL_EXT_FA_LINE_SOURCES_V.SOURCE_TABLE%TYPE;
7737 --Bug# 6373605 End
7738
7739 --Bug# 3156924
7740 l_release_date date;
7741 l_trans_number okl_trx_assets.trans_number%TYPE;
7742 l_calling_interface varchar2(30) := 'OKLRACAB:Release';
7743
7744 --BUG# 3548044
7745 l_release_allowed_on_mg_book varchar2(1);
7746
7747 ---------------------------------------------------
7748 --Bug# 3631094 : start
7749 ---------------------------------------------------
7750 --Cursor to set transaction status to Processed
7751 CURSOR tas_csr(p_chr_id in number) IS
7752 SELECT trx.id
7753 FROM OKL_TRX_ASSETS trx,
7754 OKL_TXL_ASSETS_B txl,
7755 OKC_K_LINES_B cle,
7756 OKC_LINE_STYLES_B lse
7757 WHERE txl.kle_id = cle.id
7758 AND cle.dnz_chr_id = p_chr_id
7759 AND cle.lse_id = lse.id
7760 AND not exists (select '1'
7761 from OKC_STATUSES_B sts
7762 Where sts.code = cle.sts_code
7763 And sts.ste_code in ('HOLD','EXPIRED','TERMINATED','CANCELLED')
7764 )
7765 AND lse.lty_code = G_FA_LINE_LTY_CODE
7766 AND trx.id = txl.tas_id
7767 and trx.tsu_code <> 'PROCESSED'
7768 and trx.tas_type = G_TRX_HDR_TYPE_RELEASE
7769 AND txl.tal_type = G_TRX_LINE_TYPE_RELEASE;
7770
7771 --Cursor to check if asset_id already exists in tax_book
7772 CURSOR chk_ast_bk_csr(p_book_type_code IN Varchar2,
7773 p_asset_id IN Number) is
7774 SELECT '!'
7775 FROM OKX_AST_BKS_V
7776 WHERE asset_id = p_asset_id
7777 AND book_type_code = p_book_type_code
7778 AND status = 'A';
7779
7780 l_ast_bk_exists Varchar2(1) default '?';
7781
7782 --Cursor to chk book validity for an asset category
7783 CURSOR chk_cat_bk_csr(p_book_type_code IN VARCHAR2,
7784 p_category_id IN NUMBER) is
7785 SELECT '!'
7786 FROM OKX_AST_CAT_BKS_V
7787 WHERE CATEGORY_ID = p_category_id
7788 AND BOOK_TYPE_CODE = p_book_type_code
7789 AND STATUS = 'A';
7790
7791 l_cat_bk_exists Varchar2(1) default '?';
7792
7793 --Cursor chk if corp book is the mass copy source book
7794 CURSOR chk_mass_cpy_book(p_corp_book IN Varchar2,
7795 p_tax_book IN Varchar2) is
7796 SELECT '!'
7797 FROM OKX_ASST_BK_CONTROLS_V
7798 WHERE book_type_code = p_tax_book
7799 AND book_class = 'TAX'
7800 AND mass_copy_source_book = p_corp_book
7801 AND allow_mass_copy = 'YES'
7802 AND copy_additions_flag = 'YES';
7803
7804 l_mass_cpy_book Varchar2(1) default '?';
7805
7806 --Cursor to fetch book records for an asset
7807 Cursor ast_bks_csr(p_asset_id IN NUMBER,
7808 p_book_class IN VARCHAR2) is
7809 select book_type_code,
7810 cost,
7811 salvage_value,
7812 percent_salvage_value
7813 from okx_ast_bks_v
7814 where asset_id = p_Asset_id
7815 and book_class = p_book_class;
7816
7817 ast_corp_book_rec okx_ast_csr%ROWTYPE;
7818 ast_rep_book_rec okx_ast_csr%ROWTYPE;
7819 l_bk_dfs_rec bk_dfs_csr%ROWTYPE;
7820 l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
7821 l_talv_rec talv_rec_type;
7822 l_no_data_found BOOLEAN;
7823 l_asset_fin_rec FA_API_TYPES.asset_fin_rec_type;
7824 l_adjust_cost NUMBER;
7825 l_adj_salvage_value NUMBER;
7826 l_adj_percent_sv NUMBER;
7827
7828 l_current_asset_number OKX_ASSETS_V.Name%Type;
7829 l_asset_corp_book_cost NUMBER;
7830 ---------------------------------------------------
7831 --Bug# 3631094 : end
7832 ---------------------------------------------------
7833
7834 --Bug# 3783518
7835 CURSOR orig_pdt_csr(p_cle_id IN NUMBER) is
7836 SELECT pdt.reporting_pdt_id
7837 FROM okc_k_lines_b cle,
7838 okl_k_headers khr,
7839 okl_products pdt
7840 WHERE cle.id = p_cle_id
7841 AND khr.id = cle.dnz_chr_id
7842 AND pdt.id = khr.pdt_id;
7843
7844 l_subsidy_asset_fin_rec_adj FA_API_TYPES.asset_fin_rec_type;
7845 l_orig_system_id1 NUMBER;
7846 l_orig_reporting_pdt_id NUMBER;
7847
7848
7849 ------
7850 --Bug# 4028371
7851 -----
7852 l_fa_add_date_mg date;
7853 l_fa_adj_date_mg date;
7854 l_fa_adj_date date;
7855 l_fa_tsfr_date date;
7856 l_talv_date_rec okl_tal_pvt.talv_rec_type;
7857 lx_talv_date_rec okl_tal_pvt.talv_rec_type;
7858 ------
7859 --Bug# 4028371
7860 ------
7861 l_hdr_rec l_hdr_csr%ROWTYPE;
7862
7863 -- Bug# 4627009
7864 l_add_cap_fee varchar2(1) ;
7865 l_cap_fee_delta number;
7866 l_cap_fee_delta_converted_amt number;
7867
7868 Cursor cap_fee_csr(fa_cle_id in number
7869 ,rel_chr_id in number) IS
7870 Select nvl(sum(cov_ast_kle.capital_amount),0) capitalized_fee
7871 From
7872 OKL_K_LINES fee_kle,
7873 OKC_K_LINES_B fee_cle,
7874 OKC_STATUSES_B fee_sts,
7875 OKL_K_LINES cov_ast_kle,
7876 OKC_K_LINES_B cov_ast_cle,
7877 OKC_LINE_STYLES_B cov_ast_lse,
7878 OKC_STATUSES_B cov_ast_sts,
7879 OKC_K_ITEMS cov_ast_cim,
7880 OKC_K_LINES_B fa_cle
7881 Where fee_kle.id = fee_cle.id
7882 and fee_kle.fee_type = 'CAPITALIZED'
7883 and fee_cle.id = cov_ast_cle.cle_id
7884 and fee_cle.dnz_chr_id = cov_ast_cle.dnz_chr_id
7885 and fee_cle.sts_code = fee_sts.code
7886 and fee_sts.ste_code not in ('HOLD', 'EXPIRED', 'TERMINATED', 'CANCELLED')
7887 and cov_ast_kle.id = cov_ast_cle.id
7888 and cov_ast_cle.id = cov_ast_cim.cle_id
7889 and cov_ast_cle.lse_id = cov_ast_lse.id
7890 and cov_ast_lse.lty_code = 'LINK_FEE_ASSET'
7891 and cov_ast_cle.sts_code = cov_ast_sts.code
7892 and cov_ast_sts.ste_code not in ('HOLD', 'EXPIRED', 'TERMINATED', 'CANCELLED')
7893 and cov_ast_cle.dnz_chr_id = cov_ast_cim.dnz_chr_id
7894 and cov_ast_cim.object1_id1 = to_char(fa_cle.cle_id)
7895 and cov_ast_cim.object1_id2 = '#'
7896 and cov_ast_cim.jtot_object1_code = 'OKX_COVASST'
7897 and fa_cle.id = fa_cle_id
7898 and fee_cle.dnz_chr_id = rel_chr_id ;
7899
7900 --Bug# 4627009 end
7901
7902 --5261704
7903 l_depreciate_flag VARCHAR2(3);
7904
7905 --Bug# 6373605 start
7906 l_dummy_asset_fin_rec_adj FA_API_TYPES.asset_fin_rec_type;
7907 --Bug# 6373605 end
7908
7909 BEGIN
7910
7911 x_return_status := OKL_API.G_RET_STS_SUCCESS;
7912 -- Call start_activity to create savepoint, check compatibility
7913 -- and initialize message list
7914 x_return_status := OKL_API.START_ACTIVITY (
7915 l_api_name
7916 ,p_init_msg_list
7917 ,'_PVT'
7918 ,x_return_status);
7919 -- Check if activity started successfully
7920 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
7921 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7922 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
7923 RAISE OKL_API.G_EXCEPTION_ERROR;
7924 END IF;
7925
7926 --get rebook reason code
7927 --dbms_output.put_line('before rebook reason code cursor :');
7928 OPEN k_hdr_csr (p_rel_chr_id => p_rel_chr_id);
7929 Fetch k_hdr_csr into
7930 l_deal_type,
7931 l_rel_chr_id,
7932 l_sts_code,
7933 l_tax_owner,
7934 l_orig_chr_id,
7935 l_pdt_id,
7936 l_start_date,
7937 --Bug# 4631549
7938 l_orig_system_source_code;
7939
7940
7941 If k_hdr_csr%NOTFOUND Then
7942 --rebook transacton not found
7943 --does this call for raising error
7944 Null;
7945 Else
7946
7947 --Bug# :11.5.9 : Multi-GAAP Begin
7948 Get_Pdt_Params (p_api_version => p_api_version,
7949 p_init_msg_list => p_init_msg_list,
7950 x_return_status => x_return_status,
7951 x_msg_count => x_msg_count,
7952 x_msg_data => x_msg_data,
7953 p_pdt_id => l_pdt_id,
7954 p_pdt_date => l_start_date,
7955 x_rep_pdt_id => l_rep_pdt_id,
7956 x_tax_owner => l_tax_owner,
7957 x_rep_deal_type => l_rep_deal_type);
7958
7959 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
7960 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7961 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
7962 RAISE OKL_API.G_EXCEPTION_ERROR;
7963 END IF;
7964
7965 If l_tax_owner is null then
7966 Open town_rul_csr(pchrid => p_rel_chr_id);
7967 Fetch town_rul_csr into l_town_rul,
7968 l_town_rul_id;
7969 If town_rul_csr%NOTFOUND Then
7970 OKC_API.set_message(
7971 p_app_name => G_APP_NAME,
7972 p_msg_name => G_REQUIRED_VALUE,
7973 p_token1 => G_COL_NAME_TOKEN,
7974 p_token1_value => 'Tax Owner');
7975 x_return_status := OKC_API.G_RET_STS_ERROR;
7976 RAISE OKL_API.G_EXCEPTION_ERROR;
7977 Else
7978 l_tax_owner := rtrim(ltrim(l_town_rul,' '),' ');
7979 End If;
7980 Close town_rul_csr;
7981 End If;
7982
7983 OPEN l_hdr_csr( p_rel_chr_id );
7984 FETCH l_hdr_csr INTO l_hdr_rec;
7985 CLOSE l_hdr_csr;
7986
7987 G_CHR_CURRENCY_CODE := l_hdr_rec.currency_code;
7988 G_FUNC_CURRENCY_CODE := okl_accounting_util.get_func_curr_code;
7989 G_CHR_AUTHORING_ORG_ID := l_hdr_rec.authoring_org_id;
7990 G_CHR_START_DATE := l_hdr_rec.start_date;
7991 G_CHR_REPORT_PDT_ID := l_hdr_rec.report_pdt_id;
7992
7993
7994 -- Bug# 3631094
7995 --BUG# 354804
7996 -- l_release_allowed_on_mg_book := 'Y';
7997 l_Multi_GAAP_YN := 'N';
7998 --checks wheter Multi-GAAP processing needs tobe done
7999 If l_rep_pdt_id is not NULL Then
8000
8001 --Bug 7708944. SMEREDDY 01/15/2009.
8002 -- Implemented MG changes based on PM recommendation.
8003
8004 l_Multi_GAAP_YN := 'Y';
8005 /*
8006 If l_deal_type = 'LEASEOP' and
8007 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
8008 nvl(l_tax_owner,'X') = 'LESSOR' Then
8009 l_Multi_GAAP_YN := 'Y';
8010 End If;
8011
8012 If l_deal_type in ('LEASEDF','LEASEST') and
8013 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
8014 nvl(l_tax_owner,'X') = 'LESSOR' Then
8015 l_Multi_GAAP_YN := 'Y';
8016 End If;
8017
8018 If l_deal_type in ('LEASEDF','LEASEST') and
8019 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
8020 nvl(l_tax_owner,'X') = 'LESSEE' Then
8021 l_Multi_GAAP_YN := 'Y';
8022 End If;
8023
8024 If l_deal_type = 'LOAN' and
8025 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
8026 nvl(l_tax_owner,'X') = 'LESSEE' Then
8027 l_Multi_GAAP_YN := 'Y';
8028 End If;
8029
8030 --Bug# 3548044
8031 --Bug# 3621663
8032 If l_deal_type = 'LEASEOP' and
8033 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST')
8034 and nvl(l_tax_owner,'X') = 'LESSOR' then
8035 l_Multi_GAAP_YN := 'Y';
8036 -- Bug# 3631094
8037 --l_release_allowed_on_mg_book := 'N';
8038 End If;
8039 If l_deal_type in ('LEASEDF','LEASEST') and
8040 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
8041 nvl(l_tax_owner,'X') = 'LESSOR' then
8042 l_Multi_GAAP_YN := 'Y';
8043 -- Bug# 3631094
8044 --l_release_allowed_on_mg_book := 'N';
8045 End If;
8046 If l_deal_type in ('LEASEDF','LEASEST') and
8047 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
8048 nvl(l_tax_owner,'X') = 'LESSEE' then
8049 l_Multi_GAAP_YN := 'Y';
8050 -- Bug# 3631094
8051 --l_release_allowed_on_mg_book := 'N';
8052 End If;
8053 --Bug# 3548044
8054 */
8055 End If;
8056
8057 -- Bug# 3631094
8058 /*If l_Multi_GAAP_YN = 'Y' Then
8059 --get reporting product book type
8060 l_rep_pdt_book := fnd_profile.value('OKL_REPORTING_PDT_ASSET_BOOK');
8061 End If;*/
8062
8063 --get reporting product book type
8064 l_rep_pdt_book := OKL_SYSTEM_PARAMS_ALL_PUB.get_system_param_value(OKL_SYSTEM_PARAMS_ALL_PUB.G_RPT_PROD_BOOK_TYPE_CODE);
8065
8066
8067 --dbms_output.put_line('deal type :'||l_deal_type);
8068 --dbms_output.put_line('rbr code :'||l_rbr_code);
8069 --get the adjusted parameters for all the lines from line transactions
8070 --dbms_output.put_line('deal type :'||l_deal_type);
8071 --get the adjusted parameters for all the lines from line transactions
8072
8073 --Bug# 3631094
8074 l_current_asset_number := null;
8075 l_asset_corp_book_cost := null;
8076
8077 Open adj_txl_csr(p_rel_chr_id => p_rel_chr_id);
8078 Loop
8079 Fetch adj_txl_csr into adj_txl_rec;
8080
8081 IF adj_txl_csr%NOTFOUND Then
8082
8083 Exit;-- exit from adj_txl_csr
8084
8085 ---------------------------------------------
8086 Else --adj_txl_csr found
8087 ---------------------------------------------
8088
8089 --Bug# 3631094
8090 IF (( l_current_asset_number is null ) OR
8091 ( l_current_asset_number is not null and
8092 l_current_asset_number <> adj_txl_rec.asset_number)) THEN
8093
8094 l_current_asset_number := adj_txl_rec.asset_number;
8095
8096 open okx_ast_csr(p_asset_number => adj_txl_rec.asset_number,
8097 p_book_type_code => adj_txl_rec.corp_book);
8098 fetch okx_ast_csr into ast_corp_book_rec;
8099 close okx_ast_csr;
8100
8101 l_asset_corp_book_cost := ast_corp_book_rec.cost;
8102
8103 END IF;
8104
8105 ---------------------------------------------------------------
8106 -- Bug# 3548044 : A part of this bug the multi-gaap book should
8107 -- not mimic corporate book . It should adjust based on entered
8108 -- parameters. DF/ST(local) vs DF/ST(reporting) MG books are created with cost
8109 -- and SV zero to be untouched till offlease amortization process
8110 ---------------------------------------------------------------
8111 -- Bug# 3631094
8112 /*If ( adj_txl_rec.book_type_code = nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR))
8113 and (l_release_allowed_on_mg_book = 'N') Then
8114 --Exit;
8115 Null; --do not do anything for reporting book
8116 Else*/
8117 --get actual parameters from FA to get the Delta
8118 Open okx_ast_csr (p_asset_number => adj_txl_rec.asset_number,
8119 p_book_type_code => adj_txl_rec.book_type_code);
8120
8121 Fetch okx_ast_csr into okx_ast_rec;
8122 If okx_ast_csr%NOTFOUND Then
8123
8124 -- Bug# 3631094: start
8125 Close okx_ast_csr;
8126
8127 -- add asset to reporting product book
8128 If l_Multi_GAAP_YN = 'Y' AND
8129 adj_txl_rec.book_type_code = l_rep_pdt_book Then
8130
8131 open okx_ast_csr(p_asset_number => adj_txl_rec.asset_number,
8132 p_book_type_code => adj_txl_rec.corp_book);
8133 fetch okx_ast_csr into ast_corp_book_rec;
8134 close okx_ast_csr;
8135
8136 --chk if asset category is valid for the tax book
8137 l_cat_bk_exists := '?';
8138 open chk_cat_bk_csr(p_book_type_code => adj_txl_rec.book_type_code,
8139 p_category_id => adj_txl_rec.asset_category_id);
8140 Fetch chk_cat_bk_csr into l_cat_bk_exists;
8141 Close chk_cat_bk_csr;
8142
8143 If l_cat_bk_exists = '?' Then
8144 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
8145 p_msg_name => G_FA_INVALID_BK_CAT,
8146 p_token1 => G_FA_BOOK,
8147 p_token1_value => adj_txl_rec.book_type_code,
8148 p_token2 => G_ASSET_CATEGORY,
8149 p_token2_value => to_char(adj_txl_rec.asset_category_id)
8150 );
8151 RAISE OKL_API.G_EXCEPTION_ERROR;
8152 Else
8153 --check if asset already exists in tax book
8154 l_ast_bk_exists := '?';
8155 Open chk_ast_bk_csr(p_book_type_code => adj_txl_rec.book_type_code,
8156 p_asset_id => ast_corp_book_rec.asset_id);
8157 Fetch chk_ast_bk_csr into l_ast_bk_exists;
8158 Close chk_ast_bk_csr;
8159
8160 If l_ast_bk_exists = '!' Then --asset already exists in tax book
8161 null; --do not have to add again
8162 Else
8163 --chk if corp book is the mass copy book for the tax book
8164 l_mass_cpy_book := '?';
8165 OPEN chk_mass_cpy_book(
8166 p_corp_book => adj_txl_rec.corp_book,
8167 p_tax_book => adj_txl_rec.book_type_code);
8168 Fetch chk_mass_cpy_book into l_mass_cpy_book;
8169 Close chk_mass_cpy_book;
8170
8171 If l_mass_cpy_book = '?' Then
8172 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
8173 p_msg_name => G_FA_TAX_CPY_NOT_ALLOWED,
8174 p_token1 => G_FA_BOOK,
8175 p_token1_value => adj_txl_rec.book_type_code
8176 );
8177 RAISE OKL_API.G_EXCEPTION_ERROR;
8178 Else
8179 --can masscopy
8180 --intialize talv record for tax book
8181
8182 l_talv_rec := get_talv_rec(adj_txl_rec.kle_id, l_trx_type, l_no_data_found);
8183 If l_no_data_found = TRUE Then
8184 --dbms_output.put_line('no asset creation transaction records ...!');
8185 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
8186 p_msg_name => G_FA_TRX_REC_NOT_FOUND,
8187 p_token1 => G_FA_LINE_ID,
8188 p_token1_value => to_char(adj_txl_rec.kle_id)
8189 );
8190 RAISE OKL_API.G_EXCEPTION_ERROR;
8191 End if;
8192
8193 l_talv_rec.corporate_book := adj_txl_rec.book_type_code;
8194 l_talv_rec.dnz_asset_id := ast_corp_book_rec.asset_id;
8195 l_talv_rec.depreciation_cost := l_asset_corp_book_cost;
8196 l_talv_rec.life_in_months := adj_txl_rec.life_in_months;
8197 l_talv_rec.deprn_method := adj_txl_rec.deprn_method;
8198 l_talv_rec.deprn_rate := adj_txl_rec.deprn_rate;
8199 l_talv_rec.salvage_value := adj_txl_rec.corp_salvage_value;
8200 l_talv_rec.percent_salvage_value := adj_txl_rec.corp_percent_sv;
8201
8202 l_release_date := l_start_date;
8203 l_trans_number := adj_txl_rec.trans_number;
8204
8205 --Bug# 5261704 : Set depreciate flag to 'NO' if cost will be adjusted to zero
8206 l_depreciate_flag := 'YES';
8207 IF (l_rep_deal_type in (G_DF_LEASE_BK_CLASS,G_ST_LEASE_BK_CLASS)) THEN
8208 l_depreciate_flag := 'NO';
8209 End If;
8210 --End Bug# 5261704
8211
8212 --call mass additions add for tax book
8213 FIXED_ASSET_ADD(p_api_version => p_api_version,
8214 p_init_msg_list => p_init_msg_list,
8215 x_return_status => x_return_status,
8216 x_msg_count => x_msg_count,
8217 x_msg_data => x_msg_data,
8218 p_talv_rec => l_talv_rec,
8219 p_trans_number => l_trans_number,
8220 p_calling_interface => l_calling_interface,
8221 --Bug# 5261704
8222 p_depreciate_flag => l_depreciate_flag,
8223 --Bug# 6373605--SLA populate source
8224 p_sla_source_header_id => adj_txl_rec.sla_source_header_id,
8225 p_sla_source_header_table => 'OKL_TRX_ASSETS',
8226 p_sla_source_try_id => adj_txl_rec.sla_source_try_id,
8227 p_sla_source_line_id => adj_txl_rec.sla_source_line_id,
8228 p_sla_source_line_table => adj_txl_rec.sla_source_line_table,
8229 p_sla_source_chr_id => p_rel_chr_id,
8230 p_sla_source_kle_id => adj_txl_rec.sla_source_kle_id,
8231 p_sla_asset_chr_id => p_rel_chr_id,
8232 --Bug# 6373605--SLA populate sources
8233 --Bug# 4028371
8234 x_fa_trx_date => l_fa_add_date_mg,
8235 x_asset_hdr_rec => l_asset_hdr_rec);
8236
8237 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
8238 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8239 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
8240 RAISE OKL_API.G_EXCEPTION_ERROR;
8241 END IF;
8242
8243 IF (l_rep_deal_type in (G_DF_LEASE_BK_CLASS,G_ST_LEASE_BK_CLASS)) THEN
8244
8245 open okx_ast_csr(p_asset_number => adj_txl_rec.asset_number,
8246 p_book_type_code => l_rep_pdt_book);
8247 fetch okx_ast_csr into ast_rep_book_rec;
8248 close okx_ast_csr;
8249
8250 l_adjust_cost := (-1)* ast_rep_book_rec.cost;
8251 l_adj_salvage_value := (-1)*ast_rep_book_rec.salvage_value;
8252 l_adj_percent_sv := (-1)*ast_rep_book_rec.percent_salvage_value;
8253
8254 IF nvl(l_adjust_cost,0) = 0 and nvl(l_adj_salvage_value,0) = 0
8255 and nvl(l_adj_percent_sv,0) = 0 Then
8256 Null;
8257 ELSE
8258 FIXED_ASSET_ADJUST_COST
8259 (p_api_version => p_api_version,
8260 p_init_msg_list => p_init_msg_list,
8261 x_return_status => x_return_status,
8262 x_msg_count => x_msg_count,
8263 x_msg_data => x_msg_data,
8264 p_chr_id => p_rel_chr_id,
8265 p_asset_id => ast_corp_book_rec.asset_id,
8266 p_book_type_code => l_rep_pdt_book,
8267 p_adjust_cost => l_adjust_cost,
8268 p_adj_salvage_value => l_adj_salvage_value,
8269 p_adj_percent_sv => l_adj_percent_sv,
8270 p_trans_number => l_trans_number,
8271 p_calling_interface => l_calling_interface,
8272 p_adj_date => l_release_date,
8273 --Bug# 6373605--SLA populate source
8274 p_sla_source_header_id => adj_txl_rec.sla_source_header_id,
8275 p_sla_source_header_table => 'OKL_TRX_ASSETS',
8276 p_sla_source_try_id => adj_txl_rec.sla_source_try_id,
8277 p_sla_source_line_id => adj_txl_rec.sla_source_line_id,
8278 p_sla_source_line_table => adj_txl_rec.sla_source_line_table,
8279 p_sla_source_chr_id => p_rel_chr_id,
8280 p_sla_source_kle_id => adj_txl_rec.sla_source_kle_id,
8281 p_sla_asset_chr_id => p_rel_chr_id,
8282 --Bug# 6373605--SLA populate sources
8283 --Bug# 4028371
8284 x_fa_trx_date => l_fa_adj_date_mg,
8285 x_asset_fin_rec => l_asset_fin_rec);
8286
8287 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
8288 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8289 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
8290 RAISE OKL_API.G_EXCEPTION_ERROR;
8291 END IF;
8292 END IF;
8293 END IF;
8294
8295 End If; --can mass copy into tax book
8296 End If; --asset does not exist in tax book
8297 End If; -- valid tax book for category
8298 End If; -- l_Multi_GAAP_YN = 'Y'
8299 -- Bug 3631094: end
8300
8301 Else
8302
8303 --Bug# 3631094
8304 Close okx_ast_csr;
8305
8306 --initialize
8307 l_adjust_yn := 'N';
8308 l_cost_delta := 0;
8309 l_salvage_delta := 0;
8310
8311 --Bug# 3548044 : Removed comments
8312 l_asset_fin_rec_adj.cost := null;
8313 l_asset_fin_rec_adj.salvage_value := null;
8314 l_asset_fin_rec_adj.date_placed_in_service := null;
8315 l_asset_fin_rec_adj.life_in_months := null;
8316 l_asset_fin_rec_adj.deprn_method_code := null;
8317 l_asset_fin_rec_adj.basic_rate := null;
8318 l_asset_fin_rec_adj.adjusted_rate := null;
8319 --Bug# 3950089
8320 l_asset_fin_rec_adj.percent_salvage_value := null;
8321 --Bug# 3548044 : Removed comments
8322
8323 --Bug# 4627009
8324 l_add_cap_fee:='Y';
8325 --Include Cap fee
8326
8327 -- Bug# 5150150 -- Don't Include Cap Fee for Re-lease contracts
8328 l_cap_fee_delta := 0;
8329 l_cap_fee_delta_converted_amt := 0;
8330 IF NVL(l_orig_system_source_code,OKL_API.G_MISS_CHAR) <> 'OKL_RELEASE' THEN
8331
8332 open cap_fee_csr(fa_cle_id => adj_txl_rec.kle_id
8333 ,rel_chr_id => p_rel_chr_id);
8334 fetch cap_fee_csr into l_cap_fee_delta;
8335 close cap_fee_csr;
8336 l_cap_fee_delta := NVL(l_cap_fee_delta,0);
8337
8338 l_cap_fee_delta_converted_amt := 0;
8339 convert_2functional_currency(
8340 p_api_version => p_api_version,
8341 p_init_msg_list => p_init_msg_list,
8342 x_return_status => x_return_status,
8343 x_msg_count => x_msg_count,
8344 x_msg_data => x_msg_data,
8345 p_chr_id => p_rel_chr_id,
8346 p_amount => l_cap_fee_delta,
8347 x_amount => l_cap_fee_delta_converted_amt);
8348
8349 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
8350 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8351 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
8352 RAISE OKL_API.G_EXCEPTION_ERROR;
8353 END IF;
8354
8355 l_cap_fee_delta_converted_amt := NVL(l_cap_fee_delta_converted_amt,0);
8356 END IF; --Bug# 5150150
8357
8358 if (l_cap_fee_delta_converted_amt>0) THEN
8359 l_add_cap_fee:='Y';
8360 else
8361 l_add_cap_fee:='N';
8362 END IF;
8363 --Bug# 4627009 end
8364
8365 ------------------------------------------------------------------
8366 -- Bug# 3533936 : Update of Asset cost should not be allowed for a
8367 -- Re-lease contract.
8368 /*---------------------------------------------------------------
8369
8370 l_dummy_amount := null;
8371 convert_2functional_currency(
8372 p_api_version => p_api_version,
8373 p_init_msg_list => p_init_msg_list,
8374 x_return_status => x_return_status,
8375 x_msg_count => x_msg_count,
8376 x_msg_data => x_msg_data,
8377 p_chr_id => p_rel_chr_id,
8378 p_amount => adj_txl_rec.depreciation_cost,
8379 x_amount => l_dummy_amount);
8380
8381 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
8382 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8383 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
8384 RAISE OKL_API.G_EXCEPTION_ERROR;
8385 END IF;
8386
8387 --calculate deltas
8388 l_cost_delta := (l_dummy_amount - okx_ast_rec.cost);
8389
8390 -----------------------------------------------------------------------*/
8391 --Bug# 3533936 : End of commented code
8392 ------------------------------------------------------------------------
8393
8394 --Bug# 3548044 : Added if-else clause for reporting product books
8395 If okx_ast_rec.book_type_code <> nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) then
8396
8397 --Bug# 3950089
8398 If (okx_ast_rec.percent_salvage_value is not null) Then
8399
8400 If (adj_txl_rec.pct_salvage_value is null) or
8401 (adj_txl_rec.salvage_value is not null) Then
8402
8403 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
8404 p_msg_name => 'OKL_LA_REVISE_SALVAGE_TYPE',
8405 p_token1 => G_ASSET_NUMBER_TOKEN,
8406 p_token1_value => okx_ast_rec.asset_number
8407 );
8408 x_return_status := OKL_API.G_RET_STS_ERROR;
8409 RAISE OKL_API.G_EXCEPTION_ERROR;
8410 End if;
8411
8412 Elsif (okx_ast_rec.salvage_value is not null) Then
8413
8414 If (adj_txl_rec.salvage_value is null) Then
8415
8416 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
8417 p_msg_name => 'OKL_LA_REVISE_SALVAGE_TYPE',
8418 p_token1 => G_ASSET_NUMBER_TOKEN,
8419 p_token1_value => okx_ast_rec.asset_number
8420 );
8421 x_return_status := OKL_API.G_RET_STS_ERROR;
8422 RAISE OKL_API.G_EXCEPTION_ERROR;
8423 End if;
8424 End If;
8425
8426 If (okx_ast_rec.percent_salvage_value is not null) and
8427 (okx_ast_rec.book_class = 'CORPORATE') Then
8428
8429 l_salvage_delta := ((adj_txl_rec.pct_salvage_value/100)
8430 - okx_ast_rec.percent_salvage_value);
8431
8432 Else
8433 l_dummy_amount := null;
8434 convert_2functional_currency(
8435 p_api_version => p_api_version,
8436 p_init_msg_list => p_init_msg_list,
8437 x_return_status => x_return_status,
8438 x_msg_count => x_msg_count,
8439 x_msg_data => x_msg_data,
8440 p_chr_id => p_rel_chr_id,
8441 p_amount => adj_txl_rec.salvage_value,
8442 x_amount => l_dummy_amount);
8443
8444 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
8445 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8446 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
8447 RAISE OKL_API.G_EXCEPTION_ERROR;
8448 END IF;
8449
8450 l_salvage_delta := (l_dummy_amount - okx_ast_rec.salvage_value);
8451 End if;
8452
8453 ElsIf okx_ast_rec.book_type_code = nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) then
8454
8455 --Bug# 3950089
8456 If (okx_ast_rec.percent_salvage_value is not null) Then
8457
8458 If (adj_txl_rec.corp_pct_salvage_value is null) or
8459 (adj_txl_rec.corp_salvage_value is not null) Then
8460
8461 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
8462 p_msg_name => 'OKL_LA_REVISE_SALVAGE_TYPE',
8463 p_token1 => G_ASSET_NUMBER_TOKEN,
8464 p_token1_value => okx_ast_rec.asset_number
8465 );
8466 x_return_status := OKL_API.G_RET_STS_ERROR;
8467 RAISE OKL_API.G_EXCEPTION_ERROR;
8468 End if;
8469
8470 Elsif (okx_ast_rec.salvage_value is not null) Then
8471
8472 If (adj_txl_rec.corp_salvage_value is null) Then
8473
8474 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
8475 p_msg_name => 'OKL_LA_REVISE_SALVAGE_TYPE',
8476 p_token1 => G_ASSET_NUMBER_TOKEN,
8477 p_token1_value => okx_ast_rec.asset_number
8478 );
8479 x_return_status := OKL_API.G_RET_STS_ERROR;
8480 RAISE OKL_API.G_EXCEPTION_ERROR;
8481 End if;
8482 End If;
8483
8484 If (okx_ast_rec.percent_salvage_value is not null) Then
8485
8486 l_salvage_delta := ((adj_txl_rec.corp_pct_salvage_value/100)
8487 - okx_ast_rec.percent_salvage_value);
8488
8489 Else
8490 l_dummy_amount := null;
8491 convert_2functional_currency(
8492 p_api_version => p_api_version,
8493 p_init_msg_list => p_init_msg_list,
8494 x_return_status => x_return_status,
8495 x_msg_count => x_msg_count,
8496 x_msg_data => x_msg_data,
8497 p_chr_id => p_rel_chr_id,
8498 p_amount => adj_txl_rec.corp_salvage_value,
8499 x_amount => l_dummy_amount);
8500
8501 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
8502 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8503 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
8504 RAISE OKL_API.G_EXCEPTION_ERROR;
8505 END IF;
8506
8507 l_salvage_delta := (l_dummy_amount - okx_ast_rec.salvage_value);
8508 End If;
8509
8510 End If;
8511 --Bug# 3548044 end
8512
8513 -- Bug# 3631094: start
8514
8515 -- Update of Asset cost
8516 If okx_ast_rec.book_type_code = nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) Then
8517
8518 If ( nvl(l_rep_deal_type,OKL_API.G_MISS_CHAR) = OKL_API.G_MISS_CHAR AND
8519 okx_ast_rec.cost <> 0 ) Then
8520
8521 --Bug# 3872534
8522 -- Adjust Asset COST and salvage value in
8523 -- Reporting Book to zero, if the product is
8524 -- not a Multi-Gaap product
8525
8526 l_cost_delta := -1 * okx_ast_rec.cost;
8527 l_asset_fin_rec_adj.cost := l_cost_delta;
8528 l_adjust_yn := 'Y';
8529 --Bug# 4627009
8530 l_add_cap_fee:='N';
8531 --Bug# 4627009 end
8532
8533 Elsif ( l_rep_deal_type = G_OP_LEASE_BK_CLASS AND
8534 l_Multi_GAAP_YN = 'Y' AND
8535 okx_ast_rec.cost = 0 ) Then
8536
8537 -- Adjust Asset cost in Reporting book to Asset
8538 -- cost in Corp book, if Reporting
8539 -- product is OP Lease and Asset cost in
8540 -- Reporting book is zero
8541
8542 l_cost_delta := l_asset_corp_book_cost;
8543 l_asset_fin_rec_adj.cost := l_cost_delta;
8544 l_adjust_yn := 'Y';
8545
8546 Elsif ( l_rep_deal_type in (G_DF_LEASE_BK_CLASS,G_ST_LEASE_BK_CLASS) AND
8547 l_Multi_GAAP_YN = 'Y' AND
8548 okx_ast_rec.cost <> 0 ) Then
8549
8550 --Bug# 3872534
8551 -- Adjust Asset COST in Reporting book to zero
8552 -- if Reporting product is DF/ST Lease
8553
8554 l_cost_delta := -1 * okx_ast_rec.cost;
8555 l_asset_fin_rec_adj.cost := l_cost_delta;
8556 l_adjust_yn := 'Y';
8557 --Bug# 4627009
8558 l_add_cap_fee:='N';
8559 --Bug# 4627009 end
8560
8561 End If;
8562
8563 ElsIf ( l_deal_type in (G_DF_LEASE_BK_CLASS,G_ST_LEASE_BK_CLASS) and
8564 l_tax_owner = 'LESSOR' and
8565 okx_ast_rec.book_class = 'CORPORATE') OR
8566 ( l_deal_type in (G_DF_LEASE_BK_CLASS,G_ST_LEASE_BK_CLASS) and
8567 l_tax_owner = 'LESSEE' ) Then
8568
8569 --Bug# 3872534
8570 -- Adjust Asset COST in Corp book to zero
8571 -- if Local product is DF/ST Lease
8572 -- Adjust Asset COST in Tax book to zero
8573 -- if Local product is DF/ST Lease and Tax Owner
8574 -- is Lessee
8575
8576 If okx_ast_rec.cost <> 0 Then
8577 l_cost_delta := -1 * okx_ast_rec.cost;
8578 l_asset_fin_rec_adj.cost := l_cost_delta;
8579 l_adjust_yn := 'Y';
8580 End If;
8581 --Bug# 4627009
8582 l_add_cap_fee:='N';
8583 --Bug# 4627009 end
8584
8585 End If;
8586
8587
8588 -- Update of Asset Salvage Value
8589 If okx_ast_rec.book_type_code = nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) Then
8590
8591 If ( nvl(l_rep_deal_type,OKL_API.G_MISS_CHAR) = OKL_API.G_MISS_CHAR) THEN
8592
8593 -- Adjust Asset cost and salvage value in
8594 -- Reporting Book to zero, if the product
8595 -- is not a Multi-Gaap product
8596
8597 --Bug# 3950089
8598 If (okx_ast_rec.percent_salvage_value is not null) And
8599 (okx_ast_rec.percent_salvage_value <> 0) Then
8600 l_salvage_delta := -1 * okx_ast_rec.percent_salvage_value;
8601 l_asset_fin_rec_adj.percent_salvage_value := l_salvage_delta;
8602 l_adjust_yn := 'Y';
8603
8604 Elsif (okx_ast_rec.salvage_value is not null) And
8605 (okx_ast_rec.salvage_value <> 0) Then
8606 l_salvage_delta := -1 * okx_ast_rec.salvage_value;
8607 l_asset_fin_rec_adj.salvage_value := l_salvage_delta;
8608 l_adjust_yn := 'Y';
8609
8610 Else
8611 l_salvage_delta := 0;
8612 End if;
8613
8614 Elsif ( l_rep_deal_type = G_OP_LEASE_BK_CLASS AND
8615 l_Multi_GAAP_YN = 'Y' AND
8616 l_salvage_delta <> 0 ) Then
8617
8618 -- Adjust Salvage value in Reporting book
8619 -- to salvage value in Corp Book if
8620 -- Reporting product is OP Lease
8621
8622 --Bug# 3950089
8623 If (okx_ast_rec.percent_salvage_value is not null) Then
8624 l_asset_fin_rec_adj.percent_salvage_value := l_salvage_delta;
8625 Else
8626 l_asset_fin_rec_adj.salvage_value := l_salvage_delta;
8627 End If;
8628 l_adjust_yn := 'Y';
8629
8630 Elsif ( l_rep_deal_type in (G_DF_LEASE_BK_CLASS,G_ST_LEASE_BK_CLASS) AND
8631 l_Multi_GAAP_YN = 'Y' AND
8632 okx_ast_rec.salvage_value <> 0 ) Then
8633
8634 -- Adjust salvage value in Reporting book to zero
8635 -- if Reporting product is DF/ST Lease
8636
8637 --Bug# 3950089
8638 If (okx_ast_rec.percent_salvage_value is not null) And
8639 (okx_ast_rec.percent_salvage_value <> 0) Then
8640 l_salvage_delta := -1 * okx_ast_rec.percent_salvage_value;
8641 l_asset_fin_rec_adj.percent_salvage_value := l_salvage_delta;
8642 l_adjust_yn := 'Y';
8643
8644 Elsif (okx_ast_rec.salvage_value is not null) And
8645 (okx_ast_rec.salvage_value <> 0) Then
8646
8647 l_salvage_delta := -1 * okx_ast_rec.salvage_value;
8648 l_asset_fin_rec_adj.salvage_value := l_salvage_delta;
8649 l_adjust_yn := 'Y';
8650 End If;
8651
8652 Else
8653 l_salvage_delta := 0;
8654 End If;
8655
8656 Elsif ( l_deal_type = G_OP_LEASE_BK_CLASS AND
8657 okx_ast_rec.book_class = 'CORPORATE' AND
8658 l_salvage_delta <> 0 ) Then
8659
8660 -- Adjust Salvage value in Corp book to user
8661 -- entered salvage value, if Local product
8662 -- is OP Lease
8663
8664 --Bug# 3950089
8665 If (okx_ast_rec.percent_salvage_value is not null) Then
8666 l_asset_fin_rec_adj.percent_salvage_value := l_salvage_delta;
8667 Else
8668 l_asset_fin_rec_adj.salvage_value := l_salvage_delta;
8669 End if;
8670 l_adjust_yn := 'Y';
8671
8672 Elsif ((l_deal_type = G_OP_LEASE_BK_CLASS and okx_ast_rec.book_class = 'TAX') OR
8673 (l_deal_type in (G_DF_LEASE_BK_CLASS,G_ST_LEASE_BK_CLASS))
8674 ) Then
8675
8676 -- Adjust salvage value in Corp book to zero
8677 -- if Local product is DF/ST Lease
8678 -- Adjust salvage value in Tax book to zero
8679 -- if Local product is OP Lease or DF/ST Lease
8680
8681 --Bug# 3950089
8682 If (okx_ast_rec.percent_salvage_value is not null) And
8683 (okx_ast_rec.percent_salvage_value <> 0) Then
8684 l_salvage_delta := -1 * okx_ast_rec.percent_salvage_value;
8685 l_asset_fin_rec_adj.percent_salvage_value := l_salvage_delta;
8686 l_adjust_yn := 'Y';
8687
8688 Elsif (okx_ast_rec.salvage_value is not null) And
8689 (okx_ast_rec.salvage_value <> 0) Then
8690
8691 l_salvage_delta := -1 * okx_ast_rec.salvage_value;
8692 l_asset_fin_rec_adj.salvage_value := l_salvage_delta;
8693 l_adjust_yn := 'Y';
8694 Else
8695 l_salvage_delta := 0;
8696 End If;
8697
8698 End If;
8699 --Bug# 3631094: end
8700 ------------------------------------------------------------------
8701 -- Bug# 3533936 : Update of In-service date should not be allowed for a
8702 -- Re-lease contract.
8703 /*---------------------------------------------------------------
8704
8705 If trunc(nvl(adj_txl_rec.in_service_date,okx_ast_rec.in_service_date)) <> trunc(okx_ast_rec.in_service_date) Then
8706 l_asset_fin_rec_adj.date_placed_in_service := nvl(adj_txl_rec.in_service_date,okx_ast_rec.in_service_date);
8707 l_adjust_yn := 'Y';
8708 End If;
8709 -----------------------------------------------------------------------*/
8710 --Bug# 3533936 : End of commented code
8711 ------------------------------------------------------------------------
8712
8713 If nvl(adj_txl_rec.life_in_months,okx_ast_rec.life_in_months) <> okx_ast_rec.life_in_months Then
8714 l_asset_fin_rec_adj.deprn_method_code := nvl(adj_txl_rec.deprn_method,okx_ast_rec.deprn_method_code);
8715 l_asset_fin_rec_adj.life_in_months := nvl(adj_txl_rec.life_in_months,okx_ast_rec.life_in_months);
8716 l_asset_fin_rec_adj.basic_rate := adj_txl_rec.deprn_rate;
8717 l_asset_fin_rec_adj.adjusted_rate := adj_txl_rec.deprn_rate;
8718 l_adjust_yn := 'Y';
8719 End If;
8720
8721 --category updates not supported by API
8722 --If adj_txl_rec.depreciation_id <> okx_ast_rec.depreciation_category Then
8723 If nvl(adj_txl_rec.deprn_method,okx_ast_rec.deprn_method_code) <> okx_ast_rec.deprn_method_code Then
8724 l_asset_fin_rec_adj.deprn_method_code := nvl(adj_txl_rec.deprn_method,okx_ast_rec.deprn_method_code);
8725 --18-Jan-03 modified this
8726 l_asset_fin_rec_adj.life_in_months := adj_txl_rec.life_in_months;
8727 l_asset_fin_rec_adj.basic_rate := adj_txl_rec.deprn_rate;
8728 l_asset_fin_rec_adj.adjusted_rate := adj_txl_rec.deprn_rate;
8729 l_adjust_yn := 'Y';
8730 End If;
8731
8732 If nvl(adj_txl_rec.deprn_rate,okx_ast_rec.adjusted_rate) <> okx_ast_rec.adjusted_rate Then
8733 l_asset_fin_rec_adj.deprn_method_code := nvl(adj_txl_rec.deprn_method,okx_ast_rec.deprn_method_code);
8734 l_asset_fin_rec_adj.life_in_months := adj_txl_rec.life_in_months;
8735 l_asset_fin_rec_adj.basic_rate := nvl(adj_txl_rec.deprn_rate,okx_ast_rec.basic_rate);
8736 l_asset_fin_rec_adj.adjusted_rate := nvl(adj_txl_rec.deprn_rate,okx_ast_rec.adjusted_rate);
8737 l_adjust_yn := 'Y';
8738 End If;
8739
8740 --Bug# 4627009
8741 if ( l_add_cap_fee='Y') THEN
8742 l_cost_delta := l_cost_delta + l_cap_fee_delta_converted_amt;
8743 l_asset_fin_rec_adj.cost:=NVL(l_asset_fin_rec_adj.cost,0) + l_cap_fee_delta_converted_amt;
8744 l_adjust_yn := 'Y';
8745 end if;
8746 --Bug# 4627009 end
8747
8748 If nvl(l_adjust_yn,'N') = 'Y' AND
8749 l_deal_type not in (G_LOAN_BK_CLASS,G_REVOLVING_LOAN_BK_CLASS) then
8750
8751 --bug # 2942543 :
8752 --check if salvage value is becoming more than asset cost
8753 --BUG# 3548044: check for all the books (not only corporate book)
8754 --If okx_ast_rec.book_class = 'CORPORATE' then --salvage value updates only for CORP
8755
8756 --Bug# 3950089
8757 l_new_cost := okx_ast_rec.cost + l_cost_delta;
8758 If (okx_ast_rec.percent_salvage_value is not null) Then
8759 l_new_salvage_value := l_new_cost * (NVL(adj_txl_rec.pct_salvage_value,0)/100);
8760 Else
8761 l_new_salvage_value := okx_ast_rec.salvage_value + l_salvage_delta;
8762 End if;
8763
8764 If (l_new_cost < l_new_salvage_value) Then
8765 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
8766 p_msg_name => G_SALVAGE_VALUE
8767 );
8768 RAISE OKL_API.G_EXCEPTION_ERROR;
8769 End If;
8770 --End If; --Bug# 3548044
8771
8772 --bug# 3156924 :
8773 --Bug# 3533936 : Use contract start date as the
8774 -- transaction date
8775 -- l_release_date := adj_txl_rec.in_service_date;
8776
8777 l_release_date := l_start_date;
8778 l_trans_number := adj_txl_rec.trans_number;
8779 --bug# 3156924
8780
8781 --Bug# 4631549
8782 --For re-lease contract move this validation upfront to
8783 --OKL_CONTRACT_BOOK_PVT
8784 --Bug# 4869443
8785 -- No date validation required for Re-lease asset and Re-lease contract
8786 /*If nvl(l_orig_system_source_code,OKL_API.G_MISS_CHAR) <> 'OKL_RELEASE' Then
8787 --Bug# 3783518
8788 -- Release contract start date should fall in the current
8789 -- open period in FA
8790 validate_release_date
8791 (p_api_version => p_api_version,
8792 p_init_msg_list => p_init_msg_list,
8793 x_return_status => x_return_status,
8794 x_msg_count => x_msg_count,
8795 x_msg_data => x_msg_data,
8796 p_book_type_code => okx_ast_rec.book_type_code,
8797 p_release_date => l_release_date);
8798
8799 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
8800 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8801 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
8802 RAISE OKL_API.G_EXCEPTION_ERROR;
8803 END IF;
8804 End If;*/
8805 --Bug# End 4631549
8806
8807 --Bug# 6373605 start
8808 l_asset_fin_rec_adj.contract_id := p_rel_chr_id;
8809 --Bug# 6373605 end
8810 --call the adjustment api to do adjustment
8811 FIXED_ASSET_ADJUST
8812 (p_api_version => p_api_version,
8813 p_init_msg_list => p_init_msg_list,
8814 x_return_status => x_return_status,
8815 x_msg_count => x_msg_count,
8816 x_msg_data => x_msg_data,
8817 p_chr_id => p_rel_chr_id,
8818 p_asset_id => okx_ast_rec.asset_id,
8819 p_book_type_code => okx_ast_rec.book_type_code,
8820 p_asset_fin_rec_adj => l_asset_fin_rec_adj,
8821 -- Bug Fix# 2925461
8822 --p_adj_date => adj_txl_rec.in_service_date,
8823 p_adj_date => l_release_date,
8824 --Bug# 3156924
8825 p_trans_number => l_trans_number,
8826 p_calling_interface => l_calling_interface,
8827 -- Bug# 3156924
8828 --Bug# 6373605--SLA populate source
8829 p_sla_source_header_id => adj_txl_rec.sla_source_header_id,
8830 p_sla_source_header_table => 'OKL_TRX_ASSETS',
8831 p_sla_source_try_id => adj_txl_rec.sla_source_try_id,
8832 p_sla_source_line_id => adj_txl_rec.sla_source_line_id,
8833 p_sla_source_line_table => adj_txl_rec.sla_source_line_table,
8834 p_sla_source_chr_id => p_rel_chr_id,
8835 p_sla_source_kle_id => adj_txl_rec.sla_source_kle_id,
8836 --Bug# 6373605--SLA populate sources
8837 --Bug# 4028371
8838 x_fa_trx_date => l_fa_adj_date,
8839 x_asset_fin_rec_new => l_asset_fin_rec_new);
8840
8841 --dbms_output.put_line('After fixed asset adjust for rebook :'||x_return_status);
8842 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
8843 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8844 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
8845 RAISE OKL_API.G_EXCEPTION_ERROR;
8846 END IF;
8847 --Bug# 4028371
8848 If adj_txl_rec.tal_id is not null Then
8849 --update the fa trx date on transaction line
8850 l_talv_date_rec.id := adj_txl_rec.tal_id;
8851 l_talv_date_rec.fa_trx_date := l_fa_adj_date;
8852
8853 okl_tal_pvt.update_row
8854 (p_api_version => p_api_version,
8855 p_init_msg_list => p_init_msg_list,
8856 x_return_status => x_return_status,
8857 x_msg_count => x_msg_count,
8858 x_msg_data => x_msg_data,
8859 p_talv_rec => l_talv_date_rec,
8860 x_talv_rec => lx_talv_date_rec);
8861 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
8862 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8863 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
8864 RAISE OKL_API.G_EXCEPTION_ERROR;
8865 END IF;
8866 End If;
8867 --End Bug# 4028371
8868 Else
8869 --------------------
8870 --Bug# 6373605 start
8871 --------------------
8872 --Even if nothing is being adjusted in FA
8873 --make a dummy transaction to update the
8874 --contract_id as assets are moving from
8875 -- off-lease or old contract to new contract
8876
8877 l_dummy_asset_fin_rec_adj.contract_id := p_rel_chr_id;
8878 --call the adjustment api to do adjustment
8879 FIXED_ASSET_ADJUST
8880 (p_api_version => p_api_version,
8881 p_init_msg_list => p_init_msg_list,
8882 x_return_status => x_return_status,
8883 x_msg_count => x_msg_count,
8884 x_msg_data => x_msg_data,
8885 p_chr_id => p_rel_chr_id,
8886 p_asset_id => okx_ast_rec.asset_id,
8887 p_book_type_code => okx_ast_rec.book_type_code,
8888 p_asset_fin_rec_adj => l_dummy_asset_fin_rec_adj,
8889 p_adj_date => l_release_date,
8890 p_trans_number => l_trans_number,
8891 p_calling_interface => l_calling_interface,
8892 --Bug# 6373605--SLA populate source
8893 p_sla_source_header_id => adj_txl_rec.sla_source_header_id,
8894 p_sla_source_header_table => 'OKL_TRX_ASSETS',
8895 p_sla_source_try_id => adj_txl_rec.sla_source_try_id,
8896 p_sla_source_line_id => adj_txl_rec.sla_source_line_id,
8897 p_sla_source_line_table => adj_txl_rec.sla_source_line_table,
8898 p_sla_source_chr_id => p_rel_chr_id,
8899 p_sla_source_kle_id => adj_txl_rec.sla_source_kle_id,
8900 --Bug# 6373605--SLA populate sources
8901 x_fa_trx_date => l_fa_adj_date,
8902 x_asset_fin_rec_new => l_asset_fin_rec_new);
8903
8904 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
8905 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8906 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
8907 RAISE OKL_API.G_EXCEPTION_ERROR;
8908 END IF;
8909
8910 If adj_txl_rec.tal_id is not null then
8911 --update th fa trx date on transaction line
8912 l_talv_date_rec.id := adj_txl_rec.tal_id;
8913
8914 --Bug# 6373605 : Commented as we have
8915 --actual FA transaction noe and do not
8916 --need to derive date
8917 /*okl_accounting_util.get_fa_trx_date
8918 (p_book_type_code => okx_ast_rec.book_type_code,
8919 x_return_status => x_return_status,
8920 x_fa_trx_date => l_fa_adj_date);
8921
8922 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
8923 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8924 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
8925 RAISE OKL_API.G_EXCEPTION_ERROR;
8926 END IF;
8927
8928 l_talv_date_rec.fa_trx_date := l_fa_adj_date;*/
8929 l_talv_date_rec.fa_trx_date := l_fa_adj_date;
8930 -----------
8931 --Bug# 6373605 end
8932 -------------
8933
8934 okl_tal_pvt.update_row
8935 (p_api_version => p_api_version,
8936 p_init_msg_list => p_init_msg_list,
8937 x_return_status => x_return_status,
8938 x_msg_count => x_msg_count,
8939 x_msg_data => x_msg_data,
8940 p_talv_rec => l_talv_date_rec,
8941 x_talv_rec => lx_talv_date_rec);
8942 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
8943 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8944 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
8945 RAISE OKL_API.G_EXCEPTION_ERROR;
8946 END IF;
8947 End If; --adj_txl_rec.tal_id is not null
8948 End If; --l_adjust_yn = 'Y'
8949
8950
8951 -- Bug# 3533936
8952 IF adj_txl_rec.fa_location_id is not null THEN
8953 FIXED_ASSET_TRANSFER
8954 (p_api_version => p_api_version,
8955 p_init_msg_list => p_init_msg_list,
8956 x_return_status => x_return_status,
8957 x_msg_count => x_msg_count,
8958 x_msg_data => x_msg_data,
8959 p_asset_id => okx_ast_rec.asset_id,
8960 p_book_type_code => okx_ast_rec.book_type_code,
8961 p_location_id => adj_txl_rec.fa_location_id,
8962 p_trx_date => l_release_date,
8963 p_trx_number => l_trans_number,
8964 p_calling_interface => l_calling_interface,
8965 --Bug# 6373605--SLA populate source
8966 p_sla_source_header_id => adj_txl_rec.sla_source_header_id,
8967 p_sla_source_header_table => 'OKL_TRX_ASSETS',
8968 p_sla_source_try_id => adj_txl_rec.sla_source_try_id,
8969 p_sla_source_line_id => adj_txl_rec.sla_source_line_id,
8970 p_sla_source_line_table => adj_txl_rec.sla_source_line_table,
8971 p_sla_source_chr_id => p_rel_chr_id,
8972 p_sla_source_kle_id => adj_txl_rec.sla_source_kle_id,
8973 --Bug# 6373605--SLA populate sources
8974 --Bug# 4028371
8975 x_fa_trx_date => l_fa_tsfr_date
8976 );
8977
8978 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
8979 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8980 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
8981 RAISE OKL_API.G_EXCEPTION_ERROR;
8982 END IF;
8983 END IF;
8984 End If;
8985
8986 -- Bug# 3631094
8987 --End If; -- do not do explicit changes for multi-gaap reporting book
8988
8989 -- Bug 3631094 : Setting transaction status to processed is moved
8990 -- to the end of Release_asset procedure.
8991 /*--Bug# 3533936 : set the status of transaction to processed
8992 If adj_txl_rec.tas_id is not NULL then
8993
8994 update_trx_status(p_api_version => p_api_version,
8995 p_init_msg_list => p_init_msg_list,
8996 x_return_status => x_return_status,
8997 x_msg_count => x_msg_count,
8998 x_msg_data => x_msg_data,
8999 p_tas_id => adj_txl_rec.tas_id,
9000 p_tsu_code => G_TSU_CODE_PROCESSED);
9001
9002 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
9003 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
9004 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
9005 RAISE OKL_API.G_EXCEPTION_ERROR;
9006 END IF;
9007 End If;
9008 --End Bug# 3533936*/
9009
9010 End If; --adj_txl_rec found
9011 End Loop;
9012 Close adj_txl_csr;
9013 End If; --k hdr csr
9014 CLOSE k_hdr_csr;
9015
9016 ---------------------------------------------------------------
9017 --Bug# 3143522 : Adjust subsidy adjustments into asset cost
9018 ---------------------------------------------------------------
9019 open l_allast_csr(p_chr_id => p_rel_chr_id);
9020 loop
9021 fetch l_allast_csr into l_asset_cle_id,l_orig_system_id1;
9022 exit when l_allast_csr%NOTFOUND;
9023 l_subsidy_exists := OKL_API.G_FALSE;
9024 okl_subsidy_process_pvt.is_asset_subsidized
9025 (p_api_version => p_api_version,
9026 p_init_msg_list => p_init_msg_list,
9027 x_return_status => x_return_status,
9028 x_msg_count => x_msg_count,
9029 x_msg_data => x_msg_data,
9030 p_asset_cle_id => l_asset_cle_id,
9031 x_subsidized => l_subsidy_exists);
9032 IF (x_return_status = Okl_Api.G_RET_STS_UNEXP_ERROR) THEN
9033 RAISE Okl_Api.G_EXCEPTION_UNEXPECTED_ERROR;
9034 ELSIF (x_return_status = Okl_Api.G_RET_STS_ERROR) THEN
9035 RAISE Okl_Api.G_EXCEPTION_ERROR;
9036 END IF;
9037
9038
9039 If l_subsidy_exists = OKL_API.G_TRUE then
9040
9041 --get total discount for original asset
9042 OKL_EXECUTE_FORMULA_PUB.execute(p_api_version => p_api_version,
9043 p_init_msg_list => p_init_msg_list,
9044 x_return_status => x_return_status,
9045 x_msg_count => x_msg_count,
9046 x_msg_data => x_msg_data,
9047 p_formula_name => G_FORMULA_LINE_DISCOUNT,
9048 p_contract_id => l_rel_chr_id,
9049 p_line_id => l_asset_cle_id,
9050 x_value => l_total_discount);
9051
9052 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
9053 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
9054 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
9055 RAISE OKL_API.G_EXCEPTION_ERROR;
9056 END IF;
9057
9058 --Bug# 3621663 : Fix for Multi-Currency
9059 l_dummy_amount := null;
9060 convert_2functional_currency(
9061 p_api_version => p_api_version,
9062 p_init_msg_list => p_init_msg_list,
9063 x_return_status => x_return_status,
9064 x_msg_count => x_msg_count,
9065 x_msg_data => x_msg_data,
9066 p_chr_id => p_rel_chr_id,
9067 p_amount => l_total_discount,
9068 x_amount => l_dummy_amount);
9069
9070 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
9071 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
9072 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
9073 RAISE OKL_API.G_EXCEPTION_ERROR;
9074 END IF;
9075 l_total_discount := l_dummy_amount;
9076 --Bug# 3621663 : Fix for Multi-Currency
9077
9078 If (l_total_discount <> 0) then
9079 l_cost_adjustment := (-1)* l_total_discount;
9080 --open cursor to get asset details
9081 open l_Asset_csr(p_asset_cle_id => l_asset_cle_id);
9082 Loop
9083 Fetch l_asset_csr into l_asset_rec;
9084 Exit when l_asset_csr%NOTFOUND;
9085
9086 -- Bug# 3783518
9087 -- Do not make adjustment for subsidy for the Reporting
9088 -- Book for cases where the asset is added to the
9089 -- Reporting Book on Re-lease. The subsidy adjustment
9090 -- is done by the call to Fixed_Asset_Add
9091
9092 If l_asset_rec.book_type_code =
9093 nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) Then
9094
9095 open orig_pdt_csr(l_orig_system_id1);
9096 fetch orig_pdt_csr into l_orig_reporting_pdt_id;
9097 close orig_pdt_csr;
9098
9099 End If;
9100
9101 If (l_asset_rec.book_type_code =
9102 nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR)
9103 AND l_orig_reporting_pdt_id is null) Then
9104
9105 NULL;
9106
9107 Else
9108
9109 --Bug# 3872534: Replace NBV checks with cost checks
9110 If (l_asset_rec.asset_cost <> 0) then
9111 If ((l_asset_rec.asset_cost + l_cost_adjustment) <= 0) then
9112 OKL_API.set_message(p_app_name => G_APP_NAME,
9113 p_msg_name => G_SUBSIDY_ADJ_COST_ERROR,
9114 p_token1 => G_ASSET_NUMBER_TOKEN,
9115 p_token1_value => l_asset_rec.asset_number,
9116 p_token2 => G_BOOK_TYPE_TOKEN,
9117 p_token2_value => l_asset_rec.book_type_code,
9118 p_token3 => G_ASSET_NUMBER_TOKEN,
9119 p_token3_value => l_asset_rec.asset_number);
9120 x_return_status := OKL_API.G_RET_STS_ERROR;
9121 RAISE OKL_API.G_EXCEPTION_ERROR;
9122 Elsif ((l_asset_rec.asset_cost + l_cost_adjustment) > 0) then
9123
9124 --Bug# 3156924
9125 l_trans_number := l_asset_rec.trans_number;
9126
9127 --Bug# 3533936 : Use contract start date as the
9128 -- transaction date
9129 -- l_release_date := l_asset_rec.in_service_date;
9130 l_release_date := l_start_date;
9131 --bug# 3156924
9132
9133 --call api to adjust FA cost-amortize adjustment
9134
9135 -- Bug# 3783518
9136 -- Release contract start date should fall in the current
9137 -- open period in FA
9138 --Bug# 4869443
9139 -- No date validation required for Re-lease asset and Re-lease contract
9140 /*
9141 validate_release_date
9142 (p_api_version => p_api_version,
9143 p_init_msg_list => p_init_msg_list,
9144 x_return_status => x_return_status,
9145 x_msg_count => x_msg_count,
9146 x_msg_data => x_msg_data,
9147 p_book_type_code => l_asset_rec.book_type_code,
9148 p_release_date => l_release_date);
9149
9150 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
9151 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
9152 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
9153 RAISE OKL_API.G_EXCEPTION_ERROR;
9154 END IF;
9155 */
9156
9157 l_subsidy_asset_fin_rec_adj.cost := l_cost_adjustment;
9158 --Bug# 6373605 start
9159 If l_asset_rec.book_class = 'CORPORATE' then
9160 l_sla_source_line_id :=
9161 l_asset_rec.sla_source_line_id;
9162 l_sla_source_line_table :=
9163 'OKL_TXL_ASSETS_B';
9164 Elsif l_asset_rec.book_class = 'TAX' then
9165 Open l_txd_from_book_type_csr(p_book_type_code =>
9166 l_asset_rec.book_type_code,
9167 p_tal_id =>
9168 l_asset_rec.sla_source_line_id);
9169 Fetch l_txd_from_book_type_csr into
9170 l_txd_from_book_type_rec;
9171 If l_txd_from_book_type_csr%NOTFOUND then
9172 l_sla_source_line_id :=
9173 l_asset_rec.sla_source_line_id;
9174 l_sla_source_line_table :=
9175 'OKL_TXL_ASSETS_B';
9176 Else
9177 l_sla_source_line_id :=
9178 l_txd_from_book_type_rec.sla_source_line_id;
9179 l_sla_source_line_table :=
9180 'OKL_TXD_ASSETS_B';
9181 End If;
9182 Close l_txd_from_book_type_Csr;
9183 End If;
9184
9185 l_asset_fin_rec_adj.contract_id := p_rel_chr_id;
9186 --bug# 6373605 End;
9187
9188 FIXED_ASSET_ADJUST
9189 (p_api_version => p_api_version,
9190 p_init_msg_list => p_init_msg_list,
9191 x_return_status => x_return_status,
9192 x_msg_count => x_msg_count,
9193 x_msg_data => x_msg_data,
9194 p_chr_id => l_rel_chr_id,
9195 p_asset_id => l_asset_rec.asset_id,
9196 p_book_type_code => l_asset_rec.book_type_code,
9197 p_asset_fin_rec_adj => l_subsidy_asset_fin_rec_adj,
9198 p_adj_date => l_release_date,
9199 p_trans_number => l_trans_number,
9200 p_calling_interface => l_calling_interface,
9201 --Bug# 6373605--SLA populate source
9202 p_sla_source_header_id => l_asset_rec.sla_source_header_id,
9203 p_sla_source_header_table => 'OKL_TRX_ASSETS',
9204 p_sla_source_try_id => l_Asset_rec.sla_source_try_id,
9205 p_sla_source_line_id => l_sla_source_line_id,
9206 p_sla_source_line_table => l_sla_source_line_table,
9207 p_sla_source_chr_id => p_rel_chr_id,
9208 p_sla_source_kle_id => l_asset_rec.sla_source_kle_id,
9209 --Bug# 6373605--SLA populate sources
9210 --Bug# 4028371
9211 x_fa_trx_date => l_fa_adj_date,
9212 x_asset_fin_rec_new => l_asset_fin_rec_new);
9213
9214 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
9215 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
9216 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
9217 RAISE OKL_API.G_EXCEPTION_ERROR;
9218 END IF;
9219
9220 End If;
9221 End If;
9222 End If;
9223 End Loop;
9224 Close l_asset_csr;
9225 End If;
9226 End If; --if l_subsidy_exist = TRUE
9227 End Loop;
9228 Close l_allast_csr;
9229 ----------------------------------------------------------------
9230 --Bug# 3143522 : 11.5.10 End processing for subsidies
9231 ----------------------------------------------------------------
9232
9233 --Bug 3631094: start
9234 --Bug# 3533936 : set the status of transaction to processed
9235 FOR tas_rec in tas_csr(p_chr_id => p_rel_chr_id) LOOP
9236
9237 update_trx_status(p_api_version => p_api_version,
9238 p_init_msg_list => p_init_msg_list,
9239 x_return_status => x_return_status,
9240 x_msg_count => x_msg_count,
9241 x_msg_data => x_msg_data,
9242 p_tas_id => tas_rec.id,
9243 p_tsu_code => G_TSU_CODE_PROCESSED);
9244
9245 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
9246 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
9247 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
9248 RAISE OKL_API.G_EXCEPTION_ERROR;
9249 END IF;
9250
9251 END LOOP;
9252 --End Bug# 3533936
9253 --Bug 3631094: end
9254
9255 OKL_API.END_ACTIVITY (x_msg_count,x_msg_data );
9256 EXCEPTION
9257 WHEN OKL_API.G_EXCEPTION_ERROR THEN
9258 If ( l_hdr_csr%ISOPEN ) Then
9259 CLOSE l_hdr_csr;
9260 End If;
9261
9262 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
9263 l_api_name,
9264 G_PKG_NAME,
9265 'OKL_API.G_RET_STS_ERROR',
9266 x_msg_count,
9267 x_msg_data,
9268 '_PVT');
9269 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
9270 If ( l_hdr_csr%ISOPEN ) Then
9271 CLOSE l_hdr_csr;
9272 End If;
9273
9274 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
9275 l_api_name,
9276 G_PKG_NAME,
9277 'OKL_API.G_RET_STS_UNEXP_ERROR',
9278 x_msg_count,
9279 x_msg_data,
9280 '_PVT');
9281 WHEN OTHERS THEN
9282 If ( l_hdr_csr%ISOPEN ) Then
9283 CLOSE l_hdr_csr;
9284 End If;
9285
9286 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
9287 l_api_name,
9288 G_PKG_NAME,
9289 'OTHERS',
9290 x_msg_count,
9291 x_msg_data,
9292 '_PVT');
9293 END RELEASE_ASSET;
9294
9295 --Bug# 3621875: fetching depreciaion parameters for pricing
9296 ---------------------------------------------------------------------
9297 --Bug# 3621875: pricing parameters
9298 --------------------------------------------------------------------
9299 Procedure Get_pricing_Parameters ( p_api_version IN NUMBER,
9300 p_init_msg_list IN VARCHAR2 DEFAULT OKL_API.G_FALSE,
9301 x_return_status OUT NOCOPY VARCHAR2,
9302 x_msg_count OUT NOCOPY NUMBER,
9303 x_msg_data OUT NOCOPY VARCHAR2,
9304 p_chr_id IN NUMBER,
9305 p_cle_id IN NUMBER,
9306 x_ast_dtl_tbl OUT NOCOPY ast_dtl_tbl_type) is
9307
9308 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
9309 l_api_name CONSTANT varchar2(30) := 'GET_PRICING_PARAMS';
9310 l_api_version CONSTANT NUMBER := 1.0;
9311
9312 --cursor to get transaction going on on this asset
9313 cursor l_curr_trx_csr(p_chr_id in number,
9314 p_cle_id in number) is
9315 select ttyt.name transaction_type,
9316 trx.tas_type,
9317 txl.tal_type,
9318 txl.id tal_id,
9319 trx.creation_date
9320 from okl_trx_types_tl ttyt,
9321 okl_trx_assets trx,
9322 okl_txl_assets_b txl,
9323 okc_k_lines_b cleb,
9324 okc_line_styles_b lseb
9325 where ttyt.id = trx.try_id
9326 and ttyt.language = 'US'
9327 and trx.id = txl.tas_id
9328 and trx.tsu_code = 'ENTERED'
9329 and txl.kle_id = cleb.id
9330 and cleb.cle_id = p_cle_id
9331 and cleb.dnz_chr_id = p_chr_id
9332 and cleb.lse_id = lseb.id
9333 and lseb.lty_code = 'FIXED_ASSET'
9334 order by trx.creation_date desc;
9335
9336 l_curr_trx_rec l_curr_trx_csr%ROWTYPE;
9337
9338 --cursor to check if the contract is selected for Mass Rebook
9339 CURSOR l_chk_mass_rbk_csr (p_chr_id IN NUMBER) IS
9340 SELECT 'Y'
9341 FROM okc_k_headers_b CHR,
9342 okl_trx_contracts ktrx
9343 where CHR.ID = p_chr_id
9344 AND ktrx.KHR_ID = chr.id
9345 AND ktrx.tsu_code = 'ENTERED'
9346 AND ktrx.rbr_code IS NOT NULL
9347 AND ktrx.tcn_type = 'TRBK'
9348 --rkuttiya added for 12.1.1 Multi GAAP Proect
9349 AND ktrx.representation_type = 'PRIMARY'
9350 --
9351 AND EXISTS (SELECT '1'
9352 FROM okl_rbk_selected_contract rbk_khr
9353 WHERE rbk_khr.KHR_ID = chr.id
9354 AND rbk_khr.STATUS <> 'PROCESSED');
9355
9356 l_mass_rbk_yn varchar2(1);
9357
9358
9359 --cursor to get all the data from fa in case of mass rebook
9360 -- and no transaction
9361 cursor l_fa_csr2 (p_cle_id in number,
9362 p_chr_id in number) is
9363 select fab.*,
9364 fa.asset_category_id,
9365 fbc.book_class,
9366 fa.asset_number
9367 from fa_additions fa,
9368 fa_books fab,
9369 fa_book_controls fbc,
9370 okc_k_items cim,
9371 okc_k_lines_b cleb,
9372 okc_line_styles_b lseb
9373 where fab.asset_id = fa.asset_id
9374 and fab.transaction_header_id_out is null
9375 and fbc.book_type_code = fab.book_type_code
9376 and fa.asset_id = cim.object1_id1
9377 and cim.object1_id2 = '#'
9378 and cim.jtot_object1_code = 'OKX_ASSET'
9379 and cim.cle_id = cleb.id
9380 and cim.dnz_chr_id = cleb.dnz_chr_id
9381 and cleb.cle_id = p_cle_id
9382 and cleb.lse_id = lseb.id
9383 and cleb.dnz_chr_id = p_chr_id
9384 and lseb.lty_code = 'FIXED_ASSET';
9385
9386 l_fa_rec2 l_fa_csr2%ROWTYPE;
9387
9388
9389 --cursor to get contract header details
9390 cursor l_chr_csr (p_chr_id in number) is
9391 select khr.pdt_id,
9392 khr.deal_type,
9393 chrb.start_date,
9394 rul.rule_information1
9395 from okc_rules_b rul,
9396 okc_rule_groups_b rgp,
9397 okl_k_headers khr,
9398 okc_k_headers_b chrb
9399 where rul.rule_information_category = 'LATOWN'
9400 and rul.rgp_id = rgp.id
9401 and rul.dnz_chr_id = rgp.dnz_chr_id
9402 and rgp.dnz_chr_id = chrb.id
9403 and rgp.chr_id = chrb.id
9404 and rgp.rgd_code = 'LATOWN'
9405 and khr.id = chrb.id
9406 and chrb.id = p_chr_id;
9407
9408 l_pdt_id number;
9409 l_start_date date;
9410 l_rep_pdt_id number;
9411 l_tax_owner okc_rules_b.rule_information_category%TYPE;
9412 l_deal_type okl_k_headers.deal_type%TYPE;
9413 l_rep_deal_type okl_k_headers.deal_type%TYPE;
9414 l_Multi_GAAP_YN varchar2(1);
9415 l_adjust_asset_to_zero varchar2(1);
9416 l_multi_gaap_book_done varchar2(1);
9417
9418
9419
9420 --cursor to get asset details for contract undergoing booking :
9421 cursor l_booking_corp_csr (p_tal_id in number) is
9422 select txl.asset_number,
9423 txl.corporate_book,
9424 fbc.book_class,
9425 txl.deprn_method,
9426 txl.in_service_date,
9427 txl.life_in_months,
9428 txl.deprn_rate,
9429 txl.salvage_value,
9430 txl.percent_salvage_value,
9431 fcbd.prorate_convention_code,
9432 txl.depreciation_cost,
9433 txl.depreciation_id,
9434 txl.kle_id
9435 from okl_txl_Assets_b txl,
9436 fa_book_controls fbc,
9437 fa_category_book_defaults fcbd
9438 where fcbd.category_id = txl.depreciation_id
9439 and fcbd.book_type_code = txl.corporate_book
9440 and txl.in_service_date between fcbd.start_dpis and nvl(fcbd.end_dpis,txl.in_service_date)
9441 and fbc.book_type_code = txl.corporate_book
9442 and txl.id = p_tal_id;
9443
9444 l_booking_corp_rec l_booking_corp_csr%ROWTYPE;
9445
9446 --cursor to get asset details for contract undergoing mass rebook :
9447 cursor l_mass_rebook_corp_csr (p_tal_id in number) is
9448 select txl.asset_number,
9449 txl.corporate_book,
9450 fbc.book_class,
9451 txl.deprn_method,
9452 txl.in_service_date,
9453 txl.life_in_months,
9454 txl.deprn_rate,
9455 txl.salvage_value,
9456 txl.percent_salvage_value,
9457 fcbd.prorate_convention_code,
9458 txl.depreciation_cost,
9459 txl.depreciation_id,
9460 txl.kle_id
9461 from okl_txl_Assets_b txl,
9462 fa_book_controls fbc,
9463 fa_category_book_defaults fcbd,
9464 fa_additions fa
9465 where fcbd.category_id = fa.asset_category_id
9466 and fcbd.book_type_code = txl.corporate_book
9467 and fa.asset_number = txl.asset_number
9468 and txl.in_service_date between fcbd.start_dpis and nvl(fcbd.end_dpis,txl.in_service_date)
9469 and fbc.book_type_code = txl.corporate_book
9470 and txl.id = p_tal_id;
9471
9472 l_mass_rebook_corp_rec l_mass_rebook_corp_csr%ROWTYPE;
9473
9474 cursor l_booking_tax_csr (p_tal_id in number,
9475 p_category_id in number,
9476 p_in_service_date date) is
9477 select txd.tax_book,
9478 fbc.book_class,
9479 txd.deprn_method_tax,
9480 txd.life_in_months_tax,
9481 txd.deprn_rate_tax,
9482 fcbd.prorate_convention_code,
9483 txd.cost
9484 from okl_txd_Assets_b txd,
9485 fa_book_controls fbc,
9486 fa_category_book_defaults fcbd
9487 where fcbd.category_id = p_category_id
9488 and fcbd.book_type_code = txd.tax_book
9489 and p_in_service_date between fcbd.start_dpis and nvl(fcbd.end_dpis,p_in_service_date)
9490 and fbc.book_type_code = txd.tax_book
9491 and txd.tal_id = p_tal_id;
9492
9493
9494 l_booking_tax_rec l_booking_tax_csr%ROWTYPE;
9495
9496 cursor l_mass_rebook_tax_csr (p_tal_id in number,
9497 p_category_id in number,
9498 p_in_service_date date,
9499 p_book in varchar2 ) is
9500 select txd.tax_book,
9501 fbc.book_class,
9502 txd.deprn_method_tax,
9503 txd.life_in_months_tax,
9504 txd.deprn_rate_tax,
9505 fcbd.prorate_convention_code,
9506 txd.cost
9507 from okl_txd_Assets_b txd,
9508 fa_book_controls fbc,
9509 fa_category_book_defaults fcbd
9510 where fcbd.category_id = p_category_id
9511 and fcbd.book_type_code = txd.tax_book
9512 and p_in_service_date between fcbd.start_dpis and nvl(fcbd.end_dpis,p_in_service_date)
9513 and fbc.book_type_code = txd.tax_book
9514 and txd.tal_id = p_tal_id
9515 and txd.tax_book = p_book;
9516
9517 l_mass_rebook_tax_rec l_mass_rebook_tax_csr%ROWTYPE;
9518
9519
9520 --cursor to get method id
9521 cursor l_method_csr1 (p_method_code in varchar2,
9522 p_life in number) is
9523 select fm.method_id
9524 from fa_methods fm
9525 where fm.method_code = p_method_code
9526 and fm.life_in_months = p_life
9527 and fm.life_in_months is not null;
9528
9529 cursor l_method_csr2 (p_method_code in varchar2,
9530 p_basic_rate in number,
9531 p_adj_rate in number) is
9532 select fm.method_id
9533 from fa_methods fm
9534 where fm.method_code = p_method_code
9535 and fm.life_in_months is null
9536 and exists (select 1
9537 from fa_flat_rates ffr
9538 where ffr.method_id = fm.method_id
9539 and ffr.basic_rate = p_basic_rate
9540 and ffr.adjusted_rate = p_adj_rate);
9541
9542 l_method_id fa_methods.method_id%TYPE;
9543
9544 l_rep_pdt_book fa_books.book_type_code%TYPE;
9545
9546
9547 --cursor to get defaults for multi-GAAP book
9548 cursor l_defaults_csr (p_book in varchar2,
9549 p_category_id in number,
9550 p_date in date) is
9551 select deprn_method,
9552 life_in_months,
9553 basic_rate,
9554 adjusted_rate,
9555 prorate_convention_code
9556 from fa_category_book_defaults
9557 where book_type_code = p_book
9558 and category_id = p_category_id
9559 and p_date between start_dpis and nvl(end_dpis,p_date);
9560
9561
9562 l_defaults_rec l_defaults_csr%ROWTYPE;
9563 i number;
9564
9565 --Cursor to get values from FA
9566 Cursor l_fa_csr (p_asset_number in varchar2,
9567 p_book in varchar2) is
9568 select fab.*,
9569 fa.asset_category_id
9570 from fa_books fab,
9571 fa_additions fa
9572 where fab.book_type_code = p_book
9573 and fab.asset_id = fa.asset_id
9574 and fa.asset_number = p_asset_number
9575 and fab.transaction_header_id_out is null;
9576
9577 l_fa_rec l_fa_csr%ROWTYPE;
9578
9579 l_cap_fee_delta number;
9580 l_ast_trx_not_found varchar2(1);
9581
9582 --Bug# 4775166
9583 Cursor l_clev_csr(p_cle_id in number) is
9584 select name
9585 from okc_k_lines_v
9586 where id = p_cle_id;
9587
9588 l_clev_rec l_clev_csr%rowtype;
9589
9590 -- Bug# 5150150 - start
9591 -- cursor to get expected asset cost
9592 cursor l_exp_asset_cost_csr (p_cle_id in number) is
9593 select id,EXPECTED_ASSET_COST
9594 from okl_k_lines_v
9595 where id = p_cle_id;
9596
9597 -- cursor to get ORIG_SYSTEM_SOURCE_CODE of the contract
9598
9599 cursor l_orig_sys_src_code_csr (p_chr_id in number) is
9600 select id, ORIG_SYSTEM_SOURCE_CODE
9601 from okc_k_headers_b
9602 where id = p_chr_id;
9603
9604 l_chr_id okc_k_headers_b.id%type;
9605 l_orig_system_source_code okc_k_headers_b.orig_system_source_code%type;
9606 l_cle_id okl_k_lines_v.id%type;
9607 l_exp_asset_cost okl_k_lines_v.expected_asset_cost%type;
9608
9609 --cursor to get Cap fees added during Re-lease for the asset
9610 Cursor cap_fee_csr(p_fin_ast_cle_id in number
9611 ,p_chr_id in number) IS
9612 Select nvl(sum(cov_ast_kle.capital_amount),0) capitalized_fee
9613 From
9614 OKL_K_LINES fee_kle,
9615 OKC_K_LINES_B fee_cle,
9616 OKC_STATUSES_B fee_sts,
9617 OKL_K_LINES cov_ast_kle,
9618 OKC_K_LINES_B cov_ast_cle,
9619 OKC_STATUSES_B cov_ast_sts,
9620 OKC_K_ITEMS cov_ast_cim
9621 Where fee_kle.id = fee_cle.id
9622 and fee_kle.fee_type = 'CAPITALIZED'
9623 and fee_cle.dnz_chr_id = p_chr_id
9624 and fee_cle.chr_id = p_chr_id
9625 and fee_cle.lse_id = 52 -- FEE
9626 and fee_cle.sts_code = fee_sts.code
9627 and fee_sts.ste_code not in ('HOLD', 'EXPIRED', 'TERMINATED', 'CANCELLED')
9628 and fee_cle.id = cov_ast_cle.cle_id
9629 and fee_cle.dnz_chr_id = cov_ast_cle.dnz_chr_id
9630 and cov_ast_kle.id = cov_ast_cle.id
9631 and cov_ast_cle.id = cov_ast_cim.cle_id
9632 and cov_ast_cle.lse_id = 53 --LINK_FEE_ASSET
9633 and cov_ast_cle.sts_code = cov_ast_sts.code
9634 and cov_ast_sts.ste_code not in ('HOLD', 'EXPIRED', 'TERMINATED', 'CANCELLED')
9635 and cov_ast_cle.dnz_chr_id = cov_ast_cim.dnz_chr_id
9636 and cov_ast_cim.object1_id1 = to_char(p_fin_ast_cle_id)
9637 and cov_ast_cim.object1_id2 = '#'
9638 and cov_ast_cim.jtot_object1_code = 'OKX_COVASST';
9639
9640 l_new_cap_fee NUMBER;
9641 -- Bug# 5150150 - End
9642
9643 begin
9644 x_return_status := OKL_API.G_RET_STS_SUCCESS;
9645
9646 -- Call start_activity to create savepoint, check compatibility
9647 -- and initialize message list
9648 x_return_status := OKL_API.START_ACTIVITY (
9649 l_api_name
9650 ,p_init_msg_list
9651 ,'_PVT'
9652 ,x_return_status);
9653 -- Check if activity started successfully
9654 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
9655 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
9656 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
9657 RAISE OKL_API.G_EXCEPTION_ERROR;
9658 END IF;
9659
9660 -------------------------------------------------
9661 --1. Find out details of the current transactions
9662 -------------------------------------------------
9663 open l_curr_trx_csr (p_chr_id => p_chr_id,
9664 p_cle_id => p_cle_id) ;
9665 fetch l_curr_trx_csr into l_curr_trx_rec;
9666 If l_curr_trx_csr%NOTFOUND then
9667 --Raise error
9668 l_ast_trx_not_found := 'Y';
9669 else
9670 l_ast_trx_not_found := 'N';
9671 end if;
9672 close l_curr_trx_csr;
9673
9674 If l_ast_trx_not_found = 'Y' then
9675 i := 0;
9676 open l_fa_csr2(p_chr_id => p_chr_id,
9677 p_cle_id => p_cle_id);
9678 loop
9679 fetch l_fa_csr2 into l_fa_rec2;
9680 exit when l_fa_csr2%NOTFOUND;
9681 i := i + 1;
9682 x_ast_dtl_tbl(i).ASSET_NUMBER := l_fa_rec2.asset_number;
9683 x_ast_dtl_tbl(i).BOOK_TYPE_CODE := l_fa_rec2.book_type_code;
9684 x_ast_dtl_tbl(i).BOOK_CLASS := l_fa_rec2.book_class;
9685 x_ast_dtl_tbl(i).DEPRN_METHOD := l_fa_rec2.deprn_method_code;
9686 x_ast_dtl_tbl(i).IN_SERVICE_DATE := l_fa_rec2.date_placed_in_service;
9687 x_ast_dtl_tbl(i).LIFE_IN_MONTHS := l_fa_rec2.life_in_months;
9688 x_ast_dtl_tbl(i).BASIC_RATE := l_fa_rec2.basic_rate;
9689 x_ast_dtl_tbl(i).ADJUSTED_RATE := l_fa_rec2.adjusted_rate;
9690 x_ast_dtl_tbl(i).SALVAGE_VALUE := l_fa_rec2.salvage_value;
9691 x_ast_dtl_tbl(i).PERCENT_SALVAGE_VALUE := l_fa_rec2.percent_salvage_value;
9692 x_ast_dtl_tbl(i).PRORATE_CONVENTION_CODE := l_fa_rec2.prorate_convention_code;
9693 x_ast_dtl_tbl(i).COST := l_fa_rec2.cost;
9694 --get method id
9695 l_method_id := null;
9696 If nvl(l_fa_rec2.life_in_months,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
9697 open l_method_csr1(p_method_code => l_fa_rec2.deprn_method_code,
9698 p_life => l_fa_rec2.life_in_months);
9699 fetch l_method_csr1 into l_method_id;
9700 if l_method_csr1%NOTFOUND then
9701 null;
9702 end if;
9703 close l_method_csr1;
9704 ElsIf nvl(l_fa_rec2.adjusted_rate,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
9705 open l_method_csr2(p_method_code => l_fa_rec2.deprn_method_code,
9706 p_basic_rate => l_fa_rec2.basic_rate,
9707 p_adj_rate => l_fa_rec2.adjusted_rate);
9708 fetch l_method_csr2 into l_method_id;
9709 --Bug# 4775166
9710 if l_method_csr2%NOTFOUND then
9711 null;
9712 end if;
9713 close l_method_csr2;
9714 End If;
9715 x_ast_dtl_tbl(i).DEPRN_METHOD_ID := l_method_id;
9716
9717 end loop;
9718 --Bug# 4775166
9719 close l_fa_csr2;
9720 End If;
9721
9722 If l_ast_trx_not_found = 'N' then
9723 --cursor to get contract detials :
9724 open l_chr_csr (p_chr_id => p_chr_id);
9725 fetch l_chr_csr into l_pdt_id,
9726 l_deal_type,
9727 l_start_date,
9728 l_tax_owner;
9729 If l_chr_csr%NOTFOUND then
9730 --Raise Error : contract header details not found
9731 null;
9732 End If;
9733 close l_chr_csr;
9734
9735 -- Multi-GAAP Begin
9736 Get_Pdt_Params (p_api_version => p_api_version,
9737 p_init_msg_list => p_init_msg_list,
9738 x_return_status => x_return_status,
9739 x_msg_count => x_msg_count,
9740 x_msg_data => x_msg_data,
9741 p_pdt_id => l_pdt_id,
9742 p_pdt_date => l_start_date,
9743 x_rep_pdt_id => l_rep_pdt_id,
9744 x_tax_owner => l_tax_owner,
9745 x_rep_deal_type => l_rep_deal_type);
9746
9747 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
9748 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
9749 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
9750 RAISE OKL_API.G_EXCEPTION_ERROR;
9751 END IF;
9752
9753
9754 l_Multi_GAAP_YN := 'N';
9755 l_adjust_asset_to_zero := 'N';
9756 --checks wheter Multi-GAAP processing needs tobe done
9757 If l_rep_pdt_id is not NULL Then
9758
9759 --Bug 7708944. SMEREDDY 01/15/2009.
9760 -- Implemented MG changes based on PM recommendation.
9761
9762 l_Multi_GAAP_YN := 'Y';
9763 /*
9764 If l_deal_type = 'LEASEOP' and
9765 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
9766 nvl(l_tax_owner,'X') = 'LESSOR' Then
9767 l_Multi_GAAP_YN := 'Y';
9768 End If;
9769
9770 If l_deal_type in ('LEASEDF','LEASEST') and
9771 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
9772 nvl(l_tax_owner,'X') = 'LESSOR' Then
9773 l_Multi_GAAP_YN := 'Y';
9774 End If;
9775
9776 If l_deal_type in ('LEASEDF','LEASEST') and
9777 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
9778 nvl(l_tax_owner,'X') = 'LESSEE' Then
9779 l_Multi_GAAP_YN := 'Y';
9780 End If;
9781
9782 If l_deal_type = 'LOAN' and
9783 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
9784 nvl(l_tax_owner,'X') = 'LESSEE' Then
9785 l_Multi_GAAP_YN := 'Y';
9786 End If;
9787 */
9788 --Bug 7708944. SMEREDDY 01/15/2009.
9789 -- Implemented MG changes based on PM recommendation.
9790
9791 If l_deal_type = 'LEASEOP' and
9792 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
9793 nvl(l_tax_owner,'X') = 'LESSOR' Then
9794 --l_Multi_GAAP_YN := 'Y';
9795 l_adjust_asset_to_zero := 'Y';
9796 End If;
9797
9798 If l_deal_type in ('LEASEDF','LEASEST') and
9799 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
9800 nvl(l_tax_owner,'X') = 'LESSOR' Then
9801 --l_Multi_GAAP_YN := 'Y';
9802 l_adjust_asset_to_zero := 'Y';
9803 End If;
9804
9805 If l_deal_type in ('LEASEDF','LEASEST') and
9806 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
9807 nvl(l_tax_owner,'X') = 'LESSEE' Then
9808 --l_Multi_GAAP_YN := 'Y';
9809 l_adjust_asset_to_zero := 'Y';
9810 End If;
9811 End If;
9812
9813 If l_Multi_GAAP_YN = 'Y' Then
9814 --get reporting product book type
9815 l_rep_pdt_book := OKL_SYSTEM_PARAMS_ALL_PUB.get_system_param_value(OKL_SYSTEM_PARAMS_ALL_PUB.G_RPT_PROD_BOOK_TYPE_CODE);
9816 End If;
9817
9818 If (l_curr_trx_rec.transaction_type) = 'Internal Asset Creation' then
9819 --1. Booking and Online rebook new asset addition
9820 If (l_curr_trx_rec.tas_type = 'CFA') and (l_curr_trx_rec.tal_type = 'CFA') then
9821 open l_booking_corp_csr(p_tal_id => l_curr_trx_rec.tal_id);
9822 Fetch l_booking_corp_csr into l_booking_corp_rec;
9823 If l_booking_corp_csr%NOTFOUND then
9824 --Bug# 4775166
9825 close l_booking_corp_csr;
9826 open l_clev_csr(p_cle_id => p_cle_id);
9827 fetch l_clev_csr into l_clev_rec;
9828 close l_clev_csr;
9829
9830 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
9831 p_msg_name => 'OKL_LA_NO_CORP_BOOK_DFLTS',
9832 p_token1 => 'ASSET_NUMBER',
9833 p_token1_value => l_clev_rec.name
9834 );
9835 Raise OKL_API.G_EXCEPTION_ERROR;
9836 --Bug# 4775166
9837 End If;
9838 close l_booking_corp_csr;
9839
9840 l_method_id := null;
9841 If nvl(l_booking_corp_rec.life_in_months,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
9842 open l_method_csr1(p_method_code => l_booking_corp_rec.deprn_method,
9843 p_life => l_booking_corp_rec.life_in_months);
9844 fetch l_method_csr1 into l_method_id;
9845 if l_method_csr1%NOTFOUND then
9846 null;
9847 end if;
9848 close l_method_csr1;
9849 ElsIf nvl(l_booking_corp_rec.deprn_rate,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
9850 open l_method_csr2(p_method_code => l_booking_corp_rec.deprn_method,
9851 p_basic_rate => l_booking_corp_rec.deprn_rate,
9852 p_adj_rate => l_booking_corp_rec.deprn_rate);
9853 fetch l_method_csr2 into l_method_id;
9854 --Bug# 4775166
9855 if l_method_csr2%NOTFOUND then
9856 null;
9857 end if;
9858 close l_method_csr2;
9859 End If;
9860
9861 i := 1;
9862 x_ast_dtl_tbl(i).ASSET_NUMBER := l_booking_corp_rec.asset_number;
9863 x_ast_dtl_tbl(i).BOOK_TYPE_CODE := l_booking_corp_rec.corporate_book;
9864 x_ast_dtl_tbl(i).BOOK_CLASS := l_booking_corp_rec.book_class;
9865 x_ast_dtl_tbl(i).DEPRN_METHOD := l_booking_corp_rec.deprn_method;
9866 x_ast_dtl_tbl(i).DEPRN_METHOD_ID := l_method_id;
9867 x_ast_dtl_tbl(i).IN_SERVICE_DATE := l_booking_corp_rec.in_service_date;
9868 x_ast_dtl_tbl(i).LIFE_IN_MONTHS := l_booking_corp_rec.life_in_months;
9869 x_ast_dtl_tbl(i).BASIC_RATE := null;
9870 x_ast_dtl_tbl(i).ADJUSTED_RATE := l_booking_corp_rec.deprn_rate;
9871 x_ast_dtl_tbl(i).SALVAGE_VALUE := l_booking_corp_rec.salvage_value;
9872 x_ast_dtl_tbl(i).PERCENT_SALVAGE_VALUE := l_booking_corp_rec.percent_salvage_value;
9873 x_ast_dtl_tbl(i).PRORATE_CONVENTION_CODE := l_booking_corp_rec.prorate_convention_code;
9874
9875 If l_deal_type in ('LEASEDF','LEASEST','LOAN') then
9876 x_ast_dtl_tbl(i).cost := 0;
9877 x_ast_dtl_tbl(i).salvage_value := 0;
9878 x_ast_dtl_tbl(i).percent_salvage_value := null;
9879 Else
9880
9881 Calc_Deprn_Cost ( p_api_version => p_api_version,
9882 p_init_msg_list => p_init_msg_list,
9883 x_msg_count => x_msg_count,
9884 x_msg_data => x_msg_data,
9885 x_return_status => x_return_status,
9886 p_entered_deprn => l_booking_corp_rec.depreciation_cost,
9887 p_fa_cle_id => l_booking_corp_rec.kle_id,
9888 x_calculated_deprn => x_ast_dtl_tbl(i).cost);
9889
9890 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
9891 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
9892 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
9893 RAISE OKL_API.G_EXCEPTION_ERROR;
9894 END IF;
9895 End If;
9896
9897 --process tax_books
9898 l_multi_gaap_book_done := 'N';
9899 open l_booking_tax_csr(p_tal_id => l_curr_trx_rec.tal_id,
9900 p_category_id => l_booking_corp_rec.depreciation_id,
9901 p_in_service_date => l_booking_corp_rec.in_service_date);
9902 loop
9903 fetch l_booking_tax_csr into l_booking_tax_rec;
9904 Exit when l_booking_tax_csr%NOTFOUND;
9905 i := i + 1;
9906
9907 --get deprn method
9908 l_method_id := null;
9909 If nvl(l_booking_tax_rec.life_in_months_tax,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
9910 open l_method_csr1(p_method_code => l_booking_tax_rec.deprn_method_tax,
9911 p_life => l_booking_tax_rec.life_in_months_tax);
9912 fetch l_method_csr1 into l_method_id;
9913 if l_method_csr1%NOTFOUND then
9914 null;
9915 end if;
9916 close l_method_csr1;
9917 ElsIf nvl(l_booking_tax_rec.deprn_rate_tax,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
9918 open l_method_csr2(p_method_code => l_booking_tax_rec.deprn_method_tax,
9919 p_basic_rate => l_booking_tax_rec.deprn_rate_tax,
9920 p_adj_rate => l_booking_tax_rec.deprn_rate_tax);
9921 fetch l_method_csr2 into l_method_id;
9922 --Bug# 4775166
9923 if l_method_csr2%NOTFOUND then
9924 null;
9925 end if;
9926 close l_method_csr2;
9927 End If;
9928
9929 x_ast_dtl_tbl(i).ASSET_NUMBER := l_booking_corp_rec.asset_number;
9930 x_ast_dtl_tbl(i).BOOK_TYPE_CODE := l_booking_tax_rec.tax_book;
9931 x_ast_dtl_tbl(i).BOOK_CLASS := l_booking_tax_rec.book_class;
9932 x_ast_dtl_tbl(i).DEPRN_METHOD := l_booking_tax_rec.deprn_method_tax;
9933 x_ast_dtl_tbl(i).DEPRN_METHOD_ID := l_method_id;
9934 x_ast_dtl_tbl(i).IN_SERVICE_DATE := l_booking_corp_rec.in_service_date;
9935 x_ast_dtl_tbl(i).LIFE_IN_MONTHS := l_booking_tax_rec.life_in_months_tax;
9936 x_ast_dtl_tbl(i).BASIC_RATE := null;
9937 x_ast_dtl_tbl(i).ADJUSTED_RATE := l_booking_tax_rec.deprn_rate_tax;
9938 If nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) <> OKL_API.G_MISS_CHAR and
9939 l_multi_gaap_yn = 'Y' and
9940 l_rep_pdt_book = l_booking_tax_rec.tax_book then
9941 x_ast_dtl_tbl(i).SALVAGE_VALUE := l_booking_corp_rec.salvage_value;
9942 x_ast_dtl_tbl(i).PERCENT_SALVAGE_VALUE := l_booking_corp_rec.percent_salvage_value;
9943 l_multi_gaap_book_done := 'Y';
9944 end if;
9945 x_ast_dtl_tbl(i).PRORATE_CONVENTION_CODE := l_booking_tax_rec.prorate_convention_code;
9946
9947 If (l_multi_GAAP_yn = 'N') OR
9948 (l_multi_GAAP_yn = 'Y' and nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) <> l_booking_tax_rec.tax_book) then
9949 If (l_deal_type = 'LOAN') OR
9950 (l_deal_type in ('LEASEST','LEASEDF') AND l_tax_owner = 'LESSEE')
9951 then
9952 x_ast_dtl_tbl(i).cost := 0;
9953 Else
9954 Calc_Deprn_Cost ( p_api_version => p_api_version,
9955 p_init_msg_list => p_init_msg_list,
9956 x_msg_count => x_msg_count,
9957 x_msg_data => x_msg_data,
9958 x_return_status => x_return_status,
9959 p_entered_deprn => l_booking_tax_rec.cost,
9960 p_fa_cle_id => l_booking_corp_rec.kle_id,
9961 x_calculated_deprn => x_ast_dtl_tbl(i).cost);
9962
9963 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
9964 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
9965 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
9966 RAISE OKL_API.G_EXCEPTION_ERROR;
9967 END IF;
9968 End If;
9969 ElsIf (l_multi_gaap_yn = 'Y') and nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) = l_booking_tax_rec.tax_book then
9970 If (l_rep_deal_type = 'LEASEOP') then
9971 Calc_Deprn_Cost ( p_api_version => p_api_version,
9972 p_init_msg_list => p_init_msg_list,
9973 x_msg_count => x_msg_count,
9974 x_msg_data => x_msg_data,
9975 x_return_status => x_return_status,
9976 p_entered_deprn => l_booking_tax_rec.cost,
9977 p_fa_cle_id => l_booking_corp_rec.kle_id,
9978 x_calculated_deprn => x_ast_dtl_tbl(i).cost);
9979
9980 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
9981 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
9982 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
9983 RAISE OKL_API.G_EXCEPTION_ERROR;
9984 END IF;
9985 ElsIf l_rep_deal_type in ('LEASEST','LEASEDF') then
9986 x_ast_dtl_tbl(i).cost := 0;
9987 x_ast_dtl_tbl(i).salvage_value := 0;
9988 x_ast_dtl_tbl(i).percent_salvage_value := null;
9989 End If;
9990 End If;
9991 End Loop;
9992 close l_booking_tax_csr;
9993
9994 --if multigaap book has not been done
9995 If (l_multi_gaap_yn = 'Y') and (l_multi_gaap_book_done = 'N') then
9996 i := i+1;
9997 --get defaults
9998 open l_defaults_csr (p_book => l_rep_pdt_book,
9999 p_category_id => l_booking_corp_rec.depreciation_id,
10000 p_date => l_booking_corp_rec.in_service_date);
10001 fetch l_defaults_csr into l_defaults_rec;
10002 If l_defaults_csr%NOTFOUND then
10003 --Raise Error
10004 null;
10005 End If;
10006 close l_defaults_csr;
10007
10008 --get deprn method
10009 l_method_id := null;
10010 If nvl(l_defaults_rec.life_in_months,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10011 open l_method_csr1(p_method_code => l_defaults_rec.deprn_method,
10012 p_life => l_defaults_rec.life_in_months);
10013 fetch l_method_csr1 into l_method_id;
10014 if l_method_csr1%NOTFOUND then
10015 null;
10016 end if;
10017 close l_method_csr1;
10018 ElsIf nvl(l_defaults_rec.basic_rate,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10019 open l_method_csr2(p_method_code => l_defaults_rec.deprn_method,
10020 p_basic_rate => l_defaults_rec.basic_rate,
10021 p_adj_rate => l_defaults_rec.adjusted_rate);
10022 fetch l_method_csr2 into l_method_id;
10023 --Bug# 4775166
10024 if l_method_csr2%NOTFOUND then
10025 null;
10026 end if;
10027 close l_method_csr2;
10028 End If;
10029
10030 x_ast_dtl_tbl(i).ASSET_NUMBER := l_booking_corp_rec.asset_number;
10031 x_ast_dtl_tbl(i).BOOK_TYPE_CODE := l_rep_pdt_book;
10032 x_ast_dtl_tbl(i).BOOK_CLASS := 'TAX';
10033 x_ast_dtl_tbl(i).DEPRN_METHOD := l_defaults_rec.deprn_method;
10034 x_ast_dtl_tbl(i).DEPRN_METHOD_ID := l_method_id;
10035 x_ast_dtl_tbl(i).IN_SERVICE_DATE := l_booking_corp_rec.in_service_date;
10036 x_ast_dtl_tbl(i).LIFE_IN_MONTHS := l_defaults_rec.life_in_months;
10037 x_ast_dtl_tbl(i).BASIC_RATE := l_defaults_rec.basic_rate;
10038 x_ast_dtl_tbl(i).ADJUSTED_RATE := l_defaults_rec.adjusted_rate;
10039 x_ast_dtl_tbl(i).SALVAGE_VALUE := l_booking_corp_rec.salvage_value;
10040 x_ast_dtl_tbl(i).PERCENT_SALVAGE_VALUE := l_booking_corp_rec.percent_salvage_value;
10041 x_ast_dtl_tbl(i).PRORATE_CONVENTION_CODE := l_defaults_rec.prorate_convention_code;
10042 l_multi_gaap_book_done := 'Y';
10043
10044 If (l_rep_deal_type = 'LEASEOP') then
10045 Calc_Deprn_Cost ( p_api_version => p_api_version,
10046 p_init_msg_list => p_init_msg_list,
10047 x_msg_count => x_msg_count,
10048 x_msg_data => x_msg_data,
10049 x_return_status => x_return_status,
10050 p_entered_deprn => l_booking_tax_rec.cost,
10051 p_fa_cle_id => l_booking_corp_rec.kle_id,
10052 x_calculated_deprn => x_ast_dtl_tbl(i).cost);
10053
10054 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
10055 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
10056 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
10057 RAISE OKL_API.G_EXCEPTION_ERROR;
10058 END IF;
10059 Elsif l_rep_deal_type in ('LEASEST','LEASEDF') then
10060 x_ast_dtl_tbl(i).cost := 0;
10061 x_ast_dtl_tbl(i).salvage_value := 0;
10062 x_ast_dtl_tbl(i).percent_salvage_value := null;
10063 End If;
10064 End If;
10065
10066 --2. Online Rebook adjustments
10067 ElsIf (l_curr_trx_rec.tas_type = 'CRB') and (l_curr_trx_rec.tal_type = 'CRB') then
10068
10069 open l_booking_corp_csr(p_tal_id => l_curr_trx_rec.tal_id);
10070 Fetch l_booking_corp_csr into l_booking_corp_rec;
10071 If l_booking_corp_csr%NOTFOUND then
10072 --Bug# 4775166
10073 close l_booking_corp_csr;
10074 open l_clev_csr(p_cle_id => p_cle_id);
10075 fetch l_clev_csr into l_clev_rec;
10076 close l_clev_csr;
10077
10078 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
10079 p_msg_name => 'OKL_LA_NO_CORP_BOOK_DFLTS',
10080 p_token1 => 'ASSET_NUMBER',
10081 p_token1_value => l_clev_rec.name
10082 );
10083 Raise OKL_API.G_EXCEPTION_ERROR;
10084 --Bug# 4775166
10085 End If;
10086 close l_booking_corp_csr;
10087
10088 l_method_id := null;
10089 If nvl(l_booking_corp_rec.life_in_months,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10090 open l_method_csr1(p_method_code => l_booking_corp_rec.deprn_method,
10091 p_life => l_booking_corp_rec.life_in_months);
10092 fetch l_method_csr1 into l_method_id;
10093 if l_method_csr1%NOTFOUND then
10094 null;
10095 end if;
10096 close l_method_csr1;
10097 ElsIf nvl(l_booking_corp_rec.deprn_rate,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10098 open l_method_csr2(p_method_code => l_booking_corp_rec.deprn_method,
10099 p_basic_rate => l_booking_corp_rec.deprn_rate,
10100 p_adj_rate => l_booking_corp_rec.deprn_rate);
10101 fetch l_method_csr2 into l_method_id;
10102 --Bug# 4775166
10103 if l_method_csr2%NOTFOUND then
10104 null;
10105 end if;
10106 close l_method_csr2;
10107 End If;
10108
10109 --fetch data from FA
10110 l_fa_rec := null;
10111 open l_fa_csr (p_asset_number => l_booking_corp_rec.asset_number,
10112 p_book => l_booking_corp_rec.corporate_book);
10113 fetch l_fa_csr into l_fa_rec;
10114 If l_fa_csr%NOTFOUND then
10115 --Raise error
10116 null;
10117 End If;
10118 close l_fa_csr;
10119
10120 i := 1;
10121 x_ast_dtl_tbl(i).ASSET_NUMBER := l_booking_corp_rec.asset_number;
10122 x_ast_dtl_tbl(i).BOOK_TYPE_CODE := l_booking_corp_rec.corporate_book;
10123 x_ast_dtl_tbl(i).BOOK_CLASS := l_booking_corp_rec.book_class;
10124 x_ast_dtl_tbl(i).DEPRN_METHOD := l_booking_corp_rec.deprn_method;
10125 x_ast_dtl_tbl(i).DEPRN_METHOD_ID := l_method_id;
10126 x_ast_dtl_tbl(i).IN_SERVICE_DATE := l_booking_corp_rec.in_service_date;
10127 x_ast_dtl_tbl(i).LIFE_IN_MONTHS := l_booking_corp_rec.life_in_months;
10128 x_ast_dtl_tbl(i).BASIC_RATE := null;
10129 x_ast_dtl_tbl(i).ADJUSTED_RATE := l_booking_corp_rec.deprn_rate;
10130 x_ast_dtl_tbl(i).SALVAGE_VALUE := l_booking_corp_rec.salvage_value;
10131 x_ast_dtl_tbl(i).PERCENT_SALVAGE_VALUE := l_booking_corp_rec.percent_salvage_value;
10132 x_ast_dtl_tbl(i).PRORATE_CONVENTION_CODE := l_fa_rec.prorate_convention_code;
10133
10134
10135
10136 If l_deal_type in ('LEASEDF','LEASEST','LOAN') then
10137 x_ast_dtl_tbl(i).cost := l_fa_rec.cost;
10138 x_ast_dtl_tbl(i).salvage_value := l_fa_rec.salvage_value;
10139 x_ast_dtl_tbl(i).percent_salvage_value := l_fa_rec.percent_salvage_value;
10140 Else
10141
10142 -- Bug# 4899328: Cap fee changes are now included in the
10143 -- Depreciation cost. Depreciation cost amount is automatically
10144 -- recalculated whenever there is a change to cap fee.
10145 /*
10146 --find out if new capitalized fee has been added
10147 Calc_Cap_Fee_Adjustment
10148 (p_api_version => p_api_version,
10149 p_init_msg_list => p_init_msg_list,
10150 x_msg_count => x_msg_count,
10151 x_msg_data => x_msg_data,
10152 x_return_status => x_return_status,
10153 p_rbk_fa_cle_id => l_booking_corp_rec.kle_id,
10154 p_rbk_chr_id => p_chr_id,
10155 x_cap_fee_adjustment => l_cap_fee_delta);
10156
10157 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
10158 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
10159 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
10160 RAISE OKL_API.G_EXCEPTION_ERROR;
10161 END IF;
10162 x_ast_dtl_tbl(i).cost := l_booking_corp_rec.depreciation_cost + l_cap_fee_delta;
10163 */
10164
10165 x_ast_dtl_tbl(i).cost := l_booking_corp_rec.depreciation_cost;
10166 -- Bug# 4899328: End
10167
10168 End If;
10169
10170 --process tax_books
10171 l_multi_gaap_book_done := 'N';
10172 open l_booking_tax_csr(p_tal_id => l_curr_trx_rec.tal_id,
10173 p_category_id => l_booking_corp_rec.depreciation_id,
10174 p_in_service_date => l_booking_corp_rec.in_service_date);
10175 loop
10176 fetch l_booking_tax_csr into l_booking_tax_rec;
10177 Exit when l_booking_tax_csr%NOTFOUND;
10178 i := i + 1;
10179
10180 --get deprn method
10181 l_method_id := null;
10182 If nvl(l_booking_tax_rec.life_in_months_tax,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10183 open l_method_csr1(p_method_code => l_booking_tax_rec.deprn_method_tax,
10184 p_life => l_booking_tax_rec.life_in_months_tax);
10185 fetch l_method_csr1 into l_method_id;
10186 if l_method_csr1%NOTFOUND then
10187 null;
10188 end if;
10189 close l_method_csr1;
10190 ElsIf nvl(l_booking_tax_rec.deprn_rate_tax,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10191 open l_method_csr2(p_method_code => l_booking_tax_rec.deprn_method_tax,
10192 p_basic_rate => l_booking_tax_rec.deprn_rate_tax,
10193 p_adj_rate => l_booking_tax_rec.deprn_rate_tax);
10194 fetch l_method_csr2 into l_method_id;
10195 --Bug# 4775166
10196 if l_method_csr2%NOTFOUND then
10197 null;
10198 end if;
10199 close l_method_csr2;
10200 End If;
10201
10202 --fetch data from FA
10203 l_fa_rec := null;
10204 open l_fa_csr (p_asset_number => l_booking_corp_rec.asset_number,
10205 p_book => l_booking_tax_rec.tax_book);
10206 fetch l_fa_csr into l_fa_rec;
10207 If l_fa_csr%NOTFOUND then
10208 --Raise error
10209 null;
10210 End If;
10211 close l_fa_csr;
10212
10213 x_ast_dtl_tbl(i).ASSET_NUMBER := l_booking_corp_rec.asset_number;
10214 x_ast_dtl_tbl(i).BOOK_TYPE_CODE := l_booking_tax_rec.tax_book;
10215 x_ast_dtl_tbl(i).BOOK_CLASS := l_booking_tax_rec.book_class;
10216 x_ast_dtl_tbl(i).DEPRN_METHOD := l_booking_tax_rec.deprn_method_tax;
10217 x_ast_dtl_tbl(i).DEPRN_METHOD_ID := l_method_id;
10218 x_ast_dtl_tbl(i).IN_SERVICE_DATE := l_booking_corp_rec.in_service_date;
10219 x_ast_dtl_tbl(i).LIFE_IN_MONTHS := l_booking_tax_rec.life_in_months_tax;
10220 x_ast_dtl_tbl(i).BASIC_RATE := null;
10221 x_ast_dtl_tbl(i).ADJUSTED_RATE := l_booking_tax_rec.deprn_rate_tax;
10222 If nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) <> OKL_API.G_MISS_CHAR and
10223 l_multi_gaap_yn = 'Y' and
10224 l_rep_pdt_book = l_booking_tax_rec.tax_book then
10225 x_ast_dtl_tbl(i).SALVAGE_VALUE := l_booking_corp_rec.salvage_value;
10226 x_ast_dtl_tbl(i).PERCENT_SALVAGE_VALUE := l_booking_corp_rec.percent_salvage_value;
10227 l_multi_gaap_book_done := 'Y';
10228 end if;
10229 x_ast_dtl_tbl(i).PRORATE_CONVENTION_CODE := l_fa_rec.prorate_convention_code;
10230
10231 If (l_multi_GAAP_yn = 'N') OR
10232 (l_multi_GAAP_yn = 'Y' and nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) <> l_booking_tax_rec.tax_book) then
10233 If (l_deal_type = 'LOAN') OR
10234 (l_deal_type in ('LEASEST','LEASEDF') AND l_tax_owner = 'LESSEE')
10235 then
10236 x_ast_dtl_tbl(i).cost := l_fa_rec.cost;
10237 Else
10238
10239 -- Bug# 4899328: Cap fee changes are now included in the
10240 -- Depreciation cost. Depreciation cost amount is automatically
10241 -- recalculated whenever there is a change to cap fee.
10242 /*
10243 --find out if new capitalized fee has been added
10244 Calc_Cap_Fee_Adjustment
10245 (p_api_version => p_api_version,
10246 p_init_msg_list => p_init_msg_list,
10247 x_msg_count => x_msg_count,
10248 x_msg_data => x_msg_data,
10249 x_return_status => x_return_status,
10250 p_rbk_fa_cle_id => l_booking_corp_rec.kle_id,
10251 p_rbk_chr_id => p_chr_id,
10252 x_cap_fee_adjustment => l_cap_fee_delta);
10253
10254 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
10255 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
10256 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
10257 RAISE OKL_API.G_EXCEPTION_ERROR;
10258 END IF;
10259 x_ast_dtl_tbl(i).cost := l_booking_tax_rec.cost + l_cap_fee_delta;
10260 */
10261
10262 x_ast_dtl_tbl(i).cost := l_booking_tax_rec.cost;
10263 --Bug# 4899328: End
10264 End If;
10265
10266 ElsIf (l_multi_gaap_yn = 'Y') and nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) = l_booking_tax_rec.tax_book then
10267 If (l_rep_deal_type = 'LEASEOP') then
10268
10269 -- Bug# 4899328: Cap fee changes are now included in the
10270 -- Depreciation cost. Depreciation cost amount is automatically
10271 -- recalculated whenever there is a change to cap fee.
10272 /*
10273 --find out if new capitalized fee has been added
10274 Calc_Cap_Fee_Adjustment
10275 (p_api_version => p_api_version,
10276 p_init_msg_list => p_init_msg_list,
10277 x_msg_count => x_msg_count,
10278 x_msg_data => x_msg_data,
10279 x_return_status => x_return_status,
10280 p_rbk_fa_cle_id => l_booking_corp_rec.kle_id,
10281 p_rbk_chr_id => p_chr_id,
10282 x_cap_fee_adjustment => l_cap_fee_delta);
10283
10284 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
10285 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
10286 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
10287 RAISE OKL_API.G_EXCEPTION_ERROR;
10288 END IF;
10289 x_ast_dtl_tbl(i).cost := l_booking_tax_rec.cost + l_cap_fee_delta;
10290 */
10291
10292 x_ast_dtl_tbl(i).cost := l_booking_tax_rec.cost;
10293 --Bug# 4899328: End
10294
10295 ElsIf l_rep_deal_type in ('LEASEST','LEASEDF') then
10296
10297 x_ast_dtl_tbl(i).cost := l_fa_rec.cost;
10298 x_ast_dtl_tbl(i).salvage_value := l_fa_rec.salvage_value;
10299 x_ast_dtl_tbl(i).percent_salvage_value := l_fa_rec.percent_salvage_value;
10300
10301 End If;
10302 End If;
10303 End Loop;
10304 close l_booking_tax_csr;
10305 --3. Release Asset and Release Contract Case
10306 ElsIf (l_curr_trx_rec.tas_type = 'CRL') and (l_curr_trx_rec.tal_type = 'CRL') then
10307 open l_booking_corp_csr(p_tal_id => l_curr_trx_rec.tal_id);
10308 Fetch l_booking_corp_csr into l_booking_corp_rec;
10309 If l_booking_corp_csr%NOTFOUND then
10310 --Bug# 4775166
10311 close l_booking_corp_csr;
10312 open l_clev_csr(p_cle_id => p_cle_id);
10313 fetch l_clev_csr into l_clev_rec;
10314 close l_clev_csr;
10315
10316 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
10317 p_msg_name => 'OKL_LA_NO_CORP_BOOK_DFLTS',
10318 p_token1 => 'ASSET_NUMBER',
10319 p_token1_value => l_clev_rec.name
10320 );
10321 Raise OKL_API.G_EXCEPTION_ERROR;
10322 --Bug# 4775166
10323 End If;
10324 close l_booking_corp_csr;
10325
10326 l_method_id := null;
10327 If nvl(l_booking_corp_rec.life_in_months,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10328 open l_method_csr1(p_method_code => l_booking_corp_rec.deprn_method,
10329 p_life => l_booking_corp_rec.life_in_months);
10330 fetch l_method_csr1 into l_method_id;
10331 if l_method_csr1%NOTFOUND then
10332 null;
10333 end if;
10334 close l_method_csr1;
10335 ElsIf nvl(l_booking_corp_rec.deprn_rate,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10336 open l_method_csr2(p_method_code => l_booking_corp_rec.deprn_method,
10337 p_basic_rate => l_booking_corp_rec.deprn_rate,
10338 p_adj_rate => l_booking_corp_rec.deprn_rate);
10339 fetch l_method_csr2 into l_method_id;
10340 --Bug# 4775166
10341 if l_method_csr2%NOTFOUND then
10342 null;
10343 end if;
10344 close l_method_csr2;
10345 End If;
10346
10347 --fetch data from FA
10348 l_fa_rec := null;
10349 open l_fa_csr (p_asset_number => l_booking_corp_rec.asset_number,
10350 p_book => l_booking_corp_rec.corporate_book);
10351 fetch l_fa_csr into l_fa_rec;
10352 If l_fa_csr%NOTFOUND then
10353 --Raise error
10354 null;
10355 End If;
10356 close l_fa_csr;
10357
10358 i := 1;
10359 x_ast_dtl_tbl(i).ASSET_NUMBER := l_booking_corp_rec.asset_number;
10360 x_ast_dtl_tbl(i).BOOK_TYPE_CODE := l_booking_corp_rec.corporate_book;
10361 x_ast_dtl_tbl(i).BOOK_CLASS := l_booking_corp_rec.book_class;
10362 x_ast_dtl_tbl(i).DEPRN_METHOD := l_booking_corp_rec.deprn_method;
10363 x_ast_dtl_tbl(i).DEPRN_METHOD_ID := l_method_id;
10364 x_ast_dtl_tbl(i).IN_SERVICE_DATE := l_booking_corp_rec.in_service_date;
10365 x_ast_dtl_tbl(i).LIFE_IN_MONTHS := l_booking_corp_rec.life_in_months;
10366 x_ast_dtl_tbl(i).BASIC_RATE := null;
10367 x_ast_dtl_tbl(i).ADJUSTED_RATE := l_booking_corp_rec.deprn_rate;
10368 x_ast_dtl_tbl(i).SALVAGE_VALUE := l_booking_corp_rec.salvage_value;
10369 x_ast_dtl_tbl(i).PERCENT_SALVAGE_VALUE := l_booking_corp_rec.percent_salvage_value;
10370 x_ast_dtl_tbl(i).PRORATE_CONVENTION_CODE := l_fa_rec.prorate_convention_code;
10371
10372 -- Bug# 5150150
10373 OPEN l_orig_sys_src_code_csr ( p_chr_id );
10374 FETCH l_orig_sys_src_code_csr INTO l_chr_id, l_orig_system_source_code;
10375 CLOSE l_orig_sys_src_code_csr;
10376
10377 -- If Re-lease contract
10378 if ((l_orig_system_source_code is not null) and (l_orig_system_source_code = 'OKL_RELEASE')) then
10379
10380 OPEN l_exp_asset_cost_csr ( p_cle_id );
10381 FETCH l_exp_asset_cost_csr INTO l_cle_id, l_exp_asset_cost;
10382 CLOSE l_exp_asset_cost_csr;
10383 end if;
10384 -- Bug# 5150150
10385
10386 If l_deal_type in ('LEASEDF','LEASEST','LOAN') then
10387 -- Bug# 5150150
10388 x_ast_dtl_tbl(i).cost := 0;
10389 x_ast_dtl_tbl(i).salvage_value := 0;
10390 x_ast_dtl_tbl(i).percent_salvage_value := 0;
10391 Else
10392 -- Bug# 5150150-start
10393 -- If Re-lease contract
10394 if ((l_orig_system_source_code is not null) and (l_orig_system_source_code = 'OKL_RELEASE')) then
10395 if (NVL(l_fa_rec.cost,0) = 0) then
10396 x_ast_dtl_tbl(i).cost := l_exp_asset_cost ;
10397 else
10398 x_ast_dtl_tbl(i).cost := l_fa_rec.cost ;
10399 end if;
10400
10401 -- if Re-lease asset
10402 else
10403 x_ast_dtl_tbl(i).cost := l_fa_rec.cost ;
10404
10405 --find out if new capitalized fee has been added
10406 open cap_fee_csr(p_fin_ast_cle_id => p_cle_id
10407 ,p_chr_id => p_chr_id);
10408 fetch cap_fee_csr into l_new_cap_fee;
10409 close cap_fee_csr;
10410
10411 x_ast_dtl_tbl(i).cost := x_ast_dtl_tbl(i).cost + NVL(l_new_cap_fee,0);
10412 end if;
10413
10414 -- Bug# 5150150-End
10415 End If;
10416
10417 --process tax_books
10418 l_multi_gaap_book_done := 'N';
10419 open l_booking_tax_csr(p_tal_id => l_curr_trx_rec.tal_id,
10420 p_category_id => l_booking_corp_rec.depreciation_id,
10421 p_in_service_date => l_booking_corp_rec.in_service_date);
10422 loop
10423 fetch l_booking_tax_csr into l_booking_tax_rec;
10424 Exit when l_booking_tax_csr%NOTFOUND;
10425 i := i + 1;
10426
10427 --get deprn method
10428 l_method_id := null;
10429 If nvl(l_booking_tax_rec.life_in_months_tax,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10430 open l_method_csr1(p_method_code => l_booking_tax_rec.deprn_method_tax,
10431 p_life => l_booking_tax_rec.life_in_months_tax);
10432 fetch l_method_csr1 into l_method_id;
10433 if l_method_csr1%NOTFOUND then
10434 null;
10435 end if;
10436 close l_method_csr1;
10437 ElsIf nvl(l_booking_tax_rec.deprn_rate_tax,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10438 open l_method_csr2(p_method_code => l_booking_tax_rec.deprn_method_tax,
10439 p_basic_rate => l_booking_tax_rec.deprn_rate_tax,
10440 p_adj_rate => l_booking_tax_rec.deprn_rate_tax);
10441 fetch l_method_csr2 into l_method_id;
10442 --Bug# 4775166
10443 if l_method_csr2%NOTFOUND then
10444 null;
10445 end if;
10446 close l_method_csr2;
10447 End If;
10448
10449 --fetch data from FA
10450 l_fa_rec := null;
10451 open l_fa_csr (p_asset_number => l_booking_corp_rec.asset_number,
10452 p_book => l_booking_tax_rec.tax_book);
10453 fetch l_fa_csr into l_fa_rec;
10454 If l_fa_csr%NOTFOUND then
10455 --Raise error
10456 null;
10457 End If;
10458 close l_fa_csr;
10459
10460 x_ast_dtl_tbl(i).ASSET_NUMBER := l_booking_corp_rec.asset_number;
10461 x_ast_dtl_tbl(i).BOOK_TYPE_CODE := l_booking_tax_rec.tax_book;
10462 x_ast_dtl_tbl(i).BOOK_CLASS := l_booking_tax_rec.book_class;
10463 x_ast_dtl_tbl(i).DEPRN_METHOD := l_booking_tax_rec.deprn_method_tax;
10464 x_ast_dtl_tbl(i).DEPRN_METHOD_ID := l_method_id;
10465 x_ast_dtl_tbl(i).IN_SERVICE_DATE := l_booking_corp_rec.in_service_date;
10466 x_ast_dtl_tbl(i).LIFE_IN_MONTHS := l_booking_tax_rec.life_in_months_tax;
10467 x_ast_dtl_tbl(i).BASIC_RATE := null;
10468 x_ast_dtl_tbl(i).ADJUSTED_RATE := l_booking_tax_rec.deprn_rate_tax;
10469 If nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) <> OKL_API.G_MISS_CHAR and
10470 l_multi_gaap_yn = 'Y' and
10471 l_rep_pdt_book = l_booking_tax_rec.tax_book then
10472 x_ast_dtl_tbl(i).SALVAGE_VALUE := l_booking_corp_rec.salvage_value;
10473 x_ast_dtl_tbl(i).PERCENT_SALVAGE_VALUE := l_booking_corp_rec.percent_salvage_value;
10474 l_multi_gaap_book_done := 'Y';
10475 end if;
10476 x_ast_dtl_tbl(i).PRORATE_CONVENTION_CODE := l_fa_rec.prorate_convention_code;
10477 If (l_multi_GAAP_yn = 'N') OR
10478 (l_multi_GAAP_yn = 'Y' and nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) <> l_booking_tax_rec.tax_book) then
10479
10480 -- Bug# 5150150
10481 If (l_deal_type = 'LOAN') OR
10482 (l_deal_type in ('LEASEST','LEASEDF') AND l_tax_owner = 'LESSEE')
10483 then
10484 x_ast_dtl_tbl(i).cost := 0;
10485 Else
10486 -- Bug# 5150150-start
10487 -- If Re-lease contract
10488 if ((l_orig_system_source_code is not null) and (l_orig_system_source_code = 'OKL_RELEASE')) then
10489 if (NVL(l_fa_rec.cost,0) = 0) then
10490 x_ast_dtl_tbl(i).cost := l_exp_asset_cost ;
10491 else
10492 x_ast_dtl_tbl(i).cost := l_fa_rec.cost ;
10493 end if;
10494 -- if Re-lease asset
10495 else
10496 x_ast_dtl_tbl(i).cost := l_fa_rec.cost ;
10497
10498 --find out if new capitalized fee has been added
10499 open cap_fee_csr(p_fin_ast_cle_id => p_cle_id
10500 ,p_chr_id => p_chr_id);
10501 fetch cap_fee_csr into l_new_cap_fee;
10502 close cap_fee_csr;
10503
10504 x_ast_dtl_tbl(i).cost := x_ast_dtl_tbl(i).cost + NVL(l_new_cap_fee,0);
10505 end if;
10506 -- Bug# 5150150-End
10507 End If;
10508
10509 ElsIf (l_multi_gaap_yn = 'Y') and nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) = l_booking_tax_rec.tax_book then
10510 If (l_rep_deal_type = 'LEASEOP') then
10511 --find out if new capitalized fee has been added
10512
10513 -- Bug# 5150150-start
10514 -- If Re-lease contract
10515 if (NVL(l_orig_system_source_code,OKL_API.G_MISS_CHAR) = 'OKL_RELEASE') then
10516 if (NVL(l_fa_rec.cost,0) = 0) then
10517 x_ast_dtl_tbl(i).cost := l_exp_asset_cost ;
10518 else
10519 x_ast_dtl_tbl(i).cost := l_fa_rec.cost ;
10520 end if;
10521 -- if Re-lease asset
10522 else
10523 x_ast_dtl_tbl(i).cost := l_fa_rec.cost ;
10524
10525 --find out if new capitalized fee has been added
10526 open cap_fee_csr(p_fin_ast_cle_id => p_cle_id
10527 ,p_chr_id => p_chr_id);
10528 fetch cap_fee_csr into l_new_cap_fee;
10529 close cap_fee_csr;
10530
10531 x_ast_dtl_tbl(i).cost := x_ast_dtl_tbl(i).cost + NVL(l_new_cap_fee,0);
10532 end if;
10533 -- Bug# 5150150-End
10534
10535 ElsIf l_rep_deal_type in ('LEASEST','LEASEDF') then
10536 -- Bug# 5150150
10537 x_ast_dtl_tbl(i).cost := 0;
10538 x_ast_dtl_tbl(i).salvage_value := 0;
10539 x_ast_dtl_tbl(i).percent_salvage_value := 0;
10540
10541 End If;
10542 End If;
10543 End Loop;
10544 close l_booking_tax_csr;
10545 -------------
10546 --Bug# 4138635
10547 --4. Split Asset Case
10548 ElsIf (l_curr_trx_rec.tas_type = 'CSP') and (l_curr_trx_rec.tal_type = 'CSP') then
10549 open l_booking_corp_csr(p_tal_id => l_curr_trx_rec.tal_id);
10550 Fetch l_booking_corp_csr into l_booking_corp_rec;
10551 If l_booking_corp_csr%NOTFOUND then
10552 --Bug# 4775166
10553 close l_booking_corp_csr;
10554 open l_clev_csr(p_cle_id => p_cle_id);
10555 fetch l_clev_csr into l_clev_rec;
10556 close l_clev_csr;
10557
10558 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
10559 p_msg_name => 'OKL_LA_NO_CORP_BOOK_DFLTS',
10560 p_token1 => 'ASSET_NUMBER',
10561 p_token1_value => l_clev_rec.name
10562 );
10563 Raise OKL_API.G_EXCEPTION_ERROR;
10564 --Bug# 4775166
10565 End If;
10566 close l_booking_corp_csr;
10567
10568 l_method_id := null;
10569 If nvl(l_booking_corp_rec.life_in_months,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10570 open l_method_csr1(p_method_code => l_booking_corp_rec.deprn_method,
10571 p_life => l_booking_corp_rec.life_in_months);
10572 fetch l_method_csr1 into l_method_id;
10573 if l_method_csr1%NOTFOUND then
10574 null;
10575 end if;
10576 close l_method_csr1;
10577 ElsIf nvl(l_booking_corp_rec.deprn_rate,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10578 open l_method_csr2(p_method_code => l_booking_corp_rec.deprn_method,
10579 p_basic_rate => l_booking_corp_rec.deprn_rate,
10580 p_adj_rate => l_booking_corp_rec.deprn_rate);
10581 fetch l_method_csr2 into l_method_id;
10582 --Bug# 4775166
10583 if l_method_csr2%NOTFOUND then
10584 null;
10585 end if;
10586 close l_method_csr2;
10587 End If;
10588
10589 --fetch data from FA
10590 l_fa_rec := null;
10591 open l_fa_csr (p_asset_number => l_booking_corp_rec.asset_number,
10592 p_book => l_booking_corp_rec.corporate_book);
10593 fetch l_fa_csr into l_fa_rec;
10594 If l_fa_csr%NOTFOUND then
10595 --Raise error
10596 null;
10597 End If;
10598 close l_fa_csr;
10599
10600 i := 1;
10601 x_ast_dtl_tbl(i).ASSET_NUMBER := l_booking_corp_rec.asset_number;
10602 x_ast_dtl_tbl(i).BOOK_TYPE_CODE := l_booking_corp_rec.corporate_book;
10603 x_ast_dtl_tbl(i).BOOK_CLASS := l_booking_corp_rec.book_class;
10604 x_ast_dtl_tbl(i).DEPRN_METHOD := l_booking_corp_rec.deprn_method;
10605 x_ast_dtl_tbl(i).DEPRN_METHOD_ID := l_method_id;
10606 x_ast_dtl_tbl(i).IN_SERVICE_DATE := l_booking_corp_rec.in_service_date;
10607 x_ast_dtl_tbl(i).LIFE_IN_MONTHS := l_booking_corp_rec.life_in_months;
10608 x_ast_dtl_tbl(i).BASIC_RATE := null;
10609 x_ast_dtl_tbl(i).ADJUSTED_RATE := l_booking_corp_rec.deprn_rate;
10610 x_ast_dtl_tbl(i).SALVAGE_VALUE := l_booking_corp_rec.salvage_value;
10611 x_ast_dtl_tbl(i).PERCENT_SALVAGE_VALUE := l_booking_corp_rec.percent_salvage_value;
10612 x_ast_dtl_tbl(i).PRORATE_CONVENTION_CODE := l_fa_rec.prorate_convention_code;
10613
10614
10615
10616 If l_deal_type in ('LEASEDF','LEASEST','LOAN') then
10617 x_ast_dtl_tbl(i).cost := l_fa_rec.cost;
10618 x_ast_dtl_tbl(i).salvage_value := l_fa_rec.salvage_value;
10619 x_ast_dtl_tbl(i).percent_salvage_value := l_fa_rec.percent_salvage_value;
10620 Else
10621 x_ast_dtl_tbl(i).cost := l_fa_rec.cost ;
10622 End If;
10623
10624 --process tax_books
10625 l_multi_gaap_book_done := 'N';
10626 open l_booking_tax_csr(p_tal_id => l_curr_trx_rec.tal_id,
10627 p_category_id => l_booking_corp_rec.depreciation_id,
10628 p_in_service_date => l_booking_corp_rec.in_service_date);
10629 loop
10630 fetch l_booking_tax_csr into l_booking_tax_rec;
10631 Exit when l_booking_tax_csr%NOTFOUND;
10632 i := i + 1;
10633
10634 --get deprn method
10635 l_method_id := null;
10636 If nvl(l_booking_tax_rec.life_in_months_tax,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10637 open l_method_csr1(p_method_code => l_booking_tax_rec.deprn_method_tax,
10638 p_life => l_booking_tax_rec.life_in_months_tax);
10639 fetch l_method_csr1 into l_method_id;
10640 if l_method_csr1%NOTFOUND then
10641 null;
10642 end if;
10643 close l_method_csr1;
10644 ElsIf nvl(l_booking_tax_rec.deprn_rate_tax,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10645 open l_method_csr2(p_method_code => l_booking_tax_rec.deprn_method_tax,
10646 p_basic_rate => l_booking_tax_rec.deprn_rate_tax,
10647 p_adj_rate => l_booking_tax_rec.deprn_rate_tax);
10648 fetch l_method_csr2 into l_method_id;
10649 --Bug# 4775166
10650 if l_method_csr2%NOTFOUND then
10651 null;
10652 end if;
10653 close l_method_csr2;
10654 End If;
10655
10656 --fetch data from FA
10657 l_fa_rec := null;
10658 open l_fa_csr (p_asset_number => l_booking_corp_rec.asset_number,
10659 p_book => l_booking_tax_rec.tax_book);
10660 fetch l_fa_csr into l_fa_rec;
10661 If l_fa_csr%NOTFOUND then
10662 --Raise error
10663 null;
10664 End If;
10665 close l_fa_csr;
10666
10667 x_ast_dtl_tbl(i).ASSET_NUMBER := l_booking_corp_rec.asset_number;
10668 x_ast_dtl_tbl(i).BOOK_TYPE_CODE := l_booking_tax_rec.tax_book;
10669 x_ast_dtl_tbl(i).BOOK_CLASS := l_booking_tax_rec.book_class;
10670 x_ast_dtl_tbl(i).DEPRN_METHOD := l_booking_tax_rec.deprn_method_tax;
10671 x_ast_dtl_tbl(i).DEPRN_METHOD_ID := l_method_id;
10672 x_ast_dtl_tbl(i).IN_SERVICE_DATE := l_booking_corp_rec.in_service_date;
10673 x_ast_dtl_tbl(i).LIFE_IN_MONTHS := l_booking_tax_rec.life_in_months_tax;
10674 x_ast_dtl_tbl(i).BASIC_RATE := null;
10675 x_ast_dtl_tbl(i).ADJUSTED_RATE := l_booking_tax_rec.deprn_rate_tax;
10676 If nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) <> OKL_API.G_MISS_CHAR and
10677 l_multi_gaap_yn = 'Y' and
10678 l_rep_pdt_book = l_booking_tax_rec.tax_book then
10679 x_ast_dtl_tbl(i).SALVAGE_VALUE := l_booking_corp_rec.salvage_value;
10680 x_ast_dtl_tbl(i).PERCENT_SALVAGE_VALUE := l_booking_corp_rec.percent_salvage_value;
10681 l_multi_gaap_book_done := 'Y';
10682 end if;
10683 x_ast_dtl_tbl(i).PRORATE_CONVENTION_CODE := l_fa_rec.prorate_convention_code;
10684 If (l_multi_GAAP_yn = 'N') OR
10685 (l_multi_GAAP_yn = 'Y' and nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) <> l_booking_tax_rec.tax_book) then
10686 x_ast_dtl_tbl(i).cost := l_fa_rec.cost;
10687
10688 ElsIf (l_multi_gaap_yn = 'Y') and nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) = l_booking_tax_rec.tax_book then
10689 If (l_rep_deal_type = 'LEASEOP') then
10690 --find out if new capitalized fee has been added
10691 x_ast_dtl_tbl(i).cost := l_fa_rec.cost ;
10692
10693 ElsIf l_rep_deal_type in ('LEASEST','LEASEDF') then
10694
10695 x_ast_dtl_tbl(i).cost := l_fa_rec.cost;
10696 x_ast_dtl_tbl(i).salvage_value := l_fa_rec.salvage_value;
10697 x_ast_dtl_tbl(i).percent_salvage_value := l_fa_rec.percent_salvage_value;
10698
10699 End If;
10700 End If;
10701 End Loop;
10702 close l_booking_tax_csr;
10703 --Bug# 4138635
10704 End If;
10705 --Mass rebook - created transaction type
10706
10707 --Bug# 6344223 : Included transaction type 'Split Asset'
10708 ElsIf (l_curr_trx_rec.transaction_type) in('Rebook', 'Split Asset') then
10709 --Bug# 6344223 Included tas_type 'ALI'
10710 If (l_curr_trx_rec.tas_type in('CRB','ALI')) and (l_curr_trx_rec.tal_type in('CRB','ALI')) then
10711 open l_mass_rebook_corp_csr(p_tal_id => l_curr_trx_rec.tal_id);
10712 Fetch l_mass_rebook_corp_csr into l_mass_rebook_corp_rec;
10713 If l_mass_rebook_corp_csr%NOTFOUND then
10714 --Bug# 4775166
10715 close l_mass_rebook_corp_csr;
10716 open l_clev_csr(p_cle_id => p_cle_id);
10717 fetch l_clev_csr into l_clev_rec;
10718 close l_clev_csr;
10719
10720 OKL_API.SET_MESSAGE(p_app_name => g_app_name,
10721 p_msg_name => 'OKL_LA_NO_CORP_BOOK_DFLTS',
10722 p_token1 => 'ASSET_NUMBER',
10723 p_token1_value => l_clev_rec.name
10724 );
10725 Raise OKL_API.G_EXCEPTION_ERROR;
10726 --Bug# 4775166
10727 End If;
10728 close l_mass_rebook_corp_csr;
10729
10730 l_method_id := null;
10731 If nvl(l_mass_rebook_corp_rec.life_in_months,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10732 open l_method_csr1(p_method_code => l_mass_rebook_corp_rec.deprn_method,
10733 p_life => l_mass_rebook_corp_rec.life_in_months);
10734 fetch l_method_csr1 into l_method_id;
10735 if l_method_csr1%NOTFOUND then
10736 null;
10737 end if;
10738 close l_method_csr1;
10739 ElsIf nvl(l_mass_rebook_corp_rec.deprn_rate,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10740 open l_method_csr2(p_method_code => l_mass_rebook_corp_rec.deprn_method,
10741 p_basic_rate => l_mass_rebook_corp_rec.deprn_rate,
10742 p_adj_rate => l_mass_rebook_corp_rec.deprn_rate);
10743 fetch l_method_csr2 into l_method_id;
10744 --Bug# 4775166
10745 if l_method_csr2%NOTFOUND then
10746 null;
10747 end if;
10748 close l_method_csr2;
10749 End If;
10750
10751 --fetch data from FA
10752 l_fa_rec := null;
10753 open l_fa_csr (p_asset_number => l_mass_rebook_corp_rec.asset_number,
10754 p_book => l_mass_rebook_corp_rec.corporate_book);
10755 fetch l_fa_csr into l_fa_rec;
10756 If l_fa_csr%NOTFOUND then
10757 --Raise error
10758 null;
10759 End If;
10760 close l_fa_csr;
10761
10762 i := 1;
10763
10764 x_ast_dtl_tbl(i).ASSET_NUMBER := l_mass_rebook_corp_rec.asset_number;
10765 x_ast_dtl_tbl(i).BOOK_TYPE_CODE := l_mass_rebook_corp_rec.corporate_book;
10766 x_ast_dtl_tbl(i).BOOK_CLASS := l_mass_rebook_corp_rec.book_class;
10767 x_ast_dtl_tbl(i).DEPRN_METHOD := l_mass_rebook_corp_rec.deprn_method;
10768 x_ast_dtl_tbl(i).DEPRN_METHOD_ID := l_method_id;
10769 x_ast_dtl_tbl(i).IN_SERVICE_DATE := nvl(l_mass_rebook_corp_rec.in_service_date,l_fa_rec.date_placed_in_service);
10770 x_ast_dtl_tbl(i).LIFE_IN_MONTHS := l_mass_rebook_corp_rec.life_in_months;
10771 x_ast_dtl_tbl(i).BASIC_RATE := null;
10772 x_ast_dtl_tbl(i).ADJUSTED_RATE := l_mass_rebook_corp_rec.deprn_rate;
10773 x_ast_dtl_tbl(i).SALVAGE_VALUE := nvl(l_mass_rebook_corp_rec.salvage_value,l_fa_rec.salvage_value);
10774 x_ast_dtl_tbl(i).PERCENT_SALVAGE_VALUE := nvl(l_mass_rebook_corp_rec.percent_salvage_value,l_fa_rec.percent_salvage_value);
10775 x_ast_dtl_tbl(i).PRORATE_CONVENTION_CODE := l_fa_rec.prorate_convention_code;
10776
10777 If x_ast_dtl_tbl(i).asset_number is not null and l_method_id is null Then
10778 --unable to resolve method from supplied deprn parameters
10779 x_ast_dtl_tbl(i).DEPRN_METHOD := l_fa_rec.deprn_method_code;
10780 x_ast_dtl_tbl(i).LIFE_IN_MONTHS := l_fa_rec.life_in_months;
10781 x_ast_dtl_tbl(i).BASIC_RATE := l_fa_Rec.basic_rate;
10782 x_ast_dtl_tbl(i).ADJUSTED_RATE := l_fa_rec.adjusted_rate;
10783 --get method id
10784 l_method_id := null;
10785 If nvl(l_fa_rec.life_in_months,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10786 open l_method_csr1(p_method_code => l_fa_rec.deprn_method_code,
10787 p_life => l_fa_rec.life_in_months);
10788 fetch l_method_csr1 into l_method_id;
10789 if l_method_csr1%NOTFOUND then
10790 null;
10791 end if;
10792 close l_method_csr1;
10793 ElsIf nvl(l_fa_rec.adjusted_rate,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10794 open l_method_csr2(p_method_code => l_fa_rec.deprn_method_code,
10795 p_basic_rate => l_fa_rec.basic_rate,
10796 p_adj_rate => l_fa_rec.adjusted_rate);
10797 fetch l_method_csr2 into l_method_id;
10798 --Bug# 4775166
10799 if l_method_csr2%NOTFOUND then
10800 null;
10801 end if;
10802 close l_method_csr2;
10803 End If;
10804 End If;
10805
10806 x_ast_dtl_tbl(i).DEPRN_METHOD_ID := l_method_id;
10807 x_ast_dtl_tbl(i).COST := l_fa_rec.cost;
10808
10809 --process tax_books
10810 open l_fa_csr2 (p_chr_id => p_chr_id,
10811 p_cle_id => p_cle_id);
10812 Loop
10813 fetch l_fa_csr2 into l_fa_rec2;
10814 Exit when l_fa_csr2%NOTFOUND ;
10815 If l_fa_rec2.book_class = 'TAX' then
10816 open l_mass_rebook_tax_csr(p_tal_id => l_curr_trx_rec.tal_id,
10817 p_category_id => l_fa_rec.asset_category_id,
10818 p_in_service_date => l_fa_rec.date_placed_in_service,
10819 p_book => l_fa_rec2.book_type_code);
10820
10821 fetch l_mass_rebook_tax_csr into l_mass_rebook_tax_rec;
10822 If l_mass_rebook_tax_csr%NOTFOUND then
10823 i := i + 1;
10824 x_ast_dtl_tbl(i).ASSET_NUMBER := l_fa_rec2.asset_number;
10825 x_ast_dtl_tbl(i).BOOK_TYPE_CODE := l_fa_rec2.book_type_code;
10826 x_ast_dtl_tbl(i).BOOK_CLASS := l_fa_rec2.book_class;
10827 x_ast_dtl_tbl(i).DEPRN_METHOD := l_fa_rec2.deprn_method_code;
10828 x_ast_dtl_tbl(i).IN_SERVICE_DATE := l_fa_rec2.date_placed_in_service;
10829 x_ast_dtl_tbl(i).LIFE_IN_MONTHS := l_fa_rec2.life_in_months;
10830 x_ast_dtl_tbl(i).BASIC_RATE := l_fa_rec2.basic_rate;
10831 x_ast_dtl_tbl(i).ADJUSTED_RATE := l_fa_rec2.adjusted_rate;
10832 x_ast_dtl_tbl(i).SALVAGE_VALUE := l_fa_rec2.salvage_value;
10833 x_ast_dtl_tbl(i).PERCENT_SALVAGE_VALUE := l_fa_rec2.percent_salvage_value;
10834 x_ast_dtl_tbl(i).PRORATE_CONVENTION_CODE := l_fa_rec2.prorate_convention_code;
10835 x_ast_dtl_tbl(i).COST := l_fa_rec2.cost;
10836 --get method id
10837 l_method_id := null;
10838 If nvl(l_fa_rec2.life_in_months,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10839 open l_method_csr1(p_method_code => l_fa_rec2.deprn_method_code,
10840 p_life => l_fa_rec2.life_in_months);
10841 fetch l_method_csr1 into l_method_id;
10842 if l_method_csr1%NOTFOUND then
10843 null;
10844 end if;
10845 close l_method_csr1;
10846 ElsIf nvl(l_fa_rec2.adjusted_rate,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10847 open l_method_csr2(p_method_code => l_fa_rec2.deprn_method_code,
10848 p_basic_rate => l_fa_rec2.basic_rate,
10849 p_adj_rate => l_fa_rec2.adjusted_rate);
10850 fetch l_method_csr2 into l_method_id;
10851 --Bug# 4775166
10852 if l_method_csr2%NOTFOUND then
10853 null;
10854 end if;
10855 close l_method_csr2;
10856 End If;
10857 x_ast_dtl_tbl(i).DEPRN_METHOD_ID := l_method_id;
10858
10859 ElsIf l_mass_rebook_tax_csr%FOUND then
10860 --get deprn method
10861 i := i + 1;
10862 l_method_id := null;
10863 If nvl(l_mass_rebook_tax_rec.life_in_months_tax,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10864 open l_method_csr1(p_method_code => l_mass_rebook_tax_rec.deprn_method_tax,
10865 p_life => l_mass_rebook_tax_rec.life_in_months_tax);
10866 fetch l_method_csr1 into l_method_id;
10867 if l_method_csr1%NOTFOUND then
10868 null;
10869 end if;
10870 close l_method_csr1;
10871 ElsIf nvl(l_mass_rebook_tax_rec.deprn_rate_tax,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10872 open l_method_csr2(p_method_code => l_mass_rebook_tax_rec.deprn_method_tax,
10873 p_basic_rate => l_mass_rebook_tax_rec.deprn_rate_tax,
10874 p_adj_rate => l_mass_rebook_tax_rec.deprn_rate_tax);
10875 fetch l_method_csr2 into l_method_id;
10876 --Bug# 4775166
10877 if l_method_csr2%NOTFOUND then
10878 null;
10879 end if;
10880 close l_method_csr2;
10881 End If;
10882
10883 x_ast_dtl_tbl(i).ASSET_NUMBER := l_mass_rebook_corp_rec.asset_number;
10884 x_ast_dtl_tbl(i).BOOK_TYPE_CODE := l_mass_rebook_tax_rec.tax_book;
10885 x_ast_dtl_tbl(i).BOOK_CLASS := l_mass_rebook_tax_rec.book_class;
10886 x_ast_dtl_tbl(i).DEPRN_METHOD := l_mass_rebook_tax_rec.deprn_method_tax;
10887 x_ast_dtl_tbl(i).DEPRN_METHOD_ID := l_method_id;
10888 x_ast_dtl_tbl(i).IN_SERVICE_DATE := nvl(l_mass_rebook_corp_rec.in_service_date,l_fa_rec2.date_placed_in_service);
10889 x_ast_dtl_tbl(i).LIFE_IN_MONTHS := l_mass_rebook_tax_rec.life_in_months_tax;
10890 x_ast_dtl_tbl(i).BASIC_RATE := null;
10891 x_ast_dtl_tbl(i).ADJUSTED_RATE := l_mass_rebook_tax_rec.deprn_rate_tax;
10892 x_ast_dtl_tbl(i).salvage_value := l_fa_rec2.salvage_value;
10893 x_ast_dtl_tbl(i).percent_salvage_value := l_fa_rec2.percent_salvage_value;
10894 x_ast_dtl_tbl(i).COST := l_fa_rec2.cost;
10895 If x_ast_dtl_tbl(i).asset_number is not null and l_method_id is null Then
10896 --unable to resolve method from supplied deprn parameters
10897 x_ast_dtl_tbl(i).DEPRN_METHOD := l_fa_rec2.deprn_method_code;
10898 x_ast_dtl_tbl(i).LIFE_IN_MONTHS := l_fa_rec2.life_in_months;
10899 x_ast_dtl_tbl(i).BASIC_RATE := l_fa_Rec2.basic_rate;
10900 x_ast_dtl_tbl(i).ADJUSTED_RATE := l_fa_rec2.adjusted_rate;
10901 --get method id
10902 l_method_id := null;
10903 If nvl(l_fa_rec.life_in_months,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10904 open l_method_csr1(p_method_code => l_fa_rec2.deprn_method_code,
10905 p_life => l_fa_rec2.life_in_months);
10906 fetch l_method_csr1 into l_method_id;
10907 if l_method_csr1%NOTFOUND then
10908 null;
10909 end if;
10910 close l_method_csr1;
10911 ElsIf nvl(l_fa_rec2.adjusted_rate,OKL_API.G_MISS_NUM) <> OKL_API.G_MISS_NUM then
10912 open l_method_csr2(p_method_code => l_fa_rec2.deprn_method_code,
10913 p_basic_rate => l_fa_rec2.basic_rate,
10914 p_adj_rate => l_fa_rec2.adjusted_rate);
10915 fetch l_method_csr2 into l_method_id;
10916 --Bug# 4775166
10917 if l_method_csr2%NOTFOUND then
10918 null;
10919 end if;
10920 close l_method_csr2;
10921 End If;
10922 End If;
10923 x_ast_dtl_tbl(i).DEPRN_METHOD_ID := l_method_id;
10924 End If;
10925 close l_mass_rebook_tax_csr;
10926 End If;
10927 End Loop;
10928 close l_fa_csr2;
10929 End If;
10930 End If;
10931 End If;
10932 OKL_API.END_ACTIVITY (x_msg_count,x_msg_data );
10933 EXCEPTION
10934 WHEN OKL_API.G_EXCEPTION_ERROR THEN
10935 If l_curr_trx_csr%ISOPEN then
10936 close l_curr_trx_csr;
10937 end if;
10938 If l_booking_corp_csr%ISOPEN then
10939 close l_booking_corp_csr;
10940 end if;
10941 if l_booking_tax_csr%ISOPEN then
10942 close l_booking_tax_csr;
10943 end if;
10944 if l_method_csr1%isopen then
10945 close l_method_csr1;
10946 end if;
10947 if l_method_csr2%isopen then
10948 close l_method_csr2;
10949 end if;
10950 if l_defaults_csr%isopen then
10951 close l_defaults_csr;
10952 end if;
10953 if l_chr_csr%isopen then
10954 close l_chr_csr;
10955 end if;
10956 if l_chk_mass_rbk_csr%isopen then
10957 close l_chk_mass_rbk_csr;
10958 end if;
10959 if l_fa_csr2%isopen then
10960 close l_fa_csr2;
10961 end if;
10962 if l_fa_csr%isopen then
10963 close l_fa_csr;
10964 end if;
10965 if l_mass_rebook_corp_csr%isopen then
10966 close l_mass_rebook_corp_csr;
10967 end if;
10968 if l_mass_rebook_tax_csr%isopen then
10969 close l_mass_rebook_tax_csr;
10970 end if;
10971 if l_clev_csr%isopen then
10972 close l_clev_csr;
10973 end if;
10974 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
10975 l_api_name,
10976 G_PKG_NAME,
10977 'OKL_API.G_RET_STS_ERROR',
10978 x_msg_count,
10979 x_msg_data,
10980 '_PVT');
10981 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
10982 If l_curr_trx_csr%ISOPEN then
10983 close l_curr_trx_csr;
10984 end if;
10985 If l_booking_corp_csr%ISOPEN then
10986 close l_booking_corp_csr;
10987 end if;
10988 if l_booking_tax_csr%ISOPEN then
10989 close l_booking_tax_csr;
10990 end if;
10991 if l_method_csr1%isopen then
10992 close l_method_csr1;
10993 end if;
10994 if l_method_csr2%isopen then
10995 close l_method_csr2;
10996 end if;
10997 if l_defaults_csr%isopen then
10998 close l_defaults_csr;
10999 end if;
11000 if l_chr_csr%isopen then
11001 close l_chr_csr;
11002 end if;
11003 if l_chk_mass_rbk_csr%isopen then
11004 close l_chk_mass_rbk_csr;
11005 end if;
11006 if l_fa_csr2%isopen then
11007 close l_fa_csr2;
11008 end if;
11009 if l_fa_csr%isopen then
11010 close l_fa_csr;
11011 end if;
11012 if l_mass_rebook_corp_csr%isopen then
11013 close l_mass_rebook_corp_csr;
11014 end if;
11015 if l_mass_rebook_tax_csr%isopen then
11016 close l_mass_rebook_tax_csr;
11017 end if;
11018 if l_clev_csr%isopen then
11019 close l_clev_csr;
11020 end if;
11021 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
11022 l_api_name,
11023 G_PKG_NAME,
11024 'OKL_API.G_RET_STS_UNEXP_ERROR',
11025 x_msg_count,
11026 x_msg_data,
11027 '_PVT');
11028 WHEN OTHERS THEN
11029 If l_curr_trx_csr%ISOPEN then
11030 close l_curr_trx_csr;
11031 end if;
11032 If l_booking_corp_csr%ISOPEN then
11033 close l_booking_corp_csr;
11034 end if;
11035 if l_booking_tax_csr%ISOPEN then
11036 close l_booking_tax_csr;
11037 end if;
11038 if l_method_csr1%isopen then
11039 close l_method_csr1;
11040 end if;
11041 if l_method_csr2%isopen then
11042 close l_method_csr2;
11043 end if;
11044 if l_defaults_csr%isopen then
11045 close l_defaults_csr;
11046 end if;
11047 if l_chr_csr%isopen then
11048 close l_chr_csr;
11049 end if;
11050 if l_chk_mass_rbk_csr%isopen then
11051 close l_chk_mass_rbk_csr;
11052 end if;
11053 if l_fa_csr2%isopen then
11054 close l_fa_csr2;
11055 end if;
11056 if l_fa_csr%isopen then
11057 close l_fa_csr;
11058 end if;
11059 if l_mass_rebook_corp_csr%isopen then
11060 close l_mass_rebook_corp_csr;
11061 end if;
11062 if l_mass_rebook_tax_csr%isopen then
11063 close l_mass_rebook_tax_csr;
11064 end if;
11065 if l_clev_csr%isopen then
11066 close l_clev_csr;
11067 end if;
11068 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
11069 l_api_name,
11070 G_PKG_NAME,
11071 'OTHERS',
11072 x_msg_count,
11073 x_msg_data,
11074 '_PVT');
11075
11076 END Get_Pricing_parameters;
11077
11078 --------------------------------------------------------------------------------
11079 --Start of Comments
11080 --Function Name : RECALCULATE_ASSET_COST Bug fix# 4899328
11081 --Description : Procedure to recalculate Asset Depreciable Cost on Rebook
11082 -- when there is a change to Capitalized Fee or Subsidy
11083 --
11084 --History :
11085 -- 05-Dec-2005 rpillay Created
11086 --
11087 --End of Comments
11088 --------------------------------------------------------------------------------
11089 Procedure recalculate_asset_cost ( p_api_version IN NUMBER,
11090 p_init_msg_list IN VARCHAR2 DEFAULT OKL_API.G_FALSE,
11091 x_return_status OUT NOCOPY VARCHAR2,
11092 x_msg_count OUT NOCOPY NUMBER,
11093 x_msg_data OUT NOCOPY VARCHAR2,
11094 p_chr_id IN NUMBER,
11095 p_cle_id IN NUMBER) is
11096
11097 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
11098 l_api_name CONSTANT varchar2(30) := 'RECALCULATE_ASSET_COST';
11099 l_api_version CONSTANT NUMBER := 1.0;
11100
11101 --cursor to check if the contract is undergoing on-line rebook
11102 cursor l_chk_rbk_csr(p_chr_id IN NUMBER) is
11103 SELECT '!'
11104 FROM okc_k_headers_b CHR,
11105 okl_trx_contracts ktrx
11106 WHERE ktrx.khr_id_new = chr.id
11107 AND ktrx.tsu_code = 'ENTERED'
11108 AND ktrx.rbr_code is NOT NULL
11109 AND ktrx.tcn_type = 'TRBK'
11110 --rkuttiya added for 12.1.1 Multi GAAP Project
11111 AND ktrx.representation_type = 'PRIMARY'
11112 --
11113 AND CHR.id = p_chr_id
11114 AND CHR.ORIG_SYSTEM_SOURCE_CODE = 'OKL_REBOOK';
11115
11116 l_rbk_khr VARCHAR2(1) DEFAULT '?';
11117
11118 --cursor to get transaction going on on this asset
11119 cursor l_curr_trx_csr(p_chr_id in number,
11120 p_cle_id in number) is
11121 select ttyt.name transaction_type,
11122 trx.tas_type,
11123 txl.tal_type,
11124 txl.id tal_id,
11125 trx.creation_date
11126 from okl_trx_types_tl ttyt,
11127 okl_trx_assets trx,
11128 okl_txl_assets_b txl,
11129 okc_k_lines_b cleb,
11130 okc_line_styles_b lseb
11131 where ttyt.id = trx.try_id
11132 and ttyt.language = 'US'
11133 and trx.id = txl.tas_id
11134 and trx.tsu_code = 'ENTERED'
11135 and txl.kle_id = cleb.id
11136 and cleb.cle_id = p_cle_id
11137 and cleb.dnz_chr_id = p_chr_id
11138 and cleb.lse_id = lseb.id
11139 and lseb.lty_code = 'FIXED_ASSET'
11140 order by trx.creation_date desc;
11141
11142 l_curr_trx_rec l_curr_trx_csr%ROWTYPE;
11143
11144 --cursor to get contract header details
11145 cursor l_chr_csr (p_chr_id in number) is
11146 select khr.pdt_id,
11147 khr.deal_type,
11148 chrb.start_date,
11149 rul.rule_information1
11150 from okc_rules_b rul,
11151 okc_rule_groups_b rgp,
11152 okl_k_headers khr,
11153 okc_k_headers_b chrb
11154 where rul.rule_information_category = 'LATOWN'
11155 and rul.rgp_id = rgp.id
11156 and rul.dnz_chr_id = rgp.dnz_chr_id
11157 and rgp.dnz_chr_id = chrb.id
11158 and rgp.chr_id = chrb.id
11159 and rgp.rgd_code = 'LATOWN'
11160 and khr.id = chrb.id
11161 and chrb.id = p_chr_id;
11162
11163 l_pdt_id number;
11164 l_start_date date;
11165 l_rep_pdt_id number;
11166 l_tax_owner okc_rules_b.rule_information_category%TYPE;
11167 l_deal_type okl_k_headers.deal_type%TYPE;
11168 l_rep_deal_type okl_k_headers.deal_type%TYPE;
11169 l_Multi_GAAP_YN varchar2(1);
11170
11171 cursor l_tax_book_csr(p_tal_id in number) is
11172 select txd.id,
11173 txd.tax_book
11174 from okl_txd_Assets_b txd
11175 where txd.tal_id = p_tal_id;
11176
11177 l_rep_pdt_book fa_books.book_type_code%TYPE;
11178
11179 cursor l_capital_cost_csr(p_fin_cle_id in number) IS
11180 select kle_fin.capital_amount
11181 from okc_k_lines_b cleb_fin,
11182 okl_k_lines kle_fin
11183 where cleb_fin.id = p_fin_cle_id
11184 and kle_fin.id = cleb_fin.id;
11185
11186 l_capital_amount okl_k_lines.capital_amount%TYPE;
11187
11188 l_talv_rec okl_txl_assets_pub.tlpv_rec_type;
11189 lx_talv_rec okl_txl_assets_pub.tlpv_rec_type;
11190 l_txdv_rec okl_txd_assets_pub.adpv_rec_type;
11191 lx_txdv_rec okl_txd_assets_pub.adpv_rec_type;
11192
11193 BEGIN
11194 x_return_status := OKL_API.G_RET_STS_SUCCESS;
11195
11196 -- Call start_activity to create savepoint, check compatibility
11197 -- and initialize message list
11198 x_return_status := OKL_API.START_ACTIVITY (
11199 l_api_name
11200 ,p_init_msg_list
11201 ,'_PVT'
11202 ,x_return_status);
11203 -- Check if activity started successfully
11204 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
11205 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
11206 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
11207 RAISE OKL_API.G_EXCEPTION_ERROR;
11208 END IF;
11209
11210 --check for rebook contract
11211 l_rbk_khr := '?';
11212 OPEN l_chk_rbk_csr (p_chr_id => p_chr_id);
11213 FETCH l_chk_rbk_csr INTO l_rbk_khr;
11214 CLOSE l_chk_rbk_csr;
11215
11216 If l_rbk_khr = '!' Then
11217
11218 -------------------------------------------------
11219 --1. Find out details of the current transactions
11220 -------------------------------------------------
11221
11222 For l_curr_trx_rec in l_curr_trx_csr(p_chr_id => p_chr_id,
11223 p_cle_id => p_cle_id) Loop
11224
11225 --cursor to get capital cost
11226 l_capital_amount := 0;
11227 open l_capital_cost_csr(p_fin_cle_id => p_cle_id);
11228 fetch l_capital_cost_csr into l_capital_amount;
11229 close l_capital_cost_csr;
11230
11231 --cursor to get contract detials :
11232 open l_chr_csr (p_chr_id => p_chr_id);
11233 fetch l_chr_csr into l_pdt_id,
11234 l_deal_type,
11235 l_start_date,
11236 l_tax_owner;
11237 close l_chr_csr;
11238
11239 -- Multi-GAAP Begin
11240 Get_Pdt_Params (p_api_version => p_api_version,
11241 p_init_msg_list => p_init_msg_list,
11242 x_return_status => x_return_status,
11243 x_msg_count => x_msg_count,
11244 x_msg_data => x_msg_data,
11245 p_pdt_id => l_pdt_id,
11246 p_pdt_date => l_start_date,
11247 x_rep_pdt_id => l_rep_pdt_id,
11248 x_tax_owner => l_tax_owner,
11249 x_rep_deal_type => l_rep_deal_type);
11250
11251 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
11252 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
11253 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
11254 RAISE OKL_API.G_EXCEPTION_ERROR;
11255 END IF;
11256
11257 l_Multi_GAAP_YN := 'N';
11258 --checks wheter Multi-GAAP processing needs tobe done
11259 If l_rep_pdt_id is not NULL Then
11260
11261 --Bug 7708944. SMEREDDY 01/15/2009.
11262 -- Implemented MG changes based on PM recommendation.
11263
11264 l_Multi_GAAP_YN := 'Y';
11265 /*
11266 If l_deal_type = 'LEASEOP' and
11267 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
11268 nvl(l_tax_owner,'X') = 'LESSOR' Then
11269 l_Multi_GAAP_YN := 'Y';
11270 End If;
11271
11272 If l_deal_type in ('LEASEDF','LEASEST') and
11273 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
11274 nvl(l_tax_owner,'X') = 'LESSOR' Then
11275 l_Multi_GAAP_YN := 'Y';
11276 End If;
11277
11278 If l_deal_type in ('LEASEDF','LEASEST') and
11279 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
11280 nvl(l_tax_owner,'X') = 'LESSEE' Then
11281 l_Multi_GAAP_YN := 'Y';
11282 End If;
11283
11284 If l_deal_type = 'LOAN' and
11285 nvl(l_rep_deal_type,'X') = 'LEASEOP' and
11286 nvl(l_tax_owner,'X') = 'LESSEE' Then
11287 l_Multi_GAAP_YN := 'Y';
11288 End If;
11289
11290 If l_deal_type = 'LEASEOP' and
11291 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
11292 nvl(l_tax_owner,'X') = 'LESSOR' Then
11293 l_Multi_GAAP_YN := 'Y';
11294 End If;
11295
11296 If l_deal_type in ('LEASEDF','LEASEST') and
11297 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
11298 nvl(l_tax_owner,'X') = 'LESSOR' Then
11299 l_Multi_GAAP_YN := 'Y';
11300 End If;
11301
11302 If l_deal_type in ('LEASEDF','LEASEST') and
11303 nvl(l_rep_deal_type,'X') in ('LEASEDF','LEASEST') and
11304 nvl(l_tax_owner,'X') = 'LESSEE' Then
11305 l_Multi_GAAP_YN := 'Y';
11306 End If;
11307 */
11308 End If;
11309
11310 If l_Multi_GAAP_YN = 'Y' Then
11311 --get reporting product book type
11312 l_rep_pdt_book := OKL_SYSTEM_PARAMS_ALL_PUB.get_system_param_value(OKL_SYSTEM_PARAMS_ALL_PUB.G_RPT_PROD_BOOK_TYPE_CODE);
11313 End If;
11314
11315 If (l_curr_trx_rec.transaction_type) = 'Internal Asset Creation' then
11316 --1. Online rebook new asset addition
11317 If (l_curr_trx_rec.tas_type = 'CFA') and (l_curr_trx_rec.tal_type = 'CFA') then
11318
11319 -- Update Depreciation_Cost in Okl_Txl_Assets_B to
11320 -- the calculated Line Capital Amount
11321 l_talv_rec.id := l_curr_trx_rec.tal_id;
11322 l_talv_rec.depreciation_cost := l_capital_amount;
11323
11324 OKL_TXL_ASSETS_PUB.update_txl_asset_def(
11325 p_api_version => p_api_version,
11326 p_init_msg_list => p_init_msg_list,
11327 x_return_status => x_return_status,
11328 x_msg_count => x_msg_count,
11329 x_msg_data => x_msg_data,
11330 p_tlpv_rec => l_talv_rec,
11331 x_tlpv_rec => lx_talv_rec);
11332
11333 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
11334 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
11335 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
11336 RAISE OKL_API.G_EXCEPTION_ERROR;
11337 END IF;
11338
11339 --process tax_books
11340 For l_tax_book_rec in l_tax_book_csr(p_tal_id => l_curr_trx_rec.tal_id)
11341 Loop
11342
11343 -- Update Cost in Okl_Txd_Assets to the calculated Line Capital Amount
11344 l_txdv_rec.id := l_tax_book_rec.id;
11345 l_txdv_rec.cost := l_capital_amount;
11346
11347 OKL_TXD_ASSETS_PUB.UPDATE_TXD_ASSET_DEF
11348 (p_api_version => p_api_version,
11349 p_init_msg_list => p_init_msg_list,
11350 x_return_status => x_return_status,
11351 x_msg_count => x_msg_count,
11352 x_msg_data => x_msg_data,
11353 p_adpv_rec => l_txdv_rec,
11354 x_adpv_rec => lx_txdv_rec);
11355
11356 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
11357 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
11358 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
11359 RAISE OKL_API.G_EXCEPTION_ERROR;
11360 END IF;
11361 End Loop;
11362
11363 --2. Online Rebook adjustments
11364 ElsIf (l_curr_trx_rec.tas_type = 'CRB') and (l_curr_trx_rec.tal_type = 'CRB') then
11365
11366 If l_deal_type in ('LEASEDF','LEASEST','LOAN') then
11367 -- Do not recalculate asset cost for DF/ST Lease and Loan
11368 NULL;
11369
11370 ElsIf l_deal_type = 'LEASEOP' Then
11371 -- Update Depreciation_Cost in Okl_Txl_Assets_B to
11372 -- the calculated Line Capital Amount
11373 l_talv_rec.id := l_curr_trx_rec.tal_id;
11374 l_talv_rec.depreciation_cost := l_capital_amount;
11375
11376 OKL_TXL_ASSETS_PUB.update_txl_asset_def(
11377 p_api_version => p_api_version,
11378 p_init_msg_list => p_init_msg_list,
11379 x_return_status => x_return_status,
11380 x_msg_count => x_msg_count,
11381 x_msg_data => x_msg_data,
11382 p_tlpv_rec => l_talv_rec,
11383 x_tlpv_rec => lx_talv_rec);
11384
11385 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
11386 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
11387 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
11388 RAISE OKL_API.G_EXCEPTION_ERROR;
11389 END IF;
11390 End If;
11391
11392 --process tax_books
11393 For l_tax_book_rec in l_tax_book_csr(p_tal_id => l_curr_trx_rec.tal_id)
11394 Loop
11395
11396 --Multi-Gaap Book
11397 If (l_multi_GAAP_yn = 'Y' and nvl(l_rep_pdt_book,OKL_API.G_MISS_CHAR) = l_tax_book_rec.tax_book) then
11398
11399 If l_rep_deal_type in ('LEASEDF','LEASEST','LOAN') then
11400 -- Do not recalculate asset cost for DF/ST Lease and Loan
11401 NULL;
11402
11403 ElsIf l_rep_deal_type = 'LEASEOP' then
11404
11405 -- Update Cost in Okl_Txd_Assets to the calculated Line Capital Amount
11406 l_txdv_rec.id := l_tax_book_rec.id;
11407 l_txdv_rec.cost := l_capital_amount;
11408
11409 OKL_TXD_ASSETS_PUB.UPDATE_TXD_ASSET_DEF
11410 (p_api_version => p_api_version,
11411 p_init_msg_list => p_init_msg_list,
11412 x_return_status => x_return_status,
11413 x_msg_count => x_msg_count,
11414 x_msg_data => x_msg_data,
11415 p_adpv_rec => l_txdv_rec,
11416 x_adpv_rec => lx_txdv_rec);
11417
11418 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
11419 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
11420 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
11421 RAISE OKL_API.G_EXCEPTION_ERROR;
11422 END IF;
11423
11424 End If;
11425
11426 -- Tax Books
11427 Else
11428
11429 If (l_deal_type = 'LOAN') OR
11430 (l_deal_type in ('LEASEST','LEASEDF') AND l_tax_owner = 'LESSEE') then
11431
11432 -- Do not recalculate asset cost for Loan and DF/ST Lease with Tax owner Lessee
11433 NULL;
11434 Else
11435
11436 -- Update Cost in Okl_Txd_Assets to the calculated Line Capital Amount
11437 l_txdv_rec.id := l_tax_book_rec.id;
11438 l_txdv_rec.cost := l_capital_amount;
11439
11440 OKL_TXD_ASSETS_PUB.UPDATE_TXD_ASSET_DEF
11441 (p_api_version => p_api_version,
11442 p_init_msg_list => p_init_msg_list,
11443 x_return_status => x_return_status,
11444 x_msg_count => x_msg_count,
11445 x_msg_data => x_msg_data,
11446 p_adpv_rec => l_txdv_rec,
11447 x_adpv_rec => lx_txdv_rec);
11448
11449 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
11450 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
11451 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
11452 RAISE OKL_API.G_EXCEPTION_ERROR;
11453 END IF;
11454
11455 End if;
11456 End if;
11457 End Loop;
11458
11459 End If;
11460 End If;
11461 End Loop;
11462 End If;
11463 OKL_API.END_ACTIVITY (x_msg_count,x_msg_data );
11464 EXCEPTION
11465 WHEN OKL_API.G_EXCEPTION_ERROR THEN
11466 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
11467 l_api_name,
11468 G_PKG_NAME,
11469 'OKL_API.G_RET_STS_ERROR',
11470 x_msg_count,
11471 x_msg_data,
11472 '_PVT');
11473 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
11474 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
11475 l_api_name,
11476 G_PKG_NAME,
11477 'OKL_API.G_RET_STS_UNEXP_ERROR',
11478 x_msg_count,
11479 x_msg_data,
11480 '_PVT');
11481 WHEN OTHERS THEN
11482 If l_chk_rbk_csr%ISOPEN then
11483 close l_chk_rbk_csr;
11484 end if;
11485 If l_capital_cost_csr%ISOPEN then
11486 close l_capital_cost_csr;
11487 end if;
11488 if l_chr_csr%ISOPEN then
11489 close l_chr_csr;
11490 end if;
11491 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
11492 l_api_name,
11493 G_PKG_NAME,
11494 'OTHERS',
11495 x_msg_count,
11496 x_msg_data,
11497 '_PVT');
11498
11499 END recalculate_asset_cost;
11500
11501 END OKL_ACTIVATE_ASSET_PVT;