1 PACKAGE BODY FA_REC_PVT_PKG3 AS
2 /* $Header: FAXVRC3B.pls 120.4.12010000.1 2008/07/28 13:20:31 appldev ship $ */
3
4 /*===================================================================================+
5 | FUNCTION Validate_Rule_Changes |
6 +====================================================================================*/
7
8 FUNCTION Validate_Rule_Changes(
9 p_asset_id IN NUMBER,
10 p_new_category_id IN NUMBER,
11 p_book_type_code IN VARCHAR2,
12 p_amortize_flag IN VARCHAR2,
13 p_old_rules IN FA_LOAD_TBL_PKG.asset_deprn_info,
14 p_new_rules IN FA_LOAD_TBL_PKG.asset_deprn_info,
15 x_prorate_date OUT NOCOPY DATE,
16 x_rate_source_rule OUT NOCOPY VARCHAR2,
17 x_deprn_basis_rule OUT NOCOPY VARCHAR2,
18 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) RETURN BOOLEAN IS
19 BEGIN
20 ---- Validate each new depreciation rule ----
21
22 /* Validate new depreciation ceiling. */
23 IF NOT Validate_Ceiling(
24 p_asset_id => p_asset_id,
25 p_book_type_code => p_book_type_code,
26 p_old_ceiling_name => p_old_rules.ceiling_name,
27 p_new_ceiling_name => p_new_rules.ceiling_name,
28 p_log_level_rec => p_log_level_rec)
29 THEN
30 FA_SRVR_MSG.Add_Message(
31 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Rule_Changes'
32 ,p_log_level_rec => p_log_level_rec);
33 RETURN (FALSE);
34 END IF;
35
36 /* Validate new depreciation flag. */
37 /* Skip this check -- we will not change depreciate flag through mass reclass.
38 IF NOT Validate_Deprn_Flag(
39 p_old_rules => p_old_rules,
40 p_new_rules => p_new_rules,
41 p_log_level_rec => p_log_level_rec)
42 THEN
43 FA_SRVR_MSG.Add_Message(
44 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Rule_Changes'
45 ,p_log_level_rec => p_log_level_rec);
46 RETURN (FALSE);
47 END IF;
48 */
49
50 /* Validate new prorate convention. */
51 IF NOT Validate_Convention(
52 p_asset_id => p_asset_id,
53 p_book_type_code => p_book_type_code,
54 p_date_placed_in_service => p_old_rules.start_dpis,
55 p_old_conv => p_old_rules.prorate_conv_code,
56 p_new_conv => p_new_rules.prorate_conv_code,
57 p_amortize_flag => p_amortize_flag,
58 x_prorate_date => x_prorate_date,
59 p_log_level_rec => p_log_level_rec)
60 THEN
61 FA_SRVR_MSG.Add_Message(
62 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Rule_Changes'
63 ,p_log_level_rec => p_log_level_rec);
64 RETURN (FALSE);
65 END IF;
66
67 /* Validate new depreciation method. */
68 -- p_old_rules.start_dpis and end_dpis store the current date placed in
69 -- service for the asset.
70 IF NOT Validate_Deprn_Method(
71 p_asset_id => p_asset_id,
72 p_book_type_code => p_book_type_code,
73 p_old_deprn_method => p_old_rules.deprn_method,
74 p_new_deprn_method => p_new_rules.deprn_method,
75 p_new_category_id => p_new_category_id,
76 x_rate_source_rule => x_rate_source_rule,
77 x_deprn_basis_rule => x_deprn_basis_rule,
78 p_log_level_rec => p_log_level_rec)
79 THEN
80 FA_SRVR_MSG.Add_Message(
81 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Rule_Changes'
82 ,p_log_level_rec => p_log_level_rec);
83 RETURN (FALSE);
84 END IF;
85
86 /* Validate new life and rates. */
87 IF NOT Validate_Life_Rates(
88 p_deprn_method => p_new_rules.deprn_method,
89 p_basic_rate => p_new_rules.basic_rate,
90 p_adjusted_rate => p_new_rules.adjusted_rate,
91 p_life_in_months => p_new_rules.life_in_months,
92 p_log_level_rec => p_log_level_rec)
93 THEN
94 FA_SRVR_MSG.Add_Message(
95 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Rule_Changes'
96 ,p_log_level_rec => p_log_level_rec);
97 RETURN (FALSE);
98 END IF;
99
100 RETURN (TRUE);
101 EXCEPTION
102 WHEN OTHERS THEN
103 FA_SRVR_MSG.Add_SQL_Error(
104 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Rule_Changes'
105 ,p_log_level_rec => p_log_level_rec);
106 RETURN (FALSE);
107 END Validate_Rule_Changes;
108
109
110 /*===================================================================================+
111 | FUNCTION Validate_Ceiling |
112 +====================================================================================*/
113
114 FUNCTION Validate_Ceiling(
115 p_asset_id IN NUMBER,
116 p_book_type_code IN VARCHAR2,
117 p_old_ceiling_name IN VARCHAR2,
118 p_new_ceiling_name IN VARCHAR2,
119 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) RETURN BOOLEAN IS
120 l_book_class VARCHAR2(15);
121 l_allow_cost_ceil VARCHAR2(3);
122 l_allow_deprn_exp_ceil VARCHAR2(3);
123 l_cost NUMBER;
124 l_itc_amount_id NUMBER(15);
125 l_new_ceiling_type VARCHAR2(30);
126 CURSOR get_book_info IS
127 SELECT book_class, allow_cost_ceiling, allow_deprn_exp_ceiling
128 FROM FA_BOOK_CONTROLS
129 WHERE book_type_code = p_book_type_code;
130 CURSOR get_ceiling_type IS
131 SELECT ceiling_type FROM FA_CEILING_TYPES
132 WHERE ceiling_name = p_new_ceiling_name;
133 CURSOR get_cost_itc IS
134 SELECT cost, itc_amount_id FROM FA_BOOKS
135 WHERE asset_id = p_asset_id and book_type_code = p_book_type_code
136 AND date_ineffective IS NULL;
137 BEGIN
138 -- Skip validation if rule remains the same or if new ceiling name
139 -- is null.
140 IF (nvl(p_old_ceiling_name, 'NULL')
141 = nvl(p_new_ceiling_name, 'NULL') OR
142 p_new_ceiling_name IS NULL) THEN
143 RETURN (TRUE);
144 END IF;
145
146 OPEN get_book_info;
147 FETCH get_book_info INTO l_book_class, l_allow_cost_ceil, l_allow_deprn_exp_ceil;
148 CLOSE get_book_info;
149
150 OPEN get_ceiling_type;
151 FETCH get_ceiling_type INTO l_new_ceiling_type;
152 CLOSE get_ceiling_type;
153
154 OPEN get_cost_itc;
155 FETCH get_cost_itc INTO l_cost, l_itc_amount_id;
156 CLOSE get_cost_itc;
157
158 IF (l_book_class IN ('BUDGET', 'CORPORATE') OR
159 l_cost <= 0) THEN
160 FA_SRVR_MSG.Add_Message(
161 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Ceiling',
162 NAME => 'FA_REC_CANNOT_SET_CEIL'
163 ,p_log_level_rec => p_log_level_rec);
164 /* Message text: 'You cannot set a depreciation ceiling for
165 an asset in a corporate or budget book or an asset with a
166 negative or zero cost.' */
167 RETURN (FALSE);
168 END IF;
169
170 IF (l_new_ceiling_type = 'RECOVERABLE COST CEILING') THEN
171 IF (l_allow_cost_ceil = 'NO') THEN
172 FA_SRVR_MSG.Add_Message(
173 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Ceiling',
174 NAME => 'FA_REC_NO_COST_CEIL'
175 ,p_log_level_rec => p_log_level_rec);
176 /* Message text:
177 'Cost ceiling is not allowed in this book.' */
178 RETURN (FALSE);
179 END IF;
180 ELSIF (l_new_ceiling_type = 'DEPRN EXPENSE CEILING') THEN
181 IF (l_allow_deprn_exp_ceil = 'NO') THEN
182 FA_SRVR_MSG.Add_Message(
183 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Ceiling',
184 NAME => 'FA_REC_NO_DEPRN_EXP_CEIL'
185 ,p_log_level_rec => p_log_level_rec);
186 /* Message text:
187 'Depreciation expense ceiling is not allowed in this book.' */
188 RETURN (FALSE);
189 END IF;
190 END IF;
191
192 /* You can use either a depreciation cost ceiling or ITC for an asset,
193 but not both. */
194 IF (l_itc_amount_id IS NOT NULL AND
195 l_new_ceiling_type = 'RECOVERABLE COST CEILING') THEN
196 FA_SRVR_MSG.Add_Message(
197 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Ceiling',
198 NAME => 'FA_BOOK_CANT_ITC_AND_COST_CEIL'
199 ,p_log_level_rec => p_log_level_rec);
200 RETURN (FALSE);
201 END IF;
202
203 RETURN (TRUE);
204 EXCEPTION
205 WHEN OTHERS THEN
206 FA_SRVR_MSG.Add_SQL_Error(
207 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Ceiling'
208 ,p_log_level_rec => p_log_level_rec);
209 RETURN (FALSE);
210 END Validate_Ceiling;
211
212
213 /*===================================================================================+
214 | FUNCTION Validate_Deprn_Flag |
215 +====================================================================================*/
216
217 FUNCTION Validate_Deprn_Flag(
218 p_old_rules IN FA_LOAD_TBL_PKG.asset_deprn_info,
219 p_new_rules IN FA_LOAD_TBL_PKG.asset_deprn_info,
220 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) RETURN BOOLEAN IS
221 CURSOR chk_deprn_flag IS
222 SELECT 'N'
223 FROM FA_METHODS mth
224 WHERE mth.method_code = p_old_rules.deprn_method
225 AND mth.rate_source_rule = 'PRODUCTION';
226 check_flag VARCHAR2(3);
227 BEGIN
228 -- Skip validation if rule remains the same.
229 IF (p_old_rules.depreciate_flag = p_new_rules.depreciate_flag) THEN
230 RETURN (TRUE);
231 END IF;
232
233 /* Other depreciation rules must remain the same, when changing the
234 Depreciate flag. */
235 IF NOT ((p_old_rules.prorate_conv_code = p_new_rules.prorate_conv_code) AND
236 (p_old_rules.deprn_method = p_new_rules.deprn_method) AND
237 (nvl(p_old_rules.life_in_months, 99999) =
238 nvl(p_new_rules.life_in_months, 99999)) AND
239 (nvl(p_old_rules.basic_rate, 99999) =
240 nvl(p_new_rules.basic_rate, 99999)) AND
241 (nvl(p_old_rules.adjusted_rate, 99999) =
242 nvl(p_new_rules.adjusted_rate, 99999)) AND
243 (nvl(p_old_rules.production_capacity, 99999) =
244 nvl(p_new_rules.production_capacity, 99999)) AND
245 (nvl(p_old_rules.unit_of_measure, 99999) =
246 nvl(p_new_rules.unit_of_measure, 99999)) AND
247 (nvl(p_old_rules.bonus_rule, 'NULL') =
248 nvl(p_new_rules.bonus_rule, 'NULL')) AND
249 (nvl(p_old_rules.ceiling_name, 'NULL') =
250 nvl(p_new_rules.ceiling_name, 'NULL')) AND
251 (nvl(p_old_rules.allow_deprn_limit, 99) =
252 nvl(p_new_rules.allow_deprn_limit, 99)) AND
253 (nvl(to_char(p_old_rules.deprn_limit_amount), 'NULL') =
254 nvl(to_char(p_new_rules.deprn_limit_amount), 'NULL')) AND
255 (nvl(p_old_rules.percent_salvage_value, 99) =
256 nvl(p_new_rules.percent_salvage_value, 99)))
257 THEN
258 FA_SRVR_MSG.Add_Message(
259 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Deprn_Flag',
260 NAME => 'FA_REC_NO_MULTIPLE_CHANGES'
261 ,p_log_level_rec => p_log_level_rec);
262 /* Message text: 'You cannot make more than one adjustment
263 upon changing the Depreciate flag.' */
264 RETURN (FALSE);
265 ELSE /* Other depreciation rules remain the same. */
266 /* You cannot set Depreciate flag to No for units of production
267 assets. */
268 IF (p_old_rules.depreciate_flag = 'YES' AND
269 p_new_rules.depreciate_flag = 'NO') THEN
270 OPEN chk_deprn_flag;
271 FETCH chk_deprn_flag INTO check_flag;
272 IF (chk_deprn_flag%found) THEN
273 CLOSE chk_deprn_flag;
274 FA_SRVR_MSG.Add_Message(
275 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Deprn_Flag',
276 NAME => 'FA_BOOK_INVALID_DEPRN_FLAG'
277 ,p_log_level_rec => p_log_level_rec);
278 RETURN (FALSE);
279 END IF;
280 CLOSE chk_deprn_flag;
281 END IF;
282 END IF;
283
284 RETURN (TRUE);
285 EXCEPTION
286 WHEN OTHERS THEN
287 FA_SRVR_MSG.Add_SQL_Error(
288 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Deprn_Flag'
289 ,p_log_level_rec => p_log_level_rec);
290 RETURN (FALSE);
291 END Validate_Deprn_Flag;
292
293
294 /*===================================================================================+
295 | FUNCTION Validate_Convention |
296 +====================================================================================*/
297
298 FUNCTION Validate_Convention(
299 p_asset_id IN NUMBER,
300 p_book_type_code IN VARCHAR2,
301 p_date_placed_in_service IN DATE,
302 p_old_conv IN VARCHAR2,
303 p_new_conv IN VARCHAR2,
304 p_amortize_flag IN VARCHAR2,
305 x_prorate_date OUT NOCOPY DATE,
306 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) RETURN BOOLEAN IS
307 l_dpis DATE;
308 l_prorate_date DATE;
309 check_flag VARCHAR2(3);
310 CURSOR get_prorate_date IS
311 SELECT conv.prorate_date
312 FROM FA_CONVENTIONS conv
313 WHERE conv.prorate_convention_code = p_new_conv
314 AND p_date_placed_in_service between conv.start_date and conv.end_date;
315 CURSOR check_prorate_date IS
316 SELECT 'x'
317 FROM FA_CALENDAR_PERIODS cp, FA_BOOK_CONTROLS bc
318 WHERE bc.book_type_code = p_book_type_code
319 AND bc.prorate_calendar = cp.calendar_type
320 AND l_prorate_date between cp.start_date and cp.end_date;
321 BEGIN
322
323 /* Get the prorate date. This will be used in Do_Redefault(). */
324 OPEN get_prorate_date;
325 FETCH get_prorate_date INTO l_prorate_date;
326 IF (get_prorate_date%notfound) THEN
327 CLOSE get_prorate_date;
328 FA_SRVR_MSG.Add_Message(
329 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Convention',
330 NAME => 'FA_BOOK_CANT_GEN_PRORATE_DATE'
331 ,p_log_level_rec => p_log_level_rec);
332 RETURN (FALSE);
333 END IF;
334 CLOSE get_prorate_date;
335
336 x_prorate_date := l_prorate_date;
337
338 -- Skip the rest of the validations if rule remains the same.
339 IF (p_old_conv = p_new_conv) THEN
340 RETURN (TRUE);
341 END IF;
342
343 /* Cannot amortize a prorate convention adjustment. */
344 -- Bug 1111642
345 -- IF (p_amortize_flag = 'YES') THEN
346 -- FA_SRVR_MSG.Add_Message(
347 -- CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Convention',
348 -- NAME => 'FA_CANNOT_AMORTIZE_PRORATE_CHE');
349 -- RETURN (FALSE);
350 -- END IF;
351
352 /* Check if the new prorate date is valid. */
353 OPEN check_prorate_date;
354 FETCH check_prorate_date INTO check_flag;
355 IF (check_prorate_date%notfound) THEN
356 CLOSE check_prorate_date;
357 FA_SRVR_MSG.Add_Message(
358 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Convention',
359 NAME => 'FA_BKS_INVALID_PRORATE_DATE'
360 ,p_log_level_rec => p_log_level_rec);
361 RETURN (FALSE);
362 END IF;
363 CLOSE check_prorate_date;
364
365 RETURN (TRUE);
366 EXCEPTION
367 WHEN OTHERS THEN
368 FA_SRVR_MSG.Add_SQL_Error(
369 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Convention'
370 ,p_log_level_rec => p_log_level_rec);
371 RETURN (FALSE);
372 END Validate_Convention;
373
374
375 /*===================================================================================+
376 | FUNCTION Validate_Deprn_Method |
377 +====================================================================================*/
378
379 FUNCTION Validate_Deprn_Method(
380 p_asset_id IN NUMBER,
381 p_book_type_code IN VARCHAR2,
382 p_old_deprn_method IN VARCHAR2,
383 p_new_deprn_method IN VARCHAR2,
384 p_new_category_id IN NUMBER,
385 x_rate_source_rule OUT NOCOPY VARCHAR2,
386 x_deprn_basis_rule OUT NOCOPY VARCHAR2,
387 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) RETURN BOOLEAN IS
388 l_new_rate_src_rule VARCHAR2(10);
389 l_new_deprn_basis_rule VARCHAR2(4);
390 l_itc_amount_id NUMBER(15);
391 l_conversion_date DATE;
392 l_depreciation_check VARCHAR2(3) := 'N';
393 -- Indicates whether depreciation has already been run
394 -- on the asset or not.
395 l_book_class VARCHAR2(15);
396 l_count NUMBER := 0;
397 check_flag VARCHAR2(3);
398 CURSOR check_method IS
399 SELECT 'N'
400 FROM FA_METHODS mth
401 WHERE l_depreciation_check = 'Y'
402 AND p_old_deprn_method = mth.method_code
403 AND mth.rate_source_rule <> 'PRODUCTION'
404 AND l_new_rate_src_rule = 'PRODUCTION';
405 CURSOR check_tax_book_method IS
406 SELECT 'x'
407 FROM FA_METHODS mth, FA_CATEGORY_BOOK_DEFAULTS cbd,
408 FA_BOOK_CONTROLS bc, FA_BOOKS bk
409 WHERE bc.distribution_source_book = p_book_type_code
410 AND bc.book_class = 'TAX'
411 AND bk.book_type_code = bc.book_type_code
412 AND bk.asset_id = p_asset_id
413 AND bk.date_ineffective IS NULL
414 AND bk.book_type_code = cbd.book_type_code
415 AND cbd.category_id = p_new_category_id
416 AND bk.date_placed_in_service between cbd.start_dpis
417 and nvl(cbd.end_dpis, to_date('31-12-4712', 'DD-MM-YYYY'))
418 AND cbd.deprn_method = mth.method_code
419 AND mth.rate_source_rule = 'PRODUCTION'
420 AND l_new_rate_src_rule <> 'PRODUCTION';
421 CURSOR check_corp_book_method IS
422 SELECT 'x'
423 FROM FA_METHODS corp_mth, FA_CATEGORY_BOOK_DEFAULTS cbd,
424 FA_BOOK_CONTROLS bc, FA_BOOKS bk
425 WHERE bc.book_type_code = p_book_type_code
426 AND bk.book_type_code = bc.distribution_source_book
427 AND bk.asset_id = p_asset_id
428 AND bk.date_ineffective IS NULL
429 AND bk.book_type_code = cbd.book_type_code
430 AND cbd.category_id = p_new_category_id
431 AND bk.date_placed_in_service between cbd.start_dpis
432 and nvl(cbd.end_dpis, to_date('31-12-4712', 'DD-MM-YYYY'))
433 AND cbd.deprn_method = corp_mth.method_code
434 AND corp_mth.rate_source_rule <> 'PRODUCTION'
435 AND l_new_rate_src_rule = 'PRODUCTION';
436 CURSOR get_rate_deprn_rules IS
437 SELECT rate_source_rule, deprn_basis_rule
438 FROM FA_METHODS
439 WHERE method_code = p_new_deprn_method;
440 /* cursor to get a book row for an asset */
441 CURSOR get_book_info IS
442 SELECT itc_amount_id, conversion_date
443 FROM FA_BOOKS
444 WHERE asset_id = p_asset_id AND book_type_code = p_book_type_code
445 AND date_ineffective IS NULL;
446 CURSOR get_book_class IS
447 SELECT book_class FROM FA_BOOK_CONTROLS
448 WHERE book_type_code = p_book_type_code;
449 /* cursor to validate depreciation method change for a
450 short-tax-year asset */
451 CURSOR check_short_tax IS
452 SELECT 'N'
453 FROM FA_DEPRN_SUMMARY ds, FA_METHODS mth
454 WHERE mth.method_code = p_old_deprn_method
455 AND mth.rate_source_rule = 'FORMULA'
456 AND ds.asset_id = p_asset_id
457 AND ds.book_type_code = p_book_type_code
458 AND ds.deprn_source_code = 'DEPRN' AND deprn_amount <> 0;
459 BEGIN
460 -- If old_deprn_method is 'JP_STL_EXTND' then do not allow the method change
461 if (p_old_deprn_method = 'JP-STL-EXTND') then
462 return (false);
463 end if;
464
465 -- Get new rate source rule and depreciation basis rule for the new
466 -- depreciation method.
467 OPEN get_rate_deprn_rules;
468 FETCH get_rate_deprn_rules INTO l_new_rate_src_rule, l_new_deprn_basis_rule;
469 CLOSE get_rate_deprn_rules;
470
471 x_rate_source_rule := l_new_rate_src_rule;
472 x_deprn_basis_rule := l_new_deprn_basis_rule;
473
474 -- Skip validation if rule remains the same.
475 IF (p_old_deprn_method = p_new_deprn_method) THEN
476 RETURN (TRUE);
477 END IF;
478
479 -- Get the asset's current book information.
480 OPEN get_book_info;
481 FETCH get_book_info INTO l_itc_amount_id, l_conversion_date;
482 CLOSE get_book_info;
483
484 -- Get the book class for the book being processed.
485 OPEN get_book_class;
486 FETCH get_book_class INTO l_book_class;
487 CLOSE get_book_class;
488
489 SELECT count(1) INTO l_count FROM FA_DEPRN_SUMMARY
490 WHERE book_type_code = p_book_type_code AND asset_id = p_asset_id
491 AND deprn_source_code = 'DEPRN' AND deprn_amount <> 0
492 AND rownum < 2;
493
494 IF (l_count > 0) THEN
495 l_depreciation_check := 'Y'; -- Asset has already been depreciated.
496 END IF;
497
498 /* You can assign ITC to assets that use a life-based depreciation method
499 only. */
500 IF (l_new_deprn_basis_rule = 'NBV' AND
501 l_new_rate_src_rule = 'FLAT' AND
502 l_itc_amount_id IS NOT NULL) THEN
503 FA_SRVR_MSG.Add_Message(
504 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Deprn_Method',
505 NAME => 'FA_BOOK_INVALID_METHOD'
506 ,p_log_level_rec => p_log_level_rec);
507 RETURN (FALSE);
508 END IF;
509
510 /* You cannot change to a production method after you run depreciation. */
511 OPEN check_method;
512 FETCH check_method INTO check_flag;
513 IF (check_method%found) THEN
514 CLOSE check_method;
515 FA_SRVR_MSG.Add_Message(
516 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Deprn_Method',
517 NAME => 'FA_BOOK_NO_CHANGE_TO_PROD'
518 ,p_log_level_rec => p_log_level_rec);
519 RETURN (FALSE);
520 END IF;
521 CLOSE check_method;
522
523 IF (l_book_class = 'CORPORATE') THEN
524 /* Production method must be used in a corporate book, if a production
525 method will be used in any of the associated tax books.
526 Check the new depreciation methods for the corporate book and the
527 associated tax books. */
528 OPEN check_tax_book_method;
529 FETCH check_tax_book_method INTO check_flag;
530 IF (check_tax_book_method%found) THEN
531 CLOSE check_tax_book_method;
532 FA_SRVR_MSG.Add_Message(
533 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Deprn_Method',
534 NAME => 'FA_REC_MUST_USE_UOP'
535 ,p_log_level_rec => p_log_level_rec);
536 /* Message text: 'Production method must be used in a
537 corporate book, if a production method will be used in
538 any of the associated tax books.' */
539 RETURN (FALSE);
540 END IF;
541 CLOSE check_tax_book_method;
542 ELSE /* TAX book */
543 /* Production method cannot be used in a tax book, if production method
544 will not be used in its associated corporate book.
545 Check the new depreciation methods for the corporate book and the
546 associated tax books. */
547 OPEN check_corp_book_method;
548 FETCH check_corp_book_method INTO check_flag;
549 IF (check_corp_book_method%found) THEN
550 CLOSE check_corp_book_method;
551 FA_SRVR_MSG.Add_Message(
552 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Deprn_Method',
553 NAME => 'FA_REC_CORP_NOT_UOP'
554 ,p_log_level_rec => p_log_level_rec);
555 /* Message text: 'Production method cannot be used in
556 a tax book, if production method will not be used in its
557 associated corporate book.' */
558 RETURN (FALSE);
559 END IF;
560 CLOSE check_corp_book_method;
561 END IF;
562
563 /* Depreciation method cannot be changed from a FORMULA method to
564 a non-FORMULA method for a short-tax-year asset, if depreciation
565 has already run. */
566 IF (l_conversion_date IS NOT NULL AND
567 l_new_rate_src_rule <> 'FORMULA') THEN
568 /* If an asset is a short-tax-year asset and if the new method is
569 not a FORMULA method
570 -- Use conversion_date as a measure of whether an asset
571 is a short-tax-year asset or not, since short_fiscal_year_flag
572 can be 'NO' for short-tax-year assets, after the first fiscal
573 year. */
574 OPEN check_short_tax;
575 FETCH check_short_tax INTO check_flag;
576 IF (check_short_tax%found) THEN
577 /* Old method was a FORMULA method, and asset has already depreciated,
578 and therefore depreciation method change is disallowed. */
579 CLOSE check_short_tax;
580 FA_SRVR_MSG.Add_Message(
581 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Deprn_Method',
582 NAME => 'FA_SHORT_TAX_METHOD'
583 ,p_log_level_rec => p_log_level_rec);
584 /* New message:
585 'Depreciation method cannot be changed from a formula-based
586 method to a non-formula-based method for an asset added in
587 a short fiscal year after depreciation has run.' */
588 RETURN (FALSE);
589 END IF;
590 CLOSE check_short_tax;
591 END IF;
592
593 RETURN (TRUE);
594 EXCEPTION
595 WHEN OTHERS THEN
596 FA_SRVR_MSG.Add_SQL_Error(
597 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Deprn_Method'
598 ,p_log_level_rec => p_log_level_rec);
599 RETURN (FALSE);
600 END Validate_Deprn_Method;
601
602
603 /*===================================================================================+
604 | FUNCTION Validate_Life_Rates |
605 +====================================================================================*/
606
607 FUNCTION Validate_Life_Rates(
608 p_deprn_method IN VARCHAR2,
609 p_basic_rate IN NUMBER,
610 p_adjusted_rate IN NUMBER,
611 p_life_in_months IN NUMBER,
612 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) RETURN BOOLEAN IS
613 check_flag VARCHAR2(3);
614 l_rate_src_rule VARCHAR2(10);
615 CURSOR check_rate IS
616 SELECT 'Y'
617 FROM FA_FLAT_RATES fr, FA_METHODS mth
618 WHERE mth.method_code = p_deprn_method
619 AND mth.life_in_months IS NULL
620 AND mth.method_id = fr.method_id
621 AND fr.basic_rate = p_basic_rate
622 AND fr.adjusted_rate = p_adjusted_rate;
623 CURSOR check_life IS
624 SELECT 'Y'
625 FROM FA_METHODS mth
626 WHERE mth.method_code = p_deprn_method
627 AND nvl(mth.life_in_months, 99999) = p_life_in_months;
628 CURSOR get_rate_src_rule IS
629 SELECT rate_source_rule FROM FA_METHODS
630 WHERE method_code = p_deprn_method;
631 BEGIN
632 -- Small validation unit. Just validate without checking whehter
633 -- change exists or not.
634
635 -- Get new rate source rule for the new depreciation method.
636 OPEN get_rate_src_rule;
637 FETCH get_rate_src_rule INTO l_rate_src_rule;
638 CLOSE get_rate_src_rule;
639
640 IF (l_rate_src_rule = 'FLAT') THEN
641 OPEN check_rate;
642 FETCH check_rate INTO check_flag;
643 IF (check_rate%notfound) THEN
644 CLOSE check_rate;
645 FA_SRVR_MSG.Add_Message(
646 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Life_Rates',
647 NAME => 'FA_SHARED_INVALID_METHOD_RATE'
648 ,p_log_level_rec => p_log_level_rec);
649 RETURN (FALSE);
650 END IF;
651 CLOSE check_rate;
652 ELSE
653 IF (l_rate_src_rule <> 'PRODUCTION') THEN
654 OPEN check_life;
655 FETCH check_life INTO check_flag;
656 IF (check_life%notfound) THEN
657 CLOSE check_life;
658 FA_SRVR_MSG.Add_Message(
659 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Life_Rates',
660 NAME => 'FA_SHARED_INVALID_METHOD_LIFE'
661 ,p_log_level_rec => p_log_level_rec);
662 RETURN (FALSE);
663 END IF;
664 CLOSE check_life;
665 END IF;
666 END IF;
667
668 RETURN (TRUE);
669 EXCEPTION
670 WHEN OTHERS THEN
671 FA_SRVR_MSG.Add_SQL_Error(
672 CALLING_FN => 'FA_REC_PVT_PKG3.Validate_Life_Rates'
673 ,p_log_level_rec => p_log_level_rec);
674 RETURN (FALSE);
675 END Validate_Life_Rates;
676
677
678 END FA_REC_PVT_PKG3;