1 PACKAGE FA_WHATIF_DEPRN_PKG as
2 /* $Header: FAWDPRS.pls 120.8.12010000.1 2008/07/28 13:19:29 appldev ship $ */
3
4
5 -- store deprn expense values for each period in these globally-declared
6 -- arrays temporarily. insert into interface table once deprn is
7 -- completed for an asset.
8
9 TYPE whatif_itf_table_rec is RECORD (
10 new_deprn number,
11 deprn number,
12 new_bonus_deprn number,
13 bonus_deprn number,
14 fiscal_year number,
15 period_name varchar2(15),
16 new_rsv number,
17 period_num number
18 );
19
20 TYPE whatif_itf_table is TABLE of whatif_itf_table_rec
21 index by binary_integer;
22
23 G_deprn whatif_itf_table;
24
25 TYPE tab_num_type IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
26 TYPE tab_num15_type IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
27 TYPE tab_char15_type IS TABLE OF VARCHAR2(15) INDEX BY BINARY_INTEGER;
28 TYPE tab_char30_type IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;
29 TYPE tab_char35_type IS TABLE OF VARCHAR2(35) INDEX BY BINARY_INTEGER;
30 TYPE tab_char80_type IS TABLE OF VARCHAR2(80) INDEX BY BINARY_INTEGER;
31 TYPE tab_char240_type IS TABLE OF VARCHAR2(240) INDEX BY BINARY_INTEGER;
32 TYPE tab_char500_type IS TABLE OF VARCHAR2(500) INDEX BY BINARY_INTEGER;
33 TYPE tab_date_type IS TABLE OF DATE INDEX BY BINARY_INTEGER;
34
35 tb_period_name tab_char30_type;
36 tb_period_num tab_num15_type;
37 tb_fiscal_year tab_num15_type;
38
39 t_request_id tab_num15_type;
40 t_book_type_code tab_char15_type;
41 t_asset_id tab_num15_type;
42 t_asset_number tab_char15_type;
43 t_description tab_char80_type;
44 t_tag_number tab_char15_type;
45 t_serial_number tab_char35_type;
46 t_period_name tab_char15_type;
47 t_fiscal_year tab_num15_type;
48 t_expense_acct tab_char500_type;
49 t_location tab_char500_type;
50 t_units tab_num_type;
51 t_employee_name tab_char240_type;
52 t_employee_number tab_char30_type;
53 t_asset_key tab_char500_type;
54 t_current_cost tab_num_type;
55 t_current_prorate_conv tab_char15_type;
56 t_current_method tab_char15_type;
57 t_current_life tab_num15_type;
58 t_current_basic_rate tab_num_type;
59 t_current_adjusted_rate tab_num_type;
60 t_current_salvage_value tab_num_type;
61 t_depreciation tab_num_type;
62 t_new_depreciation tab_num_type;
63 t_created_by tab_num15_type;
64 t_creation_date tab_date_type;
65 t_last_update_date tab_date_type;
66 t_last_updated_by tab_num15_type;
67 t_last_update_login tab_num15_type;
68 t_date_placed_in_service tab_date_type;
69 t_category tab_char500_type;
70 t_accumulated_deprn tab_num_type;
71 t_bonus_depreciation tab_num_type;
72 t_new_bonus_depreciation tab_num_type;
73 t_current_bonus_rule tab_char30_type;
74 t_period_num tab_num15_type;
75 t_currency_code tab_char15_type;
76
77 t_ind BINARY_INTEGER := 0;
78
79 -- function whatif_deprn_asset:
80 --
81 -- Perform depreciation on an asset using the given properties.
82 -- Includes effects of adjusting the asset first.
83 -- Places deprn expense for each period in global arrays (to be committed
84 -- to interface table later, in whatif_insert_itf).
85 -- Arguments to this function include all parameters needed to fully
86 -- load a dpr_in structure (remaining dpr_in elements can be either
87 -- deduced or selected given these parameters).
88 -- Deprn runs beginning in X_start_per and continuing for X_num_per
89 -- periods.
90 --
91 -- X_mode contains one of several values that determine how this
92 -- procedure executes:
93 -- 'E'... Asset exists, but some of the input parameters differ
94 -- from the asset's current state. Hypothetically perform the
95 -- expensed adjustment, then run deprn for the given periods,
96 -- storing expense in G_new_deprn.
97 -- 'A'... Asset exists, but some of the input parameters differ
98 -- from the asset's current state. Hypothetically perform the
99 -- amortized adjustment, then run deprn for the given periods,
100 -- storing expense in G_new_deprn.
101 -- 'N'... Asset exists, and we've already run this procedure in 'E'
102 -- or 'A' mode. Now run deprn for given periods again, this time
103 -- given asset's current state, storing expense in G_deprn.
104 -- Select asset's current state from DB, ignoring parameters.
105 -- 'H'... Hypothetical asset which doesn't exist. Just run deprn
106 -- for the indicated periods given the hypothetical parameters,
107 -- storing expense in G_new_deprn.
108 -- Also runs whatif_insert_itf when done. Should be called only from form.
109 --
110 -- This procedure can be called by whatif_deprn (E,A,N modes)
111 -- or from a R11 form (H mode). Could also be called by new Projections
112 -- code (N mode).
113
114 function whatif_deprn_asset (
115 X_asset_id in number,
116 X_mode in varchar2,
117 X_book in varchar2,
118 X_start_per in varchar2,
119 X_num_pers in number,
120 X_dpis in date default null,
121 X_prorate_date in date default null,
122 X_prorate_conv in varchar2 default null,
123 X_deprn_start_date in date default null,
124 X_ceiling_name in varchar2 default null,
125 X_bonus_rule in varchar2 default null,
126 X_method_code in varchar2 default null,
127 X_cost in number default null,
128 X_old_cost in number default null,
129 X_adj_cost in number default null,
130 X_rec_cost in number default null,
131 X_raf in number default null,
132 X_adj_rate in number default null,
133 X_reval_amo_basis in number default null,
134 X_capacity in number default null,
135 X_adj_capacity in number default null,
136 X_life in number default null,
137 X_adj_rec_cost in number default null,
138 X_salvage_value in number default null,
139 X_salvage_pct in number default null,
140 X_category_id in number default null,
141 X_deprn_rnd_flag in varchar2 default null,
142 X_calendar_type in varchar2 default null,
143 X_prior_fy_exp in number default null,
144 X_deprn_rsv in number default null,
145 X_reval_rsv in number default null,
146 X_ytd_deprn in number default null,
147 X_ltd_prod in number default null,
148 retcode out nocopy number,
149 errbuf out nocopy varchar2)
150 return boolean;
151
152 -- function whatif_insert_itf
153
154 -- Commit rows into whatif_commit_itf,
155 -- using deprn stored in global arrays G_new_deprn and G_deprn.
156 -- X_request_id is 0 if not called from within a concurrent req.
157
158 function whatif_insert_itf (
159 X_asset_id in number,
160 X_book in varchar2,
161 X_request_id in number,
162 X_num_pers in number,
163 X_acct_struct in number,
164 X_key_struct in number,
165 X_cat_struct in number,
166 X_loc_struct in number,
167 X_precision in number,
168 X_user_id in number,
169 X_login_id in number,
170 X_last_asset in boolean default false,
171 retcode out nocopy number,
172 errbuf out nocopy varchar2)
173 return boolean;
174
175 END FA_WHATIF_DEPRN_PKG;