[Home] [Help]
PACKAGE BODY: APPS.ARP_PROCESS_DEBIT_MEMO
Source
1 PACKAGE BODY ARP_PROCESS_DEBIT_MEMO AS
2 /* $Header: ARTEDBMB.pls 115.3 2002/11/18 22:34:37 anukumar ship $ */
3
4 /*===========================================================================+
5 | PROCEDURE |
6 | line_post_insert |
7 | |
8 | DESCRIPTION |
9 | Line post-insert logic for debit memo reversals. |
10 | |
11 | This procedure creates two distribution records that correspond to the |
12 | two sets of ccid / amount pairs that are passed in as parameters. |
13 | |
14 | SCOPE - PUBLIC |
15 | |
16 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
17 | arp_util.debug |
18 | |
19 | ARGUMENTS : IN: |
20 | p_customer_trx_line_id |
21 | p_ccid1 |
22 | p_ccid2 |
23 | p_amount1 |
24 | p_amount2 |
25 | OUT: |
26 | RETURNS : NONE |
27 | |
28 | NOTES |
29 | |
30 | MODIFICATION HISTORY |
31 | 06-AUG-95 Charlie Tomberg Created |
32 | 19-OCT-01 Muthuraman. R Bugfix 2061395. Ora 1476 divide by zero|
33 | occurs when receipt amount is zero. |
34 | This was because of percentage |
35 | calculation using zero. Handled in code|
36 | now so that it becomes 100 if Amt is 0.|
37 | |
38 +===========================================================================*/
39
40 PROCEDURE line_post_insert (
41 p_customer_trx_line_id IN
42 ra_customer_trx_lines.customer_trx_line_id%type,
43 p_ccid1 IN
44 gl_code_combinations.code_combination_id%type,
45 p_ccid2 IN
46 gl_code_combinations.code_combination_id%type,
47 p_amount1 IN
48 ra_cust_trx_line_gl_dist.amount%type,
49 p_amount2 IN
50 ra_cust_trx_line_gl_dist.amount%type )
51 IS
52
53 l_dist_rec ra_cust_trx_line_gl_dist%rowtype;
54 l_cust_trx_line_gl_dist_id
55 ra_cust_trx_line_gl_dist.cust_trx_line_gl_dist_id%type;
56 l_customer_trx_id ra_customer_trx.customer_trx_id%type;
57 l_gl_date ra_cust_trx_line_gl_dist.gl_date%type;
58 l_extended_amount ra_customer_trx_lines.extended_amount%type;
59 l_exchange_rate ra_customer_trx.exchange_rate%type;
60
61 BEGIN
62
63 arp_util.debug('arp_process_debit_memo.line_post_insert()+');
64
65
66 /*----------------------------------------+
67 | Get information about the debit memo |
68 +----------------------------------------*/
69
70 SELECT ct.customer_trx_id,
71 ct.exchange_rate,
72 lgd.gl_date,
73 ctl.extended_amount
74 INTO l_customer_trx_id,
75 l_exchange_rate,
76 l_gl_date,
77 l_extended_amount
78 FROM ra_customer_trx ct,
79 ra_cust_trx_line_gl_dist lgd,
80 ra_customer_trx_lines ctl
81 WHERE ctl.customer_trx_line_id = p_customer_trx_line_id
82 AND ctl.customer_trx_id = ct.customer_trx_id
83 AND ctl.customer_trx_id = lgd.customer_trx_id
84 AND lgd.account_class = 'REC'
85 AND lgd.latest_rec_flag = 'Y';
86
87
88 arp_util.debug('l_customer_trx_id = ' || l_customer_trx_id );
89 arp_util.debug('l_exchange_rate = ' || l_exchange_rate );
90 arp_util.debug('l_gl_date = ' || l_gl_date );
91 arp_util.debug('l_extended_amount = ' || l_extended_amount );
92 arp_util.debug('p_amount1 = ' || p_amount1);
93 arp_util.debug('p_amount2 = ' || p_amount2);
94 arp_util.debug('p_ccid1 = ' || p_ccid1);
95 arp_util.debug('p_ccid2 = ' || p_ccid2);
96
97 /*-----------------------------------------------+
98 | Validate the parameters and make sure that |
99 | the amounts add up to the extended amount. |
100 +-----------------------------------------------*/
101
102 IF (
103 p_customer_trx_line_id IS NULL OR
104 p_ccid1 IS NULL OR
105 p_amount1 IS NULL OR
106 p_amount1 + p_amount2 <> l_extended_amount
107 )
108 THEN
109 arp_util.debug('invalid parameters specified for line_post_insert()');
110 fnd_message.set_name('AR', 'AR_INV_ARGS');
111 fnd_message.set_token('USER_EXIT',
112 'arp_process_debit_memo.line_post_insert()');
113 app_exception.raise_exception;
114 END IF;
115
116
117 /*-------------------------------------+
118 | Populate the distributions record |
119 +-------------------------------------*/
120
121 l_dist_rec.customer_trx_line_id := p_customer_trx_line_id;
122 l_dist_rec.customer_trx_id := l_customer_trx_id;
123 l_dist_rec.posting_control_id := -3;
124 l_dist_rec.gl_date := l_gl_date;
125 l_dist_rec.account_class := 'REV';
126 l_dist_rec.account_set_flag := 'N';
127
128 l_dist_rec.code_combination_id := p_ccid1;
129 l_dist_rec.amount := p_amount1;
130
131 /* Bugfix 2061395. Added the following IF clause */
132 IF l_extended_amount <> 0 THEN
133 l_dist_rec.percent := ROUND(
134 ( p_amount1 * 100 ) /
135 l_extended_amount,
136 4
137 );
138 ELSE
139 l_dist_rec.percent := 100;
140 END IF;
141
142 /*----------------------------------+
143 | Insert distribution number one |
144 +----------------------------------*/
145
146 arp_ctlgd_pkg.insert_p(
147 l_dist_rec,
148 l_cust_trx_line_gl_dist_id,
149 l_exchange_rate,
150 arp_trx_global.system_info.base_currency,
151 arp_trx_global.system_info.base_precision,
152 arp_trx_global.system_info.base_min_acc_unit
153 );
154
155
156 arp_util.debug('ctlid for dist one: ' || l_cust_trx_line_gl_dist_id );
157
158 IF (p_ccid2 IS NOT NULL AND
159 p_amount2 IS NOT NULL) THEN
160
161 l_dist_rec.code_combination_id := p_ccid2;
162 l_dist_rec.amount := p_amount2;
163 l_dist_rec.percent := ROUND(
164 ( p_amount2 * 100 ) /
165 l_extended_amount,
166 4
167 );
168
169 /*----------------------------------+
170 | Insert distribution number two |
171 +----------------------------------*/
172
173 arp_ctlgd_pkg.insert_p(
174 l_dist_rec,
175 l_cust_trx_line_gl_dist_id,
176 l_exchange_rate,
177 arp_trx_global.system_info.base_currency,
178 arp_trx_global.system_info.base_precision,
179 arp_trx_global.system_info.base_min_acc_unit
180 );
181
182 arp_util.debug('ctlid for dist two: ' || l_cust_trx_line_gl_dist_id );
183
184 ELSE
185
186 arp_util.debug('p_ccid2 or p_amount2 NULL');
187 arp_util.debug('--> No 2nd distribution record needed');
188
189 END IF;
190
191 arp_util.debug('arp_process_debit_memo.line_post_insert()-');
192
193 EXCEPTION
194 WHEN OTHERS THEN
195 arp_util.debug('EXCEPTION: arp_process_debit_memo.line_post_insert()');
196
197 arp_util.debug('---------- ' ||
198 'Parameters for arp_process_debit_memo.line_post_insert() ' ||
199 '---------- ');
200
201 arp_util.debug('p_customer_trx_line_id = ' || p_customer_trx_line_id );
202 arp_util.debug('p_ccid1 = ' || p_ccid1 );
203 arp_util.debug('p_ccid2 = ' || p_ccid2 );
204 arp_util.debug('p_amount1 = ' || p_amount1 );
205 arp_util.debug('p_amount2 = ' || p_amount2 );
206
207 RAISE;
208
209 END;
210
211
212 END ARP_PROCESS_DEBIT_MEMO;