DBA Data[Home] [Help]

PACKAGE: APPS.AP_TAX_ENGINE_PKG

Source


4 TYPE tax_info_rec_type IS RECORD
1 package Ap_TAX_ENGINE_PKG AUTHID CURRENT_USER as
2 /* $Header: aptxengs.pls 120.2 2005/10/06 18:11:38 hongliu noship $ */
3 
5 (
6 
7 -- This record holds general information used by the tax engine about
8 -- each transaction, transaction line and tax line. Records in this
9 -- global can change on each row returned from any of the tax views.
10 
11 ----------------------------------------------------------------------
12 --  Primary Keys
13 ----------------------------------------------------------------------
14 trx_header_id                   po_headers_all.po_header_id%TYPE,
15 trx_line_id                     po_lines_all.po_line_id%TYPE,
16 trx_shipment_id                 po_line_locations_all.line_location_id%TYPE,
17 trx_distribution_id             po_distributions_all.po_distribution_id%TYPE,
18 
19 
20 ----------------------------------------------------------------------
21 --  Transaction Information
22 ----------------------------------------------------------------------
23 tax_line_number                 varchar2(1),
24 set_of_books_id                 po_distributions_all.set_of_books_id%TYPE,
25 request_id                      po_headers_all.request_id%TYPE,
26 trx_number                      ap_invoices_all.invoice_num%TYPE,
27 previous_trx_header_id          number(15),
28 trx_date                        po_headers_all.last_update_date%TYPE,
29 trx_currency_code               po_headers_all.currency_code%TYPE,
30 exchange_rate                   po_headers_all.rate%TYPE,
31 minimum_accountable_unit        fnd_currencies.minimum_accountable_unit%TYPE,
32 precision                       fnd_currencies.precision%TYPE,
33 ship_from_supplier_id           po_headers_all.vendor_id%TYPE,
34 ship_from_supplier_number       po_vendors.segment1%TYPE,
35 ship_from_supplier_name         po_vendors.vendor_name%TYPE,
36 ship_from_site_use_id           po_headers_all.vendor_site_id%TYPE,
37 ship_from_country               po_vendor_sites_all.country%TYPE,
38 ship_from_state                 po_vendor_sites_all.state%TYPE,
39 ship_from_county                po_vendor_sites_all.county%TYPE,
40 -- Modified the definition of ship_to_city for bug 3480512 ..
41 ship_from_city                  po_vendor_sites_all.city%TYPE,
42 ship_from_province              varchar2(150),
43 ship_from_postal_code           po_vendor_sites_all.zip%TYPE,
44 ship_from_in_city_limits_flag   varchar2(1),
45 ship_from_geocode               varchar2(1),
46 line_number                     po_lines_all.line_num%TYPE,
47 trx_line_type                   po_line_types_tl.line_type%TYPE,
48 inventory_item_id               po_lines_all.item_id%TYPE,
49 part_number                     mtl_system_items.segment1%TYPE,
50 quantity                        po_line_locations_all.quantity%TYPE,
51 quantity_ordered                po_distributions_all.quantity_ordered%TYPE,
52 unit_price                      po_lines_all.unit_price%TYPE,
53 price_override                  po_line_locations_all.price_override%TYPE,
54 taxable_flag                    po_line_locations_all.taxable_flag%TYPE,
55 code_combination_id             po_distributions_all.code_combination_id%TYPE,
56 fob_code                        po_headers_all.fob_lookup_code%TYPE,
57 previous_trx_line_id            ap_invoice_distributions_all.po_distribution_id%TYPE,
58 ussgl_transaction_code          po_lines_all.ussgl_transaction_code%TYPE,
59 ussgl_trx_code_context          po_lines_all.government_context%TYPE,
60 ship_to_location_id             po_line_locations_all.ship_to_location_id%TYPE,
61 ship_to_organization_id         po_line_locations_all.ship_to_organization_id%TYPE,
62 ship_to_warehouse_id            varchar2(1),
63 ship_to_country                 hr_locations_all.country%TYPE,
64 ship_to_state                   varchar2(150),
65 ship_to_county                  varchar2(150),
66 ship_to_city                    hz_locations.city%TYPE,
67 ship_to_province                varchar2(150),
68 ship_to_postal_code             hr_locations_all.postal_code%TYPE,
69 ship_to_in_city_limits_flag     varchar2(1),
70 ship_to_geocode                 varchar2(1),
71 poo_address_code                varchar2(1),
75 tax_user_override_flag          po_line_locations_all.tax_user_override_flag%TYPE,
72 poa_address_code                varchar2(1),
73 tax_code_id                     ap_tax_codes_all.tax_id%TYPE,
74 tax_code                        ap_tax_codes_all.name%TYPE,
76 tax_rate                        ap_tax_codes_all.tax_rate%TYPE,
77 total_tax_amount                po_distributions_all.recoverable_tax%TYPE,
78 recoverable_tax                 po_distributions_all.recoverable_tax%TYPE,
79 nonrecoverable_tax              po_distributions_all.nonrecoverable_tax%TYPE,
80 location_qualifier              varchar2(1),
81 compounding_precedence          varchar2(1),
82 tax_exemption_id                varchar2(1),
83 tax_exception_id                varchar2(1),
84 vendor_control_exemptions       varchar2(1),
85 tax_recovery_rate               po_distributions_all.recovery_rate%TYPE,
86 tax_recovery_override_flag      po_distributions_all.tax_recovery_override_flag%TYPE,
87 global_attribute1               po_line_locations_all.global_attribute1%TYPE,
88 global_attribute2               po_line_locations_all.global_attribute2%TYPE,
89 global_attribute3               po_line_locations_all.global_attribute3%TYPE,
90 global_attribute4               po_line_locations_all.global_attribute4%TYPE,
91 global_attribute5               po_line_locations_all.global_attribute5%TYPE,
92 global_numeric_attribute1       varchar2(1),
93 global_numeric_attribute2       varchar2(1),
94 global_numeric_attribute3       varchar2(1),
95 global_numeric_attribute4       varchar2(1),
96 global_numeric_attribute5       varchar2(1),
97 tax_exempt_flag                 varchar2(1),
98 tax_exempt_number               varchar2(1),
99 tax_exempt_reason_code          varchar2(1),
100 company_code                    varchar2(1),
101 division_code                   varchar2(1),
102 audit_flag                      varchar2(1),
103 tax_header_level_flag           varchar2(1),
104 --tax_rounding_rule               po_vendor_sites_all.ap_tax_rounding_rule%TYPE,
105 tax_rounding_rule               ap_supplier_sites_all.ap_tax_rounding_rule%TYPE,
106 tax_type                        ap_tax_codes_all.tax_type%TYPE,
107 tax_description                 ap_tax_codes_all.description%TYPE,
108 allow_tax_code_override_flag    gl_tax_option_accounts.allow_tax_code_override_flag%TYPE,
109 project_id                      ap_invoice_distributions_all.project_id%TYPE,
110 task_id                         ap_invoice_distributions_all.task_id%TYPE,
111 award_id                        ap_invoice_distributions_all.award_id%TYPE,
112 expenditure_type                ap_invoice_distributions_all.expenditure_type%TYPE,
113 expenditure_organization_id     ap_invoice_distributions_all.expenditure_organization_id%TYPE,
114 expenditure_item_date           ap_invoice_distributions_all.expenditure_item_date%TYPE,
115 pa_quantity                     ap_invoice_distributions_all.pa_quantity%TYPE,
116 tax_minimum_accountable_unit    financials_system_params_all.minimum_accountable_unit%TYPE,
117 tax_precision                   financials_system_params_all.precision%TYPE,
118 amount_includes_tax_flag        ap_invoice_distributions_all.amount_includes_tax_flag%TYPE,
119 tax_calculated_flag             ap_invoice_distributions_all.tax_calculated_flag%TYPE,
120 tax_recoverable_flag            ap_invoice_distributions_all.tax_recoverable_flag%TYPE,
121 currency_unit_price             po_requisition_lines_all.currency_unit_price%TYPE,
122 account_gl_date                 ap_invoice_distributions_all.accounting_date%TYPE,
123 prepay_tax_parent_id            NUMBER,
124 invoice_includes_prepay_flag    varchar2(1),
125 -- Added for the bug 2373358 by zmohiudd..
126 rcv_transaction_id ap_invoice_distributions_all.rcv_transaction_id%TYPE,
127 -- added for bug 3672005
128 assets_tracking_flag            ap_invoice_distributions_all.assets_tracking_flag%TYPE
129 );
130 
131 
132 g_tax_info_rec   tax_info_rec_type;
133 
134 TYPE tax_info_rec_tbl_type IS TABLE OF tax_info_rec_type
135      INDEX BY BINARY_INTEGER;
136 
137 g_tax_info_tbl     AP_TAX_ENGINE_PKG.tax_info_rec_tbl_type;
138 g_pdt_tax_info_tbl AP_TAX_ENGINE_PKG.tax_info_rec_tbl_type;
139 g_appl_name        FND_APPLICATION.application_short_name%TYPE;
140 
141 --Index of table g_tax_info_tbl
142 g_num INTEGER := 0;
143 
144 
145 -- Define record and table types to create allocations in AP_CHRG_ALLOCATIONS table
146 -- AP_CHRG_ALLOCATIONS links tax and taxable items.
147 
148 TYPE tax_alloc_rec_type is RECORD (item_dist_id             NUMBER(15),
149                                    allocated_amount         NUMBER,
150                                    charge_dist_id           NUMBER(15));
151 
152 TYPE tax_alloc_tbl_type is TABLE of tax_alloc_rec_type
153                  index by BINARY_INTEGER;
154 
155 g_rec_tax_alloc_tbl      tax_alloc_tbl_type;
156 g_nonrec_tax_alloc_tbl   tax_alloc_tbl_type;
157 
158 --Indexes for table g_tax_info_tbl
159 
160 g_rec_alloc_num INTEGER := 0;
161 g_nonrec_alloc_num INTEGER := 0;
162 
163 
164 TYPE system_info_rec_type IS RECORD
165 (
166   --
167   -- Note: This record holds general system-level tax information
168   -- All tax information should be moved to the consolidated view structure,
169   -- even if it resides at system level.
170   --
171         ap                           ap_system_parameters%ROWTYPE,
172         inventory_organization_id    financials_system_params_all.org_id%TYPE
173 );
174 
175 sysinfo system_info_rec_type;
176 
177 ap                              ap_system_parameters%ROWTYPE;
178 
179 inventory_organization_id       financials_system_params_all.inventory_organization_id%TYPE;
180 
181 
182 PROCEDURE calculate_tax
183           (p_viewname                   IN  VARCHAR2,
184            p_trx_header_id              IN  NUMBER,
185            p_trx_line_id                IN  NUMBER,
186            p_trx_shipment_id            IN  NUMBER,
190 
187            p_calling_sequence           IN  VARCHAR2,
188            p_tax_info_tbl               IN OUT NOCOPY tax_info_rec_tbl_type
189            );
191 PROCEDURE calculate_tax
192           ( p_pdt_tax_info_tbl           IN  AP_TAX_ENGINE_PKG.tax_info_rec_tbl_type
193            ,p_application_name           IN  VARCHAR2
194            ,p_tax_info_tbl               IN OUT NOCOPY AP_TAX_ENGINE_PKG.tax_info_rec_tbl_type
195            );
196 
197 PROCEDURE copy_record
198           (p_calling_sequence           IN VARCHAR2,
199            p_tax_info_rec               IN tax_info_rec_type
200            );
201 
202 
203 PROCEDURE initialize_g_tax_info_rec
204           (p_calling_sequence           IN VARCHAR2
205            );
206 
207 /* Function called by view JG_AP_TAX_LINES_SUMMARY_V to provide multiple tax inclusive calculation solution. */
208 FUNCTION sum_tax_group_rate
209           (p_tax_group_id               IN  ar_tax_group_codes_all.tax_group_id%TYPE,
210            p_trx_date                   IN  ap_invoices_all.invoice_date%TYPE,
211            p_vendor_site_id             IN  po_vendor_sites_all.vendor_site_id%TYPE
212            )
213                                         return NUMBER;
214 
215 /* Function called by view AP_TAX_LINES_SUMMARY_V to provide inclusive tax calculation with offset solution. */
216 FUNCTION offset_factor
217    (p_offset_tax_flag	     IN  ap_supplier_sites_all.offset_tax_flag%TYPE,
218     p_amount_includes_tax_flag IN ap_invoice_distributions_all.amount_includes_tax_flag%TYPE,
219     p_tax_rate		IN ap_tax_codes_all.tax_rate%TYPE,
220     p_offset_tax_code_id     IN  ap_tax_codes_all.offset_tax_code_id%TYPE,
221     p_trx_date         IN  ap_invoices_all.invoice_date%TYPE)
222 					 return NUMBER;
223 
224 /* Function called by the tax view to get orginal amount (replace aid.amount) */
225 FUNCTION get_amount( p_invoice_distribution_id     NUMBER,
226                      p_line_type_lookup_code       VARCHAR2,
227                      p_amount_includes_tax_flag    VARCHAR2,
228                      p_amount                      NUMBER )
229                                         return NUMBER;
230 
231 end AP_TAX_ENGINE_PKG;