[Home] [Help]
PACKAGE BODY: APPS.ARP_PROC_RCT_UTIL
Source
1 PACKAGE BODY ARP_PROC_RCT_UTIL AS
2 /* $Header: ARRURGWB.pls 120.33.12020000.2 2013/02/01 12:29:45 kyennawa ship $ */
3 PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
4 SUBTYPE l_ae_doc_rec_type IS arp_acct_main.ae_doc_rec_type ;
5
6 /* =======================================================================
7 | Global Data Types
8 * ======================================================================*/
9
10 -- ***************** BEGIN Private Procedures: **********************
11 -- ***************** END Private Procedures: **********************
12
13 FUNCTION revision RETURN VARCHAR2 IS
14 BEGIN
15
16 RETURN '$Revision: 120.33.12020000.2 $';
17
18 END revision;
19
20
21 /*===========================================================================+
22 | PROCEDURE |
23 | insert_ps_rec_cash |
24 | |
25 | DESCRIPTION |
26 | Inserts a payment schedule record for a cash receipt |
27 | |
28 | SCOPE - PRIVATE |
29 | |
30 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED |
31 | |
32 | ARGUMENTS |
33 | IN: |
34 | OUT: |
35 | |
36 | RETURNS |
37 | |
38 | NOTES |
39 | |
40 | MODIFICATION HISTORY |
41 | |
42 | 8-SEP-95 OSTEINME created |
43 | 12-JUL-96 OSTEINME now populates gl_date_closed with 12-31-4712 |
44 | to avoid problems if DB trigger is not |
45 | installed. Same for actual_date_closed. |
46 | |
47 +===========================================================================*/
48
49
50 Procedure insert_ps_rec_cash(
51 p_cr_rec IN ar_cash_receipts%ROWTYPE,
52 p_gl_date IN DATE,
53 p_maturity_date IN DATE,
54 p_acctd_amount IN
55 ar_payment_schedules.acctd_amount_due_remaining%TYPE,
56 p_ps_id OUT NOCOPY
57 ar_payment_schedules.payment_schedule_id%TYPE
58 ) IS
59
60 l_ps_rec ar_payment_schedules%ROWTYPE;
61 l_ps_id ar_payment_schedules.payment_schedule_id%TYPE;
62
63 l_status ar_cash_receipt_history.status%TYPE;
64 BEGIN
65
66 IF PG_DEBUG in ('Y', 'C') THEN
67 arp_standard.debug('arp_process_rct_util.insert_ps_rec_cash()+');
68 END IF;
69
70 -- fill record columns with data from cash receipt:
71
72 l_ps_rec.due_date := p_maturity_date;
73 l_ps_rec.gl_date := p_gl_date;
74 l_ps_rec.amount_due_original := -p_cr_rec.amount;
75 l_ps_rec.amount_due_remaining := -p_cr_rec.amount;
76 l_ps_rec.acctd_amount_due_remaining := -p_acctd_amount;
77 l_ps_rec.number_of_due_dates := 1;
78 l_ps_rec.status := 'OP';
79 l_ps_rec.invoice_currency_code := p_cr_rec.currency_code;
80 l_ps_rec.class := 'PMT';
81 l_ps_rec.cust_trx_type_id := NULL;
82 l_ps_rec.customer_id := p_cr_rec.pay_from_customer;
83 l_ps_rec.customer_site_use_id := p_cr_rec.customer_site_use_id;
84 l_ps_rec.cash_receipt_id := p_cr_rec.cash_receipt_id;
85 l_ps_rec.associated_cash_receipt_id := p_cr_rec.cash_receipt_id;
86 l_ps_rec.gl_date_closed := TO_DATE('12/31/4712','MM/DD/YYYY');
87 l_ps_rec.actual_date_closed := TO_DATE('12/31/4712','MM/DD/YYYY');
88 l_ps_rec.amount_applied := NULL;
89 l_ps_rec.exchange_rate_type := p_cr_rec.exchange_rate_type;
90 l_ps_rec.exchange_rate := p_cr_rec.exchange_rate;
91 l_ps_rec.exchange_date := p_cr_rec.exchange_date;
92 l_ps_rec.trx_number := p_cr_rec.receipt_number;
93 l_ps_rec.trx_date := p_cr_rec.receipt_date;
94
95 /* bug 5569488, set confirmed flag to N if the status is APPROVED */
96 select status
97 into l_status
98 from ar_cash_receipt_history
99 where cash_receipt_id = p_cr_rec.cash_receipt_id
100 and current_record_flag = 'Y' ;
101
102 IF l_status = 'APPROVED' THEN
103 l_ps_rec.receipt_confirmed_flag := 'N' ;
104 END IF ;
105
106 --insert record into payment schedule table:
107
108 arp_ps_pkg.insert_p(l_ps_rec, l_ps_id);
109
110 p_ps_id := l_ps_id;
111
112 IF PG_DEBUG in ('Y', 'C') THEN
113 arp_standard.debug('arp_process_rct_util.insert_ps_rec_cash()-');
114 END IF;
115
116 EXCEPTION
117 WHEN OTHERS THEN
118 IF PG_DEBUG in ('Y', 'C') THEN
119 arp_standard.debug('EXCEPTION: arp_process_rct_util.insert_ps_rec_cash()');
120 END IF;
121 RAISE;
122
123 END insert_ps_rec_cash;
124
125
126 /*===========================================================================+
127 | PROCEDURE |
128 | insert_crh_rec |
129 | |
130 | DESCRIPTION |
131 | Creates a new record in AR_CASH_RECEIPT_HISTORY for a new cash or |
132 | misc receipt. |
133 | |
134 | SCOPE - PRIVATE |
135 | |
136 | NOTES |
137 | |
138 | MODIFICATION HISTORY |
139 | |
140 | 08-SEP-95 OSTEINME created |
141 | 04-NOV-96 OSTEINME modified for Japan enhancements: |
142 | added new parameters for bank charges |
143 | |
144 +===========================================================================*/
145
146 PROCEDURE insert_crh_rec(
147 p_cr_rec IN ar_cash_receipts%ROWTYPE,
148 p_crh_amount IN ar_cash_receipt_history.amount%TYPE,
149 p_acctd_amount IN ar_cash_receipt_history.acctd_amount%TYPE,
150 p_factor_discount_amount IN
151 ar_cash_receipt_history.factor_discount_amount%TYPE,
152 p_acctd_factor_discount_amount IN
153 ar_cash_receipt_history.acctd_factor_discount_amount%TYPE,
154 p_gl_date IN DATE,
155 p_creation_status IN VARCHAR2,
156 p_batch_id IN ar_cash_receipt_history.batch_id%TYPE,
157 p_ccid IN
158 ar_cash_receipt_history.account_code_combination_id%TYPE,
159 p_bank_charges_ccid IN
160 ar_cash_receipt_history.bank_charge_account_ccid%TYPE,
161 p_crh_rec OUT NOCOPY ar_cash_receipt_history%ROWTYPE,
162 p_called_from IN VARCHAR2 DEFAULT NULL
163 ) IS
164
165 l_crh_rec ar_cash_receipt_history%ROWTYPE;
166 l_crh_id ar_cash_receipt_history.cash_receipt_history_id%TYPE;
167 l_dummy NUMBER;
168 --Bug#2750340
169 l_xla_ev_rec arp_xla_events.xla_events_type;
170
171 BEGIN
172 arp_standard.debug('arp_process_rct_util.insert_crh_rec()+');
173
174 -- fill record columns with data from cash receipt:
175
176 l_crh_rec.amount := p_crh_amount;
177 l_crh_rec.acctd_amount := p_acctd_amount;
178 l_crh_rec.cash_receipt_id := p_cr_rec.cash_receipt_id;
179 l_crh_rec.factor_flag := 'N';
180
181 /* bug5569488, set the first_posted_record_flag and postable_flag to N,
182 for receipts which requires confirmation, else set to Y. */
183 IF p_creation_status = 'APPROVED' THEN
184 l_crh_rec.first_posted_record_flag := 'N' ;
185 l_crh_rec.postable_flag := 'N' ;
186 ELSE
187 l_crh_rec.first_posted_record_flag := 'Y' ;
188 l_crh_rec.postable_flag := 'Y' ;
189 END IF ;
190
191 l_crh_rec.gl_date := trunc(p_gl_date);
192 -- l_crh_rec.postable_flag := 'Y'; -- bug 5569488, commented and replaced above
193 l_crh_rec.status := p_creation_status;
194 l_crh_rec.trx_date := p_cr_rec.receipt_date;
195 l_crh_rec.acctd_factor_discount_amount:= p_acctd_factor_discount_amount;
196 l_crh_rec.factor_discount_amount := p_factor_discount_amount;
197 l_crh_rec.account_code_combination_id := p_ccid;
198 l_crh_rec.batch_id := p_batch_id;
199 l_crh_rec.current_record_flag := 'Y';
200 l_crh_rec.exchange_date := p_cr_rec.exchange_date;
201 l_crh_rec.exchange_rate := p_cr_rec.exchange_rate;
202 l_crh_rec.exchange_rate_type := p_cr_rec.exchange_rate_type;
203 l_crh_rec.gl_posted_date := NULL;
204 l_crh_rec.posting_control_id := -3;
205 l_crh_rec.reversal_cash_receipt_hist_id := NULL;
206 l_crh_rec.reversal_gl_date := NULL;
207 l_crh_rec.reversal_gl_posted_date := NULL;
208 l_crh_rec.reversal_posting_control_id := NULL;
209 l_crh_rec.request_id := NULL;
210 l_crh_rec.program_application_id := NULL;
211 l_crh_rec.program_id := NULL;
212 l_crh_rec.program_update_date := NULL;
213
214 --BUG 7555125
215 IF p_called_from is null THEN
216 l_crh_rec.created_from := 'ARRERGW';
217 ELSE
218 l_crh_rec.created_from := p_called_from;
219 END IF;
220
221 -- populate bank charge ccid only if there is actually a bank
222 -- charge amount:
223
224 IF (p_factor_discount_amount IS NULL) THEN
225 l_crh_rec.bank_charge_account_ccid := NULL;
226 ELSE
227 l_crh_rec.bank_charge_account_ccid := p_bank_charges_ccid;
228 END IF;
229
230 arp_cr_history_pkg.insert_p(l_crh_rec, l_crh_id);
231
232 l_crh_rec.cash_receipt_history_id := l_crh_id;
233
234 p_crh_rec := l_crh_rec; -- return crh record
235
236 --Bug2750340
237 IF NVL(p_called_from, 'NONE') NOT IN ('AUTORECAPI','AUTORECAPI2','CUSTRECAPIBULK') THEN
238 l_xla_ev_rec.xla_from_doc_id := p_cr_rec.cash_receipt_id;
239 l_xla_ev_rec.xla_to_doc_id := p_cr_rec.cash_receipt_id;
240 l_xla_ev_rec.xla_doc_table := 'CRH';
241 l_xla_ev_rec.xla_mode := 'O';
242 l_xla_ev_rec.xla_call := 'B';
243 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
244 END IF;
245
246 arp_standard.debug('arp_process_rct_util.insert_crh_rec()-');
247
248 EXCEPTION
249 WHEN OTHERS THEN
250 arp_standard.debug('EXCEPTION: arp_process_rct_util.insert_crh_rec');
251 RAISE;
252
253 END;
254
255
256 /*===========================================================================+
257 | PROCEDURE |
258 | insert_ra_rec_cash |
259 | |
260 | DESCRIPTION |
261 | Creates a new record in AR_RECEIVABLE_APPLICATIONS table for a cash |
262 | receipt. |
263 | |
264 | SCOPE : PRIVATE |
265 | |
266 | NOTES |
267 | |
268 | MODIFICATION HISTORY |
269 | |
270 | 11-SEP-95 OSTEINME created |
271 | 13-MAY-97 KLAWRANC Bug fix #487513. |
272 | Added parameter p_reversal_gl_date. Reversal |
273 | GL Date must be set for all reversed |
274 | receivable applications records. Parameter |
275 | defaults to NULL, so that other packages that|
276 | call this procedure do not need to be |
277 | modified. |
278 | 03-SEP-97 OSTEINME Bug 547165: Changed |
279 | %type to %rowtype |
280 | |
281 | 14-APR-2000 Jani Rautiainen Added parameter p_called_from. This is needed|
282 | in the logic to decide whether first UNAPP |
283 | row is postable or not. In BR scenario when |
284 | Activity Application of Short Term Debt is |
285 | created the UNAPP rows are not postable. |
286 | This is an user requirement for BR. |
287 | The parameter is defaulted to NULL so no |
288 | impact for the existing functionality. |
289 | 03-Sep-2002 Debbie Jancis Modified for MRC trigger replacement |
290 | Added calls to AR_MRC_ENGINE3 for |
291 | for processing inserts into |
292 | AR_RECEIVABLE_APPLICATIONS |
293 | |
294 +===========================================================================*/
295
296 PROCEDURE insert_ra_rec_cash(
297 p_cash_receipt_id IN ar_cash_receipts.cash_receipt_id%TYPE,
298 p_amount IN ar_cash_receipts.amount%TYPE,
299 p_apply_date IN DATE,
300 p_status IN ar_cash_receipts.status%TYPE,
301 p_acctd_amount IN
302 ar_receivable_applications.acctd_amount_applied_from%TYPE,
303 p_gl_date IN DATE,
304 p_ccid IN
305 ar_receivable_applications.code_combination_id%TYPE,
306 p_payment_schedule_id IN
307 ar_payment_schedules.payment_schedule_id%TYPE,
308 p_application_rule IN ar_receivable_applications.application_rule%TYPE,
309 p_reversal_gl_date IN DATE default null,
310 p_ra_id OUT NOCOPY ar_receivable_applications.receivable_application_id%TYPE,
311 p_called_from IN VARCHAR2 DEFAULT NULL -- jrautiai BR project
312 ) IS
313
314 l_ra_rec ar_receivable_applications%ROWTYPE;
315 l_ra_id ar_receivable_applications.receivable_application_id%TYPE;
316 --BUG#2750340
317 l_xla_ev_rec arp_xla_events.xla_events_type;
318
319 BEGIN
320
321 arp_standard.debug('arp_process_rct_util.insert_ra_rec_cash()+');
322
323 -- create new receivable applications record:
324
325 l_ra_rec.amount_applied := p_amount;
326 l_ra_rec.acctd_amount_applied_from := p_acctd_amount;
327 l_ra_rec.cash_receipt_id := p_cash_receipt_id;
328 l_ra_rec.gl_date := trunc(p_gl_date);
329 l_ra_rec.reversal_gl_date := p_reversal_gl_date;
330 l_ra_rec.apply_date := p_apply_date;
331 l_ra_rec.display := 'N';
332 l_ra_rec.application_type := 'CASH';
333 l_ra_rec.payment_schedule_id := p_payment_schedule_id;
334 l_ra_rec.posting_control_id := -3;
335 l_ra_rec.application_rule := p_application_rule;
336
337 /* 14-APR-2000 jrautiai BR implementation
338 * In this BR specific situation the first UNAPP row created is not POSTABLE
339 * see procedure description for more information */
340
341 IF nvl(p_called_from,'NONE') = 'BR_FACTORED_WITH_RECOURSE' THEN -- jrautiai BR project
342 l_ra_rec.postable := 'N';
343 END IF;
344
345 --bug 5298846 For Receipts which require confirmation the following needs to be set
346 IF nvl(p_called_from,'NONE') = 'AUTORECAPI' THEN -- jrautiai BR project
347 l_ra_rec.application_rule:= '97.0';
348 l_ra_rec.confirmed_flag := 'N';
349 END IF;
350
351 -- based on receipt status, set application rule:
352
353 l_ra_rec.status := p_status;
354 l_ra_rec.code_combination_id := p_ccid;
355
356 -- call table handler to insert record
357
358 arp_standard.debug('amount_applied = ' || to_char(l_ra_rec.amount_applied));
359 arp_standard.debug('acctd_amount_applied_from = ' || to_char(l_ra_rec.acctd_amount_applied_from));
360 arp_standard.debug('cash_receipt_id = ' || to_char(l_ra_rec.cash_receipt_id));
361 arp_standard.debug('gl_date = ' || to_char(l_ra_rec.gl_date));
362 arp_standard.debug('apply_date = ' || to_char(l_ra_rec.apply_date));
363 arp_standard.debug('display = ' || l_ra_rec.display);
364 arp_standard.debug('application_type = ' || l_ra_rec.application_type);
365 arp_standard.debug('payment_schedule_id = ' || to_char(l_ra_rec.payment_schedule_id));
366 arp_standard.debug('status = ' || l_ra_rec.status);
367 arp_standard.debug('ccid = ' || to_char(l_ra_rec.code_combination_id));
368 arp_standard.debug('sob id = ' || TO_CHAR(arp_global.set_of_books_id));
369 arp_standard.debug('application_rule = ' || TO_CHAR(l_ra_rec.application_rule));
370 arp_standard.debug('confirmed_flag = ' || TO_CHAR(l_ra_rec.confirmed_flag));
371 arp_standard.debug('p_called_from = ' || TO_CHAR(p_called_from));
372 arp_app_pkg.insert_p(l_ra_rec, l_ra_id);
373
374 p_ra_id := l_ra_id;
375
376 --
377 --Release 11.5 VAT changes, create receivable application accounting
378 --in ar_distributions. Note tax accounting must be created after a call
379 --to this function. It is due to this reason that the app id is returned
380 --as output to the parent procedure to enable a call to the tax accounting
381 --routine
382
383 -- CAll MRC ENGINE for Processing Insert into rec apps.
384 --{BUG#4301323
385 -- ar_mrc_engine3.insert_ra_rec_cash(
386 -- p_ra_id,
387 -- l_ra_rec,
388 -- l_ra_rec.cash_receipt_id,
389 -- p_amount,
390 -- l_ra_rec.payment_schedule_id);
391 --}
392 --BUG#2750340
393 --Autoreceipts performance changes nproddut
394 IF NVL(p_called_from, 'NONE') NOT IN ('AUTORECAPI','AUTORECAPI2','CUSTRECAPIBULK') THEN
395 l_xla_ev_rec.xla_from_doc_id := l_ra_id;
396 l_xla_ev_rec.xla_to_doc_id := l_ra_id;
397 l_xla_ev_rec.xla_doc_table := 'APP';
398 l_xla_ev_rec.xla_mode := 'O';
399 l_xla_ev_rec.xla_call := 'B';
400 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
401 END IF;
402 arp_standard.debug('arp_process_rct_util.insert_ra_rec_cash()-');
403
404 END; -- insert_ra_rec_cash()
405
406
407 /*===========================================================================+
408 | PROCEDURE |
409 | insert_dist_rec |
410 | |
411 | DESCRIPTION |
412 | inserts ar_distributions record for a cash/misc receipt |
413 | |
414 | SCOPE - PRIVATE |
415 | |
416 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED |
417 | |
418 | ARGUMENTS |
419 | IN: |
420 | OUT: |
421 | |
422 | RETURNS |
423 | |
424 | NOTES |
425 | |
426 | MODIFICATION HISTORY |
427 | |
428 | 19-AUG-95 OSTEINME created |
429 | 05-Jan-98 DJancis added p_cr_id so we can get additional info |
430 | required for 11.5 VAT changes |
431 | |
432 +===========================================================================*/
433
434 PROCEDURE insert_dist_rec(
435 p_amount IN ar_cash_receipts.amount%TYPE,
436 p_acctd_amount IN ar_cash_receipt_history.acctd_amount%TYPE,
437 p_crh_id IN
438 ar_cash_receipt_history.cash_receipt_history_id%TYPE,
439 p_source_type IN ar_distributions.source_type%TYPE,
440 p_ccid IN ar_distributions.code_combination_id%TYPE,
441 p_called_from IN VARCHAR2 DEFAULT NULL -- jrautiai BR project
442 ) IS
443
444 l_dist_rec ar_distributions%ROWTYPE;
445 l_source_type ar_distributions.source_type%TYPE;
446 l_ccid ar_distributions.code_combination_id%TYPE;
447 l_dummy ar_distributions.line_id%TYPE;
448 l_cr_rec ar_cash_receipts%ROWTYPE;
449 l_crh_rec ar_cash_receipt_history%ROWTYPE;
450 --bug#2750340
451 l_xla_ev_rec arp_xla_events.xla_events_type;
452
453 BEGIN
454 arp_standard.debug('arp_process_rct_util.insert_dist_rec()+');
455
456 arp_standard.debug('-- getting infomation from cash receipt --');
457
458 -- Fetch the history record
459 arp_cr_history_pkg.fetch_p( p_crh_id, l_crh_rec );
460
461 -- Fetch the cash receipt record
462 l_cr_rec.cash_receipt_id := l_crh_rec.cash_receipt_id;
463 arp_cash_receipts_pkg.fetch_p( l_cr_rec );
464
465
466 -- 11.5 VAT changes:
467 l_dist_rec.currency_code := l_cr_rec.currency_code;
468 l_dist_rec.currency_conversion_rate := l_crh_rec.exchange_rate;
469 l_dist_rec.currency_conversion_type := l_crh_rec.exchange_rate_type;
470 l_dist_rec.currency_conversion_date := l_crh_rec.exchange_date;
471 l_dist_rec.third_party_id := l_cr_rec.pay_from_customer;
472 l_dist_rec.third_party_sub_id := l_cr_rec.customer_site_use_id;
473
474
475 l_dist_rec.source_id := p_crh_id;
476 l_dist_rec.source_table := 'CRH';
477 l_dist_rec.source_type := p_source_type;
478 l_dist_rec.code_combination_id:= p_ccid;
479 /* Bug 44188117 : Added the 'or' condition below */
480 IF (p_amount < 0) or (p_amount = 0 and p_acctd_amount < 0) THEN
481 l_dist_rec.amount_dr := NULL;
482 l_dist_rec.amount_cr := - p_amount;
483 l_dist_rec.acctd_amount_dr := NULL;
484 l_dist_rec.acctd_amount_cr := - p_acctd_amount;
485
486 ELSE
487 l_dist_rec.amount_dr := p_amount;
488 l_dist_rec.amount_cr := NULL;
489 l_dist_rec.acctd_amount_dr := p_acctd_amount;
490 l_dist_rec.acctd_amount_cr := NULL;
491
492 END IF;
493 /* Bug No 3635076 JVARKEY */
494 /* Commented out as same code is shifted to the above if loop IF (p_amount < 0) THEN.. */
495 /*IF (p_acctd_amount < 0) THEN
496 l_dist_rec.acctd_amount_dr := NULL;
497 l_dist_rec.acctd_amount_cr := - p_acctd_amount;
498 ELSE
499 l_dist_rec.acctd_amount_dr := p_acctd_amount;
500 l_dist_rec.acctd_amount_cr := NULL;
501 END IF;*/
502
503 arp_distributions_pkg.insert_p(l_dist_rec, l_dummy);
504
505 /* store l_dummy into the rec for use for mrc */
506 l_dist_rec.line_id := l_dummy;
507
508 /* need to insert records into the MRC table. Calling new
509 mrc engine */
510 --{BUG4301323
511 -- ar_mrc_engine2.maintain_mrc_data2(
512 -- p_event_mode => 'INSERT',
513 -- p_table_name => 'AR_DISTRIBUTIONS',
514 -- p_mode => 'SINGLE',
515 -- p_key_value => l_dist_rec.line_id,
516 -- p_row_info => l_dist_rec);
517 --}
518 --BUG#2750340
519 --Autoreceipts performance changes nproddut
520 IF NVL(p_called_from, 'NONE') NOT IN ('AUTORECAPI','AUTORECAPI2','CUSTRECAPIBULK') THEN
521 l_xla_ev_rec.xla_from_doc_id := l_crh_rec.cash_receipt_id;
522 l_xla_ev_rec.xla_to_doc_id := l_crh_rec.cash_receipt_id;
523 l_xla_ev_rec.xla_doc_table := 'CRH';
524 l_xla_ev_rec.xla_mode := 'O';
525 l_xla_ev_rec.xla_call := 'B';
526 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
527 END IF;
528
529 arp_standard.debug('arp_process_rct_util.insert_dist_rec()-');
530
531 END; -- insert_dist_rec()
532
533
534 /*===========================================================================+
535 | PROCEDURE |
536 | round_mcd_recs |
537 | |
538 | DESCRIPTION |
539 | This function takes care of rounding errors in ar_misc_cash_distr. |
540 | |
541 | SCOPE - PRIVATE |
542 | |
543 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED |
544 | |
545 | ARGUMENTS |
546 | IN: |
547 | OUT: |
548 | |
549 | RETURNS |
550 | |
551 | NOTES |
552 | |
553 | MODIFICATION HISTORY |
554 | |
555 | 09-OCT-95 OSTEINME created |
556 | |
557 +===========================================================================*/
558
559 PROCEDURE round_mcd_recs(
560 p_cash_receipt_id IN ar_cash_receipts.cash_receipt_id%TYPE
561 ) IS
562
563 l_rounding_diff NUMBER;
564 l_misc_cash_key_value_list gl_ca_utility_pkg.r_key_value_arr; /* MRC */
565
566 BEGIN
567
568 IF PG_DEBUG in ('Y', 'C') THEN
569 arp_standard.debug('arp_process_receipts.round_mcd_recs()+');
570 END IF;
571
572 SELECT ROUND(100 - sum(mcd.percent),3)
573 INTO l_rounding_diff
574 FROM ar_misc_cash_distributions mcd
575 WHERE mcd.cash_receipt_id = p_cash_receipt_id;
576
577 IF (l_rounding_diff <> 0) THEN
578 -- rounding error must be added to first record so that percent
579 -- values add up to 100
580 --
581 IF PG_DEBUG in ('Y', 'C') THEN
582 arp_standard.debug('round_mcd_recs: ' || 'Rounding difference = ' || TO_CHAR(l_rounding_diff));
583 END IF;
584 --
585 /*----------------------------------+
586 | Added bulk collect of misc cash |
587 | distribution id for use in MRC |
588 | engine for trigger replacement |
589 +----------------------------------*/
590
591 UPDATE ar_misc_cash_distributions mcd
592 SET mcd.percent = mcd.percent + l_rounding_diff
593 WHERE cash_receipt_id = p_cash_receipt_id
594 AND ROWNUM =1
595 RETURNING misc_cash_distribution_id
596 BULK COLLECT INTO l_misc_cash_key_value_list;
597 --
598
599 /*---------------------------------+
600 | Calling central MRC library |
601 | for MRC Integration |
602 +---------------------------------*/
603 /*BUG4301323
604 BEGIN
605 ar_mrc_engine.maintain_mrc_data(
606 p_event_mode => 'UPDATE',
607 p_table_name => 'AR_MISC_CASH_DISTRIBUTIONS',
608 p_mode => 'BATCH',
609 p_key_value_list => l_misc_cash_key_value_list);
610 EXCEPTION
611 WHEN OTHERS THEN
612 IF PG_DEBUG in ('Y', 'C') THEN
613 arp_util.debug('round_mcd_recs: ' || 'error updating ar_mc_misc_cash_dists');
614 arp_util.debug('round_mcd_recs: ' || 'SQLCODE = ' || SQLCODE || SQLERRM);
615 END IF;
616 APP_EXCEPTION.RAISE_EXCEPTION;
617 END;
618 */
619 END IF;
620
621 IF PG_DEBUG in ('Y', 'C') THEN
622 arp_standard.debug('arp_process_receipts.round_mcd_recs()-');
623 END IF;
624
625 END round_mcd_recs;
626
627
628 /*===========================================================================+
629 | PROCEDURE |
630 | insert_misc_dist |
631 | |
632 | DESCRIPTION |
633 | Inserts distributions for miscellaneous transactions |
634 | |
635 | SCOPE - PRIVATE |
636 | |
637 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED |
638 | |
639 | ARGUMENTS |
640 | IN: |
641 | OUT: |
642 | |
643 | RETURNS |
644 | |
645 | NOTES |
646 | |
647 | MODIFICATION HISTORY |
648 | |
649 | 21-SEP-95 OSTEINME created |
650 | 28-SEP-98 K.Murphy Bug #705078. Added code to validate the key |
651 | flex before the MISC distribution is |
652 | created. Checks both the enabled flag and |
653 | From/To dates. |
654 | 30-SEP-98 K.Murphy Cash Management Enhancement: Allow creation |
655 | of Misc Receipts with distribution set. |
656 | Added p_created_from parameter and included |
657 | "default NULL" for p_distribution_set_id. |
658 | Modified code so that the distribution set |
659 | is selected along with the cc id (as in the |
660 | form you can no longer choose a different |
661 | distribution set for a given activity. |
662 | 03-Mar-05 JASSING Added the code to check for the profile |
663 | option 'AR:Disable Receivable Activity |
664 | Balancing Segment Substitution' for the |
665 | misc receipt creation during Credit Card |
666 | Refunds. Bug fix 4025652. |
667 +===========================================================================*/
668
669
670 PROCEDURE insert_misc_dist(
671 p_cash_receipt_id IN ar_cash_receipts.cash_receipt_id%TYPE,
672 p_gl_date IN ar_cash_receipt_history.gl_date%TYPE,
673 p_amount IN ar_cash_receipts.amount%TYPE,
674 p_currency_code IN ar_cash_receipts.currency_code%TYPE,
675 p_exchange_rate IN ar_cash_receipts.exchange_rate%TYPE,
676 p_acctd_amount IN ar_cash_receipt_history.acctd_amount%TYPE,
677 p_receipt_date IN ar_cash_receipts.receipt_date%TYPE,
678 p_receivables_trx_id IN ar_cash_receipts.receivables_trx_id%TYPE,
679 p_distribution_set_id IN ar_cash_receipts.distribution_set_id%TYPE default NULL,
680 p_ussgl_trx_code IN ar_cash_receipts.ussgl_transaction_code%TYPE default NULL,
681 p_created_from IN ar_misc_cash_distributions.created_from%TYPE default 'ARRERCT'
682 ) IS
683
684 l_trx_code_combination_id ar_receivables_trx.code_combination_id%TYPE;
685 l_distribution_set_id ar_receivables_trx.default_acctg_distribution_set%TYPE;
686 l_dummy ar_misc_cash_distributions.misc_cash_distribution_id%TYPE;
687 l_misc_cash_dist_rec ar_misc_cash_distributions%ROWTYPE;
688 l_misc_cash_key_value_list gl_ca_utility_pkg.r_key_value_arr; /* MRC */
689 l_crh_ccid ar_cash_receipt_history.account_code_combination_id%TYPE; /*Bug fix 4025652 */
690 l_type ar_receivables_trx.type%TYPE; /*4726219 */
691
692 l_xla_ev_rec arp_xla_events.xla_events_type;
693
694 CURSOR c_hist IS
695 SELECT cash_receipt_history_id
696 FROM ar_cash_receipt_history
697 WHERE current_record_flag = 'Y'
698 AND cash_receipt_id = p_cash_receipt_id;
699
700 l_crh_id NUMBER;
701
702 BEGIN
703
704 arp_standard.debug('arp_process_receipts.insert_misc_dist()+');
705
706 arp_standard.debug('ussgl_trx code = ' || p_ussgl_trx_code);
707 -- delete existing distributions records
708
709 /*----------------------------------+
710 | Added bulk collect of misc cash |
711 | distribution id for use in MRC |
712 | engine for trigger replacement |
713 +----------------------------------*/
714
715 DELETE ar_misc_cash_distributions
716 WHERE cash_receipt_id = p_cash_receipt_id
717 RETURNING misc_cash_distribution_id
718 BULK COLLECT INTO l_misc_cash_key_value_list;
719 --
720
721 /*---------------------------------+
722 | Calling central MRC library |
723 | for MRC Integration |
724 +---------------------------------*/
725 /*BUG4301323
726 BEGIN
727 ar_mrc_engine.maintain_mrc_data(
728 p_event_mode => 'DELETE',
729 p_table_name => 'AR_MISC_CASH_DISTRIBUTIONS',
730 p_mode => 'BATCH',
731 p_key_value_list => l_misc_cash_key_value_list);
732 EXCEPTION
733 WHEN OTHERS THEN
734 arp_util.debug('error deleting ar_mc_misc_cash_dists');
735 arp_util.debug('SQLCODE = ' || SQLCODE || SQLERRM);
736 APP_EXCEPTION.RAISE_EXCEPTION;
737 END;
738 */
739 -- check if receipt amount is zero. If yes, don't create any
740 -- distributions
741 -------------------------------------------------------------
742 -- Commented the following 'if' as part of bug fix 868448
743 ----------------------------------------------
744 --IF (p_amount <> 0) THEN
745
746 -- determine if distribution set or single account
747
748 -- Now selecting both the code combination id and the distribution set id.
749 -- Previously you could create a receipt with a different distribution set
750 -- for the choosen activity (i.e. other than the default). This is no
751 -- longer permitted. Cash Management have added the ability to create
752 -- Misc Receipts with distribution sets but we won't require them to pass
753 -- in the distribution set id as se will get it ourselves based on the
754 -- activity.
755 /* Bug4726219 */
756 SELECT rt.code_combination_id,
757 rt.default_acctg_distribution_set,
758 rt.type
759 INTO l_trx_code_combination_id,
760 l_distribution_set_id,
761 l_type
762 FROM ar_receivables_trx rt
763 WHERE rt.type in
764 ('MISCCASH', 'BANK_ERROR', 'CCREFUND', 'CM_REFUND','CC_CHARGEBACK')
765 AND NVL( rt.status, 'A' ) = 'A'
766 AND rt.RECEIVABLES_TRX_ID = p_receivables_trx_id;
767
768
769 IF (l_trx_code_combination_id IS NOT NULL) THEN
770
771 -- Default account ccid exists. Create misc cash distribution
772 -- record with 100% for this account
773
774 /* bug fix 4025652 */
775 select account_code_combination_id
776 into l_crh_ccid
777 from ar_cash_receipt_history
778 where cash_receipt_id = p_cash_receipt_id
779 and current_record_flag = 'Y';
780
781 /* -------------------------------------------------------------------+
782 | Balancing segment of ACTIVITY application should be replaced with |
783 | that of CRH record's CCID. |
784 +--------------------------------------------------------------------*/
785 /* Bug4726219 */
786 IF NVL(FND_PROFILE.value('AR_DISABLE_REC_ACTIVITY_BALSEG_SUBSTITUTION'),
787 'N') = 'N' AND l_type <> 'MISCCASH' THEN
788 arp_util.Substitute_Ccid(
789 p_coa_id => arp_global.chart_of_accounts_id,
790 p_original_ccid => l_trx_code_combination_id,
791 p_subs_ccid => l_crh_ccid,
792 p_actual_ccid => l_misc_cash_dist_rec.code_combination_id );
793 ELSE
794 l_misc_cash_dist_rec.code_combination_id := l_trx_code_combination_id;
795 END IF;
796
797 l_misc_cash_dist_rec.cash_receipt_id := p_cash_receipt_id;
798 l_misc_cash_dist_rec.gl_date := trunc(p_gl_date);
799 l_misc_cash_dist_rec.apply_date := p_receipt_date;
800 /* l_misc_cash_dist_rec.code_combination_id:= l_trx_code_combination_id; Bug fix 4025652 */
801 l_misc_cash_dist_rec.percent := 100;
802 l_misc_cash_dist_rec.amount := p_amount;
803 l_misc_cash_dist_rec.acctd_amount := p_acctd_amount;
804 l_misc_cash_dist_rec.posting_control_id := -3;
805 l_misc_cash_dist_rec.created_from := p_created_from;
806 l_misc_cash_dist_rec.set_of_books_id := arp_global.set_of_books_id;
807 OPEN c_hist;
808 FETCH c_hist INTO l_misc_cash_dist_rec.cash_receipt_history_id;
809 CLOSE c_hist;
810
811 -- Bug 2641258: USSGL TRX code not being defaulted
812 l_misc_cash_dist_rec.ussgl_transaction_code := p_ussgl_trx_code;
813
814 -- Bug fix #705078
815 -- Verify that account is valid before doing insert.
816 --
817 -- Using the flex field server APIs to do this ...
818 -- (note also that we are using the same error message
819 -- for each case.
820 --
821 -- Firstly, call fnd_flex_keyval.validate_ccid to populate
822 -- all of the relevant global variables.
823 --
824 IF fnd_flex_keyval.validate_ccid(
825 appl_short_name => 'SQLGL',
826 key_flex_code => 'GL#',
827 structure_number => arp_global.chart_of_accounts_id,
828 combination_id => l_trx_code_combination_id ) THEN
829 -- Secondly, check is the key flex is enabled.
830 -- Fix 1341201, Added rollback
831 IF not fnd_flex_keyval.enabled_flag THEN
832 rollback;
833 FND_MESSAGE.Set_Name('AR', 'AR_GL_ACCOUNT_INVALID');
834 APP_EXCEPTION.Raise_Exception;
835 -- Thirdly, check if the key flex is valid for this date.
836 --
837 ELSIF p_gl_date NOT between nvl(fnd_flex_keyval.start_date,p_gl_date)
838 and nvl(fnd_flex_keyval.end_date,p_gl_date) THEN
839 rollback;
840 FND_MESSAGE.Set_Name('AR', 'AR_GL_ACCOUNT_INVALID');
841 APP_EXCEPTION.Raise_Exception;
842 END IF;
843 END IF;
844
845 arp_misc_cash_dist_pkg.insert_p(l_misc_cash_dist_rec, l_dummy);
846
847
848 --
849 l_xla_ev_rec.xla_from_doc_id := p_cash_receipt_id;
850 l_xla_ev_rec.xla_to_doc_id := p_cash_receipt_id;
851 l_xla_ev_rec.xla_doc_table := 'MCD';
852 l_xla_ev_rec.xla_mode := 'O';
853 l_xla_ev_rec.xla_call := 'D';
854 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
855
856 ELSIF (l_distribution_set_id is not null) THEN
857
858 -- 941243: insert distributions records
859 -- do not create ar_misc_cash_distributions if receipt amount = 0
860 /* Bug fix 2272461
861 When the MISC receipt amount is changed to zero, the MISCCASH accounting
862 Record is not created in ar_distributions table. Commented out NOCOPY the condition
863 which check for the receipt amount before creating the record.
864 IF (p_amount <> 0) THEN */
865
866 create_mcd_recs(p_cash_receipt_id,
867 p_amount,
868 p_acctd_amount,
869 p_exchange_rate,
870 p_currency_code,
871 p_gl_date,
872 p_receipt_date,
873 p_distribution_set_id,
874 p_ussgl_trx_code);
875
876
877 /*END IF; */
878 END IF;
879
880 --END IF; -- p_amount <> 0
881 -------------------------------------------------------------
882 -- Commented out NOCOPY the above 'END IF' as part of bug fix 868448
883 --------------------------------------------------------------
884
885 arp_standard.debug('arp_process_receipts.insert_misc_dist()-');
886
887 END; -- arp_process_receipts.insert_misc_dist()
888
889
890
891 /*===========================================================================+
892 | PROCEDURE |
893 | update_misc_dist |
894 | |
895 | DESCRIPTION |
896 | updates distribution in ar_misc_cash_distributions |
897 | |
898 | SCOPE - PRIVATE |
899 | |
900 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED |
901 | |
902 | ARGUMENTS |
903 | IN: |
904 | OUT: |
905 | |
906 | RETURNS |
907 | |
908 | NOTES |
909 | |
910 | MODIFICATION HISTORY |
911 | |
912 | 22-SEP-95 OSTEINME created |
913 | 30-MAY-01 MRAMANAT Added an ELSIF condition to handle Case# 6 |
914 | to fix bug 1792989 |
915 | |
916 +===========================================================================*/
917
918 PROCEDURE update_misc_dist(
919 p_cash_receipt_id IN ar_cash_receipts.cash_receipt_id%TYPE,
920 p_amount IN ar_cash_receipts.amount%TYPE,
921 p_acctd_amount IN ar_cash_receipt_history.acctd_amount%TYPE,
922 p_amount_changed_flag IN BOOLEAN,
923 p_distribution_set_id IN ar_cash_receipts.distribution_set_id%TYPE,
924 p_receivables_trx_id IN ar_cash_receipts.receivables_trx_id%TYPE,
925 p_old_distribution_set_id IN ar_cash_receipts.distribution_set_id%TYPE,
926 p_old_receivables_trx_id IN ar_cash_receipts.receivables_trx_id%TYPE,
927 p_gl_date IN ar_cash_receipt_history.gl_date%TYPE,
928 p_gl_date_changed_flag IN BOOLEAN,
929 p_currency_code IN ar_cash_receipts.currency_code%TYPE,
930 p_exchange_rate IN ar_cash_receipts.exchange_rate%TYPE,
931 p_receipt_date IN ar_cash_receipts.receipt_date%TYPE,
932 p_receipt_date_changed_flag IN BOOLEAN,
933 p_gl_tax_acct IN ar_distributions.code_combination_id%TYPE
934 ) IS
935
936 l_trx_code_combination_id ar_receivables_trx.code_combination_id%TYPE;
937 l_old_trx_code_combination_id ar_receivables_trx.code_combination_id%TYPE;
938 l_dummy ar_misc_cash_distributions.misc_cash_distribution_id%TYPE;
939 l_misc_cash_dist_rec ar_misc_cash_distributions%ROWTYPE;
940 l_old_recs_auto_flag BOOLEAN;
941 l_new_recs_auto_flag BOOLEAN;
942 l_count NUMBER;
943 l_posted ar_cash_receipt_history.posting_control_id%TYPE;
944 l_ae_doc_rec l_ae_doc_rec_type;
945 l_misc_cash_key_value_list gl_ca_utility_pkg.r_key_value_arr;
946 l_old_default_distribution_set NUMBER; --Bug 6416611
947 l_default_distribution_set NUMBER; --Bug 6416611
948 dummy varchar2(1); --Bug 6416611
949 BEGIN
950
951 IF PG_DEBUG in ('Y', 'C') THEN
952 arp_standard.debug('arp_process_receipts.update_misc_dist()+');
953 END IF;
954
955
956 -- The following cases need to be distinguished with regard to
957 -- an update of the distribution set and/or the amount:
958 --
959 -- 1. old distribution set : NULL
960 -- default ccid of activity: NULL
961 -- new distribution set : NULL
962 -- amount : unchanged
963 --
964 -- In this case the manually created distribution records
965 -- do not require any changes (trivial case).
966 --
967 -- 2. old distribution set : NULL
968 -- default ccid of activity: NULL
969 -- new distribution set : NULL
970 -- amount : changed
971 --
972 -- In this case the manually created distribution records
973 -- need to be updated. The percent values must remain
974 -- unchanged, but the corresponding amounts need to be
975 -- adapted to the new total amount.
976 --
977 -- 3. old distribution set : automatically created
978 -- new distribution set : NULL (manually created)
979 -- amount : changed or unchanged
980 --
981 -- Was:
982 -- The old (automatically created) distribution records must
983 -- be deleted. The distribution set must be entered
984 -- manually by the user.
985 --
986 -- As of 11/20/95: distribution window is semi-modal, and user
987 -- can no longer null out NOCOPY distribution set in receipt window.
988 -- Is:
989 -- The user has manually modified the distribution set in the
990 -- distributions window. Nothing needs to be done.
991 --
992 --
993 -- 4. old distribution set : NULL (manually created)
994 -- new distribution set : automatically created
995 -- amount : changed or unchanged
996 --
997 -- The old (manually created) distribution records must
998 -- be deleted; new records must be created according to
999 -- the new distribution_set/activity.
1000 --
1001 -- 5. old distribution set : automatically created
1002 -- new distribution set : automatically created, but changed
1003 -- amount : changed or unchanged
1004 --
1005 -- The old (automatically created) records must be deleted,
1006 -- new records need to be created automatically based on
1007 -- ccid or distribution set
1008 --
1009 -- 6. old distribution set : automatically created
1010 -- new distribution set : unchanged
1011 -- amount : changed
1012 --
1013 -- The old records must be deleted, new ones created for the
1014 -- new amount.
1015 --
1016 -- 7. old distribution set : automatically created
1017 -- new distribution set : unchanged
1018 -- amount : unchanged
1019 --
1020 -- Trivial case -- no change required
1021 --
1022 -- 8. amount : 0 (zero)
1023 --
1024 -- super-trivial case: just delete existing distributions (if any)
1025 -- and exit.
1026 --
1027 -- ... here we go...
1028
1029 -- first determine if current (=old) set of distribution records is
1030 -- based on default account/distribution set
1031
1032 /* Bug fix 2272461
1033 When the MISC receipt amount is changed to zero, the MISCCASH accounting
1034 Record is not created in ar_distributions table. Commented out NOCOPY the portion
1035 of the code which handles the zero receipt amount separately.
1036 IF (p_amount = 0) THEN
1037 --
1038 -- Handle case 8 right away:
1039 --
1040 IF PG_DEBUG in ('Y', 'C') THEN
1041 arp_util.debug('update_misc_dist: ' || '=====> Case 8: amount is zero -- deleting applications');
1042 END IF;
1043
1044 SELECT count(mcd.misc_cash_distribution_id)
1045 INTO l_count
1046 FROM ar_misc_cash_distributions mcd
1047 WHERE mcd.cash_receipt_id = p_cash_receipt_id
1048 AND mcd.reversal_gl_date IS NULL --For rate adjustments picks up records with new rate
1049 AND mcd.posting_control_id = -3 --Not posted
1050 AND EXISTS (SELECT 'x'
1051 FROM ar_distributions ard
1052 WHERE ard.source_id = mcd.misc_cash_distribution_id
1053 AND ard.source_table = 'MCD');
1054
1055 IF PG_DEBUG in ('Y', 'C') THEN
1056 arp_standard.debug('update_misc_dist: ' || ' l_count ' || TO_CHAR(l_count));
1057 END IF;
1058
1059 IF (l_count > 0) THEN
1060 SELECT distinct posting_control_id
1061 INTO l_posted
1062 FROM ar_cash_receipt_history
1063 WHERE cash_receipt_id = p_cash_receipt_id
1064 AND current_record_flag = 'Y';
1065 END IF;
1066 l_ae_doc_rec.document_type := 'RECEIPT';
1067 l_ae_doc_rec.document_id := p_cash_receipt_id;
1068 l_ae_doc_rec.accounting_entity_level := 'ONE';
1069 l_ae_doc_rec.source_table := 'MCD';
1070 l_ae_doc_rec.source_id := '';
1071
1072 --
1073 IF (l_count > 0) then
1074 IF (l_posted = -3) then
1075 arp_acct_main.Delete_Acct_Entry(l_ae_doc_rec);
1076 END IF;
1077 END IF; */
1078 --
1079 /*----------------------------------+
1080 | Added bulk collect of misc cash |
1081 | distribution id for use in MRC |
1082 | engine for trigger replacement |
1083 +----------------------------------*/
1084
1085 /*DELETE ar_misc_cash_distributions
1086 WHERE cash_receipt_id = p_cash_receipt_id
1087 RETURNING misc_cash_distribution_id
1088 BULK COLLECT INTO l_misc_cash_key_value_list; */
1089
1090 /*---------------------------------+
1091 | Calling central MRC library |
1092 | for MRC Integration |
1093 +---------------------------------*/
1094
1095 /* ar_mrc_engine.maintain_mrc_data(
1096 p_event_mode => 'DELETE',
1097 p_table_name => 'AR_MISC_CASH_DISTRIBTIONS',
1098 p_mode => 'BATCH',
1099 p_key_value_list => l_misc_cash_key_value_list);
1100
1101 RETURN;
1102 END IF; */
1103
1104 IF (p_old_distribution_set_id IS NOT NULL) THEN
1105 l_old_recs_auto_flag := TRUE;
1106 ELSE
1107 --
1108 BEGIN
1109 /* For bug2221221 modified the query to handle when receivable
1110 activity is inactivated on the same date as the receipt date */
1111 /* Start Bug 6416611 - modified query to handle case of receivable activity
1112 with distribution set */
1113 SELECT rt.code_combination_id, rt.default_acctg_distribution_set
1114 INTO l_old_trx_code_combination_id, l_old_default_distribution_set
1115 FROM ar_receivables_trx rt
1116 WHERE rt.type in
1117 ('MISCCASH', 'BANK_ERROR', 'CCREFUND', 'CM_REFUND', 'CC_CHARGEBACK')
1118 -- AND ( (NVL( rt.status, 'A' ) = 'A') or (rt.end_date_active=p_receipt_date))
1119 AND rt.RECEIVABLES_TRX_ID = p_old_receivables_trx_id;
1120
1121 IF l_old_default_distribution_set IS NULL then
1122 SELECT 'x' INTO dummy from gl_code_combinations
1123 where code_combination_id = l_old_trx_code_combination_id
1124 AND ENABLED_FLAG='Y';
1125 END IF;
1126 EXCEPTION
1127 WHEN NO_DATA_FOUND THEN
1128 FND_MESSAGE.Set_Name('AR', 'AR_NO_ACTIVITY_FOUND');
1129 APP_EXCEPTION.Raise_Exception;
1130 END;
1131 --
1132 IF (l_old_trx_code_combination_id IS NOT NULL) THEN
1133 l_old_recs_auto_flag := TRUE;
1134 ELSE
1135 l_old_recs_auto_flag := FALSE;
1136 END IF;
1137 END IF;
1138 -- now determine if new set of distribution records is
1139 -- based on default account/distribution set
1140
1141 IF (p_distribution_set_id IS NOT NULL) THEN
1142 l_new_recs_auto_flag := TRUE;
1143 ELSE
1144 --
1145 BEGIN
1146 /* For bug2221221 modified the query to handle when receivable
1147 activity is inactivated on the same date as the receipt date */
1148 /* Start Bug 6416611 - modified query to handle case of receivable activity
1149 with distribution set */
1150 SELECT rt.code_combination_id, rt.default_acctg_distribution_set
1151 INTO l_trx_code_combination_id, l_default_distribution_set
1152 FROM ar_receivables_trx rt
1153 WHERE rt.type in
1154 ('MISCCASH', 'BANK_ERROR', 'CCREFUND', 'CM_REFUND' , 'CC_CHARGEBACK')
1155 -- AND ((NVL( rt.status, 'A' ) = 'A') or (rt.end_date_active=p_receipt_date))
1156 AND rt.RECEIVABLES_TRX_ID = p_receivables_trx_id;
1157
1158 IF l_default_distribution_set IS NULL then
1159 SELECT 'x' INTO dummy from gl_code_combinations
1160 where code_combination_id = l_trx_code_combination_id
1161 AND ENABLED_FLAG='Y';
1162 END IF;
1163 EXCEPTION
1164 WHEN NO_DATA_FOUND THEN
1165 FND_MESSAGE.Set_Name('AR', 'AR_NO_ACTIVITY_FOUND');
1166 APP_EXCEPTION.Raise_Exception;
1167 END;
1168 --
1169 IF (l_trx_code_combination_id IS NOT NULL) THEN
1170 l_new_recs_auto_flag := TRUE;
1171 ELSE
1172 l_new_recs_auto_flag := FALSE;
1173 END IF;
1174 END IF;
1175
1176 IF (l_new_recs_auto_flag) THEN
1177 IF PG_DEBUG in ('Y', 'C') THEN
1178 arp_standard.debug('update_misc_dist: ' || 'l_new_recs_auto_flag = TRUE');
1179 END IF;
1180 ELSE
1181 IF PG_DEBUG in ('Y', 'C') THEN
1182 arp_standard.debug('update_misc_dist: ' || 'l_new_recs_auto_flag = FALSE');
1183 END IF;
1184 END IF;
1185
1186 IF (l_old_recs_auto_flag) THEN
1187 IF PG_DEBUG in ('Y', 'C') THEN
1188 arp_standard.debug('update_misc_dist: ' || 'l_old_recs_auto_flag = TRUE');
1189 END IF;
1190 ELSE
1191 IF PG_DEBUG in ('Y', 'C') THEN
1192 arp_standard.debug('update_misc_dist: ' || 'l_old_recs_auto_flag = FALSE');
1193 END IF;
1194 END IF;
1195
1196 IF PG_DEBUG in ('Y', 'C') THEN
1197 arp_standard.debug('update_misc_dist: ' || 'p_distribution_set_id = ' ||
1198 to_char(p_distribution_set_id));
1199 arp_standard.debug('update_misc_dist: ' || 'p_old_distribution_set_id = ' ||
1200 to_char(p_old_distribution_set_id));
1201 arp_standard.debug('update_misc_dist: ' || 'l_trx_code_combination_id = ' ||
1202 to_char(l_trx_code_combination_id));
1203 arp_standard.debug('update_misc_dist: ' || 'l_old_trx_code_combination_id = ' ||
1204 to_char(l_old_trx_code_combination_id));
1205 END IF;
1206
1207
1208 --
1209 -- now handle different cases as outlined above:
1210 --
1211 IF ((p_amount_changed_flag = FALSE) AND
1212 ((l_old_recs_auto_flag = TRUE and l_new_recs_auto_flag = TRUE and
1213 (p_distribution_set_id = p_old_distribution_set_id OR
1214 l_trx_code_combination_id = l_old_trx_code_combination_id)) OR
1215 (l_old_recs_auto_flag = FALSE and l_new_recs_auto_flag = FALSE))) THEN
1216 --
1217 -- Handle cases 1 / 7:
1218 --
1219 -- check if gl_date or receipt date has changed. If one of them has
1220 -- changed, simply update the dates in all existing distribution records:
1221 --
1222 IF (p_receipt_date_changed_flag = TRUE OR
1223 p_gl_date_changed_flag = TRUE) THEN
1224 --
1225 IF PG_DEBUG in ('Y', 'C') THEN
1226 arp_util.debug('update_misc_dist: ' || '=====> Case 1/7: updating distributions with new date(s)');
1227 END IF;
1228 --
1229 /*----------------------------------+
1230 | Added bulk collect of misc cash |
1231 | distribution id for use in MRC |
1232 | engine for trigger replacement |
1233 +----------------------------------*/
1234 /* Bug 5980036 */
1235 UPDATE ar_misc_cash_distributions
1236 SET -- gl_date = p_gl_date,
1237 apply_date = p_receipt_date
1238 WHERE cash_receipt_id = p_cash_receipt_id
1239 RETURNING misc_cash_distribution_id
1240 BULK COLLECT INTO l_misc_cash_key_value_list;
1241
1242 /*---------------------------------+
1243 | Calling central MRC library |
1244 | for MRC Integration |
1245 +---------------------------------*/
1246 /*BUG4301323
1247 ar_mrc_engine.maintain_mrc_data(
1248 p_event_mode => 'UPDATE',
1249 p_table_name => 'AR_MISC_CASH_DISTRIBTIONS',
1250 p_mode => 'BATCH',
1251 p_key_value_list => l_misc_cash_key_value_list);
1252 */
1253 ELSE
1254 IF PG_DEBUG in ('Y', 'C') THEN
1255 arp_util.debug('update_misc_dist: ' || '=====> Case 1/7: no update required');
1256 END IF;
1257 END IF;
1258 --
1259 /* Bug 1792989. When only the receipt amount is changed with no change
1260 to receivable activity, then distribution accounting should not be
1261 affected and only the amounts should be updated in
1262 AR_MISC_CASH_DISTRIBUTIONS. Also Accounting engine is called to
1263 recreate accounting in AR_DISTRIBUTIONS for the new amounts.
1264 This is done by
1265 1. Calling the Accounting engine to delete the MCD records
1266 from AR_DISTRIBUTIONS for the passed cash_receipt_id.
1267 2. Update the amount in AR_MISC_CASH_DISTRIBUTIONS by calling
1268 procedure update_manual_dist.
1269 3. Calling the Accounting engine to recreate the MCD records
1270 taking the new amount into consideration.
1271 */
1272 /* bug 3324670 : modified the below ELSIF */
1273 ELSIF (p_amount_changed_flag = TRUE AND
1274 (l_old_recs_auto_flag = TRUE AND
1275 l_new_recs_auto_flag = TRUE AND
1276 (p_distribution_set_id = p_old_distribution_set_id OR
1277 l_trx_code_combination_id = l_old_trx_code_combination_id)) OR
1278 (l_old_recs_auto_flag = FALSE AND
1279 l_new_recs_auto_flag = FALSE)) THEN
1280
1281 IF PG_DEBUG in ('Y', 'C') THEN
1282 arp_util.debug('update_misc_dist: ' || '=====> Case 2: updating amounts');
1283 END IF;
1284 SELECT count(mcd.misc_cash_distribution_id)
1285 INTO l_count
1286 FROM ar_misc_cash_distributions mcd
1287 WHERE mcd.cash_receipt_id = p_cash_receipt_id
1288 AND mcd.reversal_gl_date IS NULL
1289 AND mcd.posting_control_id = -3
1290 AND EXISTS (SELECT 'x'
1291 FROM ar_distributions ard
1292 WHERE ard.source_id = mcd.misc_cash_distribution_id
1293 AND ard.source_table = 'MCD');
1294
1295 l_ae_doc_rec.document_type := 'RECEIPT';
1296 l_ae_doc_rec.document_id := p_cash_receipt_id;
1297 l_ae_doc_rec.accounting_entity_level := 'ONE';
1298 l_ae_doc_rec.source_table := 'MCD';
1299 l_ae_doc_rec.source_id := '';
1300 /* Bugfix 2753644. */
1301 l_ae_doc_rec.gl_tax_acct := p_gl_tax_acct;
1302
1303 IF (l_count > 0) then
1304 SELECT distinct posting_control_id
1305 INTO l_posted
1306 FROM ar_cash_receipt_history
1307 WHERE cash_receipt_id = p_cash_receipt_id
1308 AND current_record_flag = 'Y';
1309
1310 IF (l_posted = -3) THEN
1311
1312 -- Call accounting entry library begins
1313 IF PG_DEBUG in ('Y', 'C') THEN
1314 arp_standard.debug('update_misc_dist: ' || 'Delete Misc Cash Receipt start () +');
1315 END IF;
1316 arp_acct_main.Delete_Acct_Entry(l_ae_doc_rec);
1317 IF PG_DEBUG in ('Y', 'C') THEN
1318 arp_standard.debug('update_misc_dist: ' || 'Delete Misc Cash Receipt start () -');
1319 END IF;
1320 END IF;
1321 END IF;
1322
1323 update_manual_dist( p_cash_receipt_id,
1324 p_amount,
1325 p_acctd_amount,
1326 p_exchange_rate,
1327 p_currency_code,
1328 p_gl_date,
1329 p_receipt_date );
1330
1331 SELECT distinct posting_control_id
1332 INTO l_posted
1333 FROM ar_cash_receipt_history
1334 WHERE cash_receipt_id = p_cash_receipt_id
1335 AND current_record_flag = 'Y';
1336 IF (l_posted = -3) then
1337 IF PG_DEBUG in ('Y', 'C') THEN
1338 arp_standard.debug('update_misc_dist: ' || ' Create Acct Entry');
1339 END IF;
1340 arp_acct_main.Create_Acct_Entry(l_ae_doc_rec);
1341 END IF;
1342 --
1343 /* bug 3324670 : commenting below code.Case 2 has been handled Above */
1344 /*
1345 ELSIF (p_amount_changed_flag = TRUE AND
1346 l_old_recs_auto_flag = FALSE AND
1347 l_new_recs_auto_flag = TRUE) THEN
1348 --
1349 -- Handle case 2:
1350 --
1351 -- if distribution was and still is created manually, just update
1352 -- the amounts for each record.
1353 --
1354 IF PG_DEBUG in ('Y', 'C') THEN
1355 arp_util.debug('update_misc_dist: ' || '=====> Case 2: updating amounts');
1356 END IF;
1357 --
1358 update_manual_dist( p_cash_receipt_id,
1359 p_amount,
1360 p_acctd_amount,
1361 p_exchange_rate,
1362 p_currency_code,
1363 p_gl_date,
1364 p_receipt_date );
1365 --
1366 */
1367 ELSIF (l_old_recs_auto_flag = TRUE AND
1368 l_new_recs_auto_flag = FALSE) THEN
1369 --
1370 -- Handle case 3:
1371 --
1372 -- was:
1373 -- Delete old (automatically created records). User has to enter
1374 -- new records manually.
1375 --
1376 -- now: do nothing (see above)
1377 --
1378 /*
1379 ***** IF THIS EVER IS UNCOMMENTED, THEN A CALL TO THE MRC ENGINE IS
1380 REQUIRED.....
1381
1382 IF PG_DEBUG in ('Y', 'C') THEN
1383 arp_util.debug('update_misc_dist: ' || 'Case 3: deleting old records');
1384 END IF;
1385
1386 DELETE ar_misc_cash_distributions
1387 WHERE cash_receipt_id = p_cash_receipt_id;
1388
1389 */
1390 IF PG_DEBUG in ('Y', 'C') THEN
1391 arp_util.debug('update_misc_dist: ' || '=====> Case 3: do nothing');
1392 END IF;
1393 NULL;
1394
1395 ELSE
1396
1397 /* ((l_old_recs_auto_flag = FALSE AND
1398 l_new_recs_auto_flag = TRUE) OR
1399 (l_old_recs_auto_flag = TRUE AND
1400 l_new_recs_auto_flag = TRUE)) THEN
1401 --
1402 -- the above condition can obviously simplified, but was left the
1403 -- way it is to more closely match the conditions associated with
1404 -- cases 4, 5, and 6 (for maintenance purposes).
1405
1406 */
1407 --
1408 -- Handle case 4, 5, 6:
1409 --
1410 -- the old records need to be deleted (no matter how they were
1411 -- created, and new ones will created automatically based on the
1412 -- ccid or distribution set.
1413
1414 IF PG_DEBUG in ('Y', 'C') THEN
1415 arp_standard.debug('update_misc_dist: ' || ' =====> CASE 4, 5, 6');
1416 END IF;
1417
1418 SELECT count(mcd.misc_cash_distribution_id)
1419 INTO l_count
1420 FROM ar_misc_cash_distributions mcd
1421 WHERE mcd.cash_receipt_id = p_cash_receipt_id
1422 AND mcd.reversal_gl_date IS NULL --For rate adjustments picks up records with new rate
1423 AND mcd.posting_control_id = -3 --Not posted
1424 AND EXISTS (SELECT 'x'
1425 FROM ar_distributions ard
1426 WHERE ard.source_id = mcd.misc_cash_distribution_id
1427 AND ard.source_table = 'MCD');
1428
1429 IF PG_DEBUG in ('Y', 'C') THEN
1430 arp_standard.debug('update_misc_dist: ' || ' l_count ' || TO_CHAR(l_count));
1431 END IF;
1432
1433 l_ae_doc_rec.document_type := 'RECEIPT';
1434 l_ae_doc_rec.document_id := p_cash_receipt_id;
1435 l_ae_doc_rec.accounting_entity_level := 'ONE';
1436 l_ae_doc_rec.source_table := 'MCD';
1437 l_ae_doc_rec.source_id := '';
1438 /* Bugfix 2753644 */
1439 l_ae_doc_rec.gl_tax_acct := p_gl_tax_acct;
1440
1441 IF (l_count > 0) then
1442
1443 SELECT distinct posting_control_id
1444 INTO l_posted
1445 FROM ar_cash_receipt_history
1446 WHERE cash_receipt_id = p_cash_receipt_id
1447 AND current_record_flag = 'Y';
1448
1449 IF (l_posted = -3) THEN
1450
1451 -- Call accounting entry library begins
1452 IF PG_DEBUG in ('Y', 'C') THEN
1453 arp_standard.debug('update_misc_dist: ' || 'Delete Misc Cash Receipt start () +');
1454 END IF;
1455
1456 -- Calling accounting entry library
1457 arp_acct_main.Delete_Acct_Entry(l_ae_doc_rec);
1458 IF PG_DEBUG in ('Y', 'C') THEN
1459 arp_standard.debug('update_misc_dist: ' || 'Delete Misc Cash Receipt start () -');
1460 END IF;
1461 END IF;
1462 END IF;
1463
1464 insert_misc_dist( p_cash_receipt_id,
1465 p_gl_date,
1466 p_amount,
1467 p_currency_code,
1468 p_exchange_rate,
1469 p_acctd_amount,
1470 p_receipt_date,
1471 p_receivables_trx_id,
1472 p_distribution_set_id);
1473
1474 SELECT distinct posting_control_id
1475 INTO l_posted
1476 FROM ar_cash_receipt_history
1477 WHERE cash_receipt_id = p_cash_receipt_id
1478 AND current_record_flag = 'Y';
1479 IF (l_posted = -3) then
1480 IF PG_DEBUG in ('Y', 'C') THEN
1481 arp_standard.debug('update_misc_dist: ' || ' Create Acct Entry');
1482 END IF;
1483 arp_acct_main.Create_Acct_Entry(l_ae_doc_rec);
1484
1485 END IF;
1486 --
1487 END IF;
1488
1489 IF PG_DEBUG in ('Y', 'C') THEN
1490 arp_standard.debug('arp_process_receipts.update_misc_dist()-');
1491 END IF;
1492
1493 END update_misc_dist;
1494
1495 /*===========================================================================+
1496 | PROCEDURE |
1497 | create_mcd_recs |
1498 | |
1499 | DESCRIPTION |
1500 | creates distribution in ar_misc_cash_distributions based on a pre- |
1501 | defined distribution set. This function also takes care of possible |
1502 | rounding errors. |
1503 | |
1504 | SCOPE - PRIVATE |
1505 | |
1506 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED |
1507 | |
1508 | ARGUMENTS |
1509 | IN: |
1510 | OUT: |
1511 | |
1512 | RETURNS |
1513 | |
1514 | NOTES |
1515 | |
1516 | MODIFICATION HISTORY |
1517 | |
1518 | 22-SEP-95 OSTEINME created |
1519 | 28-SEP-98 K.Murphy Bug #705078. Added code to validate the key |
1520 | flex before the MISC distributions are |
1521 | created. Checks both the enabled flag and |
1522 | From/To dates. |
1523 | Shuffled the code around a bit in order to do|
1524 | this. Changed the insert from "insert as |
1525 | select" to using a cursor. |
1526 | |
1527 +===========================================================================*/
1528
1529
1530 PROCEDURE create_mcd_recs(
1531 p_cash_receipt_id IN ar_cash_receipts.cash_receipt_id%TYPE,
1532 p_amount IN ar_cash_receipts.amount%TYPE,
1533 p_acctd_amount IN ar_cash_receipt_history.acctd_amount%TYPE,
1534 p_exchange_rate IN ar_cash_receipts.exchange_rate%TYPE,
1535 p_currency_code IN ar_cash_receipts.currency_code%TYPE,
1536 p_gl_date IN ar_cash_receipt_history.gl_date%TYPE,
1537 p_receipt_date IN ar_cash_receipts.receipt_date%TYPE,
1538 p_distribution_set_id IN ar_cash_receipts.distribution_set_id%TYPE,
1539 p_ussgl_trx_code IN ar_cash_receipts.ussgl_transaction_code%TYPE
1540 ) IS
1541
1542 l_min_unit NUMBER;
1543 l_precision NUMBER;
1544 l_acctd_rounding_diff NUMBER;
1545 l_rounding_diff NUMBER;
1546 l_misc_cash_dist_id ar_misc_cash_distributions.misc_cash_distribution_id%TYPE; /* added for mrc changes */
1547 l_misc_cash_key_value_list gl_ca_utility_pkg.r_key_value_arr;
1548
1549 l_xla_ev_rec arp_xla_events.xla_events_type;
1550
1551 /* Bug fix 2843634
1552 Modified the cursor to take care of the situation where the receipt amount is zero */
1553
1554 CURSOR c_dist IS
1555 SELECT
1556 dist_code_combination_id,
1557 DECODE(p_amount,0,ROUND(percent_distribution,3),
1558 ROUND
1559 (
1560 ROUND((percent_distribution/100.0) * p_amount,3) * 100/
1561 p_amount,
1562 3
1563 )) percent,
1564 decode
1565 (
1566 l_min_unit, null,
1567 round(p_amount * percent_distribution/100,
1568 l_precision),
1569 round(p_amount * (percent_distribution/100)/l_min_unit)
1570 * l_min_unit
1571 ) amount,
1572 decode
1573 (
1574 arp_global.base_min_acc_unit, null,
1575 round((p_amount * percent_distribution/100) * nvl(p_exchange_rate,1),
1576 arp_global.base_precision),
1577 round(p_amount * (percent_distribution/100) * nvl(p_exchange_rate,1)
1578 / arp_global.base_precision) * arp_global.base_precision
1579 ) acctd_amount
1580 FROM
1581 ar_distribution_set_lines
1582 WHERE
1583 distribution_set_id = p_distribution_set_id;
1584
1585 CURSOR c_hist IS
1586 SELECT cash_receipt_history_id
1587 FROM ar_cash_receipt_history
1588 WHERE current_record_flag = 'Y'
1589 AND cash_receipt_id = p_cash_receipt_id;
1590
1591 l_crh_id NUMBER;
1592
1593 BEGIN
1594
1595 arp_standard.debug('arp_process_receipts.create_mcd_recs()+');
1596
1597 SELECT minimum_accountable_unit,precision
1598 INTO l_min_unit, l_precision
1599 FROM fnd_currencies
1600 WHERE currency_code = p_currency_code;
1601
1602 OPEN c_hist;
1603 FETCH c_hist INTO l_crh_id;
1604 CLOSE c_hist;
1605
1606
1607 FOR dist in c_dist LOOP
1608 -- Bug fix #705078
1609 -- Verify that account is valid before doing insert.
1610 --
1611 -- Using the flex field server APIs to do this ...
1612 -- (note also that we are using the same error message
1613 -- for each case.
1614 --
1615 -- Firstly, call fnd_flex_keyval.validate_ccid to populate
1616 -- all of the relevant global variables.
1617 --
1618 IF fnd_flex_keyval.validate_ccid(
1619 appl_short_name => 'SQLGL',
1620 key_flex_code => 'GL#',
1621 structure_number => arp_global.chart_of_accounts_id,
1622 combination_id => dist.dist_code_combination_id) THEN
1623 -- Secondly, check is the key flex is enabled.
1624 --
1625 IF not fnd_flex_keyval.enabled_flag THEN
1626 FND_MESSAGE.Set_Name('AR', 'AR_GL_ACCOUNT_INVALID');
1627 APP_EXCEPTION.Raise_Exception;
1628 -- Thirdly, check if the key flex is valid for this date.
1629 --
1630 ELSIF p_gl_date NOT between nvl(fnd_flex_keyval.start_date,p_gl_date)
1631 and nvl(fnd_flex_keyval.end_date,p_gl_date) THEN
1632 FND_MESSAGE.Set_Name('AR', 'AR_GL_ACCOUNT_INVALID');
1633 APP_EXCEPTION.Raise_Exception;
1634 END IF;
1635 END IF;
1636
1637 /* store the misc cash dist id for use in MRC call */
1638
1639 SELECT ar_misc_cash_distributions_s.nextval
1640 INTO l_misc_cash_dist_id
1641 FROM DUAL;
1642
1643 INSERT INTO ar_misc_cash_distributions (
1644 misc_cash_distribution_id,
1645 last_updated_by,
1646 last_update_date,
1647 created_by,
1648 creation_date,
1649 cash_receipt_id,
1650 gl_date,
1651 apply_date,
1652 code_combination_id,
1653 percent,
1654 amount,
1655 set_of_books_id,
1656 acctd_amount,
1657 posting_control_id,
1658 created_from,
1659 ussgl_transaction_code,org_id,
1660 cash_receipt_history_id)
1661 VALUES
1662 (
1663 l_misc_cash_dist_id,
1664 arp_global.user_id,
1665 arp_global.last_update_date,
1666 arp_global.created_by,
1667 arp_global.creation_date,
1668 p_cash_receipt_id,
1669 trunc(p_gl_date),
1670 p_receipt_date,
1671 dist.dist_code_combination_id,
1672 dist.percent,
1673 dist.amount,
1674 arp_global.set_of_books_id,
1675 dist.acctd_amount,
1676 -3,
1677 'ARRERCT',
1678 p_ussgl_trx_code, arp_standard.sysparm.org_id,
1679 l_crh_id);
1680
1681
1682 l_xla_ev_rec.xla_from_doc_id := p_cash_receipt_id;
1683 l_xla_ev_rec.xla_to_doc_id := p_cash_receipt_id;
1684 l_xla_ev_rec.xla_doc_table := 'MCD';
1685 l_xla_ev_rec.xla_mode := 'O';
1686 l_xla_ev_rec.xla_call := 'D';
1687 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
1688
1689
1690 /*---------------------------------+
1691 | Calling central MRC library |
1692 | for MRC Integration |
1693 +---------------------------------*/
1694 /*4301323
1695 ar_mrc_engine.maintain_mrc_data(
1696 p_event_mode => 'INSERT',
1697 p_table_name => 'AR_MISC_CASH_DISTRIBUTIONS',
1698 p_mode => 'SINGLE',
1699 p_key_value => l_misc_cash_dist_id );
1700 */
1701 END LOOP;
1702
1703 -- determine if there is a rounding error
1704
1705 SELECT NVL(p_amount, 0) -
1706 NVL(SUM
1707 (
1708 decode
1709 (
1710 l_min_unit, null,
1711 round(p_amount * percent_distribution/100,
1712 l_precision),
1713 round(p_amount*(percent_distribution/100)/l_min_unit)
1714 *l_min_unit
1715 )
1716 ),0)
1717 ,
1718 NVL(p_acctd_amount, 0) -
1719 NVL(SUM
1720 (
1721 decode
1722 (
1723 arp_global.base_min_acc_unit, null,
1724 round((p_amount * percent_distribution/100)
1725 * nvl(p_exchange_rate,1),
1726 arp_global.base_precision),
1727 round(p_amount * (percent_distribution/100)
1728 * nvl(p_exchange_rate ,1) /
1729 arp_global.base_precision)
1730 * arp_global.base_precision
1731 )
1732 ),0)
1733
1734 INTO l_rounding_diff,
1735 l_acctd_rounding_diff
1736 FROM ar_distribution_set_lines
1737 WHERE distribution_set_id = p_distribution_set_id;
1738
1739 arp_util.debug('Rounding error = ' || to_char(l_rounding_diff));
1740 arp_util.debug('Rounding error (acctd) = ' || to_char(l_acctd_rounding_diff));
1741
1742
1743 IF (l_acctd_rounding_diff <> 0 OR l_rounding_diff <>0) THEN
1744
1745 /*----------------------------------+
1746 | Added bulk collect of misc cash |
1747 | distribution id for use in MRC |
1748 | engine for trigger replacement |
1749 +----------------------------------*/
1750
1751 UPDATE ar_misc_cash_distributions
1752 SET amount = amount + l_rounding_diff,
1753 acctd_amount = acctd_amount + l_acctd_rounding_diff,
1754 percent = ROUND (
1755 (amount + l_rounding_diff)*100/p_amount,
1756 3 )
1757 WHERE cash_receipt_id = p_cash_receipt_id
1758 AND ROWNUM = 1
1759 RETURNING misc_cash_distribution_id
1760 BULK COLLECT INTO l_misc_cash_key_value_list;
1761
1762 /*---------------------------------+
1763 | Calling central MRC library |
1764 | for MRC Integration |
1765 +---------------------------------*/
1766 /*BUG4301323
1767 ar_mrc_engine.maintain_mrc_data(
1768 p_event_mode => 'UPDATE',
1769 p_table_name => 'AR_MISC_CASH_DISTRIBUTIONS',
1770 p_mode => 'BATCH',
1771 p_key_value_list => l_misc_cash_key_value_list);
1772 */
1773
1774 END IF;
1775
1776 -- round percentages if necessary
1777
1778 round_mcd_recs(p_cash_receipt_id);
1779
1780 arp_standard.debug('arp_process_receipts.create_mcd_recs()-');
1781
1782 END; -- create_mcd_recs()
1783
1784
1785 /*===========================================================================+
1786 | PROCEDURE |
1787 | update_manual_dist |
1788 | |
1789 | DESCRIPTION |
1790 | creates distribution in ar_misc_cash_distributions based on a pre- |
1791 | defined distribution set. This function also takes care of possible |
1792 | rounding errors. |
1793 | |
1794 | SCOPE - PRIVATE |
1795 | |
1796 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED |
1797 | |
1798 | ARGUMENTS |
1799 | IN: |
1800 | OUT: |
1801 | |
1802 | RETURNS |
1803 | |
1804 | NOTES |
1805 | |
1806 | MODIFICATION HISTORY |
1807 | |
1808 | 22-SEP-95 OSTEINME created |
1809 | |
1810 +===========================================================================*/
1811
1812 PROCEDURE update_manual_dist(
1813 p_cash_receipt_id IN ar_cash_receipts.cash_receipt_id%TYPE,
1814 p_amount IN ar_cash_receipts.amount%TYPE,
1815 p_acctd_amount IN ar_cash_receipt_history.acctd_amount%TYPE,
1816 p_exchange_rate IN ar_cash_receipts.exchange_rate%TYPE,
1817 p_currency_code IN ar_cash_receipts.currency_code%TYPE,
1818 p_gl_date IN ar_cash_receipt_history.gl_date%TYPE,
1819 p_receipt_date IN ar_cash_receipts.receipt_date%TYPE
1820 ) IS
1821
1822 l_min_unit NUMBER;
1823 l_precision NUMBER;
1824 l_acctd_rounding_diff NUMBER;
1825 l_rounding_diff NUMBER;
1826 l_misc_cash_key_value_list gl_ca_utility_pkg.r_key_value_arr;
1827
1828 BEGIN
1829
1830 arp_standard.debug('arp_process_receipts.update_manual_dist()+');
1831
1832 SELECT minimum_accountable_unit,precision
1833 INTO l_min_unit, l_precision
1834 FROM fnd_currencies
1835 WHERE currency_code = p_currency_code;
1836
1837 /*----------------------------------+
1838 | Added bulk collect of misc cash |
1839 | distribution id for use in MRC |
1840 | engine for trigger replacement |
1841 +----------------------------------*/
1842
1843 UPDATE ar_misc_cash_distributions
1844 SET gl_date = p_gl_date,
1845 apply_date = p_receipt_date,
1846 amount = decode
1847 (
1848 l_min_unit, null,
1849 round(p_amount * percent/100,
1850 l_precision),
1851 round(p_amount * (percent/100)/l_min_unit)
1852 * l_min_unit
1853 ),
1854 acctd_amount = decode
1855 (
1856 arp_global.base_min_acc_unit, null,
1857 round((p_amount * percent/100) * nvl(p_exchange_rate,1),
1858 arp_global.base_precision),
1859 round(p_amount * (percent/100) * nvl(p_exchange_rate,1)
1860 / arp_global.base_precision) * arp_global.base_precision
1861 ),
1862 last_updated_by = arp_global.user_id,
1863 last_update_date = arp_global.last_update_date
1864 WHERE cash_receipt_id = p_cash_receipt_id
1865 RETURNING misc_cash_distribution_id
1866 BULK COLLECT INTO l_misc_cash_key_value_list;
1867
1868 /*---------------------------------+
1869 | Calling central MRC library |
1870 | for MRC Integration |
1871 +---------------------------------*/
1872 /*BUG4301323
1873 ar_mrc_engine.maintain_mrc_data(
1874 p_event_mode => 'UPDATE',
1875 p_table_name => 'AR_MISC_CASH_DISTRIBUTIONS',
1876 p_mode => 'BATCH',
1877 p_key_value_list => l_misc_cash_key_value_list);
1878 */
1879 -- determine if there is a rounding error
1880
1881 SELECT NVL(p_amount, 0) -
1882 NVL(SUM
1883 (
1884 decode
1885 (
1886 l_min_unit, null,
1887 round(p_amount * percent/100,
1888 l_precision),
1889 round(p_amount*(percent/100)/l_min_unit)
1890 *l_min_unit
1891 )
1892 ),0)
1893 ,
1894 NVL(p_acctd_amount, 0) -
1895 NVL(SUM
1896 (
1897 decode
1898 (
1899 arp_global.base_min_acc_unit, null,
1900 round((p_amount * percent/100)
1901 * nvl(p_exchange_rate,1),
1902 arp_global.base_precision),
1903 round(p_amount * (percent/100)
1904 * nvl(p_exchange_rate ,1) /
1905 arp_global.base_precision)
1906 * arp_global.base_precision
1907 )
1908 ),0)
1909
1910 INTO l_rounding_diff,
1911 l_acctd_rounding_diff
1912 FROM ar_misc_cash_distributions
1913 WHERE cash_receipt_id = p_cash_receipt_id;
1914
1915 arp_util.debug('Rounding error = ' || to_char(l_rounding_diff));
1916 arp_util.debug('Rounding error (acctd) = ' || to_char(l_acctd_rounding_diff));
1917
1918
1919 IF (l_acctd_rounding_diff <> 0 OR l_rounding_diff <>0) THEN
1920
1921 /*----------------------------------+
1922 | Added bulk collect of misc cash |
1923 | distribution id for use in MRC |
1924 | engine for trigger replacement |
1925 +----------------------------------*/
1926 UPDATE ar_misc_cash_distributions
1927 SET amount = amount + l_rounding_diff,
1928 acctd_amount = acctd_amount + l_acctd_rounding_diff,
1929 percent = ROUND (
1930 (amount + l_rounding_diff)*100/p_amount,
1931 3 )
1932 WHERE cash_receipt_id = p_cash_receipt_id
1933 AND ROWNUM = 1
1934 RETURNING misc_cash_distribution_id
1935 BULK COLLECT INTO l_misc_cash_key_value_list;
1936
1937 /*---------------------------------+
1938 | Calling central MRC library |
1939 | for MRC Integration |
1940 +---------------------------------*/
1941 /*BUG4301323
1942 ar_mrc_engine.maintain_mrc_data(
1943 p_event_mode => 'UPDATE',
1944 p_table_name => 'AR_MISC_CASH_DISTRIBUTIONS',
1945 p_mode => 'BATCH',
1946 p_key_value_list => l_misc_cash_key_value_list);
1947 */
1948
1949 END IF;
1950
1951 -- round percent columns if necessary
1952
1953 round_mcd_recs(p_cash_receipt_id);
1954
1955 arp_standard.debug('arp_process_receipts.update_manual_dist()-');
1956
1957 END; -- update_manual_dist()
1958 --
1959
1960
1961 /*===========================================================================+
1962 | PROCEDURE |
1963 | rate_adjust |
1964 | |
1965 | DESCRIPTION |
1966 | This function inserts a record into the rate adjustments table by |
1967 | calling the rate adjustments table handler. The INSERT will cause |
1968 | a database trigger to fire, which will update related tables. |
1969 | This function is being called from update_cash_receipts and from |
1970 | update_misc_receipts. |
1971 | |
1972 | SCOPE - PRIVATE |
1973 | |
1974 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED |
1975 | |
1976 | ARGUMENTS |
1977 | IN: |
1978 | OUT: |
1979 | |
1980 | RETURNS |
1981 | |
1982 | NOTES |
1983 | |
1984 | MODIFICATION HISTORY |
1985 | |
1986 | 26-JAN-96 OSTEINME created |
1987 | 08-AUG-97 KLAWRANC Added call to arp_rate_adj.main as the rate |
1988 | adjustments trigger has been removed in |
1989 | Release 11. |
1990 | |
1991 +===========================================================================*/
1992
1993 PROCEDURE rate_adjust(
1994 p_cash_receipt_id IN ar_cash_receipts.cash_receipt_id%TYPE,
1995 p_rate_adjust_gl_date IN DATE,
1996 p_new_exchange_date IN DATE,
1997 p_new_exchange_rate IN ar_rate_adjustments.new_exchange_rate%TYPE,
1998 p_new_exchange_rate_type IN ar_rate_adjustments.new_exchange_rate_type%TYPE,
1999 p_old_exchange_date IN DATE,
2000 p_old_exchange_rate IN ar_rate_adjustments.old_exchange_rate%TYPE,
2001 p_old_exchange_rate_type IN ar_rate_adjustments.old_exchange_rate_type%TYPE,
2002 p_gain_loss IN ar_rate_adjustments.gain_loss%TYPE,
2003 p_exchange_rate_attr_cat IN ar_rate_adjustments.attribute_category%TYPE,
2004 p_exchange_rate_attr1 IN ar_rate_adjustments.attribute1%TYPE,
2005 p_exchange_rate_attr2 IN ar_rate_adjustments.attribute2%TYPE,
2006 p_exchange_rate_attr3 IN ar_rate_adjustments.attribute3%TYPE,
2007 p_exchange_rate_attr4 IN ar_rate_adjustments.attribute4%TYPE,
2008 p_exchange_rate_attr5 IN ar_rate_adjustments.attribute5%TYPE,
2009 p_exchange_rate_attr6 IN ar_rate_adjustments.attribute6%TYPE,
2010 p_exchange_rate_attr7 IN ar_rate_adjustments.attribute7%TYPE,
2011 p_exchange_rate_attr8 IN ar_rate_adjustments.attribute8%TYPE,
2012 p_exchange_rate_attr9 IN ar_rate_adjustments.attribute9%TYPE,
2013 p_exchange_rate_attr10 IN ar_rate_adjustments.attribute10%TYPE,
2014 p_exchange_rate_attr11 IN ar_rate_adjustments.attribute11%TYPE,
2015 p_exchange_rate_attr12 IN ar_rate_adjustments.attribute12%TYPE,
2016 p_exchange_rate_attr13 IN ar_rate_adjustments.attribute13%TYPE,
2017 p_exchange_rate_attr14 IN ar_rate_adjustments.attribute14%TYPE,
2018 p_exchange_rate_attr15 IN ar_rate_adjustments.attribute15%TYPE) IS
2019
2020 l_radj_rec ar_rate_adjustments%ROWTYPE;
2021 l_radj_id ar_rate_adjustments.rate_adjustment_id%TYPE;
2022 l_crh_id_out ar_cash_receipt_history.cash_receipt_history_id%TYPE;
2023
2024 BEGIN
2025 IF PG_DEBUG in ('Y', 'C') THEN
2026 arp_standard.debug('arp_process_rct_util.rate_adjust()+');
2027 END IF;
2028
2029 l_radj_rec.cash_receipt_id := p_cash_receipt_id;
2030 l_radj_rec.old_exchange_rate := p_old_exchange_rate;
2031 l_radj_rec.old_exchange_date := p_old_exchange_date;
2032 l_radj_rec.old_exchange_rate_type := p_old_exchange_rate_type;
2033 l_radj_rec.new_exchange_rate := p_new_exchange_rate;
2034 l_radj_rec.new_exchange_date := p_new_exchange_date;
2035 l_radj_rec.new_exchange_rate_type := p_new_exchange_rate_type;
2036 l_radj_rec.gain_loss := p_gain_loss;
2037 l_radj_rec.gl_date := p_rate_adjust_gl_date;
2038 l_radj_rec.attribute_category := p_exchange_rate_attr_cat;
2039 l_radj_rec.attribute1 := p_exchange_rate_attr1;
2040 l_radj_rec.attribute2 := p_exchange_rate_attr2;
2041 l_radj_rec.attribute3 := p_exchange_rate_attr3;
2042 l_radj_rec.attribute4 := p_exchange_rate_attr4;
2043 l_radj_rec.attribute5 := p_exchange_rate_attr5;
2044 l_radj_rec.attribute6 := p_exchange_rate_attr6;
2045 l_radj_rec.attribute7 := p_exchange_rate_attr7;
2046 l_radj_rec.attribute8 := p_exchange_rate_attr8;
2047 l_radj_rec.attribute9 := p_exchange_rate_attr9;
2048 l_radj_rec.attribute10 := p_exchange_rate_attr10;
2049 l_radj_rec.attribute11 := p_exchange_rate_attr11;
2050 l_radj_rec.attribute12 := p_exchange_rate_attr12;
2051 l_radj_rec.attribute13 := p_exchange_rate_attr13;
2052 l_radj_rec.attribute14 := p_exchange_rate_attr14;
2053 l_radj_rec.attribute15 := p_exchange_rate_attr15;
2054
2055 l_radj_rec.created_from := 'ARXCAACI';
2056
2057 arp_rate_adjustments_pkg.insert_p(
2058 l_radj_rec,
2059 l_radj_id);
2060
2061 -- Call procedure that performs the rate adjustment processing,
2062 -- e.g. updates receivable applications etc.
2063 arp_rate_adj.main(
2064 p_cash_receipt_id,
2065 p_new_exchange_date,
2066 p_new_exchange_rate,
2067 p_new_exchange_rate_type,
2068 p_rate_adjust_gl_date,
2069 arp_standard.profile.user_id,
2070 sysdate,
2071 arp_standard.profile.user_id,
2072 sysdate,
2073 arp_standard.profile.last_update_login,
2074 TRUE,
2075 l_crh_id_out);
2076
2077 IF PG_DEBUG in ('Y', 'C') THEN
2078 arp_standard.debug('arp_process_rct_util.rate_adjust()-');
2079 END IF;
2080
2081 EXCEPTION
2082 WHEN OTHERS THEN
2083 IF PG_DEBUG in ('Y', 'C') THEN
2084 arp_standard.debug('Exception in arp_process_rct_util.rate_adjust');
2085 END IF;
2086 RAISE;
2087
2088 END rate_adjust;
2089
2090
2091 /*===========================================================================+
2092 | PROCEDURE |
2093 | get_ccids |
2094 | |
2095 | DESCRIPTION |
2096 | determines the ccid's a given remittance bank account and |
2097 | payment method combination. |
2098 | |
2099 | SCOPE - PRIVATE |
2100 | |
2101 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED |
2102 | |
2103 | ARGUMENTS |
2104 | IN: |
2105 | OUT: |
2106 | |
2107 | RETURNS |
2108 | |
2109 | NOTES |
2110 | |
2111 | MODIFICATION HISTORY |
2112 | |
2113 | 29-AUG-95 OSTEINME created |
2114 | |
2115 | 04-NOV-96 OSTEINME changed name from get_ra_ccid to get_ccids |
2116 | and added parameters to allow procedure to |
2117 | return all ccid's for the IN parameters |
2118 | 07-JAN-98 DJANCIS selected code combination id's for earned |
2119 | and unearnd ccids from |
2120 | ar_receivables_trx instead of |
2121 | ar_receipt_method_accounts for |
2122 | 11.5 VAT changes |
2123 | |
2124 +===========================================================================*/
2125
2126 PROCEDURE get_ccids(
2127 p_receipt_method_id IN NUMBER,
2128 p_remittance_bank_account_id IN NUMBER,
2129 p_unidentified_ccid OUT NOCOPY NUMBER,
2130 p_unapplied_ccid OUT NOCOPY NUMBER,
2131 p_on_account_ccid OUT NOCOPY NUMBER,
2132 p_earned_ccid OUT NOCOPY NUMBER,
2133 p_unearned_ccid OUT NOCOPY NUMBER,
2134 p_bank_charges_ccid OUT NOCOPY NUMBER,
2135 p_factor_ccid OUT NOCOPY NUMBER,
2136 p_confirmation_ccid OUT NOCOPY NUMBER,
2137 p_remittance_ccid OUT NOCOPY NUMBER,
2138 p_cash_ccid OUT NOCOPY NUMBER
2139 ) IS
2140 BEGIN
2141
2142 /* selected code combination id's for earned and unearnd ccids from
2143 ar_receivables_trx instead of ar_receipt_method_accounts for
2144 11.5 VAT changes */
2145
2146 SELECT
2147 rma.unidentified_ccid,
2148 rma.unapplied_ccid,
2149 rma.on_account_ccid,
2150 ed.code_combination_id, /* earned_ccid */
2151 uned.code_combination_id, /* unearned_ccid */
2152 rma.bank_charges_ccid,
2153 rma.factor_ccid,
2154 rma.receipt_clearing_ccid,
2155 rma.remittance_ccid,
2156 rma.cash_ccid
2157 INTO
2158 p_unidentified_ccid,
2159 p_unapplied_ccid,
2160 p_on_account_ccid,
2161 p_earned_ccid,
2162 p_unearned_ccid,
2163 p_bank_charges_ccid,
2164 p_factor_ccid,
2165 p_confirmation_ccid,
2166 p_remittance_ccid,
2167 p_cash_ccid
2168 FROM
2169 AR_RECEIPT_METHOD_ACCOUNTS rma,
2170 AR_RECEIVABLES_TRX ed,
2171 AR_RECEIVABLES_TRX uned
2172 WHERE remit_bank_acct_use_id = p_remittance_bank_account_id
2173 AND receipt_method_id = p_receipt_method_id
2174 AND rma.edisc_receivables_trx_id = ed.receivables_trx_id (+)
2175 AND rma.unedisc_receivables_trx_id = uned.receivables_trx_id (+);
2176
2177 EXCEPTION
2178 WHEN OTHERS THEN
2179 IF PG_DEBUG in ('Y', 'C') THEN
2180 arp_standard.debug('EXCEPTION: arp_process_receipts.get_ccids');
2181 END IF;
2182 RAISE;
2183
2184 END get_ccids;
2185
2186 /*===========================================================================+
2187 | PROCEDURE |
2188 | get_ps_rec |
2189 | |
2190 | DESCRIPTION |
2191 | gets the payment schedule record of a receipt given a cash_receipt_id |
2192 | |
2193 | SCOPE - PRIVATE |
2194 | |
2195 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED |
2196 | |
2197 | ARGUMENTS |
2198 | IN: |
2199 | OUT: |
2200 | |
2201 | RETURNS |
2202 | |
2203 | NOTES |
2204 | |
2205 | MODIFICATION HISTORY |
2206 | |
2207 | 19-NOV-96 OSTEINME created |
2208 +===========================================================================*/
2209
2210 PROCEDURE get_ps_rec( p_cash_receipt_id IN NUMBER,
2211 p_ps_rec OUT NOCOPY ar_payment_schedules%ROWTYPE) IS
2212
2213 l_ps_id NUMBER;
2214
2215 BEGIN
2216
2217 SELECT payment_schedule_id
2218 INTO l_ps_id
2219 FROM ar_payment_schedules
2220 WHERE cash_receipt_id = p_cash_receipt_id;
2221
2222 -- the following should utimately be done with nowaitlock_fetch_p (but
2223 -- it didn't exist yet when this function was written and tested).
2224
2225 arp_ps_pkg.fetch_p( l_ps_id,
2226 p_ps_rec);
2227
2228 END get_ps_rec;
2229
2230 /*===========================================================================+
2231 | PROCEDURE |
2232 | update_dist_rec |
2233 | |
2234 | DESCRIPTION |
2235 | updates a record in AR_DISTRIBUTIONS table |
2236 | |
2237 | SCOPE - PRIVATE |
2238 | |
2239 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED |
2240 | |
2241 | ARGUMENTS |
2242 | IN: |
2243 | OUT: |
2244 | |
2245 | RETURNS |
2246 | |
2247 | NOTES |
2248 | |
2249 | MODIFICATION HISTORY |
2250 | |
2251 | 19-NOV-96 OSTEINME created |
2252 +===========================================================================*/
2253
2254 PROCEDURE update_dist_rec( p_crh_id IN NUMBER,
2255 p_source_type IN ar_distributions.source_type%TYPE,
2256 p_amount IN NUMBER,
2257 p_acctd_amount IN NUMBER) IS
2258
2259 l_dist_rec AR_DISTRIBUTIONS%ROWTYPE;
2260 l_amount number;
2261 l_acctd_amount number;
2262 BEGIN
2263
2264 -- fetch existing distributions record for update:
2265
2266 arp_distributions_pkg.nowaitlock_fetch_pk(
2267 p_crh_id,
2268 'CRH',
2269 p_source_type,
2270 l_dist_rec);
2271
2272 /* Commented the following code for bug 2311742
2273 IF (p_amount < 0) THEN
2274 l_dist_rec.amount_dr := NULL;
2275 l_dist_rec.amount_cr := - p_amount;
2276 ELSE
2277 l_dist_rec.amount_dr := p_amount;
2278 l_dist_rec.amount_cr := NULL;
2279 END IF;
2280
2281 IF (p_acctd_amount < 0) THEN
2282 l_dist_rec.acctd_amount_dr := NULL;
2283 l_dist_rec.acctd_amount_cr := - p_acctd_amount;
2284 ELSE
2285 l_dist_rec.acctd_amount_dr := p_acctd_amount;
2286 l_dist_rec.acctd_amount_cr := NULL;
2287 END IF; */
2288
2289 /* Added the following code for bug 2311742 */
2290
2291 IF (l_dist_rec.amount_dr is not null) THEN
2292 l_amount := l_dist_rec.amount_dr + p_amount;
2293
2294 If (l_amount > 0) then
2295 l_dist_rec.amount_dr := l_amount;
2296 l_dist_rec.amount_cr := null;
2297 else
2298 l_dist_rec.amount_cr := - l_amount;
2299 l_dist_rec.amount_dr := null;
2300 End if;
2301 ELSE
2302 l_amount := l_dist_rec.amount_cr - p_amount;
2303
2304 If ( l_amount >= 0) then
2305 l_dist_rec.amount_dr := null;
2306 l_dist_rec.amount_cr := l_amount;
2307 Else
2308 l_dist_rec.amount_dr := - l_amount;
2309 l_dist_rec.amount_cr := null;
2310 End if;
2311 END IF;
2312
2313 IF (l_dist_rec.acctd_amount_dr is not null) THEN
2314 l_acctd_amount := l_dist_rec.acctd_amount_dr + p_acctd_amount;
2315
2316 If (l_acctd_amount > 0) then
2317 l_dist_rec.acctd_amount_dr := l_acctd_amount;
2318 l_dist_rec.acctd_amount_cr := null;
2319 Else
2320 l_dist_rec.acctd_amount_cr := - l_acctd_amount;
2321 l_dist_rec.acctd_amount_dr := null;
2322 End if;
2323
2324 ELSE
2325 l_acctd_amount := l_dist_rec.acctd_amount_cr - p_acctd_amount;
2326
2327 If (l_acctd_amount >= 0) then
2328 l_dist_rec.acctd_amount_dr := null;
2329 l_dist_rec.acctd_amount_cr := l_acctd_amount;
2330 Else
2331 l_dist_rec.acctd_amount_dr := - l_acctd_amount;
2332 l_dist_rec.acctd_amount_cr := null;
2333 End if;
2334 END IF;
2335 /* End of bug 2311742 */
2336
2337 arp_distributions_pkg.update_p(l_dist_rec);
2338
2339 /* need to update records into the MRC table. Calling new
2340 mrc engine */
2341 /*4301323
2342 ar_mrc_engine2.maintain_mrc_data2(
2343 p_event_mode => 'UPDATE',
2344 p_table_name => 'AR_DISTRIBUTIONS',
2345 p_mode => 'SINGLE',
2346 p_key_value => l_dist_rec.line_id,
2347 p_row_info => l_dist_rec);
2348 */
2349 END update_dist_rec;
2350 END ARP_PROC_RCT_UTIL;