DBA Data[Home] [Help]

PACKAGE BODY: APPS.JAI_RCV_EXCISE_PROCESSING_PKG

Source


1 PACKAGE BODY jai_rcv_excise_processing_pkg AS
2 /* $Header: jai_rcv_exc_prc.plb 120.22.12010000.4 2009/01/19 12:52:24 vumaasha ship $ */
3 
4 /* --------------------------------------------------------------------------------------
5 Filename:
6 
7 Change History:
8 
9 Date         Bug         Remarks
10 ---------    ----------  -------------------------------------------------------------
11 08-Jun-2005  Version 116.2 jai_rcv_exc_prc -Object is Modified to refer to New DB Entity names in place of Old DB Entity Names
12 		as required for CASE COMPLAINCE.
13 
14 13-Jun-2005  4428980     File Version: 116.3
15                          Ramananda for bug#4428980. Removal of SQL LITERALs is done
16 
17 27-Jul-2005  4516667     Added by Lakshmi Gopalsami Version 120.2
18                          (1) Removed CVD from additional amount. This is
19 			     accidentally added to additional excise. This is
20 			     done in PROCEDURE rg23_d_entry.
21                          (2) Rounded p_rate_per_unit to 4 decimal places in
22  			     jai_cmn_rg_23d_trxs_pkg.insert_row
23 
24 27-Jul-2005  4516678     Added by Lakshmi Gopalsami Version 120.3
25                          Issue :
26                           a.Whenever a user creates a receipt for a CGIN or
27 			    CGEX item, 50% cenvat is claimed. If he/she intends to
28 			    return the entire quantity in the receipt, he/she must
29 			    claim the remaining 50% cenvat first and then do the
30 			    RTV. Else, the system should throw an error.
31 
32                           b.After creating a receipt for a CGIN or CGEX item,
33 			    if the user does a partial RTV on that receipt,
34 			    the system should allow it although the remaining
35 			    50% CENVAT has not been claimed.
36 
37 			 Fix   :
38                           a. Added code to check this in Package jai_rcv_tax_pkg
39 			  (1) Created new procedure pick_register_type to get the
40 			  register_type depending on the item_class
41 			  (2)Created two new cursors  c_fetch_receive_quantity
42 			  and c_fetch_transaction_Quantity to get the
43 			  quantity received for the receipt and RTV transactions
44 			  (3) Added  nvl(cenvat_amount,0) in
45 			  cursor c_fetch_unclaim_cenvat
46 
47 			  Dependencies(Functional)
48 			  ------------------------
49 			  jai_rcv_tax.plb Version 120.2
50 
51                           b. The cenvat receivable accounts were not getting passed
52 			     in case of a CGIN/CGEX item.
53 			     Thus, the system is throwing an error.
54 			     Commented the generic assignment for cenvat
55 			     accounting entries and added the condition for
56 			     CGIN and CGEX item class in procedure
57 			     accounting_entries.
58 
59 
60 02-May-06    5176133   Added by rallamse version 120.4
61                        Issue : Object not getting compiled
62                        Fix:
63                        Modified the multi-line statement :
64                        r_diff_tax.basic_excise  := r_rtv_dtls.excise_basis_amt
65                        to a single line statement
66 17-Jul-2006  5378630 Aiyer, File Version 120.6
67                       Issue:-
68                         India Receiving transaction processor fails during validation phase for RMA
69                         type of transactions.
70 
71                       Fix:-
72                        During DFF elimination one elsif statment in the procedure validate_transaction got missed out
73                        due to which for RMA TYPE of either "PRODUCTION INPUT" or "GOODS RETURN" the code used to fail.
74                        To restrict this added back the if condition to check that the failure should happen only for PO receipt with FGIN or FGEX type
75                        of item class. The new IF condition now checks for source_document_type in PO or REQUISITION
76                        Also converted the reference of RMA TYPE "FG RETURN" into "GOODS RETURN" as FG return is not as per the abbreviation
77                        standard
78 
79 14-feb-2007  4704957,5841749  vkaranam,File version 120.11
80                               4704957-Forward porting the changes in 11i bug 4683156(return to vendor report shows 50% cenvat amount for partial rtv)
81                               5841749-Forward porting the changes in 11i bug 5647216(doing rtv for partial quantity, after claiming 50%, is giving error)
82 
83 
84 22-Feb-2007 5155138 srjayara, file version 120.12
85 			Forward port for 11i bug 5110511
86 			Issue: No accounting should be passed for Excise and Cess in case of RMA receipt for a Trading
87 			       organization.
88 			Fix: When call to accounting_entries is made for Trading organization a check is added so that
89 			     the call is made only if the attribute category is not India RMA Receipt.
90 16-APR-2007   Bug 5989740 Vkaranam for bug 5989740, File version 120.13
91               Forward porting the changes in 115 bug 5907436(Enh:Handling Secondary And Higher Education Cess)
92 
93 
94 17 14-may-07   kunkumar made changes for Budget and ST by IO and Build issues resolved	.
95 
96 04-Jun-2007  ssawant for bug#6084771,File Version 120.18
97                 Issue: UNABLE TO CLAIM CENVAT
98                   Fix: Added reference_id while jai_rcv_accounting_pkg.process_transaction to avoid
99                        the Duplicate accounting error.
100 
101 08-Jun-2007  CSahoo for bug#6078460, File Version 120.20
102 						 Issue:Excise Expense entry is getting generated for Excise and Education cess but
103 									 not for the SHE cess. The accounting entrty needs to be generated for the
104 									 same.
105 						 Fix: Added code for SH Education Cess Acccounting Entries in the procedure rtv_processing_for_ssi.
106 
107 9-Nov-2008  Bug 5752026 (FP for bug 5747435) File version 120.25
108              Issue : Total duty amount includes addl. CVD for the invoices flown from receipts.
109                      This is not consistent with what we have for manual entries.
110              Fix   : Excluded the addl. CVD when calculating the total duty amount in procedure
111                      rg23_d_entry.
112 --------------------------------------------------------------------------------------*/
113 
114   FUNCTION get_apportioned_tax(
115     pr_tax      IN  TAX_BREAKUP,
116     p_factor    IN  NUMBER,
117     p_claim_type IN VARCHAR2     -- Date 30/10/2006 Bug 5228046 added by SACSETHI
118   ) RETURN TAX_BREAKUP IS
119 
120     r_tax   TAX_BREAKUP;
121     ln_factor     NUMBER;
122     lv_object_name CONSTANT VARCHAR2 (61) := 'jai_rcv_excise_processing_pkg.get_apportioned_tax';
123 
124   BEGIN
125 
126     if p_factor IS NULL or p_factor = 0 then
127       ln_factor := 1;
128     else
129       ln_factor := p_factor;
130     end if;
131 
132     r_tax.basic_excise     := pr_tax.basic_excise     * ln_factor;
133     r_tax.addl_excise      := pr_tax.addl_excise      * ln_factor;
134     r_tax.other_excise     := pr_tax.other_excise     * ln_factor;
135     r_tax.cvd              := pr_tax.cvd              * ln_factor;
136     r_tax.non_cenvat       := pr_tax.non_cenvat       * ln_factor;
137     r_tax.excise_edu_cess  := pr_tax.excise_edu_cess  * ln_factor;
138     r_tax.cvd_edu_cess     := pr_tax.cvd_edu_cess     * ln_factor;
139      /*added the following by vkaranam for budget 07 impact - bug#5989740*/
140     --start
141     r_tax.sh_exc_edu_cess  := pr_tax.sh_exc_edu_cess  * ln_factor;
142     r_tax.sh_cvd_edu_cess  := pr_tax.sh_cvd_edu_cess  * ln_factor;
143     --end
144 
145 
146      -- Date 30/10/2006 Bug 5228046 added by sacsethi
147     IF p_claim_type ='2ND CLAIM' THEN
148        r_tax.addl_cvd       := 0;
149     ELSE
150        r_tax.addl_cvd       := pr_tax.addl_cvd;
151     END IF;
152     RETURN r_tax;
153 
154   EXCEPTION
155     WHEN OTHERS THEN
156     FND_MESSAGE.SET_NAME ('JA','JAI_EXCEPTION_OCCURED');
157     FND_MESSAGE.SET_TOKEN ('JAI_PROCESS_MSG',lv_object_name ||'.Err:'||sqlerrm);
158     app_exception.raise_exception;
159   END get_apportioned_tax;
160 
161 
162   -- Start, following procedures added by Vijay Shankar for Bug#3940588. RECEIPTS DEPLUG
163   PROCEDURE get_changed_vendor_dtls(
164     p_receive_trx_id      IN  NUMBER,
165     p_shipment_line_id    IN  NUMBER,
166     p_vendor_id OUT NOCOPY NUMBER,
167     p_vendor_site_id OUT NOCOPY NUMBER
168   ) IS
169 
170     CURSOR c_receipt_cenvat_dtl(cp_transaction_id IN NUMBER) IS
171       SELECT vendor_changed_flag, vendor_id, vendor_site_id
172       FROM JAI_RCV_CENVAT_CLAIMS
173       WHERE transaction_id = cp_transaction_id;
174 
175     r_receipt_cenvat_dtl  c_receipt_cenvat_dtl%ROWTYPE;
176     lv_object_name CONSTANT VARCHAR2 (61) := 'jai_rcv_excise_processing_pkg.get_changed_vendor_dtls';
177 
178   BEGIN
179 
180     OPEN c_receipt_cenvat_dtl(p_receive_trx_id);
181     FETCH c_receipt_cenvat_dtl INTO r_receipt_cenvat_dtl;
182     CLOSE c_receipt_cenvat_dtl;
183 
184     IF r_receipt_cenvat_dtl.vendor_changed_flag = 'Y' THEN
185       p_vendor_id       := r_receipt_cenvat_dtl.vendor_id;
186       p_vendor_site_id  := r_receipt_cenvat_dtl.vendor_site_id;
187     END IF;
188   EXCEPTION
189     WHEN OTHERS THEN
190     p_vendor_id := null;
191     p_vendor_site_id := null;
192     FND_MESSAGE.SET_NAME ('JA','JAI_EXCEPTION_OCCURED');
193     FND_MESSAGE.SET_TOKEN ('JAI_PROCESS_MSG',lv_object_name ||'.Err:'||sqlerrm);
194     app_exception.raise_exception;
195   END get_changed_vendor_dtls;
196 
197   /* Procedure Created by Vijay Shankar for Bug#3940588. RECEIPTS DEPLUG
198      POST PROCESSOR of CENVAT */
199   PROCEDURE post_cenvat_processor(
200     p_transaction_id            IN  NUMBER,
201     p_cenvat_claimed_ptg        IN  NUMBER,
202     p_cenvat_claimed_amt        IN  NUMBER,
203     p_other_cenvat_claimed_amt  IN  NUMBER
204   ) IS
205 
206     r_trx                         c_trx%ROWTYPE;
207     lv_transaction_type           JAI_RCV_TRANSACTIONS.transaction_type%TYPE;
208 
209     ln_trx_qty_for_2nd_claim      NUMBER;
210     ln_trx_equivalent_of_receive  NUMBER;
211     lv_object_name CONSTANT VARCHAR2 (61) := 'jai_rcv_excise_processing_pkg.post_cenvat_processor';
212 
213   BEGIN
214 
215     OPEN c_trx(p_transaction_id);
216     FETCH c_trx INTO r_trx;
217     CLOSE c_trx;
218 
219     IF r_trx.transaction_type = 'CORRECT' THEN
220       lv_transaction_type := r_trx.parent_transaction_type;
221     ELSE
222       lv_transaction_type := r_trx.transaction_type;
223     END IF;
224 
225     -- update the quantity for 2nd claim only during the first claim of transaction line and that too only for CG Items only
226     IF p_cenvat_claimed_ptg = 50 AND r_trx.item_class IN ('CGIN','CGEX') THEN
227 
228       IF lv_transaction_type IN ('DELIVER','RETURN TO RECEIVING','RETURN TO VENDOR') THEN
229         ln_trx_equivalent_of_receive := jai_rcv_trx_processing_pkg.get_equivalent_qty_of_receive(r_trx.transaction_id);
230       ELSE
231         ln_trx_equivalent_of_receive := r_trx.quantity;
232       END IF;
233 
234       IF lv_transaction_type IN ('RECEIVE', 'MATCH')
235         -- non bonded RTR case i.e goods are returned to receiving from non bonded subinventory
236         or (lv_transaction_type = 'RETURN TO RECEIVING' and nvl(r_trx.loc_subinv_type, 'X') = 'N')
237       THEN
238         -- only during 1st Claim the quantity should be updated
239         ln_trx_qty_for_2nd_claim  := ln_trx_equivalent_of_receive;
240 
241       ELSIF lv_transaction_type = 'RETURN TO VENDOR'
242         -- non bonded delivery case. i.e goods are delivered to non bonded subinventory
243         or (lv_transaction_type = 'DELIVER' and nvl(r_trx.loc_subinv_type, 'X') = 'N')
244       THEN
245         ln_trx_qty_for_2nd_claim  := -1 * ln_trx_equivalent_of_receive;
246 
247       ELSE
248         ln_trx_qty_for_2nd_claim := 0;
249       END IF;
250 
251     ELSE
252       ln_trx_qty_for_2nd_claim := 0;
253     END IF;
254 
255     /* Start, Vijay Shankar for Bug#3940588 */
256     IF r_trx.transaction_type IN ('RECEIVE', 'MATCH') THEN
257       UPDATE JAI_RCV_CENVAT_CLAIMS
258       SET cenvat_claimed_ptg = p_cenvat_claimed_ptg,
259           cenvat_sequence = nvl(cenvat_sequence, 0) + 1,
260           cenvat_claimed_amt = nvl(cenvat_claimed_amt, 0) + p_cenvat_claimed_amt,
261           other_cenvat_claimed_amt = nvl(other_cenvat_claimed_amt,0) + p_other_cenvat_claimed_amt,
262           quantity_for_2nd_claim = nvl(quantity_for_2nd_claim,0) + nvl(ln_trx_qty_for_2nd_claim, 0),
263           last_update_date = sysdate,
264           last_updated_by = fnd_global.user_id,
265           last_update_login = fnd_global.login_id
266       WHERE transaction_id = p_transaction_id;
267 
268       -- this is to set the flag that is shown in JAINPORE, which signifies that the cenvat is claimed or not
269       update JAI_RCV_LINES
270       set claim_modvat_flag = 'Y',
271           last_update_date = sysdate,
272           last_updated_by = fnd_global.user_id,
273           last_update_login = fnd_global.login_id
274       where transaction_id = p_transaction_id;
275 
276     ELSE
277 
278       UPDATE JAI_RCV_CENVAT_CLAIMS
279       SET quantity_for_2nd_claim = nvl(quantity_for_2nd_claim,0) + ln_trx_qty_for_2nd_claim,
280           last_update_date = sysdate,
281           last_updated_by = fnd_global.user_id,
282           last_update_login = fnd_global.login_id
283       WHERE transaction_id = r_trx.tax_transaction_id;
284 
285     END IF;
286     /* End, Vijay Shankar for Bug#3940588 */
287   EXCEPTION
288     WHEN OTHERS THEN
289     FND_MESSAGE.SET_NAME ('JA','JAI_EXCEPTION_OCCURED');
290     FND_MESSAGE.SET_TOKEN ('JAI_PROCESS_MSG',lv_object_name ||'.Err:'||sqlerrm);
291     app_exception.raise_exception;
292   END post_cenvat_processor;
293 
294   /* Start of bug 5365346. Created by Lakshmi Gopalsami */
295   PROCEDURE  update_RTV_Diff_value
296             (pr_base_trx            IN jai_rcv_excise_processing_pkg.c_base_trx%ROWTYPE,
297 	     pr_tax                 IN jai_rcv_excise_processing_pkg.c_trx%ROWTYPE,
298   	     pr_diff_tax            IN TAX_BREAKUP,
299 	     p_source_reg           IN VARCHAR2 ,
300 	     p_register_entry_type  IN VARCHAR2 ,
301              p_register_id          IN OUT NOCOPY NUMBER,
302 	     p_simulate_flag        IN  VARCHAR2,
303 	     p_codepath             IN OUT NOCOPY VARCHAR2,
304 	     p_process_status       OUT NOCOPY VARCHAR2,
305 	     p_process_message      OUT NOCOPY VARCHAR2
306 	    ) IS
307 
308     ln_tr_amount       NUMBER ;
309     ln_opening_balance NUMBER ;
310     ln_closing_balance NUMBER ;
311     ln_dr_basic        NUMBER ;
312     ln_dr_addl         NUMBER ;
313     ln_dr_other        NUMBER ;
314     ln_other_tax_debit NUMBER ;
315     ln_cr_basic        NUMBER ;
316     ln_cr_addl         NUMBER ;
317     ln_cr_other        NUMBER ;
318     ln_other_tax_credit  NUMBER ;
319     ln_transaction_id   NUMBER(10);
320     lv_transaction_type VARCHAR2(50);
321     ln_register_id      NUMBER ;
322     lv_remarks          JAI_CMN_RG_PLA_TRXS.REMARKS%TYPE;
323     lv_statement_id     VARCHAR2(5);
324     lv_process_status   VARCHAR2(2);
325     lv_process_message  VARCHAR2(2000);
326     lv_register_type    JAI_CMN_RG_23AC_II_TRXS.register_type%TYPE;
327     ln_reg_dr           NUMBER ;
328     ln_reg_cr           NUMBER ;
329     lv_upd_opening_bal_dr NUMBER ;
330     lv_upd_opening_bal_cr NUMBER ;
331     ln_ex_cess_diff     NUMBER ;
332     ln_cvd_cess_diff    NUMBER ;
333     ln_ex_sh_cess_diff     NUMBER ;
334     ln_cvd_sh_cess_diff    NUMBER ;
335 
336 
337   BEGIN
338 
339    p_codepath := jai_general_pkg.plot_codepath(1, p_codepath,
340    'jai_rcv_excise_processing_pkg.update_RTV_Diff_value', 'START');
341 
342 
343    lv_statement_id := '1';
344    p_codepath := jai_general_pkg.plot_codepath(1, p_codepath);
345 
346    fnd_file.put_line(FND_FILE.LOG, ' Inside Update RTV Diff value ->statement id '
347                                     || lv_statement_id);
348    fnd_file.put_line(FND_FILE.LOG, ' source register ' || p_source_reg);
349    /* If source register is PLA */
350    IF p_source_reg = 'PLA' THEN
351       IF pr_tax.transaction_type = 'CORRECT' THEN
352         lv_transaction_type := pr_tax.parent_transaction_type;
353       ELSE
354         lv_transaction_type := pr_tax.transaction_type;
355       END IF;
356       lv_statement_id := '2';
357       p_codepath := jai_general_pkg.plot_codepath(2, p_codepath);
358       fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
359       jai_cmn_rg_pla_trxs_pkg.get_trxn_type_and_id(lv_transaction_type,
360                            pr_base_trx.source_document_code,
361 			   ln_transaction_id);
362       lv_statement_id := '3';
363       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath);
364       FOR c_get_register_id IN
365            (SELECT register_id ,
366 	           cr_basic_ed,
367 		   cr_additional_ed,
368 		   cr_other_ed,
369 		   dr_basic_ed,
370 		   dr_additional_ed,
371 		   dr_other_ed,
372 		   other_tax_credit,
373 		   other_tax_debit,
374 		   remarks
375             FROM jai_cmn_rg_pla_trxs
376 	    WHERE organization_id = pr_tax.organization_id
377 	      AND location_id = pr_tax.location_id
378 	      AND inventory_item_id = pr_tax.inventory_item_id
379 	      AND ref_document_id = pr_tax.transaction_id
380 	      AND transaction_source_num = ln_transaction_id
381 	    )
382       LOOP
383         lv_statement_id := '4';
384 	p_codepath := jai_general_pkg.plot_codepath(4, p_codepath);
385         fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
386         ln_register_id := c_get_register_id.register_id;
387 	ln_dr_basic    := c_get_register_id.dr_basic_ed;
388 	ln_dr_addl     := c_get_register_id.dr_additional_ed;
389 	ln_dr_other    := c_get_register_id.dr_other_ed;
390 	ln_other_tax_debit := c_get_register_id.other_tax_debit;
391 	ln_cr_basic    := c_get_register_id.cr_basic_ed;
392 	ln_cr_addl     := c_get_register_id.cr_additional_ed;
393 	ln_cr_other    := c_get_register_id.cr_other_ed;
394 	ln_other_tax_credit := c_get_register_id.other_tax_credit;
395 	lv_remarks     := c_get_register_id.remarks || 'RTV ADjustment';
396 	fnd_file.put_line(FND_FILE.LOG, ' RTV Adjustment values --> ');
397 	fnd_file.put_line(FND_FILE.LOG, ' Register id ' || ln_register_id);
398 	fnd_file.put_line(FND_FILE.LOG, 'CR: Basic--Addl--Other--cess'||
399                          ln_cr_basic||'--'||ln_cr_addl||'--'||
400 			 ln_cr_other||'--'||ln_other_tax_credit);
401 	fnd_file.put_line(FND_FILE.LOG, 'DR: Basic--Addl--Other--cess'||
402                          ln_dr_basic||'--'||ln_dr_addl||'--'||
403 			 ln_dr_other||'--'||ln_other_tax_debit);
404       END LOOP ;
405 
406       lv_statement_id := '5';
407       p_codepath := jai_general_pkg.plot_codepath(5, p_codepath);
408       fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
409 
410       lv_statement_id := '6';
411       p_codepath := jai_general_pkg.plot_codepath(6, p_codepath);
412       fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
413 
414       lv_statement_id := '7';
415       p_codepath := jai_general_pkg.plot_codepath(7, p_codepath);
416       fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
417       /* Set the value of credit and debit basic, additional and other */
418 
419       IF p_register_entry_type = CENVAT_DEBIT THEN
420          lv_statement_id := '8';
421 	 p_codepath := jai_general_pkg.plot_codepath(8, p_codepath);
422          lv_upd_opening_bal_dr := ln_dr_basic + ln_dr_addl + ln_dr_other;
423          ln_dr_basic   := ln_dr_basic+ pr_diff_tax.basic_excise;
424          ln_dr_addl    := ln_dr_addl + pr_diff_tax.addl_excise + pr_diff_tax.cvd;
425          ln_dr_other   := ln_dr_other + pr_diff_tax.other_excise;
426          ln_other_tax_debit  := ln_other_tax_debit +
427 	                        pr_diff_tax.excise_edu_cess +
428 				pr_diff_tax.cvd_edu_cess + nvl(pr_diff_tax.sh_exc_edu_cess,0) +
429 				 nvl(pr_diff_tax.sh_cvd_edu_cess,0); --Bgowrava for Bug#6071509, added SH related cess
430 	 ln_reg_dr     := nvl(pr_diff_tax.basic_excise,0) +
431                           nvl(pr_diff_tax.addl_excise,0)+ nvl(pr_diff_tax.cvd,0) +
432 			  nvl(pr_diff_tax.other_excise,0);
433          fnd_file.put_line(FND_FILE.LOG, ' Reg. dr' || ln_reg_dr);
434       ELSE
435          lv_statement_id := '10';
436          lv_upd_opening_bal_cr := ln_cr_basic + ln_cr_addl + ln_cr_other;
437          fnd_file.put_line(FND_FILE.LOG, ' Reg. open cr' || lv_upd_opening_bal_cr);
438          ln_cr_basic   := ln_cr_basic + pr_diff_tax.basic_excise;
439          ln_cr_addl    := ln_cr_addl + pr_diff_tax.addl_excise + pr_diff_tax.cvd;
440          ln_cr_other   := ln_cr_other + pr_diff_tax.other_excise;
441          ln_other_tax_credit  := ln_other_tax_credit +
442 	                         pr_diff_tax.excise_edu_cess +
443 				 pr_diff_tax.cvd_edu_cess + nvl(pr_diff_tax.sh_exc_edu_cess,0) +
444 				 nvl(pr_diff_tax.sh_cvd_edu_cess,0); --Bgowrava for Bug#6071509, added SH related cess
445 	 ln_reg_cr     := nvl(pr_diff_tax.basic_excise,0) +
446                           nvl(pr_diff_tax.addl_excise,0)+ nvl(pr_diff_tax.cvd,0) +
447 			  nvl(pr_diff_tax.other_excise,0);
448          fnd_file.put_line(FND_FILE.LOG, ' Reg. cr' || ln_reg_cr);
449       END IF;
450 
451       /* Calculate the transaction amount difference to be updated */
452 
453       ln_tr_amount :=  nvl(ln_reg_cr,0) - nvl(ln_reg_dr,0);
454 
455       fnd_file.put_line(FND_FILE.LOG, ' Trx amt ' || ln_tr_amount);
456 
457             /*  Get the balance details */
458       jai_cmn_rg_balances_pkg.get_balance(
459          P_ORGANIZATION_ID   => pr_tax.organization_id,
460          P_LOCATION_ID       => pr_tax.location_id,
461          P_REGISTER_TYPE     => 'PLA',
462          P_OPENING_BALANCE   => ln_opening_balance,
463          P_PROCESS_STATUS    => lv_process_status,
464          P_PROCESS_MESSAGE   => lv_process_message
465        );
466       lv_statement_id := '9';
467       p_codepath := jai_general_pkg.plot_codepath(9, p_codepath);
468       fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
469       ln_closing_balance := ln_opening_balance + ln_tr_amount;
470       ln_opening_balance := ln_opening_balance - (nvl(lv_upd_opening_bal_cr,0) - nvl(lv_upd_opening_bal_dr,0));
471 
472       fnd_file.put_line(FND_FILE.LOG, 'Opening balance to be updated ' || ln_opening_balance);
473 
474       lv_statement_id := '10';
475       p_codepath := jai_general_pkg.plot_codepath(10, p_codepath);
476       fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
477 
478       /* Update PLA with the latest difference amount to the existing amount */
479       JAI_CMN_RG_PLA_TRXS_PKG.update_row(
480          P_REGISTER_ID         => ln_register_id,
481 	 P_CR_BASIC_ED         => ln_cr_basic,
482 	 P_CR_ADDITIONAL_ED    => ln_cr_addl,
483 	 P_CR_OTHER_ED         => ln_cr_other,
484 	 P_DR_BASIC_ED         => ln_dr_basic,
485 	 P_DR_ADDITIONAL_ED    => ln_dr_addl,
486 	 P_DR_OTHER_ED         => ln_dr_other,
487 	 P_REMARKS             => lv_remarks,
488 	 P_OPENING_BALANCE     => ln_opening_balance,
489 	 P_CLOSING_BALANCE     => ln_closing_balance,
490 	 P_OTHER_TAX_CREDIT    => ln_other_tax_credit,
491 	 P_OTHER_TAX_DEBIT     => ln_other_tax_debit
492          );
493       lv_statement_id := '11';
494       p_codepath := jai_general_pkg.plot_codepath(11, p_codepath);
495       fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
496       /* Update the balances with the latest amount*/
497 
498       jai_cmn_rg_balances_pkg.update_row(
499         p_organization_id   => pr_tax.organization_id,
500         p_location_id       => pr_tax.location_id,
501         p_register_type     => 'PLA',
502 	p_amount_to_be_added=> ln_tr_amount,
503 	p_simulate_flag     => p_simulate_flag,
504 	p_process_status    => lv_process_status,
505 	p_process_message   => lv_process_message
506      );
507      p_register_id := ln_register_id;
508    /* If source register is RG23 part II */
509    ELSE
510       lv_register_type := jai_general_pkg.get_rg_register_type(pr_tax.item_class);
511       IF pr_tax.transaction_type = 'CORRECT' THEN
512         lv_transaction_type := pr_tax.parent_transaction_type;
513       ELSE
514         lv_transaction_type := pr_tax.transaction_type;
515       END IF;
516       lv_statement_id := '2';
517       p_codepath := jai_general_pkg.plot_codepath(2, p_codepath);
518       fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
519       jai_cmn_rg_23ac_ii_pkg.get_trxn_type_and_id(lv_transaction_type,
520                            pr_base_trx.source_document_code,
521 			   ln_transaction_id);
522       lv_statement_id := '3';
523       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath);
524       FOR c_get_register_id IN
525            (SELECT register_id ,
526 	           cr_basic_ed,
527 		   cr_additional_ed,
528 		   cr_other_ed,
529 		   dr_basic_ed,
530 		   dr_additional_ed,
531 		   dr_other_ed,
532 		   other_tax_credit,
533 		   other_tax_debit,
534 		   remarks
535             FROM JAI_CMN_RG_23AC_II_TRXS
536 	    WHERE organization_id = pr_tax.organization_id
537 	      AND location_id = pr_tax.location_id
538 	      AND inventory_item_id = pr_tax.inventory_item_id
539 	      AND receipt_ref = pr_tax.transaction_id
540 	      AND transaction_source_num = ln_transaction_id
541 	    )
542       LOOP
543         lv_statement_id := '4';
544         fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
545         ln_register_id := c_get_register_id.register_id;
546 	ln_dr_basic    := c_get_register_id.dr_basic_ed;
547 	ln_dr_addl     := c_get_register_id.dr_additional_ed;
548 	ln_dr_other    := c_get_register_id.dr_other_ed;
549 	ln_other_tax_debit := c_get_register_id.other_tax_debit;
550 	ln_cr_basic    := c_get_register_id.cr_basic_ed;
551 	ln_cr_addl     := c_get_register_id.cr_additional_ed;
552 	ln_cr_other    := c_get_register_id.cr_other_ed;
553 	ln_other_tax_credit := c_get_register_id.other_tax_credit;
554 	lv_remarks     := c_get_register_id.remarks || 'RTV ADjustment';
555 	fnd_file.put_line(FND_FILE.LOG, ' RTV Adjustment values --> ');
556 	fnd_file.put_line(FND_FILE.LOG, ' Register id ' || ln_register_id);
557 	fnd_file.put_line(FND_FILE.LOG, 'CR: Basic--Addl--Other--cess'||
558                          ln_cr_basic||'--'||ln_cr_addl||'--'||
559 			 ln_cr_other||'--'||ln_other_tax_credit);
560 	fnd_file.put_line(FND_FILE.LOG, 'DR: Basic--Addl--Other--cess'||
561                          ln_dr_basic||'--'||ln_dr_addl||'--'||
562 			 ln_dr_other||'--'||ln_other_tax_debit);
563       END LOOP ;
564 
565       lv_statement_id := '5';
566       p_codepath := jai_general_pkg.plot_codepath(5, p_codepath);
567       fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
568 
569 
570       lv_statement_id := '6';
571       p_codepath := jai_general_pkg.plot_codepath(6, p_codepath);
572       fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
573       /* Set the value of credit and debit basic, additional and other */
574       IF p_register_entry_type = CENVAT_DEBIT THEN
575          lv_statement_id := '7';
576          lv_upd_opening_bal_dr := ln_dr_basic + ln_dr_addl + ln_dr_other;
577          ln_dr_basic   := ln_dr_basic+ pr_diff_tax.basic_excise;
578          ln_dr_addl    := ln_dr_addl + pr_diff_tax.addl_excise + pr_diff_tax.cvd;
579          ln_dr_other   := ln_dr_other + pr_diff_tax.other_excise;
580          ln_other_tax_debit  := ln_other_tax_debit +
581 	                        pr_diff_tax.excise_edu_cess +
582 				pr_diff_tax.cvd_edu_cess + nvl(pr_diff_tax.sh_exc_edu_cess,0) +
583 				 nvl(pr_diff_tax.sh_cvd_edu_cess,0); --Bgowrava for Bug#6071509, added SH related cess
584 	 ln_reg_dr     := nvl(pr_diff_tax.basic_excise,0) +
585                           nvl(pr_diff_tax.addl_excise,0)+ nvl(pr_diff_tax.cvd,0) +
586 			  nvl(pr_diff_tax.other_excise,0);
587       ELSE
588          lv_statement_id := '8';
589 	 p_codepath := jai_general_pkg.plot_codepath(8, p_codepath);
590 	 lv_upd_opening_bal_cr := ln_cr_basic + ln_cr_addl + ln_cr_other;
591          ln_cr_basic   := ln_cr_basic + pr_diff_tax.basic_excise;
592          ln_cr_addl    := ln_cr_addl + pr_diff_tax.addl_excise + pr_diff_tax.cvd;
593          ln_cr_other   := ln_cr_other + pr_diff_tax.other_excise;
594          ln_other_tax_credit  := ln_other_tax_credit +
595 	                         pr_diff_tax.excise_edu_cess +
596 				 pr_diff_tax.cvd_edu_cess+ nvl(pr_diff_tax.sh_exc_edu_cess,0) +
597 				 nvl(pr_diff_tax.sh_cvd_edu_cess,0); --Bgowrava for Bug#6071509, added SH related cess
598 	 ln_reg_cr     := nvl(pr_diff_tax.basic_excise,0) +
599                           nvl(pr_diff_tax.addl_excise,0)+ nvl(pr_diff_tax.cvd,0) +
600 			  nvl(pr_diff_tax.other_excise,0);
601       END IF;
602 
603        /* Calculate the transaction amount difference to be updated */
604 
605       ln_tr_amount :=  nvl(ln_reg_cr,0) - nvl(ln_reg_dr,0);
606 
607       lv_statement_id := '9';
608       p_codepath := jai_general_pkg.plot_codepath(9, p_codepath);
609       fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
610 
611       /*  Get the balance details */
612       jai_cmn_rg_balances_pkg.get_balance(
613          P_ORGANIZATION_ID   => pr_tax.organization_id,
614          P_LOCATION_ID       => pr_tax.location_id,
615          P_REGISTER_TYPE     => lv_register_type,
616          P_OPENING_BALANCE   => ln_opening_balance,
617          P_PROCESS_STATUS    => lv_process_status,
618          P_PROCESS_MESSAGE   => lv_process_message
619        );
620       lv_statement_id := '10';
621       p_codepath := jai_general_pkg.plot_codepath(10, p_codepath);
622       fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
623       ln_closing_balance := ln_opening_balance + ln_tr_amount;
624       ln_opening_balance := ln_opening_balance - (nvl(lv_upd_opening_bal_cr,0) - nvl(lv_upd_opening_bal_dr,0));
625       fnd_file.put_line(FND_FILE.LOG, 'Opening balance to be updated ' || ln_opening_balance);
626 
627       lv_statement_id := '11';
628       p_codepath := jai_general_pkg.plot_codepath(11, p_codepath);
629       fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
630 
631       /* Update RG 23 Part II with the latest difference amount to the existing amount */
632       jai_cmn_rg_23ac_ii_pkg.update_row(
633          P_REGISTER_ID         => ln_register_id,
634 	 P_CR_BASIC_ED         => ln_cr_basic,
635 	 P_CR_ADDITIONAL_ED    => ln_cr_addl,
636 	 P_CR_OTHER_ED         => ln_cr_other,
637 	 P_DR_BASIC_ED         => ln_dr_basic,
638 	 P_DR_ADDITIONAL_ED    => ln_dr_addl,
639 	 P_DR_OTHER_ED         => ln_dr_other,
640 	 P_REMARKS             => lv_remarks,
641 	 P_OPENING_BALANCE     => ln_opening_balance,
642 	 P_CLOSING_BALANCE     => ln_closing_balance,
643 	 P_OTHER_TAX_CREDIT    => ln_other_tax_credit,
644 	 P_OTHER_TAX_DEBIT     => ln_other_tax_debit,
645 	 p_simulate_flag     => p_simulate_flag,
646 	 p_process_status    => lv_process_status,
647 	 p_process_message   => lv_process_message
648          );
649       lv_statement_id := '12';
650       p_codepath := jai_general_pkg.plot_codepath(12, p_codepath);
651       fnd_file.put_line(FND_FILE.LOG, ' Value of statement id ' || lv_statement_id);
652       /* Update the balances with the latest amount*/
653 
654       jai_cmn_rg_balances_pkg.update_row(
655         p_organization_id   => pr_tax.organization_id,
656         p_location_id       => pr_tax.location_id,
657         p_register_type     => lv_register_type,
658 	p_amount_to_be_added=> ln_tr_amount,
659 	p_simulate_flag     => p_simulate_flag,
660 	p_process_status    => lv_process_status,
661 	p_process_message   => lv_process_message
662      );
663      p_register_id := ln_register_id;
664    END IF ;
665 
666    /* Update CESS balances */
667    IF pr_diff_tax.excise_edu_cess <> 0 THEN
668       IF p_register_entry_type = CENVAT_DEBIT THEN
669         ln_other_tax_debit  := pr_diff_tax.excise_edu_cess;
670       ELSE
671         ln_other_tax_credit := pr_diff_tax.excise_edu_cess;
672       END IF;
673 
674       ln_ex_cess_diff := nvl(ln_other_tax_credit,0) -
675                          nvl(ln_other_tax_debit,0);
676 
677       UPDATE  JAI_CMN_RG_OTHERS
678          SET  credit = credit + ln_other_tax_credit,
679               debit  = debit + ln_other_tax_debit,
680   	      opening_balance = opening_balance,
681 	      closing_balance = closing_balance + ln_ex_cess_diff
682        WHERE  source_register = decode(p_source_reg,'PLA', jai_constants.reg_pla,
683                                   decode(lv_register_type,
684 				         jai_constants.register_type_a,
685 					 jai_constants.reg_rg23a_2,
686 					 jai_constants.reg_rg23c_2
687 					)
688 				   )
689         AND  source_register_id = p_register_id
690         AND  tax_type = jai_constants.tax_type_exc_edu_cess;
691    END IF; /* Excise cess*/
692 
693    p_codepath := jai_general_pkg.plot_codepath(7, p_codepath);
694 
695    IF pr_diff_tax.cvd_edu_cess <> 0 THEN
696      IF p_register_entry_type = CENVAT_DEBIT THEN
697         ln_other_tax_debit  := pr_diff_tax.cvd_edu_cess;
698      ELSE
699         ln_other_tax_credit := pr_diff_tax.cvd_edu_cess;
700      END IF;
701 
702      ln_cvd_cess_diff := nvl(ln_other_tax_credit,0) -
703                         nvl(ln_other_tax_debit,0);
704 
705      UPDATE  JAI_CMN_RG_OTHERS
706         SET  credit = credit + ln_other_tax_credit,
707              debit  = debit + ln_other_tax_debit,
708 	     opening_balance = opening_balance,
709 	     closing_balance = closing_balance + ln_cvd_cess_diff
710       WHERE  source_register = decode(p_source_reg,'PLA', jai_constants.reg_pla,
711                                   decode(lv_register_type,
712 				         jai_constants.register_type_a,
713 					 jai_constants.reg_rg23a_2,
714 					 jai_constants.reg_rg23c_2
715 					)
716 				   )
717         AND  source_register_id = p_register_id
718         AND  tax_type = jai_constants.tax_type_cvd_edu_cess;
719     END IF; /* CVD Cess */
720 
721     --For Excise SH Edu cess
722     IF pr_diff_tax.sh_exc_edu_cess <> 0 THEN
723 		      IF p_register_entry_type = CENVAT_DEBIT THEN
724 		        ln_other_tax_debit  := pr_diff_tax.sh_exc_edu_cess;
725 		      ELSE
726 		        ln_other_tax_credit := pr_diff_tax.sh_exc_edu_cess;
727 		      END IF;
728 
729 		      ln_ex_sh_cess_diff := nvl(ln_other_tax_credit,0) -
730 		                         nvl(ln_other_tax_debit,0);
731 
732 		      UPDATE  JAI_CMN_RG_OTHERS
733 		         SET  credit = credit + ln_other_tax_credit,
734 		              debit  = debit + ln_other_tax_debit,
735 		  	      opening_balance = opening_balance,
736 			      closing_balance = closing_balance + ln_ex_sh_cess_diff
737 		       WHERE  source_register = decode(p_source_reg,'PLA', jai_constants.reg_pla,
738 		                                  decode(lv_register_type,
739 						         jai_constants.register_type_a,
740 							 jai_constants.reg_rg23a_2,
741 							 jai_constants.reg_rg23c_2
742 							)
743 						   )
744 		        AND  source_register_id = p_register_id
745 		        AND  tax_type = jai_constants.tax_type_sh_exc_edu_cess;
746    END IF; /* Excise SH cess*/
747 
748    --For CVD SH cess
749    IF pr_diff_tax.sh_cvd_edu_cess <> 0 THEN
750 	      IF p_register_entry_type = CENVAT_DEBIT THEN
751 	         ln_other_tax_debit  := pr_diff_tax.sh_cvd_edu_cess;
752 	      ELSE
753 	         ln_other_tax_credit := pr_diff_tax.sh_cvd_edu_cess;
754 	      END IF;
755 
756 	      ln_cvd_sh_cess_diff := nvl(ln_other_tax_credit,0) -
757 	                         nvl(ln_other_tax_debit,0);
758 
759 	      UPDATE  JAI_CMN_RG_OTHERS
760 	         SET  credit = credit + ln_other_tax_credit,
761 	              debit  = debit + ln_other_tax_debit,
762 	 	     opening_balance = opening_balance,
763 	 	     closing_balance = closing_balance + ln_cvd_sh_cess_diff
764 	       WHERE  source_register = decode(p_source_reg,'PLA', jai_constants.reg_pla,
765 	                                   decode(lv_register_type,
766 	 				         jai_constants.register_type_a,
767 	 					 jai_constants.reg_rg23a_2,
768 	 					 jai_constants.reg_rg23c_2
769 	 					)
770 	 				   )
771 	         AND  source_register_id = p_register_id
772 	         AND  tax_type = jai_constants.tax_type_sh_cvd_edu_cess;
773     END IF; /* CVD SH Cess */
774 
775   EXCEPTION
776     WHEN OTHERS THEN
777       lv_process_status := 'E';
778       lv_process_message := 'EXC_PRC_PKG.update_RTV_Diff_value'||SQLERRM
779                             ||', StmtId->'||lv_statement_id;
780       FND_FILE.put_line( FND_FILE.log, 'Error in '||lv_process_message);
781       p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END');
782   END update_RTV_Diff_value;
783 
784   -- End for bug 5365346
785 
786   PROCEDURE do_cenvat_rounding(
787     p_transaction_id  IN NUMBER,
788     pr_tax            IN OUT NOCOPY TAX_BREAKUP,
789     p_codepath        IN OUT NOCOPY VARCHAR2
790   ) IS
791 
792     ln_total_cenvat         NUMBER;
793     ln_total_cenvat_rounded NUMBER;
794     ln_rounded_amt          NUMBER;
795 
796     lv_object_name CONSTANT VARCHAR2 (61) := 'jai_rcv_excise_processing_pkg.do_cenvat_rounding';
797   BEGIN
798 
799     FND_FILE.put_line(FND_FILE.log, '^CENVAT_RG_PKG.do_cenvat_rounding. Basic->'||pr_tax.basic_excise
800       ||', Additional->'||pr_tax.addl_excise
801       ||', Other->'|| pr_tax.other_excise||', CVD->'|| pr_tax.cvd
802     ||', Add CVD -> '|| pr_tax.addl_CVD
803     -- Date 30/10/2006 Bug 5228046 added by sacsethi
804     );
805 
806     p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'cenvat_rg_pkg.do_cenvat_rounding', 'START');
807 
808     ln_total_cenvat         := pr_tax.basic_excise +
809                                pr_tax.addl_excise +
810 			       pr_tax.other_excise +
811 			       pr_tax.cvd +
812   			       pr_tax.addl_cvd ; -- Date 30/10/2006 Bug 5228046 added by sacsethi
813 
814 
815     ln_total_cenvat_rounded := round(ln_total_cenvat, gn_cenvat_rnd);
816     ln_rounded_amt          := ln_total_cenvat - ln_total_cenvat_rounded;
817 
818     IF ln_rounded_amt <> 0 THEN
819 
820       p_codepath := jai_general_pkg.plot_codepath(2, p_codepath);
821 
822       IF pr_tax.cvd <> 0 THEN
823          pr_tax.cvd :=  pr_tax.cvd - ln_rounded_amt;
824       ELSIF pr_tax.other_excise <> 0 THEN
825          pr_tax.other_excise :=  pr_tax.other_excise - ln_rounded_amt;
826       ELSIF pr_tax.addl_excise <> 0 THEN
827         pr_tax.addl_excise := pr_tax.addl_excise - ln_rounded_amt;
828       -- Date 30/10/2006 Bug 5228046 added by sacsethi
829       -- START BUG 5228046
830       ELSIF pr_tax.addl_cvd <> 0 THEN
831         pr_tax.addl_cvd := pr_tax.addl_cvd - ln_rounded_amt;
832       -- END BUG 5228046
833       ELSE
834         pr_tax.basic_excise := pr_tax.basic_excise - ln_rounded_amt;
835       END IF;
836 
837       FND_FILE.put_line(FND_FILE.log, 'Rounded Amts. Basic->'||pr_tax.basic_excise||
838                                       ',Additional->'||pr_tax.addl_excise||
839 				      ', Other->'|| pr_tax.other_excise||
840 				      ', CVD->'|| pr_tax.cvd ||
841 				    ', Addl CVD-> ' || pr_tax.addl_cvd     -- Date 30/10/2006 Bug 5228046 added by sacsethi
842       );
843 
844     END IF;
845 
846     p_codepath := jai_general_pkg.plot_codepath(3, p_codepath, null, 'END');
847   EXCEPTION
848     WHEN OTHERS THEN
849     pr_tax := null;
850     FND_MESSAGE.SET_NAME ('JA','JAI_EXCEPTION_OCCURED');
851     FND_MESSAGE.SET_TOKEN ('JAI_PROCESS_MSG',lv_object_name ||'.Err:'||sqlerrm);
852     app_exception.raise_exception;
853   END do_cenvat_rounding;
854 
855   PROCEDURE process_transaction(
856     p_transaction_id            IN        NUMBER,
857     p_cenvat_claimed_ptg        IN OUT NOCOPY VARCHAR2,
858     p_process_status OUT NOCOPY VARCHAR2,
859     p_process_message OUT NOCOPY VARCHAR2,
860     p_simulate_flag             IN        VARCHAR2,
861     p_codepath                  IN OUT NOCOPY VARCHAR2,
862     -- following parameters introduced for second claim of receive transaction
863     -- Vijay shankar for Bug#3940588. RECEIPTS DEPLUG
864     p_process_special_reason    IN        VARCHAR2    DEFAULT NULL,
865     p_process_special_qty       IN        NUMBER      DEFAULT NULL
866   ) IS
867 
868     lv_procedure_name             VARCHAR2(60); --File.Sql.35 Cbabu  := 'CENVAT_RG_PKG.process_transaction';
869 
870     r_trx                         c_trx%ROWTYPE;
871     r_base_trx                    c_base_trx%ROWTYPE;
872     r_orgn_info                   c_orgn_info%ROWTYPE;
873     lv_transaction_type           RCV_TRANSACTIONS.transaction_type%TYPE;
874     ln_trx_type_code              NUMBER(5);
875 
876     -- For RTV case
877     ln_receive_trx_id             JAI_RCV_TRANSACTIONS.transaction_type%TYPE;
878     ln_receive_basic              NUMBER;
879     ln_receive_addl               NUMBER;
880     ln_receive_other              NUMBER;
881     ln_receive_cvd                NUMBER;
882     ln_receipt_addl_cvd           NUMBER;     -- Date 30/10/2006 Bug 5228046 added by sacsethi
883     ln_receive_non_cenvat         NUMBER;
884     lv_receive_part_ii_type       VARCHAR2(10);
885     ln_receive_part_ii_reg_id     NUMBER;
886     ln_receive_charge_accnt       NUMBER;
887 
888     lv_cenvat_accounting_type     VARCHAR2(10);
889     lv_register_entry_type        VARCHAR2(10);
890     lv_cgin_code                  VARCHAR2(100);
891 
892     lv_reference_num              JAI_CMN_RG_23AC_II_TRXS.reference_num%TYPE;
893 
894     -- amount related variables
895     ln_curr_conv_rate             NUMBER;
896     ln_excise_amount              NUMBER;
897 
898     /* Vijay Shankar for Bug#3940588 */
899     r_half_tax                    TAX_BREAKUP;/*uncommented by vkaranam for bug 4704957*/
900     r_tax                         TAX_BREAKUP;
901 
902 
903     ln_amount_factor              NUMBER;   --File.Sql.35 Cbabu  := 1;
904     ln_apportion_factor           NUMBER;
905 
906     ln_charge_account_id          NUMBER;
907     lv_part_i_register            VARCHAR2(20);
908     ln_part_i_register_id         NUMBER;
909     lv_part_ii_register           VARCHAR2(20);
910     ln_part_ii_register_id        NUMBER;
911     lv_register_type              VARCHAR(1);
912 
913     lv_excise_invoice_no          JAI_RCV_TRANSACTIONS.excise_invoice_no%TYPE;
914     ld_excise_invoice_date        JAI_RCV_TRANSACTIONS.excise_invoice_date%TYPE;
915     lv_tax_breakup_type           VARCHAR2(20);
916     lb_process_iso                BOOLEAN;
917 
918     lv_message                    VARCHAR2(500);
919     lv_err_message                VARCHAR2(500);
920     lv_statement_id               VARCHAR2(5);
921     lv_temp                       VARCHAR2(50);
922 
923     lv_cenvat_register_type       VARCHAR2(30);
924     lv_edu_cess_register_type     VARCHAR2(30);
925     r_cenvat                      TAX_BREAKUP;
926     r_edu_cess                    TAX_BREAKUP;
927 
928     /*bgowrava for forward porting Bug#5756676 START*/
929 
930     CURSOR cur_rg1_register_id
931 		  IS
932 		  SELECT register_id
933 		    FROM JAI_CMN_RG_I_TRXS
934 		   WHERE TRANSACTION_SOURCE_NUM = 18
935 		     AND register_id    > 0 /*This check excludes master org records*/
936 		     AND ref_doc_no     = p_transaction_id;
937 
938 		  CURSOR cur_rg23_1_register_id
939 		  IS
940 		  SELECT register_id
941 		    FROM JAI_CMN_RG_23AC_I_TRXS
942 		   WHERE TRANSACTION_SOURCE_NUM = 18
943 		     AND register_id    > 0 /*This check excludes master org records*/
944      AND RECEIPT_REF     = p_transaction_id;
945 /*bgowrava for forward porting Bug#5756676 END*/
946 
947 
948     /* Bug 6800251. Added by Lakshmi Gopalsami
949      * Fetched the total amount of RTV of the receipt
950      * for which we are claiming the 2nd 50%.
951      * This cursor will be fetched only in case of 2nd 50% claim
952      */
953     CURSOR C_Get_Total_RTV (cp_shipment_header_id IN NUMBER,
954                             cp_shipment_line_id IN NUMBER
955                            ) IS
956     SELECT SUM(nvl(quantity,0))
957       FROM jai_rcv_transactions jrt
958      WHERE
959        -- jrt.transaction_id > p_transaction_id AND
960        jrt.transaction_type = 'RETURN TO VENDOR'
961        AND jrt.shipment_header_id = cp_shipment_header_id
962        AND jrt.shipment_line_id = cp_shipment_line_id;
963 
964     ln_RTV_qty NUMBER;
965     ln_special_qty NUMBER;
966 
967   BEGIN
968 
969   /*----------------------------------------------------------------------------------------------------------------------------
970   CHANGE HISTORY for FILENAME: jai_rcv_excise_processing_pkg.sql
971   S.No  dd/mm/yyyy   Author and Details
972   ------------------------------------------------------------------------------------------------------------------------------
973   1     26/07/2004   Vijay Shankar for Bug# 3496408, Version:115.0
974                       This Package is coded for Corrections Enhancement to invoke CENVAT and RG related insert APIs for PO Functionality.
975 
976             - PROCESS_TRANSACTION
977                This is the driving procedure that calls different internal API's which further calls CENVAT and RG APIs for data insertion
978             - VALIDATE_TRANSACTION
979                Validates whether CENVAT and RG entries needs to be passed for receipt transaction.
980                Returns a value based on which the main procedure either proceeds or returns with a error message
981             - DERIVE_CGIN_SCENARIO
982                Returns a CGIN Scenario Code based on which Accounting and RG entry APIs are invoked
983                valid values:  (1) 'REGULAR-FULL + REVERSAL-HALF' (2) 'REGULAR-HALF'
984                               (3) 'REGULAR-FULL'                 (4) 'REGULAR-FULL + PARENT-REGULAR-HALF'
985             - RG_I_ENTRY
986                Has the RG1 Entry related data fetching logic. Invokes API to pass an RG1 Entry
987             - RG23_PART_I_ENTRY
988                Has the RG23 Part1 Entry related data fetching logic. Invokes API to pass RG23(A or C) Entry for quantity
989             - RG23_D_ENTRY
990                Has the RG23D Entry related data fetching logic. Invokes API to pass an RG23D Entry
991             - RG23_PART_II_ENTRY
992                Has the RG23 Part2 Entry related data fetching logic. Invokes API to pass RG23(A or C) Entry for Amount
993             - PLA_ENTRY
994                Has data fetching logic related to PLA Entry. Invokes API to pass a PLA Entry
995             - ACCOUNTING_ENTRIES
996                Determines the accounts that needs to be hit based on input params. Call Receipt Accounting API to pass accounting entries
997             - GENERATE_EXCISE_INVOICE
998                Invoices excise invoice no generation API and returns a value to caller
999             Other Procedure and Functions are used for the processing of the transaction purpose
1000 
1001   2     26/10/2004   Vijay Shankar for Bug# 3927371, Version:115.1
1002                       IF Condition for Trading related transaction processing is corrected, which is previously wrong in PROCESS_TRANSACTION procedure
1003 
1004   3     03/01/2005   Vijay Shankar for Bug# 3940588, Version:115.2, 115.3
1005                       Following are the changes done as part of RECEIPTS DEPLUG and Education Cess Enhancement
1006                       - Added a RECORD Definition for tax breakup as TAX_BREAUP and modified to use this as a parameter in all the calls
1007                       that passes cenvat accounting and register entries. this change is made from an extensible perspective of breakup
1008                       - added the following procedures
1009                         - get_vendor_changed_dtls   : Retuns the changed excise vendor details as OUT Parameters
1010                         - post_cenvat_processor     : Updates JAI_RCV_CENVAT_CLAIMS, JAI_RCV_LINES tables with claim details
1011                         - other_cenvat_rg_recording : Inserts a record into JAI_CMN_RG_OTHERS table with the parameters passed to the call
1012                       - added the parameters p_process_special_reason and qty in PROCESS_TRANSACTION. These are used incase the accounting
1013                       and rg entries should consider these values for TAX_BREAUP instead of main transaction values.
1014                       These parameters are mainly added for RECEIPTS DEPLUG to support second Claim functionality of CGIN items
1015                       - COMMENTED the code related to AUTO Claim of 2nd 50% of RECEIVE transaction to the tune of RETURN TO VENDOR
1016                       that is being processed. this redundant as the 2nd 50% claim of RECEIVE will happen only to the tune of remaining
1017                       quantity of RECEIVE after RTV. Previous functionality is that, it claims whole of RECEIVE quantity for 2nd 50% also
1018                       Incase of CGIN items, CGIN_CODE returned from derive_cgin_code for RTV previously is 'REGULAR-FULL + PARENT-REGULAR-HALF'
1019                       and now it returns 'REGULAR-FULL + REVERSAL-HALF' incase the parent RECEIVE is only 50% claimed
1020                       - Call to get_vendor_changed_dtls is added in all RG Entries related procedures like rg23_part_i_entry etc. this
1021                       is used to insert RG Entries with a different Vendor other than excise if the user indicated the same through
1022                       Claim Cenvat Screen of India Localization
1023                       - Modified all RG Entries related procedures to make calls to other_cenvat_rg_recording incase EXCISE or CVD
1024                       EDUCATION_CESS are attached to receipt lines. the call inturn makes relevant CESS entries into RG tables
1025                       - Modified ACCOUTING_ENTRIES procedure to pass accounting for CESS Amounts to relevant CESS accounts of
1026                       Organization Additional information. this passes different accounting entries for EXCISE and CVD EUDCATION_CESS
1027                       incase they have different accounts defined in Organization Addl. Info Setup
1028                       - Modified get_tax_amount_breakup to break the amount for EXCISE_EDUCATION_CESS and CVD_EDUCATION_CESS also
1029 
1030   4.   16/02/2005 - bug#4187859  - File Version - 115.4
1031                    Even when RTV did not have cess, Validation to cess was done and an error was thrown to the uset that cess amount is
1032                    zero. This has been stopped by adding code not to call the ja_in_rg_others_pkg.insert_row procedure only if
1033                    the cess amount is not zero.
1034 
1035                    Dependency due to this bug:-
1036                     None
1037 
1038   5.   16/03/2005 - Vijay Shankar for Bug#4211045  - File Version - 115.5
1039                      Incase of RMA Accounting for CESS, we are hitting Cr. Excise Receivable A/C  and Dr. Cess RM A/C for Cess Amount.
1040                      this set of accounting for cess is wrong, instead it should be Cr. Cess Paid Payable Account and Dr. Cess RM A/C for Cess Amount
1041                      to fix this, changes are made in accounting_entries procedure and a call to jai_rcv_accounting_pkg.process_transaction
1042                      is made to pass an extra entry as Cr. Cess Paid Payable Accnt for Cess amt
1043 
1044   6.   15/04/2005    Sanjikum for Bug #4293421, File Version 116.0(115.7)
1045 
1046                      Problem
1047                      -------
1048                      During Cenvat Claim, while Inserting the Record into JAI_CMN_RG_23AC_II_TRXS, the Transaction date is inserted as Transaction Date of
1049                      the JAI_RCV_TRANSACTIONS.transaction_date. It should be the date on which claim is being made.
1050 
1051                      Fix
1052                      ---
1053                      In the Procedure rg23_part_ii_entry, while calling jai_cmn_rg_23ac_ii_pkg.insert_row, value of the parameter
1054                      p_transaction_date is changed to SYSDATE from r_trx.transaction_date
1055 
1056   7.   19/04/2005   Vijay Shankar for Bug #4103161, File Version 116.1(115.8)
1057                      Rounding of RTV Excise amounts to nearest rupee is removed as it will be done separately through RG Rounding
1058                      Concurrrent program
1059 
1060                    * Dependancy for later versions of this object *
1061 
1062   8   10/05/2005   Vijay Shankar for Bug#4346453. Version: 116.2
1063                    Code is modified due to the Impact of Receiving Transactions DFF Elimination
1064                    added a procedure rtv_processing_for_ssi that will be invoked for SSI processing
1065                 * High Dependancy for future Versions of this object *
1066 
1067 
1068  9   10-may-2007  bgowrava for forward porting Bug#5756676, 11i bug#5747013. File Version 120.15
1069 	                  Issue : QTY REGISTER SHOULD BE UPDATED ON RECEIVE DEPENDING ON SETUP
1070 	                    Fix : Changes are made to check if the Qty register is already hit. If it is then
1071 	                          the Qty register is updated with the amounts. Otherwise call to api is made
1072 	                          to insert into Qty register
1073 
1074 	                  Dependancy due to this bug : Yes
1075 
1076 10   10-may-2007  bgowrava for forward porting Bug#5756676, 11i bug#5747013. File Version 120.15
1077 	                  Issue : QTY REGISTER SHOULD BE UPDATED ON RECEIVE DEPENDING ON SETUP
1078 	                    Fix : The excise_invoice_no and excise_invoice_date should also be updated in Qty registers
1079                           in case of deferred claim also. So modified the update statement to update these columns also
1080 
1081 11.   04/06/2007  sacsethi for bug 6109941  file version #120.18
1082 
1083                   CODE REVIEW COMMENTS FOR ENHANCEMENTS
1084 
1085 		  Problem found for forward porting for Enhancement Additional cvd ( 5228046)  and budget 2007  ( 5989740)
1086 
1087 
1088   Dependancy:
1089   -----------
1090   IN60105D2 + 3496408
1091   IN60106   + 3940588 + 4146708/4239736 + 4103161 + 4346453
1092 
1093   /* IMPORTANT NOTE:
1094     For Receiving Transactions: In case of CGIN Claim a value needs to be passed for JAI_CMN_RG_23AC_II_TRXS.REFERENCE_NUM column
1095       that will be used for Duplicate Checking.
1096       Incase of RECEIVE transaction value passed for 1st 50% Claim is '1st Claim'. During 2nd 50% Claim '2nd Claim' is passed
1097       If 2nd Claim is happening from RTV transaction then TRANSACTION_ID of RECEIVE is passed as the value towards REFERENCE_NUM
1098       In all Other transactions value passed for REFERENCE_NUM column is NULL
1099 
1100 
1101   ----------------------------------------------------------------------------------------------------------------------------*/
1102 
1103     lv_procedure_name    := 'CENVAT_RG_PKG.process_transaction';
1104     ln_amount_factor     := 1;
1105 
1106     -- this is to identify the path in SQL TRACE file if any problem occured
1107     SELECT 'jai_rcv_excise_processing_pkg-'||p_transaction_id INTO lv_temp FROM DUAL;
1108 
1109     if lb_rg_debug then
1110       FND_FILE.put_line(FND_FILE.log,'*** Start jai_rcv_excise_processing_pkg.process_transaction');
1111       -- FND_FILE.put_line(FND_FILE.log,'*** Start jai_rcv_excise_processing_pkg.process_transaction');
1112     end if;
1113 
1114     lv_statement_id := '0';
1115     p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'cenvat_rg.process_trx', 'START'); /* 1 */
1116     FND_FILE.put_line( FND_FILE.log, '***** Start of jai_rcv_excise_processing_pkg.process_transaction. Time:'||to_char(SYSDATE, 'dd/mm/yyyy hh24:mi:ss') );
1117 
1118     lv_statement_id := '1';
1119     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
1120     OPEN c_trx(p_transaction_id);
1121     FETCH c_trx INTO r_trx;
1122     CLOSE c_trx;
1123 
1124     OPEN c_base_trx(p_transaction_id);
1125     FETCH c_base_trx INTO r_base_trx;
1126     CLOSE c_base_trx;
1127 
1128     IF r_trx.transaction_type = 'CORRECT' THEN
1129       lv_transaction_type := r_trx.parent_transaction_type;
1130     ELSE
1131       lv_transaction_type := r_trx.transaction_type;
1132     END IF;
1133 
1134     lv_statement_id := '2';
1135     p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
1136 
1137     validate_transaction(
1138       p_transaction_id    => p_transaction_id,
1139       p_validation_type   => 'COMMON',
1140       p_process_status    => p_process_status,
1141       p_process_message   => p_process_message,
1142       p_simulate_flag     => p_simulate_flag,
1143       p_codepath          => p_codepath
1144     );
1145 
1146     IF p_process_status IN ('X', 'E') THEN
1147       GOTO finish;
1148     END IF;
1149 
1150     lv_statement_id := '3';
1151     IF r_trx.organization_type = 'T' THEN
1152       lv_tax_breakup_type := 'RG23D';
1153     ELSE  -- manufacturing and others
1154       lv_tax_breakup_type := 'MODVAT';
1155     END IF;
1156 
1157     lv_statement_id := '4';
1158     p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
1159 
1160     -- ln_curr_conv_rate := r_trx.currency_conversion_rate;
1161     get_tax_amount_breakup(
1162         p_shipment_line_id  => r_trx.shipment_line_id,
1163         p_transaction_id    => r_trx.transaction_id,
1164         p_curr_conv_rate    => r_trx.currency_conversion_rate,
1165         pr_tax              => r_tax,
1166         p_breakup_type      => lv_tax_breakup_type,
1167         p_codepath          => p_codepath
1168     );
1169 
1170     -- Vijay Shankar for Bug#3940588. RECEIPTS DEPLUG
1171     -- following should be executed only incase of RECEIVE (or) MATCH transactions and that too for 2nd claim
1172     IF p_process_special_reason = jai_rcv_excise_processing_pkg.second_50ptg_claim THEN
1173       /* Bug 6800251. Added by Lakshmi Gopalsami
1174        * Get the total RTV qty and proportion it against the receipt qty.
1175        * The tax breakup should happen for the remaining quantity so that
1176        * half of the amount can be used for 2nd claim.
1177        * changed p_process_special_qty
1178        */
1179       OPEN C_Get_Total_RTV(r_trx.shipment_header_id, r_trx.shipment_line_id);
1180         FETCH C_Get_Total_RTV INTO ln_RTV_qty;
1181       CLOSE C_Get_Total_RTV;
1182       ln_special_qty := r_trx.quantity - nvl(ln_RTV_qty,0);
1183       /* Bug 6800251.
1184        * This is to check whether all the materials are returned.
1185        * case where RTV qty = Receipt Qty cannot happen before 2nd claim,
1186        * as 100% should be claimed before returning full goods.
1187        *
1188        */
1189       r_tax := get_apportioned_tax(r_tax, ln_special_qty/r_trx.quantity,'2ND CLAIM' );
1190        -- Date 01/11/2006 Bug 5228046 added by SACSETHI
1191     END IF;
1192 
1193     if lb_rg_debug then
1194       FND_FILE.put_line(FND_FILE.log,'*** Start jai_rcv_excise_processing_pkg.process_transaction');
1195       -- FND_FILE.put_line(FND_FILE.log,'*** Start jai_rcv_excise_processing_pkg.process_transaction');
1196     end if;
1197 
1198     -- Following is to calculate Tax Breakup Amount As Per Apportion Factor. This is calculated based on
1199     -- Transaction UOMs, Quantities of Parent RECEIVE and present trxn an
1200     lv_statement_id := '4a';
1201     p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
1202 
1203     -- These variable are used for 2nd 50% Claim of RECEIVE Transaction of CGIN Items
1204 
1205      r_half_tax := get_apportioned_tax(r_tax, 0.5,null);/*uncommented by vkaranam  and passed null to the p_claim_type parameter for bug 4704957*/
1206 
1207     /* Call to Rounding of Excise Amounts */
1208     -- Rounding is done only for transaction types other than RECEIVE. Rounding of RECEIVE is handled at Excise invoice level seperately
1209     /* following is modified to include RETURN TO VENDOR as rounding of RTV will be done through a seperate process
1210     Vijay Shankar for Bug#4103161
1211     IF lv_transaction_type <> 'RECEIVE' THEN */
1212     IF lv_transaction_type NOT IN ('RECEIVE','RETURN TO VENDOR') THEN
1213       do_cenvat_rounding(
1214         p_transaction_id  => r_trx.transaction_id,
1215         pr_tax            => r_tax,
1216         p_codepath        => p_codepath
1217       );
1218     END IF;
1219 
1220     if lb_rg_debug then
1221       --dbms_output.put_line('After Rounding. Basic:'||r_tax.basic_excise||', Addl:'||r_tax.addl_excise
1222       --  ||', Other:'||r_tax.other_excise||', cvd:'||r_tax.cvd ||', Addl. CVD:'||r_tax.addl_cvd);
1223       -- Date 30/10/2006 Bug 5228046 added by sacsethi
1224       FND_FILE.put_line(FND_FILE.log, 'After Rounding. Basic:'||r_tax.basic_excise||', Addl:'||r_tax.addl_excise
1225         ||', Other:'||r_tax.other_excise||', cvd:'||r_tax.cvd ||', Addl. CVD :'||r_tax.addl_cvd   );
1226     end if;
1227 
1228     OPEN c_orgn_info(r_trx.organization_id, r_trx.location_id);
1229     FETCH c_orgn_info INTO r_orgn_info;
1230     CLOSE c_orgn_info;
1231 
1232     lv_register_type := jai_general_pkg.get_rg_register_type( p_item_class  => r_trx.item_class);
1233 
1234     lv_statement_id := '5';
1235     p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
1236 
1237     /* Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh.
1238     -- Excise Invoce Generation for Return to Vendor Transactions
1239     IF lv_transaction_type = 'RETURN TO VENDOR' THEN
1240 
1241       generate_excise_invoice(
1242           p_transaction_id       => p_transaction_id,
1243           p_organization_id      => r_trx.organization_id,
1244           p_location_id          => r_trx.location_id,
1245           p_excise_invoice_no    => lv_excise_invoice_no,
1246           p_excise_invoice_date  => ld_excise_invoice_date,
1247           p_simulate_flag        => p_simulate_flag,
1248           p_errbuf               => lv_err_message,
1249           p_codepath             => p_codepath
1250       );
1251 
1252       if lb_rg_debug then
1253         --dbms_output.put_line('After ExciseInv Gen. ExInvNo:'||nvl(lv_excise_invoice_no,'NULL') );
1254         FND_FILE.put_line(FND_FILE.log, 'After ExciseInv Gen. ExInvNo:'||nvl(lv_excise_invoice_no, 'NULL') );
1255       end if;
1256 
1257       lv_statement_id := '6';
1258       p_codepath := jai_general_pkg.plot_codepath(8, p_codepath);
1259       IF lv_excise_invoice_no IS NOT NULL THEN
1260         INSERT INTO JAI_RCV_RTV_DTLS(
1261           transaction_id, parent_transaction_id, shipment_line_id,
1262           excise_invoice_no, excise_invoice_date, rg_register_part_i,
1263           creation_date, created_by, last_update_date, last_updated_by, last_update_login
1264         ) VALUES (
1265           p_transaction_id, r_trx.parent_transaction_id, r_trx.shipment_line_id,
1266           lv_excise_invoice_no, ld_excise_invoice_date, NULL,
1267           SYSDATE, FND_GLOBAL.user_id, SYSDATE, FND_GLOBAL.user_id, FND_GLOBAL.login_id
1268         );
1269 
1270         lv_statement_id := '7';
1271         p_codepath := jai_general_pkg.plot_codepath(9, p_codepath);
1272         jai_rcv_transactions_pkg.update_excise_invoice_no(
1273           p_transaction_id      => p_transaction_id,
1274           p_excise_invoice_no   => lv_excise_invoice_no,
1275           p_excise_invoice_date => ld_excise_invoice_date
1276         );
1277       ELSE
1278         lv_message := 'Cenvat Entries cannot be posted due to Excise Invoice cant be generated';
1279         GOTO finish;
1280       END IF;
1281 
1282     END IF;
1283     */
1284 
1285     -- to determine the way in which CGIN Items are Processed
1286     IF lv_register_type = 'C' THEN
1287       derive_cgin_scenario(
1288           p_transaction_id  => p_transaction_id,
1289           p_cgin_code       => lv_cgin_code,
1290           p_process_status  => p_process_status,
1291           p_process_message => p_process_message,
1292           p_codepath        => p_codepath
1293       );
1294 
1295       FND_FILE.put_line(FND_FILE.log, 'CGIN_CODE->'||lv_cgin_code);
1296       IF p_process_status IN ('E', 'X') THEN
1297         GOTO finish;
1298       END IF;
1299     END IF;
1300 
1301     -- Following is Very Important IF condition that determines whether the transaction should be debited or credited
1302     IF lv_transaction_type IN ('RECEIVE', 'RETURN TO RECEIVING') THEN
1303       lv_cenvat_accounting_type  := CENVAT_DEBIT;
1304       lv_register_entry_type     := CENVAT_CREDIT;
1305     ELSIF lv_transaction_type IN ('DELIVER', 'RETURN TO VENDOR') THEN
1306       lv_cenvat_accounting_type  := CENVAT_CREDIT;
1307       lv_register_entry_type     := CENVAT_DEBIT;
1308     END IF;
1309 
1310     if lb_rg_debug then
1311       FND_FILE.put_line(FND_FILE.log, 'AccntEntry Type:'||lv_cenvat_accounting_type||', RegEntryType:'|| lv_register_entry_type);
1312     end if;
1313 
1314     -- 90% of the cenvat entries entries happen only for RECEIVE and RTV entries (code=1)
1315     -- and cenvat entries happen for DELIVER and RTR (code=2)cases only if subinventory is nonbonded
1316     -- 1. RECEIVE and RTV.   We dont check for Subinventory for these transaction types
1317     -- 2. DELIVER and RTR. These were supported only if subinventory is non bonded or expense or non asset case
1318     lv_statement_id := '8';
1319     p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10 */
1320     IF lv_transaction_type IN ('RECEIVE', 'RETURN TO RECEIVING', 'DELIVER', 'RETURN TO VENDOR') THEN
1321 
1322       IF r_trx.organization_type = jai_rcv_trx_processing_pkg.MFG_ORGN  THEN
1323 
1324         lv_statement_id := '9';
1325         p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11 */
1326 
1327         IF (r_base_trx.source_document_code = jai_rcv_trx_processing_pkg.source_rma  -- 'India RMA Receipt'
1328             AND r_trx.item_class IN ('FGIN', 'FGEX', 'CCIN', 'CCEX'))
1329 	  /*Added by nprashar for bug 6710747 The following condition is added to support register update for Inter Org Transfer*/
1330 	  OR ( r_base_trx.source_document_Code = 'INVENTORY' AND lv_transaction_type <>'DELIVER' AND r_trx.item_class IN ('FGIN', 'FGEX', 'CCIN', 'CCEX'))
1331         THEN
1332 
1333         /*bgowrava for forward porting Bug#5756676..start*/
1334 				        IF nvl(r_trx.quantity_register_flag,'N') = 'Y' THEN
1335 
1336 				          OPEN  cur_rg1_register_id;
1337 				          FETCH cur_rg1_register_id INTO ln_part_i_register_id;
1338 				          CLOSE cur_rg1_register_id;
1339 
1340 				          UPDATE JAI_CMN_RG_I_TRXS
1341 				             SET basic_ed              = r_tax.basic_excise,
1342 				                 additional_ed         = r_tax.addl_excise + r_tax.cvd,
1343 				                 other_ed              = r_tax.other_excise,
1344 				                 excise_duty_amount    = r_tax.basic_excise + r_tax.addl_excise + r_tax.cvd + r_tax.other_excise,
1345 				                 excise_invoice_number = r_trx.excise_invoice_no,
1346 				                 excise_invoice_date   = r_trx.excise_invoice_date
1347            WHERE register_id           = ln_part_i_register_id;
1348 
1349            ELSE
1350 
1351           rg_i_entry(
1352               p_transaction_id       => r_trx.transaction_id,
1353               pr_tax                 => r_tax,
1354               p_register_entry_type  => lv_register_entry_type,
1355               p_register_id          => ln_part_i_register_id,
1356               p_process_status       => p_process_status,
1357               p_process_message      => p_process_message,
1358               p_simulate_flag        => p_simulate_flag,
1359               p_codepath             => p_codepath
1360           );
1361 
1362           END IF;
1363           /*bgowrava for forward porting Bug#5756676..end*/
1364 
1365           IF ln_part_i_register_id IS NOT NULL THEN
1366             lv_part_i_register  := 'RG1';
1367           END IF;
1368 
1369         ELSIF r_trx.item_class IN ('RMIN', 'RMEX', 'CCIN', 'CCEX', 'CGIN', 'CGEX') THEN
1370 
1371           lv_statement_id := '10';
1372           p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12 */
1373 
1374           -- RG23 Part I Entry is already made during first Claim, in case of CGIN Items
1375           -- So no need of another entry during Second 50% Claim of CENVAT
1376           IF nvl(lv_cgin_code, 'XXX') <> 'REGULAR-HALF' THEN
1377 
1378            /*bgowrava for forward porting Bug#5756676..start*/
1379 
1380 							IF nvl(r_trx.quantity_register_flag,'N') = 'Y' THEN
1381 
1382 							FND_FILE.put_line(FND_FILE.log, 'Quantity register is already hit. So updating amounts');
1383 
1384 								OPEN  cur_rg23_1_register_id;
1385 								FETCH cur_rg23_1_register_id INTO ln_part_i_register_id;
1386 								CLOSE cur_rg23_1_register_id;
1387 
1388 			  			  FND_FILE.put_line(FND_FILE.log, 'RG23 Part I Register Id:'||ln_part_i_register_id);
1389 
1390 								UPDATE JAI_CMN_RG_23AC_I_TRXS
1391 									 SET basic_ed            = r_tax.basic_excise,
1392 			  			         additional_ed       = r_tax.addl_excise + r_tax.cvd,
1393 			  			         additional_cvd      = r_tax.addl_cvd,
1394 			  			         other_ed            = r_tax.other_excise,
1395 			  			         EXCISE_INVOICE_NO   = r_trx.excise_invoice_no,
1396 			  			         excise_invoice_date = r_trx.excise_invoice_date
1397 								 WHERE register_id         = ln_part_i_register_id;
1398 
1399 							ELSE
1400 
1401 					     FND_FILE.put_line(FND_FILE.log, 'Quantity register is not hit. So calling rg23_part_i_entry');
1402                rg23_part_i_entry(
1403                 p_transaction_id       => r_trx.transaction_id,
1404                 pr_tax                 => r_tax,
1405                 p_register_entry_type  => lv_register_entry_type,
1406                 p_register_id          => ln_part_i_register_id,
1407                 p_process_status       => p_process_status,
1408                 p_process_message      => p_process_message,
1409                 p_simulate_flag        => p_simulate_flag,
1410                 p_codepath             => p_codepath
1411             );
1412 
1413             END IF;
1414           /*bgowrava for forward porting Bug#5756676..end*/
1415 
1416           ELSE
1417             FND_FILE.put_line( FND_FILE.log, 'No Call to RG23_PART_I_ENTRY');
1418           END IF;
1419 
1420           IF ln_part_i_register_id IS NOT NULL THEN
1421             lv_part_i_register  := 'RG23'||lv_register_type;
1422           END IF;
1423 
1424         ELSE
1425           lv_message := 'ItemClass Not Supported for Transaction';
1426           GOTO finish;
1427         END IF;
1428 
1429         IF p_process_status IN ('E', 'X') THEN
1430           GOTO finish;
1431         END IF;
1432 
1433         /*uncommneted by vkaranam for bug#4704957, start */--Commented by Vijay Shankar for Bug#3940588. RECEIPTS DEPLUG.
1434         -- Start PARENT Half Claim entry for RTV
1435         -- This is for RTV case when Parent RECEIVE is only 50% Claimed
1436         IF lv_transaction_type = 'RETURN TO VENDOR'
1437           AND lv_register_type = 'C'
1438           AND lv_cgin_code like '%PARENT-REGULAR-HALF%'
1439         THEN
1440 
1441           FND_FILE.put_line(FND_FILE.log, '<< Start 2nd 50% Claim of RECEIVE during RTV');
1442 
1443           lv_statement_id := '11';
1444           p_codepath := jai_general_pkg.plot_codepath(13, p_codepath);
1445           ln_receive_trx_id := r_trx.tax_transaction_id;
1446 
1447           -- Pass an RG23 PartII Entry against Parent RECEIVE line to the tune of 50% of RTV Quantity
1448           rg23_part_ii_entry(
1449               --p_transaction_id        => r_trx.transaction_id,
1450               p_transaction_id        => r_trx.tax_transaction_id,--added by vkaranam for bug 5841749
1451               pr_tax                  => r_half_tax,
1452               p_part_i_register_id    => NULL,
1453               p_register_entry_type   => CENVAT_CREDIT,
1454               p_reference_num         => r_trx.transaction_id,/*ln_receive_trx_id is replaced by r_trx.transaction_id by vkaranam for bug#4704957*/
1455               p_register_id           => ln_receive_part_ii_reg_id,
1456               p_process_status        => p_process_status,
1457               p_process_message       => p_process_message,
1458               p_simulate_flag         => p_simulate_flag,
1459               p_codepath              => p_codepath
1460           );
1461 
1462           IF p_process_status IN ('E', 'X') THEN
1463             GOTO finish;
1464           END IF;
1465 
1466           IF ln_receive_part_ii_reg_id IS NOT NULL THEN
1467             lv_receive_part_ii_type := 'RG23C';
1468 
1469             -- Vijay Shankar for Bug#3940588. The same is coded at the end of procedure
1470             -- this is to increase the cenvat_claimed_amt to the tune of second 50% that is claimed now on RECEIVE transaction
1471             UPDATE JAI_RCV_CENVAT_CLAIMS
1472               SET cenvat_claimed_amt = nvl(cenvat_claimed_amt,0)
1473                           + (r_half_tax.basic_excise +
1474 			     r_half_tax.addl_excise +
1475 			     r_half_tax.other_excise +
1476 			     r_half_tax.cvd +
1477 			     r_tax.addl_cvd     -- Date 30/10/2006 Bug 5228046 added by sacsethi
1478 			    ),
1479                         other_cenvat_claimed_amt = nvl(other_cenvat_claimed_amt,0)
1480                           + (r_half_tax.excise_edu_cess + r_half_tax.cvd_edu_cess+nvl(r_half_tax.sh_exc_edu_cess,0)
1481                           + nvl(r_half_tax.sh_cvd_edu_cess,0)),
1482                           /*added nvl(r_half_tax.sh_exc_edu_cess,0) + nvl(r_half_tax.sh_cvd_edu_cess,0) by vkaranam for budget 07 impact - bug#5989740*/
1483                   cenvat_sequence = cenvat_sequence + 1,
1484                   last_update_date = sysdate,
1485                   last_updated_by = fnd_global.user_id
1486             WHERE transaction_id = ln_receive_trx_id;
1487             -- CHK whether the above update is required or not. because there is another update at the end of procedure
1488 
1489           END IF;
1490 
1491           lv_statement_id := '11a';
1492           p_codepath := jai_general_pkg.plot_codepath(14, p_codepath);
1493           -- Pass accounting for the remaining 50% Claim against Parent RECEIVE line to the tune of RTV Quantity.
1494           -- Full amount is passed here but half amount will be passed in accounting_entries procedure
1495           accounting_entries(
1496               p_transaction_id          => r_trx.transaction_id,
1497               pr_tax                    => r_tax,
1498               p_cgin_code               => 'REGULAR-HALF',
1499               p_cenvat_accounting_type  => CENVAT_DEBIT,
1500               p_amount_register         => lv_receive_part_ii_type,
1501               p_cenvat_account_id       => ln_receive_charge_accnt,
1502               p_process_status          => p_process_status,
1503               p_process_message         => p_process_message,
1504               p_simulate_flag           => p_simulate_flag,
1505               p_codepath                => p_codepath
1506           );
1507 
1508           IF p_process_status IN ('E', 'X') THEN
1509             GOTO finish;
1510           END IF;
1511 
1512           jai_cmn_rg_23ac_ii_pkg.update_payment_details(
1513             p_register_id         => ln_receive_part_ii_reg_id,
1514             p_register_id_part_i  => NULL,
1515             p_charge_account_id   => ln_receive_charge_accnt
1516           );
1517 
1518           FND_FILE.put_line(FND_FILE.log, '>> END 2nd 50% Claim of RECEIVE during RTV');
1519 
1520         END IF;
1521         -- End PARENT Half Claim entry for RTV
1522         /*vkaranam for bug #4704957,end*/
1523 
1524         lv_statement_id := '11b';
1525         p_codepath := jai_general_pkg.plot_codepath(15, p_codepath); /* 15 */
1526         -- lv_cgin_code will have a value only in case of CGIN items wherein 1st 50% claim is 'REGULAR-FULL + REVERSAL-HALF'
1527         -- and 2nd 50% claim is done by 'REGULAR-HALF'
1528         IF lv_cgin_code IN ( 'REGULAR-FULL + REVERSAL-HALF', 'REGULAR-HALF') THEN
1529           ln_amount_factor := 0.5;
1530         ELSE
1531           ln_amount_factor := 1;
1532         END IF;
1533 
1534         lv_statement_id := '12';
1535 
1536         /* START - DUTY REGISTER HITTING LOGIC */
1537         -- following if condition modified by Vijay Shankar for RECEIPTS DEPLUG
1538         -- IF lv_transaction_type = 'RETURN TO VENDOR' AND r_orgn_info.pref_pla = 1 THEN
1539         IF lv_transaction_type = 'RETURN TO VENDOR' THEN
1540 
1541           p_codepath := jai_general_pkg.plot_codepath(16, p_codepath); /* 16 */
1542 
1543           derive_duty_registers(
1544             p_organization_id           => r_trx.organization_id,
1545             p_location_id               => r_trx.location_id,
1546             p_item_class                => r_trx.item_class,
1547             pr_tax                      => r_tax,
1548             p_cenvat_register_type      => lv_cenvat_register_type,
1549             -- p_edu_cess_register_type    => lv_edu_cess_register_type,
1550             p_process_flag              => p_process_status,
1551             p_process_message           => p_process_message,
1552             p_codepath                  => p_codepath
1553           );
1554 
1555           IF p_process_status = 'E' THEN
1556             GOTO finish;
1557           END IF;
1558 
1559         ELSE
1560           lv_cenvat_register_type   := NULL;
1561           lv_edu_cess_register_type := NULL;
1562         END IF;
1563 
1564         IF    (lv_cenvat_register_type IS NULL AND lv_edu_cess_register_type IS NULL)
1565             OR lv_cenvat_register_type IN (jai_constants.register_type_a, jai_constants.register_type_c)
1566         THEN
1567 
1568           lv_statement_id := '13';
1569           p_codepath := jai_general_pkg.plot_codepath(17, p_codepath);
1570 
1571           IF lv_transaction_type = 'RECEIVE' AND lv_cgin_code IS NOT NULL THEN
1572             -- 1st Claim
1573             IF nvl(p_cenvat_claimed_ptg, 0) = 0 THEN
1574               lv_reference_num := CGIN_FIRST_CLAIM;
1575             -- 2nd Claim onwards. -- Helpful to identify the duplicate entry in JAI_CMN_RG_23AC_II_TRXS. if the line is 100% Claimed, then we should not pass another entry
1576             ELSE    -- IF p_cenvat_claimed_ptg = 50 THEN
1577               lv_reference_num := CGIN_SECOND_CLAIM;
1578             END IF;
1579           ELSE
1580             lv_reference_num := NULL;
1581           END IF;
1582 
1583           lv_statement_id := '13.1';
1584           rg23_part_ii_entry(
1585               p_transaction_id        => r_trx.transaction_id,
1586               pr_tax                  => get_apportioned_tax(r_tax,
1587 	                                                     ln_amount_factor,
1588 							     UPPER(lv_reference_num)     -- Date 30/10/2006 Bug 5228046 added by sacsethi
1589 							    ),
1590               p_part_i_register_id    => ln_part_i_register_id,
1591               p_register_entry_type   => lv_register_entry_type,
1592               p_reference_num         => lv_reference_num,
1593               p_register_id           => ln_part_ii_register_id,
1594               p_process_status        => p_process_status,
1595               p_process_message       => p_process_message,
1596               p_simulate_flag         => p_simulate_flag,
1597               p_codepath              => p_codepath
1598           );
1599 
1600           IF p_process_status IN ('E', 'X') THEN
1601             GOTO finish;
1602           END IF;
1603 
1604           IF ln_part_ii_register_id IS NOT NULL THEN
1605             lv_part_ii_register  := 'RG23'||lv_register_type;
1606           END IF;
1607 
1608         ELSIF lv_cenvat_register_type = jai_constants.register_type_pla THEN
1609 
1610           lv_statement_id := '13.2';
1611           p_codepath := jai_general_pkg.plot_codepath(17.1, p_codepath);
1612           pla_entry(
1613               p_transaction_id      => p_transaction_id,
1614               pr_tax                => get_apportioned_tax(r_tax,
1615 	                                                   ln_amount_factor,
1616 							   UPPER(lv_reference_num)) ,    -- Date 30/10/2006 Bug 5228046 added by sacsethi
1617               p_register_entry_type => lv_register_entry_type,
1618               p_register_id         => ln_part_ii_register_id,
1619               p_process_status      => p_process_status,
1620               p_process_message     => p_process_message,
1621               p_simulate_flag       => p_simulate_flag,
1622               p_codepath            => p_codepath
1623           );
1624 
1625           IF p_process_status IN ('E', 'X') THEN
1626             GOTO finish;
1627           END IF;
1628 
1629           IF ln_part_ii_register_id IS NOT NULL THEN
1630             lv_part_ii_register  := 'PLA';
1631           END IF;
1632 
1633         ELSE
1634           lv_statement_id := '13.3';
1635           p_codepath := jai_general_pkg.plot_codepath(17.2, p_codepath);
1636           --p_process_status  := 'E';
1637           lv_message := 'Duty Register cannot be derived';
1638           GOTO finish;
1639         END IF;
1640 
1641         /* END - DUTY REGISTER HITTING LOGIC */
1642 
1643         /* START - ACCOUNTING LOGIC */
1644         lv_statement_id := '13a';
1645         p_codepath := jai_general_pkg.plot_codepath(18, p_codepath); /* 18 */
1646 
1647         fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb> --- 1');
1648 
1649         accounting_entries(
1650             p_transaction_id          => r_trx.transaction_id,
1651             pr_tax                    => r_tax,
1652             p_cgin_code               => lv_cgin_code,
1653             p_cenvat_accounting_type  => lv_cenvat_accounting_type,
1654             p_amount_register         => lv_part_ii_register,
1655             p_cenvat_account_id       => ln_charge_account_id,
1656             p_process_status          => p_process_status,
1657             p_process_message         => p_process_message,
1658             p_simulate_flag           => p_simulate_flag,
1659             p_codepath                => p_codepath
1660         );
1661 
1662         IF p_process_status IN ('E', 'X') THEN
1663           GOTO finish;
1664         END IF;
1665         /* END - ACCOUNTING LOGIC */
1666 
1667       ELSIF r_trx.organization_type = jai_rcv_trx_processing_pkg.TRADING_ORGN THEN
1668 
1669         -- In a Trading Organization all the ITEM CLASSes are supported
1670 
1671         lv_statement_id := '14';
1672         -- IF r_trx.item_class IN ('FGIN', 'FGEX') THEN
1673           -- right now i am assuming that we need not pass any accouting entries. however we need to pass rg23d entry
1674 
1675         lv_statement_id := '15';
1676         p_codepath := jai_general_pkg.plot_codepath(20, p_codepath); /* 20 */
1677         rg23_d_entry(
1678             p_transaction_id      => p_transaction_id,
1679             pr_tax                => r_tax,
1680             p_register_entry_type => lv_register_entry_type,
1681             p_register_id         => ln_part_i_register_id,
1682             p_process_status      => p_process_status,
1683             p_process_message     => p_process_message,
1684             p_simulate_flag       => p_simulate_flag,
1685             p_codepath            => p_codepath
1686         );
1687 
1688         IF ln_part_i_register_id IS NOT NULL THEN
1689           lv_part_i_register  := 'RG23D';
1690         END IF;
1691 
1692         IF p_process_status IN ('E', 'X') THEN
1693           GOTO finish;
1694         END IF;
1695 
1696         lv_statement_id := '16';
1697         p_codepath := jai_general_pkg.plot_codepath(21, p_codepath); /* 21 */
1698         -- there is no part II entry for TRADING transactions
1699         IF lv_transaction_type IN ('RECEIVE', 'RETURN TO VENDOR') AND r_trx.excise_in_trading = 'Y' THEN
1700 
1701           lb_process_iso := jai_rcv_trx_processing_pkg.process_iso_transaction(
1702                                 p_transaction_id    => r_trx.transaction_id,
1703                                 p_shipment_line_id  => r_trx.shipment_line_id
1704                             );
1705 
1706           -- No cenvat accounting in case of DELIVER/ RETURN TO RECEIVING.
1707           -- Also accounting happens only if Organization Setup for Excise in RG23D is checked
1708 
1709         -- Vijay Shankar for Bug#3927371, This needs modification after discussing with Yadu
1710           -- IF r_trx.organization_type = 'M' OR (r_trx.organization_type = 'T' AND lb_process_iso)
1711           IF ( r_base_trx.source_document_code <> 'REQ'
1712             OR (r_base_trx.source_document_code='REQ' AND lb_process_iso) )
1713             AND r_base_trx.source_document_code <> jai_rcv_trx_processing_pkg.source_rma /*srjayara for bug#5155138 - change done for base bug 5110511 + DFF Elimination*/
1714 
1715           THEN
1716 
1717             p_codepath := jai_general_pkg.plot_codepath(21.2, p_codepath);
1718             accounting_entries(
1719                 p_transaction_id          => r_trx.transaction_id,
1720                 pr_tax                    => r_tax,
1721                 p_cgin_code               => NULL, -- lv_cgin_code can be null as this is trading organization
1722                 p_cenvat_accounting_type  => lv_cenvat_accounting_type,
1723                 p_amount_register         => lv_part_ii_register,
1724                 p_cenvat_account_id       => ln_charge_account_id,
1725                 p_process_status          => p_process_status,
1726                 p_process_message         => p_process_message,
1727                 p_simulate_flag           => p_simulate_flag,
1728                 p_codepath                => p_codepath
1729             );
1730 
1731           ELSE
1732             FND_FILE.put_line( FND_FILE.log, '..No Accounting Required for Trading Orgn');
1733           END IF;
1734 
1735         END IF;
1736 
1737       ELSE
1738         p_codepath := jai_general_pkg.plot_codepath(21.5, p_codepath);
1739         lv_message := 'Organization Type Not supported';
1740         GOTO finish;
1741       END IF;
1742 
1743       IF p_process_status IN ('E', 'X') THEN
1744         GOTO finish;
1745       END IF;
1746 
1747     ELSE
1748       lv_statement_id := '18';
1749       p_codepath := jai_general_pkg.plot_codepath(22, p_codepath); /* 22 */
1750       lv_message := 'Transaction Type Not supported';
1751       GOTO finish;
1752     END IF;
1753 
1754     lv_statement_id := '19';
1755     p_codepath := jai_general_pkg.plot_codepath(23, p_codepath); /* 23 */
1756     -- Updation of RG Part1 Registers with Payment Register, Register_Id_Part_II, ChargeAccountId
1757     update_registers(
1758         p_quantity_register_id  => ln_part_i_register_id,
1759         p_quantity_register     => lv_part_i_register,
1760         p_payment_register_id   => ln_part_ii_register_id,
1761         p_payment_register      => lv_part_ii_register,
1762         p_charge_account_id     => ln_charge_account_id,
1763         p_process_status        => p_process_status,
1764         p_process_message       => p_process_message,
1765         p_simulate_flag         => p_simulate_flag,
1766         p_codepath              => p_codepath
1767     );
1768 
1769     IF lv_transaction_type = 'RETURN TO VENDOR' AND ln_part_i_register_id IS NOT NULL THEN
1770       lv_statement_id := '20';
1771       p_codepath := jai_general_pkg.plot_codepath(24, p_codepath); /* 24 */
1772       UPDATE JAI_RCV_RTV_DTLS
1773       SET rg_register_part_i = ln_part_i_register_id
1774       WHERE transaction_id = p_transaction_id;
1775     END IF;
1776 
1777     -- Assigning the Percentage value that has been claimed w.r.t transaction
1778     IF lv_register_type = 'C' THEN
1779       IF lv_transaction_type = 'RECEIVE' THEN
1780         IF lv_cgin_code = 'REGULAR-FULL' THEN
1781           p_cenvat_claimed_ptg := 100;
1782         ELSE      --IF lv_transaction_type = 'REGULAR-HALF' THEN
1783           p_cenvat_claimed_ptg := nvl(p_cenvat_claimed_ptg, 0) + 50;
1784         END IF;
1785       ELSE
1786         IF lv_cgin_code in ('REGULAR-FULL + REVERSAL-HALF', 'REGULAR-HALF') THEN
1787           p_cenvat_claimed_ptg := 50;
1788         ELSE
1789           p_cenvat_claimed_ptg := 100;
1790         END IF;
1791       END IF;
1792     ELSE
1793       p_cenvat_claimed_ptg := 100;
1794     END IF;
1795 
1796     -- CALL TO Post Processor updated claim related stuff in JAI_RCV_CENVAT_CLAIMS and JAI_RCV_LINES at RECEIVE trx level
1797     -- Vijay Shankar for Bug#3940588
1798     post_cenvat_processor(
1799       p_transaction_id            => p_transaction_id,
1800       p_cenvat_claimed_ptg        => p_cenvat_claimed_ptg,
1801       p_cenvat_claimed_amt        => (
1802                                         (  r_tax.basic_excise +
1803 					   r_tax.addl_excise +
1804 					   r_tax.other_excise +
1805 					   r_tax.cvd
1806 					)  * ln_amount_factor
1807 				     ) + r_tax.addl_cvd ,-- Date 30/10/2006 Bug 5228046 added by sacsethi
1808       p_other_cenvat_claimed_amt  => (r_tax.excise_edu_cess + r_tax.cvd_edu_cess+r_tax.sh_exc_edu_cess + r_tax.sh_cvd_edu_cess) * ln_amount_factor/*added r_tax.sh_exc_edu_cess + r_tax.sh_cvd_edu_cess
1809                                                                                                                                                    by vkaranam for budget 07 impact - bug#5989740*/
1810     );
1811 
1812     p_process_status := 'Y';
1813 
1814     <<finish>>
1815     IF lv_message IS NOT NULL THEN
1816       p_codepath := jai_general_pkg.plot_codepath(25, p_codepath); /* 25 */
1817 
1818       FND_FILE.put_line(FND_FILE.log, 'CENVAT_RG_PKG.process_trxn:'||lv_message||', StatementId:'||lv_statement_id);
1819       p_process_status := 'E';
1820       p_process_message := 'CENVAT_RG_PKG.process_trxn:'||lv_message||', StatementId:'||lv_statement_id;
1821     END IF;
1822 
1823     p_codepath := jai_general_pkg.plot_codepath(26, p_codepath, null, 'END'); /* 26 */
1824     FND_FILE.put_line( FND_FILE.log, '----- END, jai_rcv_excise_processing_pkg.process_transaction. Time:'||to_char(SYSDATE, 'dd/mm/yyyy hh24:mi:ss') );
1825 
1826   EXCEPTION
1827     WHEN OTHERS THEN
1828       p_process_status := 'E';
1829       p_process_message := 'CENVAT_RG_PKG.process_transaction->'||SQLERRM||', StmtId->'||lv_statement_id;
1830       FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
1831       p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END');
1832 
1833   END process_transaction;
1834 
1835   -- this procedure to be called only for RMA case of FGIN, FGEX, CCIN, CCEX
1836   PROCEDURE rg_i_entry(
1837     p_transaction_id      IN  NUMBER,
1838     pr_tax                IN  TAX_BREAKUP,
1839     p_register_entry_type IN  VARCHAR2,
1840     p_register_id OUT NOCOPY NUMBER,
1841     p_process_status OUT NOCOPY VARCHAR2,
1842     p_process_message OUT NOCOPY VARCHAR2,
1843     p_simulate_flag       IN  VARCHAR2,
1844     p_codepath            IN OUT NOCOPY VARCHAR2
1845   ) IS
1846 
1847     r_trx                     c_trx%ROWTYPE;
1848     r_base_trx                c_base_trx%ROWTYPE;
1849 
1850     ln_register_id            JAI_CMN_RG_I_TRXS.register_id%TYPE;
1851     lv_slno                   JAI_CMN_RG_I_TRXS.slno%TYPE;
1852     lv_range                  JAI_CMN_RG_I_TRXS.range_no%TYPE;
1853     lv_division               JAI_CMN_RG_I_TRXS.division_no%TYPE;
1854     ln_excise_duty_rate       JAI_CMN_RG_I_TRXS.excise_duty_rate%TYPE;
1855     lv_excise_invoice_no      JAI_CMN_RG_I_TRXS.excise_invoice_number%TYPE;
1856     ld_excise_invoice_date    JAI_CMN_RG_I_TRXS.excise_invoice_date%TYPE;
1857     ln_customer_id            RCV_TRANSACTIONS.customer_id%TYPE;
1858     ln_customer_site_id       RCV_TRANSACTIONS.customer_site_id%TYPE;
1859     r_parent_base_trx         c_base_trx%ROWTYPE;
1860 
1861     ln_entry_type             NUMBER;   --File.Sql.35 Cbabu  := 1;
1862     ln_basic_ed               NUMBER;
1863     ln_additional_ed          NUMBER;
1864     ln_other_ed               NUMBER;
1865     ln_excise_duty_amount     NUMBER;
1866 
1867 
1868     lv_transaction_type       JAI_CMN_RG_I_TRXS.transaction_type%TYPE;
1869 
1870     ln_quantity               NUMBER;
1871     ln_vendor_id              NUMBER(15);
1872     ln_vendor_site_id         NUMBER(15);
1873 
1874     lv_statement_id           VARCHAR2(5);
1875     ln_exc_edu_cess           NUMBER; /*vkaranam for bug 5989740*/
1876     ln_sh_exc_edu_cess        NUMBER; /*vkaranam for bug 5989740*/
1877 
1878   BEGIN
1879 
1880     ln_entry_type := 1;
1881     if lb_rg_debug then
1882       FND_FILE.put_line(FND_FILE.log,'^ RG1 Entry. Basic:'||pr_tax.basic_excise
1883         ||', Addl:'||pr_tax.addl_excise||', Other:'||pr_tax.other_excise
1884         ||', CVD:'||pr_tax.cvd||', EntryType:'||p_register_entry_type ||', PrcSta:'||p_process_status
1885       );
1886     end if;
1887 
1888     lv_statement_id := '1';
1889     p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'cenvat_rg.rg_i_entry', 'START'); /* 1 */
1890 
1891     OPEN c_trx(p_transaction_id);
1892     FETCH c_trx INTO r_trx;
1893     CLOSE c_trx;
1894 
1895     lv_statement_id := '2';
1896     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
1897     OPEN c_base_trx(p_transaction_id);
1898     FETCH c_base_trx INTO r_base_trx;
1899     CLOSE c_base_trx;
1900 
1901     ln_customer_id      := r_base_trx.customer_id;
1902     ln_customer_site_id := r_base_trx.customer_site_id;
1903 
1904     IF r_base_trx.source_document_code = 'REQ' THEN
1905       lv_statement_id := '4';
1906       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
1907       OPEN c_source_orgn_loc( r_base_trx.shipment_header_id, r_base_trx.requisition_line_id);
1908       FETCH c_source_orgn_loc INTO ln_vendor_id, ln_vendor_site_id;
1909       CLOSE c_source_orgn_loc;
1910 
1911       ln_vendor_id      := -ln_vendor_id;
1912       ln_vendor_site_id := -ln_vendor_site_id;
1913 
1914     ELSE
1915       lv_statement_id := '5';
1916       p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
1917 
1918       get_changed_vendor_dtls(
1919         p_receive_trx_id      => r_trx.tax_transaction_id,
1920         p_shipment_line_id    => r_trx.shipment_line_id,
1921         p_vendor_id           => ln_vendor_id,
1922         p_vendor_site_id      => ln_vendor_site_id
1923       );
1924 
1925       ln_vendor_id      := nvl(ln_vendor_id, r_base_trx.vendor_id);
1926       ln_vendor_site_id := nvl(ln_vendor_site_id, r_base_trx.vendor_site_id);
1927 
1928     END IF;
1929 
1930     IF r_base_trx.source_document_code = 'RMA' THEN
1931       IF ln_customer_site_id IS NULL THEN
1932         /*OPEN c_base_trx( jai_rcv_trx_processing_pkg.get_ancestor_id(
1933                             p_transaction_id     => r_trx.transaction_id,
1934                             p_shipment_line_id   => r_trx.shipment_line_id,
1935                             p_required_trx_type  => 'RECEIVE'
1936                          )
1937                        );*/
1938         OPEN c_base_trx(r_trx.tax_transaction_id);
1939         FETCH c_base_trx INTO r_parent_base_trx;
1940         CLOSE c_base_trx;
1941 
1942         ln_customer_site_id := r_parent_base_trx.customer_site_id;
1943       END IF;
1944     END IF;
1945 
1946     lv_statement_id := '61';
1947     p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
1948     jai_general_pkg.get_range_division(
1949         p_vendor_id       => ln_vendor_id,
1950         p_vendor_site_id  => ln_vendor_site_id,
1951         p_range_no        => lv_range,
1952         p_division_no     => lv_division
1953     );
1954 
1955     lv_excise_invoice_no    := r_trx.excise_invoice_no;
1956     ld_excise_invoice_date  := r_trx.excise_invoice_date;
1957 
1958     lv_statement_id := '7';
1959     p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
1960     -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. IF r_base_trx.attr_cat = 'India RMA Receipt' THEN
1961     IF r_base_trx.source_document_code = jai_rcv_trx_processing_pkg.source_rma then -- 'India RMA Receipt' THEN
1962       lv_transaction_type := 'CR';
1963     ELSE
1964       lv_transaction_type := 'R';
1965     END IF;
1966 
1967     IF p_register_entry_type = CENVAT_DEBIT THEN
1968       ln_entry_type := -1;
1969     END IF;
1970 
1971     lv_statement_id := '8';
1972     p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
1973     ln_quantity           := r_trx.quantity * ln_entry_type;
1974     ln_basic_ed           := pr_tax.basic_excise * ln_entry_type;
1975     ln_additional_ed      := (pr_tax.addl_excise + pr_tax.cvd) * ln_entry_type;
1976     ln_other_ed           := pr_tax.other_excise * ln_entry_type;
1977     ln_excise_duty_amount := ln_basic_ed + ln_additional_ed + ln_other_ed;
1978     ln_exc_edu_cess       := pr_tax.excise_edu_cess * ln_entry_type;/*added by vkaranam for bug #5989740*/
1979     ln_sh_exc_edu_cess       := pr_tax.sh_exc_edu_cess * ln_entry_type;/*added by vkaranam for bug #5989740*/
1980     ln_excise_duty_rate := ln_excise_duty_amount/ln_quantity;
1981 
1982     if lb_rg_debug then
1983       FND_FILE.put_line(FND_FILE.log,'Before call to RG1. ExDutyAmt:'||ln_excise_duty_amount);
1984     end if;
1985 
1986     lv_statement_id := '9';
1987     p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
1988     jai_cmn_rg_i_trxs_pkg.create_rg1_entry(
1989         p_register_id                  => p_register_id,
1990         p_register_id_part_ii          => null,
1991         p_fin_year                     => jai_general_pkg.get_fin_year(p_organization_id => r_trx.organization_id),
1992         p_slno                         => lv_slno,
1993         p_transaction_id               => null,
1994         p_organization_id              => r_trx.organization_id,
1995         p_location_id                  => r_trx.location_id,
1996         p_transaction_date             => r_trx.transaction_date,
1997         p_inventory_item_id            => r_trx.inventory_item_id,
1998         p_transaction_type             => lv_transaction_type,
1999         p_ref_doc_id                   => to_char(p_transaction_id),
2000         p_quantity                     => ln_quantity,
2001         p_transaction_uom_code         => r_trx.uom_code,
2002         p_issue_type                   => null,
2003         p_excise_duty_amount           => ln_excise_duty_amount,
2004         p_excise_invoice_number        => r_trx.excise_invoice_no,
2005         p_excise_invoice_date          => r_trx.excise_invoice_date,
2006         p_payment_register             => null,
2007         p_charge_account_id            => NULL,
2008         p_range_no                     => lv_range,
2009         p_division_no                  => lv_division,
2010         p_remarks                      => null,
2011         p_basic_ed                     => ln_basic_ed,
2012         p_additional_ed                => ln_additional_ed,
2013         p_other_ed                     => ln_other_ed,
2014         p_assessable_value             => null,
2015         p_excise_duty_rate             => ln_excise_duty_rate,
2016         p_vendor_id                    => ln_vendor_id,
2017         p_vendor_site_id               => ln_vendor_site_id,
2018         p_customer_id                  => ln_customer_id,
2019         p_customer_site_id             => ln_customer_site_id,
2020         p_creation_date                => SYSDATE,
2021         p_created_by                   => fnd_global.user_id,
2022         p_last_update_date             => SYSDATE,
2023         p_last_updated_by              => fnd_global.user_id,
2024         p_last_update_login            => fnd_global.login_id,
2025         p_called_from                  => 'RECEIPTS',
2026         p_cess_amount                  => ln_exc_edu_cess ,/*added by vkaranam for budget 07 impact - bug#5989740*/
2027 	p_sh_cess_amount               => ln_sh_exc_edu_cess --added by vkaranam for budget 07 impact - bug#5989740
2028      );
2029 
2030 
2031      /*bgowrava for forward porting Bug#5756676..start*/
2032 
2033 		 	UPDATE JAI_RCV_TRANSACTIONS
2034 		 		 SET quantity_register_flag  = 'Y',
2035 		 				 last_updated_by         = fnd_global.user_id,
2036 		 				 last_update_date        = sysdate,
2037 		 				 last_update_login       = fnd_global.login_id
2038 		 	 WHERE transaction_id          = p_transaction_id ;
2039 
2040 		   FND_FILE.put_line(FND_FILE.log, 'Updating quantity register flag to Y');
2041 
2042 		   /*bgowrava for forward porting Bug#5756676..end*/
2043 
2044 
2045     p_codepath := jai_general_pkg.plot_codepath(9, p_codepath, null, 'END'); /* 9 */
2046 
2047   EXCEPTION
2048     WHEN OTHERS THEN
2049       p_process_status := 'E';
2050       p_process_message := 'CENVAT_RG_PKG.rg_i_entry->'||SQLERRM||', StmtId->'||lv_statement_id;
2051       FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
2052       p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END');
2053 
2054   END rg_i_entry;
2055 
2056   PROCEDURE rg23_part_i_entry(
2057     p_transaction_id    IN NUMBER,
2058     pr_tax                IN  TAX_BREAKUP,
2059     p_register_entry_type IN VARCHAR2,
2060     p_register_id OUT NOCOPY NUMBER,
2061     p_process_status OUT NOCOPY VARCHAR2,
2062     p_process_message OUT NOCOPY VARCHAR2,
2063     p_simulate_flag     IN VARCHAR2,
2064     p_codepath          IN OUT NOCOPY VARCHAR2
2065   ) IS
2066 
2067     CURSOR c_po_header(cp_po_header_id IN NUMBER) IS
2068       SELECT po_header_id, creation_date
2069       FROM po_headers_all
2070       WHERE po_header_id = cp_po_header_id;
2071 
2072     r_trx                     c_trx%ROWTYPE;
2073     r_base_trx                c_base_trx%ROWTYPE;
2074     r_po_header               c_po_header%ROWTYPE;
2075 
2076     ln_register_id            JAI_CMN_RG_23AC_I_TRXS.register_id%TYPE;
2077     ln_vendor_id              RCV_TRANSACTIONS.vendor_id%TYPE;
2078     ln_vendor_site_id         RCV_TRANSACTIONS.vendor_site_id%TYPE;
2079     lv_excise_invoice_no      JAI_CMN_RG_23AC_I_TRXS.EXCISE_INVOICE_NO%TYPE;
2080     ld_excise_invoice_date    JAI_CMN_RG_23AC_I_TRXS.excise_invoice_date%TYPE;
2081     lv_transaction_type       RCV_TRANSACTIONS.transaction_type%TYPE;
2082     ln_customer_id            RCV_TRANSACTIONS.customer_id%TYPE;
2083     ln_customer_site_id       RCV_TRANSACTIONS.customer_site_id%TYPE;
2084     r_parent_base_trx         c_base_trx%ROWTYPE;
2085 
2086     ln_entry_type             NUMBER;   --File.Sql.35 Cbabu  := 1;
2087     ln_basic_ed               NUMBER;
2088     ln_additional_ed          NUMBER;
2089     ln_additional_cvd         NUMBER;     -- Date 30/10/2006 Bug 5228046 added by sacsethi
2090     ln_other_ed               NUMBER;
2091     ln_quantity               NUMBER;
2092 
2093     lv_statement_id           VARCHAR2(5);
2094   BEGIN
2095 
2096     ln_entry_type    := 1;
2097     if lb_rg_debug then
2098      -- Date 30/10/2006 Bug 5228046 added by sacsethi
2099       FND_FILE.put_line(FND_FILE.log,'^ RG23_PART_I_Entry. Basic:'||pr_tax.basic_excise
2100         ||', Addl:'||pr_tax.addl_excise||', Other:'||pr_tax.other_excise
2101         ||', CVD:'||pr_tax.cvd ||', Addl. CVD: '|| pr_tax.addl_cvd||', EntryType:'||p_register_entry_type ||', PrcSta:'||p_process_status
2102       );
2103     end if;
2104 
2105     lv_statement_id := '1';
2106     p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'cenvat_rg.23_part_i', 'START'); /* 1 */
2107     OPEN c_trx(p_transaction_id);
2108     FETCH c_trx INTO r_trx;
2109     CLOSE c_trx;
2110 
2111     lv_statement_id := '2';
2112     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
2113 
2114     OPEN c_base_trx(p_transaction_id);
2115     FETCH c_base_trx INTO r_base_trx;
2116     CLOSE c_base_trx;
2117 
2118     ln_customer_id      := r_base_trx.customer_id;
2119     ln_customer_site_id := r_base_trx.customer_site_id;
2120 
2121     lv_statement_id := '3';
2122     p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
2123     IF r_base_trx.po_header_id IS NOT NULL THEN
2124       OPEN c_po_header(r_base_trx.po_header_id);
2125       FETCH c_po_header INTO r_po_header;
2126       CLOSE c_po_header;
2127     END IF;
2128 
2129     IF r_base_trx.source_document_code = 'REQ' THEN
2130       lv_statement_id := '4';
2131       p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
2132       OPEN c_source_orgn_loc( r_base_trx.shipment_header_id, r_base_trx.requisition_line_id);
2133       FETCH c_source_orgn_loc INTO ln_vendor_id, ln_vendor_site_id;
2134       CLOSE c_source_orgn_loc;
2135 
2136       ln_vendor_id      := -ln_vendor_id;
2137       ln_vendor_site_id := -ln_vendor_site_id;
2138 
2139     ELSE
2140       lv_statement_id := '5';
2141       p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
2142 
2143       -- Vijay Shankar for Bug#3940588
2144       get_changed_vendor_dtls(
2145         p_receive_trx_id      => r_trx.tax_transaction_id,
2146         p_shipment_line_id    => r_trx.shipment_line_id,
2147         p_vendor_id           => ln_vendor_id,
2148         p_vendor_site_id      => ln_vendor_site_id
2149       );
2150 
2151       ln_vendor_id      := nvl(ln_vendor_id, r_base_trx.vendor_id);
2152       ln_vendor_site_id := nvl(ln_vendor_site_id, r_base_trx.vendor_site_id);
2153     END IF;
2154 
2155     IF r_base_trx.source_document_code = 'RMA' THEN
2156 
2157       IF ln_customer_site_id IS NULL THEN
2158         /*OPEN c_base_trx( jai_rcv_trx_processing_pkg.get_ancestor_id(
2159                             p_transaction_id     => r_trx.transaction_id,
2160                             p_shipment_line_id   => r_trx.shipment_line_id,
2161                             p_required_trx_type  => 'RECEIVE'
2162                          )
2163                        );*/
2164         OPEN c_base_trx(r_trx.tax_transaction_id);
2165         FETCH c_base_trx INTO r_parent_base_trx;
2166         CLOSE c_base_trx;
2167 
2168         ln_customer_site_id := r_parent_base_trx.customer_site_id;
2169       END IF;
2170     END IF;
2171 
2172     IF r_trx.transaction_type = 'CORRECT' THEN
2173       lv_transaction_type := r_trx.parent_transaction_type;
2174     ELSE
2175       lv_transaction_type := r_trx.transaction_type;
2176     END IF;
2177 
2178     IF p_register_entry_type = CENVAT_DEBIT THEN
2179       ln_entry_type := -1;
2180     END IF;
2181 
2182     lv_excise_invoice_no    := r_trx.excise_invoice_no;
2183     ld_excise_invoice_date  := r_trx.excise_invoice_date;
2184 
2185     lv_statement_id := '6';
2186     p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
2187     ln_quantity           := r_trx.quantity * ln_entry_type;
2188     ln_basic_ed           := pr_tax.basic_excise * ln_entry_type;
2189     ln_additional_ed      := (pr_tax.addl_excise + pr_tax.cvd) * ln_entry_type;
2190     ln_additional_cvd      := pr_tax.addl_cvd  * ln_entry_type;  -- Date 06/04/2007 by sacsethi for bug 6109941
2191     ln_other_ed           := pr_tax.other_excise * ln_entry_type;
2192 
2193     if lb_rg_debug then
2194       FND_FILE.put_line(FND_FILE.log,'Before call to jai_cmn_rg_23ac_i_trxs_pkg.insert_row');
2195     end if;
2196 
2197     lv_statement_id := '7';
2198     p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
2199     jai_cmn_rg_23ac_i_trxs_pkg.insert_row(
2200         p_register_id                   => p_register_id,
2201         p_inventory_item_id             => r_trx.inventory_item_id,
2202         p_organization_id               => r_trx.organization_id,
2203         p_quantity_received             => ln_quantity,
2204         p_receipt_id                    => r_trx.transaction_id,
2205         p_transaction_type              => lv_transaction_type,
2206         p_receipt_date                  => r_trx.transaction_date,      -- Why cant this be ShipmentHeader.Receipt_date
2207         p_po_header_id                  => r_base_trx.po_header_id,
2208         p_po_header_date                => r_po_header.creation_date,
2209         p_po_line_id                    => r_base_trx.po_line_id,
2210         p_po_line_location_id           => r_base_trx.po_line_location_id,
2211         p_vendor_id                     => ln_vendor_id,
2212         p_vendor_site_id                => ln_vendor_site_id,
2213         p_customer_id                   => ln_customer_id,
2214         p_customer_site_id              => ln_customer_site_id,
2215         p_goods_issue_id                => NULL,
2216         p_goods_issue_date              => NULL,
2217         p_goods_issue_quantity          => NULL,
2218         p_sales_invoice_id              => NULL,
2219         p_sales_invoice_date            => NULL,
2220         p_sales_invoice_quantity        => NULL,
2221         p_excise_invoice_id             => lv_excise_invoice_no,
2222         p_excise_invoice_date           => ld_excise_invoice_date,
2223         p_oth_receipt_quantity          => NULL,
2224         p_oth_receipt_id                => NULL,
2225         p_oth_receipt_date              => NULL,
2226         p_register_type                 => jai_general_pkg.get_rg_register_type(p_item_class => r_trx.item_class),
2227         p_identification_no             => NULL,
2228         p_identification_mark           => NULL,
2229         p_brand_name                    => NULL,
2230         p_date_of_verification          => NULL,
2231         p_date_of_installation          => NULL,
2232         p_date_of_commission            => NULL,
2233         p_regiser_id_part_ii            => NULL,
2234         p_place_of_install              => NULL,
2235         p_remarks                       => NULL,
2236         p_location_id                   => r_trx.location_id,
2237         p_transaction_uom_code          => r_trx.uom_code,
2238         p_transaction_date              => r_trx.transaction_date,
2239         p_basic_ed                      => ln_basic_ed,
2240         p_additional_ed                 => ln_additional_ed,
2241         p_additional_cvd                => ln_additional_cvd,     -- Date 30/10/2006 Bug 5228046 added by sacsethi
2242         p_other_ed                      => ln_other_ed,
2243         p_charge_account_id             => NULL,
2244         p_transaction_source            => r_base_trx.source_document_code,
2245         p_called_from                   => 'CENVAT_RG_PKG.rg23_part_i_entry',
2246         p_simulate_flag                 => p_simulate_flag,
2247         p_process_status                => p_process_status,
2248         p_process_message               => p_process_message
2249     );
2250 
2251     /*bgowrava for forward porting Bug#5756676..start*/
2252 
2253 			UPDATE JAI_RCV_TRANSACTIONS
2254 				 SET quantity_register_flag  = 'Y',
2255 						 last_updated_by         = fnd_global.user_id,
2256 						 last_update_date        = sysdate,
2257 						 last_update_login       = fnd_global.login_id
2258 			 WHERE transaction_id          = p_transaction_id ;
2259 
2260 		  FND_FILE.put_line(FND_FILE.log, 'Updating quantity register flag to Y');
2261 
2262   /*bgowrava for forward porting Bug#5756676..end*/
2263 
2264     p_codepath := jai_general_pkg.plot_codepath(8, p_codepath, null, 'END'); /* 8 */
2265 
2266   EXCEPTION
2267     WHEN OTHERS THEN
2268       p_process_status := 'E';
2269       p_process_message := 'CENVAT_RG_PKG.rg23_part_i_entry->'||SQLERRM||', StmtId->'||lv_statement_id;
2270       FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
2271       p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END');
2272 
2273   END rg23_part_i_entry;
2274 
2275   PROCEDURE rg23_d_entry(
2276     p_transaction_id    IN NUMBER,
2277     pr_tax                IN  TAX_BREAKUP,
2278     p_register_entry_type       IN VARCHAR2,
2279     p_register_id OUT NOCOPY NUMBER,
2280     p_process_status OUT NOCOPY VARCHAR2,
2281     p_process_message OUT NOCOPY VARCHAR2,
2282     p_simulate_flag     IN VARCHAR2,
2283     p_codepath          IN OUT NOCOPY VARCHAR2
2284   ) IS
2285 
2286     CURSOR c_rma_tax_rate(cp_oe_order_line_id IN NUMBER) IS
2287       SELECT rel.excise_duty_rate
2288       FROM JAI_OM_OE_RMA_LINES rel
2289       WHERE rel.rma_line_id = cp_oe_order_line_id;
2290 
2291     CURSOR c_parent_register_id(cp_receipt_id IN NUMBER, cp_transaction_id IN NUMBER) IS
2292       SELECT register_id
2293       FROM JAI_CMN_RG_23D_TRXS
2294       WHERE receipt_ref = cp_receipt_id
2295       ANd transaction_source_num = cp_transaction_id;
2296 
2297     CURSOR c_tax_rate(cp_shipment_line_id IN NUMBER) IS
2298       SELECT tax_rate
2299       FROM JAI_RCV_LINE_TAXES
2300       WHERE shipment_line_id = cp_shipment_line_id
2301       AND tax_type IN (jai_constants.tax_type_excise,
2302                        jai_constants.tax_type_exc_additional,
2303                        jai_constants.tax_type_exc_other,
2304 		       jai_constants.tax_type_cvd,
2305 		       jai_constants.tax_type_add_cvd)
2306       --AND upper(tax_type) IN ('EXCISE', 'ADDL. EXCISE', 'OTHER EXCISE', 'CVD')
2307       -- we need not include the CESS here, because the rate should correspond to actual tax instead of cess
2308       ORDER BY tax_line_no;
2309 
2310     r_trx                     c_trx%ROWTYPE;
2311     r_base_trx                c_base_trx%ROWTYPE;
2312 
2313     ln_register_id            JAI_CMN_RG_23D_TRXS.register_id%TYPE;
2314     ln_vendor_id              RCV_TRANSACTIONS.vendor_id%TYPE;
2315     ln_vendor_site_id         RCV_TRANSACTIONS.vendor_site_id%TYPE;
2316     lv_excise_invoice_no      JAI_CMN_RG_23D_TRXS.comm_invoice_no%TYPE;
2317     ld_excise_invoice_date    JAI_CMN_RG_23D_TRXS.comm_invoice_date%TYPE;
2318     ln_excise_duty_rate       JAI_CMN_RG_23D_TRXS.excise_duty_rate%TYPE;
2319     lv_transaction_type       RCV_TRANSACTIONS.transaction_type%TYPE;
2320     lv_transaction_uom_code   MTL_UNITS_OF_MEASURE.uom_code%TYPE;
2321     ln_customer_id            RCV_TRANSACTIONS.customer_id%TYPE;
2322     ln_customer_site_id       RCV_TRANSACTIONS.customer_site_id%TYPE;
2323     r_parent_base_trx         c_base_trx%ROWTYPE;
2324 
2325     ln_entry_type             NUMBER;   --File.Sql.35 Cbabu  := 1;
2326     ln_basic_ed               NUMBER;
2327     ln_additional_ed          NUMBER;
2328     ln_other_ed               NUMBER;
2329     ln_additional_cvd         NUMBER;    -- Date 30/10/2006 Bug 5228046 added by sacsethi
2330     ln_cvd                    NUMBER;
2331     ln_duty_amount            NUMBER;
2332     ln_quantity_received      NUMBER;
2333     ln_qty_to_adjust          NUMBER;
2334 
2335     ln_ancestor_reg_id        JAI_CMN_RG_23D_TRXS.register_id%TYPE;
2336     ln_ancestor_trxn_id       RCV_TRANSACTIONS.transaction_id%TYPE;
2337 
2338     lv_statement_id           VARCHAR2(5);
2339 
2340     ln_other_tax_debit        NUMBER;
2341     ln_other_tax_credit       NUMBER;
2342 
2343   BEGIN
2344 
2345     ln_entry_type := 1;
2346 
2347     if lb_rg_debug then
2348 
2349     -- Date 30/10/2006 Bug 5228046 added by sacsethi
2350       FND_FILE.put_line(FND_FILE.log,'^ RG23_D_Entry. Basic:'||pr_tax.basic_excise
2351         ||', Addl:'||pr_tax.addl_excise||', Other:'||pr_tax.other_excise
2352         ||', CVD:'||pr_tax.cvd||', Addl. CVD:'||pr_tax.addl_cvd||', EntryType:'||p_register_entry_type ||', PrcSta:'||p_process_status
2353       );
2354     end if;
2355 
2356     lv_statement_id := '1';
2357     p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'cenvat_rg.23_d', 'START'); /* 1 */
2358     OPEN c_trx(p_transaction_id);
2359     FETCH c_trx INTO r_trx;
2360     CLOSE c_trx;
2361 
2362     lv_statement_id := '2';
2363     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
2364     OPEN c_base_trx(p_transaction_id);
2365     FETCH c_base_trx INTO r_base_trx;
2366     CLOSE c_base_trx;
2367 
2368     ln_customer_id      := r_base_trx.customer_id;
2369     ln_customer_site_id := r_base_trx.customer_site_id;
2370 
2371     IF r_base_trx.source_document_code = 'REQ' THEN
2372       lv_statement_id := '3';
2373       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
2374       OPEN c_source_orgn_loc( r_base_trx.shipment_header_id, r_base_trx.requisition_line_id);
2375       FETCH c_source_orgn_loc INTO ln_vendor_id, ln_vendor_site_id;
2376       CLOSE c_source_orgn_loc;
2377 
2378       ln_vendor_id      := -ln_vendor_id;
2379       ln_vendor_site_id := -ln_vendor_site_id;
2380 
2381     ELSE
2382       ln_vendor_id      := r_base_trx.vendor_id;
2383       ln_vendor_site_id := r_base_trx.vendor_site_id;
2384     END IF;
2385 
2386     lv_excise_invoice_no    := r_trx.excise_invoice_no;
2387     ld_excise_invoice_date  := r_trx.excise_invoice_date;
2388 
2389     IF r_trx.transaction_type = 'CORRECT' THEN
2390       lv_transaction_type := r_trx.parent_transaction_type;
2391     ELSE
2392       lv_transaction_type := r_trx.transaction_type;
2393     END IF;
2394 
2395     IF r_base_trx.source_document_code = 'RMA' THEN
2396       lv_statement_id := '4';
2397       p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
2398       OPEN c_rma_tax_rate(r_base_trx.oe_order_line_id);
2399       FETCH c_rma_tax_rate INTO ln_excise_duty_rate;
2400       CLOSE c_rma_tax_rate;
2401 
2402       IF ln_customer_site_id IS NULL THEN
2403         /*OPEN c_base_trx( jai_rcv_trx_processing_pkg.get_ancestor_id
2404                               (p_transaction_id     => r_trx.transaction_id,
2405                                p_shipment_line_id   => r_trx.shipment_line_id,
2406                                p_required_trx_type  => 'RECEIVE')
2407                        );*/
2408         OPEN c_base_trx(r_trx.tax_transaction_id);
2409         FETCH c_base_trx INTO r_parent_base_trx;
2410         CLOSE c_base_trx;
2411 
2412         ln_customer_site_id := r_parent_base_trx.customer_site_id;
2413       END IF;
2414 
2415     ELSE
2416       lv_statement_id := '4.1';
2417       p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
2418       OPEN c_tax_rate(r_trx.shipment_line_id);
2419       FETCH c_tax_rate INTO ln_excise_duty_rate;
2420       CLOSE c_tax_rate;
2421     END IF;
2422 
2423     lv_statement_id := '5';
2424     p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
2425     lv_transaction_uom_code := r_trx.uom_code;
2426 
2427     IF p_register_entry_type = CENVAT_DEBIT THEN
2428       ln_entry_type := -1;
2429       ln_other_tax_debit    := pr_tax.excise_edu_cess + pr_tax.cvd_edu_cess+nvl(pr_tax.sh_exc_edu_cess,0)+ nvl(pr_tax.sh_cvd_edu_cess,0);/*added pr_tax.sh_exc_edu_cess + pr_tax.sh_cvd_edu_cess by vkaranam for budget 07 impact - bug#5989740*/
2430     ELSIF p_register_entry_type = CENVAT_CREDIT THEN
2431       ln_entry_type := 1;
2432       ln_other_tax_credit   := pr_tax.excise_edu_cess + pr_tax.cvd_edu_cess+nvl(pr_tax.sh_exc_edu_cess,0)+ nvl(pr_tax.sh_cvd_edu_cess,0);/*added pr_tax.sh_exc_edu_cess + pr_tax.sh_cvd_edu_cess by vkaranam for budget 07 impact - bug#5989740*/
2433     END IF;
2434 
2435     ln_quantity_received  := r_trx.quantity * ln_entry_type;
2436     ln_qty_to_adjust      := ln_quantity_received;
2437 
2438     ln_basic_ed           := pr_tax.basic_excise * ln_entry_type;
2439 
2440     /* Bug 4516667. Added by Lakshmi.
2441      Removed CVD from additional amount. This is accidentally added to
2442      additional excise */
2443 
2444     ln_additional_ed      := pr_tax.addl_excise  * ln_entry_type;
2445     ln_other_ed           := pr_tax.other_excise * ln_entry_type;
2446     ln_cvd                := pr_tax.cvd * ln_entry_type;
2447 
2448     -- Date 30/10/2006 Bug 5228046 added by sacsethi
2449     -- START BUG 5228046
2450     ln_additional_cvd     := pr_tax.addl_cvd * ln_entry_type;
2451     ln_duty_amount        := ln_basic_ed + ln_additional_ed + ln_other_ed + ln_cvd; /*addl. CVD excluded for bug 5752026 (FP for bug 5747435)*/
2452     -- END BUG 5228046
2453 
2454     IF ln_qty_to_adjust < 0 OR lv_transaction_type = 'RETURN TO VENDOR' THEN
2455       ln_qty_to_adjust := 0;
2456     END IF;
2457 
2458     if lb_rg_debug then
2459       FND_FILE.put_line(FND_FILE.log,'Calling jai_cmn_rg_23d_trxs_pkg.insert_row');
2460     end if;
2461 
2462     lv_statement_id := '6';
2463     p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
2464     jai_cmn_rg_23d_trxs_pkg.insert_row(
2465         p_register_id                   => p_register_id,
2466         p_organization_id               => r_trx.organization_id,
2467         p_location_id                   => r_trx.location_id,
2468         p_transaction_type              => lv_transaction_type,
2469         p_receipt_id                    => p_transaction_id,
2470         p_quantity_received             => ln_quantity_received,
2471         p_inventory_item_id             => r_trx.inventory_item_id,
2472         p_subinventory                  => r_base_trx.subinventory,
2473         p_reference_line_id             => r_trx.shipment_line_id,
2474         p_transaction_uom_code          => lv_transaction_uom_code,
2475         p_customer_id                   => ln_customer_id,
2476         p_bill_to_site_id               => NULL,
2477         p_ship_to_site_id               => ln_customer_site_id,
2478         p_quantity_issued               => NULL,
2479         p_register_code                 => NULL,
2480         p_released_date                 => NULL,
2481         p_comm_invoice_no               => lv_excise_invoice_no,
2482         p_comm_invoice_date             => ld_excise_invoice_date,
2483         p_receipt_boe_num               => jai_general_pkg.get_matched_boe_no(p_transaction_id),
2484         p_oth_receipt_id                => NULL,
2485         p_oth_receipt_date              => NULL,
2486         p_oth_receipt_quantity          => NULL,
2487         p_remarks                       => 'Live-Trx/PrntTrx:'||r_trx.transaction_id||'/'||r_trx.parent_transaction_id,
2488         p_qty_to_adjust                 => ln_qty_to_adjust,
2489         /* Bug 4516667.
2490          As per discussion with Vikram and Gadde rounding to 4 decimal places
2491 	 for rate per unit */
2492         p_rate_per_unit                 => round(ln_duty_amount/ln_quantity_received,4),
2493         p_excise_duty_rate              => ln_excise_duty_rate,
2494         p_charge_account_id             => NULL,    -- this will be updated later by calling update procedure
2495         p_duty_amount                   => ln_duty_amount,
2496         p_receipt_date                  => r_trx.transaction_date,
2497         p_goods_issue_id                => NULL,
2498         p_goods_issue_date              => NULL,
2499         p_goods_issue_quantity          => NULL,
2500         p_transaction_date              => r_trx.transaction_date,
2501         p_basic_ed                      => ln_basic_ed,
2502         p_additional_ed                 => ln_additional_ed,
2503         p_additional_cvd                => ln_additional_cvd,  -- Date 30/10/2006 Bug 5228046 added by sacsethi
2504         p_other_ed                      => ln_other_ed,
2505         p_cvd                           => ln_cvd,
2506         p_vendor_id                     => ln_vendor_id,
2507         p_vendor_site_id                => ln_vendor_site_id,
2508         p_receipt_num                   => r_trx.receipt_num,
2509         p_attribute1                    => NULL,
2510         p_attribute2                    => NULL,
2511         p_attribute3                    => NULL,
2512         p_attribute4                    => NULL,
2513         p_attribute5                    => NULL,
2514         p_consignee                     => NULL,
2515         p_manufacturer_name             => NULL,
2516         p_manufacturer_address          => NULL,
2517         p_manufacturer_rate_amt_per_un  => NULL,
2518         p_qty_received_from_manufactur  => NULL,
2519         p_tot_amt_paid_to_manufacturer  => NULL,
2520         p_other_tax_credit              => ln_other_tax_credit,
2521         p_other_tax_debit               => ln_other_tax_debit,
2522         p_transaction_source            => r_base_trx.source_document_code,
2523         p_called_from                   => 'CENVAT_RG_PKG.rg23_d_entry',
2524         p_simulate_flag                 => p_simulate_flag,
2525         p_process_status                => p_process_status,
2526         p_process_message               => p_process_message
2527     );
2528 
2529     p_codepath := jai_general_pkg.plot_codepath(7.1, p_codepath);
2530     lv_statement_id := '6.1';
2531     -- Vijay Shankar for Bug#3940588 EDUCATION CESS
2532     IF pr_tax.excise_edu_cess <> 0 THEN
2533       IF p_register_entry_type = CENVAT_DEBIT THEN
2534         ln_other_tax_debit  := pr_tax.excise_edu_cess;
2535       ELSE
2536         ln_other_tax_credit := pr_tax.excise_edu_cess;
2537       END IF;
2538       jai_rcv_excise_processing_pkg.other_cenvat_rg_recording(
2539           p_source_register     => jai_constants.reg_rg23d,
2540           p_source_register_id  => p_register_id,
2541           p_tax_type            => jai_constants.tax_type_exc_edu_cess,
2542           p_credit              => ln_other_tax_credit,
2543           p_debit               => ln_other_tax_debit,
2544           p_process_status      => p_process_status,
2545           p_process_message     => p_process_message
2546        );
2547     END IF;
2548 
2549     lv_statement_id := '6.2';
2550     p_codepath := jai_general_pkg.plot_codepath(7.2, p_codepath);
2551 
2552     IF pr_tax.cvd_edu_cess <> 0 THEN
2553       IF p_register_entry_type = CENVAT_DEBIT THEN
2554         ln_other_tax_debit  := pr_tax.cvd_edu_cess;
2555       ELSE
2556         ln_other_tax_credit := pr_tax.cvd_edu_cess;
2557       END IF;
2558       jai_rcv_excise_processing_pkg.other_cenvat_rg_recording(
2559           p_source_register     => jai_constants.reg_rg23d,
2560           p_source_register_id  => p_register_id,
2561           p_tax_type            => jai_constants.tax_type_cvd_edu_cess,
2562           p_credit              => ln_other_tax_credit,
2563           p_debit               => ln_other_tax_debit,
2564           p_process_status      => p_process_status,
2565           p_process_message     => p_process_message
2566        );
2567     END IF;
2568  /*added the following by vkaranam for budget 07 impact - bug#5989740*/
2569   --start
2570   lv_statement_id := '6.3';
2571 	p_codepath := jai_general_pkg.plot_codepath(7.3, p_codepath);
2572 
2573 	 IF pr_tax.sh_exc_edu_cess <> 0 THEN
2574 	    IF p_register_entry_type = CENVAT_DEBIT THEN
2575 	      ln_other_tax_debit  := pr_tax.sh_exc_edu_cess;
2576 	    ELSE
2577 	      ln_other_tax_credit := pr_tax.sh_exc_edu_cess;
2578 	    END IF;
2579 
2580 	    jai_rcv_excise_processing_pkg.other_cenvat_rg_recording(
2581 	        p_source_register     => jai_constants.reg_rg23d,
2582 	        p_source_register_id  => p_register_id,
2583 	        p_tax_type            => jai_constants.tax_type_sh_exc_edu_cess,
2584 	        p_credit              => ln_other_tax_credit,
2585 	        p_debit               => ln_other_tax_debit,
2586 	        p_process_status      => p_process_status,
2587 	        p_process_message     => p_process_message
2588 	     );
2589   END IF;
2590 
2591   lv_statement_id := '6.4';
2592 	p_codepath := jai_general_pkg.plot_codepath(7.4, p_codepath);
2593 
2594 	 IF pr_tax.sh_cvd_edu_cess <> 0 THEN
2595 			IF p_register_entry_type = CENVAT_DEBIT THEN
2596 				ln_other_tax_debit  := pr_tax.sh_cvd_edu_cess;
2597 			ELSE
2598 				ln_other_tax_credit := pr_tax.sh_cvd_edu_cess;
2599 			END IF;
2600 			  jai_rcv_excise_processing_pkg.other_cenvat_rg_recording(
2601 					p_source_register     => jai_constants.reg_rg23d,
2602 					p_source_register_id  => p_register_id,
2603 					p_tax_type            => jai_constants.tax_type_sh_cvd_edu_cess,
2604 					p_credit              => ln_other_tax_credit,
2605 					p_debit               => ln_other_tax_debit,
2606 					p_process_status      => p_process_status,
2607 					p_process_message     => p_process_message
2608  			 );
2609 	END IF;
2610 	--end bug#5989740
2611 
2612 
2613     lv_statement_id := '6.5';
2614     p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
2615 
2616     -- following code to update parent RG23D entry with transaction qty
2617     IF lv_transaction_type = 'RETURN TO VENDOR' OR ln_quantity_received < 0 THEN
2618       FND_FILE.put_line(FND_FILE.log, 'To Update Qty_To_Adjust field of RG23D Table' );
2619 
2620       lv_statement_id := '7';
2621       p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9 */
2622       ln_quantity_received  := nvl(r_base_trx.primary_quantity, r_base_trx.quantity);
2623 
2624       -- this is to reduce main RG23D entry of RECEIVE transaction incase of -ve RECEIVE Correction
2625       IF lv_transaction_type = 'RECEIVE' THEN
2626         ln_quantity_received := -ln_quantity_received;
2627       END IF;
2628 
2629       ln_ancestor_trxn_id   := jai_rcv_trx_processing_pkg.get_ancestor_id(
2630                                   p_transaction_id    => r_trx.transaction_id,
2631                                   p_shipment_line_id  => r_trx.shipment_line_id,
2632                                   p_required_trx_type => 'RECEIVE'
2633                                );
2634 
2635       lv_statement_id := '8';
2636       p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10 */
2637       OPEN c_parent_register_id(ln_ancestor_trxn_id, 18);
2638       FETCH c_parent_register_id INTO ln_ancestor_reg_id;
2639       CLOSE c_parent_register_id;
2640 
2641       if lb_rg_debug then
2642         FND_FILE.put_line(FND_FILE.log,'Calling jai_cmn_rg_23d_trxs_pkg.update_qty_to_adjust');
2643       end if;
2644 
2645       lv_statement_id := '9';
2646       p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11 */
2647       jai_cmn_rg_23d_trxs_pkg.update_qty_to_adjust(
2648           p_register_id     => ln_ancestor_reg_id,
2649           p_quantity        => ln_quantity_received ,
2650           p_simulate_flag   => p_simulate_flag,
2651           p_process_status  => p_process_status,
2652           p_process_message => p_process_message
2653       );
2654 
2655     END IF;
2656 
2657     p_codepath := jai_general_pkg.plot_codepath(12, p_codepath, null, 'END'); /* 12 */
2658 
2659   EXCEPTION
2660     WHEN OTHERS THEN
2661       p_process_status := 'E';
2662       p_process_message := 'CENVAT_RG_PKG.rg23_d_entry->'||SQLERRM||', StmtId->'||lv_statement_id;
2663       FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
2664       p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END');
2665 
2666   END rg23_d_entry;
2667 
2668   PROCEDURE rg23_part_ii_entry(
2669     p_transaction_id        IN        NUMBER,
2670     pr_tax                  IN        TAX_BREAKUP,
2671     p_part_i_register_id    IN        NUMBER,
2672     p_register_entry_type   IN        VARCHAR2,
2673     p_reference_num         IN        VARCHAR2,
2674     p_register_id OUT NOCOPY NUMBER,
2675     p_process_status OUT NOCOPY VARCHAR2,
2676     p_process_message OUT NOCOPY VARCHAR2,
2677     p_simulate_flag         IN        VARCHAR2,
2678     p_codepath              IN OUT NOCOPY VARCHAR2
2679   ) IS
2680 
2681     r_trx                     c_trx%ROWTYPE;
2682     r_base_trx                c_base_trx%ROWTYPE;
2683     r_parent_trx              c_trx%ROWTYPE;
2684 
2685     ln_register_id            JAI_CMN_RG_23AC_II_TRXS.register_id%TYPE;
2686     ln_vendor_id              RCV_TRANSACTIONS.vendor_id%TYPE;
2687     ln_vendor_site_id         RCV_TRANSACTIONS.vendor_site_id%TYPE;
2688     lv_transaction_type       RCV_TRANSACTIONS.transaction_type%TYPE;
2689     lv_excise_invoice_no      JAI_CMN_RG_23AC_II_TRXS.excise_invoice_no%TYPE;
2690     ld_excise_invoice_date    JAI_CMN_RG_23AC_II_TRXS.excise_invoice_date%TYPE;
2691     ln_customer_id            RCV_TRANSACTIONS.customer_id%TYPE;
2692     ln_customer_site_id       RCV_TRANSACTIONS.customer_site_id%TYPE;
2693     r_parent_base_trx         c_base_trx%ROWTYPE;
2694 
2695     ln_cr_basic               JAI_CMN_RG_23AC_II_TRXS.cr_basic_ed%TYPE;
2696     ln_cr_addl                JAI_CMN_RG_23AC_II_TRXS.cr_additional_ed%TYPE;
2697     ln_cr_other               JAI_CMN_RG_23AC_II_TRXS.cr_other_ed%TYPE;
2698     ln_dr_basic               JAI_CMN_RG_23AC_II_TRXS.dr_basic_ed%TYPE;
2699     ln_dr_addl                JAI_CMN_RG_23AC_II_TRXS.dr_additional_ed%TYPE;
2700     ln_dr_other               JAI_CMN_RG_23AC_II_TRXS.dr_other_ed%TYPE;
2701 
2702 -- Date 04/06/2007 by sacsethi for bug 5228046
2703     ln_cr_addl_cvd            JAI_CMN_RG_23AC_II_TRXS.cr_additional_cvd%TYPE;
2704     ln_dr_addl_cvd            JAI_CMN_RG_23AC_II_TRXS.dr_additional_cvd%TYPE;
2705 
2706 
2707     lv_statement_id           VARCHAR2(5);
2708     ln_other_tax_credit       NUMBER;
2709     ln_other_tax_debit        NUMBER;
2710     lv_register_type          JAI_CMN_RG_23AC_II_TRXS.register_type%TYPE;
2711     lv_source_register        JAI_CMN_RG_OTHERS.source_register%TYPE;
2712 
2713   BEGIN
2714 
2715     if lb_rg_debug then
2716       FND_FILE.put_line(FND_FILE.log,'^ RG23_PART_II_Entry. Basic:'||pr_tax.basic_excise
2717         ||', Addl:'||pr_tax.addl_excise||', Other:'||pr_tax.other_excise
2718         ||', CVD:'||pr_tax.cvd||', ExCes:'||pr_tax.excise_edu_cess||', CvdCes:'||pr_tax.cvd_edu_cess
2719         ||', EntryType:'||p_register_entry_type ||', PrcSta:'||p_process_status
2720         ||', Part1Id:'||p_part_i_register_id||', RefNo:'||p_reference_num
2721       );
2722     end if;
2723 
2724     lv_statement_id := '1';
2725     p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'cenvat_rg.23_part_ii', 'START'); /* 1 */
2726     OPEN c_trx(p_transaction_id);
2727     FETCH c_trx INTO r_trx;
2728     CLOSE c_trx;
2729 
2730     lv_statement_id := '2';
2731     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
2732     OPEN c_base_trx(p_transaction_id);
2733     FETCH c_base_trx INTO r_base_trx;
2734     CLOSE c_base_trx;
2735 
2736     ln_customer_id      := r_base_trx.customer_id;
2737     ln_customer_site_id := r_base_trx.customer_site_id;
2738 
2739     IF r_base_trx.source_document_code = 'REQ' THEN
2740       lv_statement_id := '3';
2741       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
2742       OPEN c_source_orgn_loc( r_base_trx.shipment_header_id, r_base_trx.requisition_line_id);
2743       FETCH c_source_orgn_loc INTO ln_vendor_id, ln_vendor_site_id;
2744       CLOSE c_source_orgn_loc;
2745 
2746       ln_vendor_id      := -ln_vendor_id;
2747       ln_vendor_site_id := -ln_vendor_site_id;
2748 
2749     ELSE
2750 
2751       -- Vijay Shankar for Bug#3940588
2752       get_changed_vendor_dtls(
2753         p_receive_trx_id      => r_trx.tax_transaction_id,
2754         p_shipment_line_id    => r_trx.shipment_line_id,
2755         p_vendor_id           => ln_vendor_id,
2756         p_vendor_site_id      => ln_vendor_site_id
2757       );
2758 
2759       ln_vendor_id      := nvl(ln_vendor_id, r_base_trx.vendor_id);
2760       ln_vendor_site_id := nvl(ln_vendor_site_id, r_base_trx.vendor_site_id);
2761 
2762     END IF;
2763 
2764     IF r_base_trx.source_document_code = 'RMA' THEN
2765       IF ln_customer_site_id IS NULL THEN
2766         /*OPEN c_base_trx( jai_rcv_trx_processing_pkg.get_ancestor_id
2767                               (p_transaction_id     => r_trx.transaction_id,
2768                                p_shipment_line_id   => r_trx.shipment_line_id,
2769                                p_required_trx_type  => 'RECEIVE')
2770                        );*/
2771         OPEN c_base_trx(r_trx.tax_transaction_id);
2772         FETCH c_base_trx INTO r_parent_base_trx;
2773         CLOSE c_base_trx;
2774 
2775         ln_customer_site_id := r_parent_base_trx.customer_site_id;
2776       END IF;
2777     END IF;
2778 
2779     IF r_trx.transaction_type = 'CORRECT' THEN
2780       lv_transaction_type := r_trx.parent_transaction_type;
2781     ELSE
2782       lv_transaction_type := r_trx.transaction_type;
2783     END IF;
2784 
2785     -- p_reference_num will contain parent RECEIVE trx_id incase of PARENT REGULAR 50% that is passed during RTV of CGIN item
2786     IF lv_transaction_type = 'RETURN TO VENDOR' AND p_reference_num IN (CGIN_FIRST_CLAIM, CGIN_SECOND_CLAIM) THEN
2787       OPEN c_trx(to_number(p_reference_num));
2788       FETCH c_trx INTO r_parent_trx;
2789       CLOSE c_trx;
2790       lv_excise_invoice_no    := r_parent_trx.excise_invoice_no;
2791       ld_excise_invoice_date  := r_parent_trx.excise_invoice_date;
2792     ELSE
2793       lv_excise_invoice_no    := r_trx.excise_invoice_no;
2794       ld_excise_invoice_date  := r_trx.excise_invoice_date;
2795     END IF;
2796 
2797     lv_statement_id := '4';
2798     p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
2799     IF p_register_entry_type = CENVAT_DEBIT THEN
2800       ln_dr_basic   := pr_tax.basic_excise;
2801       ln_dr_addl    := pr_tax.addl_excise + pr_tax.cvd;
2802       ln_dr_other   := pr_tax.other_excise;
2803       ln_dr_addl_cvd := pr_tax.addl_cvd; --Date 30/10/2006 Bug 5228046 added by sacsethi
2804       ln_other_tax_debit  := pr_tax.excise_edu_cess + pr_tax.cvd_edu_cess + nvl(pr_tax.sh_exc_edu_cess,0)+ nvl(pr_tax.sh_cvd_edu_cess,0); --Bgowrava for Bug #6071509 ,Added SH related cess
2805     ELSE
2806       ln_cr_basic   := pr_tax.basic_excise;
2807       ln_cr_addl    := pr_tax.addl_excise + pr_tax.cvd;
2808       ln_cr_other   := pr_tax.other_excise;
2809       ln_cr_addl_cvd := pr_tax.addl_cvd; --Date 30/10/2006 Bug 5228046 added by sacsethi
2810       ln_other_tax_credit := pr_tax.excise_edu_cess + pr_tax.cvd_edu_cess+ nvl(pr_tax.sh_exc_edu_cess,0)+ nvl(pr_tax.sh_cvd_edu_cess,0); --Bgowrava for Bug #6071509 ,Added SH related cess
2811     END IF;
2812 
2813     if lb_rg_debug then
2814       FND_FILE.put_line(FND_FILE.log,'Calling jai_cmn_rg_23ac_ii_pkg.insert_row');
2815     end if;
2816 
2817     lv_register_type := jai_general_pkg.get_rg_register_type(r_trx.item_class);
2818     if lv_register_type = jai_constants.register_type_a then
2819       lv_source_register := jai_constants.reg_rg23a_2;
2820     else
2821       lv_source_register := jai_constants.reg_rg23c_2;
2822     end if;
2823 
2824     lv_statement_id := '5';
2825     p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
2826     jai_cmn_rg_23ac_ii_pkg.insert_row(
2827         p_register_id                   => p_register_id,
2828         p_inventory_item_id             => r_trx.inventory_item_id,
2829         p_organization_id               => r_trx.organization_id,
2830         p_receipt_id                    => r_trx.transaction_id,
2831         p_receipt_date                  => r_trx.transaction_date,
2832         p_cr_basic_ed                   => ln_cr_basic,
2833         p_cr_additional_ed              => ln_cr_addl,
2834         p_cr_additional_cvd              => ln_cr_addl_cvd,  -- Date 30/10/2006 Bug 5228046 added by sacsethi
2835         p_cr_other_ed                   => ln_cr_other,
2836         p_dr_basic_ed                   => ln_dr_basic,
2837         p_dr_additional_ed              => ln_dr_addl,
2838         p_dr_additional_cvd              => ln_dr_addl_cvd, -- Date 30/10/2006 Bug 5228046 added by sacsethi
2839         p_dr_other_ed                   => ln_dr_other,
2840         p_excise_invoice_no             => lv_excise_invoice_no,
2841         p_excise_invoice_date           => ld_excise_invoice_date,
2842         p_register_type                 => lv_register_type,
2843         p_remarks                       => 'Live-Trx/PrntTrx:'||r_trx.transaction_id||'/'||r_trx.parent_transaction_id,
2844         p_vendor_id                     => ln_vendor_id,
2845         p_vendor_site_id                => ln_vendor_site_id,
2846         p_customer_id                   => ln_customer_id,
2847         p_customer_site_id              => ln_customer_site_id,
2848         p_location_id                   => r_trx.location_id,
2849         p_transaction_date              => SYSDATE, --r_trx.transaction_date, --Changed by Sanjikum for Bug #4293421
2850         p_charge_account_id             => NULL,
2851         p_register_id_part_i            => p_part_i_register_id,
2852         p_reference_num                 => p_reference_num,
2853         p_rounding_id                   => NULL,
2854         p_other_tax_credit              => ln_other_tax_credit,
2855         p_other_tax_debit               => ln_other_tax_debit,
2856         p_transaction_type              => lv_transaction_type,
2857         p_transaction_source            => r_base_trx.source_document_code,
2858         p_called_from                   => 'CENVAT_RG_PKG.rg23_part_ii_entry',
2859         p_simulate_flag                 => p_simulate_flag,
2860         p_process_status                => p_process_status,
2861         p_process_message               => p_process_message
2862     );
2863 
2864     p_codepath := jai_general_pkg.plot_codepath(6, p_codepath);
2865 
2866     -- Vijay Shankar for Bug#3940588 EDUCATION CESS
2867     IF pr_tax.excise_edu_cess <> 0 THEN
2868       IF p_register_entry_type = CENVAT_DEBIT THEN
2869         ln_other_tax_debit  := pr_tax.excise_edu_cess;
2870       ELSE
2871         ln_other_tax_credit := pr_tax.excise_edu_cess;
2872       END IF;
2873       jai_rcv_excise_processing_pkg.other_cenvat_rg_recording(
2874           p_source_register     => lv_source_register,
2875           p_source_register_id  => p_register_id,
2876           p_tax_type            => jai_constants.tax_type_exc_edu_cess,
2877           p_credit              => ln_other_tax_credit,
2878           p_debit               => ln_other_tax_debit,
2879           p_process_status      => p_process_status,
2880           p_process_message     => p_process_message
2881        );
2882     END IF;
2883 
2884     p_codepath := jai_general_pkg.plot_codepath(7, p_codepath);
2885 
2886     IF pr_tax.cvd_edu_cess <> 0 THEN
2887       IF p_register_entry_type = CENVAT_DEBIT THEN
2888         ln_other_tax_debit  := pr_tax.cvd_edu_cess;
2889       ELSE
2890         ln_other_tax_credit := pr_tax.cvd_edu_cess;
2891       END IF;
2892       jai_rcv_excise_processing_pkg.other_cenvat_rg_recording(
2893           p_source_register     => lv_source_register,
2894           p_source_register_id  => p_register_id,
2895           p_tax_type            => jai_constants.tax_type_cvd_edu_cess,
2896           p_credit              => ln_other_tax_credit,
2897           p_debit               => ln_other_tax_debit,
2898           p_process_status      => p_process_status,
2899           p_process_message     => p_process_message
2900        );
2901     END IF;
2902 
2903     --For SH EDU CESS
2904     -- START,Bgowrava for Bug#6071509
2905     IF pr_tax.sh_exc_edu_cess <> 0 THEN
2906 		      IF p_register_entry_type = CENVAT_DEBIT THEN
2907 		        ln_other_tax_debit  := pr_tax.sh_exc_edu_cess;
2908 		      ELSE
2909 		        ln_other_tax_credit := pr_tax.sh_exc_edu_cess;
2910 		      END IF;
2911 		      jai_rcv_excise_processing_pkg.other_cenvat_rg_recording(
2912 		          p_source_register     => lv_source_register,
2913 		          p_source_register_id  => p_register_id,
2914 		          p_tax_type            => jai_constants.tax_type_sh_exc_edu_cess,
2915 		          p_credit              => ln_other_tax_credit,
2916 		          p_debit               => ln_other_tax_debit,
2917 		          p_process_status      => p_process_status,
2918 		          p_process_message     => p_process_message
2919 		       );
2920 		    END IF;
2921 
2922 		    p_codepath := jai_general_pkg.plot_codepath(7, p_codepath);
2923 
2924 		    IF pr_tax.sh_cvd_edu_cess <> 0 THEN
2925 		      IF p_register_entry_type = CENVAT_DEBIT THEN
2926 		        ln_other_tax_debit  := pr_tax.sh_cvd_edu_cess;
2927 		      ELSE
2928 		        ln_other_tax_credit := pr_tax.sh_cvd_edu_cess;
2929 		      END IF;
2930 		      jai_rcv_excise_processing_pkg.other_cenvat_rg_recording(
2931 		          p_source_register     => lv_source_register,
2932 		          p_source_register_id  => p_register_id,
2933 		          p_tax_type            => jai_constants.tax_type_sh_cvd_edu_cess,
2934 		          p_credit              => ln_other_tax_credit,
2935 		          p_debit               => ln_other_tax_debit,
2936 		          p_process_status      => p_process_status,
2937 		          p_process_message     => p_process_message
2938 		       );
2939     END IF;
2940 
2941      -- END,Bgowrava for Bug#6071509
2942 
2943     p_codepath := jai_general_pkg.plot_codepath(8, p_codepath, null, 'END');
2944 
2945   EXCEPTION
2946     WHEN OTHERS THEN
2947       p_process_status := 'E';
2948       p_process_message := 'CENVAT_RG_PKG.rg23_part_ii_entry->'||SQLERRM||', StmtId->'||lv_statement_id;
2949       FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
2950       p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END');
2951 
2952   END rg23_part_ii_entry;
2953 
2954   PROCEDURE pla_entry(
2955     p_transaction_id        IN  NUMBER,
2956     pr_tax                  IN  TAX_BREAKUP,
2957     p_register_entry_type   IN  VARCHAR2,
2958     p_register_id OUT NOCOPY NUMBER,
2959     p_process_status OUT NOCOPY VARCHAR2,
2960     p_process_message OUT NOCOPY VARCHAR2,
2961     p_simulate_flag         IN  VARCHAR2,
2962     p_codepath              IN OUT NOCOPY VARCHAR2
2963   ) IS
2964 
2965     r_trx                     c_trx%ROWTYPE;
2966     r_base_trx                c_base_trx%ROWTYPE;
2967     r_orgn_info               c_orgn_info%ROWTYPE;
2968 
2969     ln_register_id            JAI_CMN_RG_PLA_TRXS.register_id%TYPE;
2970     ln_vendor_id              RCV_TRANSACTIONS.vendor_id%TYPE;
2971     ln_vendor_site_id         RCV_TRANSACTIONS.vendor_site_id%TYPE;
2972     lv_excise_invoice_no      JAI_CMN_RG_PLA_TRXS.DR_INVOICE_NO%TYPE;
2973     ld_excise_invoice_date    JAI_CMN_RG_PLA_TRXS.dr_invoice_date%TYPE;
2974     lv_transaction_type       RCV_TRANSACTIONS.transaction_type%TYPE;
2975 
2976     ln_cr_basic               JAI_CMN_RG_PLA_TRXS.cr_basic_ed%TYPE;
2977     ln_cr_addl                JAI_CMN_RG_PLA_TRXS.cr_additional_ed%TYPE;
2978     ln_cr_other               JAI_CMN_RG_PLA_TRXS.cr_other_ed%TYPE;
2979     ln_dr_basic               JAI_CMN_RG_PLA_TRXS.dr_basic_ed%TYPE;
2980     ln_dr_addl                JAI_CMN_RG_PLA_TRXS.dr_additional_ed%TYPE;
2981     ln_dr_other               JAI_CMN_RG_PLA_TRXS.dr_other_ed%TYPE;
2982 
2983     lv_statement_id           VARCHAR2(5);
2984     ln_other_tax_credit       NUMBER;
2985     ln_other_tax_debit        NUMBER;
2986 
2987   BEGIN
2988 
2989     if lb_rg_debug then
2990     FND_FILE.put_line(FND_FILE.log,'^ PLA_Entry. Basic:'||pr_tax.basic_excise
2991       ||', Addl:'||pr_tax.addl_excise||', Other:'||pr_tax.other_excise||', ExCes:'||pr_tax.excise_edu_cess||', CvdCes:'||pr_tax.cvd_edu_cess
2992       ||', SH_ExCes:'||pr_tax.sh_exc_edu_cess||', SH_CvdCes:'||pr_tax.sh_cvd_edu_cess /*added by vkaranam for bug #5989740*/
2993       ||', CVD:'||pr_tax.cvd
2994       ||', EntryType:'||p_register_entry_type ||', PrcSta:'||p_process_status
2995     );
2996    end if;
2997 
2998     if lb_rg_debug then
2999       FND_FILE.put_line(FND_FILE.log,'^ PLA_Entry');
3000     end if;
3001 
3002     lv_statement_id := '1';
3003     p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'cenvat_rg.pla', 'START'); /* 1 */
3004     OPEN c_trx(p_transaction_id);
3005     FETCH c_trx INTO r_trx;
3006     CLOSE c_trx;
3007 
3008     lv_statement_id := '2';
3009     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
3010     OPEN c_base_trx(p_transaction_id);
3011     FETCH c_base_trx INTO r_base_trx;
3012     CLOSE c_base_trx;
3013 
3014     IF r_base_trx.source_document_code = 'REQ' THEN
3015       lv_statement_id := '3';
3016       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
3017 
3018       OPEN c_source_orgn_loc( r_base_trx.shipment_header_id, r_base_trx.requisition_line_id);
3019       FETCH c_source_orgn_loc INTO ln_vendor_id, ln_vendor_site_id;
3020       CLOSE c_source_orgn_loc;
3021 
3022       ln_vendor_id      := -ln_vendor_id;
3023       ln_vendor_site_id := -ln_vendor_site_id;
3024 
3025     ELSE
3026 
3027       -- Vijay Shankar for Bug#3940588
3028       get_changed_vendor_dtls(
3029         p_receive_trx_id      => r_trx.tax_transaction_id,
3030         p_shipment_line_id    => r_trx.shipment_line_id,
3031         p_vendor_id           => ln_vendor_id,
3032         p_vendor_site_id      => ln_vendor_site_id
3033       );
3034 
3035       ln_vendor_id      := nvl(ln_vendor_id, r_base_trx.vendor_id);
3036       ln_vendor_site_id := nvl(ln_vendor_site_id, r_base_trx.vendor_site_id);
3037 
3038     END IF;
3039 
3040     IF r_trx.transaction_type = 'CORRECT' THEN
3041       lv_transaction_type := r_trx.parent_transaction_type;
3042     ELSE
3043       lv_transaction_type := r_trx.transaction_type;
3044     END IF;
3045 
3046     lv_excise_invoice_no    := r_trx.excise_invoice_no;
3047     ld_excise_invoice_date  := r_trx.excise_invoice_date;
3048 
3049     lv_statement_id := '4';
3050     p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
3051     IF p_register_entry_type = CENVAT_DEBIT THEN
3052       ln_dr_basic   := pr_tax.basic_excise;
3053       ln_dr_addl    := pr_tax.addl_excise + pr_tax.cvd;
3054       ln_dr_other   := pr_tax.other_excise;
3055      ln_other_tax_debit  := pr_tax.excise_edu_cess + pr_tax.cvd_edu_cess+nvl(pr_tax.sh_exc_edu_cess,0)+ nvl(pr_tax.sh_cvd_edu_cess,0);/*added pr_tax.sh_exc_edu_cess + pr_tax.sh_cvd_edu_cess by vkaranam for budget 07 impact - bug#5989740*/
3056     ELSE
3057       ln_cr_basic   := pr_tax.basic_excise;
3058       ln_cr_addl    := pr_tax.addl_excise + pr_tax.cvd;
3059       ln_cr_other   := pr_tax.other_excise;
3060       ln_other_tax_credit  := pr_tax.excise_edu_cess + pr_tax.cvd_edu_cess+nvl(pr_tax.sh_exc_edu_cess,0)+ nvl(pr_tax.sh_cvd_edu_cess,0);/*added pr_tax.sh_exc_edu_cess + pr_tax.sh_cvd_edu_cess by vkaranam for budget 07 impact - bug#5989740*/
3061     END IF;
3062 
3063     if lb_rg_debug then
3064       FND_FILE.put_line(FND_FILE.log,'Calling jai_cmn_rg_pla_trxs_pkg.insert_row');
3065     end if;
3066 
3067     lv_statement_id := '5';
3068     p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
3069     jai_cmn_rg_pla_trxs_pkg.insert_row(
3070         p_register_id                   => p_register_id,
3071         p_tr6_challan_no                => NULL,
3072         p_tr6_challan_date              => NULL,
3073         p_cr_basic_ed                   => ln_cr_basic,
3074         p_cr_additional_ed              => ln_cr_addl,
3075         p_cr_other_ed                   => ln_cr_other,
3076         p_ref_document_id               => r_trx.transaction_id,
3077         p_ref_document_date             => r_trx.transaction_date,
3078         p_dr_invoice_id                 => lv_excise_invoice_no,
3079         p_dr_invoice_date               => ld_excise_invoice_date,
3080         p_dr_basic_ed                   => ln_dr_basic,
3081         p_dr_additional_ed              => ln_dr_addl,
3082         p_dr_other_ed                   => ln_dr_other,
3083         p_organization_id               => r_trx.organization_id,
3084         p_location_id                   => r_trx.location_id,
3085         p_bank_branch_id                => NULL,
3086         p_entry_date                    => NULL,
3087         p_inventory_item_id             => r_trx.inventory_item_id,
3088         p_vendor_cust_flag              => 'V',
3089         p_vendor_id                     => ln_vendor_id,
3090         p_vendor_site_id                => ln_vendor_site_id,
3091         p_excise_invoice_no             => lv_excise_invoice_no,
3092         p_remarks                       => 'Live-Trx/PrntTrx:'||r_trx.transaction_id||'/'||r_trx.parent_transaction_id,
3093         p_transaction_date              => r_trx.transaction_date,
3094         p_charge_account_id             => NULL,
3095         p_other_tax_credit              => ln_other_tax_credit,
3096         p_other_tax_debit               => ln_other_tax_debit,
3097         p_transaction_type              => lv_transaction_type,
3098         p_transaction_source            => r_base_trx.source_document_code,
3099         p_called_from                   => 'cenvat_RG_PKG.pla_entry',
3100         p_simulate_flag                 => p_simulate_flag,
3101         p_process_status                => p_process_status,
3102         p_process_message               => p_process_message
3103     );
3104 
3105     p_codepath := jai_general_pkg.plot_codepath(6, p_codepath);
3106 
3107     -- Vijay Shankar for Bug#3940588 EDUCATION CESS
3108     IF pr_tax.excise_edu_cess <> 0 THEN
3109       IF p_register_entry_type = CENVAT_DEBIT THEN
3110         ln_other_tax_debit  := pr_tax.excise_edu_cess;
3111       ELSE
3112         ln_other_tax_credit := pr_tax.excise_edu_cess;
3113       END IF;
3114       jai_rcv_excise_processing_pkg.other_cenvat_rg_recording(
3115           p_source_register     => jai_constants.reg_pla,
3116           p_source_register_id  => p_register_id,
3117           p_tax_type            => jai_constants.tax_type_exc_edu_cess,
3118           p_credit              => ln_other_tax_credit,
3119           p_debit               => ln_other_tax_debit,
3120           p_process_status      => p_process_status,
3121           p_process_message     => p_process_message
3122        );
3123     END IF;
3124 
3125     p_codepath := jai_general_pkg.plot_codepath(7, p_codepath);
3126 
3127     IF pr_tax.cvd_edu_cess <> 0 THEN
3128       IF p_register_entry_type = CENVAT_DEBIT THEN
3129         ln_other_tax_debit  := pr_tax.cvd_edu_cess;
3130       ELSE
3131         ln_other_tax_credit := pr_tax.cvd_edu_cess;
3132       END IF;
3133       jai_rcv_excise_processing_pkg.other_cenvat_rg_recording(
3134           p_source_register     => jai_constants.reg_pla,
3135           p_source_register_id  => p_register_id,
3136           p_tax_type            => jai_constants.tax_type_cvd_edu_cess,
3137           p_credit              => ln_other_tax_credit,
3138           p_debit               => ln_other_tax_debit,
3139           p_process_status      => p_process_status,
3140           p_process_message     => p_process_message
3141        );
3142     END IF;
3143 
3144   /*added the following by vkaranam for budget 07 impact - bug#5989740*/
3145   --start
3146   p_codepath := jai_general_pkg.plot_codepath(8, p_codepath);
3147    IF pr_tax.sh_exc_edu_cess <> 0 THEN
3148 	    IF p_register_entry_type = CENVAT_DEBIT THEN
3149 	      ln_other_tax_debit  := nvl(pr_tax.sh_exc_edu_cess,0);
3150 	    ELSE
3151 	      ln_other_tax_credit := nvl(pr_tax.sh_exc_edu_cess,0);
3152 	    END IF;
3153 
3154 	    jai_rcv_excise_processing_pkg.other_cenvat_rg_recording(
3155 	        p_source_register     => jai_constants.reg_pla,
3156 	        p_source_register_id  => p_register_id,
3157 	        p_tax_type            => jai_constants.tax_type_sh_exc_edu_cess,
3158 	        p_credit              => ln_other_tax_credit,
3159 	        p_debit               => ln_other_tax_debit,
3160 	        p_process_status      => p_process_status,
3161 	        p_process_message     => p_process_message
3162 	     );
3163 	  END IF;
3164 
3165 	  p_codepath := jai_general_pkg.plot_codepath(9, p_codepath);
3166 
3167 	  IF pr_tax.sh_cvd_edu_cess <> 0 THEN
3168 	    IF p_register_entry_type = CENVAT_DEBIT THEN
3169 	      ln_other_tax_debit  := nvl(pr_tax.sh_cvd_edu_cess,0);
3170 	    ELSE
3171 	      ln_other_tax_credit := nvl(pr_tax.sh_cvd_edu_cess,0);
3172 	    END IF;
3173 	    jai_rcv_excise_processing_pkg.other_cenvat_rg_recording(
3174 	        p_source_register     => jai_constants.reg_pla,
3175 	        p_source_register_id  => p_register_id,
3176 	        p_tax_type            => jai_constants.tax_type_sh_cvd_edu_cess,
3177 	        p_credit              => ln_other_tax_credit,
3178 	        p_debit               => ln_other_tax_debit,
3179 	        p_process_status      => p_process_status,
3180 	        p_process_message     => p_process_message
3181 	     );
3182 	  END IF;
3183 	  --end #5989740
3184 
3185 
3186 
3187     p_codepath := jai_general_pkg.plot_codepath(10, p_codepath, NULL, 'END'); /* 6 */
3188 
3189   EXCEPTION
3190     WHEN OTHERS THEN
3191       p_process_status := 'E';
3192       p_process_message := 'CENVAT_RG_PKG.pla_entry->'||SQLERRM||', StmtId->'||lv_statement_id;
3193       FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
3194       p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END');
3195 
3196   END pla_entry;
3197 
3198   /*~~~~~~~~~~~~~~~~~~~ ACCOUNTING_ENTRIES Main Procedure for Accounting ~~~~~~~~~~~~~~~~~~~~~*/
3199 
3200   PROCEDURE accounting_entries(
3201     p_transaction_id    IN NUMBER,
3202     pr_tax              IN  TAX_BREAKUP,
3203     p_cgin_code         IN VARCHAR2,
3204     p_cenvat_accounting_type IN VARCHAR2,
3205     p_amount_register   IN VARCHAR2,
3206     p_cenvat_account_id OUT NOCOPY NUMBER,
3207     p_process_status OUT NOCOPY VARCHAR2,
3208     p_process_message OUT NOCOPY VARCHAR2,
3209     p_simulate_flag     IN VARCHAR2,
3210     p_codepath          IN OUT NOCOPY VARCHAR2
3211   , pv_retro_reference          IN VARCHAR2 DEFAULT NULL --Added by rchandan on Jan 18,2008 for retro
3212 
3213   ) IS
3214 
3215     r_trx                           c_trx%ROWTYPE;
3216     r_base_trx                      c_base_trx%ROWTYPE;
3217     r_orgn_info                     c_orgn_info%ROWTYPE;
3218     r_rcv_params                    c_rcv_params%ROWTYPE;
3219 
3220     lv_register_type                VARCHAR2(1);
3221     lv_transaction_type             RCV_TRANSACTIONS.transaction_type%TYPE;
3222     ln_total_excise_amt             NUMBER;
3223     ln_cenvat_claimed_ptg           NUMBER;
3224 
3225     lv_accnt_type                   JAI_RCV_JOURNAL_ENTRIES.acct_type%TYPE;
3226     lv_accnt_nature                 JAI_RCV_JOURNAL_ENTRIES.acct_nature%TYPE;
3227 
3228     ln_cenvat_accnt_id              NUMBER;
3229     ln_cenvat_balancing_accnt_id    NUMBER;
3230     ln_receiving_accnt_id           NUMBER;
3231     ln_cenvat_rcvble_accnt_id       NUMBER;
3232     lv_cgin_case                    VARCHAR2(100);
3233 
3234     ln_debit                        NUMBER;
3235     ln_credit                       NUMBER;
3236     ln_balancing_debit              NUMBER;
3237     ln_balancing_credit             NUMBER;
3238 
3239     lv_accounting_date              DATE;   --File.Sql.35 Cbabu  := trunc(SYSDATE);
3240     lv_reference10                  VARCHAR2(240);
3241     lv_message                      VARCHAR2(200);
3242 
3243     lv_statement_id                 VARCHAR2(5);
3244 
3245     ln_exc_edu_cess_accnt           NUMBER(15);
3246     ln_exc_edu_cess_rcvble_accnt    NUMBER(15);
3247     ln_total_excise_edu_cess_amt    NUMBER;
3248     ln_edu_cess_debit               NUMBER;
3249     ln_edu_cess_credit              NUMBER;
3250     ln_bal_edu_cess_debit           NUMBER;
3251     ln_bal_edu_cess_credit          NUMBER;
3252 
3253     /* following variables added as part of Bug#4211045 */
3254     ln_cess_paid_payable_accnt_id   NUMBER;
3255     ln_edu_cess_balancing_debit     NUMBER;
3256     ln_edu_cess_balancing_credit    NUMBER;
3257     /*added the following variables by vkaranam for budget 07 impact - bug#5989740*/
3258     ln_sh_cess_paid_payable_accnt   NUMBER;
3259     ln_sh_exc_edu_cess_accnt        NUMBER;
3260     ln_sh_exc_edu_cess_rcvb_accnt   NUMBER;
3261     ln_sh_total_exc_edu_cess_amt    NUMBER;
3262     ln_sh_edu_cess_debit            NUMBER;
3263     ln_sh_edu_cess_credit           NUMBER;
3264     ln_sh_edu_cess_balancin_debit  NUMBER;
3265     ln_sh_edu_cess_balancin_credit NUMBER;
3266     ln_sh_bal_edu_cess_debit       NUMBER;
3267     ln_sh_bal_edu_cess_credit      NUMBER;
3268 
3269 
3270   BEGIN
3271 
3272     lv_accounting_date := trunc(SYSDATE);
3273 
3274     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb> --- 2');
3275 
3276     if lb_rg_debug then
3277       FND_FILE.put_line(FND_FILE.log,'^ Accounting Entries. CGIN Code->'||nvl(p_cgin_code, 'NULL')
3278       ||'. Basic:'||pr_tax.basic_excise ||', Addl:'||pr_tax.addl_excise||', Other:'||pr_tax.other_excise
3279       ||', ExCes:'||pr_tax.excise_edu_cess||', CvdCes:'||pr_tax.cvd_edu_cess
3280       --added by vkaranam fro bug #5989740
3281       ||', SH_ExCes:'||pr_tax.sh_exc_edu_cess||', SH_CvdCes:'||pr_tax.sh_cvd_edu_cess
3282       ||', CVD:'||pr_tax.cvd
3283       -- Bug 5143906. Added by Lakshmi Gopalsami
3284       ||', Addl CVD: '|| pr_tax.addl_cvd
3285       ||', AccntType:'||p_cenvat_accounting_type ||', PrcSta:'||p_process_status
3286       ||', AmtRegister:'||p_amount_register||', CGIN Code->'||nvl(p_cgin_code, 'NULL')
3287     );
3288     end if;
3289 
3290 
3291      fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 3');
3292 
3293     lv_statement_id := '1';
3294     p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'cenvat_rg.accounting', 'START'); /* 1 */
3295     OPEN c_trx(p_transaction_id);
3296     FETCH c_trx INTO r_trx;
3297     CLOSE c_trx;
3298 
3299     lv_statement_id := '2';
3300     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
3301 
3302     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 4');
3303 
3304     lv_reference10  := 'India Local Cenvat Entries for Receipt:' || r_trx.receipt_num ||'. Transaction Type '||r_trx.transaction_type;
3305     if r_trx.transaction_type = 'CORRECT' THEN
3306       lv_reference10 := lv_reference10 || ' of '||r_trx.parent_transaction_type;
3307     end if;
3308 
3309     lv_statement_id := '3';
3310     p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
3311     IF( NVL(r_trx.cenvat_claimed_ptg, 0) = 100 AND pv_retro_reference IS NULL ) THEN--Added by eric on Jan 18,2008 for retro
3312       p_process_status    := 'E';
3313       p_process_message := 'Cenvat was fully claimed already. No more claims can happen';
3314       GOTO end_of_accounting;
3315     END IF;
3316 
3317     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 5');
3318 
3319     OPEN c_base_trx(p_transaction_id);
3320     FETCH c_base_trx INTO r_base_trx;
3321     CLOSE c_base_trx;
3322 
3323     lv_statement_id := '4';
3324     p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
3325 
3326     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 6');
3327 
3328     IF r_trx.transaction_type = 'CORRECT' THEN
3329       lv_transaction_type := r_trx.parent_transaction_type;
3330     ELSE
3331       lv_transaction_type := r_trx.transaction_type;
3332     END IF;
3333 
3334     lv_register_type := jai_general_pkg.get_rg_register_type(r_trx.item_class);
3335 
3336     -- following cenvat_claimed_ptg corresponds to RECEIVE i.e parent of any other type of transaction
3337     -- ln_cenvat_claimed_ptg := get_receive_claimed_ptg(p_transaction_id, r_trx.shipment_line_id);
3338 
3339     lv_statement_id := '5';
3340     p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
3341     OPEN c_orgn_info(r_trx.organization_id, r_trx.location_id);
3342     FETCH c_orgn_info INTO r_orgn_info;
3343     CLOSE c_orgn_info;
3344 
3345     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 7');
3346 
3347     OPEN c_rcv_params(r_trx.organization_id);
3348     FETCH c_rcv_params INTO r_rcv_params;  -- this is the default accnt and will be overriden later based on transaction requirement
3349     CLOSE c_rcv_params;
3350     ln_receiving_accnt_id := r_rcv_params.receiving_account_id;
3351 
3352     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 8');
3353 
3354     lv_statement_id := '5a';
3355     p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
3356     IF r_trx.organization_type = 'M' THEN
3357       lv_statement_id := '6';
3358       p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
3359       lv_accnt_nature   := 'CENVAT';
3360       -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. IF r_base_trx.attr_cat = 'India RMA Receipt' THEN
3361       IF r_base_trx.source_document_code = jai_rcv_trx_processing_pkg.source_rma then
3362         ln_receiving_accnt_id := r_orgn_info.excise_rcvble_account;   /* In front end this is shown as excise Paid Payable Accnt */
3363 
3364         /* Vijay Shankar for Bug#4211045 */
3365         ln_cess_paid_payable_accnt_id := r_orgn_info.cess_paid_payable_account_id;
3366         ln_sh_cess_paid_payable_accnt :=r_orgn_info.sh_cess_paid_payable_acct_id ;--added by vkaranam for budget 07 impact - bug#5989740
3367       END IF;
3368 
3369       IF p_amount_register = 'PLA' THEN
3370         ln_cenvat_accnt_id        := r_orgn_info.modvat_pla_account_id;
3371         ln_exc_edu_cess_accnt     := r_orgn_info.modvat_pla_account_id;          -- CHK IMPORTANT
3372         ln_sh_exc_edu_cess_accnt     := r_orgn_info.modvat_pla_account_id;          -- by vkaranam,bug #5989740
3373       ELSIF p_amount_register = 'RG23A' THEN
3374         ln_cenvat_accnt_id        := r_orgn_info.modvat_rm_account_id;
3375         ln_exc_edu_cess_accnt     := r_orgn_info.excise_edu_cess_rm_account;
3376         ln_sh_exc_edu_cess_accnt  := r_orgn_info.sh_cess_rm_account;--added by vkaranam for budget 07 impact - bug#5989740
3377       ELSIF p_amount_register = 'RG23C' THEN
3378         ln_cenvat_accnt_id          := r_orgn_info.modvat_cg_account_id;
3379         ln_exc_edu_cess_accnt       := r_orgn_info.excise_edu_cess_cg_account;
3380         ln_sh_exc_edu_cess_accnt       := r_orgn_info.sh_cess_cg_account_id;--added by vkaranam for budget 07 impact - bug#5989740
3381 	-- Bug 4516678. Added by Lakshmi Gopalsami.
3382 	-- Commented the following assignments.
3383         --ln_cenvat_rcvble_accnt_id   := r_orgn_info.cenvat_rcvble_account;
3384         --ln_exc_edu_cess_rcvble_accnt := r_orgn_info.excise_edu_cess_rcvble_accnt;
3385       ELSE
3386         -- something wrong
3387         NULL;
3388       END IF;
3389 
3390       /* Bug 4516678. Added by Lakshmi Gopalsami
3391          Added the following conditions for CGIN and CGEX type of items
3392       */
3393 
3394       IF r_trx.item_class IN ('CGIN','CGEX') THEN
3395         ln_cenvat_rcvble_accnt_id   := r_orgn_info.cenvat_rcvble_account;
3396         ln_exc_edu_cess_rcvble_accnt := r_orgn_info.excise_edu_cess_rcvble_accnt;
3397         ln_sh_exc_edu_cess_rcvb_accnt := r_orgn_info.sh_cess_rcvble_acct_id;--added by vkaranam for budget 07 impact - bug#5989740
3398       END IF ;
3399 
3400     ELSIF r_trx.organization_type = 'T' THEN
3401       lv_accnt_nature   := 'TRADING';
3402       ln_cenvat_accnt_id    := r_orgn_info.excise_23d_account;
3403       ln_exc_edu_cess_accnt := r_orgn_info.excise_23d_account;    -- CHK IMPORTANT
3404       ln_sh_exc_edu_cess_accnt := r_orgn_info.excise_23d_account;    -- bug #5989740
3405       ln_cess_paid_payable_accnt_id := r_orgn_info.excise_23d_account; -- bug #5989740
3406     ELSE
3407       -- something wrong
3408       fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 9');
3409       NULL;
3410     END IF;
3411      fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 10');
3412 
3413     ln_total_excise_amt := nvl(pr_tax.basic_excise,0) +
3414                            nvl(pr_tax.addl_excise,0)  +
3415 			   nvl(pr_tax.other_excise,0) +
3416 			   nvl(pr_tax.cvd,0)  +
3417       			   nvl(pr_tax.addl_cvd,0); --Date 30/10/2006 Bug 5228046 added by sacsethi
3418 
3419      fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 11');
3420     ln_total_excise_edu_cess_amt := nvl(pr_tax.excise_edu_cess,0) + nvl(pr_tax.cvd_edu_cess,0);
3421     --added by vkaranam for budget 07 impact - bug#5989740
3422     ln_sh_total_exc_edu_cess_amt := nvl(pr_tax.sh_exc_edu_cess,0) + nvl(pr_tax.sh_cvd_edu_cess,0);
3423 
3424     lv_statement_id := '7';
3425     p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
3426     -- IF ln_cenvat_accnt_id IS NULL THEN
3427     IF ln_total_excise_amt <> 0 THEN
3428       IF ln_cenvat_accnt_id IS NULL THEN
3429         IF r_trx.organization_type = 'T' THEN
3430           lv_message := 'Excise RG23D Account was not defined in Organization Setup';
3431         ELSIF p_amount_register = 'PLA' THEN
3432           lv_message := 'Modvat PLA Account was not defined in Organization Setup';
3433         ELSIF lv_register_type = 'A' THEN
3434           lv_message := 'Modvat RM Account was not defined in Organization Setup';
3435         ELSIF lv_register_type = 'C' THEN
3436           lv_message := 'Modvat CG Account was not defined in Organization Setup';
3437         ELSE
3438           lv_message := 'Could not derive Cenvat Account';
3439         END IF;
3440 
3441       ELSIF p_cgin_code IN ('REGULAR-HALF', 'REGULAR-FULL + REVERSAL-HALF','REGULAR-FULL-RETRO') AND ln_cenvat_rcvble_accnt_id IS NULL THEN
3442         lv_message := 'Cenvat Receivable Account was not defined in Organization Setup';
3443       END IF;
3444     END IF;
3445 
3446     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 12');
3447 
3448     IF ln_receiving_accnt_id IS NULL THEN
3449       -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. IF r_base_trx.attr_cat = 'India RMA Receipt' THEN
3450       IF r_base_trx.source_document_code = jai_rcv_trx_processing_pkg.source_rma then
3451         lv_message := 'Excise Receivable Account was not defined in Organization Setup';
3452       ELSE
3453         lv_message := 'Receivable Account was not defined in RCV Parameters';
3454       END IF;
3455     END IF;
3456 
3457     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 13');
3458 
3459     /* following Added for EDUCATION CESS by Vijay Shankar*/
3460     IF ln_total_excise_edu_cess_amt <> 0 THEN
3461       /* Vijay Shankar for Bug#4211045 */
3462       -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. IF r_base_trx.attr_cat = 'India RMA Receipt'
3463       IF r_base_trx.source_document_code = jai_rcv_trx_processing_pkg.source_rma
3464         AND ln_cess_paid_payable_accnt_id IS NULL
3465       THEN
3466         lv_message := 'Cess Paid/Payable Account was not defined in Organization Setup'; /* Cess meaning Excise Education Cess */
3467       END IF;
3468 
3469       IF ln_exc_edu_cess_accnt IS NULL THEN
3470         IF r_trx.organization_type = 'T' THEN
3471           lv_message := 'Excise RG23D Account was not defined in Organization Setup';
3472         ELSIF p_amount_register = 'PLA' THEN
3473           lv_message := 'Modvat PLA Account was not defined in Organization Setup';
3474         ELSIF lv_register_type = 'A' THEN
3475           lv_message := 'Excise Education Cess RM Account was not defined in Organization Setup';
3476         ELSIF lv_register_type = 'C' THEN
3477           lv_message := 'Excise Education Cess CG Account was not defined in Organization Setup';
3478         ELSE
3479           lv_message := 'Could not derive Cenvat Account';
3480         END IF;
3481 
3482       ELSIF p_cgin_code IN ('REGULAR-HALF', 'REGULAR-FULL + REVERSAL-HALF','REGULAR-FULL-RETRO') AND ln_cenvat_rcvble_accnt_id IS NULL THEN
3483         lv_message := 'Excise Education Cess Receivable Account was not defined in Organization Setup';
3484       END IF;
3485     END IF;
3486   /*added the following by vkaranam for budget 07 impact - bug#5989740*/
3487    --start
3488   IF ln_sh_total_exc_edu_cess_amt <> 0 THEN
3489 	     IF r_base_trx.source_document_code = jai_rcv_trx_processing_pkg.source_rma
3490 	      AND ln_sh_cess_paid_payable_accnt IS NULL
3491 	    THEN
3492 	      lv_message := 'Secondary/Higher Cess Paid/Payable Account was not defined in Organization Setup';
3493 	    END IF;
3494 
3495 	    IF ln_sh_exc_edu_cess_accnt IS NULL THEN
3496 	      IF r_trx.organization_type = 'T' THEN
3497 	        lv_message := 'Excise RG23D Account was not defined in Organization Setup';
3498 	      ELSIF p_amount_register = 'PLA' THEN
3499 	        lv_message := 'Modvat PLA Account was not defined in Organization Setup';
3500 	      ELSIF lv_register_type = 'A' THEN
3501 	        lv_message := 'Secondary/Higher Excise Education Cess RM Account was not defined in Organization Setup';
3502 	      ELSIF lv_register_type = 'C' THEN
3503 	        lv_message := 'Secondary/Higher Excise Education Cess CG Account was not defined in Organization Setup';
3504 	      ELSE
3505 	        lv_message := 'Could not derive Cenvat Account';
3506 	      END IF;
3507 
3508 	    ELSIF p_cgin_code IN ('REGULAR-HALF', 'REGULAR-FULL + REVERSAL-HALF','REGULAR-FULL-RETRO') AND ln_cenvat_rcvble_accnt_id IS NULL THEN
3509 	      lv_message := 'Secondary/Higher Excise Education Cess Receivable Account was not defined in Organization Setup';
3510 	    END IF;
3511   END IF;
3512  --end bug #5989740
3513 
3514 
3515     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 14');
3516 
3517     lv_statement_id := '8';
3518     p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9 */
3519     IF lv_message IS NOT NULL THEN
3520       p_process_status  := 'E';
3521       p_process_message := lv_message;
3522       RETURN;
3523     END IF;
3524 
3525 
3526     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 15');
3527 
3528     -- This will be used to update PART 1 and 2 Registers later
3529     p_cenvat_account_id := ln_cenvat_accnt_id;
3530 
3531     IF lv_transaction_type IN ('RECEIVE', 'RETURN TO RECEIVING') THEN
3532       lv_accnt_type   := 'REGULAR';
3533     ELSIF lv_transaction_type IN ('DELIVER', 'RETURN TO VENDOR') THEN
3534       lv_accnt_type   := 'REVERSAL';
3535     ELSE
3536       -- Sorry
3537       fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 16');
3538       NULL;
3539     END IF;
3540 
3541     lv_statement_id := '9';
3542     p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10 */
3543     IF p_cenvat_accounting_type = CENVAT_DEBIT THEN
3544       ln_debit            := ln_total_excise_amt;
3545       ln_balancing_credit := ln_total_excise_amt;
3546       ln_credit           := NULL;
3547       ln_balancing_debit  := NULL;
3548     ELSE
3549       ln_credit           := ln_total_excise_amt;
3550       ln_balancing_debit  := ln_total_excise_amt;
3551       ln_debit            := NULL;
3552       ln_balancing_credit := NULL;
3553     END IF;
3554 
3555     -- Vijay Shankar for Bug#3940588 ADDED for EDUCATION CESS
3556     -- If both accounts are same, then we can pass the accounting in one entry instead of two
3557     IF ln_exc_edu_cess_accnt IS NOT NULL AND ln_cenvat_accnt_id IS NOT NULL
3558       AND ln_exc_edu_cess_accnt = ln_cenvat_accnt_id
3559     THEN
3560       ln_edu_cess_debit   := null;
3561       ln_edu_cess_credit  := null;
3562       IF p_cenvat_accounting_type = CENVAT_DEBIT THEN
3563         ln_debit  := ln_debit + ln_total_excise_edu_cess_amt;
3564       ELSE
3565         ln_credit := ln_credit + ln_total_excise_edu_cess_amt;
3566       END IF;
3567 
3568     /* if the execution comes here, it means different accounts are defined for edu cess. So, we need to pass
3569        seperate entry for cess */
3570     ELSIF ln_total_excise_edu_cess_amt <> 0 THEN
3571 
3572       IF p_cenvat_accounting_type = CENVAT_DEBIT THEN
3573         ln_edu_cess_debit := ln_total_excise_edu_cess_amt;
3574         ln_edu_cess_credit  := null;
3575       ELSE
3576         ln_edu_cess_credit := ln_total_excise_edu_cess_amt;
3577         ln_edu_cess_debit   := null;
3578       END IF;
3579 
3580     END IF;
3581     -- End Education Cess
3582     /*added the following by vkaranam for budget 07 impact - bug#5989740*/
3583    --start
3584   IF ln_sh_exc_edu_cess_accnt IS NOT NULL AND ln_cenvat_accnt_id IS NOT NULL
3585 	    AND ln_sh_exc_edu_cess_accnt = ln_cenvat_accnt_id
3586 	  THEN
3587 	    ln_sh_edu_cess_debit   := null;
3588 	    ln_sh_edu_cess_credit  := null;
3589 
3590 	    IF p_cenvat_accounting_type = CENVAT_DEBIT THEN
3591 	      ln_debit  := ln_debit + ln_sh_total_exc_edu_cess_amt;
3592 	    ELSE
3593 	      ln_credit := ln_credit + ln_sh_total_exc_edu_cess_amt;
3594 	    END IF;
3595 
3596 	  /* if the execution comes here, it means different accounts are defined for edu cess. So, we need to pass
3597 	     seperate entry for cess */
3598 	  ELSIF ln_sh_total_exc_edu_cess_amt <> 0 THEN
3599 
3600 	    IF p_cenvat_accounting_type = CENVAT_DEBIT THEN
3601 	      ln_sh_edu_cess_debit := ln_sh_total_exc_edu_cess_amt;
3602 	      ln_sh_edu_cess_credit  := null;
3603 	    ELSE
3604 	      ln_sh_edu_cess_credit := ln_sh_total_exc_edu_cess_amt;
3605 	      ln_sh_edu_cess_debit   := null;
3606 	    END IF;
3607 
3608   END IF;
3609   --end bug#5989740
3610 
3611 
3612     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 17');
3613     /* setting values for balancing credit/debit variables */
3614     /* edu_cess_balancing part was coded as part of Bug#4211045 */
3615     IF ln_total_excise_edu_cess_amt <> 0 THEN
3616       ln_edu_cess_balancing_debit := null;
3617       ln_edu_cess_balancing_credit := null;
3618 
3619       IF p_cenvat_accounting_type = CENVAT_DEBIT THEN
3620 
3621         /* ln_balancing_credit := ln_balancing_credit + ln_total_excise_edu_cess_amt; */
3622         /* If condition added by Vijay Shankar for Bug#4211045. Else is existing previously itself as above statement */
3623         -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. IF r_base_trx.attr_cat = 'India RMA Receipt' THEN
3624         IF r_base_trx.source_document_code = jai_rcv_trx_processing_pkg.source_rma then
3625           ln_edu_cess_balancing_credit := ln_total_excise_edu_cess_amt;
3626         ELSE
3627           ln_balancing_credit := ln_balancing_credit + ln_total_excise_edu_cess_amt;
3628         END IF;
3629 
3630       ELSE
3631 
3632         /* ln_balancing_debit := ln_balancing_debit + ln_total_excise_edu_cess_amt; */
3633         /* If condition added by Vijay Shankar for Bug#4211045. Else is existing previously itself as above statement */
3634         -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. IF r_base_trx.attr_cat = 'India RMA Receipt' THEN
3635         IF r_base_trx.source_document_code = jai_rcv_trx_processing_pkg.source_rma then
3636           ln_edu_cess_balancing_debit := ln_total_excise_edu_cess_amt;
3637         ELSE
3638           ln_balancing_debit := ln_balancing_debit + ln_total_excise_edu_cess_amt;
3639         END IF;
3640       END IF;
3641     END IF;
3642  /*added the following by vkaranam for budget 07 impact - bug#5989740*/
3643 	 --start
3644 	IF ln_sh_total_exc_edu_cess_amt <> 0 THEN
3645 	    ln_sh_edu_cess_balancin_debit := null;
3646 	    ln_sh_edu_cess_balancin_credit := null;
3647 
3648 	    IF p_cenvat_accounting_type = CENVAT_DEBIT THEN
3649 
3650 
3651 
3652 	      IF r_base_trx.source_document_code = jai_rcv_trx_processing_pkg.source_rma then
3653 	        ln_sh_edu_cess_balancin_credit := ln_sh_total_exc_edu_cess_amt;
3654 	      ELSE
3655 	        ln_balancing_credit := ln_balancing_credit + ln_sh_total_exc_edu_cess_amt;
3656 	      END IF;
3657 
3658 	    ELSE
3659 
3660 
3661 	      IF r_base_trx.source_document_code = jai_rcv_trx_processing_pkg.source_rma then
3662 	        ln_sh_edu_cess_balancin_debit := ln_sh_total_exc_edu_cess_amt;
3663 	      ELSE
3664 	        ln_balancing_debit := ln_balancing_debit + ln_sh_total_exc_edu_cess_amt;
3665 	      END IF;
3666 	    END IF;
3667 	  END IF;
3668   --end bug#5989740
3669 
3670 
3671     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 18');
3672 
3673     lv_statement_id := '10';
3674     p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11 */
3675     IF p_cgin_code IS NULL OR (lv_register_type = 'C' AND p_cgin_code like 'REGULAR-FULL%') THEN
3676 
3677       if lb_rg_debug then
3678         FND_FILE.put_line(FND_FILE.log,'11_1 jai_rcv_accounting_pkg.process_transaction.'
3679           ||' Debit:'||ln_debit||', Credit:'||ln_credit||', CenvatAccntId:'||ln_cenvat_accnt_id);
3680       end if;
3681 
3682       lv_statement_id := '10a';
3683       p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12 */
3684       -- Actual Entry-1: Cenvat Accounting ( This Includes Edu Cess also if different account is not specified for cess)
3685     -- bug 5581319. Added by Lakshmi Gopalsami
3686     IF NVL(ln_debit,0) <> 0 OR NVL(ln_credit,0) <> 0 THEN
3687       fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 19');
3688       jai_rcv_accounting_pkg.process_transaction(
3689           P_TRANSACTION_ID       => p_transaction_id,
3690           P_ACCT_TYPE            => lv_accnt_type,
3691           P_ACCT_NATURE          => lv_accnt_nature,
3692           P_SOURCE_NAME          => gv_source_name,
3693           P_CATEGORY_NAME        => gv_category_name,
3694           P_CODE_COMBINATION_ID  => ln_cenvat_accnt_id,
3695           P_ENTERED_DR           => ln_debit,
3696           P_ENTERED_CR           => ln_credit,
3697           P_CURRENCY_CODE        => jai_rcv_trx_processing_pkg.gv_func_curr,
3698           P_ACCOUNTING_DATE      => lv_accounting_date,
3699           P_REFERENCE_10         => lv_reference10,
3700           P_REFERENCE_23         => 'jai_rcv_excise_processing_pkg.accounting_entries',
3701           P_REFERENCE_24         => 'rcv_transactions',
3702           P_REFERENCE_25         => 'transaction_id',
3703           P_REFERENCE_26         => to_char(p_transaction_id),
3704           P_DESTINATION          => 'G',
3705           P_SIMULATE_FLAG        => p_simulate_flag,
3706           P_CODEPATH             => p_codepath,
3707           P_PROCESS_STATUS       => p_process_status,
3708           P_PROCESS_MESSAGE      => p_process_message,
3709           p_reference_name       => pv_retro_reference /*added by rchandan*/
3710       );
3711 
3712       IF p_process_status IN ('E', 'X') THEN
3713         GOTO end_of_accounting;
3714       END IF;
3715      END IF;
3716      -- Bug 5581319
3717 
3718       -- Start, EDUCATION CESS ACCCOUNTING
3719       IF nvl(ln_edu_cess_debit,0)<>0 OR nvl(ln_edu_cess_credit,0)<>0 THEN
3720 
3721         if lb_rg_debug then
3722           FND_FILE.put_line(FND_FILE.log,'11_2 Cen Accounting -- '
3723             ||' Dr:'||ln_edu_cess_debit||', Cr:'||ln_edu_cess_credit||', EduCessAccnt:'||ln_cenvat_accnt_id);
3724         end if;
3725     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 20');
3726         lv_statement_id := '10a';
3727         p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12 */
3728         -- Actual Entry-2: Cenvat Cess Accounting
3729         jai_rcv_accounting_pkg.process_transaction(
3730             P_TRANSACTION_ID       => p_transaction_id,
3731             P_ACCT_TYPE            => lv_accnt_type,
3732             P_ACCT_NATURE          => lv_accnt_nature,
3733             P_SOURCE_NAME          => gv_source_name,
3734             P_CATEGORY_NAME        => gv_category_name,
3735             P_CODE_COMBINATION_ID  => ln_exc_edu_cess_accnt,
3736             P_ENTERED_DR           => ln_edu_cess_debit,
3737             P_ENTERED_CR           => ln_edu_cess_credit,
3738             P_CURRENCY_CODE        => jai_rcv_trx_processing_pkg.gv_func_curr,
3739             P_ACCOUNTING_DATE      => lv_accounting_date,
3740             P_REFERENCE_10         => lv_reference10,
3741             P_REFERENCE_23         => 'jai_rcv_excise_processing_pkg.accounting_entries',
3742             P_REFERENCE_24         => 'rcv_transactions',
3743             P_REFERENCE_25         => 'transaction_id',
3744             P_REFERENCE_26         => to_char(p_transaction_id),
3745             P_DESTINATION          => 'G',
3746             P_SIMULATE_FLAG        => p_simulate_flag,
3747             P_CODEPATH             => p_codepath,
3748             P_PROCESS_STATUS       => p_process_status,
3749             P_PROCESS_MESSAGE      => p_process_message,
3750             p_reference_name       => pv_retro_reference /*added by rchandan*/
3751         );
3752 
3753         IF p_process_status IN ('E', 'X') THEN
3754           GOTO end_of_accounting;
3755         END IF;
3756       END IF;
3757       -- End, EDUCATION CESS ACCCOUNTING
3758 /*added the following by vkaranam for budget 07 impact - bug#5989740*/
3759   --start SH_excise_edu_cess accounting
3760     IF nvl(ln_sh_edu_cess_debit,0)<>0 OR nvl(ln_sh_edu_cess_credit,0)<>0 THEN
3761 
3762       if lb_rg_debug then
3763         FND_FILE.put_line(FND_FILE.log,'11_3 Cen Accounting -- '
3764           ||' SH_Dr:'||ln_sh_edu_cess_debit||', SH_Cr:'||ln_sh_edu_cess_credit||', SH_EduCessAccnt:'||ln_sh_exc_edu_cess_accnt);
3765       end if;
3766 
3767       lv_statement_id := '10b';
3768       p_codepath := jai_general_pkg.plot_codepath(13, p_codepath); /* 13 */
3769       -- Actual Entry-2: Cenvat Cess Accounting
3770       jai_rcv_accounting_pkg.process_transaction(
3771           P_TRANSACTION_ID       => p_transaction_id,
3772           P_ACCT_TYPE            => lv_accnt_type,
3773           P_ACCT_NATURE          => lv_accnt_nature,
3774           P_SOURCE_NAME          => gv_source_name,
3775           P_CATEGORY_NAME        => gv_category_name,
3776           P_CODE_COMBINATION_ID  => ln_sh_exc_edu_cess_accnt,
3777           P_ENTERED_DR           => ln_sh_edu_cess_debit,
3778           P_ENTERED_CR           => ln_sh_edu_cess_credit,
3779           P_CURRENCY_CODE        => jai_rcv_trx_processing_pkg.gv_func_curr,
3780           P_ACCOUNTING_DATE      => lv_accounting_date,
3781           P_REFERENCE_10         => lv_reference10,
3782           P_REFERENCE_23         => 'ja_in_receipt_cenvat_rg_pkg.accounting_entries',
3783           P_REFERENCE_24         => 'rcv_transactions',
3784           P_REFERENCE_25         => 'transaction_id',
3785           P_REFERENCE_26         => to_char(p_transaction_id),
3786           P_DESTINATION          => 'G',
3787           P_SIMULATE_FLAG        => p_simulate_flag,
3788           P_CODEPATH             => p_codepath,
3789           P_PROCESS_STATUS       => p_process_status,
3790           P_PROCESS_MESSAGE      => p_process_message,
3791           p_reference_name       => pv_retro_reference /*added by rchandan*/
3792           , p_reference_id         => 3
3793       );
3794 
3795       IF p_process_status IN ('E', 'X') THEN
3796         GOTO end_of_accounting;
3797       END IF;
3798     END IF;
3799     -- End 5989740
3800 
3801 
3802       if lb_rg_debug then
3803         FND_FILE.put_line(FND_FILE.log,'12 jai_rcv_accounting_pkg.process_transaction.'
3804           ||' Debit:'||ln_balancing_debit||', Credit:'||ln_balancing_credit||', RecvngAccntId:'||ln_receiving_accnt_id);
3805       end if;
3806 
3807       lv_statement_id := '10b';
3808       p_codepath := jai_general_pkg.plot_codepath(13, p_codepath); /* 13 */
3809       -- Balancing Entry: Receiving Accounting
3810      -- bug 5581319. Added by Lakshmi Gopalsami
3811      IF NVL(ln_balancing_debit,0) <> 0 OR NVL(ln_balancing_credit,0) <> 0 THEN
3812       fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 21');
3813 
3814       jai_rcv_accounting_pkg.process_transaction(
3815           P_TRANSACTION_ID       => p_transaction_id,
3816           P_ACCT_TYPE            => lv_accnt_type,
3817           P_ACCT_NATURE          => lv_accnt_nature,
3818           P_SOURCE_NAME          => gv_source_name,
3819           P_CATEGORY_NAME        => gv_category_name,
3820           P_CODE_COMBINATION_ID  => ln_receiving_accnt_id,
3821           P_ENTERED_DR           => ln_balancing_debit,
3822           P_ENTERED_CR           => ln_balancing_credit,
3823           P_CURRENCY_CODE        => jai_rcv_trx_processing_pkg.gv_func_curr,
3824           P_ACCOUNTING_DATE      => lv_accounting_date,
3825           P_REFERENCE_10         => lv_reference10,
3826           P_REFERENCE_23         => 'jai_rcv_excise_processing_pkg.accounting_entries',
3827           P_REFERENCE_24         => 'rcv_transactions',
3828           P_REFERENCE_25         => 'transaction_id',
3829           P_REFERENCE_26         => to_char(p_transaction_id),
3830           P_DESTINATION          => 'G',
3831           P_SIMULATE_FLAG        => p_simulate_flag,
3832           P_CODEPATH             => p_codepath,
3833           P_PROCESS_STATUS       => p_process_status,
3834           P_PROCESS_MESSAGE      => p_process_message,
3835           p_reference_name       => pv_retro_reference ,/*added by rchandan*/
3836            p_reference_id         => 5--replaced 3 with 5 by vkaranam fro bug#5989740
3837       );
3838 
3839       IF p_process_status IN ('E', 'X') THEN
3840         GOTO end_of_accounting;
3841       END IF;
3842      END IF;
3843      -- Bug 5581319
3844 
3845 
3846       /* following entry (CESS BALANCING ENTRY for RMA Production Input and GOODS RETURN cases)
3847        added by Vijay Shankar for Bug#4211045 */
3848       -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. IF r_base_trx.attr_cat = 'India RMA Receipt'
3849       IF r_base_trx.source_document_code = jai_rcv_trx_processing_pkg.source_rma
3850         AND nvl(ln_edu_cess_balancing_debit, ln_edu_cess_balancing_credit) <> 0
3851       THEN
3852 
3853         lv_statement_id := '10b';
3854         p_codepath := jai_general_pkg.plot_codepath(13.1, p_codepath);
3855         -- Balancing Entry: Receiving Accounting
3856     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 22');
3857         jai_rcv_accounting_pkg.process_transaction(
3858             P_TRANSACTION_ID       => p_transaction_id,
3859             P_ACCT_TYPE            => lv_accnt_type,
3860             P_ACCT_NATURE          => lv_accnt_nature,
3861             P_SOURCE_NAME          => gv_source_name,
3862             P_CATEGORY_NAME        => gv_category_name,
3863             P_CODE_COMBINATION_ID  => ln_cess_paid_payable_accnt_id,
3864             P_ENTERED_DR           => ln_edu_cess_balancing_debit,
3865             P_ENTERED_CR           => ln_edu_cess_balancing_credit,
3866             P_CURRENCY_CODE        => jai_rcv_trx_processing_pkg.gv_func_curr,
3867             P_ACCOUNTING_DATE      => lv_accounting_date,
3868             P_REFERENCE_10         => lv_reference10,
3869             P_REFERENCE_23         => 'jai_rcv_excise_processing_pkg.accounting_entries',
3870             P_REFERENCE_24         => 'rcv_transactions',
3871             P_REFERENCE_25         => 'transaction_id',
3872             P_REFERENCE_26         => to_char(p_transaction_id),
3873             P_DESTINATION          => 'G',
3874             P_SIMULATE_FLAG        => p_simulate_flag,
3875             P_CODEPATH             => p_codepath,
3876             P_PROCESS_STATUS       => p_process_status,
3877             P_PROCESS_MESSAGE      => p_process_message,
3878             p_reference_name       => pv_retro_reference, /*added by rchandan*/
3879              p_reference_id         => 6 --replaced 4 with 6 by vkaranam fro bug#5989740
3880         );
3881 
3882         IF p_process_status IN ('E', 'X') THEN
3883           GOTO end_of_accounting;
3884         END IF;
3885 
3886       END IF;
3887  /*added the following by vkaranam for budget 07 impact - bug#5989740*/
3888  	   --start
3889  	   if lb_rg_debug then
3890  	 	      FND_FILE.put_line(FND_FILE.log,'15 JA_IN_RECEIPT_ACCOUNTING_PKG.process_transaction.'
3891  	 	        ||' SH_Debit:'||ln_sh_edu_cess_balancin_debit||', SH_Credit:'||ln_sh_edu_cess_balancin_credit
3892  	 	        ||', ln_sh_cess_paid_payable_accnt:'||ln_sh_cess_paid_payable_accnt);
3893  	   end if;
3894 
3895  	   IF r_base_trx.source_document_code = jai_rcv_trx_processing_pkg.source_rma
3896  	 	      AND nvl(ln_sh_edu_cess_balancin_debit, ln_sh_edu_cess_balancin_credit) <> 0
3897  	 	    THEN
3898 
3899  	 	      lv_statement_id := '10d';
3900  	 	      p_codepath := jai_general_pkg.plot_codepath(15.1, p_codepath);
3901  	 	      -- Balancing Entry: Receiving Accounting
3902  	 	      jai_rcv_accounting_pkg.process_transaction(
3903  	 	          P_TRANSACTION_ID       => p_transaction_id,
3904  	 	          P_ACCT_TYPE            => lv_accnt_type,
3905  	 	          P_ACCT_NATURE          => lv_accnt_nature,
3906  	 	          P_SOURCE_NAME          => gv_source_name,
3907  	 	          P_CATEGORY_NAME        => gv_category_name,
3908  	 	          P_CODE_COMBINATION_ID  => ln_sh_cess_paid_payable_accnt,--replaced ln_cess_paid_payable_accnt_id with ln_sh_cess_paid_payable_accnt for bug #5989740
3909  	 	          P_ENTERED_DR           => ln_sh_edu_cess_balancin_debit,
3910  	 	          P_ENTERED_CR           => ln_sh_edu_cess_balancin_credit,
3911  	 	          P_CURRENCY_CODE        => jai_rcv_trx_processing_pkg.gv_func_curr,
3912  	 	          P_ACCOUNTING_DATE      => lv_accounting_date,
3913  	 	          P_REFERENCE_10         => lv_reference10,
3914  	 	          P_REFERENCE_23         => 'jai_rcv_excise_processing_pkg.accounting_entries',
3915  	 	          P_REFERENCE_24         => 'rcv_transactions',
3916  	 	          P_REFERENCE_25         => 'transaction_id',
3917  	 	          P_REFERENCE_26         => to_char(p_transaction_id),
3918  	 	          P_DESTINATION          => 'G',
3919  	 	          P_SIMULATE_FLAG        => p_simulate_flag,
3920  	 	          P_CODEPATH             => p_codepath,
3921  	 	          P_PROCESS_STATUS       => p_process_status,
3922  	 	          P_PROCESS_MESSAGE      => p_process_message,
3923  	 	          p_reference_name       => pv_retro_reference /*added by rchandan*/
3924  	 	          , p_reference_id         => 4
3925  	 	      );
3926 
3927  	 	      IF p_process_status IN ('E', 'X') THEN
3928  	 	        GOTO end_of_accounting;
3929  	 	      END IF;
3930 
3931  	  END IF;
3932 
3933  	  --end 5989740
3934 
3935 
3936     END IF;
3937 
3938     /*~~~~~~~~~ Reversal/Regular Entry of 50% for CGIN Items from MainCG/RcvbleCG account to RcvbleCG/MainCG account ~~~~~~~~~~~~~~~*/
3939 
3940     lv_statement_id := '11';
3941     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb> --- 23a - cgin code ' || p_cgin_code );
3942 
3943     IF nvl(p_cgin_code,'AA') IN ('REGULAR-HALF', 'REGULAR-FULL + REVERSAL-HALF') THEN
3944     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 23');
3945       lv_statement_id := '12';
3946       p_codepath := jai_general_pkg.plot_codepath(15, p_codepath); /* 15 */
3947 
3948       -- this can happen only for RECEIVE type of transaction and that too for 2nd 50% Claim
3949       IF p_cgin_code = 'REGULAR-HALF' THEN
3950         lv_accnt_nature     := 'CENVAT-REG-50%';
3951         ln_debit            := ln_total_excise_amt/2;
3952         ln_balancing_credit := ln_total_excise_amt/2;
3953         ln_credit           := NULL;
3954         ln_balancing_debit  := NULL;
3955 
3956         -- Vijay Shankar for Bug#3940588 ADDED for EDUCATION CESS
3957         IF ln_exc_edu_cess_accnt IS NOT NULL AND ln_cenvat_accnt_id IS NOT NULL
3958           AND ln_exc_edu_cess_accnt = ln_cenvat_accnt_id
3959         THEN
3960           ln_debit            := ln_debit + ln_total_excise_edu_cess_amt/2;
3961           ln_edu_cess_debit   := null;
3962         -- if different account is specified for Cess, then we pass separate entry for cess and balance the amount with balance entry
3963         ELSIF ln_total_excise_edu_cess_amt <> 0 THEN
3964           ln_edu_cess_debit   := ln_total_excise_edu_cess_amt/2;
3965         END IF;
3966         ln_edu_cess_credit  := null;
3967 
3968         -- this is required in case Excise Rcvble and Edu Cess Rcvble are same, so that no separate accnt entry for Cess Rcvble Amount
3969         IF ln_exc_edu_cess_rcvble_accnt IS NOT NULL AND ln_cenvat_rcvble_accnt_id IS NOT NULL
3970           AND ln_cenvat_rcvble_accnt_id = ln_exc_edu_cess_rcvble_accnt
3971         THEN
3972           ln_balancing_credit := ln_balancing_credit + ln_total_excise_edu_cess_amt/2;
3973         ELSIF ln_total_excise_edu_cess_amt <> 0 THEN
3974           ln_bal_edu_cess_credit := ln_total_excise_edu_cess_amt/2;
3975           ln_bal_edu_cess_debit := null;
3976         END IF;
3977         -- End, Vijay Shankar for Bug#3940588
3978    /*added the following by vkaranam for budget 07 impact - bug#5989740*/
3979 		  --start
3980 	    IF ln_sh_exc_edu_cess_accnt IS NOT NULL AND ln_cenvat_accnt_id IS NOT NULL
3981 					AND ln_sh_exc_edu_cess_accnt = ln_cenvat_accnt_id
3982 				THEN
3983 					ln_debit            := ln_debit + ln_sh_total_exc_edu_cess_amt/2;
3984 					ln_sh_edu_cess_debit   := null;
3985 				-- if different account is specified for Cess, then we pass separate entry for cess and balance the amount with balance entry
3986 				ELSIF ln_sh_total_exc_edu_cess_amt <> 0 THEN
3987 					ln_sh_edu_cess_debit   := ln_sh_total_exc_edu_cess_amt/2;
3988 				END IF;
3989 				ln_sh_edu_cess_credit  := null;
3990 
3991 				-- this is required in case Excise Rcvble and SH Edu Cess Rcvble are same, so that no separate accnt entry for Cess Rcvble Amount
3992 				IF ln_sh_exc_edu_cess_rcvb_accnt IS NOT NULL AND ln_cenvat_rcvble_accnt_id IS NOT NULL
3993 					AND ln_cenvat_rcvble_accnt_id = ln_sh_exc_edu_cess_rcvb_accnt
3994 				THEN
3995 					ln_balancing_credit := ln_balancing_credit + ln_sh_total_exc_edu_cess_amt/2;
3996 				ELSIF ln_sh_total_exc_edu_cess_amt <> 0 THEN -- Date 04/06/2007 by sacsethi for bug 6109941
3997 					ln_sh_bal_edu_cess_credit := ln_sh_total_exc_edu_cess_amt/2;
3998 					ln_sh_bal_edu_cess_debit := null;
3999 	    END IF;
4000      -- End bug#5989740
4001 
4002 
4003       ELSIF p_cgin_code = 'REGULAR-FULL + REVERSAL-HALF' THEN
4004 
4005         lv_accnt_nature   := 'CENVAT-REV-50%';
4006         IF p_cenvat_accounting_type = CENVAT_DEBIT THEN
4007           -- because this is reversal transaction, opposite of regular acocunting should be passed
4008           -- this happens in case of DELIVER Trxn
4009         /*ln_credit           := ln_total_excise_amt/2;
4010           ln_balancing_debit  := ln_total_excise_amt/2;
4011 		  commented the above and added the below by vumaasha for 7716044
4012 		  as ln_total_excise_amt is including the additional CVD, which shouldn't be reversed */
4013 		  ln_credit           := (ln_total_excise_amt - nvl(pr_tax.addl_cvd,0))/2;
4014 		  ln_balancing_debit  := (ln_total_excise_amt - nvl(pr_tax.addl_cvd,0))/2;
4015           ln_debit            := NULL;
4016           ln_balancing_credit := NULL;
4017 
4018           -- Vijay Shankar for Bug#3940588 ADDED for EDUCATION CESS
4019           IF ln_exc_edu_cess_accnt IS NOT NULL AND ln_cenvat_accnt_id IS NOT NULL
4020             AND ln_exc_edu_cess_accnt = ln_cenvat_accnt_id
4021           THEN
4022             ln_credit           := ln_credit + ln_total_excise_edu_cess_amt/2;
4023             ln_edu_cess_credit  := null;
4024           -- if different account is specified for Cess, then we pass separate entry for cess and balance the amount with balance entry
4025           ELSIF ln_total_excise_edu_cess_amt <> 0 THEN
4026             ln_edu_cess_credit   := ln_total_excise_edu_cess_amt/2;
4027           END IF;
4028           ln_edu_cess_debit  := null;
4029 
4030           -- this is required in case Excise Rcvble and Edu Cess Rcvble are same, so that no separate accnt entry for Cess Rcvble Amount
4031           IF ln_exc_edu_cess_rcvble_accnt IS NOT NULL AND ln_cenvat_rcvble_accnt_id IS NOT NULL
4032             AND ln_cenvat_rcvble_accnt_id = ln_exc_edu_cess_rcvble_accnt
4033           THEN
4034             ln_balancing_debit := ln_balancing_debit + ln_total_excise_edu_cess_amt/2;
4035             ln_bal_edu_cess_debit  := null;
4036             ln_bal_edu_cess_credit := null;
4037           ELSIF ln_total_excise_edu_cess_amt <> 0 THEN
4038             ln_bal_edu_cess_debit := ln_total_excise_edu_cess_amt/2;
4039             ln_bal_edu_cess_credit := null;
4040           END IF;
4041           -- End, Vijay Shankar for Bug#3940588
4042   /*added the following by vkaranam for budget 07 impact - bug#5989740*/
4043 	IF ln_sh_exc_edu_cess_accnt IS NOT NULL AND ln_cenvat_accnt_id IS NOT NULL
4044 	  AND ln_sh_exc_edu_cess_accnt = ln_cenvat_accnt_id
4045 	THEN
4046 	  ln_credit           := ln_credit + ln_sh_total_exc_edu_cess_amt/2;
4047 	  ln_sh_edu_cess_credit  := null;
4048 	-- if different account is specified for Cess, then we pass separate entry for cess and balance the amount with balance entry
4049 	ELSIF ln_sh_total_exc_edu_cess_amt <> 0 THEN
4050 	  ln_sh_edu_cess_credit   := ln_sh_total_exc_edu_cess_amt/2;
4051 	END IF;
4052 	ln_sh_edu_cess_debit  := null;
4053 
4054 	-- this is required in case Excise Rcvble and Edu Cess Rcvble are same, so that no separate accnt entry for Cess Rcvble Amount
4055 	IF ln_sh_exc_edu_cess_rcvb_accnt IS NOT NULL AND ln_cenvat_rcvble_accnt_id IS NOT NULL
4056 	  AND ln_cenvat_rcvble_accnt_id = ln_sh_exc_edu_cess_rcvb_accnt
4057 	THEN
4058 
4059 	  ln_balancing_debit := ln_balancing_debit + ln_sh_total_exc_edu_cess_amt/2;
4060 	  ln_sh_bal_edu_cess_debit  := null;
4061 	  ln_sh_bal_edu_cess_credit := null;
4062 	ELSIF ln_sh_total_exc_edu_cess_amt <> 0 THEN
4063 	  ln_sh_bal_edu_cess_debit := ln_sh_total_exc_edu_cess_amt/2;
4064 	  ln_sh_bal_edu_cess_credit := null;
4065 	END IF;
4066      -- End bug 5989740
4067 
4068 
4069         ELSE
4070 
4071           /* ln_debit            := ln_total_excise_amt/2;
4072           ln_balancing_credit := ln_total_excise_amt/2;
4073 		  commented the above and added the below by vumaasha for 7716044.
4074 		  as ln_total_excise_amt is including the additional CVD, which shouldn't be reversed */
4075 		  ln_debit            := (ln_total_excise_amt - nvl(pr_tax.addl_cvd,0))/2;
4076 		  ln_balancing_credit := (ln_total_excise_amt - nvl(pr_tax.addl_cvd,0))/2;
4077           ln_credit           := NULL;
4078           ln_balancing_debit  := NULL;
4079 
4080           -- Vijay Shankar for Bug#3940588 ADDED for EDUCATION CESS
4081           IF ln_exc_edu_cess_accnt IS NOT NULL AND ln_cenvat_accnt_id IS NOT NULL
4082             AND ln_exc_edu_cess_accnt = ln_cenvat_accnt_id
4083           THEN
4084             ln_debit            := ln_debit + ln_total_excise_edu_cess_amt/2;
4085             ln_edu_cess_debit   := null;
4086           -- if different account is specified for Cess, then we pass separate entry for cess and balance the amount with balance entry
4087           ELSIF ln_total_excise_edu_cess_amt <> 0 THEN
4088             ln_edu_cess_debit   := ln_total_excise_edu_cess_amt/2;
4089           END IF;
4090           ln_edu_cess_credit  := null;
4091 
4092           -- this is required in case Excise Rcvble and Edu Cess Rcvble are same, so that no separate accnt entry for Cess Rcvble Amount
4093           IF ln_exc_edu_cess_rcvble_accnt IS NOT NULL AND ln_cenvat_rcvble_accnt_id IS NOT NULL
4094             AND ln_cenvat_rcvble_accnt_id = ln_exc_edu_cess_rcvble_accnt
4095           THEN
4096             ln_balancing_credit := ln_balancing_credit + ln_total_excise_edu_cess_amt/2;
4097             ln_bal_edu_cess_debit  := null;
4098             ln_bal_edu_cess_credit := null;
4099           ELSIF ln_total_excise_edu_cess_amt <> 0 THEN
4100             ln_bal_edu_cess_credit := ln_total_excise_edu_cess_amt/2;
4101             ln_bal_edu_cess_debit := null;
4102           END IF;
4103           -- End, Vijay Shankar for Bug#3940588
4104    /*added the following by vkaranam for budget 07 impact - bug#5989740*/
4105 	IF ln_sh_exc_edu_cess_accnt IS NOT NULL AND ln_cenvat_accnt_id IS NOT NULL
4106 	  AND ln_sh_exc_edu_cess_accnt = ln_cenvat_accnt_id
4107 	THEN
4108 	  ln_debit            := ln_debit + ln_sh_total_exc_edu_cess_amt/2;
4109 	  ln_sh_edu_cess_debit   := null;
4110 	-- if different account is specified for Cess, then we pass separate entry for cess and balance the amount with balance entry
4111 	ELSIF ln_sh_total_exc_edu_cess_amt <> 0 THEN
4112 	  ln_sh_edu_cess_debit   := ln_sh_total_exc_edu_cess_amt/2;
4113 	END IF;
4114 	ln_sh_edu_cess_credit  := null;
4115 
4116 	-- this is required in case Excise Rcvble and Edu Cess Rcvble are same, so that no separate accnt entry for Cess Rcvble Amount
4117 	IF ln_sh_exc_edu_cess_rcvb_accnt IS NOT NULL AND ln_cenvat_rcvble_accnt_id IS NOT NULL
4118 	  AND ln_cenvat_rcvble_accnt_id = ln_sh_exc_edu_cess_rcvb_accnt
4119 	THEN
4120 	  ln_balancing_credit := ln_balancing_credit + ln_sh_total_exc_edu_cess_amt/2;
4121 	  ln_sh_bal_edu_cess_debit  := null;
4122 	  ln_sh_bal_edu_cess_credit := null;
4123 	ELSIF ln_sh_total_exc_edu_cess_amt <> 0 THEN
4124 	  ln_sh_bal_edu_cess_credit := ln_sh_total_exc_edu_cess_amt/2;
4125 	  ln_sh_bal_edu_cess_debit := null;
4126 	END IF;
4127    -- End bug 5989740
4128 
4129         END IF;
4130 
4131       ELSE
4132         FND_FILE.put_line(FND_FILE.log, '**** CGIN_CODE Not Handled ****');
4133 
4134         p_process_message   := 'CGIN_CODE Not Handled';
4135         GOTO end_of_accounting;
4136       END IF;
4137 
4138       lv_statement_id := '13';
4139       p_codepath := jai_general_pkg.plot_codepath(16, p_codepath); /* 16 */
4140       if lb_rg_debug then
4141         FND_FILE.put_line(FND_FILE.log,'21 jai_rcv_accounting_pkg.process_transaction'
4142           ||' Debit:'||ln_debit||', Credit:'||ln_credit||', CenvatAccntId:'||ln_cenvat_accnt_id);
4143       end if;
4144 
4145       lv_statement_id := '13a';
4146       p_codepath := jai_general_pkg.plot_codepath(17, p_codepath); /* 17 */
4147       -- SecondSet First Entry_1: Cenvat Accounting
4148       -- bug 5581319. Added by Lakshmi Gopalsami
4149      IF NVL(ln_balancing_debit,0) <> 0 OR NVL(ln_balancing_credit,0) <> 0 THEN
4150 
4151       fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 24');
4152       jai_rcv_accounting_pkg.process_transaction(
4153           P_TRANSACTION_ID       => p_transaction_id,
4154           P_ACCT_TYPE            => lv_accnt_type,
4155           P_ACCT_NATURE          => lv_accnt_nature,
4156           P_SOURCE_NAME          => gv_source_name,
4157           P_CATEGORY_NAME        => gv_category_name,
4158           P_CODE_COMBINATION_ID  => ln_cenvat_accnt_id,
4159           P_ENTERED_DR           => ln_debit,
4160           P_ENTERED_CR           => ln_credit,
4161           P_CURRENCY_CODE        => jai_rcv_trx_processing_pkg.gv_func_curr,
4162           P_ACCOUNTING_DATE      => lv_accounting_date,
4163           P_REFERENCE_10         => lv_reference10,
4164           P_REFERENCE_23         => 'jai_rcv_excise_processing_pkg.accounting_entries',
4165           P_REFERENCE_24         => 'rcv_transactions',
4166           P_REFERENCE_25         => 'transaction_id',
4167           P_REFERENCE_26         => to_char(p_transaction_id),
4168           P_DESTINATION          => 'G',
4169           P_SIMULATE_FLAG        => p_simulate_flag,
4170           P_CODEPATH             => p_codepath,
4171           P_PROCESS_STATUS       => p_process_status,
4172           P_PROCESS_MESSAGE      => p_process_message,
4173           p_reference_name       => pv_retro_reference, /*added by rchandan*/
4174 	  p_reference_id         => 7 /*added by ssawant for bug 6084771*/
4175       );
4176 
4177       IF p_process_status IN ('E', 'X') THEN
4178         GOTO end_of_accounting;
4179       END IF;
4180     END IF;
4181     -- bug 5581319
4182 
4183       -- Vijay Shankar for Bug#3940588 EDUCATION CESS Accoounting
4184       IF nvl(ln_edu_cess_debit,0)<>0 OR nvl(ln_edu_cess_credit,0)<>0 THEN
4185 
4186         if lb_rg_debug then
4187           FND_FILE.put_line(FND_FILE.log,'21_1 Cess Accnt - '
4188             ||' Dr:'||ln_edu_cess_debit||', Cr:'||ln_edu_cess_credit||', Cess Accnt:'||ln_exc_edu_cess_accnt);
4189         end if;
4190         -- SecondSet First Entry_2: Education Cess Accounting
4191         lv_statement_id := '13z';
4192         p_codepath := jai_general_pkg.plot_codepath(17, p_codepath); /* 17 */
4193         -- SecondSet First Entry: cenvat Accounting
4194     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 25');
4195         jai_rcv_accounting_pkg.process_transaction(
4196             P_TRANSACTION_ID       => p_transaction_id,
4197             P_ACCT_TYPE            => lv_accnt_type,
4198             P_ACCT_NATURE          => lv_accnt_nature,
4199             P_SOURCE_NAME          => gv_source_name,
4200             P_CATEGORY_NAME        => gv_category_name,
4201             P_CODE_COMBINATION_ID  => ln_exc_edu_cess_accnt,
4202             P_ENTERED_DR           => ln_edu_cess_debit,
4203             P_ENTERED_CR           => ln_edu_cess_credit,
4204             P_CURRENCY_CODE        => jai_rcv_trx_processing_pkg.gv_func_curr,
4205             P_ACCOUNTING_DATE      => lv_accounting_date,
4206             P_REFERENCE_10         => lv_reference10,
4207             P_REFERENCE_23         => 'jai_rcv_excise_processing_pkg.accounting_entries',
4208             P_REFERENCE_24         => 'rcv_transactions',
4209             P_REFERENCE_25         => 'transaction_id',
4210             P_REFERENCE_26         => to_char(p_transaction_id),
4211             P_DESTINATION          => 'G',
4212             P_SIMULATE_FLAG        => p_simulate_flag,
4213             P_CODEPATH             => p_codepath,
4214             P_PROCESS_STATUS       => p_process_status,
4215             P_PROCESS_MESSAGE      => p_process_message,
4216             p_reference_name       => pv_retro_reference, /*added by rchandan*/
4217 	    p_reference_id         => 8 /*added by ssawant for bug 6084771*/
4218         );
4219 
4220         IF p_process_status IN ('E', 'X') THEN
4221           GOTO end_of_accounting;
4222         END IF;
4223 
4224       END IF;
4225  /*added the following by vkaranam for budget 07 impact - bug#5989740*/
4226     --start
4227     IF nvl(ln_sh_edu_cess_debit,0)<>0 OR nvl(ln_sh_edu_cess_credit,0)<>0 THEN
4228 
4229 	    if lb_rg_debug then
4230 	    FND_FILE.put_line(FND_FILE.log,'21_2 Cess Accnt - '
4231 	      ||' Dr:'||ln_sh_edu_cess_debit||', Cr:'||ln_sh_edu_cess_credit||', SH Cess Accnt:'||ln_sh_exc_edu_cess_accnt);
4232 	  end if;
4233 	  -- SecondSet First Entry_2: SH Education Cess Accounting
4234 	  lv_statement_id := '13x';
4235 	  p_codepath := jai_general_pkg.plot_codepath(20, p_codepath);
4236 	  -- SecondSet First Entry: cenvat Accounting
4237 	  jai_rcv_accounting_pkg.process_transaction(
4238 	      P_TRANSACTION_ID       => p_transaction_id,
4239 	      P_ACCT_TYPE            => lv_accnt_type,
4240 	      P_ACCT_NATURE          => lv_accnt_nature,
4241 	      P_SOURCE_NAME          => gv_source_name,
4242 	      P_CATEGORY_NAME        => gv_category_name,
4243 	      P_CODE_COMBINATION_ID  => ln_sh_exc_edu_cess_accnt,
4244 	      P_ENTERED_DR           => ln_sh_edu_cess_debit,
4245 	      P_ENTERED_CR           => ln_sh_edu_cess_credit,
4246 	      P_CURRENCY_CODE        => jai_rcv_trx_processing_pkg.gv_func_curr,
4247 	      P_ACCOUNTING_DATE      => lv_accounting_date,
4248 	      P_REFERENCE_10         => lv_reference10,
4249 	      P_REFERENCE_23         => 'jai_rcv_excise_processing_pkg.accounting_entries',
4250 	      P_REFERENCE_24         => 'rcv_transactions',
4251 	      P_REFERENCE_25         => 'transaction_id',
4252 	      P_REFERENCE_26         => to_char(p_transaction_id),
4253 	      P_DESTINATION          => 'G',
4254 	      P_SIMULATE_FLAG        => p_simulate_flag,
4255 	      P_CODEPATH             => p_codepath,
4256 	      P_PROCESS_STATUS       => p_process_status,
4257 	      P_PROCESS_MESSAGE      => p_process_message,
4258 	      p_reference_name       => pv_retro_reference, /*added by rchandan*/
4259               p_reference_id         => 9  /*added by ssawant for bug 6084771*/
4260 	  );
4261 
4262 	  IF p_process_status IN ('E', 'X') THEN
4263 	    GOTO end_of_accounting;
4264 	  END IF;
4265 
4266     END IF;
4267     --end 5989740
4268 
4269 
4270       FND_FILE.put_line( FND_FILE.log, 'Codepath->'||p_codepath);
4271       if lb_rg_debug then
4272         FND_FILE.put_line(FND_FILE.log,'22 jai_rcv_accounting_pkg.process_transaction'
4273           ||' Debit:'||ln_balancing_debit||', Credit:'||ln_balancing_credit||', CenRcvbleAccntId:'||ln_cenvat_rcvble_accnt_id);
4274       end if;
4275 
4276       lv_statement_id := '13b';
4277       p_codepath := jai_general_pkg.plot_codepath(18, p_codepath); /* 18 */
4278       -- SecondSet Balancing Entry: Cenvat Receivable Accounting
4279       -- bug 5581319. Added by Lakshmi Gopalsami
4280       IF NVL(ln_balancing_debit,0) <> 0 OR NVL(ln_balancing_credit,0) <> 0 THEN
4281 
4282       fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 26');
4283       jai_rcv_accounting_pkg.process_transaction(
4284           P_TRANSACTION_ID       => p_transaction_id,
4285           P_ACCT_TYPE            => lv_accnt_type,
4286           P_ACCT_NATURE          => lv_accnt_nature,
4287           P_SOURCE_NAME          => gv_source_name,
4288           P_CATEGORY_NAME        => gv_category_name,
4289           P_CODE_COMBINATION_ID  => ln_cenvat_rcvble_accnt_id,
4290           P_ENTERED_DR           => ln_balancing_debit,
4291           P_ENTERED_CR           => ln_balancing_credit,
4292           P_CURRENCY_CODE        => jai_rcv_trx_processing_pkg.gv_func_curr,
4293           P_ACCOUNTING_DATE      => lv_accounting_date,
4294           P_REFERENCE_10         => lv_reference10,
4295           P_REFERENCE_23         => 'jai_rcv_excise_processing_pkg.accounting_entries',
4296           P_REFERENCE_24         => 'rcv_transactions',
4297           P_REFERENCE_25         => 'transaction_id',
4298           P_REFERENCE_26         => to_char(p_transaction_id),
4299           P_DESTINATION          => 'G',
4300           P_SIMULATE_FLAG        => p_simulate_flag,
4301           P_CODEPATH             => p_codepath,
4302           P_PROCESS_STATUS       => p_process_status,
4303           P_PROCESS_MESSAGE      => p_process_message,
4304           p_reference_name       => pv_retro_reference, /*added by rchandan*/
4305 	  p_reference_id         => 10 /*added by ssawant for bug 6084771*/
4306       );
4307 
4308       IF p_process_status IN ('E', 'X') THEN
4309         GOTO end_of_accounting;
4310       END IF;
4311      END IF;
4312      -- Bug 5581319
4313 
4314       -- Vijay Shankar for Bug#3940588 EDUCATION CESS ACCOUNTING
4315       IF nvl(ln_bal_edu_cess_debit,0)<>0 OR nvl(ln_bal_edu_cess_credit,0)<>0  THEN
4316 
4317         if lb_rg_debug then
4318           FND_FILE.put_line(FND_FILE.log,'22_2 Cess Rcvble accnt'
4319             ||' Dr:'||ln_bal_edu_cess_debit||', Cr:'||ln_bal_edu_cess_credit||', CessRcvbleAccnt:'||ln_cenvat_rcvble_accnt_id);
4320         end if;
4321 
4322         lv_statement_id := '13b';
4323         p_codepath := jai_general_pkg.plot_codepath(18, p_codepath); /* 18 */
4324         -- SecondSet Balancing Entry: Cenvat Receivable Accounting
4325     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 27');
4326         jai_rcv_accounting_pkg.process_transaction(
4327             P_TRANSACTION_ID       => p_transaction_id,
4328             P_ACCT_TYPE            => lv_accnt_type,
4329             P_ACCT_NATURE          => lv_accnt_nature,
4330             P_SOURCE_NAME          => gv_source_name,
4331             P_CATEGORY_NAME        => gv_category_name,
4332             P_CODE_COMBINATION_ID  => ln_exc_edu_cess_rcvble_accnt,
4333             P_ENTERED_DR           => ln_bal_edu_cess_debit,
4334             P_ENTERED_CR           => ln_bal_edu_cess_credit,
4335             P_CURRENCY_CODE        => jai_rcv_trx_processing_pkg.gv_func_curr,
4336             P_ACCOUNTING_DATE      => lv_accounting_date,
4337             P_REFERENCE_10         => lv_reference10,
4338             P_REFERENCE_23         => 'jai_rcv_excise_processing_pkg.accounting_entries',
4339             P_REFERENCE_24         => 'rcv_transactions',
4340             P_REFERENCE_25         => 'transaction_id',
4341             P_REFERENCE_26         => to_char(p_transaction_id),
4342             P_DESTINATION          => 'G',
4343             P_SIMULATE_FLAG        => p_simulate_flag,
4344             P_CODEPATH             => p_codepath,
4345             P_PROCESS_STATUS       => p_process_status,
4346             P_PROCESS_MESSAGE      => p_process_message,
4347             p_reference_name       => pv_retro_reference, /*added by rchandan*/
4348 	    p_reference_id         => 11 /*added by ssawant for bug 6084771*/
4349         );
4350 
4351         IF p_process_status IN ('E', 'X') THEN
4352           GOTO end_of_accounting;
4353         END IF;
4354 
4355       END IF;
4356       -- END EDUCATION CESS ACCOUNTING
4357 /*added the following by vkaranam for budget 07 impact - bug#5989740*/
4358     --start
4359     IF nvl(ln_sh_bal_edu_cess_debit,0)<>0 OR nvl(ln_sh_bal_edu_cess_credit,0)<>0  THEN
4360 
4361 	      if lb_rg_debug then
4362 	        FND_FILE.put_line(FND_FILE.log,'22_3 Cess Rcvble accnt'
4363 	          ||' Dr:'||ln_sh_bal_edu_cess_debit||', Cr:'||ln_sh_bal_edu_cess_credit||', SH CessRcvbleAccnt:'||ln_cenvat_rcvble_accnt_id);
4364 	      end if;
4365 
4366 	      lv_statement_id := '13d';
4367 	      p_codepath := jai_general_pkg.plot_codepath(20, p_codepath); /* 18 */
4368 	      -- SecondSet Balancing Entry: Cenvat Receivable Accounting
4369 	     jai_rcv_accounting_pkg.process_transaction(
4370 	          P_TRANSACTION_ID       => p_transaction_id,
4371 	          P_ACCT_TYPE            => lv_accnt_type,
4372 	          P_ACCT_NATURE          => lv_accnt_nature,
4373 	          P_SOURCE_NAME          => gv_source_name,
4374 	          P_CATEGORY_NAME        => gv_category_name,
4375 	          P_CODE_COMBINATION_ID  => ln_sh_exc_edu_cess_rcvb_accnt,
4376 	          P_ENTERED_DR           => ln_sh_bal_edu_cess_debit,
4377 	          P_ENTERED_CR           => ln_sh_bal_edu_cess_credit,
4378 	          P_CURRENCY_CODE        => jai_rcv_trx_processing_pkg.gv_func_curr,
4379 	          P_ACCOUNTING_DATE      => lv_accounting_date,
4380 	          P_REFERENCE_10         => lv_reference10,
4381 	          P_REFERENCE_23         => 'jai_rcv_excise_processing_pkg.accounting_entries',
4382 	          P_REFERENCE_24         => 'rcv_transactions',
4383 	          P_REFERENCE_25         => 'transaction_id',
4384 	          P_REFERENCE_26         => to_char(p_transaction_id),
4385 	          P_DESTINATION          => 'G',
4386 	          P_SIMULATE_FLAG        => p_simulate_flag,
4387 	          P_CODEPATH             => p_codepath,
4388 	          P_PROCESS_STATUS       => p_process_status,
4389 	          P_PROCESS_MESSAGE      => p_process_message,
4390 	          p_reference_name       => pv_retro_reference, /*added by rchandan*/
4391 		  p_reference_id         => 12 /*added by ssawant for bug 6084771*/
4392 	      );
4393 
4394 	      IF p_process_status IN ('E', 'X') THEN
4395 	        GOTO end_of_accounting;
4396 	      END IF;
4397 
4398 	END IF;
4399 	-- END bug 5989740
4400 
4401 
4402 
4403     END IF;
4404 
4405     <<end_of_accounting>>
4406     NULL;
4407 
4408     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 28a');
4409     p_codepath := jai_general_pkg.plot_codepath(19, p_codepath, null, 'END'); /* 19 */
4410     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- 28');
4411   EXCEPTION
4412     WHEN OTHERS THEN
4413       p_process_status := 'E';
4414     fnd_file.put_line(FND_FILE.LOG, ' <jai_rcv_exc_prc.plb --- ERR 29');
4415       p_process_message := 'CENVAT_RG_PKG.accounting_entries->'||SQLERRM||', StmtId->'||lv_statement_id;
4416       FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
4417       p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END');
4418 
4419   END accounting_entries;
4420 
4421 
4422   PROCEDURE update_registers(
4423     p_quantity_register_id  IN  NUMBER,
4424     p_quantity_register     IN  VARCHAR2,
4425     p_payment_register_id   IN  NUMBER,
4426     p_payment_register      IN  VARCHAR2,
4427     p_charge_account_id     IN  NUMBER,
4428     p_process_status OUT NOCOPY VARCHAR2,
4429     p_process_message OUT NOCOPY VARCHAR2,
4430     p_simulate_flag         IN  VARCHAR2,
4431     p_codepath              IN OUT NOCOPY VARCHAR2
4432   ) IS
4433 
4434     lv_statement_id   VARCHAR2(5);
4435   BEGIN
4436 
4437     lv_statement_id := '1';
4438     p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'cenvat_rg.update_reg' , 'START'); /* 1 */
4439     if lb_rg_debug then
4440       /*dbms_output.put_line('^ Upd_Regs. Payid:'||p_payment_register_id
4441         ||', PayReg:'||p_payment_register
4442         ||', Qtyid:'||p_quantity_register_id
4443         ||', QtyReg:'||p_quantity_register
4444         ||', ChrgAccnt:'||p_charge_account_id); */
4445       fnd_file.put_line(fnd_file.log, '^ Upd_Regs. Payid:'||p_payment_register_id
4446         ||', PayReg:'||p_payment_register
4447         ||', Qtyid:'||p_quantity_register_id
4448         ||', QtyReg:'||p_quantity_register
4449         ||', ChrgAccnt:'||p_charge_account_id);
4450     end if;
4451 
4452     IF p_quantity_register IN ('RG23A', 'RG23C') THEN
4453       lv_statement_id := '2';
4454       p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
4455       jai_cmn_rg_23ac_i_trxs_pkg.update_payment_details(
4456         p_register_id         => p_quantity_register_id,
4457         p_register_id_part_ii => p_payment_register_id,
4458         p_charge_account_id   => p_charge_account_id
4459       );
4460 
4461     ELSIF p_quantity_register = 'RG23D' THEN
4462       lv_statement_id := '3';
4463       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
4464       jai_cmn_rg_23d_trxs_pkg.update_payment_details(
4465         p_register_id         => p_quantity_register_id,
4466         p_charge_account_id   => p_charge_account_id
4467       );
4468 
4469     ELSIF p_quantity_register = 'RG1' THEN
4470       lv_statement_id := '4';
4471       p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
4472       UPDATE JAI_CMN_RG_I_TRXS
4473       SET
4474         register_id_part_ii = p_payment_register_id,
4475         charge_account_id   = p_charge_account_id,
4476         payment_register    = p_payment_register
4477       WHERE register_id = p_quantity_register_id;
4478 
4479     ELSE
4480       FND_FILE.put_line( FND_FILE.log, 'JA_IN_RECEIPT_MODVAT_RG_PKG.update_registers: No Quantity Register Updated');
4481     END IF;
4482 
4483     IF p_payment_register IN ('RG23A', 'RG23C') THEN
4484       lv_statement_id := '5';
4485       p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
4486       jai_cmn_rg_23ac_ii_pkg.update_payment_details(
4487         p_register_id         => p_payment_register_id,
4488         p_register_id_part_i  => p_quantity_register_id,
4489         p_charge_account_id   => p_charge_account_id
4490       );
4491 
4492     ELSIF p_payment_register = 'PLA' THEN
4493       lv_statement_id := '6';
4494       p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
4495       jai_cmn_rg_pla_trxs_pkg.update_payment_details(
4496         p_register_id         => p_payment_register_id,
4497         p_charge_account_id   => p_charge_account_id
4498       );
4499 
4500     ELSE
4501       p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
4502       FND_FILE.put_line( FND_FILE.log, 'JA_IN_RECEIPT_MODVAT_RG_PKG.update_registers: No Payment Register Updated');
4503     END IF;
4504 
4505     p_codepath := jai_general_pkg.plot_codepath(8, p_codepath, NULL, 'END'); /* 8 */
4506 
4507   EXCEPTION
4508     WHEN OTHERS THEN
4509       p_process_status := 'E';
4510       p_process_message := 'CENVAT_RG_PKG.update_registers->'||SQLERRM||', StmtId->'||lv_statement_id;
4511       FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
4512       p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END');
4513 
4514   END update_registers;
4515 
4516   -- If this function returns a message, then it means there is some problem and processing should be stopped
4517   PROCEDURE validate_transaction(
4518     p_transaction_id    IN NUMBER,
4519     p_validation_type   IN VARCHAR2,
4520     p_process_status OUT NOCOPY VARCHAR2,
4521     p_process_message OUT NOCOPY VARCHAR2,
4522     p_simulate_flag     IN VARCHAR2,
4523     p_codepath          IN OUT NOCOPY VARCHAR2
4524   ) IS
4525 
4526     r_trx                   c_trx%ROWTYPE;
4527     r_base_trx              c_base_trx%ROWTYPE;
4528     lv_validation_message   VARCHAR2(100);
4529     lv_transaction_type     RCV_TRANSACTIONS.transaction_type%TYPE;
4530 
4531     lv_include_cenvat_in_cost   VARCHAR2(5);
4532 
4533     CURSOR c_rg23_part_ii_chk(cp_transaction_id IN NUMBER) IS
4534       SELECT count(1)
4535       FROM JAI_CMN_RG_23AC_II_TRXS;
4536 
4537     lv_statement_id     VARCHAR2(5);
4538 
4539     r_jai_receipt_line    c_jai_receipt_line%ROWTYPE;   -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh.
4540     lv_source_req         CONSTANT VARCHAR2(3)   := 'REQ';
4541   BEGIN
4542 
4543     if lb_rg_debug then
4544       FND_FILE.put_line(FND_FILE.log,'^ Validate');
4545     end if;
4546 
4547     lv_statement_id := '1';
4548     p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'cenvat_rg.validate', 'START'); /* 1 */
4549     OPEN c_trx(p_transaction_id);
4550     FETCH c_trx INTO r_trx;
4551     CLOSE c_trx;
4552 
4553     lv_statement_id := '2';
4554     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
4555     OPEN c_base_trx(p_transaction_id);
4556     FETCH c_base_trx INTO r_base_trx;
4557     CLOSE c_base_trx;
4558 
4559     IF r_trx.transaction_type = 'CORRECT' THEN
4560       lv_transaction_type := r_trx.parent_transaction_type;
4561     ELSE
4562       lv_transaction_type := r_trx.transaction_type;
4563     END IF;
4564 
4565     OPEN c_jai_receipt_line(r_trx.shipment_line_id);
4566     FETCH c_jai_receipt_line INTO r_jai_receipt_line;
4567     CLOSE c_jai_receipt_line;
4568 
4569     IF p_validation_type = 'COMMON' THEN
4570 
4571       lv_statement_id := '5';
4572       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
4573       --upper added by narao.
4574       -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. IF r_base_trx.attr_cat = 'India RMA Receipt' AND upper(r_base_trx.rma_type) NOT IN ('PRODUCTION INPUT', 'GOODS RETURN') THEN
4575        /*
4576        ||Start of bug 5378630
4577        ||Modified the below if statement condition such that the RMA_type 'GOODS RETURN' was changed into GOODS RETURN
4578        */
4579       IF r_base_trx.source_document_code = jai_rcv_trx_processing_pkg.source_rma
4580         AND upper(r_jai_receipt_line.rma_type) NOT IN ('PRODUCTION INPUT', 'GOODS RETURN')
4581       THEN
4582         /* End of bug 5378630 */
4583         lv_validation_message := 'RMA Type Not supported';
4584 
4585       -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. ELSIF r_base_trx.attr_cat = 'India Receipt'  THEN
4586       ELSIF r_base_trx.source_document_code IN ( jai_constants.source_po,lv_source_req ) THEN /* added by aiyer for the bug 5378630 */
4587         IF r_trx.organization_type = 'M' AND r_trx.item_class IN ('FGIN', 'FGEX')
4588 	   and r_base_trx.source_document_code <> 'INVENTORY'  THEN /* 6030615 - interorg  */
4589           lv_validation_message := 'Item Class not supported for Manufacturing Transactions';
4590 
4591         --ELSIF r_trx.organization_type = 'T' AND r_trx.item_class = jai_rcv_trx_processing_pkg.NO_SETUP THEN
4592         --
4593         ELSE
4594           lv_statement_id := '5.1';
4595         END IF;
4596 
4597       -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. ELSE
4598       --  lv_statement_id := '5.2';
4599 
4600       END IF;
4601 
4602       IF lv_transaction_type = 'RECEIVE' THEN
4603         lv_statement_id := '6';
4604         p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
4605         IF r_trx.organization_type = 'M' THEN
4606           IF r_trx.item_cenvatable <> 'Y' THEN
4607             lv_validation_message := 'Item is not a Cenvatable one';
4608           END IF;
4609 
4610         ELSIF r_trx.organization_type = 'T' THEN
4611           IF r_trx.item_trading_flag <> 'Y' THEN
4612             lv_validation_message := 'Item is not a Tradable one';
4613           --ELSIF r_trx.excise_in_trading <> 'Y' THEN
4614           --  lv_validation_message := 'Oraganization Setup for Excise in Trading is not checked';
4615           ELSIF r_trx.item_excisable <> 'Y' THEN
4616             lv_validation_message := 'Trading Item is not excisable';
4617           END IF;
4618         ELSE
4619           lv_validation_message := 'No Setup for Organization';
4620         END IF;
4621 
4622       ELSIF lv_transaction_type IN ('DELIVER', 'RETURN TO RECEIVING') THEN
4623 
4624         lv_statement_id := '7';
4625         p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
4626         IF r_trx.organization_type = 'T' THEN
4627           lv_validation_message := 'No Cenvat/RG Entries are passed for '||lv_transaction_type;
4628           GOTO end_of_validation;
4629         END IF;
4630 
4631         lv_statement_id := '7.1';
4632         p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
4633         lv_include_cenvat_in_cost := jai_rcv_deliver_rtr_pkg.include_cenvat_in_costing(
4634                                         p_transaction_id    => p_transaction_id,
4635                                         p_process_message   => p_process_message,
4636                                         p_process_status    => p_process_status,
4637                                         p_codepath          => p_codepath
4638                                      );
4639 
4640         IF p_process_status IN ('E', 'X') THEN
4641           RETURN;
4642         END IF;
4643 
4644         -- if the following condition is satisfied, then we need not pass any CENVAT entries during DELIVER or RTR transactions
4645         IF lv_include_cenvat_in_cost = 'N' THEN
4646           lv_validation_message := 'Cenvat Entries are not required for Transaction';
4647           GOTO end_of_validation;
4648         END IF;
4649 
4650       ELSIF lv_transaction_type = 'RETURN TO VENDOR' THEN
4651 
4652         lv_statement_id := '8';
4653         p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
4654         IF r_trx.organization_type = 'T' THEN
4655           IF r_trx.item_trading_flag <> 'Y' THEN
4656             lv_validation_message := 'Item is not a Tradable one';
4657           --ELSIF r_trx.excise_in_trading <> 'Y' THEN
4658           --  lv_validation_message := 'Organization Setup for Excise In RG23D is not done';
4659           ELSIF r_trx.item_excisable <> 'Y' THEN
4660             lv_validation_message := 'Trading Item is not excisable';
4661 
4662           END IF;
4663         END IF;
4664 
4665       END IF;
4666 
4667     ELSIF p_validation_type IN ('RECEIVE', 'RETURN TO VENDOR') THEN
4668       -- lv_validation_message := 'Item Class not supported';
4669       NULL;
4670     ELSIF p_validation_type IN ('DELIVER', 'RETURN TO RECEIVING') THEN
4671       NULL;
4672     ELSE
4673       NULL;
4674     END IF;
4675 
4676     <<end_of_validation>>
4677 
4678     lv_statement_id := '9';
4679     p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
4680     IF lv_validation_message IS NOT NULL THEN
4681       p_process_status  := 'X';
4682       p_process_message := lv_validation_message;
4683     END IF;
4684 
4685     p_codepath := jai_general_pkg.plot_codepath(9, p_codepath, NULL, 'END'); /* 9 */
4686 
4687   EXCEPTION
4688     WHEN OTHERS THEN
4689       p_process_status := 'E';
4690       p_process_message := 'CENVAT_RG_PKG.validate_transaction->'||SQLERRM||', StmtId->'||lv_statement_id;
4691       FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
4692       p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END');
4693 
4694   END validate_transaction;
4695 
4696   -- This procedure assumes that this is called only at the time of RTV
4697   PROCEDURE generate_excise_invoice(
4698     p_transaction_id          IN  NUMBER,
4699     p_organization_id         IN  NUMBER,
4700     p_location_id             IN  NUMBER,
4701     p_excise_invoice_no OUT NOCOPY VARCHAR2,
4702     p_excise_invoice_date OUT NOCOPY DATE,
4703     p_simulate_flag           IN VARCHAR2,
4704     p_errbuf OUT NOCOPY VARCHAR2,
4705     p_codepath                IN OUT NOCOPY VARCHAR2
4706   ) IS
4707 
4708     CURSOR c_rtv_excise_inv_no(cp_transaction_id IN NUMBER) IS
4709       SELECT excise_invoice_no, excise_invoice_date
4710       FROM JAI_RCV_RTV_DTLS
4711       WHERE transaction_id = cp_transaction_id;
4712 
4713     r_trx       c_trx%ROWTYPE;
4714     lv_statement_id   VARCHAR2(5);
4715   BEGIN
4716 
4717     if lb_rg_debug then
4718       FND_FILE.put_line(FND_FILE.log,'^ Gen_Exc_inv');
4719     end if;
4720 
4721     lv_statement_id := '1';
4722     p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'cenvat_rg.generate_exc_inv', 'START'); /* 1 */
4723     OPEN c_trx(p_transaction_id);
4724     FETCH c_trx INTO r_trx;
4725     CLOSE c_trx;
4726 
4727     IF r_trx.transaction_type = 'CORRECT' THEN
4728       lv_statement_id := '2';
4729       p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
4730 
4731       OPEN c_rtv_excise_inv_no(r_trx.parent_transaction_id);
4732       FETCH c_rtv_excise_inv_no INTO p_excise_invoice_no, p_excise_invoice_date;
4733       CLOSE c_rtv_excise_inv_no;
4734     ELSE
4735       lv_statement_id := '3';
4736       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
4737       jai_cmn_setup_pkg.generate_excise_invoice_no(
4738           p_organization_id       => p_organization_id,
4739           p_location_id           => p_location_id,
4740           p_called_from           => 'P',         -- Required for excise generation during RTV
4741           p_order_invoice_type_id => NULL,
4742           p_fin_year              => jai_general_pkg.get_fin_year(p_organization_id),
4743           p_excise_inv_no         => p_excise_invoice_no,
4744           p_errbuf                => p_errbuf
4745       );
4746 
4747       IF p_excise_invoice_no IS NOT NULL THEN
4748         p_excise_invoice_date := trunc(SYSDATE);
4749       END IF;
4750     END IF;
4751 
4752     p_codepath := jai_general_pkg.plot_codepath(4, p_codepath, NULL, 'END'); /* 4 */
4753 
4754   EXCEPTION
4755     WHEN OTHERS THEN
4756       p_errbuf := 'CENVAT_RG_PKG.generate_excise_invoice->'||SQLERRM||', StmtId->'||lv_statement_id;
4757       FND_FILE.put_line( FND_FILE.log, 'Error in '||p_errbuf);
4758       p_codepath := jai_general_pkg.plot_codepath(999, p_errbuf, null, 'END');
4759       RAISE;
4760 
4761   END generate_excise_invoice;
4762 
4763   FUNCTION get_receive_claimed_ptg(
4764     p_transaction_id     IN  NUMBER,
4765     p_shipment_line_id  IN  NUMBER,
4766     p_codepath        IN OUT NOCOPY VARCHAR2
4767   ) RETURN NUMBER IS
4768 
4769     CURSOR c_cenvat_claimed_ptg(cp_shipment_line_id IN NUMBER) IS
4770       SELECT nvl(cenvat_claimed_ptg,0)
4771       FROM JAI_RCV_CENVAT_CLAIMS
4772       WHERE shipment_line_id = cp_shipment_line_id;
4773 
4774     ln_cenvat_claimed_ptg         NUMBER;
4775     lv_object_name CONSTANT VARCHAR2 (61) := 'jai_rcv_excise_processing_pkg.get_receive_claimed_ptg';
4776 
4777     --ln_ancestor_receive_trxn_id   JAI_RCV_TRANSACTIONS.transaction_id%TYPE;
4778 
4779   BEGIN
4780 
4781   /*
4782     Ancestor should be a RECEIVE type of transaction, because CENVAT is claimed only for RECEIVE transaction and all other
4783     transactions follow this
4784     This is the function that should be changed if all Receipt Queries should be based on TRANSACTION_ID instead of SHIPMENT_LINE_ID
4785   */
4786     --ln_ancestor_receive_trxn_id :=
4787     --    jai_rcv_trx_processing_pkg.get_ancestor_id(p_transaction_id, p_shipment_line_id, 'RECEIVE');
4788 
4789     -- commented as pert of review and modified  p_shipment_line_id -> p_transaction_id
4790     p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'cenvat_rg.get_receive_claimed_ptg', 'START'); /* 1 */
4791     OPEN c_cenvat_claimed_ptg(p_shipment_line_id);
4792     FETCH c_cenvat_claimed_ptg INTO ln_cenvat_claimed_ptg;
4793     CLOSE c_cenvat_claimed_ptg;
4794 
4795     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath, NULL, 'END'); /* 2 */
4796 
4797     RETURN ln_cenvat_claimed_ptg;
4798   EXCEPTION
4799     WHEN OTHERS THEN
4800     FND_MESSAGE.SET_NAME ('JA','JAI_EXCEPTION_OCCURED');
4801     FND_MESSAGE.SET_TOKEN ('JAI_PROCESS_MSG',lv_object_name ||'.Err:'||sqlerrm);
4802     app_exception.raise_exception;
4803   END get_receive_claimed_ptg;
4804 
4805   /*~~~~~~~~~~~~~~~~~~~~~~~~~ TAX BREAUP ~~~~~~~~~~~~~~~~~~~~~~~~~~*/
4806 
4807   PROCEDURE get_tax_amount_breakup(
4808     p_shipment_line_id  IN      NUMBER,
4809     p_transaction_id    IN      NUMBER,
4810     p_curr_conv_rate    IN      NUMBER,
4811     pr_tax              OUT NOCOPY TAX_BREAKUP,
4812     p_breakup_type      IN      VARCHAR2,
4813     p_codepath          IN OUT NOCOPY VARCHAR2
4814   ) IS
4815 
4816     ln_curr_conv            NUMBER;
4817     ln_mod_problem_amt      NUMBER;
4818     ln_nonmod_problem_amt   NUMBER;
4819     ln_apportion_factor     NUMBER;
4820     lv_object_name CONSTANT VARCHAR2 (61) := 'jai_rcv_excise_processing_pkg.get_tax_amount_breakup';
4821 
4822   BEGIN
4823     /* This procedure returns excise amounts as per transaction quantity
4824     If p_breakup_type is RG23D, then total tax amount should be added to excise amount instead of taking
4825     mod_cr_percentage into consideration
4826     */
4827 
4828     p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'cenvat_rg.tax_breakup','START'); /* 1 */
4829     if lb_rg_debug then
4830       FND_FILE.put_line(FND_FILE.log,'^ tax_breakup');
4831     end if;
4832 
4833     ln_mod_problem_amt      := 0;
4834     ln_nonmod_problem_amt   := 0;
4835 
4836     ln_apportion_factor   := jai_rcv_trx_processing_pkg.get_apportion_factor(p_transaction_id);
4837 
4838     FOR tax_rec IN (SELECT  rtl.tax_type                                                                      ,
4839                             nvl(rtl.tax_amount, 0)                                              tax_amount    ,
4840                             nvl(rtl.modvat_flag, 'N')                                           modvat_flag   ,
4841                             nvl(rtl.currency, jai_rcv_trx_processing_pkg.gv_func_curr)      currency      ,
4842                             nvl(decode(p_breakup_type, 'RG23D', 100, jtc.mod_cr_percentage), 0) mod_cr_percentage,
4843                             nvl(jtc.rounding_factor, 0)                                         rnd
4844                     FROM JAI_RCV_LINE_TAXES rtl, JAI_CMN_TAXES_ALL jtc
4845                     WHERE rtl.shipment_line_id = p_shipment_line_id
4846                     AND jtc.tax_id = rtl.tax_id)
4847     LOOP
4848 
4849       p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
4850 
4851 
4852       IF tax_rec.currency <> jai_rcv_trx_processing_pkg.gv_func_curr THEN
4853         ln_curr_conv := NVL(p_curr_conv_rate, 1);
4854       ELSE
4855         ln_curr_conv := 1;
4856       END IF;
4857 
4858       IF p_breakup_type = 'RG23D' THEN    -- trading case
4859         p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
4860         IF upper(tax_rec.tax_type) = 'EXCISE' THEN
4861           p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
4862           pr_tax.basic_excise   := pr_tax.basic_excise + round(tax_rec.tax_amount * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4863 
4864         ELSIF upper(tax_rec.tax_type) = 'ADDL. EXCISE' THEN
4865           p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
4866           pr_tax.addl_excise    := pr_tax.addl_excise + round(tax_rec.tax_amount * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4867 
4868         ELSIF upper(tax_rec.tax_type) = 'OTHER EXCISE' THEN
4869           p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
4870           pr_tax.other_excise   := pr_tax.other_excise + round(tax_rec.tax_amount * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4871 
4872         ELSIF tax_rec.tax_type = 'CVD' THEN
4873           p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
4874           pr_tax.cvd      := pr_tax.cvd + round(tax_rec.tax_amount * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4875 
4876         -- Start, Vijay Shankar for Bug#3940588
4877         ELSIF tax_rec.tax_type = jai_constants.tax_type_exc_edu_cess THEN
4878           pr_tax.excise_edu_cess   := pr_tax.excise_edu_cess + round(tax_rec.tax_amount * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4879 
4880         ELSIF tax_rec.tax_type = jai_constants.tax_type_cvd_edu_cess THEN
4881           pr_tax.cvd_edu_cess   := pr_tax.cvd_edu_cess + round(tax_rec.tax_amount * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4882         -- End, Vijay Shankar for Bug#3940588
4883       /*added the following by vkaranam for budget 07 impact - bug#5989740*/
4884       --start
4885       ELSIF tax_rec.tax_type = jai_constants.tax_type_sh_cvd_edu_cess THEN
4886          pr_tax.sh_cvd_edu_cess  := nvl(pr_tax.sh_cvd_edu_cess,0) + round(tax_rec.tax_amount * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4887 
4888       ELSIF tax_rec.tax_type = jai_constants.tax_type_sh_exc_edu_cess THEN
4889 			   pr_tax.sh_exc_edu_cess  := nvl(pr_tax.sh_exc_edu_cess,0) + round(tax_rec.tax_amount * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4890 
4891       --end bug #5989740*/
4892 
4893         ELSIF tax_rec.tax_type = jai_constants.tax_type_add_cvd THEN
4894           p_codepath := jai_general_pkg.plot_codepath(7.1, p_codepath); /* 7.1 */
4895           pr_tax.addl_cvd  := pr_tax.addl_cvd + round(tax_rec.tax_amount * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4896         ELSE
4897           p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
4898           pr_tax.non_cenvat  := pr_tax.non_cenvat + round(tax_rec.tax_amount * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4899         END IF;
4900 
4901       ELSE  -- manufacturing case
4902         p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9 */
4903 
4904          IF tax_rec.modvat_flag = 'Y' AND
4905          upper(tax_rec.tax_type) IN ('EXCISE', 'ADDL. EXCISE',
4906                                'OTHER EXCISE', 'CVD',
4907              -- Bug 5143906. Added by Lakshmi Gopalsami
4908              -- Included Addl. CVD
4909              'ADDITIONAL_CVD',
4910              jai_constants.tax_type_exc_edu_cess,
4911              jai_constants.tax_type_cvd_edu_cess,
4912              /*added the following by vkaranam for budget 07 impact - bug#5989740*/
4913              jai_constants.tax_type_sh_cvd_edu_cess,
4914              jai_constants.tax_type_sh_exc_edu_cess)
4915      THEN
4916 
4917           p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10 */
4918           IF upper(tax_rec.tax_type) = 'EXCISE' THEN
4919             p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11 */
4920             pr_tax.basic_excise := pr_tax.basic_excise
4921               + round(tax_rec.tax_amount * (tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4922             pr_tax.non_cenvat := pr_tax.non_cenvat
4923               + round(tax_rec.tax_amount * (1 - tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4924 
4925           ELSIF upper(tax_rec.tax_type) = 'ADDL. EXCISE' THEN
4926             p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12 */
4927             pr_tax.addl_excise := pr_tax.addl_excise
4928               + round(tax_rec.tax_amount * (tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4929             pr_tax.non_cenvat := pr_tax.non_cenvat
4930               + round(tax_rec.tax_amount * (1 - tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4931 
4932           ELSIF upper(tax_rec.tax_type) = 'OTHER EXCISE' THEN
4933             p_codepath := jai_general_pkg.plot_codepath(13, p_codepath); /* 13 */
4934             pr_tax.other_excise := pr_tax.other_excise
4935               + round(tax_rec.tax_amount * (tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4936             pr_tax.non_cenvat := pr_tax.non_cenvat
4937               + round(tax_rec.tax_amount * (1 - tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4938 
4939           ELSIF tax_rec.tax_type IN ('CVD') THEN
4940             p_codepath := jai_general_pkg.plot_codepath(14, p_codepath); /* 14 */
4941             pr_tax.cvd := pr_tax.cvd
4942               + round(tax_rec.tax_amount * (tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4943             pr_tax.non_cenvat := pr_tax.non_cenvat
4944               + round(tax_rec.tax_amount * (1 - tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4945 -- Date 04/06/2007 by sacsethi for bug 6109941
4946 -- Code review from bug 5228046
4947           ELSIF tax_rec.tax_type IN ( jai_constants.tax_type_add_cvd) THEN
4948             p_codepath := jai_general_pkg.plot_codepath(14, p_codepath); /* 14 */
4949             pr_tax.addl_cvd := pr_tax.addl_cvd
4950               + round(tax_rec.tax_amount * (tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4951             pr_tax.non_cenvat := pr_tax.non_cenvat
4952               + round(tax_rec.tax_amount * (1 - tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4953 -------------------------------------------------
4954           -- Start, Vijay Shankar for Bug#3940588
4955           ELSIF tax_rec.tax_type = jai_constants.tax_type_exc_edu_cess THEN
4956             pr_tax.excise_edu_cess   := pr_tax.excise_edu_cess +
4957                 + round(tax_rec.tax_amount * (tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4958             pr_tax.non_cenvat := pr_tax.non_cenvat
4959               + round(tax_rec.tax_amount * (1 - tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4960 
4961           ELSIF tax_rec.tax_type = jai_constants.tax_type_cvd_edu_cess THEN
4962             pr_tax.cvd_edu_cess   := pr_tax.cvd_edu_cess
4963                 + round(tax_rec.tax_amount * (tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4964             pr_tax.non_cenvat := pr_tax.non_cenvat
4965               + round(tax_rec.tax_amount * (1 - tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4966           -- End, Vijay Shankar for Bug#3940588
4967          /*added the following by vkaranam for budget 07 impact - bug#5989740*/
4968         --start
4969         ELSIF tax_rec.tax_type = jai_constants.tax_type_sh_exc_edu_cess THEN
4970 
4971           pr_tax.sh_exc_edu_cess   := nvl(pr_tax.sh_exc_edu_cess,0)+
4972 					              + round(tax_rec.tax_amount * (tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4973 					pr_tax.non_cenvat := pr_tax.non_cenvat
4974 					            + round(tax_rec.tax_amount * (1 - tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4975 			  ELSIF tax_rec.tax_type = jai_constants.tax_type_sh_cvd_edu_cess THEN
4976 
4977 				  pr_tax.sh_cvd_edu_cess   := nvl(pr_tax.sh_cvd_edu_cess,0)+
4978 											+ round(tax_rec.tax_amount * (tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4979 				  pr_tax.non_cenvat := pr_tax.non_cenvat
4980 										+ round(tax_rec.tax_amount * (1 - tax_rec.mod_cr_percentage/100) * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4981 	--end ,for bug #5989740
4982 
4983 
4984           ELSE
4985             p_codepath := jai_general_pkg.plot_codepath(15, p_codepath); /* 15 */
4986             ln_mod_problem_amt := ln_mod_problem_amt
4987               + round(tax_rec.tax_amount * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4988           END IF;
4989 
4990         ELSIF tax_rec.modvat_flag = 'N' and tax_rec.tax_type NOT IN ('TDS', 'Modvat Recovery') THEN
4991           p_codepath := jai_general_pkg.plot_codepath(16, p_codepath); /* 16 */
4992           pr_tax.non_cenvat := pr_tax.non_cenvat
4993             + round(tax_rec.tax_amount * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4994 
4995         ELSE
4996           p_codepath := jai_general_pkg.plot_codepath(17, p_codepath); /* 17 */
4997           ln_nonmod_problem_amt := ln_nonmod_problem_amt
4998             + round(tax_rec.tax_amount * ln_curr_conv * ln_apportion_factor, tax_rec.rnd);
4999         END IF;
5000 
5001       END IF;
5002 
5003     END LOOP;
5004 
5005     if lb_rg_debug then
5006       /*dbms_output.put_line('$tax_breakup. Basic:'||pr_tax.basic_excise||', Addl:'||pr_tax.addl_excise
5007         ||', Other:'||pr_tax.other_excise||', cvd:'||pr_tax.cvd||', Addl. CVD:'|| pr_tax.addl_cvd||', exc_ces:'||pr_tax.excise_edu_cess||', cvd_ces:'||pr_tax.cvd_edu_cess );
5008 
5009         */
5010       FND_FILE.put_line(FND_FILE.log, '$tax_breakup. Basic:'||pr_tax.basic_excise||', Addl:'||pr_tax.addl_excise
5011         ||', Other:'||pr_tax.other_excise||', cvd:'||pr_tax.cvd||', Addl. CVD:'|| pr_tax.addl_cvd||', exc_ces:'||pr_tax.excise_edu_cess||', cvd_ces:'||pr_tax.cvd_edu_cess );
5012     end if;
5013 
5014     p_codepath := jai_general_pkg.plot_codepath(18, p_codepath, NULL, 'END'); /* 18 */
5015 
5016   EXCEPTION
5017     WHEN OTHERS THEN
5018     pr_tax := null;
5019     FND_MESSAGE.SET_NAME ('JA','JAI_EXCEPTION_OCCURED');
5020     FND_MESSAGE.SET_TOKEN ('JAI_PROCESS_MSG',lv_object_name ||'.Err:'||sqlerrm);
5021     app_exception.raise_exception;
5022   END get_tax_amount_breakup;
5023 
5024   PROCEDURE other_cenvat_rg_recording(
5025     p_source_register     IN  VARCHAR2,
5026     p_source_register_id  IN  NUMBER,
5027     p_tax_type            IN  VARCHAR2,
5028     p_credit              IN  NUMBER,
5029     p_debit               IN  NUMBER,
5030     p_process_status OUT NOCOPY VARCHAR2,
5031     p_process_message OUT NOCOPY VARCHAR2
5032   ) IS
5033     ln_source_type    NUMBER(2);
5034     lv_object_name CONSTANT VARCHAR2 (61) := 'jai_rcv_excise_processing_pkg.other_cenvat_rg_recording';
5035   BEGIN
5036 
5037     IF p_source_register IN (jai_constants.reg_rg23a_2, jai_constants.reg_rg23c_2) THEN
5038       ln_source_type := jai_constants.reg_rg23_2_code;
5039     ELSIF p_source_register = jai_constants.reg_rg23d THEN
5040       ln_source_type := jai_constants.reg_rg23d_code;
5041     ELSIF p_source_register = jai_constants.reg_pla THEN
5042       ln_source_type := jai_constants.reg_pla_code;
5043     ELSIF p_source_register = jai_constants.reg_receipt_cenvat THEN
5044       ln_source_type := jai_constants.reg_receipt_cenvat_code;
5045     END IF;
5046 
5047     INSERT INTO JAI_CMN_RG_OTHERS(
5048       rg_other_id, source_type, source_register,
5049       source_register_id, tax_type, credit, debit,
5050       created_by, creation_date, last_updated_by, last_update_date
5051     ) VALUES (
5052       JAI_CMN_RG_OTHERS_S.nextval, ln_source_type, p_source_register,
5053       p_source_register_id, p_tax_type, p_credit, p_debit,
5054       fnd_global.user_id, sysdate, fnd_global.user_id, sysdate
5055     );
5056    EXCEPTION
5057      WHEN OTHERS THEN
5058      FND_MESSAGE.SET_NAME ('JA','JAI_EXCEPTION_OCCURED');
5059      FND_MESSAGE.SET_TOKEN ('JAI_PROCESS_MSG',lv_object_name ||'.Err:'||sqlerrm);
5060      app_exception.raise_exception;
5061   END other_cenvat_rg_recording;
5062 
5063   /*~~~~~~~~~~~~~~~~~~~~~~ DERIVING CGIN Scenario ~~~~~~~~~~~~~~~~~~~~~~~~~*/
5064 
5065   PROCEDURE derive_cgin_scenario(
5066     p_transaction_id      IN  NUMBER,
5067     p_cgin_code OUT NOCOPY VARCHAR2,
5068     p_process_status OUT NOCOPY VARCHAR2,
5069     p_process_message OUT NOCOPY VARCHAR2,
5070     p_codepath            IN OUT NOCOPY VARCHAR2
5071   ) IS
5072 
5073     r_trx                   c_trx%ROWTYPE;
5074 
5075     lv_transaction_type     JAI_RCV_TRANSACTIONS.transaction_type%TYPE;
5076     ln_receive_claimed_ptg  NUMBER;
5077     lv_message              VARCHAR2(200);
5078     lv_object_name varchar2(200) := 'jai_rcv_excise_processing_pkg.dervice_cgin_scenario';
5079 
5080 BEGIN
5081 
5082     p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'cenvat_rg.cgin_scenario' , 'START'); /* 1 */
5083     if lb_rg_debug then
5084       -- dbms_output.put_line('^ Drv_CGIN_Scnrio');
5085       FND_FILE.put_line(FND_FILE.log,'^ Drv_CGIN_Scnrio');
5086     end if;
5087 
5088 
5089   /*
5090     In 50% claim case there will be another set of entries that needs to be passed in some scenarios and in some scenario it is
5091     REGULAR key word that appear in p_cgin_code is linked with transaction accounting entries that will happen if there is no concept of 50% Claim
5092 
5093     ____________________________________________________________________________________________________________________________
5094     | Transaction Type  |Claim No| Accounting Entries                           |  Comments
5095     | ----------------  |--------| ------------------------------               |  -------------------
5096     | RECEIVE           |      1 | X   - Dr. Modvat CG, Cr. Inventory Receiving |
5097     |                   |        | X/2 - Dr. Cenvat Receivable, Cr. Modvat CG   |  Code = 'REGULAR-FULL + REVERSAL-HALF'
5098     |                   |        |                                              |
5099     |                   |      2 | X/2 - Dr. Modvat RG, Cr. Cenvat Receivable   |  There cant be no Claim in case of Delivery
5100     |                   |        |                                              |  Code = 'REGULAR-HALF'
5101     |                   |        |                                              |  to NonBonded Subinventory
5102     |                   |        |                                              |
5103     | DELIVER           |        | X   - Dr. Inventory Receiving, Dr. Modvat CG |  Code = 'REGULAR-FULL + REVERSAL-HALF'
5104     |  (NonBondedSubinv)|        | X/2 - Dr. Modvat CG, Cr. Cenvat Receivable   |
5105     |                   |        |                                              |
5106     | RTR               |        | X   - Dr. Modvat CG, Dr. Inventory Receiving |  Code = 'REGULAR-FULL + REVERSAL-HALF'
5107     |  (NonBondedSubinv)|        | X/2 - Dr. Cenvat Receivable, Cr. Modvat CG   |
5108     |                   |        |                                              |
5109     | RTV               |        |Case 1: Parent Receive was 50% Claimed        |
5110     |                   |        | X/2 - Dr. Cenvat Receivable, Cr. Modvat CG   |  X/2 Amount is to 50% Claim of Parent Trxn
5111     |                   |        | X   - Dr. Inventory Receiving, Cr. Modvat RG |  This is Regular Entry that happens during RTV
5112     |                   |        |                                              |  Code = 'REGULAR-FULL + PARENT-REGULAR-HALF'
5113     |                   |        |                                              |
5114     |                   |        |Case 2: Parent Receive was 100% Claimed       |
5115     |                   |        | X   - Dr. Inventory Receiving, Cr. Modvat RG |  Parent is fully claimed. no need of passing X/2 entry
5116     |                   |        |                                              |  Code = 'REGULAR-FULL'
5117     ____________________________________________________________________________________________________________________________
5118 
5119     NOTE: If Parent Receive is Claimed 100% then Code returned is
5120               - REGULAR Full for DELIVER/RTR and related CORRECT transactions
5121               - REGUALR FULL/REGULAR HALF  for RECEIVE CORRECTion if CORRECT is not yet Claimed/50% claimed
5122 
5123     X is the Full Cenvat Amount of RECEIVE Line
5124 
5125     Possible Values of RETURN Codes
5126       1) 'REGULAR-FULL + REVERSAL-HALF'
5127       2) 'REGULAR-HALF'
5128       3) 'REGULAR-FULL'
5129       4) 'REGULAR-FULL + PARENT-REGULAR-HALF'
5130   */
5131 
5132     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
5133     OPEN c_trx(p_transaction_id);
5134     FETCH c_trx INTO r_trx;
5135     CLOSE c_trx;
5136 
5137     IF r_trx.cenvat_claimed_ptg = 100 THEN
5138       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
5139       lv_message := 'Transaction is already full claimed';
5140       GOTO end_of_call;
5141     END IF;
5142 
5143     ln_receive_claimed_ptg    := get_receive_claimed_ptg(p_transaction_id, r_trx.shipment_line_id, p_codepath);
5144     p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
5145 
5146     IF r_trx.transaction_type = 'CORRECT' THEN
5147       p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
5148       lv_transaction_type := r_trx.parent_transaction_type;
5149     ELSE
5150       p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
5151       lv_transaction_type := r_trx.transaction_type;
5152     END IF;
5153 
5154     --following if block only for RECEIVE transactions
5155     p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
5156     IF r_trx.transaction_type = 'RECEIVE' THEN        --, 'DELIVER', 'RETURN TO RECEIVING') THEN
5157       p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
5158 
5159       IF r_trx.cenvat_claimed_ptg = 0 THEN
5160         p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9 */
5161         p_cgin_code := 'REGULAR-FULL + REVERSAL-HALF';
5162 
5163       -- RECEIVE is 50% claimed case
5164       ELSIF r_trx.cenvat_claimed_ptg < 100 THEN
5165         p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10 */
5166         p_cgin_code := 'REGULAR-HALF';
5167 
5168       -- RECEIVE is 100% claimed case
5169       ELSIF r_trx.cenvat_claimed_ptg = 100 THEN
5170         p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11 */
5171         lv_message := 'Transaction is Fully Claimed';
5172         GOTO end_of_call;
5173       END IF;
5174 
5175     -- this elsif for DELIVER, RETURN TO RECEIVING, CORRECT of RECEIVE, DELIVER and RETURN TO RECEIVING
5176     ELSIF lv_transaction_type IN ('RECEIVE', 'DELIVER', 'RETURN TO RECEIVING') THEN
5177       p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12 */
5178 
5179       IF ln_receive_claimed_ptg = 0 THEN
5180 
5181         p_codepath := jai_general_pkg.plot_codepath(13, p_codepath); /* 13 */
5182         lv_message := 'Parent Receive Transaction is not Claimed';
5183         GOTO end_of_call;
5184 
5185       -- RECEIVE is 50% claimed case
5186       ELSIF ln_receive_claimed_ptg < 100 THEN
5187 
5188         p_codepath := jai_general_pkg.plot_codepath(14, p_codepath); /* 14 */
5189         IF r_trx.cenvat_claimed_ptg = 0 THEN
5190           p_codepath := jai_general_pkg.plot_codepath(15, p_codepath); /* 15 */
5191           p_cgin_code := 'REGULAR-FULL + REVERSAL-HALF';
5192         ELSIF r_trx.cenvat_claimed_ptg = 50 THEN
5193           p_codepath := jai_general_pkg.plot_codepath(16, p_codepath); /* 16 */
5194           lv_message := 'Second Claim did not happen for Parent transaction';
5195           GOTO end_of_call;
5196         END IF;
5197 
5198       -- RECEIVE is 100% claimed case
5199       ELSIF ln_receive_claimed_ptg = 100 THEN
5200         p_codepath := jai_general_pkg.plot_codepath(17, p_codepath); /* 17 */
5201         IF r_trx.cenvat_claimed_ptg = 0 THEN
5202           p_codepath := jai_general_pkg.plot_codepath(18, p_codepath); /* 18 */
5203           p_cgin_code := 'REGULAR-FULL';
5204         ELSIF r_trx.cenvat_claimed_ptg < 100 THEN
5205           p_codepath := jai_general_pkg.plot_codepath(19, p_codepath); /* 19 */
5206           p_cgin_code := 'REGULAR-HALF';
5207         END IF;
5208       END IF;
5209 
5210     ELSIF lv_transaction_type = 'RETURN TO VENDOR' THEN
5211 
5212       p_codepath := jai_general_pkg.plot_codepath(20, p_codepath); /* 20 */
5213       -- Need to implement this. Very Complicated One
5214       IF ln_receive_claimed_ptg = 0 THEN
5215         p_codepath := jai_general_pkg.plot_codepath(21, p_codepath); /* 21 */
5216         lv_message := 'Parent Receive Transaction is not Claimed';
5217         GOTO end_of_call;
5218 
5219       -- RECEIVE is 50% claimed case
5220       ELSIF ln_receive_claimed_ptg < 100 THEN
5221         p_codepath := jai_general_pkg.plot_codepath(22, p_codepath); /* 22 */
5222         -- following modified by Vijay Shankar for Bug#3940588
5223          p_cgin_code := 'REGULAR-FULL + PARENT-REGULAR-HALF';/*uncommented by vkaranam fro bug #4704957*/
5224         --p_cgin_code := 'REGULAR-FULL + REVERSAL-HALF';/*commented by vkaranam fro bug #4704957*/
5225 
5226       -- RECEIVE is 100% claimed case
5227       ELSIF ln_receive_claimed_ptg = 100 THEN
5228         p_codepath := jai_general_pkg.plot_codepath(23, p_codepath); /* 23 */
5229         p_cgin_code := 'REGULAR-FULL';
5230 
5231       END IF;
5232       p_codepath := jai_general_pkg.plot_codepath(24, p_codepath); /* 24 */
5233 
5234     END IF;
5235 
5236     <<end_of_call>>
5237     p_codepath := jai_general_pkg.plot_codepath(25, p_codepath); /* 25 */
5238 
5239     IF lv_message IS NOT NULL THEN
5240       p_process_status  := 'E';
5241       p_process_message := lv_message;
5242       RETURN;
5243     END IF;
5244     p_codepath := jai_general_pkg.plot_codepath(26, p_codepath, NULL, 'END'); /* 26 */
5245   EXCEPTION
5246     WHEN OTHERS THEN
5247     p_cgin_code := null;
5248     FND_MESSAGE.SET_NAME ('JA','JAI_EXCEPTION_OCCURED');
5249     FND_MESSAGE.SET_TOKEN ('JAI_PROCESS_MSG',lv_object_name ||'.Err:'||sqlerrm);
5250     app_exception.raise_exception;
5251   END derive_cgin_scenario;
5252 
5253   PROCEDURE derive_duty_registers(
5254     p_organization_id           IN      NUMBER,
5255     p_location_id               IN      NUMBER,
5256     p_item_class                IN      VARCHAR2,
5257     pr_tax                      IN      TAX_BREAKUP,
5258     p_cenvat_register_type OUT NOCOPY VARCHAR2,
5259     -- p_edu_cess_register_type        OUT VARCHAR2,
5260     p_process_flag OUT NOCOPY VARCHAR2,
5261     p_process_message OUT NOCOPY VARCHAR2,
5262     p_codepath                  IN OUT NOCOPY VARCHAR2
5263   ) IS
5264 
5265     r_orgn_info               c_orgn_info%ROWTYPE;
5266 
5267     lv_process_flag           JAI_RCV_TRANSACTIONS.PROCESS_STATUS%TYPE;
5268     lv_process_message        JAI_RCV_TRANSACTIONS.process_message%TYPE;
5269 
5270     lv_pref1_register         VARCHAR2(30);
5271     lv_pref2_register         VARCHAR2(30);
5272 
5273     lv_cess_pref1_register    VARCHAR2(30);
5274     lv_cess_pref2_register    VARCHAR2(30);
5275 
5276     /*
5277     (x) If PREF_PLA = 1 then directly check balances in PLA
5278         a) if ssi_unit_flag='Y' then no need of checking balances, return cenvat_register as PLA
5279         b) elsif ssi_unit_flag='N' then
5280           i) check balances in PLA
5281           ii) check balances in respective registers  based on ITEM CLASS
5282 
5283     (y) If PREF_PLA <> 1, then
5284         a) check balances in respective register based on ITEM CLASS
5285         b) if (a) fails then check (a), b(i) of (x)
5286     */
5287 
5288   BEGIN
5289 
5290     FND_FILE.put_line( fnd_file.log, '^derive_duty_registers');
5291     p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'CENVAT_RG_PKG.DRV_DUTY_REG' , 'START');
5292 
5293     OPEN c_orgn_info(p_organization_id, p_location_id);
5294     FETCH c_orgn_info INTO r_orgn_info;
5295     CLOSE c_orgn_info;
5296 
5297     IF r_orgn_info.pref_pla = 1 THEN
5298       lv_pref1_register         := jai_constants.register_type_pla;
5299       lv_cess_pref1_register    := jai_constants.reg_pla;
5300 
5301       IF p_item_class IN ('CGIN','CGEX') THEN
5302         p_codepath := jai_general_pkg.plot_codepath(2, p_codepath);
5303         lv_pref2_register       := jai_constants.register_type_c;
5304         lv_cess_pref2_register  := jai_constants.reg_rg23c;
5305       ELSE
5306         p_codepath := jai_general_pkg.plot_codepath(3, p_codepath);
5307         lv_pref2_register       := jai_constants.register_type_a;
5308         lv_cess_pref2_register  := jai_constants.reg_rg23a;
5309       END IF;
5310 
5311     ELSE  -- IF r_orgn_info.pref_rg23a = 1 THEN
5312 
5313       IF p_item_class IN ('CGIN','CGEX') THEN
5314         p_codepath := jai_general_pkg.plot_codepath(4, p_codepath);
5315         lv_pref1_register       := jai_constants.register_type_c;
5316         lv_cess_pref1_register  := jai_constants.reg_rg23c;
5317       ELSE
5318         p_codepath := jai_general_pkg.plot_codepath(5, p_codepath);
5319         lv_pref1_register       := jai_constants.register_type_a;
5320         lv_cess_pref1_register  := jai_constants.reg_rg23a;
5321       END IF;
5322 
5323       lv_pref2_register         := jai_constants.register_type_pla;
5324       lv_cess_pref2_register    := jai_constants.reg_pla;
5325 
5326     END IF;
5327 
5328     IF lb_rg_debug THEN
5329       FND_FILE.put_line( fnd_file.log, 'Org PlaPref:'||r_orgn_info.pref_pla||', 23aPref:'||r_orgn_info.pref_rg23a
5330         ||', 23cPref:'||r_orgn_info.pref_rg23c||', pref1_reg:'||lv_pref1_register||', pref2_reg:'||lv_pref2_register
5331         ||', AllowNegative:'||r_orgn_info.allow_negative_pla
5332       );
5333       /*dbms_output.put_line( 'Org PlaPref:'||r_orgn_info.pref_pla||', 23aPref:'||r_orgn_info.pref_rg23a
5334         ||', 23cPref:'||r_orgn_info.pref_rg23c||', pref1_reg:'||lv_pref1_register||', pref2_reg:'||lv_pref2_register
5335         ||', AllowNegative:'||r_orgn_info.allow_negative_pla);
5336         */
5337     END IF;
5338 
5339     IF    lv_pref1_register = jai_constants.register_type_pla
5340       AND r_orgn_info.allow_negative_pla = jai_constants.yes
5341     THEN
5342       p_codepath := jai_general_pkg.plot_codepath(6, p_codepath);
5343       p_cenvat_register_type    := jai_constants.register_type_pla;
5344       GOTO end_of_procedure;
5345     END IF;
5346 
5347     /* BALANCES CHECKING */
5348     p_codepath := jai_general_pkg.plot_codepath(7, p_codepath);
5349     check_cenvat_balances(
5350       p_organization_id       => p_organization_id,
5351       p_location_id           => p_location_id,
5352       p_transaction_amount    => pr_tax.basic_excise +
5353                                  pr_tax.addl_excise +
5354 				 pr_tax.other_excise +
5355 				 pr_tax.cvd +
5356 				 pr_tax.addl_cvd ,    -- Date 30/10/2006 Bug 5228046 added by sacsethi
5357       p_register_type         => lv_pref1_register,
5358       p_process_flag          => lv_process_flag,
5359       p_process_message       => lv_process_message
5360     );
5361 
5362     IF lv_process_flag = jai_constants.unexpected_error THEN
5363       p_codepath := jai_general_pkg.plot_codepath(8, p_codepath);
5364       p_process_flag    := 'E';
5365       p_process_message :=  lv_process_message;
5366       GOTO end_of_procedure;
5367 
5368     ELSIF lv_process_flag = jai_constants.expected_error THEN
5369       p_codepath := jai_general_pkg.plot_codepath(9, p_codepath);
5370 
5371     ELSIF lv_process_flag = jai_constants.successful THEN
5372 
5373       p_codepath := jai_general_pkg.plot_codepath(11, p_codepath);
5374       IF pr_tax.excise_edu_cess + pr_tax.cvd_edu_cess <> 0 THEN /* This if condition and its else added by ssumaith - bug# 4187859*/
5375           jai_cmn_rg_others_pkg.check_balances(
5376             p_organization_id   => p_organization_id ,
5377             p_location_id       => p_location_id,
5378             p_register_type     => lv_cess_pref1_register,
5379             p_trx_amount        => pr_tax.excise_edu_cess + pr_tax.cvd_edu_cess,
5380             p_process_flag      => lv_process_flag,
5381             p_process_message   => lv_process_message
5382           );
5383 
5384           IF lv_process_flag = jai_constants.unexpected_error THEN
5385             p_codepath := jai_general_pkg.plot_codepath(12, p_codepath);
5386             p_process_flag    := 'E';
5387             p_process_message :=  lv_process_message;
5388             GOTO end_of_procedure;
5389 
5390           ELSIF lv_process_flag = jai_constants.expected_error THEN
5391             p_codepath := jai_general_pkg.plot_codepath(13, p_codepath);
5392           ELSIF lv_process_flag = jai_constants.successful THEN
5393             p_codepath := jai_general_pkg.plot_codepath(14, p_codepath);
5394             p_cenvat_register_type  := lv_pref1_register;
5395             GOTO end_of_procedure;
5396           END IF;
5397    /*added the following by vkaranam for budget 07 impact - bug#5989740*/
5398     --start
5399     ELSIF nvl(pr_tax.sh_exc_edu_cess,0) + nvl(pr_tax.sh_cvd_edu_cess,0) <> 0 THEN
5400 
5401 		          jai_cmn_rg_others_pkg.check_sh_balances(
5402 		          p_organization_id   => p_organization_id ,
5403 		          p_location_id       => p_location_id,
5404 		          p_register_type     => lv_cess_pref1_register,
5405 		          p_trx_amount        => nvl(pr_tax.sh_exc_edu_cess,0) + nvl(pr_tax.sh_cvd_edu_cess,0),
5406 		          p_process_flag      => lv_process_flag,
5407 		          p_process_message   => lv_process_message
5408 		        );
5409 
5410 		        IF lv_process_flag = jai_constants.unexpected_error THEN
5411 		          p_codepath := jai_general_pkg.plot_codepath(14.1, p_codepath);
5412 		          p_process_flag    := 'E';
5413 		          p_process_message :=  lv_process_message;
5414 		          GOTO end_of_procedure;
5415 
5416 		        ELSIF lv_process_flag = jai_constants.expected_error THEN
5417 		          p_codepath := jai_general_pkg.plot_codepath(14.2, p_codepath);
5418 		        ELSIF lv_process_flag = jai_constants.successful THEN
5419 		          p_codepath := jai_general_pkg.plot_codepath(14.3, p_codepath);
5420 		          p_cenvat_register_type  := lv_pref1_register;
5421 		          GOTO end_of_procedure;
5422            END IF;
5423     --end bug #5989740
5424 
5425       ELSE
5426          lv_process_flag    := jai_constants.successful;
5427          lv_process_message := NULL;
5428          goto end_of_procedure;
5429       END IF;
5430     END IF;
5431 
5432     IF lv_pref2_register = jai_constants.register_type_pla
5433       AND r_orgn_info.allow_negative_pla = jai_constants.yes
5434     THEN
5435       p_codepath := jai_general_pkg.plot_codepath(15, p_codepath);
5436       p_cenvat_register_type  := lv_pref2_register;
5437       GOTO end_of_procedure;
5438     END IF;
5439 
5440     p_codepath := jai_general_pkg.plot_codepath(16, p_codepath);
5441     check_cenvat_balances(
5442       p_organization_id       => p_organization_id,
5443       p_location_id           => p_location_id,
5444       p_transaction_amount    => pr_tax.basic_excise +
5445                                  pr_tax.addl_excise +
5446 				 pr_tax.other_excise +
5447 				 pr_tax.cvd +
5448 				 pr_tax.addl_cvd,  -- Date 04/06/2007 by sacsethi for bug 6109941
5449       p_register_type         => lv_pref2_register,
5450       p_process_flag          => lv_process_flag,
5451       p_process_message       => lv_process_message
5452     );
5453 
5454     IF lv_process_flag = jai_constants.unexpected_error THEN
5455       p_codepath := jai_general_pkg.plot_codepath(17, p_codepath);
5456       p_process_flag    := 'E';
5457       p_process_message :=  lv_process_message;
5458       GOTO end_of_procedure;
5459 
5460     ELSIF lv_process_flag = jai_constants.expected_error THEN
5461       p_codepath := jai_general_pkg.plot_codepath(18, p_codepath);
5462       p_process_flag    := 'E';
5463       p_process_message :=  'Sufficient Balances are not available in both '||lv_pref1_register||' and '||lv_pref2_register||' registers';
5464       GOTO end_of_procedure;
5465 
5466     ELSIF lv_process_flag = jai_constants.successful THEN
5467 
5468       p_codepath := jai_general_pkg.plot_codepath(19, p_codepath);
5469 
5470       IF pr_tax.excise_edu_cess + pr_tax.cvd_edu_cess <> 0 THEN /* This if condition and its else added by ssumaith - bug# 4187859*/
5471           jai_cmn_rg_others_pkg.check_balances(
5472             p_organization_id   => p_organization_id ,
5473             p_location_id       => p_location_id,
5474             p_register_type     => lv_cess_pref2_register,
5475             p_trx_amount        => pr_tax.excise_edu_cess + pr_tax.cvd_edu_cess,
5476             p_process_flag      => lv_process_flag,
5477             p_process_message   => lv_process_message
5478           );
5479           IF lv_process_flag = jai_constants.unexpected_error THEN
5480             p_codepath := jai_general_pkg.plot_codepath(20, p_codepath);
5481             p_process_flag    := 'E';
5482             p_process_message :=  lv_process_message;
5483             GOTO end_of_procedure;
5484 
5485           ELSIF lv_process_flag = jai_constants.expected_error THEN
5486             p_codepath := jai_general_pkg.plot_codepath(21, p_codepath);
5487             p_process_flag    := 'E';
5488             p_process_message :=  'Sufficient Balances are not available in both '||lv_pref1_register||' and '||lv_pref2_register||' registers';
5489             GOTO end_of_procedure;
5490 
5491           ELSIF lv_process_flag = jai_constants.successful THEN
5492             p_codepath := jai_general_pkg.plot_codepath(22, p_codepath);
5493             p_cenvat_register_type  := lv_pref2_register;
5494             GOTO end_of_procedure;
5495           END IF;
5496 /*added the following by vkaranam for budget 07 impact - bug#5989740*/
5497      --start
5498      ELSIF nvl(pr_tax.sh_exc_edu_cess,0) + nvl(pr_tax.sh_cvd_edu_cess,0) <> 0 THEN
5499 
5500  	  jai_cmn_rg_others_pkg.check_sh_balances(
5501  	  p_organization_id   => p_organization_id ,
5502  	  p_location_id       => p_location_id,
5503  	  p_register_type     => lv_cess_pref2_register,
5504  	  p_trx_amount        => nvl(pr_tax.sh_exc_edu_cess,0) + nvl(pr_tax.sh_cvd_edu_cess,0),
5505  	  p_process_flag      => lv_process_flag,
5506  	  p_process_message   => lv_process_message
5507  	);
5508 
5509  	IF lv_process_flag = jai_constants.unexpected_error THEN
5510  	  p_codepath := jai_general_pkg.plot_codepath(22.1, p_codepath);
5511  	  p_process_flag    := 'E';
5512  	  p_process_message :=  lv_process_message;
5513  	  GOTO end_of_procedure;
5514 
5515  	ELSIF lv_process_flag = jai_constants.expected_error THEN
5516 	   p_codepath := jai_general_pkg.plot_codepath(22.2, p_codepath);
5517 	   p_process_flag    := 'E';
5518 	   p_process_message :=  'Sufficient Balances are not available in both '||lv_pref1_register||' and '||lv_pref2_register||' registers';
5519 	   GOTO end_of_procedure;
5520 
5521         ELSIF lv_process_flag = jai_constants.successful THEN
5522 	   p_codepath := jai_general_pkg.plot_codepath(22.3, p_codepath);
5523 	   p_cenvat_register_type  := lv_pref2_register;
5524 	   GOTO end_of_procedure;
5525         END IF;
5526 
5527      --end bug #5989740
5528 
5529 
5530       ELSE
5531           lv_process_flag    := jai_constants.successful;
5532           lv_process_message := NULL;
5533           goto end_of_procedure;
5534       END IF;
5535     END IF;
5536 
5537     <<end_of_procedure>>
5538 
5539     p_codepath := jai_general_pkg.plot_codepath(25, p_codepath, 'CENVAT_RG_PKG.DRV_DUTY_REG' , 'END');
5540     FND_FILE.put_line( fnd_file.log, '$derive_duty_registers. Register Type:'||p_cenvat_register_type);
5541     -- dbms_output.put_line( '$derive_duty_registers. Register Type:'||p_cenvat_register_type);
5542 
5543   EXCEPTION
5544     WHEN OTHERS THEN
5545       p_process_flag    := 'E';
5546       p_process_message := 'DERIVE_DUTY_REGISTERS: Error:'||SQLERRM;
5547       p_codepath := jai_general_pkg.plot_codepath(-999, p_codepath, 'CENVAT_RG_PKG.DRV_DUTY_REG' , 'END');
5548 
5549   END derive_duty_registers;
5550 
5551   PROCEDURE check_cenvat_balances(
5552     p_organization_id           IN      NUMBER,
5553     p_location_id               IN      NUMBER,
5554     p_transaction_amount        IN      NUMBER,
5555     p_register_type             IN      VARCHAR2,
5556     p_process_flag OUT NOCOPY VARCHAR2,
5557     p_process_message OUT NOCOPY VARCHAR2
5558   ) IS
5559 
5560     CURSOR c_orgn_balances(cp_organization_id IN NUMBER, cp_location_id IN NUMBER, cp_register_type IN VARCHAR2) IS
5561       SELECT  decode( cp_register_type,
5562                       jai_constants.register_type_pla, pla_balance,
5563                       jai_constants.register_type_a, rg23a_balance,
5564                       jai_constants.register_type_c, rg23c_balance
5565                     )
5566       FROM JAI_CMN_RG_BALANCES
5567       WHERE organization_id = cp_organization_id
5568       AND location_id = cp_location_id;
5569 
5570     ln_current_balance  NUMBER;
5571 
5572   BEGIN
5573 
5574     OPEN c_orgn_balances(p_organization_id, p_location_id, p_register_type);
5575     FETCH c_orgn_balances INTO ln_current_balance;
5576     CLOSE c_orgn_balances;
5577 
5578     IF ( nvl(ln_current_balance,0) - nvl(p_transaction_amount,0)) < 0 THEN
5579       p_process_flag    := jai_constants.expected_error;
5580       p_process_message := 'Sufficient Balances are not available in '''||p_register_type||''' register';
5581     ELSE
5582       p_process_flag    := jai_constants.successful;
5583     END IF;
5584 
5585   END check_cenvat_balances;
5586 
5587   procedure rtv_processing_for_ssi(
5588     pn_transaction_id                 NUMBER,
5589     pv_codepath         in out nocopy varchar2,
5590     pv_process_status   out nocopy    varchar2,
5591     pv_process_message  out nocopy    varchar2
5592   ) is
5593 
5594     cursor c_rtv_dtls(cp_transaction_id in number) is
5595       select receipt_excise_rate, rtv_excise_rate, excise_basis_amt
5596       from jai_rcv_rtv_batch_trxs
5597       where transaction_id = cp_transaction_id;
5598 
5599     lv_stform_type JAI_CMN_TAXES_ALL.stform_type%type ;
5600 
5601     cursor c_excise_cess_rate(cp_shipment_line_id in number) is
5602       select a.tax_rate, b.tax_account_id, a.tax_id
5603       from JAI_RCV_LINE_TAXES a, JAI_CMN_TAXES_ALL b
5604       where a.shipment_line_id = cp_shipment_line_id
5605       and a.tax_id = b.tax_id
5606       and ( a.tax_type = jai_constants.tax_type_exc_edu_cess
5607             -- following is to take care of Initial solution(Year2004) for Excise Cess func.
5608 	    or (a.tax_type = jai_constants.tax_type_other and b.stform_type =  lv_stform_type) --'EXCISE - CESS') /* Modified by Ramananda for removal of SQL LITERALs :bug#4428980*/
5609             --or (a.tax_type = 'Other' and b.stform_type = 'EXCISE - CESS')
5610           );
5611 
5612 		--added by csahoo for bug#6078460
5613 		cursor c_excise_sh_cess_rate(cp_shipment_line_id in number) is
5614 					select a.tax_rate, b.tax_account_id, a.tax_id
5615 					from JAI_RCV_LINE_TAXES a, JAI_CMN_TAXES_ALL b
5616 					where a.shipment_line_id = cp_shipment_line_id
5617 					and a.tax_id = b.tax_id
5618 					and ( a.tax_type = jai_constants.tax_type_sh_exc_edu_cess
5619 								-- following is to take care of Initial solution(Year2004) for Excise sh Cess func.
5620 					or (a.tax_type = jai_constants.tax_type_other and b.stform_type =  lv_stform_type)
5621 				 );
5622 
5623     cursor c_po_dist_accrual_accnt_id(cp_transaction_id in number) is
5624       select accrual_account_id
5625       from po_distributions_all a,
5626           ( select po_line_location_id
5627             from rcv_transactions
5628             where transaction_id = cp_transaction_id) b
5629       where a.line_location_id = b.po_line_location_id;
5630 
5631     cursor c_mtl_ap_accrual_accnt_id(cp_organization_id in number) is
5632       select ap_accrual_account
5633       from mtl_parameters
5634       where organization_id = cp_organization_id;
5635 
5636     r_trx                     c_trx%ROWTYPE;
5637     r_orgn_info               c_orgn_info%ROWTYPE;
5638 
5639     lv_reference10            gl_interface.reference10%TYPE;
5640     lv_reference23            gl_interface.reference23%TYPE;
5641     lv_reference24            gl_interface.reference24%TYPE;
5642     lv_reference25            gl_interface.reference26%TYPE;
5643     lv_reference26            gl_interface.reference25%TYPE;
5644     lv_reference_name         JAI_RCV_JOURNAL_ENTRIES.reference_name%TYPE;
5645     ln_reference_id           JAI_RCV_JOURNAL_ENTRIES.reference_id%TYPE;
5646 
5647     lv_accounting_date        DATE;
5648     lv_acct_nature            JAI_RCV_JOURNAL_ENTRIES.acct_nature%TYPE;
5649     lv_acct_type              JAI_RCV_JOURNAL_ENTRIES.acct_type%TYPE;
5650 
5651     r_diff_tax                jai_rcv_excise_processing_pkg.TAX_BREAKUP;
5652     r_rtv_dtls                c_rtv_dtls%ROWTYPE;
5653 
5654     ln_excise_cess_tax_id     JAI_CMN_TAXES_ALL.tax_id%TYPE;
5655     ln_excise_cess_rate       NUMBER;
5656     ln_excise_cess_accnt_id   gl_code_combinations.code_combination_id%TYPE;
5657     --added by csahoo for bug#6078460, start
5658     ln_excise_sh_cess_tax_id     JAI_CMN_TAXES_ALL.tax_id%TYPE;
5659 		ln_excise_sh_cess_rate       NUMBER;
5660     ln_excise_sh_cess_accnt_id   gl_code_combinations.code_combination_id%TYPE;
5661     --added by csahoo for bug#6078460, end
5662     lv_cenvat_register_type   VARCHAR2(30);
5663     lv_reference_num          JAI_CMN_RG_23AC_II_TRXS.reference_num%TYPE;
5664     lv_simulate_flag          VARCHAR2(1);
5665 
5666     ln_part_ii_register_id    NUMBER(15);
5667     lv_register_entry_type    VARCHAR2(15);
5668 
5669     ln_ccid                   gl_code_combinations.code_combination_id%TYPE;
5670     ln_credit_amt             number;
5671     ln_debit_amt              number;
5672 
5673     ln_balancing_ccid         gl_code_combinations.code_combination_id%TYPE;
5674     ln_balancing_credit_amt   number;
5675     ln_balancing_debit_amt    number;
5676 
5677     lv_statement_id           VARCHAR2(4);
5678 
5679     -- Bug 5365346. Added by Lakshmi Gopalsami
5680     r_base_trx                c_base_trx%ROWTYPE;
5681   begin
5682 
5683     lv_statement_id := '1';
5684     pv_codepath := jai_general_pkg.plot_codepath(1, pv_codepath, 'jai_rcv_excise_processing_pkg.rtv_processing_for_ssi', 'START');
5685     lv_simulate_flag        := jai_constants.no;
5686     lv_register_entry_type  := jai_rcv_excise_processing_pkg.cenvat_debit;
5687 
5688     open c_trx(pn_transaction_id);
5689     fetch c_trx into r_trx;
5690     close c_trx;
5691 
5692     -- bug 5365346. Added by Lakshmi Gopalsami
5693     OPEN  c_base_trx(pn_transaction_id);
5694      FETCH  c_base_trx INTO  r_base_trx;
5695     CLOSE  c_base_trx;
5696 
5697     open c_rtv_dtls(pn_transaction_id);
5698     fetch c_rtv_dtls into r_rtv_dtls;
5699     close c_rtv_dtls;
5700     r_diff_tax.basic_excise  := r_rtv_dtls.excise_basis_amt * (r_rtv_dtls.rtv_excise_rate - r_rtv_dtls.receipt_excise_rate) / 100;
5701 
5702      lv_statement_id := '2';
5703     if nvl(r_diff_tax.basic_excise, 0) <> 0 then
5704      lv_stform_type := 'EXCISE - CESS' ;
5705       open c_excise_cess_rate(r_trx.shipment_line_id);
5706       fetch c_excise_cess_rate into ln_excise_cess_rate, ln_excise_cess_accnt_id, ln_excise_cess_tax_id;
5707       close c_excise_cess_rate;
5708       r_diff_tax.excise_edu_cess := nvl(ln_excise_cess_rate, 0) * r_diff_tax.basic_excise/100;
5709     else
5710       GOTO end_of_procedure;
5711     end if;
5712 
5713     if r_diff_tax.excise_edu_cess <> 0 and ln_excise_cess_accnt_id is null then
5714       lv_statement_id := '2.1';
5715       pv_codepath := jai_general_pkg.plot_codepath(2.1, pv_codepath);
5716       pv_process_status := 'E';
5717       pv_process_message := 'Excise Education cess account is not defined in the tax. (TaxId:'||ln_excise_cess_tax_id||')';
5718       GOTO end_of_procedure;
5719     end if;
5720 
5721     --added by csahoo for bug#6078460, start
5722 		if nvl(r_diff_tax.basic_excise, 0) <> 0 then
5723 		 lv_stform_type := 'EXCISE - SH - CESS' ;
5724 			open c_excise_sh_cess_rate(r_trx.shipment_line_id);
5725 			fetch c_excise_sh_cess_rate into ln_excise_sh_cess_rate, ln_excise_sh_cess_accnt_id, ln_excise_sh_cess_tax_id;
5726 			close c_excise_sh_cess_rate;
5727 			r_diff_tax.sh_exc_edu_cess := nvl(ln_excise_sh_cess_rate, 0) * r_diff_tax.basic_excise/100;
5728 		else
5729 			GOTO end_of_procedure;
5730 		end if;
5731 
5732 		if r_diff_tax.sh_exc_edu_cess <> 0 and ln_excise_sh_cess_accnt_id is null then
5733 			lv_statement_id := '2.1';
5734 			pv_codepath := jai_general_pkg.plot_codepath(2.1, pv_codepath);
5735 			pv_process_status := 'E';
5736 			pv_process_message := 'Excise SH Education cess account is not defined in the tax. (TaxId:'||ln_excise_sh_cess_tax_id||')';
5737 			GOTO end_of_procedure;
5738     end if;
5739     --added by csahoo for bug#6078460, end
5740 
5741     lv_statement_id := '3';
5742     /* Start Register Entry */
5743     jai_rcv_excise_processing_pkg.derive_duty_registers(
5744       p_organization_id           => r_trx.organization_id,
5745       p_location_id               => r_trx.location_id,
5746       p_item_class                => r_trx.item_class,
5747       pr_tax                      => r_diff_tax,
5748       p_cenvat_register_type      => lv_cenvat_register_type,
5749       p_process_flag              => pv_process_status,
5750       p_process_message           => pv_process_message,
5751       p_codepath                  => pv_codepath
5752     );
5753 
5754     lv_statement_id := '4';
5755     if pv_process_status = 'E' then
5756       GOTO end_of_procedure;
5757     end if;
5758 
5759     if lv_cenvat_register_type IN (jai_constants.register_type_a, jai_constants.register_type_c) then
5760 
5761       lv_statement_id := '5';
5762       pv_codepath := jai_general_pkg.plot_codepath(17, pv_codepath);
5763 
5764       lv_reference_num := 'CENVAT-SSI';
5765       /*
5766       jai_rcv_excise_processing_pkg.rg23_part_ii_entry(
5767           p_transaction_id        => r_trx.transaction_id,
5768 	  pr_tax                  => r_diff_tax,
5769           p_part_i_register_id    => null,
5770           p_register_entry_type   => lv_register_entry_type,
5771           p_reference_num         => lv_reference_num,
5772           p_register_id           => ln_part_ii_register_id,
5773           p_process_status        => pv_process_status,
5774           p_process_message       => pv_process_message,
5775           p_simulate_flag         => lv_simulate_flag,
5776           p_codepath              => pv_codepath
5777       );
5778       */
5779       BEGIN
5780 	      update_RTV_Diff_value
5781 	      ( pr_base_trx          => r_base_trx,
5782 		pr_tax               => r_trx,
5783 		pr_diff_tax          => r_diff_tax,
5784 		p_source_reg         => 'RG23II',
5785 		p_register_entry_type => lv_register_entry_type,
5786 		p_register_id         => ln_part_ii_register_id,
5787 		p_simulate_flag       => lv_simulate_flag,
5788 		p_codepath            => pv_codepath,
5789 		p_process_status      => pv_process_status,
5790 		p_process_message     => pv_process_message
5791 	      );
5792       EXCEPTION
5793         WHEN OTHERS THEN
5794 	  fnd_file.put_line(FND_FILE.LOG, ' exception ' || SQLERRM);
5795       END ;
5796       lv_statement_id := '6';
5797       IF pv_process_status IN ('E', 'X') THEN
5798         GOTO end_of_procedure;
5799       END IF;
5800       lv_reference_name := 'JAI_CMN_RG_23AC_II_TRXS';
5801       ln_reference_id   := ln_part_ii_register_id;
5802     elsif lv_cenvat_register_type = jai_constants.register_type_pla THEN
5803       lv_statement_id := '7';
5804       pv_codepath := jai_general_pkg.plot_codepath(17.1, pv_codepath);
5805       /* Bug 5365346. Added by Lakshmi Gopalsami
5806          Commented the call to pla entry and added
5807       jai_rcv_excise_processing_pkg.pla_entry(
5808           p_transaction_id      => r_trx.transaction_id,
5809           pr_tax                => r_diff_tax,
5810           p_register_entry_type => lv_register_entry_type,
5811           p_register_id         => ln_part_ii_register_id,
5812           p_process_status      => pv_process_status,
5813           p_process_message     => pv_process_message,
5814           p_simulate_flag       => lv_simulate_flag,
5815           p_codepath            => pv_codepath
5816       );
5817       */
5818       Begin
5819 	      update_RTV_Diff_value
5820 	      ( pr_base_trx          => r_base_trx,
5821 		pr_tax               => r_trx,
5822 		pr_diff_tax          => r_diff_tax,
5823 		p_source_reg         => 'PLA',
5824 		p_register_entry_type => lv_register_entry_type,
5825 		p_register_id         => ln_part_ii_register_id,
5826 		p_simulate_flag       => lv_simulate_flag,
5827 		p_codepath            => pv_codepath,
5828 		p_process_status      => pv_process_status,
5829 		p_process_message     => pv_process_message
5830 	      );
5831       Exception
5832         WHEN OTHERS THEN
5833 	  fnd_file.put_line(FND_FILE.LOG, ' exception ' || SQLERRM);
5834       END ;
5835       lv_statement_id := '8';
5836       IF pv_process_status IN ('E', 'X') THEN
5837         GOTO end_of_procedure;
5838       END IF;
5839       lv_reference_name := 'JAI_CMN_RG_PLA_TRXS';
5840       ln_reference_id   := ln_part_ii_register_id;
5841     else
5842       lv_statement_id := '9';
5843       pv_codepath := jai_general_pkg.plot_codepath(17.2, pv_codepath);
5844       pv_process_status := 'E';
5845       pv_process_message := 'Duty Register cannot be derived';
5846       GOTO end_of_procedure;
5847     end if;
5848     /* End Register Entry */
5849 
5850     lv_statement_id := '10';
5851     open c_orgn_info(r_trx.organization_id, r_trx.location_id);
5852     fetch c_orgn_info into r_orgn_info;
5853     close c_orgn_info;
5854 
5855     if lv_cenvat_register_type = jai_constants.register_type_a then
5856       lv_statement_id := '11';
5857       ln_ccid := r_orgn_info.modvat_rm_account_id;
5858     elsif lv_cenvat_register_type = jai_constants.register_type_c then
5859       lv_statement_id := '12';
5860       ln_ccid := r_orgn_info.modvat_cg_account_id;
5861     elsif lv_cenvat_register_type = jai_constants.register_type_pla then
5862       lv_statement_id := '13';
5863       ln_ccid := r_orgn_info.modvat_pla_account_id;
5864     end if;
5865 
5866     if ln_ccid is null then
5867       lv_statement_id := '14';
5868       pv_process_status    := 'E';
5869       pv_process_message := 'Modvat '||lv_cenvat_register_type||' account in Organization Setup doesnot exist';
5870       GOTO end_of_procedure;
5871     end if;
5872 
5873     if r_orgn_info.rtv_account_flag = jai_constants.yes then
5874       ln_balancing_ccid := r_orgn_info.rtv_expense_account_id;
5875       if ln_balancing_ccid is null then
5876         null;
5877       end if;
5878     elsif r_orgn_info.rtv_account_flag = jai_constants.no then
5879 
5880       open c_po_dist_accrual_accnt_id(r_trx.transaction_id);
5881       fetch c_po_dist_accrual_accnt_id into ln_balancing_ccid;
5882       close  c_po_dist_accrual_accnt_id;
5883 
5884       if ln_balancing_ccid is null then
5885         open c_po_dist_accrual_accnt_id(r_trx.transaction_id);
5886         fetch c_po_dist_accrual_accnt_id into ln_balancing_ccid;
5887         close  c_po_dist_accrual_accnt_id;
5888       end if;
5889 
5890     end if;
5891 
5892     lv_statement_id := '15';
5893     if ln_balancing_ccid is null then
5894       pv_process_status  := 'E';
5895       pv_process_message := 'No value for po and mtl accrual account';
5896       GOTO end_of_procedure;
5897     end if;
5898 
5899     lv_acct_type        := 'REVERSAL';
5900     lv_acct_nature      := 'CENVAT-SSI';
5901     lv_accounting_date  := trunc(sysdate);
5902 
5903     lv_reference23      := 'JAINRTVN';
5904     lv_reference24      := 'rcv_transactions';
5905     lv_reference25      := 'transaction_id';
5906     lv_reference26      := to_char(r_trx.transaction_id);
5907 
5908     lv_statement_id := '16';
5909     lv_reference10      := 'India Local RTV Entry for the Receipt Number ' || r_trx.receipt_num;
5910     if r_trx.transaction_type = 'CORRECT' THEN
5911       lv_reference10 := lv_reference10 || ' of '||r_trx.parent_transaction_type;
5912     end if;
5913 
5914     if lv_register_entry_type = jai_rcv_excise_processing_pkg.CENVAT_DEBIT then
5915       ln_debit_amt  := null;
5916       ln_credit_amt := r_diff_tax.basic_excise;
5917       ln_balancing_debit_amt  := r_diff_tax.basic_excise;
5918       ln_balancing_credit_amt := null;
5919     else
5920       ln_debit_amt  := r_diff_tax.basic_excise;
5921       ln_credit_amt := null;
5922       ln_balancing_debit_amt  := null;
5923       ln_balancing_credit_amt := r_diff_tax.basic_excise;
5924     end if;
5925 
5926     lv_statement_id := '20';
5927     /* Primary Accounting Entry - 1 */
5928     jai_rcv_accounting_pkg.process_transaction(
5929         p_transaction_id       => r_trx.transaction_id,
5930         p_acct_type            => lv_acct_type,
5931         p_acct_nature          => lv_acct_nature,
5932         p_source_name          => jai_rcv_excise_processing_pkg.gv_source_name,
5933         p_category_name        => jai_rcv_excise_processing_pkg.gv_category_name,
5934 
5935         p_code_combination_id  => ln_ccid,
5936         p_entered_dr           => ln_debit_amt,
5937         p_entered_cr           => ln_credit_amt,
5938 
5939         p_currency_code        => jai_rcv_trx_processing_pkg.gv_func_curr,
5940         p_accounting_date      => lv_accounting_date,
5941         p_reference_10         => lv_reference10,
5942         p_reference_23         => lv_reference23, --'jai_rcv_excise_processing_pkg.accounting_entries',
5943         p_reference_24         => lv_reference24, --'rcv_transactions',
5944         p_reference_25         => lv_reference25, --'transaction_id',
5945         p_reference_26         => lv_reference26, -- <transaction_id_value>
5946         p_destination          => 'G',
5947         p_simulate_flag        => lv_simulate_flag,
5948         p_codepath             => pv_codepath,
5949         p_process_status       => pv_process_status,
5950         p_process_message      => pv_process_message
5951         ,p_reference_name     => lv_reference_name,
5952         p_reference_id        => ln_reference_id
5953     );
5954 
5955     lv_statement_id := '21';
5956     if pv_process_status = 'E' then
5957       goto end_of_procedure;
5958     end if;
5959 
5960     lv_statement_id := '22';
5961     /* Balacing Accounting Entry - 1  */
5962     jai_rcv_accounting_pkg.process_transaction(
5963         p_transaction_id       => r_trx.transaction_id,
5964         p_acct_type            => lv_acct_type,
5965         p_acct_nature          => lv_acct_nature,
5966         p_source_name          => jai_rcv_excise_processing_pkg.gv_source_name,
5967         p_category_name        => jai_rcv_excise_processing_pkg.gv_category_name,
5968 
5969         p_code_combination_id  => ln_balancing_ccid,
5970         p_entered_dr           => ln_balancing_debit_amt,
5971         p_entered_cr           => ln_balancing_credit_amt,
5972 
5973         p_currency_code        => jai_rcv_trx_processing_pkg.gv_func_curr,
5974         p_accounting_date      => lv_accounting_date,
5975         p_reference_10         => lv_reference10,
5976         p_reference_23         => lv_reference23, --'jai_rcv_excise_processing_pkg.accounting_entries',
5977         p_reference_24         => lv_reference24, --'rcv_transactions',
5978         p_reference_25         => lv_reference25, --'transaction_id',
5979         p_reference_26         => lv_reference26, -- <transaction_id_value>
5980         p_destination          => 'G',
5981         p_simulate_flag        => lv_simulate_flag,
5982         p_codepath             => pv_codepath,
5983         p_process_status       => pv_process_status,
5984         p_process_message      => pv_process_message
5985         ,p_reference_name     => lv_reference_name,
5986         p_reference_id        => ln_reference_id
5987     );
5988 
5989     lv_statement_id := '23';
5990     if pv_process_status = 'E' then
5991       goto end_of_procedure;
5992     end if;
5993 
5994     /* Education Cess Acccounting Entries */
5995     if r_diff_tax.excise_edu_cess <> 0 then
5996 
5997       lv_statement_id := '24';
5998       lv_acct_nature  := 'CENVAT-EDUCESS-SSI';
5999       ln_ccid         := ln_excise_cess_accnt_id;
6000 
6001       if lv_register_entry_type = jai_rcv_excise_processing_pkg.CENVAT_DEBIT then
6002         ln_debit_amt  := null;
6003         ln_credit_amt := r_diff_tax.excise_edu_cess;
6004         ln_balancing_debit_amt  := r_diff_tax.excise_edu_cess;
6005         ln_balancing_credit_amt := null;
6006       else
6007         ln_debit_amt  := r_diff_tax.excise_edu_cess;
6008         ln_credit_amt := null;
6009         ln_balancing_debit_amt  := null;
6010         ln_balancing_credit_amt := r_diff_tax.excise_edu_cess;
6011       end if;
6012 
6013       lv_statement_id := '25';
6014       /* Primary Accounting Entry - 2 */
6015       jai_rcv_accounting_pkg.process_transaction(
6016           p_transaction_id       => r_trx.transaction_id,
6017           p_acct_type            => lv_acct_type,
6018           p_acct_nature          => lv_acct_nature,
6019           p_source_name          => jai_rcv_excise_processing_pkg.gv_source_name,
6020           p_category_name        => jai_rcv_excise_processing_pkg.gv_category_name,
6021 
6022           p_code_combination_id  => ln_ccid,
6023           p_entered_dr           => ln_debit_amt,
6024           p_entered_cr           => ln_credit_amt,
6025 
6026           p_currency_code        => jai_rcv_trx_processing_pkg.gv_func_curr,
6027           p_accounting_date      => lv_accounting_date,
6028           p_reference_10         => lv_reference10,
6029           p_reference_23         => lv_reference23, --'jai_rcv_excise_processing_pkg.accounting_entries',
6030           p_reference_24         => lv_reference24, --'rcv_transactions',
6031           p_reference_25         => lv_reference25, --'transaction_id',
6032           p_reference_26         => lv_reference26, -- <transaction_id_value>
6033           p_destination          => 'G',
6034           p_simulate_flag        => lv_simulate_flag,
6035           p_codepath             => pv_codepath,
6036           p_process_status       => pv_process_status,
6037           p_process_message      => pv_process_message
6038           ,p_reference_name     => lv_reference_name,
6039           p_reference_id        => ln_reference_id
6040       );
6041 
6042       lv_statement_id := '26';
6043       if pv_process_status = 'E' then
6044         goto end_of_procedure;
6045       end if;
6046 
6047       lv_statement_id := '27';
6048       /* Balacing Accounting Entry - 2  */
6049       jai_rcv_accounting_pkg.process_transaction(
6050           p_transaction_id       => r_trx.transaction_id,
6051           p_acct_type            => lv_acct_type,
6052           p_acct_nature          => lv_acct_nature,
6053           p_source_name          => jai_rcv_excise_processing_pkg.gv_source_name,
6054           p_category_name        => jai_rcv_excise_processing_pkg.gv_category_name,
6055 
6056           p_code_combination_id  => ln_balancing_ccid,
6057           p_entered_dr           => ln_balancing_debit_amt,
6058           p_entered_cr           => ln_balancing_credit_amt,
6059 
6060           p_currency_code        => jai_rcv_trx_processing_pkg.gv_func_curr,
6061           p_accounting_date      => lv_accounting_date,
6062           p_reference_10         => lv_reference10,
6063           p_reference_23         => lv_reference23, --'jai_rcv_excise_processing_pkg.accounting_entries',
6064           p_reference_24         => lv_reference24, --'rcv_transactions',
6065           p_reference_25         => lv_reference25, --'transaction_id',
6066           p_reference_26         => lv_reference26, -- <transaction_id_value>
6067           p_destination          => 'G',
6068           p_simulate_flag        => lv_simulate_flag,
6069           p_codepath             => pv_codepath,
6070           p_process_status       => pv_process_status,
6071           p_process_message      => pv_process_message
6072           ,p_reference_name     => lv_reference_name,
6073           p_reference_id        => ln_reference_id
6074       );
6075 
6076       lv_statement_id := '28';
6077       if pv_process_status = 'E' then
6078         goto end_of_procedure;
6079       end if;
6080 
6081     end if;
6082 
6083     -- added by csahoo for bug#6078460, start
6084 		/* SH Education Cess Acccounting Entries */
6085 		 if r_diff_tax.excise_edu_cess <> 0 then
6086 
6087 			 lv_statement_id := '29';
6088 			 lv_acct_nature  := 'CENVAT-SH-EDUCESS-SSI';
6089 			 ln_ccid         := ln_excise_sh_cess_accnt_id;
6090 
6091 			 if lv_register_entry_type = jai_rcv_excise_processing_pkg.CENVAT_DEBIT then
6092 				 ln_debit_amt  := null;
6093 				 ln_credit_amt := r_diff_tax.sh_exc_edu_cess;
6094 				 ln_balancing_debit_amt  := r_diff_tax.sh_exc_edu_cess;
6095 				 ln_balancing_credit_amt := null;
6096 			 else
6097 				 ln_debit_amt  := r_diff_tax.sh_exc_edu_cess;
6098 				 ln_credit_amt := null;
6099 				 ln_balancing_debit_amt  := null;
6100 				 ln_balancing_credit_amt := r_diff_tax.sh_exc_edu_cess;
6101 			 end if;
6102 
6103 			 lv_statement_id := '30';
6104 			 /* Primary Accounting Entry - 2 */
6105 			 jai_rcv_accounting_pkg.process_transaction(
6106 					 p_transaction_id       => r_trx.transaction_id,
6107 					 p_acct_type            => lv_acct_type,
6108 					 p_acct_nature          => lv_acct_nature,
6109 					 p_source_name          => jai_rcv_excise_processing_pkg.gv_source_name,
6110 					 p_category_name        => jai_rcv_excise_processing_pkg.gv_category_name,
6111 
6112 					 p_code_combination_id  => ln_ccid,
6113 					 p_entered_dr           => ln_debit_amt,
6114 					 p_entered_cr           => ln_credit_amt,
6115 
6116 					 p_currency_code        => jai_rcv_trx_processing_pkg.gv_func_curr,
6117 					 p_accounting_date      => lv_accounting_date,
6118 					 p_reference_10         => lv_reference10,
6119 					 p_reference_23         => lv_reference23, --'jai_rcv_excise_processing_pkg.accounting_entries',
6120 					 p_reference_24         => lv_reference24, --'rcv_transactions',
6121 					 p_reference_25         => lv_reference25, --'transaction_id',
6122 					 p_reference_26         => lv_reference26, -- <transaction_id_value>
6123 					 p_destination          => 'G',
6124 					 p_simulate_flag        => lv_simulate_flag,
6125 					 p_codepath             => pv_codepath,
6126 					 p_process_status       => pv_process_status,
6127 					 p_process_message      => pv_process_message
6128 					 ,p_reference_name     => lv_reference_name,
6129 					 p_reference_id        => ln_reference_id
6130 			 );
6131 			fnd_file.put_line(FND_FILE.LOG, ' lv_statement_id ' || lv_statement_id);
6132 			 lv_statement_id := '31';
6133 			 if pv_process_status = 'E' then
6134 				 goto end_of_procedure;
6135 			 end if;
6136 
6137 			 lv_statement_id := '32';
6138 			 /* Balacing Accounting Entry - 2  */
6139 			 jai_rcv_accounting_pkg.process_transaction(
6140 					 p_transaction_id       => r_trx.transaction_id,
6141 					 p_acct_type            => lv_acct_type,
6142 					 p_acct_nature          => lv_acct_nature,
6143 					 p_source_name          => jai_rcv_excise_processing_pkg.gv_source_name,
6144 					 p_category_name        => jai_rcv_excise_processing_pkg.gv_category_name,
6145 
6146 					 p_code_combination_id  => ln_balancing_ccid,
6147 					 p_entered_dr           => ln_balancing_debit_amt,
6148 					 p_entered_cr           => ln_balancing_credit_amt,
6149 
6150 					 p_currency_code        => jai_rcv_trx_processing_pkg.gv_func_curr,
6151 					 p_accounting_date      => lv_accounting_date,
6152 					 p_reference_10         => lv_reference10,
6153 					 p_reference_23         => lv_reference23, --'jai_rcv_excise_processing_pkg.accounting_entries',
6154 					 p_reference_24         => lv_reference24, --'rcv_transactions',
6155 					 p_reference_25         => lv_reference25, --'transaction_id',
6156 					 p_reference_26         => lv_reference26, -- <transaction_id_value>
6157 					 p_destination          => 'G',
6158 					 p_simulate_flag        => lv_simulate_flag,
6159 					 p_codepath             => pv_codepath,
6160 					 p_process_status       => pv_process_status,
6161 					 p_process_message      => pv_process_message
6162 					 ,p_reference_name     => lv_reference_name,
6163 					 p_reference_id        => ln_reference_id
6164 			 );
6165 			fnd_file.put_line(FND_FILE.LOG, ' lv_statement_id ' || lv_statement_id);
6166 			 lv_statement_id := '28';
6167 			 if pv_process_status = 'E' then
6168 				 goto end_of_procedure;
6169 			 end if;
6170 
6171 
6172     end if;
6173 
6174     -- added by csahoo for bug#6078460, end
6175 
6176     lv_statement_id := '29';
6177     pv_process_status := jai_constants.yes;
6178     <<end_of_procedure>>
6179     pv_codepath := jai_general_pkg.plot_codepath(75, pv_codepath, 'jai_rcv_excise_processing_pkg.rtv_processing_for_ssi', 'END');
6180 
6181   exception
6182     when others then
6183       pv_process_status := 'E';
6184       pv_process_message := 'Unexpected error in jai_rcv_excise_processing_pkg.rtv_processing_for_ssi(StmtId:'
6185                             ||lv_statement_id||'). ErrMsg:'||SQLERRM;
6186       pv_codepath := jai_general_pkg.plot_codepath(999, pv_codepath, 'jai_rcv_excise_processing_pkg.rtv_processing_for_ssi', 'END');
6187 
6188   end rtv_processing_for_ssi;
6189 
6190 END jai_rcv_excise_processing_pkg;