[Home] [Help]
PACKAGE BODY: APPS.ARP_BR_ALLOC_WRAPPER_PKG
Source
1 PACKAGE BODY ARP_BR_ALLOC_WRAPPER_PKG AS
2 /* $Header: ARTWRAPB.pls 115.10 2004/03/16 03:22:30 vahluwal noship $ */
3
4 /* =======================================================================
5 | Package Globals BR - Bills Receivable
6 * ======================================================================*/
7 g_ae_line_tbl ae_line_tbl_type;
8 g_empty_ae_line_tbl ae_line_tbl_type;
9 g_ae_line_ctr BINARY_INTEGER;
10
11 /* =======================================================================
12 | Prototype declarations
13 * ======================================================================*/
14 PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
15
16 PROCEDURE Get_Assign_Rate_Alloc_Tax(
17 p_mode IN VARCHAR2 ,
18 p_ae_doc_rec IN ae_doc_rec_type ,
19 p_ae_event_rec IN ae_event_rec_type ,
20 p_cust_inv_rec IN ra_customer_trx%ROWTYPE ,
21 p_ae_sys_rec IN ae_sys_rec_type ,
22 p_ae_rule_rec IN OUT NOCOPY ae_rule_rec_type ,
23 p_app_rec IN OUT NOCOPY ar_receivable_applications%ROWTYPE,
24 p_adj_rec IN OUT NOCOPY ar_adjustments%ROWTYPE );
25
26 PROCEDURE Assign_Ael_Elements(
27 p_mode IN VARCHAR2 ,
28 p_ae_doc_rec IN ae_doc_rec_type ,
29 p_ae_event_rec IN ae_event_rec_type ,
30 p_ae_line_rec IN ae_line_rec_type );
31
32 PROCEDURE Allocate_Tax_BR_Main(
33 p_mode IN VARCHAR2 ,
34 p_ae_doc_rec IN ae_doc_rec_type ,
35 p_ae_event_rec IN ae_event_rec_type ,
36 p_ae_rule_rec IN ae_rule_rec_type ,
37 p_app_rec IN ar_receivable_applications%ROWTYPE ,
38 p_cust_inv_rec IN ra_customer_trx%ROWTYPE ,
39 p_adj_rec IN ar_adjustments%ROWTYPE ,
40 p_ae_sys_rec IN ae_sys_rec_type ,
41 p_ae_ctr IN OUT NOCOPY BINARY_INTEGER ,
42 p_ae_line_tbl IN OUT NOCOPY ae_line_tbl_type) IS
43
44 l_ae_doc_rec ae_doc_rec_type;
45 l_ae_rule_rec ae_rule_rec_type;
46 l_app_rec ar_receivable_applications%ROWTYPE;
47 l_adj_rec ar_adjustments%ROWTYPE;
48
49 BEGIN
50
51 IF PG_DEBUG in ('Y', 'C') THEN
52 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || 'ARP_ALLOC_WRAPPER_PKG.Allocate_Tax_BR_Main (+)' );
53 END IF;
54
55 /*-----------------------------------------------------------------------------------+
56 | Initialize the compatible records matching input parameters passed to this routine|
57 | This is necessary because the records below are changed for processing purposes. |
58 +-----------------------------------------------------------------------------------*/
59 l_ae_doc_rec := p_ae_doc_rec;
60 l_ae_rule_rec := p_ae_rule_rec;
61 l_app_rec := p_app_rec;
62 l_adj_rec := p_adj_rec;
63
64 /*-----------------------------------------------------------------------------------+
65 | Set called from to Wrapper to indicate that call made from this routine to the tax|
66 | Accounting engine. |
67 +-----------------------------------------------------------------------------------*/
68 l_ae_doc_rec.called_from := 'WRAPPER';
69
70 /*-----------------------------------------------------------------------------------+
71 | Override the source table setting it to RA as we are simulating an application |
72 | for the maturity date event as if we are applying the whole amount to a Bill using|
73 | a receipt application. |
74 +-----------------------------------------------------------------------------------*/
75 IF (l_ae_doc_rec.event = 'MATURITY_DATE') THEN
76 l_ae_doc_rec.source_table := 'RA';
77 END IF;
78
79 g_ae_line_ctr := 0;
80 g_ae_line_tbl := g_empty_ae_line_tbl;
81
82 IF l_ae_doc_rec.source_table = 'RA' THEN
83 l_ae_rule_rec.tax_amt_alloc := nvl(l_app_rec.tax_applied,0) * -1;
84 l_ae_rule_rec.charges_amt_alloc := nvl(l_app_rec.receivables_charges_applied,0) * -1;
85 l_ae_rule_rec.line_amt_alloc := nvl(l_app_rec.line_applied,0) * -1;
86 l_ae_rule_rec.freight_amt_alloc := nvl(l_app_rec.freight_applied,0) * -1;
87
88 arp_util.Set_Buckets(
89 p_header_acctd_amt => nvl(l_app_rec.acctd_amount_applied_to,0) * -1 ,
90 p_base_currency => p_ae_sys_rec.base_currency ,
91 p_exchange_rate => p_cust_inv_rec.exchange_rate ,
92 p_base_precision => p_ae_sys_rec.base_precision ,
93 p_base_min_acc_unit => p_ae_sys_rec.base_min_acc_unit ,
94 p_tax_amt => l_ae_rule_rec.tax_amt_alloc ,
95 p_charges_amt => l_ae_rule_rec.charges_amt_alloc ,
96 p_line_amt => l_ae_rule_rec.line_amt_alloc ,
97 p_freight_amt => l_ae_rule_rec.freight_amt_alloc ,
98 p_tax_acctd_amt => l_ae_rule_rec.tax_acctd_amt_alloc ,
99 p_charges_acctd_amt => l_ae_rule_rec.charges_acctd_amt_alloc ,
100 p_line_acctd_amt => l_ae_rule_rec.line_acctd_amt_alloc ,
101 p_freight_acctd_amt => l_ae_rule_rec.freight_acctd_amt_alloc );
102
103 Get_Assign_Rate_Alloc_Tax(
104 p_mode => p_mode ,
105 p_ae_doc_rec => l_ae_doc_rec ,
106 p_ae_event_rec => p_ae_event_rec ,
107 p_cust_inv_rec => p_cust_inv_rec ,
108 p_ae_sys_rec => p_ae_sys_rec ,
109 p_ae_rule_rec => l_ae_rule_rec ,
110 p_app_rec => l_app_rec ,
111 p_adj_rec => l_adj_rec );
112
113 ELSIF l_ae_doc_rec.source_table = 'ADJ' THEN
114 l_ae_rule_rec.tax_amt_alloc := nvl(l_adj_rec.tax_adjusted,0);
115 l_ae_rule_rec.charges_amt_alloc := nvl(l_adj_rec.receivables_charges_adjusted,0);
116 l_ae_rule_rec.line_amt_alloc := nvl(l_adj_rec.line_adjusted,0);
117 l_ae_rule_rec.freight_amt_alloc := nvl(l_adj_rec.freight_adjusted,0);
118
119 arp_util.Set_Buckets(
120 p_header_acctd_amt => nvl(l_adj_rec.acctd_amount,0) ,
121 p_base_currency => p_ae_sys_rec.base_currency ,
122 p_exchange_rate => p_cust_inv_rec.exchange_rate ,
123 p_base_precision => p_ae_sys_rec.base_precision ,
124 p_base_min_acc_unit => p_ae_sys_rec.base_min_acc_unit ,
125 p_tax_amt => l_ae_rule_rec.tax_amt_alloc ,
126 p_charges_amt => l_ae_rule_rec.charges_amt_alloc ,
127 p_line_amt => l_ae_rule_rec.line_amt_alloc ,
128 p_freight_amt => l_ae_rule_rec.freight_amt_alloc ,
129 p_tax_acctd_amt => l_ae_rule_rec.tax_acctd_amt_alloc ,
130 p_charges_acctd_amt => l_ae_rule_rec.charges_acctd_amt_alloc ,
131 p_line_acctd_amt => l_ae_rule_rec.line_acctd_amt_alloc ,
132 p_freight_acctd_amt => l_ae_rule_rec.freight_acctd_amt_alloc );
133
134
135 Get_Assign_Rate_Alloc_Tax(
136 p_mode => p_mode ,
137 p_ae_doc_rec => l_ae_doc_rec ,
138 p_ae_event_rec => p_ae_event_rec ,
139 p_cust_inv_rec => p_cust_inv_rec ,
140 p_ae_sys_rec => p_ae_sys_rec ,
141 p_ae_rule_rec => l_ae_rule_rec ,
142 p_app_rec => l_app_rec ,
143 p_adj_rec => l_adj_rec );
144
145 ELSE --Unknown source table
146 NULL; --Raise an Error ?
147 END IF;
148
149 /*-----------------------------------------------------------------+
150 | Assign Tax allocated lines to the the in out NOCOPY table to pass |
151 | back to calling rountine |
152 +-----------------------------------------------------------------*/
153 IF g_ae_line_tbl.EXISTS(g_ae_line_ctr) THEN
154
155 p_ae_line_tbl := g_ae_line_tbl;
156 p_ae_ctr := g_ae_line_ctr;
157
158 END IF;
159
160 IF PG_DEBUG in ('Y', 'C') THEN
161 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || 'ARP_ALLOC_WRAPPER_PKG.Allocate_Tax_BR_Main (-)' );
162 END IF;
163
164 EXCEPTION
165 WHEN NO_DATA_FOUND THEN
166 IF PG_DEBUG in ('Y', 'C') THEN
167 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || 'ARP_ALLOC_WRAPPER_PKG.Allocate_Tax_BR_Main - NO_DATA_FOUND' );
168 END IF;
169 RAISE;
170
171 WHEN OTHERS THEN
172 IF PG_DEBUG in ('Y', 'C') THEN
173 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || 'EXCEPTION: ARP_ALLOC_WRAPPER_PKG.Allocate_Tax_BR_Main');
174 END IF;
175 RAISE;
176
177 END Allocate_Tax_BR_Main;
178
179 /*=========================================================================
180 |
181 | PROCEDURE Get_Assign_Rate_Alloc_Tax
182 |
183 | DESCRIPTION
184 | This routine takes a header adjustment or application and creates
185 | sub adjustments or applications for each assignment. Further if an
186 | assignment is a Bill of Exchange then this routine is called
187 | recursively to to allocate the sub activity to assignments for that
188 | Bill
189 |
190 | PARAMETERS
191 | p_ae_doc_rec document record
192 | p_ae_event_rec accounting event record
193 | p_ae_rule_rec Rule and allocation amounts record
194 | p_app_rec Application record
195 | p_cust_inv_rec Customer and exchange rate details for Bill
196 | p_adj_rec Adjustment record
197 |
198 | NOTES
199 |
200 | MODIFICATION HISTORY
201 *=======================================================================*/
202 PROCEDURE Get_Assign_Rate_Alloc_Tax(
203 p_mode IN VARCHAR2 ,
204 p_ae_doc_rec IN ae_doc_rec_type ,
205 p_ae_event_rec IN ae_event_rec_type ,
206 p_cust_inv_rec IN ra_customer_trx%ROWTYPE ,
207 p_ae_sys_rec IN ae_sys_rec_type ,
208 p_ae_rule_rec IN OUT NOCOPY ae_rule_rec_type ,
209 p_app_rec IN OUT NOCOPY ar_receivable_applications%ROWTYPE,
210 p_adj_rec IN OUT NOCOPY ar_adjustments%ROWTYPE ) IS
211
212 CURSOR get_assignments(p_customer_trx_id IN NUMBER) is
213 SELECT ctl.customer_trx_id br_cust_trx_id ,
214 ctl.customer_trx_line_id br_customer_trx_line_id ,
215 ctl.br_ref_customer_trx_id br_ref_customer_trx_id ,
216 ctl.br_ref_payment_schedule_id br_ref_payment_schedule_id ,
217 ct.drawee_id drawee_id ,
218 ct.drawee_site_use_id drawee_site_use_id ,
219 ct.invoice_currency_code invoice_currency_code ,
220 ct.exchange_rate exchange_rate ,
221 ct.exchange_rate_type exchange_rate_type ,
222 ct.exchange_date exchange_date ,
223 ct.trx_date trx_date ,
224 ct.bill_to_customer_id bill_to_customer_id ,
225 ct.bill_to_site_use_id bill_to_site_use_id ,
226 adj.adjustment_id br_adj_id ,
227 nvl(adj.amount,0) br_adj_amt ,
228 nvl(adj.acctd_amount,0) br_adj_acctd_amt ,
229 nvl(adj.line_adjusted,0) br_adj_line_amt ,
230 nvl(adj.tax_adjusted,0) br_adj_tax_amt ,
231 nvl(adj.freight_adjusted,0) br_adj_frt_amt ,
232 nvl(adj.receivables_charges_adjusted,0) br_adj_chrg_amt
233 FROM ra_customer_trx_lines ctl,
234 ar_adjustments adj,
235 ra_customer_trx ct
236 WHERE ctl.customer_trx_id = p_customer_trx_id
237 AND ctl.br_adjustment_id = adj.adjustment_id
238 AND ct.customer_trx_id = ctl.br_ref_customer_trx_id
239 AND adj.status = 'A'
240 order by ctl.customer_trx_line_id;
241
242 TYPE l_br_rec_type IS RECORD (
243 br_cust_trx_id NUMBER,
244 br_customer_trx_line_id NUMBER,
245 br_ref_customer_trx_id NUMBER,
246 br_ref_payment_schedule_id NUMBER,
247 drawee_id NUMBER,
248 drawee_site_use_id NUMBER,
249 invoice_currency_code ra_customer_trx.invoice_currency_code%TYPE,
250 exchange_rate NUMBER,
251 exchange_rate_type ra_customer_trx.exchange_rate_type%TYPE,
252 exchange_date DATE,
253 trx_date DATE,
254 bill_to_customer_id NUMBER,
255 bill_to_site_use_id NUMBER,
256 br_adj_id NUMBER,
257 br_adj_amt NUMBER,
258 br_adj_acctd_amt NUMBER,
259 br_adj_line_amt NUMBER,
260 br_adj_tax_amt NUMBER,
261 br_adj_frt_amt NUMBER,
262 br_adj_chrg_amt NUMBER,
263 br_adj_line_acctd_amt NUMBER,
264 br_adj_tax_acctd_amt NUMBER,
265 br_adj_frt_acctd_amt NUMBER,
266 br_adj_chrg_acctd_amt NUMBER
267 );
268
269 TYPE l_br_tbl_type IS TABLE of l_br_rec_type
270 INDEX BY BINARY_INTEGER;
271
272 l_ae_line_tbl ae_line_tbl_type;
273 l_ael_line_rec ae_line_rec_type;
274 l_empty_ael_line_rec ae_line_rec_type;
275
276 l_br_tbl l_br_tbl_type;
277 l_assn_ctr BINARY_INTEGER := 0;
278 l_assn_tot_tax_amt NUMBER := 0;
279 l_assn_tot_tax_acctd_amt NUMBER := 0;
280 l_assn_tot_chrg_amt NUMBER := 0;
281 l_assn_tot_chrg_acctd_amt NUMBER := 0;
282 l_assn_tot_line_amt NUMBER := 0;
283 l_assn_tot_line_acctd_amt NUMBER := 0;
284 l_assn_tot_frt_amt NUMBER := 0;
285 l_assn_tot_frt_acctd_amt NUMBER := 0;
286 l_pro_tax_amt NUMBER := 0;
287 l_pro_tax_acctd_amt NUMBER := 0;
288 l_pro_chrg_amt NUMBER := 0;
289 l_pro_chrg_acctd_amt NUMBER := 0;
290 l_pro_line_amt NUMBER := 0;
291 l_pro_line_acctd_amt NUMBER := 0;
292 l_pro_frt_amt NUMBER := 0;
293 l_pro_frt_acctd_amt NUMBER := 0;
294 l_pro_amt NUMBER := 0;
295 l_pro_acctd_amt NUMBER := 0;
296 l_ae_ctr NUMBER;
297 l_customer_trx_id NUMBER;
298 l_tax_activity_amt NUMBER := 0;
299 l_tax_activity_acctd_amt NUMBER := 0;
300 l_chrg_activity_amt NUMBER := 0;
301 l_chrg_activity_acctd_amt NUMBER := 0;
302 l_line_activity_amt NUMBER := 0;
303 l_line_activity_acctd_amt NUMBER := 0;
304 l_frt_activity_amt NUMBER := 0;
305 l_frt_activity_acctd_amt NUMBER := 0;
306 l_tax_run_amt_tot NUMBER :=0;
307 l_tax_run_acctd_amt_tot NUMBER :=0;
308 l_chrg_run_amt_tot NUMBER :=0;
309 l_chrg_run_acctd_amt_tot NUMBER :=0;
310 l_line_run_amt_tot NUMBER :=0;
311 l_line_run_acctd_amt_tot NUMBER :=0;
312 l_frt_run_amt_tot NUMBER :=0;
313 l_frt_run_acctd_amt_tot NUMBER :=0;
314 l_tax_run_pro_amt_tot NUMBER := 0;
315 l_tax_run_pro_acctd_amt_tot NUMBER := 0;
316 l_chrg_run_pro_amt_tot NUMBER := 0;
317 l_chrg_run_pro_acctd_amt_tot NUMBER := 0;
318 l_line_run_pro_amt_tot NUMBER := 0;
319 l_line_run_pro_acctd_amt_tot NUMBER := 0;
320 l_frt_run_pro_amt_tot NUMBER := 0;
321 l_frt_run_pro_acctd_amt_tot NUMBER := 0;
322
323 l_cust_inv_rec ra_customer_trx%ROWTYPE;
324
325 BEGIN
326
327 IF PG_DEBUG in ('Y', 'C') THEN
328 arp_standard.debug('ARP_ALLOC_WRAPPER_PKG.Get_Assign_Rate_Alloc_Tax (+)');
329 END IF;
330 /*------------------------------------------------------------------------------+
331 | Set the header amounts for the line, tax, freight, charges buckets. These are|
332 | used for allocation to create sub activities from the master activity for |
333 | each assignment. |
334 +------------------------------------------------------------------------------*/
335 IF p_ae_doc_rec.source_table = 'RA' THEN
336
337 l_customer_trx_id := p_app_rec.applied_customer_trx_id ;
338
339 ELSIF p_ae_doc_rec.source_table = 'ADJ' THEN
340
341 l_customer_trx_id := p_adj_rec.customer_trx_id ;
342
343 END IF;
344
345 l_tax_activity_amt := p_ae_rule_rec.tax_amt_alloc ;
346 l_tax_activity_acctd_amt := p_ae_rule_rec.tax_acctd_amt_alloc ;
347 l_chrg_activity_amt := p_ae_rule_rec.charges_amt_alloc ;
348 l_chrg_activity_acctd_amt := p_ae_rule_rec.charges_acctd_amt_alloc ;
349 l_line_activity_amt := p_ae_rule_rec.line_amt_alloc ;
350 l_line_activity_acctd_amt := p_ae_rule_rec.line_acctd_amt_alloc ;
351 l_frt_activity_amt := p_ae_rule_rec.freight_amt_alloc ;
352 l_frt_activity_acctd_amt := p_ae_rule_rec.freight_acctd_amt_alloc ;
353
354 /*------------------------------------------------------------------------------+
355 | Get the shadow adjustments rule record for usage by the tax accounting engine|
356 | to move the deferred after prorating over each assignment. |
357 +------------------------------------------------------------------------------*/
358 FOR l_assign_rec IN get_assignments(p_customer_trx_id => l_customer_trx_id) LOOP
359
360 l_assn_ctr := l_assn_ctr + 1;
361
362 l_br_tbl(l_assn_ctr).br_cust_trx_id := l_assign_rec.br_cust_trx_id;
363 l_br_tbl(l_assn_ctr).br_customer_trx_line_id := l_assign_rec.br_customer_trx_line_id;
364 l_br_tbl(l_assn_ctr).br_ref_customer_trx_id := l_assign_rec.br_ref_customer_trx_id;
365 l_br_tbl(l_assn_ctr).br_ref_payment_schedule_id := l_assign_rec.br_ref_payment_schedule_id;
366 l_br_tbl(l_assn_ctr).drawee_id := l_assign_rec.drawee_id;
367 l_br_tbl(l_assn_ctr).drawee_site_use_id := l_assign_rec.drawee_site_use_id;
368 l_br_tbl(l_assn_ctr).br_adj_id := l_assign_rec.br_adj_id;
369 l_br_tbl(l_assn_ctr).br_adj_amt := l_assign_rec.br_adj_amt;
370 l_br_tbl(l_assn_ctr).br_adj_acctd_amt := l_assign_rec.br_adj_acctd_amt;
371 l_br_tbl(l_assn_ctr).br_adj_line_amt := l_assign_rec.br_adj_line_amt;
372 l_br_tbl(l_assn_ctr).br_adj_tax_amt := l_assign_rec.br_adj_tax_amt;
373 l_br_tbl(l_assn_ctr).br_adj_frt_amt := l_assign_rec.br_adj_frt_amt;
374 l_br_tbl(l_assn_ctr).br_adj_chrg_amt := l_assign_rec.br_adj_chrg_amt;
375
376 /*------------------------------------------------------------------------------------+
377 | Derive the currency, exchange rate and third party information. Assignments on |
378 | a bill could have different third part and third party sub id information, hence |
379 | we rederive it. The currency and exchange rate details of assignments match Invoice|
380 +------------------------------------------------------------------------------------*/
381 l_br_tbl(l_assn_ctr).invoice_currency_code := l_assign_rec.invoice_currency_code;
382 l_br_tbl(l_assn_ctr).exchange_rate := l_assign_rec.exchange_rate;
383 l_br_tbl(l_assn_ctr).exchange_rate_type := l_assign_rec.exchange_rate_type;
384 l_br_tbl(l_assn_ctr).exchange_date := l_assign_rec.exchange_date;
385 l_br_tbl(l_assn_ctr).trx_date := l_assign_rec.trx_date;
386 l_br_tbl(l_assn_ctr).bill_to_customer_id := l_assign_rec.bill_to_customer_id;
387 l_br_tbl(l_assn_ctr).bill_to_site_use_id := l_assign_rec.bill_to_site_use_id;
388
389 /*------------------------------------------------------------------------------+
390 | Get the accounted tax amounts from the shadow adjustments as a rate for each |
391 | adjustment is required as tax for each adjustment / total tax. This is done |
392 | for both amounts and accounted amounts, to move deferred tax for adjustment |
393 | or application for each assignment correctly |
394 +------------------------------------------------------------------------------*/
395 arp_util.Set_Buckets(
396 p_header_acctd_amt => l_br_tbl(l_assn_ctr).br_adj_acctd_amt ,
397 p_base_currency => p_ae_sys_rec.base_currency ,
398 p_exchange_rate => l_br_tbl(l_assn_ctr).exchange_rate ,
399 p_base_precision => p_ae_sys_rec.base_precision ,
400 p_base_min_acc_unit => p_ae_sys_rec.base_min_acc_unit ,
401 p_tax_amt => l_br_tbl(l_assn_ctr).br_adj_tax_amt ,
402 p_charges_amt => l_br_tbl(l_assn_ctr).br_adj_chrg_amt ,
403 p_line_amt => l_br_tbl(l_assn_ctr).br_adj_line_amt ,
404 p_freight_amt => l_br_tbl(l_assn_ctr).br_adj_frt_amt ,
405 p_tax_acctd_amt => l_br_tbl(l_assn_ctr).br_adj_tax_acctd_amt ,
406 p_charges_acctd_amt => l_br_tbl(l_assn_ctr).br_adj_chrg_acctd_amt ,
407 p_line_acctd_amt => l_br_tbl(l_assn_ctr).br_adj_line_acctd_amt ,
408 p_freight_acctd_amt => l_br_tbl(l_assn_ctr).br_adj_frt_acctd_amt );
409
410 l_assn_tot_tax_amt := l_assn_tot_tax_amt
411 + l_br_tbl(l_assn_ctr).br_adj_tax_amt;
412 l_assn_tot_tax_acctd_amt := l_assn_tot_tax_acctd_amt
413 + l_br_tbl(l_assn_ctr).br_adj_tax_acctd_amt;
414
415 l_assn_tot_chrg_amt := l_assn_tot_chrg_amt
416 + l_br_tbl(l_assn_ctr).br_adj_chrg_amt;
417 l_assn_tot_chrg_acctd_amt := l_assn_tot_chrg_acctd_amt
418 + l_br_tbl(l_assn_ctr).br_adj_chrg_acctd_amt;
419
420 l_assn_tot_line_amt := l_assn_tot_line_amt
421 + l_br_tbl(l_assn_ctr).br_adj_line_amt;
422 l_assn_tot_line_acctd_amt := l_assn_tot_line_acctd_amt
423 + l_br_tbl(l_assn_ctr).br_adj_line_acctd_amt;
424
425 l_assn_tot_frt_amt := l_assn_tot_frt_amt
426 + l_br_tbl(l_assn_ctr).br_adj_frt_amt;
427 l_assn_tot_frt_acctd_amt := l_assn_tot_frt_acctd_amt
428 + l_br_tbl(l_assn_ctr).br_adj_frt_acctd_amt;
429
430 END LOOP; --end loop through assignments
431
432 IF PG_DEBUG in ('Y', 'C') THEN
433 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || ' l_assn_tot_tax_amt = ' || l_assn_tot_tax_amt);
434 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || ' l_assn_tot_tax_acctd_amt = ' || l_assn_tot_tax_acctd_amt);
435 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || ' l_assn_tot_chrg_amt = ' || l_assn_tot_chrg_amt);
436 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || ' l_assn_tot_chrg_acctd_amt = ' || l_assn_tot_chrg_acctd_amt);
437 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || ' l_assn_tot_line_amt = ' || l_assn_tot_line_amt);
438 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || ' l_assn_tot_line_acctd_amt = ' || l_assn_tot_line_acctd_amt);
439 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || ' l_assn_tot_frt_amt = ' || l_assn_tot_frt_amt);
440 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || ' l_assn_tot_frt_acctd_amt = ' || l_assn_tot_frt_acctd_amt);
441 END IF;
442
443 /*------------------------------------------------------------------------------+
444 | Loop through assignments calling the tax accounting engine after allocating |
445 | the adjustment or application over each assignment, mimmicing activities on |
446 | each assignment. |
447 +------------------------------------------------------------------------------*/
448 IF l_br_tbl.EXISTS(l_assn_ctr) THEN
449
450 FOR l_ctr IN l_br_tbl.FIRST .. l_br_tbl.LAST LOOP
451
452 /*------------------------------------------------------------------------------------+
453 | Derive the currency, exchange rate and third party information. Assignments on |
454 | a bill could have different third part and third party sub id information, hence |
455 | we rederive it. The currency and exchange rate details of assignments match Invoice|
456 +------------------------------------------------------------------------------------*/
457 l_cust_inv_rec.invoice_currency_code := l_br_tbl(l_assn_ctr).invoice_currency_code;
458 l_cust_inv_rec.exchange_rate := l_br_tbl(l_assn_ctr).exchange_rate;
459 l_cust_inv_rec.exchange_rate_type := l_br_tbl(l_assn_ctr).exchange_rate_type;
460 l_cust_inv_rec.exchange_date := l_br_tbl(l_assn_ctr).exchange_date;
461 l_cust_inv_rec.trx_date := l_br_tbl(l_assn_ctr).trx_date;
462 l_cust_inv_rec.bill_to_customer_id := l_br_tbl(l_assn_ctr).bill_to_customer_id;
463 l_cust_inv_rec.bill_to_site_use_id := l_br_tbl(l_assn_ctr).bill_to_site_use_id;
464 l_cust_inv_rec.drawee_id := l_br_tbl(l_assn_ctr).drawee_id;
465 l_cust_inv_rec.drawee_site_use_id := l_br_tbl(l_assn_ctr).drawee_site_use_id;
466
467 /*------------------------------------------------------------------------------+
468 | Allocate tax for activity on Bills Receivable,Tax lines 10, 20, 30, 40, |
469 | Tax Total 100, Tax on Discount 10 |
470 | |
471 | Line 1 a -> 10 * 10/100 = 1 (allocated) |
472 | |
473 | Line 2 -> (10 + 20)/100 * 10 = 3 |
474 | b -> 3 - a = 2 (allocated) |
475 | |
476 | Line 3 -> (10 + 20 + 30) * 10/100 = 6 |
477 | c -> 6 - a - b = 3 |
478 | Line ..... |
479 +------------------------------------------------------------------------------*/
480 l_tax_run_amt_tot := l_tax_run_amt_tot
481 + l_br_tbl(l_ctr).br_adj_tax_amt;
482 l_tax_run_acctd_amt_tot := l_tax_run_acctd_amt_tot
483 + l_br_tbl(l_ctr).br_adj_tax_acctd_amt;
484 l_pro_tax_amt := 0;
485
486 /*------------------------------------------------------------------------------+
487 | Allocate the amounts over each assignment using rates from the shadow |
488 | adjustments. |
489 +------------------------------------------------------------------------------*/
490 IF l_assn_tot_tax_amt <> 0 THEN
491 l_pro_tax_amt :=
492 arpcurr.CurrRound(l_tax_run_amt_tot/l_assn_tot_tax_amt * l_tax_activity_amt,
493 l_cust_inv_rec.invoice_currency_code) - l_tax_run_pro_amt_tot;
494
495 IF PG_DEBUG in ('Y', 'C') THEN
496 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || 'l_pro_tax_amt for '|| l_ctr || ' = '||
497 l_pro_tax_amt);
498 END IF;
499
500 /*------------------------------------------------------------------------------+
501 | Running total for prorated Tax amount in currency of Invoice |
502 +------------------------------------------------------------------------------*/
503 l_tax_run_pro_amt_tot := l_tax_run_pro_amt_tot + l_pro_tax_amt;
504
505 END IF;
506
507 /*------------------------------------------------------------------------------+
508 | Allocate the tax accounted amounts over each assignment using rates from the |
509 | shadow adjustments. |
510 +------------------------------------------------------------------------------*/
511 l_pro_tax_acctd_amt := 0;
512
513 IF l_assn_tot_tax_acctd_amt <> 0 THEN
514 l_pro_tax_acctd_amt :=
515 arpcurr.CurrRound(l_tax_run_acctd_amt_tot / l_assn_tot_tax_acctd_amt
516 * l_tax_activity_acctd_amt, p_ae_sys_rec.base_currency)
517 - l_tax_run_pro_acctd_amt_tot;
518
519 IF PG_DEBUG in ('Y', 'C') THEN
520 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || 'l_pro_tax_acctd_amt for '|| l_ctr || ' = '||
521 l_pro_tax_acctd_amt);
522 END IF;
523
524 /*------------------------------------------------------------------------------+
525 | Running total for prorated Tax accounted amount in base currency |
526 +------------------------------------------------------------------------------*/
527 l_tax_run_pro_acctd_amt_tot := l_tax_run_pro_acctd_amt_tot + l_pro_tax_acctd_amt;
528 END IF;
529
530 /*--------------------------------------------------------------------------+
531 | Allocate charges for activity on Bills Receivable |
532 +--------------------------------------------------------------------------*/
533
534 l_chrg_run_amt_tot := l_chrg_run_amt_tot
535 + l_br_tbl(l_ctr).br_adj_chrg_amt;
536 l_chrg_run_acctd_amt_tot := l_chrg_run_acctd_amt_tot
537 + l_br_tbl(l_ctr).br_adj_chrg_acctd_amt;
538 l_pro_chrg_amt := 0;
539
540 /*------------------------------------------------------------------------------+
541 | Allocate the charges amounts over each assignment using rates from the shadow|
542 | adjustments. |
543 +------------------------------------------------------------------------------*/
544 IF l_assn_tot_chrg_amt <> 0 THEN
545 l_pro_chrg_amt :=
546 arpcurr.CurrRound(l_chrg_run_amt_tot/l_assn_tot_chrg_amt * l_chrg_activity_amt,
547 l_cust_inv_rec.invoice_currency_code) - l_chrg_run_pro_amt_tot;
548
549 IF PG_DEBUG in ('Y', 'C') THEN
550 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || 'l_pro_chrg_amt for '|| l_ctr || ' = '||
551 l_pro_chrg_amt);
552 END IF;
553
554 /*------------------------------------------------------------------------------+
555 | Running total for prorated Tax amount in currency of Invoice |
556 +------------------------------------------------------------------------------*/
557 l_chrg_run_pro_amt_tot := l_chrg_run_pro_amt_tot + l_pro_chrg_amt;
558
559 END IF;
560
561 /*------------------------------------------------------------------------------+
562 | Allocate the charges accounted amounts over each assignment using rates from |
563 | the shadow adjustments. |
564 +------------------------------------------------------------------------------*/
565 l_pro_chrg_acctd_amt := 0;
566
567 IF l_assn_tot_chrg_acctd_amt <> 0 THEN
568 l_pro_chrg_acctd_amt :=
569 arpcurr.CurrRound(l_chrg_run_acctd_amt_tot / l_assn_tot_chrg_acctd_amt
570 * l_chrg_activity_acctd_amt, p_ae_sys_rec.base_currency)
571 - l_chrg_run_pro_acctd_amt_tot;
572
573 IF PG_DEBUG in ('Y', 'C') THEN
574 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || 'l_pro_chrg_acctd_amt for '|| l_ctr || ' = '||
575 l_pro_chrg_acctd_amt);
576 END IF;
577
578 /*------------------------------------------------------------------------------+
579 | Running total for prorated charges accounted amount in base currency |
580 +------------------------------------------------------------------------------*/
581 l_chrg_run_pro_acctd_amt_tot := l_chrg_run_pro_acctd_amt_tot + l_pro_chrg_acctd_amt;
582 END IF;
583
584
585 /*--------------------------------------------------------------------------+
586 | Allocate line for activity on Bills Receivable |
587 +--------------------------------------------------------------------------*/
588
589 l_line_run_amt_tot := l_line_run_amt_tot
590 + l_br_tbl(l_ctr).br_adj_line_amt;
591 l_line_run_acctd_amt_tot := l_line_run_acctd_amt_tot
592 + l_br_tbl(l_ctr).br_adj_line_acctd_amt;
593 l_pro_line_amt := 0;
594
595 /*------------------------------------------------------------------------------+
596 | Allocate the line amounts over each assignment using rates from the shadow |
597 | adjustments. |
598 +------------------------------------------------------------------------------*/
599 IF l_assn_tot_line_amt <> 0 THEN
600 l_pro_line_amt :=
601 arpcurr.CurrRound(l_line_run_amt_tot/l_assn_tot_line_amt * l_line_activity_amt,
602 l_cust_inv_rec.invoice_currency_code) - l_line_run_pro_amt_tot;
603
604 IF PG_DEBUG in ('Y', 'C') THEN
605 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || 'l_pro_line_amt for '|| l_ctr || ' = '||
606 l_pro_line_amt);
607 END IF;
608
609 /*------------------------------------------------------------------------------+
610 | Running total for prorated line amount in currency of Invoice |
611 +------------------------------------------------------------------------------*/
612 l_line_run_pro_amt_tot := l_line_run_pro_amt_tot + l_pro_line_amt;
613
614 END IF;
615
616 /*------------------------------------------------------------------------------+
617 | Allocate the line accounted amounts over each assignment using rates from |
618 | the shadow adjustments. |
619 +------------------------------------------------------------------------------*/
620 l_pro_line_acctd_amt := 0;
621
622 IF l_assn_tot_line_acctd_amt <> 0 THEN
623 l_pro_line_acctd_amt :=
624 arpcurr.CurrRound(l_line_run_acctd_amt_tot / l_assn_tot_line_acctd_amt
625 * l_line_activity_acctd_amt, p_ae_sys_rec.base_currency)
626 - l_line_run_pro_acctd_amt_tot;
627
628 IF PG_DEBUG in ('Y', 'C') THEN
629 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || 'l_pro_line_acctd_amt for '|| l_ctr || ' = '||
630 l_pro_line_acctd_amt);
631 END IF;
632
633 /*------------------------------------------------------------------------------+
634 | Running total for prorated line accounted amount in base currency |
635 +------------------------------------------------------------------------------*/
636 l_line_run_pro_acctd_amt_tot := l_line_run_pro_acctd_amt_tot + l_pro_line_acctd_amt;
637 END IF;
638
639 /*--------------------------------------------------------------------------+
640 | Allocate freight for activity on Bills Receivable |
641 +--------------------------------------------------------------------------*/
642
643 l_frt_run_amt_tot := l_frt_run_amt_tot
644 + l_br_tbl(l_ctr).br_adj_frt_amt;
645 l_frt_run_acctd_amt_tot := l_frt_run_acctd_amt_tot
646 + l_br_tbl(l_ctr).br_adj_frt_acctd_amt;
647 l_pro_frt_amt := 0;
648
649 /*------------------------------------------------------------------------------+
650 | Allocate the freight amounts over each assignment using rates from the shadow|
651 | adjustments. |
652 +------------------------------------------------------------------------------*/
653 IF l_assn_tot_frt_amt <> 0 THEN
654 l_pro_frt_amt :=
655 arpcurr.CurrRound(l_frt_run_amt_tot/l_assn_tot_frt_amt * l_frt_activity_amt,
656 l_cust_inv_rec.invoice_currency_code) - l_frt_run_pro_amt_tot;
657
658 IF PG_DEBUG in ('Y', 'C') THEN
659 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || 'l_pro_frt_amt for '|| l_ctr || ' = '||
660 l_pro_frt_amt);
661 END IF;
662
663 /*------------------------------------------------------------------------------+
664 | Running total for prorated freight amount in currency of Invoice |
665 +------------------------------------------------------------------------------*/
666 l_frt_run_pro_amt_tot := l_frt_run_pro_amt_tot + l_pro_frt_amt;
667
668 END IF;
669
670 /*------------------------------------------------------------------------------+
671 | Allocate the freight accounted amounts over each assignment using rates from |
672 | the shadow adjustments. |
673 +------------------------------------------------------------------------------*/
674 l_pro_frt_acctd_amt := 0;
675
676 IF l_assn_tot_frt_acctd_amt <> 0 THEN
677 l_pro_frt_acctd_amt :=
678 arpcurr.CurrRound(l_frt_run_acctd_amt_tot / l_assn_tot_frt_acctd_amt
679 * l_frt_activity_acctd_amt, p_ae_sys_rec.base_currency)
680 - l_frt_run_pro_acctd_amt_tot;
681
682 IF PG_DEBUG in ('Y', 'C') THEN
683 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || 'l_pro_frt_acctd_amt for '|| l_ctr || ' = '||
684 l_pro_frt_acctd_amt);
685 END IF;
686
687 /*------------------------------------------------------------------------------+
688 | Running total for prorated freight accounted amount in base currency |
689 +------------------------------------------------------------------------------*/
690 l_frt_run_pro_acctd_amt_tot := l_frt_run_pro_acctd_amt_tot + l_pro_frt_acctd_amt;
691 END IF;
692
693 l_pro_amt := l_pro_tax_amt + l_pro_chrg_amt
694 + l_pro_line_amt + l_pro_frt_amt;
695
696 l_pro_acctd_amt := l_pro_tax_acctd_amt + l_pro_chrg_acctd_amt
697 + l_pro_line_acctd_amt + l_pro_frt_acctd_amt;
698
699 IF PG_DEBUG in ('Y', 'C') THEN
700 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || 'l_pro_amt = ' || l_pro_amt);
701 arp_standard.debug('Get_Assign_Rate_Alloc_Tax: ' || 'l_pro_acctd_amt = ' || l_pro_acctd_amt);
702 END IF;
703
704 /*------------------------------------------------------------------------------+
705 | Now create a tax only application or adjustment, so that individual activity |
706 | is simulated for each assignment. Its as if we have a single activity and it |
707 | gets broken up into multiple activities over each assignment. |
708 +------------------------------------------------------------------------------*/
709 IF (p_ae_doc_rec.source_table = 'RA') THEN
710
711 --Set the application record buckets
712 p_app_rec.applied_customer_trx_id := l_br_tbl(l_ctr).br_ref_customer_trx_id;
713 p_app_rec.applied_payment_schedule_id := l_br_tbl(l_ctr).br_ref_payment_schedule_id;
714 p_app_rec.amount_applied := l_pro_amt * -1;
715 p_app_rec.acctd_amount_applied_to := l_pro_acctd_amt * -1;
716 p_app_rec.line_applied := l_pro_line_amt * -1;
717 p_app_rec.tax_applied := l_pro_tax_amt * -1;
718 p_app_rec.freight_applied := l_pro_frt_amt * -1;
719 p_app_rec.receivables_charges_applied := l_pro_chrg_amt * -1;
720
721 --Initialize the allocation buckets for payments
722 p_ae_rule_rec.tax_amt_alloc := l_pro_tax_amt;
723 p_ae_rule_rec.tax_acctd_amt_alloc := l_pro_tax_acctd_amt;
724 p_ae_rule_rec.charges_amt_alloc := l_pro_chrg_amt;
725 p_ae_rule_rec.charges_acctd_amt_alloc := l_pro_chrg_acctd_amt;
726 p_ae_rule_rec.line_amt_alloc := l_pro_line_amt;
727 p_ae_rule_rec.line_acctd_amt_alloc := l_pro_line_acctd_amt;
728 p_ae_rule_rec.freight_amt_alloc := l_pro_frt_amt;
729 p_ae_rule_rec.freight_acctd_amt_alloc := l_pro_frt_acctd_amt;
730
731 ELSIF (p_ae_doc_rec.source_table = 'ADJ') THEN
732
733 --Set the adjustment record buckets
734 p_adj_rec.customer_trx_id := l_br_tbl(l_ctr).br_ref_customer_trx_id;
735 p_adj_rec.payment_schedule_id := l_br_tbl(l_ctr).br_ref_payment_schedule_id;
736 p_adj_rec.amount := l_pro_amt ;
737 p_adj_rec.acctd_amount := l_pro_acctd_amt ;
738 p_adj_rec.line_adjusted := l_pro_line_amt ;
739 p_adj_rec.tax_adjusted := l_pro_tax_amt ;
740 p_adj_rec.freight_adjusted := l_pro_frt_amt ;
741 p_adj_rec.receivables_charges_adjusted := l_pro_chrg_amt ;
742
743 --Set the adjustment assignment allocation buckets
744 p_ae_rule_rec.tax_amt_alloc := l_pro_tax_amt ;
745 p_ae_rule_rec.tax_acctd_amt_alloc := l_pro_tax_acctd_amt ;
746 p_ae_rule_rec.charges_amt_alloc := l_pro_chrg_amt ;
747 p_ae_rule_rec.charges_acctd_amt_alloc := l_pro_chrg_acctd_amt;
748 p_ae_rule_rec.line_amt_alloc := l_pro_line_amt ;
749 p_ae_rule_rec.line_acctd_amt_alloc := l_pro_line_acctd_amt;
750 p_ae_rule_rec.freight_amt_alloc := l_pro_frt_amt ;
751 p_ae_rule_rec.freight_acctd_amt_alloc := l_pro_frt_acctd_amt ;
752
753 END IF;
754
755 l_ae_line_tbl := g_empty_ae_line_tbl;
756 l_ae_ctr := 0;
757
758 /*--------------------------------------------------------------------------+
759 | Recursive call required because current assignment is a bill of exchange.|
760 | So the process of allocation of buckets and call to the tax accounting |
761 | engine starts over again.
762 +--------------------------------------------------------------------------*/
763 IF l_br_tbl(l_ctr).drawee_site_use_id IS NOT NULL THEN
764
765 Get_Assign_Rate_Alloc_Tax(
766 p_mode => p_mode ,
767 p_ae_doc_rec => p_ae_doc_rec ,
768 p_ae_event_rec => p_ae_event_rec ,
769 p_cust_inv_rec => l_cust_inv_rec ,
770 p_ae_sys_rec => p_ae_sys_rec ,
771 p_ae_rule_rec => p_ae_rule_rec ,
772 p_app_rec => p_app_rec ,
773 p_adj_rec => p_adj_rec );
774
775 ELSE
776 /*-----------------------------------------------------------------------------+
777 | Call Tax accounting engine to allocate deferred tax for the tax adjusted or |
778 | applied. For the maturity date event an application is simulated, without |
779 | discounts. |
780 +-----------------------------------------------------------------------------*/
781
782 ARP_ALLOCATION_PKG.Allocate_Tax(
783 p_ae_doc_rec => p_ae_doc_rec , --Document detail
784 p_ae_event_rec => p_ae_event_rec , --Event record
785 p_ae_rule_rec => p_ae_rule_rec , --Rule info for payment method
786 p_app_rec => p_app_rec , --Application details
787 p_cust_inv_rec => l_cust_inv_rec , --Invoice details
788 p_adj_rec => p_adj_rec , --dummy adjustment record
789 p_ae_ctr => l_ae_ctr , --counter
790 p_ae_line_tbl => l_ae_line_tbl , --final tax accounting table
791 p_br_cust_trx_line_id => l_br_tbl(l_ctr).br_customer_trx_line_id,
792 p_simul_app => '');
793
794 IF l_ae_line_tbl.EXISTS(l_ae_ctr) THEN --Atleast one Tax line exists
795
796 FOR l_ctr1 IN l_ae_line_tbl.FIRST .. l_ae_line_tbl.LAST LOOP
797
798 --It is necessary to populate the record and then call assign elements
799
800 l_ael_line_rec := l_empty_ael_line_rec;
801 l_ael_line_rec := l_ae_line_tbl(l_ctr1);
802 /*---------------------------------------------------------------------------------+
803 | When the tax accounting engine is called for the maturity date event we simulate|
804 | a Receipt application, hence the tax accounting engine uses a source table of RA|
805 | however for the maturity date event the source table should be TH, so in this |
806 | case the source table is overriden from RA - applications to TH - Transaction |
807 | history. |
808 +---------------------------------------------------------------------------------*/
809 IF ((l_ael_line_rec.source_table = 'RA')
810 AND (p_ae_doc_rec.event = 'MATURITY_DATE')) THEN
811 l_ael_line_rec.source_table := 'TH';
812 END IF;
813
814 /*----------------------------------------------------------------------------------+
815 | Populate the source table secondary for accounting created by the tax accounting |
816 | engine, because its is important to distinguish tax moved for a specific exchange|
817 | or transaction on the Bill. (tax codes and other accounting grouping attributes |
818 | could be common across different transactions.) |
819 +----------------------------------------------------------------------------------*/
820 l_ael_line_rec.source_table_secondary := 'CTL';
821 l_ael_line_rec.source_id_secondary := l_br_tbl(l_ctr).br_customer_trx_line_id;
822 l_ael_line_rec.ae_line_type_secondary := 'ASSIGNMENT';
823
824 /*------------------------------------------------------------+
825 |Add the current tax allocation to the global table necessary|
826 |due to recursion. The global table is returned as output to |
827 |the calling parent routine. |
828 +------------------------------------------------------------*/
829 Assign_Ael_Elements( p_mode => p_mode,
830 p_ae_doc_rec => p_ae_doc_rec,
831 p_ae_event_rec => p_ae_event_rec,
832 p_ae_line_rec => l_ael_line_rec );
833
834 END LOOP;
835
836 END IF; --end if atleast one tax line
837
838 END IF; --check whether assignment is an exchange
839
840 END LOOP; --end loop all assignments for a Bill
841
842 END IF; --end if Bills Receivable Table exists
843
844 IF PG_DEBUG in ('Y', 'C') THEN
845 arp_standard.debug('ARP_ALLOC_WRAPPER_PKG.Get_Assign_Rate_Alloc_Tax (-)');
846 END IF;
847
848 END Get_Assign_Rate_Alloc_Tax;
849
850 /* =======================================================================
851 | PROCEDURE Assign_Ael_Elements
852 |
853 | DESCRIPTION
854 | This procedure stores the AE Line record into AE Lines PLSQL table.
855 | Functions:
856 | - Determine regular or negative Dr/Cr.
857 | - Store AE Line Record in AE Lines PLSQL Table.
858 | - In a fully implemented SLA model, Will determine the
859 | account to use based on AE Line type and other parameters.
860 | - In a fully implemented SLA model, Will determine the
861 | account descriptions.
862 |
863 | GUIDELINE
864 | - This procedure can be shared across document types
865 | - Recommendation is to have one per document type(AE Derivation)
866 |
867 | PARAMETERS
868 | p_ae_line_rec AE Line Record
869 * ======================================================================*/
870 PROCEDURE Assign_Ael_Elements(
871 p_mode IN VARCHAR2 ,
872 p_ae_doc_rec IN ae_doc_rec_type ,
873 p_ae_event_rec IN ae_event_rec_type ,
874 p_ae_line_rec IN ae_line_rec_type ) IS
875
876 l_account NUMBER;
877 l_account_valid BOOLEAN;
878 l_replace_default_account BOOLEAN;
879
880 BEGIN
881
882 IF PG_DEBUG in ('Y', 'C') THEN
883 arp_standard.debug( 'ARP_BR_ALLOC_WRAPPER_PKG.Assign_Ael_Elements()+');
884 END IF;
885
886 /*------------------------------------------------------+
887 | Call Hook to Override Account |
888 +------------------------------------------------------*/
889 ARP_ACCT_HOOK.Override_Account(
890 p_mode => p_mode,
891 p_ae_doc_rec => p_ae_doc_rec,
892 p_ae_event_rec => p_ae_event_rec,
893 p_ae_line_rec => p_ae_line_rec,
894 p_account => l_account,
895 p_account_valid => l_account_valid,
896 p_replace_default_account => l_replace_default_account
897 );
898
899 IF ( NOT l_replace_default_account ) THEN
900
901 /*------------------------------------------------------+
902 | SLA : Build Account for AE Line Type |
903 | When SLA is fully implemented Account Builder |
904 | will be called from here. |
905 +------------------------------------------------------*/
906 l_account := p_ae_line_rec.account;
907
908 END IF; -- Replace default account?
909
910 /*------------------------------------------------------+
911 | SLA : Build Account description for AE Line Type |
912 | When SLA is fully implemented Description |
913 | builder will be called from here. |
914 +------------------------------------------------------*/
915
916 /*------------------------------------------------------+
917 | SLA : Check Negative Dr/Cr for AE Line |
918 | When SLA is fully implemented. |
919 +------------------------------------------------------*/
920
921 /*------------------------------------------------------+
922 | Store AE Line elements in AE Lines temp table |
923 +------------------------------------------------------*/
924 g_ae_line_ctr := g_ae_line_ctr +1;
925
926 g_ae_line_tbl(g_ae_line_ctr).ae_line_type := p_ae_line_rec.ae_line_type;
927 g_ae_line_tbl(g_ae_line_ctr).ae_line_type_secondary := p_ae_line_rec.ae_line_type_secondary;
928 g_ae_line_tbl(g_ae_line_ctr).source_id := p_ae_line_rec.source_id;
929 g_ae_line_tbl(g_ae_line_ctr).source_table := p_ae_line_rec.source_table;
930 g_ae_line_tbl(g_ae_line_ctr).account := p_ae_line_rec.account;
931 g_ae_line_tbl(g_ae_line_ctr).entered_dr := p_ae_line_rec.entered_dr;
932 g_ae_line_tbl(g_ae_line_ctr).entered_cr := p_ae_line_rec.entered_cr;
933 g_ae_line_tbl(g_ae_line_ctr).accounted_dr := p_ae_line_rec.accounted_dr;
934 g_ae_line_tbl(g_ae_line_ctr).accounted_cr := p_ae_line_rec.accounted_cr;
935 g_ae_line_tbl(g_ae_line_ctr).source_id_secondary := p_ae_line_rec.source_id_secondary;
936 g_ae_line_tbl(g_ae_line_ctr).source_table_secondary := p_ae_line_rec.source_table_secondary;
937 g_ae_line_tbl(g_ae_line_ctr).currency_code := p_ae_line_rec.currency_code;
938 g_ae_line_tbl(g_ae_line_ctr).currency_conversion_rate := p_ae_line_rec.currency_conversion_rate;
939 g_ae_line_tbl(g_ae_line_ctr).currency_conversion_type := p_ae_line_rec.currency_conversion_type;
940 g_ae_line_tbl(g_ae_line_ctr).currency_conversion_date := p_ae_line_rec.currency_conversion_date;
941 g_ae_line_tbl(g_ae_line_ctr).third_party_id := p_ae_line_rec.third_party_id;
942 g_ae_line_tbl(g_ae_line_ctr).third_party_sub_id := p_ae_line_rec.third_party_sub_id;
943 g_ae_line_tbl(g_ae_line_ctr).tax_group_code_id := p_ae_line_rec.tax_group_code_id;
944 g_ae_line_tbl(g_ae_line_ctr).tax_code_id := p_ae_line_rec.tax_code_id;
945 g_ae_line_tbl(g_ae_line_ctr).location_segment_id := p_ae_line_rec.location_segment_id;
946 g_ae_line_tbl(g_ae_line_ctr).taxable_entered_dr := p_ae_line_rec.taxable_entered_dr;
947 g_ae_line_tbl(g_ae_line_ctr).taxable_entered_cr := p_ae_line_rec.taxable_entered_cr;
948 g_ae_line_tbl(g_ae_line_ctr).taxable_accounted_dr := p_ae_line_rec.taxable_accounted_dr;
949 g_ae_line_tbl(g_ae_line_ctr).taxable_accounted_cr := p_ae_line_rec.taxable_accounted_cr;
950 g_ae_line_tbl(g_ae_line_ctr).applied_from_doc_table := p_ae_line_rec.applied_from_doc_table;
951 g_ae_line_tbl(g_ae_line_ctr).applied_from_doc_id := p_ae_line_rec.applied_from_doc_id;
952 g_ae_line_tbl(g_ae_line_ctr).applied_to_doc_table := p_ae_line_rec.applied_to_doc_table;
953 g_ae_line_tbl(g_ae_line_ctr).applied_to_doc_id := p_ae_line_rec.applied_to_doc_id;
954 g_ae_line_tbl(g_ae_line_ctr).tax_link_id := p_ae_line_rec.tax_link_id;
955 g_ae_line_tbl(g_ae_line_ctr).reversed_source_id := p_ae_line_rec.reversed_source_id;
956
957 IF PG_DEBUG in ('Y', 'C') THEN
958 arp_standard.debug( 'ARP_BR_ALLOC_WRAPPER_PKG.Assign_Ael_Elements()-');
959 END IF;
960
961 EXCEPTION
962 WHEN OTHERS THEN
963 IF PG_DEBUG in ('Y', 'C') THEN
964 arp_standard.debug('EXCEPTION: ARP_BR_ALLOC_WRAPPER_PKG.Assign_Ael_Elements');
965 END IF;
966 RAISE;
967
968 END Assign_Ael_Elements;
969
970 END ARP_BR_ALLOC_WRAPPER_PKG;