33: SUBTYPE thpv_rec_type IS okl_trx_assets_pub.thpv_rec_type;
34: SUBTYPE tlpv_rec_type IS okl_txl_assets_pub.tlpv_rec_type;
35:
36:
37: l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
38: l_overall_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
39: l_record_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
40:
41:
34: SUBTYPE tlpv_rec_type IS okl_txl_assets_pub.tlpv_rec_type;
35:
36:
37: l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
38: l_overall_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
39: l_record_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
40:
41:
42: l_api_name CONSTANT VARCHAR2(30) := 'create_residual_value_trx';
35:
36:
37: l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
38: l_overall_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
39: l_record_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
40:
41:
42: l_api_name CONSTANT VARCHAR2(30) := 'create_residual_value_trx';
43: l_api_version CONSTANT NUMBER := 1;
118: -- End -- Check the contract term to allow RV updates.Bug# 7014234
119:
120: BEGIN
121:
122: l_record_status := OKL_API.G_RET_STS_SUCCESS;
123:
124: l_return_status := OKL_API.START_ACTIVITY(l_api_name,
125: G_PKG_NAME,
126: p_init_msg_list,
120: BEGIN
121:
122: l_record_status := OKL_API.G_RET_STS_SUCCESS;
123:
124: l_return_status := OKL_API.START_ACTIVITY(l_api_name,
125: G_PKG_NAME,
126: p_init_msg_list,
127: l_api_version,
128: p_api_version,
128: p_api_version,
129: '_PVT',
130: x_return_status);
131:
132: IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
133: RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
134: ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
135: RAISE OKL_API.G_EXCEPTION_ERROR;
136: END IF;
129: '_PVT',
130: x_return_status);
131:
132: IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
133: RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
134: ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
135: RAISE OKL_API.G_EXCEPTION_ERROR;
136: END IF;
137:
130: x_return_status);
131:
132: IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
133: RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
134: ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
135: RAISE OKL_API.G_EXCEPTION_ERROR;
136: END IF;
137:
138: SELECT SYSDATE INTO l_sysdate FROM dual;
131:
132: IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
133: RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
134: ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
135: RAISE OKL_API.G_EXCEPTION_ERROR;
136: END IF;
137:
138: SELECT SYSDATE INTO l_sysdate FROM dual;
139:
143: x_return_status => x_return_status,
144: x_try_id => l_try_id);
145:
146:
147: IF x_return_status <> OKL_API.G_RET_STS_SUCCESS THEN
148: -- Unable to find a transaction type for this transaction
149: OKL_API.set_message(p_app_name => 'OKL',
150: p_msg_name => 'OKL_AM_NO_TRX_TYPE_FOUND',
151: p_token1 => 'TRY_NAME',
145:
146:
147: IF x_return_status <> OKL_API.G_RET_STS_SUCCESS THEN
148: -- Unable to find a transaction type for this transaction
149: OKL_API.set_message(p_app_name => 'OKL',
150: p_msg_name => 'OKL_AM_NO_TRX_TYPE_FOUND',
151: p_token1 => 'TRY_NAME',
152: p_token1_value => 'Asset Residual Change');
153: RAISE OKC_API.G_EXCEPTION_ERROR;
160: -- loop thru the table of records receieved as input. For each record get the line item information from
161: -- cursor l_linesfullv_csr. Validate the input data and then create transaction header and transaction line records
162: -- in okl_trx_assets_v and okl_txl_assets_v
163: LOOP
164: IF p_assets_tbl(i).p_id IS NULL OR p_assets_tbl(i).p_id = OKL_API.G_MISS_NUM THEN
165: l_record_status := OKL_API.G_RET_STS_ERROR;
166: -- Line id is required
167: OKC_API.set_message( p_app_name => 'OKC',
168: p_msg_name => G_REQUIRED_VALUE,
161: -- cursor l_linesfullv_csr. Validate the input data and then create transaction header and transaction line records
162: -- in okl_trx_assets_v and okl_txl_assets_v
163: LOOP
164: IF p_assets_tbl(i).p_id IS NULL OR p_assets_tbl(i).p_id = OKL_API.G_MISS_NUM THEN
165: l_record_status := OKL_API.G_RET_STS_ERROR;
166: -- Line id is required
167: OKC_API.set_message( p_app_name => 'OKC',
168: p_msg_name => G_REQUIRED_VALUE,
169: p_token1 => G_COL_NAME_TOKEN,
171: ELSE
172: OPEN l_linesfullv_csr(p_assets_tbl(i).p_id) ;
173: FETCH l_linesfullv_csr INTO l_name, l_description, l_old_residual_value, l_oec, l_chr_id, l_contract_number;
174: IF l_linesfullv_csr%NOTFOUND THEN
175: l_record_status := OKL_API.G_RET_STS_ERROR;
176: -- Asset number is invalid
177: OKC_API.set_message( p_app_name => 'OKC',
178: p_msg_name => G_INVALID_VALUE,
179: p_token1 => G_COL_NAME_TOKEN,
185: CLOSE c_contract_date_csr;
186:
187: IF NOT (l_sysdate BETWEEN chr_rec.start_date AND chr_rec.end_date) THEN
188: l_icx_date_format := NVL(FND_PROFILE.VALUE('ICX_DATE_FORMAT_MASK'),'DD-MON-RRRR');
189: OKL_API.SET_MESSAGE(G_APP_NAME,
190: 'OKL_LLA_WRONG_TRX_DATE',
191: 'START_DATE',
192: TO_CHAR(chr_rec.start_date,l_icx_date_format),
193: 'END_DATE',
194: TO_CHAR(chr_rec.end_date,l_icx_date_format),
195: 'ASSET_NUMBER',
196: l_name
197: );
198: RAISE OKL_API.G_EXCEPTION_ERROR;
199: END IF;
200: -- End -- Check the contract term to allow RV updates.Bug# 7014234
201:
202: -- SECHAWLA 07-FEB-03 Bug # 2789656 : Moved the following validation here in the beginning of the code
205: FETCH l_assettrx_csr INTO l_count;
206: CLOSE l_assettrx_csr;
207:
208: IF l_count > 0 THEN
209: l_record_status := OKL_API.G_RET_STS_ERROR;
210: -- Asset failed because a pending salvage value writedown transaction already exists for the financial asset
211: OKL_API.set_message(
212: p_app_name => 'OKL',
213: p_msg_name => 'OKL_AM_RVW_TRX_EXISTS',
207:
208: IF l_count > 0 THEN
209: l_record_status := OKL_API.G_RET_STS_ERROR;
210: -- Asset failed because a pending salvage value writedown transaction already exists for the financial asset
211: OKL_API.set_message(
212: p_app_name => 'OKL',
213: p_msg_name => 'OKL_AM_RVW_TRX_EXISTS',
214: p_token1 => 'ASSET_NUMBER',
215: p_token1_value => l_name,
220: -- Check if an accepted termination quote exists for this line
221: OPEN l_quotes_csr(p_assets_tbl(i).p_id);
222: FETCH l_quotes_csr INTO l_name;
223: IF l_quotes_csr%FOUND THEN
224: l_record_status := OKL_API.G_RET_STS_ERROR;
225: -- Can not change Residual value for asset ASSET_NUMBER as an accepted termination quote exists for this asset.
226: OKL_API.set_message( p_app_name => 'OKL',
227: p_msg_name => 'OKL_AM_RVW_NOT_ALLOWED',
228: p_token1 => 'ASSET_NUMBER',
222: FETCH l_quotes_csr INTO l_name;
223: IF l_quotes_csr%FOUND THEN
224: l_record_status := OKL_API.G_RET_STS_ERROR;
225: -- Can not change Residual value for asset ASSET_NUMBER as an accepted termination quote exists for this asset.
226: OKL_API.set_message( p_app_name => 'OKL',
227: p_msg_name => 'OKL_AM_RVW_NOT_ALLOWED',
228: p_token1 => 'ASSET_NUMBER',
229: p_token1_value => l_name);
230:
227: p_msg_name => 'OKL_AM_RVW_NOT_ALLOWED',
228: p_token1 => 'ASSET_NUMBER',
229: p_token1_value => l_name);
230:
231: ELSIF p_assets_tbl(i).p_new_residual_value IS NULL OR p_assets_tbl(i).p_new_residual_value = OKL_API.G_MISS_NUM THEN
232:
233: l_record_status := OKL_API.G_RET_STS_ERROR;
234:
235: -- Asset failed because the new Residual Value is missing
229: p_token1_value => l_name);
230:
231: ELSIF p_assets_tbl(i).p_new_residual_value IS NULL OR p_assets_tbl(i).p_new_residual_value = OKL_API.G_MISS_NUM THEN
232:
233: l_record_status := OKL_API.G_RET_STS_ERROR;
234:
235: -- Asset failed because the new Residual Value is missing
236: OKL_API.set_message( p_app_name => 'OKL',
237: p_msg_name => 'OKL_AM_NO_NEW_RESIDUAL_VALUE',
232:
233: l_record_status := OKL_API.G_RET_STS_ERROR;
234:
235: -- Asset failed because the new Residual Value is missing
236: OKL_API.set_message( p_app_name => 'OKL',
237: p_msg_name => 'OKL_AM_NO_NEW_RESIDUAL_VALUE',
238: p_token1 => 'ASSET_NUMBER',
239: p_token1_value => l_name);
240:
239: p_token1_value => l_name);
240:
241: ELSIF p_assets_tbl(i).p_new_residual_value < 0 THEN
242:
243: l_record_status := OKL_API.G_RET_STS_ERROR;
244: -- Asset failed because the new Residual Value is negative
245: OKL_API.set_message( p_app_name => 'OKL',
246: p_msg_name => 'OKL_AM_NEGATIVE_RESIDUAL_VALUE',
247: p_token1 => 'ASSET_NUMBER',
241: ELSIF p_assets_tbl(i).p_new_residual_value < 0 THEN
242:
243: l_record_status := OKL_API.G_RET_STS_ERROR;
244: -- Asset failed because the new Residual Value is negative
245: OKL_API.set_message( p_app_name => 'OKL',
246: p_msg_name => 'OKL_AM_NEGATIVE_RESIDUAL_VALUE',
247: p_token1 => 'ASSET_NUMBER',
248: p_token1_value => l_name);
249:
247: p_token1 => 'ASSET_NUMBER',
248: p_token1_value => l_name);
249:
250: ELSIF l_old_residual_value IS NULL THEN
251: l_record_status := OKL_API.G_RET_STS_ERROR;
252: -- Asset failed because the old Residual Value is missing
253: OKL_API.set_message( p_app_name => 'OKL',
254: p_msg_name => 'OKL_AM_NO_OLD_RESIDUAL_VALUE',
255: p_token1 => 'ASSET_NUMBER',
249:
250: ELSIF l_old_residual_value IS NULL THEN
251: l_record_status := OKL_API.G_RET_STS_ERROR;
252: -- Asset failed because the old Residual Value is missing
253: OKL_API.set_message( p_app_name => 'OKL',
254: p_msg_name => 'OKL_AM_NO_OLD_RESIDUAL_VALUE',
255: p_token1 => 'ASSET_NUMBER',
256: p_token1_value => l_name);
257:
262: FETCH l_oklheaders_csr into l_legal_entity_id;
263: CLOSE l_oklheaders_csr;
264:
265: IF (l_legal_entity_id is null or l_legal_entity_id = OKC_API.G_MISS_NUM) THEN
266: l_record_status := OKL_API.G_RET_STS_ERROR;
267: OKL_API.SET_MESSAGE(p_app_name => g_app_name,
268: p_msg_name => g_required_value,
269: p_token1 => g_col_name_token,
270: p_token1_value => 'legal_entity_id');
263: CLOSE l_oklheaders_csr;
264:
265: IF (l_legal_entity_id is null or l_legal_entity_id = OKC_API.G_MISS_NUM) THEN
266: l_record_status := OKL_API.G_RET_STS_ERROR;
267: OKL_API.SET_MESSAGE(p_app_name => g_app_name,
268: p_msg_name => g_required_value,
269: p_token1 => g_col_name_token,
270: p_token1_value => 'legal_entity_id');
271: RAISE OKC_API.G_EXCEPTION_ERROR;
279: END IF;
280:
281: OKL_TRX_ASSETS_PUB.create_trx_ass_h_def(
282: p_api_version => p_api_version,
283: p_init_msg_list => OKL_API.G_FALSE,
284: x_return_status => l_record_status,
285: x_msg_count => x_msg_count,
286: x_msg_data => x_msg_data,
287: p_thpv_rec => lp_thpv_rec,
288: x_thpv_rec => lx_thpv_rec);
289:
290:
291:
292: IF l_record_status = OKL_API.G_RET_STS_SUCCESS THEN
293:
294: -- SECHAWLA Bug # 2726739 : Added the following piece of code
295:
296: -- get the functional currency
317: x_currency_conversion_rate => lx_currency_conversion_rate,
318: x_currency_conversion_date => lx_currency_conversion_date,
319: x_converted_amount => lx_converted_amount );
320:
321: IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
322: RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
323: ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
324: RAISE OKL_API.G_EXCEPTION_ERROR;
325: END IF;
318: x_currency_conversion_date => lx_currency_conversion_date,
319: x_converted_amount => lx_converted_amount );
320:
321: IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
322: RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
323: ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
324: RAISE OKL_API.G_EXCEPTION_ERROR;
325: END IF;
326:
319: x_converted_amount => lx_converted_amount );
320:
321: IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
322: RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
323: ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
324: RAISE OKL_API.G_EXCEPTION_ERROR;
325: END IF;
326:
327: lp_tlpv_rec.currency_conversion_type := lx_currency_conversion_type;
320:
321: IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
322: RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
323: ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
324: RAISE OKL_API.G_EXCEPTION_ERROR;
325: END IF;
326:
327: lp_tlpv_rec.currency_conversion_type := lx_currency_conversion_type;
328: lp_tlpv_rec.currency_conversion_rate := lx_currency_conversion_rate;
346: lp_tlpv_rec.dnz_khr_id := l_chr_id;
347:
348: OKL_TXL_ASSETS_PUB.create_txl_asset_def(
349: p_api_version => p_api_version,
350: p_init_msg_list => OKL_API.G_FALSE,
351: x_return_status => l_record_status,
352: x_msg_count => x_msg_count,
353: x_msg_data => x_msg_data,
354: p_tlpv_rec => lp_tlpv_rec,
356: END IF;
357:
358:
359: ELSIF p_assets_tbl(i).p_new_residual_value = l_old_residual_value THEN
360: l_record_status := OKL_API.G_RET_STS_ERROR;
361: -- Asset failed because the new Residual Value is same as the old value.
362: OKL_API.set_message( p_app_name => 'OKL',
363: p_msg_name => 'OKL_AM_SAME_RESIDUAL_VALUE',
364: p_token1 => 'ASSET_NUMBER',
358:
359: ELSIF p_assets_tbl(i).p_new_residual_value = l_old_residual_value THEN
360: l_record_status := OKL_API.G_RET_STS_ERROR;
361: -- Asset failed because the new Residual Value is same as the old value.
362: OKL_API.set_message( p_app_name => 'OKL',
363: p_msg_name => 'OKL_AM_SAME_RESIDUAL_VALUE',
364: p_token1 => 'ASSET_NUMBER',
365: p_token1_value => l_name);
366:
365: p_token1_value => l_name);
366:
367: ELSE -- new residual < old residual
368:
369: l_record_status := OKL_API.G_RET_STS_ERROR;
370: -- Asset failed because the new Residual Value is not lower than the old value.
371: OKL_API.set_message( p_app_name => 'OKL',
372: p_msg_name => 'OKL_AM_INVALID_RESIDUAL_VALUE',
373: p_token1 => 'ASSET_NUMBER',
367: ELSE -- new residual < old residual
368:
369: l_record_status := OKL_API.G_RET_STS_ERROR;
370: -- Asset failed because the new Residual Value is not lower than the old value.
371: OKL_API.set_message( p_app_name => 'OKL',
372: p_msg_name => 'OKL_AM_INVALID_RESIDUAL_VALUE',
373: p_token1 => 'ASSET_NUMBER',
374: p_token1_value => l_name);
375:
384: CLOSE l_linesfullv_csr;
385:
386: END IF;
387: -- If it reaches this point for the current record, that means x_return_status is SUCCESS
388: IF l_overall_status = OKL_API.G_RET_STS_SUCCESS THEN
389: IF l_record_status <> OKL_API.G_RET_STS_SUCCESS THEN
390: l_overall_status := OKL_API.G_RET_STS_ERROR;
391: END IF;
392: END IF;
385:
386: END IF;
387: -- If it reaches this point for the current record, that means x_return_status is SUCCESS
388: IF l_overall_status = OKL_API.G_RET_STS_SUCCESS THEN
389: IF l_record_status <> OKL_API.G_RET_STS_SUCCESS THEN
390: l_overall_status := OKL_API.G_RET_STS_ERROR;
391: END IF;
392: END IF;
393:
386: END IF;
387: -- If it reaches this point for the current record, that means x_return_status is SUCCESS
388: IF l_overall_status = OKL_API.G_RET_STS_SUCCESS THEN
389: IF l_record_status <> OKL_API.G_RET_STS_SUCCESS THEN
390: l_overall_status := OKL_API.G_RET_STS_ERROR;
391: END IF;
392: END IF;
393:
394:
398: x_return_status := l_overall_status;
399: END IF; -- p_assets_tbl.COUNT > 0
400:
401:
402: OKL_API.END_ACTIVITY(x_msg_count, x_msg_data);
403:
404: EXCEPTION
405: WHEN OKL_API.G_EXCEPTION_ERROR THEN
406: IF l_linesfullv_csr%ISOPEN THEN
401:
402: OKL_API.END_ACTIVITY(x_msg_count, x_msg_data);
403:
404: EXCEPTION
405: WHEN OKL_API.G_EXCEPTION_ERROR THEN
406: IF l_linesfullv_csr%ISOPEN THEN
407: CLOSE l_linesfullv_csr;
408: END IF;
409: IF l_assettrx_csr%ISOPEN THEN
412: IF l_quotes_csr%ISOPEN THEN
413: CLOSE l_quotes_csr;
414: END IF;
415:
416: x_return_status := OKL_API.HANDLE_EXCEPTIONS
417: (
418: l_api_name,
419: G_PKG_NAME,
420: 'OKL_API.G_RET_STS_ERROR',
416: x_return_status := OKL_API.HANDLE_EXCEPTIONS
417: (
418: l_api_name,
419: G_PKG_NAME,
420: 'OKL_API.G_RET_STS_ERROR',
421: x_msg_count,
422: x_msg_data,
423: '_PVT'
424: );
421: x_msg_count,
422: x_msg_data,
423: '_PVT'
424: );
425: WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
426: IF l_linesfullv_csr%ISOPEN THEN
427: CLOSE l_linesfullv_csr;
428: END IF;
429: IF l_assettrx_csr%ISOPEN THEN
431: END IF;
432: IF l_quotes_csr%ISOPEN THEN
433: CLOSE l_quotes_csr;
434: END IF;
435: x_return_status :=OKL_API.HANDLE_EXCEPTIONS
436: (
437: l_api_name,
438: G_PKG_NAME,
439: 'OKL_API.G_RET_STS_UNEXP_ERROR',
435: x_return_status :=OKL_API.HANDLE_EXCEPTIONS
436: (
437: l_api_name,
438: G_PKG_NAME,
439: 'OKL_API.G_RET_STS_UNEXP_ERROR',
440: x_msg_count,
441: x_msg_data,
442: '_PVT'
443: );
450: END IF;
451: IF l_quotes_csr%ISOPEN THEN
452: CLOSE l_quotes_csr;
453: END IF;
454: x_return_status :=OKL_API.HANDLE_EXCEPTIONS
455: (
456: l_api_name,
457: G_PKG_NAME,
458: 'OTHERS',