DBA Data[Home] [Help]

PACKAGE: APPS.ARP_ACCT_MAIN

Source


1 PACKAGE ARP_ACCT_MAIN AS
2 /* $Header: ARTACCMS.pls 120.10 2005/09/08 15:11:14 mraymond 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_cust_trx_line_gl_dist_id  NUMBER,
114   ref_line_id                   NUMBER,
115   from_amount_dr                NUMBER,
116   from_amount_cr                NUMBER,
117   from_acctd_amount_dr          NUMBER,
118   from_acctd_amount_cr          NUMBER,
119   --}
120   --{HYUDETUPT
121   ref_account_class                     VARCHAR2(30),
122   activity_bucket                        VARCHAR2(30),
123   ref_dist_ccid                 NUMBER,
124   ref_mf_dist_flag              VARCHAR2(15)
125   --}
126   );
127 
128 --
129 -- Accounting Entry Line Table
130 --
131 TYPE ae_line_tbl_type IS TABLE of ae_line_rec_type
132   INDEX BY BINARY_INTEGER;
133 
134 --
135 --System parameter record can be modified based on info required
136 --
137 TYPE ae_sys_rec_type IS RECORD (
138      set_of_books_id   ar_system_parameters.set_of_books_id%TYPE           ,
139      gain_cc_id        ar_system_parameters.code_combination_id_gain%TYPE  ,
140      loss_cc_id        ar_system_parameters.code_combination_id_loss%TYPE  ,
141      round_cc_id       ar_system_parameters.code_combination_id_round%TYPE ,
142      base_currency     gl_sets_of_books.currency_code%TYPE                 ,
143      base_precision    fnd_currencies.precision%type                       ,
144      base_min_acc_unit fnd_currencies.minimum_accountable_unit%type        ,
145      coa_id            number                                              ,
146      sob_type          VARCHAR2(2)
147   );
148 
149 ae_sys_rec ae_sys_rec_type;
150 
151 TYPE ae_curr_rec_type IS RECORD (
152   precision                 fnd_currencies.precision%TYPE                ,
153   minimum_accountable_unit  fnd_currencies.minimum_accountable_unit%TYPE
154   );
155 --
156 --Rule record for earned and unearned discounts
157 --
158 TYPE ae_app_rule_rec_type IS RECORD (
159 
160 --Rules Earned discounts, adjustments
161     gl_account_source1       ar_receivables_trx.gl_account_source%TYPE       ,
162     tax_code_source1         ar_receivables_trx.tax_code_source%TYPE         ,
163     tax_recoverable_flag1    ar_receivables_trx.tax_recoverable_flag%TYPE    ,
164     code_combination_id1     ar_receivables_trx.code_combination_id%TYPE     ,
165     asset_tax_code1          zx_rates_b.tax_rate_code%TYPE                   ,
166     liability_tax_code1      zx_rates_b.tax_rate_code%TYPE                   ,
167     act_tax_non_rec_ccid1    ar_receivables_trx.code_combination_id%TYPE     ,
168     act_vat_tax_id1          zx_rates_b.tax_rate_id%TYPE                      ,
169 
170 --Rules Unearned discounts
171     gl_account_source2       ar_receivables_trx.gl_account_source%TYPE       ,
172     tax_code_source2         ar_receivables_trx.tax_code_source%TYPE         ,
173     tax_recoverable_flag2    ar_receivables_trx.tax_recoverable_flag%TYPE    ,
174     code_combination_id2     ar_receivables_trx.code_combination_id%TYPE     ,
175     asset_tax_code2          zx_rates_b.tax_rate_code%TYPE                   ,
176     liability_tax_code2      zx_rates_b.tax_rate_code%TYPE                   ,
177     act_tax_non_rec_ccid2    ar_receivables_trx.code_combination_id%TYPE     ,
178     act_vat_tax_id2          zx_rates_b.tax_rate_id%TYPE                      ,
179 
180 --Amounts for line, tax, charges, freight revenue and tax
181     receivable_account        ra_cust_trx_line_gl_dist.code_combination_id%TYPE ,
182     receivable_amt            NUMBER                                            ,
183     receivable_acctd_amt      NUMBER                                            ,
184     revenue_amt               NUMBER                                            ,
185     revenue_acctd_amt         NUMBER                                            ,
186     tax_amt                   NUMBER                                            ,
187     tax_acctd_amt             NUMBER                                            ,
188     --{BUG#2979254
189     freight_amt               NUMBER                                            ,
190     freight_acctd_amt         NUMBER                                            ,
191     line_charge_amt           NUMBER,
192     line_charge_acctd_amt     NUMBER,
193     frt_charge_amt            NUMBER,
194     frt_charge_acctd_amt      NUMBER,
195     --}
196     def_tax_amt               NUMBER                                            ,
197     def_tax_acctd_amt         NUMBER                                            ,
198     line_amt_alloc            NUMBER                                            ,
199     line_acctd_amt_alloc      NUMBER                                            ,
200     tax_amt_alloc             NUMBER                                            ,
201     tax_acctd_amt_alloc       NUMBER                                            ,
202     freight_amt_alloc         NUMBER                                            ,
203     freight_acctd_amt_alloc   NUMBER                                            ,
204     charges_amt_alloc         NUMBER                                            ,
205     charges_acctd_amt_alloc   NUMBER                                            ,
206     --{Separe line_Amt_alloc from chrg_line_amt_alloc same for frt
207     line_chrg_amt_alloc       NUMBER                                            ,
208     line_chrg_acctd_amt_alloc NUMBER                                            ,
209     frt_chrg_amt_alloc        NUMBER                                            ,
210     frt_chrg_acctd_amt_alloc  NUMBER                                            ,
211     --}
212     line_amt_applied          NUMBER                                            ,
213     line_acctd_amt_applied    NUMBER                                            ,
214     tax_amt_applied           NUMBER                                            ,
215     tax_acctd_amt_applied     NUMBER                                            ,
216     freight_amt_applied       NUMBER                                            ,
217     freight_acctd_amt_applied NUMBER                                            ,
218     charges_amt_applied       NUMBER                                            ,
219     charges_acctd_amt_applied NUMBER                                            ,
220     --{BUG#2979254
221     line_amt_rem              NUMBER,
222     line_acctd_amt_rem        NUMBER,
223     tax_amt_rem               NUMBER,
224     tax_acctd_amt_rem         NUMBER,
225     frt_amt_rem               NUMBER,
226     frt_acctd_amt_rem         NUMBER,
227     line_chrg_amt_rem         NUMBER,
228     line_chrg_acctd_amt_rem   NUMBER,
229     frt_chrg_amt_rem          NUMBER,
230     frt_chrg_acctd_amt_rem    NUMBER
231     --}
232   );
233 
234 invalid_dr_cr_total EXCEPTION;
235 
236 /*========================================================================
237  | PUBLIC PROCEDURE Create_Acct_Entry
238  |
239  | DESCRIPTION
240  |      Create accounting entries for a document
241  |      ----------------------------------------
242  |      This procedure calls the document main packages to create accounting
243  |      for Receipts, Credit Memos and Adjustments.
244  |
245  | PARAMETERS
246  |      p_mode          IN      Document or Accounting Event mode
247  |      p_ae_doc_rec    IN      Document Record
248  |      p_ae_event_rec  IN      Event Record
249  *=======================================================================*/
250 PROCEDURE Create_Acct_Entry(
251 		p_mode 		IN VARCHAR2,	-- DOCUMENT or ACCT_EVENT
252 		p_ae_doc_rec 	IN ae_doc_rec_type,
253 		p_ae_event_rec 	IN ae_event_rec_type,
254                 p_client_server IN VARCHAR2 DEFAULT NULL,
255                 --{HYUDETUPT
256                 p_from_llca_call  IN VARCHAR2 DEFAULT 'N',
257                 p_gt_id           IN NUMBER   DEFAULT NULL
258                 --}
259 		);
260 
261 /*========================================================================
262  | PUBLIC PROCEDURE Create_Acct_Entry
263  |
264  | DESCRIPTION
265  |      Create accounting entries for a document
266  |      ----------------------------------------
267  |      This is an overloaded procedure to which is passed the document
268  |      information, to create accounting entries for Receipts, Credit Memos
269  |      or Adjustments.
270  |
271  | PARAMETERS
272  |      p_mode          IN      Document or Accounting Event mode
273  |      p_ae_doc_rec    IN      Document Record
274  |      p_ae_event_rec  IN      Event Record
275  *=======================================================================*/
276 PROCEDURE Create_Acct_Entry(
277                 p_ae_doc_rec    IN ae_doc_rec_type,    -- DOCUMENT or ACCT_EVENT
278                 p_client_server IN VARCHAR2 DEFAULT NULL,
279                 --{HYUDETUPT
280                 p_from_llca_call  IN VARCHAR2 DEFAULT 'N',
281                 p_gt_id           IN NUMBER   DEFAULT NULL
282                 --}
283                 );
284 
285 /*========================================================================
286  | PUBLIC PROCEDURE Create_Acct_Entry
287  |
288  | DESCRIPTION
289  |      Create accounting entries for a document
290  |      ----------------------------------------
291  |      This is an overloaded procedure to which is passed the document
292  |      information, to create accounting entries for Receipts, Credit Memos
293  |      or Adjustments.
294  |
295  | PARAMETERS
296  |      document_type           IN      Document Type
297  |      document_id             IN      Document Id
298  |      accounting_entity_level IN      Entitity Level accounting
299  |      source_table            IN      Source table
300  |      source_id               IN      Source Id
301  |      source_id_old           IN      Source Id Old
302  |      other_flag              IN      Other Flag
303  *=======================================================================*/
304 PROCEDURE Create_Acct_Entry(
305                 p_document_type           VARCHAR2,
306                 p_document_id             NUMBER  ,
307                 p_accounting_entity_level VARCHAR2,
308                 p_source_table            VARCHAR2,
309                 p_source_id               NUMBER  ,
310                 p_source_id_old           NUMBER  ,
311                 p_other_flag              VARCHAR2,
312                 p_client_server IN VARCHAR2 DEFAULT NULL,
313                 --{HYUDETUPT
314                 p_from_llca_call  IN VARCHAR2 DEFAULT 'N',
315                 p_gt_id           IN NUMBER   DEFAULT NULL
316                 --}
317                 );
318 
319 /*========================================================================
320  | PUBLIC PROCEDURE Create_Acct_Entry
321  |
322  | DESCRIPTION
323  |      Create accounting entries for a document
324  |      ----------------------------------------
325  |      This is an overloaded procedure to which is passed the document
326  |      information, to create accounting entries for Receipts, Credit Memos
327  |      or Adjustments. This is used by C code and it was necessary to overload
328  |      this to pass the pay_sched_upd_yn, for Bills Receivable reconciliation
329  |      on closure, required by autoadjustments, and postbatch, this avoided having
330  |      to change other C routines.
331  |
332  | PARAMETERS
333  |      document_type           IN      Document Type
334  |      document_id             IN      Document Id
335  |      accounting_entity_level IN      Entitity Level accounting
336  |      source_table            IN      Source table
337  |      source_id               IN      Source Id
338  |      source_id_old           IN      Source Id Old
339  |      other_flag              IN      Other Flag
340  *=======================================================================*/
341 PROCEDURE Create_Acct_Entry(
342                 p_document_type           IN VARCHAR2,
343                 p_document_id             IN NUMBER  ,
344                 p_accounting_entity_level IN VARCHAR2,
345                 p_source_table            IN VARCHAR2,
346                 p_source_id               IN NUMBER  ,
347                 p_source_id_old           IN NUMBER  ,
348                 p_other_flag              IN VARCHAR2,
349                 p_pay_sched_upd_yn        IN VARCHAR2,
350                 p_client_server           IN VARCHAR2,
351                 --{HYUDETUPT
352                 p_from_llca_call  IN VARCHAR2 DEFAULT 'N',
353                 p_gt_id           IN NUMBER   DEFAULT NULL
354                 --}
355                 );
356 /*========================================================================
357  | PUBLIC PROCEDURE Create_Acct_Entry
358  |
359  | DESCRIPTION
360  |      Create accounting entries for a document
361  |      ----------------------------------------
362  |      This is an overloaded procedure to which is passed a request_id
363  |      from AUTORECEIPTS for processing the Receivable APPLICATION Rows
364  |
365  | PARAMETERS
366  |      p_request_id    IN      Request_id
367  *=======================================================================*/
368 PROCEDURE Create_Acct_Entry(
369                 p_request_id              IN NUMBER,
370                 p_called_from             IN VARCHAR
371                 );
372 
373 /*========================================================================
374  | PUBLIC PROCEDURE Delete_Acct_Entry
375  |
376  | DESCRIPTION
377  |      Delete accounting entries for a document
378  |      ----------------------------------------
379  |      This procedure is the standard delete routine which calls packages
380  |      for Receipts, Credit Memos and Adjustments to delete the accounting
381  |      associated with the document for a source id
382  |
383  | PARAMETERS
384  |      p_mode          IN      Document or Accounting Event mode
385  |      p_ae_doc_rec    IN      Document Record
386  |      p_ae_event_rec  IN      Event Record
387  *=======================================================================*/
388 PROCEDURE Delete_Acct_Entry(
389                 p_mode          IN VARCHAR2,    -- DOCUMENT or ACCT_EVENT
390                 p_ae_doc_rec    IN OUT NOCOPY ae_doc_rec_type,
391                 p_ae_event_rec  IN ae_event_rec_type
392                 );
393 
394 /*========================================================================
395  | PUBLIC PROCEDURE Delete_Acct_Entry
396  |
397  | DESCRIPTION
398  |      Delete accounting entries for a document
399  |      ----------------------------------------
400  |      This is an overloaded procedure which calls packages associated
401  |      with a Receipt, Credit Memo or Adjustment document to delete the
402  |      accounting for a source id.
403  |
404  | PARAMETERS
405  |      p_ae_doc_rec    IN      Document Record
406  *=======================================================================*/
407 PROCEDURE Delete_Acct_Entry(
408                 p_ae_doc_rec    IN OUT NOCOPY ae_doc_rec_type    -- DOCUMENT or ACCT_EVENT
409                 );
410 /*========================================================================
411  | PUBLIC PROCEDURE Delete_Acct_Entry
412  |
413  | DESCRIPTION
414  |      Delete accounting entries for a document
415  |      ----------------------------------------
416  |      This is an overloaded procedure which calls packages associated
417  |      with a Receipt, Credit Memo or Adjustment document to delete the
418  |      accounting for a source id. Required for C code delete calls.
419  |
420  | PARAMETERS
421  |      document_type           IN      Document Type
422  |      document_id             IN      Document Id
423  |      accounting_entity_level IN      Entitity Level accounting
424  |      source_table            IN      Source table
425  |      source_id               IN      Source Id
426  |      source_id_old           IN OUT NOCOPY  Source Id Old
427  |      other_flag              IN      Other Flag
428  *=======================================================================*/
429 PROCEDURE Delete_Acct_Entry(
430                 p_document_type           IN     VARCHAR2,
431                 p_document_id             IN     NUMBER  ,
432                 p_accounting_entity_level IN     VARCHAR2,
433                 p_source_table            IN     VARCHAR2,
434                 p_source_id               IN     NUMBER  ,
435                 p_source_id_old           IN OUT NOCOPY NUMBER  ,
436                 p_other_flag              IN     VARCHAR2
437                 );
438 
439 END ARP_ACCT_MAIN;