DBA Data[Home] [Help]

PACKAGE: APPS.ARP_ETAX_UTIL

Source


1 PACKAGE ARP_ETAX_UTIL  AUTHID CURRENT_USER AS
2 /* $Header: AREBTUTS.pls 120.19.12010000.4 2008/11/19 09:41:50 ankuagar ship $ */
3 
4 /*=======================================================================+
5  |  Declare PUBLIC Data Types and Variables
6  +=======================================================================*/
7 SUBTYPE ae_doc_rec_type   IS ARP_ACCT_MAIN.ae_doc_rec_type;
8 SUBTYPE ae_sys_rec_type   IS ARP_ACCT_MAIN.ae_sys_rec_type;
9 
10   g_gt_id NUMBER;
11 
12 /*=======================================================================+
13  |  Declare PUBLIC Exceptions
14  +=======================================================================*/
15 --    temp_exception EXCEPTION;
16 
17 /*========================================================================
18  | PUBLIC PROCEDURE populate_ebt_gt
19  |
20  | DESCRIPTION
21  |    This procedure populates the ebt GT tables that are used by
22  |    autoinvoice for tax calculations.  The procedure will be called
23  |    twice - once for INV and a second time for CM (regular) data.
24  |
25  | PSEUDO CODE/LOGIC
26  |
27  | PARAMETERS
28  |      p_request_id    IN      Request_id of import job
29  |      p_phase         IN      Indicates 'INV' or 'CM' phase
30  |
31  | KNOWN ISSUES
32  |
33  | NOTES
34  |
35  | MODIFICATION HISTORY
36  | Date                  Author            Description of Changes
37  | 28-FEB-2005           MRAYMOND          Created
38  | 11-SEP-2006           MRAYMOND    5385324 - added p_synch_line_data
39  |                                      parameter to synchronize_for_doc_seq
40  | 15-JAN-2008           MRAYMOND    6743811 - added p_return_status
41  |                                      to calculate_tax_int
42  *=======================================================================*/
43 PROCEDURE clear_ebt_gt;
44 
45 PROCEDURE validate_tax_int(p_return_status OUT NOCOPY NUMBER,
46                             p_called_from_AI IN VARCHAR2 DEFAULT 'N');
47 
48 PROCEDURE calculate_tax_int(p_return_status OUT NOCOPY NUMBER,
49                             p_called_from_AI IN VARCHAR2 DEFAULT 'N');
50 
51 PROCEDURE get_country_and_legal_ent (
52                 p_org_id      IN  NUMBER,
53                 p_def_country OUT NOCOPY VARCHAR2,
54                 p_legal_ent   OUT NOCOPY NUMBER);
55 
56 PROCEDURE synchronize_for_doc_seq(
57                 p_trx_id      IN NUMBER,
58                 p_return_status  OUT NOCOPY NUMBER,
59                 p_request_id  IN NUMBER DEFAULT NULL,
60                 p_sync_line_data IN VARCHAR2 DEFAULT 'N');
61 /*Bug 6806843.Removing the procedure synchronize_for_auto_trxnum. See bug for
62 details */
63 
64 
65 PROCEDURE global_document_update(p_customer_trx_id IN NUMBER,
66                                  p_request_id      IN NUMBER,
67                                  p_action          IN VARCHAR2);
68 
69 PROCEDURE get_default_tax_classification(
70               p_ship_to_site_use_id        IN     NUMBER DEFAULT NULL,
71               p_bill_to_site_use_id        IN     NUMBER DEFAULT NULL,
72               p_inv_item_id                IN     NUMBER DEFAULT NULL,
73               p_org_id                     IN     NUMBER,
74               p_sob_id                     IN     NUMBER,
75               p_trx_date                   IN     DATE,
76               p_trx_type_id                IN     NUMBER,
77               p_cust_trx_id                IN     NUMBER,
78               p_cust_trx_line_id           IN     NUMBER DEFAULT NULL,
79               p_customer_id                IN     NUMBER DEFAULT NULL,
80               p_memo_line_id               IN     NUMBER DEFAULT NULL,
81               p_salesrep_id                IN     NUMBER DEFAULT NULL,
82               p_warehouse_id               IN     NUMBER DEFAULT NULL,
83               p_entity_code                IN     VARCHAR2,
84               p_event_class_code           IN     VARCHAR2,
85               p_function_short_name        IN     VARCHAR2,
86               p_tax_classification_code    OUT    NOCOPY VARCHAR2);
87 
88 /* Public procedure defined for import processes (AI, API, Copy)
89    Specifically designed to grab the tax_classif from
90    ZX_LINES_DET_FACTORS and stamp it on the imported lines. */
91 
92 PROCEDURE set_default_tax_classification(
93               p_request_id  IN NUMBER,
94               p_phase       IN VARCHAR2 DEFAULT 'INV');
95 
96 FUNCTION get_event_information (p_customer_trx_id IN NUMBER,
97                                 p_action IN VARCHAR2,
98                                 p_event_class_code OUT NOCOPY VARCHAR2,
99                                 p_event_type_code OUT NOCOPY VARCHAR2)
100                                 RETURN BOOLEAN;
101 
102 PROCEDURE build_ar_tax_lines(
103                  p_customer_trx_id  IN  NUMBER,
104                  p_rows_inserted    OUT NOCOPY NUMBER);
105 
106 PROCEDURE delete_tax_lines_from_ar(
107                  p_customer_trx_id  IN  NUMBER);
108 
109 FUNCTION tax_curr_round(p_amount    IN NUMBER,
110                         p_trx_currency_code IN VARCHAR2 default null,
111                         p_precision IN NUMBER,
112                         p_min_acct_unit IN NUMBER,
113                         p_rounding_rule IN VARCHAR2 default 'NEAREST',
114                         p_autotax_flag  IN VARCHAR2 default 'Y')
115                RETURN NUMBER;
116 
117 /* Used to prorate tax across recoverable invoice lines.
118   INPUT:
119     p_adj_id     = adjustment or receipt id         (reqd)
120     p_target_id  = invoice customer_trx_id          (reqd)
121     p_target_line_id = invoice customer_trx_line_id (optional)
122     p_amount     = total adjustment or discount     (reqd)
123     p_apply_date = date effective for application or adj  (reqd)
124     p_mode       = INV, LINE, or TAX                      (reqd)
125                     INV  = zero out
126                     LINE = prorate LINE and TAX
127                     TAX  = tax only
128     p_upd_adj_and_ps = Y/A/Null.  Y means we will update   (optional)
129                        the adj and ps rows (they were already
130                        saved with previous values)
131                        A means update adj only (ps handled locally)
132     p_quote          = Y/N/Null.  Y means we will call etax in
133                        quote mode.  No tax will be stored in repository.
134                        We will have to fetch the estimated tax back
135                        from ZX_DETAIL_TAX_LINES_GT instead of ZX_LINES.
136 
137               NOTE:  Per eTax, we should not call in quote mode once
138                tax has been calculated on this transaction.
139 
140   OUTPUT:
141     p_gt_id         = sequence ID assigned in GT table for
142                       prorating accounting (needed for arp_acct_Main call)
143     p_prorated_line = portion of p_amount allocated to LINE
144     p_prorated_tax  = portion of p_amount allocated to TAX
145 */
146 PROCEDURE prorate_recoverable(p_adj_id         IN NUMBER,
147                               p_target_id      IN NUMBER,
148                               p_target_line_id IN NUMBER,
149                               p_amount         IN NUMBER,
150                               p_apply_date     IN DATE,
151                               p_mode           IN VARCHAR2,
152                               p_upd_adj_and_ps IN VARCHAR2,
153                               p_gt_id          IN OUT NOCOPY NUMBER,
154                               p_prorated_line  IN OUT NOCOPY NUMBER,
155                               p_prorated_tax   IN OUT NOCOPY NUMBER,
156                               p_quote          IN VARCHAR2 DEFAULT 'N');
157 
158 /* 5677984 -
159    Used to prorate tax across recoverable invoice lines.
160    THIS VERSION SPECIFIC TO RECEIPT APPLICATIONS/UNAPPLICATIONS
161   INPUT:
162     p_adj_id     = adjustment or receipt id         (reqd)
163     p_target_id  = invoice customer_trx_id          (reqd)
164     p_target_line_id = invoice customer_trx_line_id (optional)
165     p_amount     = total adjustment or discount     (reqd)
166     p_apply_date = date effective for application or adj  (reqd)
167     p_mode       = INV, LINE, or TAX                      (reqd)
168                     INV  = zero out
169                     LINE = prorate LINE and TAX
170                     TAX  = tax only
171     p_upd_adj_and_ps = Y/A/Null.  Y means we will update   (optional)
172                        the adj and ps rows (they were already
173                        saved with previous values)
174                        A means update adj only (ps handled locally)
175     p_quote          = Y/N/Null.  Y means we will call etax in
176                        quote mode.  No tax will be stored in repository.
177                        We will have to fetch the estimated tax back
178                        from ZX_DETAIL_TAX_LINES_GT instead of ZX_LINES.
179 
180               NOTE:  Per eTax, we should not call in quote mode once
181                tax has been calculated on this transaction.
182 
183   OUTPUT:
184     p_gt_id         = sequence ID assigned in GT table for
185                       prorating accounting (needed for arp_acct_Main call)
186     p_prorated_line = portion of p_amount allocated to LINE
187     p_prorated_tax  = portion of p_amount allocated to TAX
188 
189   BOTH:
190     p_ra_app_id = the application_id of the current APP or UNAPP
191                        row.  If passed in, we will honor it.  If not
192                        passed, we will get an ID and return it.
193 
194 NOTE:  The original version of prorate_recoverable calls this new
195    version behind the scenes with -1 for application_id.  That prevents
196    assignment of a new ID and maintains backward compatibility for
197    adjustments.
198 */
199 PROCEDURE prorate_recoverable(p_adj_id         IN NUMBER,
200                               p_target_id      IN NUMBER,
201                               p_target_line_id IN NUMBER,
202                               p_amount         IN NUMBER,
203                               p_apply_date     IN DATE,
204                               p_mode           IN VARCHAR2,
205                               p_upd_adj_and_ps IN VARCHAR2,
206                               p_gt_id          IN OUT NOCOPY NUMBER,
207                               p_prorated_line  IN OUT NOCOPY NUMBER,
208                               p_prorated_tax   IN OUT NOCOPY NUMBER,
209                               p_quote          IN VARCHAR2 DEFAULT 'N',
210                               p_ra_app_id IN OUT NOCOPY NUMBER);
211 
212 PROCEDURE adjust_for_inclusive_tax(p_trx_id     IN NUMBER,
213                                    p_request_id IN NUMBER   DEFAULT NULL,
214                                    p_phase      IN VARCHAR2 DEFAULT NULL);
215 
216 PROCEDURE set_recoverable(p_trx_id IN NUMBER,
217                           p_request_id IN NUMBER   DEFAULT NULL,
218                           p_phase      IN VARCHAR2 DEFAULT NULL);
219 
220 /* Function to call etax for tax-related accounts.  Currently
221    only fetches tax and interim accounts.
222 
223    Takes tax trx_line_id, date, and 'TAX' or 'INTERIM' and returns
224    ccid or -1 (no errors)
225 
226    p_subject_table takes either 'TAX_LINE' or 'TAX_RATE' */
227 
228 /* actually supports a list of desired_account values but all
229    except TAX and INTERIM return -1 at this time */
230 FUNCTION  get_tax_account (p_subject_id IN NUMBER,
231                            p_gl_date    IN DATE,
232                            p_desired_account IN VARCHAR2,
233                            p_subject_table IN VARCHAR2 DEFAULT 'TAX_LINE')
234      RETURN NUMBER;
235 
236 PROCEDURE calc_applied_and_remaining ( p_amt            in number
237                                ,p_receipt_id            in number
238                                ,p_apply_date            in date
239                                ,p_trx_id                in number
240                                ,p_mode                  in varchar2
241                                ,p_rule_set_id           in number
242                                ,p_currency              in varchar2
243                                ,p_line_remaining        in out NOCOPY number
244                                ,p_line_tax_remaining    in out NOCOPY number
245                                ,p_freight_remaining     in out NOCOPY number
246                                ,p_charges_remaining     in out NOCOPY number
247                                ,p_line_applied          out NOCOPY number
248                                ,p_line_tax_applied      out NOCOPY number
249                                ,p_freight_applied       out NOCOPY number
250                                ,p_charges_applied       out NOCOPY number
251                                ,p_rec_app_id             in out NOCOPY number
252                                );
253 
254 PROCEDURE distribute_recoverable(p_rec_app_id     IN NUMBER,
255                                  p_gt_id          IN NUMBER);
256 
257 FUNCTION  get_discount_rate(p_trx_id              IN NUMBER)
258     RETURN NUMBER;
259 
260 PROCEDURE validate_for_tax (p_request_id IN NUMBER);
261 
262 END ARP_ETAX_UTIL;