1 PACKAGE ARP_ACCT_MAIN AUTHID CURRENT_USER AS
2 /* $Header: ARTACCMS.pls 120.12 2010/07/23 02:56:38 nemani ship $ */
3
4 --
5 -- Declare PUBLIC Data Types and Variables
6 --
7
8 --
9 -- Accounting Entry Document Type Record (Standard)
10 --
11 TYPE ae_doc_rec_type IS RECORD (
12 document_type varchar2(30) , -- E.g. INVOICE, RECEIPT, ADJUSTMENT
13 document_id number , -- E.g. Invoice Id, Receipt Id
14 accounting_entity_level varchar2(30) , -- ALL or ONE entity.
15 source_table ar_distributions.source_table%TYPE, -- E.g. RA(ar_receivable_applications)
16 source_id NUMBER , -- E.g. receivable_application_id
17 source_id_old NUMBER , -- E.g. Old receivable_application_id
18 -- for Reversals or source_id_secondary
19 -- UNAPP, and override of ccid for adjustments
20 other_flag varchar2(10), -- Indicates what source_id_old is used
21 -- for, e.g. REVERSE or to populate
22 -- source_id_secondary for PAIRED UNAPP
23 -- records or OVERRIDE for adjustment ccid
24 miscel1 varchar2(15), --miscel list of variables below were required
25 miscel2 NUMBER , --specifically for autoreceipts, however in the
26 miscel3 varchar2(30), --future these may be used for any entity accounting
27 miscel4 DATE , --record based on type declaration
28 miscel5 NUMBER ,
29 miscel6 NUMBER ,
30 miscel7 NUMBER ,
31 miscel8 NUMBER ,
32 event VARCHAR2(30), --UNELIMINATE_RISK used to reversal tax and state
33 --that the MATURITY_DATE
34 deferred_tax VARCHAR2(1) , --Bills Receivable used by housekeeper to indicate
35 --that deferred tax has already been moved at Maturity
36 --Date event
37 called_from VARCHAR2(30), --Parent routine call, used to prevent initialization
38 --of rule amounts in tax accounting routine when called
39 --from Wrapper routine
40 pay_sched_upd_yn VARCHAR2(1), --A "Y" indicates that the payment schedule has been updated
41 --before the call to the accounting engine
42 pay_sched_upd_cm_yn VARCHAR2(1), --A "Y" indicates that the payment schedule has been updated
43 --before the call to the accounting engine
44 override_source_type ar_distributions.source_type%TYPE ,
45 gl_tax_acct ar_distributions.code_combination_id%TYPE, /* Bug fix 2300268 */
46 inv_cm_app_mode VARCHAR2(1)
47 );
48
49 --
50 -- Accounting Entry Document Type Record (Product)
51 --
52 /* Define product specific Document Type record here */
53
54
55 --
56 -- Accounting Entry Event Type Record (Standard)
57 --
58 TYPE ae_event_rec_type IS RECORD (
59 event_type varchar2(30), -- E.g. INVOICE_CREATE, RECEIPT_CREATE
60 event_id number(15),
61 event_date date,
62 event_status varchar2(30)
63 );
64
65 --
66 -- Accounting Entry Event Type Record (Product)
67 --
68 /* Define product specific Event Type record here */
69
70 --
71 -- Accounting Entry Line Type
72 --
73 -- Doc table and id columns for future usage purposes
74 --
75 --
76
77 TYPE ae_line_rec_type IS RECORD
78 (
79 ae_line_type ar_distributions.source_type%TYPE,
80 ae_line_type_secondary ar_distributions.source_type_secondary%TYPE,
81 source_id ar_distributions.source_id%TYPE,
82 source_table ar_distributions.source_table%TYPE,
83 account ar_distributions.code_combination_id%TYPE,
84 entered_dr NUMBER,
85 entered_cr NUMBER,
86 accounted_dr NUMBER,
87 accounted_cr NUMBER,
88 source_id_secondary ar_distributions.source_id_secondary%TYPE,
89 source_table_secondary ar_distributions.source_table_secondary%TYPE,
90 currency_code ar_distributions.currency_code%TYPE,
91 currency_conversion_rate ar_distributions.currency_conversion_rate%TYPE,
92 currency_conversion_type ar_distributions.currency_conversion_type%TYPE,
93 currency_conversion_date ar_distributions.currency_conversion_date%TYPE,
94 third_party_id ar_distributions.third_party_id%TYPE,
95 third_party_sub_id ar_distributions.third_party_sub_id%TYPE,
96 tax_group_code_id ar_distributions.tax_group_code_id%TYPE,
97 tax_code_id ar_distributions.tax_code_id%TYPE,
98 location_segment_id ar_distributions.location_segment_id%TYPE,
99 taxable_entered_dr NUMBER,
100 taxable_entered_cr NUMBER,
101 taxable_accounted_dr NUMBER,
102 taxable_accounted_cr NUMBER,
103 tax_link_id ar_distributions.tax_link_id%TYPE,
104 applied_from_doc_table VARCHAR2(30),
105 applied_from_doc_id NUMBER,
106 applied_to_doc_table VARCHAR2(30),
107 applied_to_doc_id NUMBER,
108 reversed_source_id ar_distributions.reversed_source_id%TYPE,
109 summarize_flag VARCHAR2(1),
110 ae_neg_ind NUMBER,
111 --{BUG#2979254
112 ref_customer_trx_line_id NUMBER,
113 ref_prev_cust_trx_line_id NUMBER,
114 ref_cust_trx_line_gl_dist_id NUMBER,
115 ref_line_id NUMBER,
116 from_amount_dr NUMBER,
117 from_amount_cr NUMBER,
118 from_acctd_amount_dr NUMBER,
119 from_acctd_amount_cr NUMBER,
120 --}
121 --{HYUDETUPT
122 ref_account_class VARCHAR2(30),
123 activity_bucket VARCHAR2(30),
124 ref_dist_ccid NUMBER,
125 ref_mf_dist_flag VARCHAR2(15)
126 --}
127 );
128
129 --
130 -- Accounting Entry Line Table
131 --
132 TYPE ae_line_tbl_type IS TABLE of ae_line_rec_type
133 INDEX BY BINARY_INTEGER;
134
135 --
136 --System parameter record can be modified based on info required
137 --
138 TYPE ae_sys_rec_type IS RECORD (
139 set_of_books_id ar_system_parameters.set_of_books_id%TYPE ,
140 gain_cc_id ar_system_parameters.code_combination_id_gain%TYPE ,
141 loss_cc_id ar_system_parameters.code_combination_id_loss%TYPE ,
142 round_cc_id ar_system_parameters.code_combination_id_round%TYPE ,
143 base_currency gl_sets_of_books.currency_code%TYPE ,
144 base_precision fnd_currencies.precision%type ,
145 base_min_acc_unit fnd_currencies.minimum_accountable_unit%type ,
146 coa_id number ,
147 sob_type VARCHAR2(2)
148 );
149
150 ae_sys_rec ae_sys_rec_type;
151
152 TYPE ae_curr_rec_type IS RECORD (
153 precision fnd_currencies.precision%TYPE ,
154 minimum_accountable_unit fnd_currencies.minimum_accountable_unit%TYPE
155 );
156 --
157 --Rule record for earned and unearned discounts
158 --
159 TYPE ae_app_rule_rec_type IS RECORD (
160
161 --Rules Earned discounts, adjustments
162 gl_account_source1 ar_receivables_trx.gl_account_source%TYPE ,
163 tax_code_source1 ar_receivables_trx.tax_code_source%TYPE ,
164 tax_recoverable_flag1 ar_receivables_trx.tax_recoverable_flag%TYPE ,
165 code_combination_id1 ar_receivables_trx.code_combination_id%TYPE ,
166 asset_tax_code1 zx_rates_b.tax_rate_code%TYPE ,
167 liability_tax_code1 zx_rates_b.tax_rate_code%TYPE ,
168 act_tax_non_rec_ccid1 ar_receivables_trx.code_combination_id%TYPE ,
169 act_vat_tax_id1 zx_rates_b.tax_rate_id%TYPE ,
170
171 --Rules Unearned discounts
172 gl_account_source2 ar_receivables_trx.gl_account_source%TYPE ,
173 tax_code_source2 ar_receivables_trx.tax_code_source%TYPE ,
174 tax_recoverable_flag2 ar_receivables_trx.tax_recoverable_flag%TYPE ,
175 code_combination_id2 ar_receivables_trx.code_combination_id%TYPE ,
176 asset_tax_code2 zx_rates_b.tax_rate_code%TYPE ,
177 liability_tax_code2 zx_rates_b.tax_rate_code%TYPE ,
178 act_tax_non_rec_ccid2 ar_receivables_trx.code_combination_id%TYPE ,
179 act_vat_tax_id2 zx_rates_b.tax_rate_id%TYPE ,
180
181 --Amounts for line, tax, charges, freight revenue and tax
182 receivable_account ra_cust_trx_line_gl_dist.code_combination_id%TYPE ,
183 receivable_amt NUMBER ,
184 receivable_acctd_amt NUMBER ,
185 revenue_amt NUMBER ,
186 revenue_acctd_amt NUMBER ,
187 tax_amt NUMBER ,
188 tax_acctd_amt NUMBER ,
189 --{BUG#2979254
190 freight_amt NUMBER ,
191 freight_acctd_amt NUMBER ,
192 line_charge_amt NUMBER,
193 line_charge_acctd_amt NUMBER,
194 frt_charge_amt NUMBER,
195 frt_charge_acctd_amt NUMBER,
196 --}
197 def_tax_amt NUMBER ,
198 def_tax_acctd_amt NUMBER ,
199 line_amt_alloc NUMBER ,
200 line_acctd_amt_alloc NUMBER ,
201 tax_amt_alloc NUMBER ,
202 tax_acctd_amt_alloc NUMBER ,
203 freight_amt_alloc NUMBER ,
204 freight_acctd_amt_alloc NUMBER ,
205 charges_amt_alloc NUMBER ,
206 charges_acctd_amt_alloc NUMBER ,
207 --{Separe line_Amt_alloc from chrg_line_amt_alloc same for frt
208 line_chrg_amt_alloc NUMBER ,
209 line_chrg_acctd_amt_alloc NUMBER ,
210 frt_chrg_amt_alloc NUMBER ,
211 frt_chrg_acctd_amt_alloc NUMBER ,
212 --}
213 line_amt_applied NUMBER ,
214 line_acctd_amt_applied NUMBER ,
215 tax_amt_applied NUMBER ,
216 tax_acctd_amt_applied NUMBER ,
217 freight_amt_applied NUMBER ,
218 freight_acctd_amt_applied NUMBER ,
219 charges_amt_applied NUMBER ,
220 charges_acctd_amt_applied NUMBER ,
221 --{BUG#2979254
222 line_amt_rem NUMBER,
223 line_acctd_amt_rem NUMBER,
224 tax_amt_rem NUMBER,
225 tax_acctd_amt_rem NUMBER,
226 frt_amt_rem NUMBER,
227 frt_acctd_amt_rem NUMBER,
228 line_chrg_amt_rem NUMBER,
229 line_chrg_acctd_amt_rem NUMBER,
230 frt_chrg_amt_rem NUMBER,
231 frt_chrg_acctd_amt_rem NUMBER
232 --}
233 );
234
235 invalid_dr_cr_total EXCEPTION;
236
237 /*========================================================================
238 | PUBLIC PROCEDURE Create_Acct_Entry
239 |
240 | DESCRIPTION
241 | Create accounting entries for a document
242 | ----------------------------------------
243 | This procedure calls the document main packages to create accounting
244 | for Receipts, Credit Memos and Adjustments.
245 |
246 | PARAMETERS
247 | p_mode IN Document or Accounting Event mode
248 | p_ae_doc_rec IN Document Record
249 | p_ae_event_rec IN Event Record
250 *=======================================================================*/
251 PROCEDURE Create_Acct_Entry(
252 p_mode IN VARCHAR2, -- DOCUMENT or ACCT_EVENT
253 p_ae_doc_rec IN ae_doc_rec_type,
254 p_ae_event_rec IN ae_event_rec_type,
255 p_client_server IN VARCHAR2 DEFAULT NULL,
256 --{HYUDETUPT
257 p_from_llca_call IN VARCHAR2 DEFAULT 'N',
258 p_gt_id IN NUMBER DEFAULT NULL,
259 p_called_from IN VARCHAR2 DEFAULT NULL
260 --}
261 );
262
263 /*========================================================================
264 | PUBLIC PROCEDURE Create_Acct_Entry
265 |
266 | DESCRIPTION
267 | Create accounting entries for a document
268 | ----------------------------------------
269 | This is an overloaded procedure to which is passed the document
270 | information, to create accounting entries for Receipts, Credit Memos
271 | or Adjustments.
272 |
273 | PARAMETERS
274 | p_mode IN Document or Accounting Event mode
275 | p_ae_doc_rec IN Document Record
276 | p_ae_event_rec IN Event Record
277 *=======================================================================*/
278 PROCEDURE Create_Acct_Entry(
279 p_ae_doc_rec IN ae_doc_rec_type, -- DOCUMENT or ACCT_EVENT
280 p_client_server IN VARCHAR2 DEFAULT NULL,
281 --{HYUDETUPT
282 p_from_llca_call IN VARCHAR2 DEFAULT 'N',
283 p_gt_id IN NUMBER DEFAULT NULL,
284 --}
285 p_called_from IN VARCHAR2 DEFAULT NULL
286 );
287
288 /*========================================================================
289 | PUBLIC PROCEDURE Create_Acct_Entry
290 |
291 | DESCRIPTION
292 | Create accounting entries for a document
293 | ----------------------------------------
294 | This is an overloaded procedure to which is passed the document
295 | information, to create accounting entries for Receipts, Credit Memos
296 | or Adjustments.
297 |
298 | PARAMETERS
299 | document_type IN Document Type
300 | document_id IN Document Id
301 | accounting_entity_level IN Entitity Level accounting
302 | source_table IN Source table
303 | source_id IN Source Id
304 | source_id_old IN Source Id Old
305 | other_flag IN Other Flag
306 *=======================================================================*/
307 PROCEDURE Create_Acct_Entry(
308 p_document_type VARCHAR2,
309 p_document_id NUMBER ,
310 p_accounting_entity_level VARCHAR2,
311 p_source_table VARCHAR2,
312 p_source_id NUMBER ,
313 p_source_id_old NUMBER ,
314 p_other_flag VARCHAR2,
315 p_client_server IN VARCHAR2 DEFAULT NULL,
316 --{HYUDETUPT
317 p_from_llca_call IN VARCHAR2 DEFAULT 'N',
318 p_gt_id IN NUMBER DEFAULT NULL
319 --}
320 );
321
322 /*========================================================================
323 | PUBLIC PROCEDURE Create_Acct_Entry
324 |
325 | DESCRIPTION
326 | Create accounting entries for a document
327 | ----------------------------------------
328 | This is an overloaded procedure to which is passed the document
329 | information, to create accounting entries for Receipts, Credit Memos
330 | or Adjustments. This is used by C code and it was necessary to overload
331 | this to pass the pay_sched_upd_yn, for Bills Receivable reconciliation
332 | on closure, required by autoadjustments, and postbatch, this avoided having
333 | to change other C routines.
334 |
335 | PARAMETERS
336 | document_type IN Document Type
337 | document_id IN Document Id
338 | accounting_entity_level IN Entitity Level accounting
339 | source_table IN Source table
340 | source_id IN Source Id
341 | source_id_old IN Source Id Old
342 | other_flag IN Other Flag
343 *=======================================================================*/
344 PROCEDURE Create_Acct_Entry(
345 p_document_type IN VARCHAR2,
346 p_document_id IN NUMBER ,
347 p_accounting_entity_level IN VARCHAR2,
348 p_source_table IN VARCHAR2,
349 p_source_id IN NUMBER ,
350 p_source_id_old IN NUMBER ,
351 p_other_flag IN VARCHAR2,
352 p_pay_sched_upd_yn IN VARCHAR2,
353 p_client_server IN VARCHAR2,
354 --{HYUDETUPT
355 p_from_llca_call IN VARCHAR2 DEFAULT 'N',
356 p_gt_id IN NUMBER DEFAULT NULL
357 --}
358 );
359 /*========================================================================
360 | PUBLIC PROCEDURE Create_Acct_Entry
361 |
362 | DESCRIPTION
363 | Create accounting entries for a document
364 | ----------------------------------------
365 | This is an overloaded procedure to which is passed a request_id
366 | from AUTORECEIPTS for processing the Receivable APPLICATION Rows
367 |
368 | PARAMETERS
369 | p_request_id IN Request_id
370 *=======================================================================*/
371 PROCEDURE Create_Acct_Entry(
372 p_request_id IN NUMBER,
373 p_called_from IN VARCHAR
374 );
375
376 /*========================================================================
377 | PUBLIC PROCEDURE Delete_Acct_Entry
378 |
379 | DESCRIPTION
380 | Delete accounting entries for a document
381 | ----------------------------------------
382 | This procedure is the standard delete routine which calls packages
383 | for Receipts, Credit Memos and Adjustments to delete the accounting
384 | associated with the document for a source id
385 |
386 | PARAMETERS
387 | p_mode IN Document or Accounting Event mode
388 | p_ae_doc_rec IN Document Record
389 | p_ae_event_rec IN Event Record
390 *=======================================================================*/
391 PROCEDURE Delete_Acct_Entry(
392 p_mode IN VARCHAR2, -- DOCUMENT or ACCT_EVENT
393 p_ae_doc_rec IN OUT NOCOPY ae_doc_rec_type,
394 p_ae_event_rec IN ae_event_rec_type
395 );
396
397 /*========================================================================
398 | PUBLIC PROCEDURE Delete_Acct_Entry
399 |
400 | DESCRIPTION
401 | Delete accounting entries for a document
402 | ----------------------------------------
403 | This is an overloaded procedure which calls packages associated
404 | with a Receipt, Credit Memo or Adjustment document to delete the
405 | accounting for a source id.
406 |
407 | PARAMETERS
408 | p_ae_doc_rec IN Document Record
409 *=======================================================================*/
410 PROCEDURE Delete_Acct_Entry(
411 p_ae_doc_rec IN OUT NOCOPY ae_doc_rec_type -- DOCUMENT or ACCT_EVENT
412 );
413 /*========================================================================
414 | PUBLIC PROCEDURE Delete_Acct_Entry
415 |
416 | DESCRIPTION
417 | Delete accounting entries for a document
418 | ----------------------------------------
419 | This is an overloaded procedure which calls packages associated
420 | with a Receipt, Credit Memo or Adjustment document to delete the
421 | accounting for a source id. Required for C code delete calls.
422 |
423 | PARAMETERS
424 | document_type IN Document Type
425 | document_id IN Document Id
426 | accounting_entity_level IN Entitity Level accounting
427 | source_table IN Source table
428 | source_id IN Source Id
429 | source_id_old IN OUT NOCOPY Source Id Old
430 | other_flag IN Other Flag
431 *=======================================================================*/
432 PROCEDURE Delete_Acct_Entry(
433 p_document_type IN VARCHAR2,
434 p_document_id IN NUMBER ,
435 p_accounting_entity_level IN VARCHAR2,
436 p_source_table IN VARCHAR2,
437 p_source_id IN NUMBER ,
438 p_source_id_old IN OUT NOCOPY NUMBER ,
439 p_other_flag IN VARCHAR2
440 );
441
442 END ARP_ACCT_MAIN;