DBA Data[Home] [Help]

PACKAGE BODY: APPS.FA_FAS445_XMLP_PKG

Source


1 PACKAGE BODY FA_FAS445_XMLP_PKG AS
2 /* $Header: FAS445B.pls 120.0.12010000.1 2008/07/28 13:14:43 appldev ship $ */
3 function report_nameformula(Company_Name in varchar2) return varchar2 is
4 begin
5 DECLARE
6   l_report_name VARCHAR2(80);
7   l_conc_program_id NUMBER;
8 BEGIN
9 --Added during DT Fix
10 P_CONC_REQUEST_ID := fnd_global.CONC_REQUEST_ID;
11 --End of DT Fix
12   RP_Company_Name := Company_Name;
13   SELECT cr.concurrent_program_id
14   INTO l_conc_program_id
15   FROM FND_CONCURRENT_REQUESTS cr
16   WHERE cr.program_application_id = 140
17   AND   cr.request_id = P_CONC_REQUEST_ID;
18   SELECT cp.user_concurrent_program_name
19   INTO   l_report_name
20   FROM    FND_CONCURRENT_PROGRAMS_VL cp
21   WHERE
22       cp.concurrent_program_id= l_conc_program_id
23   and cp.application_id = 140;
24   l_report_name := substr(l_report_name,1,instr(l_report_name,' (XML)'));
25   RP_Report_Name := l_report_name;
26   RETURN(l_report_name);
27 EXCEPTION
28   WHEN OTHERS THEN
29     RP_Report_Name := 'Form 4797 - Gain from Disposition of 1250 Property Report';
30     RETURN('Form 4797 - Gain from Disposition of 1250 Property Report');
31 END;
32 RETURN NULL; end;
33 function BeforeReport return boolean is
34 begin
35 /*SRW.USER_EXIT('FND SRWINIT');*/null;
36   return (TRUE);
37 end;
38 function AfterReport return boolean is
39 begin
40 /*SRW.USER_EXIT('FND SRWEXIT');*/null;
41   return (TRUE);
42 end;
43 function Period1_PCFormula return Number is
44 begin
45 DECLARE
46   l_period_POD  DATE;
47   l_period_PCD  DATE;
48   l_period_PC   NUMBER(15);
49   l_period_FY   NUMBER(15);
50 BEGIN
51   SELECT period_counter,
52          period_open_date,
53          nvl(period_close_date, sysdate),
54          fiscal_year
55   INTO   l_period_PC,
56          l_period_POD,
57          l_period_PCD,
58          l_period_FY
59   FROM   FA_DEPRN_PERIODS
60   WHERE  book_type_code = P_BOOK
61   AND    period_name    = P_PERIOD1;
62   Period1_POD := l_period_POD;
63   Period1_PCD := l_period_PCD;
64   Period1_FY  := l_period_FY;
65   return(l_period_PC);
66 END;
67 RETURN NULL; end;
68 function Period2_PCFormula return Number is
69 begin
70 DECLARE
71   l_period_POD  DATE;
72   l_period_PCD  DATE;
73   l_period_PC   NUMBER(15);
74   l_period_FY   NUMBER(15);
75 BEGIN
76   SELECT period_counter,
77          period_open_date,
78          nvl(period_close_date, sysdate),
79          fiscal_year
80   INTO   l_period_PC,
81          l_period_POD,
82          l_period_PCD,
83          l_period_FY
84   FROM   FA_DEPRN_PERIODS
85   WHERE  book_type_code = P_BOOK
86   AND    period_name    = P_PERIOD2;
87   Period2_POD := l_period_POD;
88   Period2_PCD := l_period_PCD;
89   Period2_FY  := l_period_FY;
90   return(l_period_PC);
91 END;
92 RETURN NULL; end;
93 function PRECFormula return VARCHAR2 is
94 begin
95 DECLARE
96   l_precision NUMBER(15);
97 BEGIN
98   SELECT
99          cur.precision
100   INTO
101          l_precision
102   FROM   FA_BOOK_CONTROLS bc,
103          GL_SETS_OF_BOOKS sob,
104          FND_CURRENCIES cur
105   WHERE  bc.book_type_code = P_BOOK
106   AND    sob.set_of_books_id = bc.set_of_books_id
107   AND    sob.currency_code   = cur.currency_code;
108   Precision := l_precision;
109   fnd_profile.get('PRINT_DEBUG',print_debug);
110   return(l_precision);
111 END;
112 RETURN NULL; end;
113 function GAIN_NLSFormula return VARCHAR2 is
114 begin
115   DECLARE
116      l_meaning  VARCHAR2(80);
117   BEGIN
118     select MEANING
119     into   l_meaning
120     from   FA_LOOKUPS
121     where  LOOKUP_TYPE = 'GAINLOSS'
122     and    LOOKUP_CODE = 'GAIN';
123     return (l_meaning);
124     EXCEPTION
125       WHEN OTHERS THEN
126          return (null);
127   END;
128 RETURN NULL; end;
129 function LOSS_NLSFormula return VARCHAR2 is
130 begin
131   DECLARE
132      l_meaning  VARCHAR2(80);
133   BEGIN
134     select MEANING
135     into   l_meaning
136     from   FA_LOOKUPS
137     where  LOOKUP_TYPE = 'GAINLOSS'
138     and    LOOKUP_CODE = 'LOSS';
139     return (l_meaning);
140     EXCEPTION
141       WHEN OTHERS THEN
142          return (null);
143   END;
144 RETURN NULL; end;
145 function d_excess_1962formula(book in varchar2, asset_id in number, book_class in varchar2, cost in number, nbvr in number, gla in number, cgain in number, ord_inc in number) return number is
146   true_or_false number;
147   ret boolean;
148   h_calendar_type varchar2(30);
149   h_fy_name     varchar2(30);
150   h_prorate_fy  number;
151   h_cur_per_num number;
152   h_num_per_fy  number;
153   h_cur_fy      number;
154   h_prorate_start_year 	number;
155   dpr_in  fa_std_types.dpr_struct;
156   dpr_out fa_std_types.dpr_out_struct;
157   dpr_arr fa_std_types.dpr_arr_type;
158   X_BOOK 		varchar2(15);
159   X_ASSET_ID		number;
160   h_new_deprn_rsv    	number;
161   l_dpis		date;
162   l_deprn_rsv_1962 	number := 0;
163   l_diff_reserve 	number;
164 	h_dpr_date date;  	h_current_cost number; 	h_itc_amount_id number;	h_itc_basis 	number;	h_ceiling_Type  varchar2(50);
165 l_new_gain_loss 		number;
166 l_new_ordinary_income		number;
167 l_new_capital_gain		number;
168 l_reserve_retired	number;
169 l_stl_method_code		fa_retirements.stl_method_code%TYPE;
170 l_stl_life_in_months		fa_retirements.stl_life_in_months%TYPE;
171 l_stl_deprn_amount	number;
172 l_diff_stl 		number;
173 l_stl_deprn_reserve_1962	number := 0;
174 l_excess_deprn		number;
175 l_recap_gain 		number;
176 l_sec_1231_gain 	number;
177 l_life			number;
178 l_fraction_life		number;
179 l_date_retired		date;
180 l_date_retired_year	number;
181 l_ttcode		varchar2(20);
182 call_faxcde		boolean;
183 zero_excess_deprn	boolean := false;
184 before_1962		boolean := true;
185 l_main_dpis		date;
186 l_method_code		varchar2(12);
187 rakn			number := 0;
188 previous_y_end 		number;
189 previous_p_cl_end	number;
190 previous_end_date	date;
191 l_rate_source_rule	varchar2(10);
192 cursor c_rsr is
193   select rate_source_rule
194   from fa_methods
195   where method_code = l_method_code;
196 l_start_date 	date;
197 l_fiscal_year_name	varchar2(30);
198 cursor c_end is
199    	select period_num, cp.start_date, fiscal_year_name
200       	from fa_calendar_periods cp,
201 	   fa_book_controls bc
202       	where calendar_type = bc.deprn_calendar
203       	and bc.book_type_code = x_book
204       	and  start_date  >=  previous_end_date
205 	order by start_date;
206 cursor c_ret is
207 SELECT	decode (mt.rate_source_rule,
208 			'CALCULATED',	bk.prorate_date,
209                         'FORMULA',      bk.prorate_date,
210 			'TABLE',	bk.deprn_start_date,
211 			'FLAT',		decode (mt.deprn_basis_rule,
212 						'COST',	bk.prorate_date,
213 						'NBV',	bk.deprn_start_date),
214                         'PROD',         bk.date_placed_in_service),
215                 to_number (to_char (bk.prorate_date, 'J')),
216 		to_number (to_char (bk.date_placed_in_service, 'J')),
217                 to_number (to_char (bk.deprn_start_date, 'J')),
218 		nvl(bk.life_in_months, 0),
219 		bk.recoverable_cost,
220 		bk.adjusted_cost,
221 		bk.cost,
222                 nvl(bk.reval_amortization_basis, 0),
223 		bk.rate_adjustment_factor,
224 		nvl(bk.adjusted_rate, 0),
225 		bk.ceiling_name,
226 		bk.bonus_rule,
227                 nvl (bk.production_capacity, 0),
228                 nvl (bk.adjusted_capacity, 0),
229 		mt.method_code,
230 		ad.asset_number,
231                 nvl (bk.adjusted_recoverable_cost, bk.recoverable_cost),
232                 bk.salvage_value,
233 		bk.period_counter_life_complete,
234 		bk.annual_deprn_rounding_flag,
235 		bk.itc_amount_id,
236 		bk.itc_basis,
237 		ceilt.ceiling_type,
238                 nvl(bk.formula_factor, 1),
239                 nvl(bk.short_fiscal_year_flag, 'NO'),
240                 bk.conversion_date,
241                 bk.original_deprn_start_date,
242                 bk.prorate_date,
243 		to_number(to_char(bk.prorate_date,'YYYY')),
244 		bk.date_placed_in_service,
245 		ret.stl_method_code,
246 		ret.stl_life_in_months,
247 		ret.stl_deprn_amount,
248 		ret.date_retired,
249 		to_number(to_char(ret.date_retired,'YYYY')),
250 		th.transaction_type_code
251  FROM	fa_ceiling_types ceilt,
252 		fa_methods mt,
253 		fa_category_books cb,
254 		fa_books bk,
255 		fa_transaction_headers th,
256 		fa_retirements ret,
257 		fa_additions ad
258   WHERE	cb.book_type_code = X_book
259 	AND	ad.asset_category_id = cb.category_id
260 	AND	ceilt.ceiling_name(+) = bk.ceiling_name
261 	AND	mt.method_code = bk.deprn_method_code
262 	AND	bk.book_type_code = X_book
263 	AND	bk.asset_id = X_asset_id
264 	AND	bk.transaction_header_id_out = th.transaction_header_id
265 	AND  	th.transaction_type_code IN ('FULL RETIREMENT','PARTIAL RETIREMENT')
266 	AND	th.transaction_header_id = ret.transaction_header_id_in
267 	AND 	ret.status = 'PROCESSED'
268 	AND	nvl (mt.life_in_months, -9999) =
269 			nvl (bk.life_in_months, -9999)
270 	AND	ad.asset_id = bk.asset_id;
271 test_stl_deprn_amount		number;
272 BEGIN
273 if print_debug = 'Y' then
274       /*srw.message(9999,'Starting D_EXCESS_1962');*/null;
275       /*srw.message(9999,book);*/null;
276       /*srw.message(9999, asset_id);*/null;
277 end if;
278 X_BOOK := book;
279 x_asset_id := asset_id;
280 if book_class = 'TAX'  then
281   dpr_in.book		:= x_book;
282   dpr_in.asset_id	:= x_asset_id;
283  select deprn_reserve, ytd_deprn, bk.date_placed_in_service,
284 		bk.deprn_method_code
285   into dpr_in.deprn_rsv, dpr_in.ytd_deprn, l_main_dpis,
286 		l_method_code
287   from fa_deprn_summary ds,
288 	fa_books bk,
289 	fa_transaction_headers th
290   where ds.book_type_code = X_book
291   and   ds.asset_id = X_asset_id
292   and   ds.deprn_source_code = 'BOOKS'
293   and 	th.transaction_header_id = bk.transaction_header_id_in
294   and   th.transaction_header_id in (select max(transaction_header_id)
295 				from fa_transaction_headers thsub
296 				where transaction_type_code like '%RETIREMENT'
297 				and   book_type_code = x_book
298 				and   asset_id = x_asset_id)
299 ;
300   open c_rsr;
301   fetch c_rsr into l_rate_source_rule;
302   close c_rsr;
303  if l_main_dpis < to_date('19611231','YYYYMMDD')
304 	and l_rate_source_rule <> 'CALCULATED' then
305     true_or_false := 1;
306   dpr_in.reval_rsv		   	:= 0;
307   dpr_in.ltd_prod		   	:= 0;
308   dpr_in.old_adj_cost			:= 0;
309   dpr_in.prior_fy_exp 			:= 0;
310   dpr_in.reval_rsv 			:= 0;
311   dpr_in.ltd_prod 			:= 0;
312   select 	bc.deprn_calendar,
313 		bc.fiscal_year_name,
314 		ct.number_per_fiscal_year
315   into h_calendar_type, h_fy_name, h_num_per_fy
316   from fa_book_controls bc, fa_calendar_types ct
317   where bc.book_type_code = X_book
318   and bc.deprn_calendar = ct.calendar_type;
319   dpr_in.calendar_type := h_calendar_type;
320   dpr_in.jdate_retired := 0;
321   dpr_in.ret_prorate_jdate := 0;
322   dpr_in.rsv_known_flag := TRUE;
323   dpr_in.prior_fy_exp := 0;
324   dpr_in.used_by_adjustment:= FALSE;
325   dpr_in.deprn_override_flag := 'N';
326   OPEN C_RET;
327   FETCH C_RET
328   INTO	h_dpr_date,
329 		dpr_in.prorate_jdate,
330 		dpr_in.jdate_in_service,
331 		dpr_in.deprn_start_jdate,
332 		dpr_in.life,
333 		dpr_in.rec_cost,
334 		dpr_in.adj_cost,
335 		h_current_cost,
336 		dpr_in.reval_amo_basis,
337 		dpr_in.rate_adj_factor,
338 		dpr_in.adj_rate,
339 		dpr_in.ceil_name,
340 		dpr_in.bonus_rule,
341 		dpr_in.capacity,
342 		dpr_in.adj_capacity,
343 		dpr_in.method_code,
344 		dpr_in.asset_num,
345 		dpr_in.adj_rec_cost,
346 		dpr_in.salvage_value,
347 		dpr_in.pc_life_end,
348 		dpr_in.deprn_rounding_flag,
349 		h_itc_amount_id,
350 		h_itc_basis,
351 		h_ceiling_Type,
352                 dpr_in.formula_factor,
353                 dpr_in.short_fiscal_year_flag,
354                 dpr_in.conversion_date,
355                 dpr_in.orig_deprn_start_date,
356                 dpr_in.prorate_date,
357 		h_prorate_start_year,
358 		l_dpis,
359 		l_stl_method_code,
360 		l_stl_life_in_months,
361 		l_stl_deprn_amount,
362 		l_date_retired,
363 		l_date_retired_year,
364 		l_ttcode;
365   WHILE C_RET%FOUND AND BEFORE_1962 LOOP
366    if print_debug = 'Y' then
367 	/*srw.message(9999,dpr_in.adj_cost);*/null;
368 	/*srw.message(9999,dpr_in.rec_cost);*/null;
369 	/*srw.message(9999,h_current_cost);*/null;
370 	/*srw.message(9999,l_dpis);*/null;
371 	/*srw.message(9999, dpr_in.method_code);*/null;
372    end if;
373    rakn := rakn + 1;
374    if rakn = 1 then
375       dpr_in.y_begin :=  h_prorate_start_year;
376       select period_num
377       into dpr_in.p_cl_begin
378       from fa_calendar_periods cp,
379 	   fa_book_controls bc
380       where calendar_type = bc.deprn_calendar
381       and bc.book_type_code = x_book
382       and dpr_in.prorate_date
383 	between cp.start_date and cp.end_date;
384       if l_date_retired > to_date('19611231','YYYYMMDD') then
385 	dpr_in.y_end := 1961;
386    	select period_num
387       	into dpr_in.p_cl_end
388       	from fa_calendar_periods cp,
389 	   fa_book_controls bc
390       	where calendar_type = bc.deprn_calendar
391       	and bc.book_type_code = x_book
392       	and to_date('19611231','YYYYMMDD')
393 	between cp.start_date and cp.end_date;
394 	previous_end_date := to_date('19611231','YYYYMMDD');
395       else
396 	dpr_in.y_end := l_date_retired_year;
397    	select period_num
398       	into dpr_in.p_cl_end
399       	from fa_calendar_periods cp,
400 	   fa_book_controls bc
401       	where calendar_type = bc.deprn_calendar
402       	and bc.book_type_code = x_book
403       	and l_date_retired
404 	between cp.start_date and cp.end_date;
405 	previous_end_date := l_date_retired;
406       end if;
407       if print_debug = 'Y' then
408 	/*srw.message(rakn,'y_begin: ' || to_char(dpr_in.y_begin));*/null;
409 	/*srw.message(rakn,'y_end: ' || to_char(dpr_in.y_end));*/null;
410 	/*srw.message(rakn,'p_cl_begin: ' || to_char(dpr_in.p_cl_begin));*/null;
411 	/*srw.message(rakn,'p_cl_end: ' || to_char(dpr_in.p_cl_end));*/null;
412       end if;
413    else
414 	open c_end;
415 	fetch c_end into dpr_in.p_cl_begin, l_start_date, l_fiscal_year_name;
416 	if c_end%FOUND then
417 	   fetch c_end into dpr_in.p_cl_begin, l_start_date, l_fiscal_year_name;
418 	end if;
419 	close c_end;
420 	select fiscal_year
421 	into dpr_in.y_begin
422 	from fa_fiscal_year
423 	where fiscal_year_name = l_fiscal_year_name
424 	and l_start_date between start_date and end_date;
425       if l_date_retired >  to_date('19611231','YYYYMMDD') then
426 	dpr_in.y_end := 1961;
427    	select period_num
428       	into dpr_in.p_cl_end
429       	from fa_calendar_periods cp,
430 	   fa_book_controls bc
431       	where calendar_type = bc.deprn_calendar
432       	and bc.book_type_code = x_book
433       	and to_date('19611231','YYYYMMDD')
434 	between cp.start_date and cp.end_date;
435 	previous_end_date := to_date('19611231','YYYYMMDD');
436       else
437 	dpr_in.y_end := l_date_retired_year;
438    	select period_num
439       	into dpr_in.p_cl_end
440       	from fa_calendar_periods cp,
441 	   fa_book_controls bc
442       	where calendar_type = bc.deprn_calendar
443       	and bc.book_type_code = x_book
444       	and l_date_retired
445 	between cp.start_date and cp.end_date;
446 	previous_end_date := l_date_retired;
447       end if;
448       if print_debug = 'Y' then
449 	/*srw.message(rakn,'y_begin: ' || to_char(dpr_in.y_begin));*/null;
450 	/*srw.message(rakn,'y_end: ' || to_char(dpr_in.y_end));*/null;
451 	/*srw.message(rakn,'p_cl_begin: ' || to_char(dpr_in.p_cl_begin));*/null;
452 	/*srw.message(rakn,'p_cl_end: ' || to_char(dpr_in.p_cl_end));*/null;
453       end if;
454    end if;
455   dpr_in.bonus_deprn_exp         := 0;
456   dpr_in.bonus_ytd_deprn	 := 0;
457   dpr_in.bonus_deprn_rsv	 := 0;
458   dpr_in.prior_fy_bonus_exp	 := 0;
459    if not fa_cache_pkg.fazcbc(X_book => X_book) then
460      true_or_false := 0;
461      /*srw.message(9999,'fazcbc returned FALSE');*/null;
462    end if;
463    if print_debug = 'Y' then
464 	/*srw.message(9999,'Calling faxcde first time');*/null;
465    end if;
466     ret := fa_cde_pkg.faxcde (
467 	dpr_in => dpr_in,
468 	dpr_arr => dpr_arr,
469 	dpr_out => dpr_out,
470 	fmode => 1);
471     if (ret = FALSE) then
472       /*srw.message(9999,'faxcde-first returned FALSE');*/null;
473     true_or_false := 0;
474     end if;
475     h_new_deprn_rsv := dpr_out.new_deprn_rsv;
476     l_deprn_rsv_1962 := l_deprn_rsv_1962 + round(h_new_deprn_rsv,precision);
477     if print_debug = 'Y' then
478        /*srw.message(9999,dpr_out.new_deprn_rsv);*/null;
479        /*srw.message(9999,dpr_out.new_adj_cost);*/null;
480        /*srw.message(9991, 'deprn_rsv_1962: ' || to_char(l_deprn_rsv_1962));*/null;
481     end if;
482     if print_debug = 'Y' then
483        /*srw.message(9991, 'stl_method_code: ' ||  l_stl_method_code );*/null;
484        /*srw.message(9991, 'stl_deprn_amount ' ||  l_stl_deprn_amount);*/null;
485     end if;
486     if l_stl_method_code is not null and nvl(l_stl_deprn_amount,0) <> 0 then
487       dpr_in.method_code := l_stl_method_code;
488       dpr_in.life 	 := l_stl_life_in_months;
489       l_fraction_life := months_between(to_date('19611231','YYYYMMDD'), l_dpis);
490       if l_fraction_life < l_stl_life_in_months then
491 	call_faxcde := true;
492       else
493 	call_faxcde := false;
494       end if;
495     else
496       if print_debug = 'Y' then
497         /*srw.message(9993,'null excess_deprn due to no fa_ret.stl_deprn_amount');*/null;
498       end if;
499       zero_excess_deprn := true;
500       call_faxcde := false;
501     end if;
502     if call_faxcde then
503       dpr_in.adj_cost := dpr_in.rec_cost;
504       if print_debug = 'Y' then
505          /*srw.message(9999,'adj_cost: ' || to_char(dpr_in.adj_cost));*/null;
506          /*srw.message(9999,'rec_cost: ' || to_char(dpr_in.rec_cost));*/null;
507          /*srw.message(9999,'Calling faxcde 2nd time');*/null;
508       end if;
509       ret := fa_cde_pkg.faxcde (
510 		dpr_in => dpr_in,
511 		dpr_arr => dpr_arr,
512 		dpr_out => dpr_out,
513 		fmode => 1);
514       if (ret = FALSE) then
515         /*srw.message(9999,'faxcde-second returned FALSE');*/null;
516         true_or_false := 0;
517       end if;
518 	      l_stl_deprn_reserve_1962 := l_stl_deprn_reserve_1962 + round(dpr_out.new_deprn_rsv, precision);
519      else
520        l_stl_deprn_reserve_1962 :=  l_stl_deprn_reserve_1962 + nvl(l_stl_deprn_amount,0);
521        if print_debug = 'Y' then
522          /*srw.message(9999,'faxcde 2nd not called');*/null;
523        end if;
524      end if;
525      if print_debug = 'Y' then
526          /*srw.message(9994, nvl(l_stl_deprn_reserve_1962,0));*/null;
527      end if;
528     if l_date_retired > to_date('19611231','YYYYMMDD') then
529 	before_1962 := false;
530     end if;
531     FETCH C_RET
532     INTO	h_dpr_date,
533 		dpr_in.prorate_jdate,
534 		dpr_in.jdate_in_service,
535 		dpr_in.deprn_start_jdate,
536 		dpr_in.life,
537 		dpr_in.rec_cost,
538 		dpr_in.adj_cost,
539 		h_current_cost,
540 		dpr_in.reval_amo_basis,
541 		dpr_in.rate_adj_factor,
542 		dpr_in.adj_rate,
543 		dpr_in.ceil_name,
544 		dpr_in.bonus_rule,
545 		dpr_in.capacity,
546 		dpr_in.adj_capacity,
547 		dpr_in.method_code,
548 		dpr_in.asset_num,
549 		dpr_in.adj_rec_cost,
550 		dpr_in.salvage_value,
551 		dpr_in.pc_life_end,
552 		dpr_in.deprn_rounding_flag,
553 		h_itc_amount_id,
554 		h_itc_basis,
555 		h_ceiling_Type,
556                 dpr_in.formula_factor,
557                 dpr_in.short_fiscal_year_flag,
558                 dpr_in.conversion_date,
559                 dpr_in.orig_deprn_start_date,
560                 dpr_in.prorate_date,
561 		h_prorate_start_year,
562 		l_dpis,
563 		l_stl_method_code,
564 		l_stl_life_in_months,
565 		l_stl_deprn_amount,
566 		l_date_retired,
567 		l_date_retired_year,
568 		l_ttcode;
569     END LOOP;
570     close c_ret;
571     if true_or_false = 1 then         l_reserve_retired := nvl(cost,0) - nvl(nbvr,0);
572         l_diff_reserve := l_reserve_retired - l_deprn_rsv_1962;
573 	l_diff_stl := nvl(l_stl_deprn_amount,0) - l_stl_deprn_reserve_1962;
574 	if print_debug = 'Y' then
575            /*srw.message(9992,'cost: ' || to_char(cost));*/null;
576            /*srw.message(9992,'nbvr: ' || to_char(nbvr));*/null;
577            /*srw.message(9992, nvl(l_stl_deprn_reserve_1962,0));*/null;
578           /*srw.message(9992, nvl(l_stl_deprn_amount,0));*/null;
579            /*srw.message(9992,'reserve_retired: ' || to_char(l_reserve_retired));*/null;
580            /*srw.message(9992,'diff_reserve: ' || to_char(l_diff_reserve));*/null;
581            /*srw.message(9994,'diff_stl: ' || to_char(l_diff_stl));*/null;
582         end if;
583   	if zero_excess_deprn then
584 	  l_excess_deprn := 0;
585 	else
586           l_excess_deprn := l_diff_reserve - l_diff_stl;
587           if l_excess_deprn <= 0 then
588 		l_excess_deprn := 0;
589        	  end if;
590 	end if;
591 	if print_debug = 'Y' then
592            /*srw.message(9995,'excess_deprn: ' || to_char(l_excess_deprn));*/null;
593         end if;
594 	l_recap_gain := round((l_reserve_retired - l_deprn_rsv_1962 - l_excess_deprn) * 0.2, precision);
595         if print_debug = 'Y' then
596            /*srw.message(9996,'excess_1969: ' || to_char(p_excess_1969_hide));*/null;
597 	end if;
598 	l_new_ordinary_income := least((nvl(gla,0) ), (p_excess_1969_hide + l_recap_gain));
599 	l_sec_1231_gain := gla - l_new_ordinary_income;
600 	if print_debug = 'Y' then
601             /*srw.message(9997,'new_ordinary_income: ' || to_char(l_new_ordinary_income));*/null;
602             /*srw.message(9996,'recap_gain: ' || to_char(l_recap_gain));*/null;
603             /*srw.message(9998,'gain_limitation: ' || to_char(gla) );*/null;
604             /*srw.message(9998,'sec_1231_gain: ' || to_char(l_sec_1231_gain));*/null;
605         end if;
606        	p_section_1231_gain_1962 := l_sec_1231_gain;
607 	p_ordinary_income_1962 := l_new_ordinary_income;
608      else          p_section_1231_gain_1962 := cgain;
609         p_ordinary_income_1962 := ord_inc;
610      end if;
611   else
612     p_section_1231_gain_1962 := cgain;
613     p_ordinary_income_1962 := ord_inc;
614     true_or_false  := 0;
615     if print_debug = 'Y' then
616         /*srw.message(7777, 'Not in dpis range and not a stl-asset');*/null;
617         /*srw.message(9997,l_rate_source_rule);*/null;
618         /*srw.message(9997, l_main_dpis);*/null;
619     end if;
620   end if;
621 else
622    p_section_1231_gain_1962 := cgain;
623    p_ordinary_income_1962 := ord_inc;
624    true_or_false  := 0;
625    if print_debug = 'Y' then
626      /*srw.message(8888, 'Not a Tax book');*/null;
627    end if;
628 end if;
629 RETURN(true_or_false);
630 end;
631 --function d_excess_1969formula(book in varchar2, asset_id in number, book_class in varchar2, xcess in number) return number is
632 function d_excess_1969formula(book in varchar2, asset_id in number, book_class in varchar2, xcess in number, cost in number, nbvr in number) return number is
633  true_or_false number;
634   ret boolean;
635   h_calendar_type varchar2(30);
636   h_fy_name     varchar2(30);
637   h_prorate_fy  number;
638   h_cur_per_num number;
639   h_num_per_fy  number;
640   h_cur_fy      number;
641   h_prorate_start_year 	number;
642   dpr_in  fa_std_types.dpr_struct;
643   dpr_out fa_std_types.dpr_out_struct;
644   dpr_arr fa_std_types.dpr_arr_type;
645   X_BOOK 		varchar2(15);
646   X_ASSET_ID		number;
647   h_new_deprn_rsv    	number;
648   l_dpis		date;
649   l_deprn_rsv_1969 	number := 0;
650   l_diff_reserve 	number;
651 	h_dpr_date date;  	h_current_cost number; 	h_itc_amount_id number;	h_itc_basis 	number;	h_ceiling_Type  varchar2(50);
652 l_new_gain_loss 		number;
653 l_new_ordinary_income		number;
654 l_new_capital_gain		number;
655 l_reserve_retired	number;
656 l_stl_deprn_amount	number := 0;
657 l_stl_method_code	fa_retirements.stl_method_code%TYPE;
658 l_stl_life_in_months	fa_retirements.stl_life_in_months%TYPE;
659 l_diff_stl 		number;
660 l_stl_deprn_reserve_1969	number := 0;
661 l_excess_deprn		number;
662 l_recap_gain 		number;
663 l_sec_1231_gain 	number;
664 l_life			number;
665 l_fraction_life		number;
666 l_date_retired		date;
667 l_date_retired_year	number;
668 l_ttcode		varchar2(20);
669 l_main_dpis		date;
670 l_method_code		varchar2(12);
671 call_faxcde		boolean;
672 zero_excess_deprn	boolean := false;
673 BEFORE_1969		boolean := true;
674 rakn			number := 0;
675 previous_y_end 		number;
676 previous_p_cl_end	number;
677 previous_end_date 	date;
678 l_rate_source_rule	varchar2(10);
679 cursor c_rsr is
680   select rate_source_rule
681   from fa_methods
682   where method_code = l_method_code;
683 l_start_date 		date;
684 l_fiscal_year_name	varchar2(30);
685 cursor c_end is
686    	select period_num, cp.start_date, fiscal_year_name
687       	from fa_calendar_periods cp,
688 	   fa_book_controls bc
689       	where calendar_type = bc.deprn_calendar
690       	and bc.book_type_code = x_book
691       	and  start_date  >=  previous_end_date
692 	order by start_date;
693 cursor c_ret is
694  SELECT	decode (mt.rate_source_rule,
695 			'CALCULATED',	bk.prorate_date,
696                         'FORMULA',      bk.prorate_date,
697 			'TABLE',	bk.deprn_start_date,
698 			'FLAT',		decode (mt.deprn_basis_rule,
699 						'COST',	bk.prorate_date,
700 						'NBV',	bk.deprn_start_date),
701                         'PROD',         bk.date_placed_in_service),
702                 to_number (to_char (bk.prorate_date, 'J')),
703 		to_number (to_char (bk.date_placed_in_service, 'J')),
704                 to_number (to_char (bk.deprn_start_date, 'J')),
705 		nvl(bk.life_in_months, 0),
706 		bk.recoverable_cost,
707 		bk.adjusted_cost,
708 		bk.cost,
709                 nvl(bk.reval_amortization_basis, 0),
710 		bk.rate_adjustment_factor,
711 		nvl(bk.adjusted_rate, 0),
712 		bk.ceiling_name,
713 		bk.bonus_rule,
714                 nvl (bk.production_capacity, 0),
715                 nvl (bk.adjusted_capacity, 0),
716 		mt.method_code,
717 		ad.asset_number,
718                 nvl (bk.adjusted_recoverable_cost, bk.recoverable_cost),
719                 bk.salvage_value,
720 		bk.period_counter_life_complete,
721 		bk.annual_deprn_rounding_flag,
722 		bk.itc_amount_id,
723 		bk.itc_basis,
724 		ceilt.ceiling_type,
725                 nvl(bk.formula_factor, 1),
726                 nvl(bk.short_fiscal_year_flag, 'NO'),
727                 bk.conversion_date,
728                 bk.original_deprn_start_date,
729                 bk.prorate_date,
730 		to_number(to_char(bk.prorate_date,'YYYY')),
731 		bk.date_placed_in_service,
732 		ret.stl_method_code,
733 		ret.stl_life_in_months,
734 		ret.stl_deprn_amount,
735 		ret.date_retired,
736 		to_number(to_char(ret.date_retired,'YYYY')),
737 		th.transaction_type_code
738   FROM	fa_ceiling_types ceilt,
739 		fa_methods mt,
740 		fa_category_books cb,
741 		fa_books bk,
742 		fa_transaction_headers th,
743 		fa_retirements ret,
744 		fa_additions ad
745   WHERE	cb.book_type_code = X_book
746 	AND	ad.asset_category_id = cb.category_id
747 	AND	ceilt.ceiling_name(+) = bk.ceiling_name
748 	AND	mt.method_code = bk.deprn_method_code
749 	AND	bk.book_type_code = X_book
750 	AND	bk.asset_id = X_asset_id
751 	AND	bk.transaction_header_id_out = th.transaction_header_id
752 	AND  	th.transaction_type_code IN ('FULL RETIREMENT','PARTIAL RETIREMENT')
753 	AND	th.transaction_header_id = ret.transaction_header_id_in
754 	AND 	ret.status = 'PROCESSED'
755 	AND	nvl (mt.life_in_months, -9999) =
756 			nvl (bk.life_in_months, -9999)
757 	AND	ad.asset_id = bk.asset_id;
758 test_stl_deprn_amount 	fa_retirements.stl_deprn_amount%TYPE;
759 test_stl_method_code 	fa_retirements.stl_method_code%TYPE;
760 BEGIN
761 if print_debug = 'Y' then
762   /*srw.message(9999,'Starting D_EXCESS_1969');*/null;
763   /*srw.message(9999,book);*/null;
764   /*srw.message(9999, asset_id);*/null;
765 end if;
766   X_BOOK := book;
767   x_asset_id := asset_id;
768   dpr_in.book		:= x_book;
769   dpr_in.asset_id	:= x_asset_id;
770   select deprn_reserve, ytd_deprn, bk.date_placed_in_service,
771 		bk.deprn_method_code, ret.stl_deprn_amount, ret.stl_method_code
772   into dpr_in.deprn_rsv, dpr_in.ytd_deprn, l_main_dpis,
773 		l_method_code, test_stl_deprn_amount, test_stl_method_code
774   from fa_deprn_summary ds,
775 	fa_books bk,
776 	fa_retirements ret,
777 	fa_transaction_headers th
778   where ds.book_type_code = X_book
779   and   ds.asset_id = X_asset_id
780   and   ds.deprn_source_code = 'BOOKS'
781   and 	th.transaction_header_id = bk.transaction_header_id_in
782   and   th.transaction_header_id = ret.transaction_header_id_in
783   and   th.transaction_header_id in (select max(transaction_header_id)
784 				from fa_transaction_headers thsub
785 				where transaction_type_code like '%RETIREMENT'
786 				and   book_type_code = x_book
787 				and   asset_id = x_asset_id)
788 ;
789   if nvl(test_stl_deprn_amount,0)  <> 0 then
790   if book_class = 'TAX'  then
791   open c_rsr;
792   fetch c_rsr into l_rate_source_rule;
793   close c_rsr;
794  if l_main_dpis < to_date('19691231','YYYYMMDD')
795 	and l_rate_source_rule <> 'CALCULATED' then
796      true_or_false := 1;
797   dpr_in.reval_rsv		   	:= 0;
798   dpr_in.ltd_prod		   	:= 0;
799   dpr_in.old_adj_cost			:= 0;
800   dpr_in.prior_fy_exp 			:= 0;
801   dpr_in.reval_rsv 			:= 0;
802   dpr_in.ltd_prod 			:= 0;
803   select 	bc.deprn_calendar,
804 		bc.fiscal_year_name,
805 		ct.number_per_fiscal_year
806   into h_calendar_type, h_fy_name, h_num_per_fy
807   from fa_book_controls bc, fa_calendar_types ct
808   where bc.book_type_code = X_book
809   and bc.deprn_calendar = ct.calendar_type;
810   dpr_in.calendar_type := h_calendar_type;
811   dpr_in.jdate_retired := 0;
812   dpr_in.ret_prorate_jdate := 0;
813   dpr_in.rsv_known_flag := TRUE;
814   dpr_in.prior_fy_exp := 0;
815   dpr_in.used_by_adjustment:= FALSE;
816   dpr_in.deprn_override_flag := 'N';
817   OPEN C_RET;
818   FETCH C_RET
819   INTO	h_dpr_date,
820 		dpr_in.prorate_jdate,
821 		dpr_in.jdate_in_service,
822 		dpr_in.deprn_start_jdate,
823 		dpr_in.life,
824 		dpr_in.rec_cost,
825 		dpr_in.adj_cost,
826 		h_current_cost,
827 		dpr_in.reval_amo_basis,
828 		dpr_in.rate_adj_factor,
829 		dpr_in.adj_rate,
830 		dpr_in.ceil_name,
831 		dpr_in.bonus_rule,
832 		dpr_in.capacity,
833 		dpr_in.adj_capacity,
834 		dpr_in.method_code,
835 		dpr_in.asset_num,
836 		dpr_in.adj_rec_cost,
837 		dpr_in.salvage_value,
838 		dpr_in.pc_life_end,
839 		dpr_in.deprn_rounding_flag,
840 		h_itc_amount_id,
841 		h_itc_basis,
842 		h_ceiling_Type,
843                 dpr_in.formula_factor,
844                 dpr_in.short_fiscal_year_flag,
845                 dpr_in.conversion_date,
846                 dpr_in.orig_deprn_start_date,
847                 dpr_in.prorate_date,
848 		h_prorate_start_year,
849 		l_dpis,
850 		l_stl_method_code,
851 		l_stl_life_in_months,
852 		l_stl_deprn_amount,
853 		l_date_retired,
854 		l_date_retired_year,
855 		l_ttcode;
856   WHILE C_RET%FOUND AND BEFORE_1969 LOOP
857    if print_debug = 'Y' then
858     /*srw.message(9999,dpr_in.adj_cost);*/null;
859     /*srw.message(9999,dpr_in.rec_cost);*/null;
860     /*srw.message(9999,h_current_cost);*/null;
861     /*srw.message(9999,l_dpis);*/null;
862     /*srw.message(9999, dpr_in.method_code);*/null;
863    end if;
864    rakn := rakn + 1;
865    if rakn = 1 then
866       dpr_in.y_begin :=  h_prorate_start_year;
867       select period_num
868       into dpr_in.p_cl_begin
869       from fa_calendar_periods cp,
870 	   fa_book_controls bc
871       where calendar_type = bc.deprn_calendar
872       and bc.book_type_code = x_book
873       and dpr_in.prorate_date
874 	between cp.start_date and cp.end_date;
875       if l_date_retired > to_date('19691231','YYYYMMDD') then
876 	dpr_in.y_end := 1969;
877    	select period_num
878       	into dpr_in.p_cl_end
879       	from fa_calendar_periods cp,
880 	   fa_book_controls bc
881       	where calendar_type = bc.deprn_calendar
882       	and bc.book_type_code = x_book
883       	and to_date('19691231','YYYYMMDD')
884 	between cp.start_date and cp.end_date;
885         previous_end_date :=   to_date('19691231','YYYYMMDD');
886       else
887 	dpr_in.y_end := l_date_retired_year;
888    	select period_num
889       	into dpr_in.p_cl_end
890       	from fa_calendar_periods cp,
891 	   fa_book_controls bc
892       	where calendar_type = bc.deprn_calendar
893       	and bc.book_type_code = x_book
894       	and l_date_retired
895 	between cp.start_date and cp.end_date;
896 	previous_end_date :=  l_date_retired;
897       end if;
898    else
899 	open c_end;
900 	fetch c_end into dpr_in.p_cl_begin, l_start_date, l_fiscal_year_name;
901 	if c_end%FOUND then
902 	  fetch c_end into dpr_in.p_cl_begin, l_start_date, l_fiscal_year_name;
903 	end if;
904 	close c_end;
905 	select fiscal_year
906 	into dpr_in.y_begin
907 	from fa_fiscal_year
908 	where fiscal_year_name = l_fiscal_year_name
909 	and l_start_date between start_date and end_date;
910       if l_date_retired >  to_date('19691231','YYYYMMDD') then
911 	dpr_in.y_end := 1969;
912    	select period_num
913       	into dpr_in.p_cl_end
914       	from fa_calendar_periods cp,
915 	   fa_book_controls bc
916       	where calendar_type = bc.deprn_calendar
917       	and bc.book_type_code = x_book
918       	and to_date('19691231','YYYYMMDD')
919 	between cp.start_date and cp.end_date;
920         previous_end_date :=  to_date('19691231','YYYYMMDD');
921       else
922 	dpr_in.y_end := l_date_retired_year;
923    	select period_num
924       	into dpr_in.p_cl_end
925       	from fa_calendar_periods cp,
926 	   fa_book_controls bc
927       	where calendar_type = bc.deprn_calendar
928       	and bc.book_type_code = x_book
929       	and l_date_retired
930 	between cp.start_date and cp.end_date;
931         previous_end_date := l_date_retired;
932       end if; 	if print_debug = 'Y' then
933  	 /*srw.message(rakn,'y_begin: ' || to_char(dpr_in.y_begin));*/null;
934  	 /*srw.message(rakn,'y_end: ' || to_char(dpr_in.y_end));*/null;
935  	 /*srw.message(9999,'p_cl_begin: ' || to_char(dpr_in.p_cl_begin));*/null;
936  	 /*srw.message(9999,'p_cl_end: ' || to_char(dpr_in.p_cl_end));*/null;
937 	end if;
938    end if;
939   dpr_in.bonus_deprn_exp         := 0;
940   dpr_in.bonus_ytd_deprn	 := 0;
941   dpr_in.bonus_deprn_rsv	 := 0;
942   dpr_in.prior_fy_bonus_exp	 := 0;
943    if not fa_cache_pkg.fazcbc(X_book => X_book) then
944      true_or_false := 0;
945      /*srw.message(9999,'fazcbc returned FALSE');*/null;
946    end if;
947    if print_debug = 'Y' then
948     /*srw.message(9999,'adj_cost: ' || to_char(dpr_in.adj_cost));*/null;
949     /*srw.message(9999,'rec_cost: ' || to_char(dpr_in.rec_cost));*/null;
950     /*srw.message(9999,'Calling faxcde first time');*/null;
951    end if;
952     ret := fa_cde_pkg.faxcde (
953 	dpr_in => dpr_in,
954 	dpr_arr => dpr_arr,
955 	dpr_out => dpr_out,
956 	fmode => 1);
957     if (ret = FALSE) then
958       /*srw.message(9999,'faxcde-first returned FALSE');*/null;
959       true_or_false := 0;
960     end if;
961     h_new_deprn_rsv := dpr_out.new_deprn_rsv;
962     if print_debug = 'Y' then
963        /*srw.message(9999,dpr_out.new_deprn_rsv);*/null;
964     end if;
965     l_deprn_rsv_1969 := l_deprn_rsv_1969 + round(h_new_deprn_rsv,precision);
966     if print_debug = 'Y' then
967        /*srw.message(9991, 'deprn_rsv_1969: ' ||  to_char(l_deprn_rsv_1969));*/null;
968                          /*srw.message(9991, 'stl_method_code: ' ||  l_stl_method_code );*/null;
969        /*srw.message(9991, 'stl_deprn_amount ' ||  l_stl_deprn_amount);*/null;
970      end if;
971     if l_stl_method_code is not null and nvl(l_stl_deprn_amount,0) <> 0 then
972       dpr_in.method_code := l_stl_method_code;
973       dpr_in.life 	 := l_stl_life_in_months;
974       l_fraction_life := months_between(to_date('19691231','YYYYMMDD'), l_dpis);
975       if l_fraction_life < l_stl_life_in_months then
976         call_faxcde := true;
977       else
978         call_faxcde := false;
979       end if;
980     else
981       if print_debug = 'Y' then
982         /*srw.message(9993,'null excess_deprn due to no fa_ret.stl_deprn_amount');*/null;
983       end if;
984       zero_excess_deprn := true;
985       true_or_false := 0;
986       call_faxcde := false;
987     end if;
988     if call_faxcde then
989 	dpr_in.adj_rate := '';
990         dpr_in.adj_cost := dpr_in.rec_cost;
991 	if print_debug = 'Y' then
992 	  /*srw.message(9999,'adj_cost: ' || to_char(dpr_in.adj_cost));*/null;
993 	  /*srw.message(9999,'rec_cost: ' || to_char(dpr_in.rec_cost));*/null;
994 	  /*srw.message(rakn,'y_begin: ' || to_char(dpr_in.y_begin));*/null;
995 	  /*srw.message(rakn,'y_end: ' || to_char(dpr_in.y_end));*/null;
996 	  /*srw.message(9999,'p_cl_begin: ' || to_char(dpr_in.p_cl_begin));*/null;
997 	  /*srw.message(9999,'p_cl_end: ' || to_char(dpr_in.p_cl_end));*/null;
998           /*srw.message(9999,'Calling faxcde 2nd time');*/null;
999 	end if;
1000         ret := fa_cde_pkg.faxcde (
1001 		dpr_in => dpr_in,
1002 		dpr_arr => dpr_arr,
1003 		dpr_out => dpr_out,
1004 		fmode => 1);
1005        if (ret = FALSE) then
1006          /*srw.message(9999,'faxcde-second returned FALSE');*/null;
1007         true_or_false := 0;
1008        end if;
1009 	       l_stl_deprn_reserve_1969  :=  l_stl_deprn_reserve_1969 + round(dpr_out.new_deprn_rsv,precision);
1010      else
1011        l_stl_deprn_reserve_1969  :=  l_stl_deprn_reserve_1969 + nvl(l_stl_deprn_amount,0);
1012 	if print_debug = 'Y' then
1013          /*srw.message(9999,'faxcde 2nd not called');*/null;
1014 	end if;
1015      end if;
1016      if print_debug = 'Y' then
1017          /*srw.message(9999, 'stl_deprn_reserve: ' || to_char(l_stl_deprn_reserve_1969));*/null;
1018      end if;
1019      if l_date_retired > to_date('19691231','YYYYMMDD') then
1020     	before_1969 := false;
1021      end if;
1022      FETCH C_RET
1023      INTO	h_dpr_date,
1024 		dpr_in.prorate_jdate,
1025 		dpr_in.jdate_in_service,
1026 		dpr_in.deprn_start_jdate,
1027 		dpr_in.life,
1028 		dpr_in.rec_cost,
1029 		dpr_in.adj_cost,
1030 		h_current_cost,
1031 		dpr_in.reval_amo_basis,
1032 		dpr_in.rate_adj_factor,
1033 		dpr_in.adj_rate,
1034 		dpr_in.ceil_name,
1035 		dpr_in.bonus_rule,
1036 		dpr_in.capacity,
1037 		dpr_in.adj_capacity,
1038 		dpr_in.method_code,
1039 		dpr_in.asset_num,
1040 		dpr_in.adj_rec_cost,
1041 		dpr_in.salvage_value,
1042 		dpr_in.pc_life_end,
1043 		dpr_in.deprn_rounding_flag,
1044 		h_itc_amount_id,
1045 		h_itc_basis,
1046 		h_ceiling_Type,
1047                 dpr_in.formula_factor,
1048                 dpr_in.short_fiscal_year_flag,
1049                 dpr_in.conversion_date,
1050                 dpr_in.orig_deprn_start_date,
1051                 dpr_in.prorate_date,
1052 		h_prorate_start_year,
1053 		l_dpis,
1054 		l_stl_method_code,
1055 		l_stl_life_in_months,
1056 		l_stl_deprn_amount,
1057 		l_date_retired,
1058 		l_date_retired_year,
1059 		l_ttcode;
1060    END LOOP;
1061    close c_ret;
1062    if true_or_false  = 1 then
1063      l_reserve_retired := nvl(cost,0)  - nvl(nbvr,0);
1064      l_diff_reserve := l_reserve_retired - l_deprn_rsv_1969;
1065      if print_debug = 'Y' then
1066        /*srw.message(9992,'cost: ' || to_char(cost)) ;*/null;
1067        /*srw.message(9992,'nbvr: ' || to_char(nbvr));*/null;
1068        /*srw.message(9992,'reserve_retired: ' || to_char(l_reserve_retired));*/null;
1069        /*srw.message(9992,'diff_reserve (B): ' || to_char(l_diff_reserve));*/null;
1070      end if;
1071      l_diff_stl := nvl(l_stl_deprn_amount,0) - l_stl_deprn_reserve_1969;
1072      l_excess_deprn := l_diff_reserve - l_diff_stl;
1073      if xcess <= 0 then
1074         p_excess_1969 := 0;
1075         p_excess_1969_hide := 0;
1076      else
1077         p_excess_1969 := l_excess_deprn;
1078         p_excess_1969_hide := l_excess_deprn;
1079      end if;
1080      if print_debug = 'Y' then
1081        /*srw.message(9995,'stl_deprn_amount: ' || to_char(l_stl_deprn_amount));*/null;
1082        /*srw.message(9995,'diff_stl: ' || to_char(l_diff_stl));*/null;
1083        /*srw.message(9996,'excess_deprn: ' || to_char(l_excess_deprn));*/null;
1084      end if;
1085    else
1086      if zero_excess_deprn then
1087         p_excess_1969_hide := 0;
1088 	p_excess_1969 := '';
1089      else
1090      if xcess <= 0 then
1091         p_excess_1969_hide := 0;
1092         p_excess_1969 := 0;
1093      else
1094         p_excess_1969_hide := xcess;
1095         p_excess_1969 := xcess;
1096      end if;
1097      end if;
1098    end if;
1099   else
1100      if print_debug = 'Y' then
1101        /*srw.message(9997,'Not in dpis range or a STL asset');*/null;
1102        /*srw.message(9997,l_rate_source_rule);*/null;
1103        /*srw.message(9997, l_main_dpis);*/null;
1104      end if;
1105      if xcess <= 0 then
1106         p_excess_1969_hide := 0;
1107         p_excess_1969 := 0;
1108      else
1109         p_excess_1969_hide := xcess;
1110         p_excess_1969 := xcess;
1111      end if;
1112      true_or_false  := 0;
1113   end if;
1114   else     p_excess_1969_hide := xcess;
1115     p_excess_1969 := xcess;
1116     if print_debug = 'Y' then
1117        /*srw.message(9998,'Not a taxbook');*/null;
1118     end if;
1119     true_or_false  := 0;
1120   end if;
1121   elsif test_stl_method_code is not null and test_stl_deprn_amount = 0 then
1122      p_excess_1969_hide := 0;
1123      p_excess_1969 := 0;
1124      if print_debug = 'Y' then
1125        /*srw.message(9998,'stl_deprn_amount=0 and stl_method_code entered');*/null;
1126      end if;
1127   else
1128      p_excess_1969_hide := 0;
1129      p_excess_1969 := '';
1130      if print_debug = 'Y' then
1131        /*srw.message(9998,'No stl_method_code');*/null;
1132      end if;
1133   end if;
1134   if print_debug = 'Y' then
1135      /*srw.message(9999,'Ending D_EXCESS_1969');*/null;
1136   end if;
1137 RETURN(true_or_false);
1138 end;
1139 --Functions to refer Oracle report placeholders--
1140  Function PRECISION_p return number is
1141 	Begin
1142 	 return PRECISION;
1143 	 END;
1144  Function PRINT_DEBUG_p return varchar2 is
1145 	Begin
1146 	 return PRINT_DEBUG;
1147 	 END;
1148  Function ACCT_BAL_APROMPT_p return varchar2 is
1149 	Begin
1150 	 return ACCT_BAL_APROMPT;
1151 	 END;
1152  Function ACCT_CC_APROMPT_p return varchar2 is
1153 	Begin
1154 	 return ACCT_CC_APROMPT;
1155 	 END;
1156  Function CAT_MAJ_RPROMPT_p return varchar2 is
1157 	Begin
1158 	 return CAT_MAJ_RPROMPT;
1159 	 END;
1160  Function Period1_POD_p return date is
1161 	Begin
1162 	 return Period1_POD;
1163 	 END;
1164  Function Period1_PCD_p return date is
1165 	Begin
1166 	 return Period1_PCD;
1167 	 END;
1168  Function Period1_FY_p return number is
1169 	Begin
1170 	 return Period1_FY;
1171 	 END;
1172  Function Period2_POD_p return date is
1173 	Begin
1174 	 return Period2_POD;
1175 	 END;
1176  Function Period2_PCD_p return date is
1177 	Begin
1178 	 return Period2_PCD;
1179 	 END;
1180  Function Period2_FY_p return number is
1181 	Begin
1182 	 return Period2_FY;
1183 	 END;
1184  Function P_SECTION_1231_GAIN_1962_p return number is
1185 	Begin
1186 	 return P_SECTION_1231_GAIN_1962;
1187 	 END;
1188  Function P_ORDINARY_INCOME_1962_p return number is
1189 	Begin
1190 	 return P_ORDINARY_INCOME_1962;
1191 	 END;
1192  Function P_EXCESS_1969_HIDE_p return number is
1193 	Begin
1194 	 return P_EXCESS_1969_HIDE;
1195 	 END;
1196  Function P_EXCESS_1969_p return number is
1197 	Begin
1198 	 return P_EXCESS_1969;
1199 	 END;
1200  Function RP_COMPANY_NAME_p return varchar2 is
1201 	Begin
1202 	 return RP_COMPANY_NAME;
1203 	 END;
1204  Function RP_REPORT_NAME_p return varchar2 is
1205 	Begin
1206 	 return RP_REPORT_NAME;
1207 	 END;
1208  Function RP_DATA_FOUND_p return varchar2 is
1209 	Begin
1210 	 return RP_DATA_FOUND;
1211 	 END;
1212  Function RP_ACCT_BAL_LPROMPT_p return varchar2 is
1213 	Begin
1214 	 return RP_ACCT_BAL_LPROMPT;
1215 	 END;
1216 END FA_FAS445_XMLP_PKG ;
1217