[Home] [Help]
PACKAGE BODY: APPS.AR_INVOICE_DEFAULT_PVT
Source
1 PACKAGE BODY AR_INVOICE_DEFAULT_PVT AS
2 /* $Header: ARXVINDB.pls 120.7.12010000.2 2008/11/13 05:41:45 dgaurab ship $ */
3
4 pg_debug VARCHAR2(1) := nvl(fnd_profile.value('AFLOG_ENABLED'),'N');
5
6 PROCEDURE Get_system_parameters (
7 p_trx_system_parameters_rec OUT NOCOPY trx_system_parameters_rec_type,
8 x_errmsg OUT NOCOPY VARCHAR2,
9 x_return_status OUT NOCOPY VARCHAR2) IS
10
11 BEGIN
12 IF pg_debug = 'Y'
13 THEN
14 ar_invoice_utils.debug ('AR_INVOICE_DEFAULT_PVT.Get_system_parameters(+)' );
15 END IF;
16 x_return_status := FND_API.G_RET_STS_SUCCESS;
17
18 /* 5921925 - copy info from arp_global.sysparam rather than selecting
19 from the db (again) */
20 arp_global.init_global;
21
22 trx_system_parameters_rec.set_of_books_id := arp_global.sysparam.set_of_books_id;
23 trx_system_parameters_rec.accounting_method := arp_global.sysparam.accounting_method;
24 trx_system_parameters_rec.accrue_interest := arp_global.sysparam.accrue_interest;
25 trx_system_parameters_rec.unearned_discount := arp_global.sysparam.unearned_discount;
26 trx_system_parameters_rec.partial_discount_flag := arp_global.sysparam.partial_discount_flag;
27 trx_system_parameters_rec.print_remit_to := arp_global.sysparam.print_remit_to;
28 trx_system_parameters_rec.default_cb_due_date := arp_global.sysparam.default_cb_due_date;
29 trx_system_parameters_rec.auto_site_numbering := arp_global.sysparam.auto_site_numbering;
30 trx_system_parameters_rec.cash_basis_set_of_books_id := arp_global.sysparam.cash_basis_set_of_books_id;
31 trx_system_parameters_rec.code_combination_id_gain := arp_global.sysparam.code_combination_id_gain;
32 trx_system_parameters_rec.autocash_hierarchy_id := arp_global.sysparam.autocash_hierarchy_id;
33 trx_system_parameters_rec.run_gl_journal_import_flag := arp_global.sysparam.run_gl_journal_import_flag;
34 trx_system_parameters_rec.cer_split_amount := arp_global.sysparam.cer_split_amount;
35 trx_system_parameters_rec.cer_dso_days := arp_global.sysparam.cer_dso_days;
36 trx_system_parameters_rec.posting_days_per_cycle := arp_global.sysparam.posting_days_per_cycle;
37 trx_system_parameters_rec.address_validation := arp_global.sysparam.address_validation;
38 trx_system_parameters_rec.calc_discount_on_lines_flag := arp_global.sysparam.calc_discount_on_lines_flag;
39 trx_system_parameters_rec.change_printed_invoice_flag := arp_global.sysparam.change_printed_invoice_flag;
40 trx_system_parameters_rec.code_combination_id_loss := arp_global.sysparam.code_combination_id_loss;
41 trx_system_parameters_rec.create_reciprocal_flag := arp_global.sysparam.create_reciprocal_flag;
42 trx_system_parameters_rec.default_country := arp_global.sysparam.default_country;
43 trx_system_parameters_rec.default_territory := arp_global.sysparam.default_territory;
44 trx_system_parameters_rec.generate_customer_number := arp_global.sysparam.generate_customer_number;
45 trx_system_parameters_rec.invoice_deletion_flag := arp_global.sysparam.invoice_deletion_flag;
46 trx_system_parameters_rec.location_structure_id := arp_global.sysparam.location_structure_id;
47 trx_system_parameters_rec.site_required_flag := arp_global.sysparam.site_required_flag;
48 trx_system_parameters_rec.tax_allow_compound_flag := arp_global.sysparam.tax_allow_compound_flag;
49 trx_system_parameters_rec.tax_header_level_flag := arp_global.sysparam.tax_header_level_flag;
50 trx_system_parameters_rec.tax_rounding_allow_override := arp_global.sysparam.tax_rounding_allow_override;
51 trx_system_parameters_rec.tax_invoice_print := arp_global.sysparam.tax_invoice_print;
52 trx_system_parameters_rec.tax_method := arp_global.sysparam.tax_method;
53 trx_system_parameters_rec.tax_use_customer_exempt_flag := arp_global.sysparam.tax_use_customer_exempt_flag;
54 trx_system_parameters_rec.tax_use_cust_exc_rate_flag := arp_global.sysparam.tax_use_cust_exc_rate_flag;
55 trx_system_parameters_rec.tax_use_loc_exc_rate_flag := arp_global.sysparam.tax_use_loc_exc_rate_flag;
56 trx_system_parameters_rec.tax_use_product_exempt_flag := arp_global.sysparam.tax_use_product_exempt_flag;
57 trx_system_parameters_rec.tax_use_prod_exc_rate_flag := arp_global.sysparam.tax_use_prod_exc_rate_flag;
58 trx_system_parameters_rec.tax_use_site_exc_rate_flag := arp_global.sysparam.tax_use_site_exc_rate_flag;
59 trx_system_parameters_rec.ai_log_file_message_level := arp_global.sysparam.ai_log_file_message_level;
60 trx_system_parameters_rec.ai_max_memory_in_bytes := arp_global.sysparam.ai_max_memory_in_bytes;
61 trx_system_parameters_rec.ai_acct_flex_key_left_prompt := arp_global.sysparam.ai_acct_flex_key_left_prompt;
62 trx_system_parameters_rec.ai_mtl_items_key_left_prompt := arp_global.sysparam.ai_mtl_items_key_left_prompt;
63 trx_system_parameters_rec.ai_territory_key_left_prompt := arp_global.sysparam.ai_territory_key_left_prompt;
64 trx_system_parameters_rec.ai_purge_int_tables_flag := arp_global.sysparam.ai_purge_interface_tables_flag;
65 trx_system_parameters_rec.ai_activate_sql_trace_flag := arp_global.sysparam.ai_activate_sql_trace_flag;
66 trx_system_parameters_rec.default_grouping_rule_id := arp_global.sysparam.default_grouping_rule_id;
67 trx_system_parameters_rec.salesrep_required_flag := arp_global.sysparam.salesrep_required_flag;
68 trx_system_parameters_rec.auto_rec_invoices_per_commit := arp_global.sysparam.auto_rec_invoices_per_commit;
69 trx_system_parameters_rec.auto_rec_receipts_per_commit := arp_global.sysparam.auto_rec_receipts_per_commit;
70 trx_system_parameters_rec.pay_unrelated_invoices_flag := arp_global.sysparam.pay_unrelated_invoices_flag;
71 trx_system_parameters_rec.print_home_country_flag := arp_global.sysparam.print_home_country_flag;
72 trx_system_parameters_rec.location_tax_account := arp_global.sysparam.location_tax_account;
73 trx_system_parameters_rec.from_postal_code := arp_global.sysparam.from_postal_code;
74 trx_system_parameters_rec.to_postal_code := arp_global.sysparam.to_postal_code;
75 trx_system_parameters_rec.tax_registration_number := arp_global.sysparam.tax_registration_number;
76 trx_system_parameters_rec.populate_gl_segments_flag := arp_global.sysparam.populate_gl_segments_flag;
77 trx_system_parameters_rec.unallocated_revenue_ccid := arp_global.sysparam.unallocated_revenue_ccid;
78 trx_system_parameters_rec.org_id := arp_global.sysparam.org_id;
79 trx_system_parameters_rec.base_currency_code := arp_global.functional_currency;
80 trx_system_parameters_rec.chart_of_accounts_id := arp_global.chart_of_accounts_id;
81 trx_system_parameters_rec.period_set_name := arp_global.period_set_name;
82 -- trx_system_parameters_rec.short_name := arp_global.sysparam.short_name;
83 trx_system_parameters_rec.precision := arp_global.base_precision;
84 -- trx_system_parameters_rec.EXTENDED_PRECISION := arp_global.sysparam.extended_precision;
85 trx_system_parameters_rec.MINIMUM_ACCOUNTABLE_UNIT := arp_global.base_min_acc_unit;
86 -- trx_system_parameters_rec.yes_meaning := l_yes_meaning;
87 -- trx_system_parameters_rec.no_meaning := l_no_meaning;
88 trx_system_parameters_rec.inclusive_tax_used := arp_global.sysparam.inclusive_tax_used;
89 trx_system_parameters_rec.tax_enforce_account_flag := arp_global.sysparam.tax_enforce_account_flag;
90 trx_system_parameters_rec.ta_installed_flag := arp_global.sysparam.ta_installed_flag;
91 trx_system_parameters_rec.br_enabled_flag := arp_global.sysparam.bills_receivable_enabled_flag;
92 trx_system_parameters_rec.DOCUMENT_SEQ_GEN_LEVEL := arp_global.sysparam.DOCUMENT_SEQ_GEN_LEVEL;
93 trx_system_parameters_rec.trx_header_level_rounding := arp_global.sysparam.trx_header_level_rounding;
94
95 p_trx_system_parameters_rec := trx_system_parameters_rec;
96 IF pg_debug = 'Y'
97 THEN
98 ar_invoice_utils.debug ('AR_INVOICE_DEFAULT_PVT.Get_system_parameters(-)' );
99 END IF;
100
101 EXCEPTION
102 WHEN OTHERS THEN
103 x_errmsg := 'Error in AR_INVOICE_DEFAULT_PVT.Get_system_parameters '||sqlerrm;
104 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
105 return;
106
107 END;
108 PROCEDURE Get_profile_values(
109 p_trx_profile_rec OUT NOCOPY trx_profile_rec_type,
110 x_errmsg OUT NOCOPY VARCHAR2,
111 x_return_status OUT NOCOPY VARCHAR2) IS
112 l_profile_value varchar2(240);
113 l_result boolean;
114 l_dummy varchar2(240);
115 l_user_conversion_type VARCHAR2(30);
116 l_user_profile_option_name VARCHAR2(240);
117
118 BEGIN
119 --- Get profile options
120 IF pg_debug = 'Y'
121 THEN
122 ar_invoice_utils.debug ('AR_INVOICE_DEFAULT_PVT.Get_profile_values(+)' );
123 END IF;
124
125 x_return_status := FND_API.G_RET_STS_SUCCESS;
126
127 trx_profile_rec.ar_unique_seq_numbers := fnd_profile.value('UNIQUE:SEQ_NUMBERS');
128
129 /* 4743228 - swap AR to ZX profiles for etax */
130 trx_profile_rec.ar_allow_manual_tax_lines := fnd_profile.value('ZX_ALLOW_MANUAL_TAX_LINES');
131 trx_profile_rec.ar_allow_tax_code_override := fnd_profile.value('ZX_ALLOW_TAX_CLASSIF_OVERRIDE');
132 trx_profile_rec.ar_allow_trx_line_exemptions := fnd_profile.value('ZX_ALLOW_TRX_LINE_EXEMPTIONS');
133 /* 4743228 - end */
134
135 trx_profile_rec.ar_batch_source := fnd_profile.value('AR_BATCH_SOURCE');
136 trx_profile_rec.ar_ra_batch_source := fnd_profile.value('AR_RA_BATCH_SOURCE');
137 trx_profile_rec.ar_update_due_date := fnd_profile.value('AR_UPDATE_DUE_DATE');
138 trx_profile_rec.ussgl_option := NVL(fnd_profile.value('USSGL_OPTION'),'N');
139 trx_profile_rec.ar_allow_salescredit_update := fnd_profile.value('AR_ALLOW_SALESCREDIT_UPDATE');
140 trx_profile_rec.so_organization_id := oe_profile.value('SO_ORGANIZATION_ID');
141 trx_profile_rec.so_source_code := oe_profile.value('SO_SOURCE_CODE');
142 trx_profile_rec.so_id_flex_code := oe_profile.value('SO_ID_FLEX_CODE');
143 trx_profile_rec.ar_jg_create_bank_charges := NVL(fnd_profile.value('AR_JG_CREATE_BANK_CHARGES'),'N');
144
145
146 fnd_profile.get('AR_DEFAULT_EXCHANGE_RATE_TYPE', l_profile_value);
147 IF (l_profile_value IS NOT NULL) THEN
148 BEGIN
149 SELECT user_conversion_type
150 INTO l_user_conversion_type
151 FROM GL_DAILY_CONVERSION_TYPES
152 WHERE conversion_type = l_profile_value;
153
154 SELECT user_profile_option_name
155 INTO l_user_profile_option_name
156 FROM FND_PROFILE_OPTIONS_VL
157 WHERE application_id = 222
158 AND profile_option_name = 'AR_DEFAULT_EXCHANGE_RATE_TYPE';
159
160
161 EXCEPTION
162 WHEN NO_DATA_FOUND THEN
163 l_profile_value := NULL;
164 l_user_conversion_type := NULL;
165 l_user_profile_option_name := NULL;
166 END;
167 END IF;
168
169 trx_profile_rec.default_exchange_rate_type := l_profile_value;
170 trx_profile_rec.default_exchange_rate_type_dsp := l_user_conversion_type;
171 trx_profile_rec.def_exchange_rate_type_profile := l_user_profile_option_name;
172
173 l_result := fnd_installation.get_app_info('OE',
174 l_profile_value,
175 l_dummy,
176 l_dummy);
177
178 trx_profile_rec.so_installed_flag := l_profile_value;
179
180
181 -- IF (p_mode <> 'RECEIPTS')
182 -- THEN
183 IF ( arp_auto_accounting.query_autoacc_def('REV', 'RA_SALESREPS') = TRUE )
184 THEN
185 trx_profile_rec.rev_based_on_srep_flag := 'Y';
186 ELSE
187 trx_profile_rec.rev_based_on_srep_flag := 'N';
188 END IF;
189
190 IF ( arp_auto_accounting.query_autoacc_def('ALL', 'RA_SALESREPS') = TRUE )
191 THEN
192 trx_profile_rec.autoacc_based_on_srep_flag := 'Y';
193 ELSE
194 trx_profile_rec.autoacc_based_on_srep_flag := 'N';
195 END IF;
196
197 IF (
198 arp_auto_accounting.query_autoacc_def('FREIGHT', 'RA_SALESREPS') = TRUE
199 OR arp_auto_accounting.query_autoacc_def('REC', 'RA_SALESREPS') = TRUE
200 )
201 THEN
202 trx_profile_rec.autoacc_based_on_primary_srep := 'Y';
203 ELSE
204 trx_profile_rec.autoacc_based_on_primary_srep := 'N';
205 END IF;
206
207 IF ( arp_auto_accounting.query_autoacc_def('REV', 'AGREEMENT/CATEGORY') = TRUE )
208 THEN
209 trx_profile_rec.autoacc_based_on_agree_cat := 'Y';
210 ELSE
211 trx_profile_rec.autoacc_based_on_agree_cat := 'N';
212 END IF;
213
214
215 IF ( arp_auto_accounting.query_autoacc_def('ALL', 'RA_CUST_TRX_TYPES') = TRUE )
216 THEN
217 trx_profile_rec.autoacc_based_on_type_flag := 'Y';
218 ELSE
219 trx_profile_rec.autoacc_based_on_type_flag := 'N';
220 END IF;
221
222 IF ( arp_auto_accounting.query_autoacc_def('ALL', 'RA_STD_TRX_LINES') = TRUE )
223 THEN
224 trx_profile_rec.autoacc_based_on_item_flag := 'Y';
225 ELSE
226 trx_profile_rec.autoacc_based_on_item_flag := 'N';
227 END IF;
228
229 IF ( arp_auto_accounting.query_autoacc_def('TAX', 'RA_TAXES') = TRUE )
230 THEN
231 trx_profile_rec.autoacc_based_on_tax_code := 'Y';
232 ELSE
233 trx_profile_rec.autoacc_based_on_tax_code := 'N';
234 END IF;
235
236 IF ( arp_auto_accounting.query_autoacc_def('ALL', 'RA_SITE_USES') = TRUE )
237 THEN
238 trx_profile_rec.autoacc_based_on_site_flag := 'Y';
239 ELSE
240 trx_profile_rec.autoacc_based_on_site_flag := 'N';
241 END IF;
242
243
244
245 p_trx_profile_rec := trx_profile_rec;
246 IF pg_debug = 'Y'
247 THEN
248 ar_invoice_utils.debug ('AR_INVOICE_DEFAULT_PVT.Get_profile_values(-)' );
249 END IF;
250 EXCEPTION
251 WHEN OTHERS
252 THEN
253 x_errmsg := 'Error in AR_INVOICE_DEFAULT_PVT.Get_profile_values '||sqlerrm;
254 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
255 return;
256
257 END;
258
259
260
261 procedure ar_common_init( p_code_combination_id_gain in number ) is
262 l_ar_receipt_multi_curr_flag varchar2(1);
263 begin
264 IF (p_code_combination_id_gain IS NULL) THEN
265 trx_system_parameters_rec.ar_multi_currency_flag := 'N';
266 trx_system_parameters_rec.ar_receipt_multi_currency_flag := 'N';
267 ELSE
268 trx_system_parameters_rec.ar_multi_currency_flag := 'Y';
269 trx_system_parameters_rec.ar_receipt_multi_currency_flag := 'Y';
270 END IF;
271 end ar_common_init;
272
273
274
275
276
277 PROCEDURE Default_gl_date IS
278
279 l_error_message VARCHAR2(128);
280 l_defaulting_rule_used VARCHAR2(50);
281 l_default_gl_date DATE;
282
283 /* 5921925 - Added post_to_gl logic so headers are skipped
284 if they are not supposed to post to gl */
285 CURSOR ar_invoice_gt_c IS
286 SELECT nvl(hdr.trx_date, sysdate) trx_date, hdr.set_of_books_id,
287 hdr.trx_header_id
288 FROM ar_trx_header_gt hdr,
289 ra_cust_trx_types tt
290 WHERE gl_date IS NULL
291 AND hdr.cust_trx_type_id = tt.cust_trx_type_id
292 AND NVL(tt.post_to_gl,'N') = 'Y';
293
294 BEGIN
295 IF pg_debug = 'Y'
296 THEN
297 ar_invoice_utils.debug ('AR_INVOICE_DEFAULT_PVT.Default_gl_date(+)' );
298 END IF;
299 FOR ar_invoice_gt_rec IN ar_invoice_gt_c
300 LOOP
301 IF (arp_util.validate_and_default_gl_date(
302 ar_invoice_gt_rec.trx_date,
303 NULL,
304 NULL,
305 NULL,
306 NULL,
307 ar_invoice_gt_rec.trx_date,
308 NULL,
309 NULL,
310 'N',
311 NULL,
312 ar_invoice_gt_rec.set_of_books_id,
313 222,
314 l_default_gl_date,
315 l_defaulting_rule_used,
316 l_error_message) = TRUE)
317 THEN
318 IF pg_debug = 'Y'
319 THEN
320 ar_invoice_utils.debug ('Default GL Date ' || l_default_gl_date);
321 END IF;
322
323 UPDATE ar_trx_header_gt
324 SET gl_date = l_default_gl_date
325 WHERE trx_header_id = ar_invoice_gt_rec.trx_header_id;
326
327 UPDATE ar_trx_dist_gt
328 SET gl_date = l_default_gl_date
329 WHERE trx_header_id = ar_invoice_gt_rec.trx_header_id
330 AND gl_date is null;
331
332 END IF;
333 END LOOP;
334 IF pg_debug = 'Y'
335 THEN
336 ar_invoice_utils.debug ('AR_INVOICE_DEFAULT_PVT.Default_gl_date(-)' );
337 END IF;
338 END default_gl_date;
339
340 END;