DBA Data[Home] [Help]

PACKAGE BODY: APPS.JAI_RCV_RCV_RTV_PKG

Source


1 PACKAGE BODY jai_rcv_rcv_rtv_pkg AS
2 /* $Header: jai_rcv_rcv_rtv.plb 120.34.12020000.7 2013/04/23 06:38:00 qimeng ship $ */
3 
4 /* --------------------------------------------------------------------------------------
5 Filename: jai_rcv_rcv_rtv_pkg.sql
6 
7 Change History:
8 
9 Date         Bug         Remarks
10 ---------    ----------  -------------------------------------------------------------
11 06-sep-2004  3848010     Created by Aparajita for correction ER#3848010. version#115.0.
12 
13                          This package has been developed as a part of correction ER#3496408.
14                          This takes care of the non cenvat processing of RECEIVE and RTV
15                          type of transactions along with their CORRECT transactions.
16 
17                          Process_transaction procedure of this package is the procedure which is
18                          called for processing of RECEIVE and RTV for a particular transaction id.
19                          process_transaction calls the following procedures of this package for
20                          the processing.
21 
22                          get_accounts
23                          get_tax_breakup
24                          validate_transaction_tax_accnt
25                          apply_relieve_boe. This further calls one of this
26                           apply_boe
27                           relieve_boe
28                          post_entries
29 
30 
31 18-jan-2005              Service Tax and Education Cess. Version#115.1
32               4106633    Base Bug For Education Cess on Excise, CVD and Customs.
33               4059774    Base Bug For Service Tax Regime Implementation.
34               4078546    Modification in receive and rtv accounting for service tax
35 
36                          For Education Cess Implementation, following changes are done.
37                               1. Taxes of type Excise Cess are considered
38                                   along with taxes of type Excise.
39 
40                               2. Taxes of type CVD Cess are considered
41                                   along with taxes of type CVD.
42 
43                               2. Taxes of type Custom Cess are considered
44                                   along with taxes of type Custom.
45 
46                          For Implementation of Service tax, wherever recoverable
47                          service tax exists following changes are done.
48 
49                               1. Receiving account is excluding recoverable service tax.
50                               2. Accrual account excludes recoverable service tax conditionally.
51                               3. Recoverable serive tax amount should be posted to interim
52                                  service tax account defined for the org and the tax type
53                                  conditionally.
54 
55                                  Service Tax accounting is debit for receive and it's corrections
56                                  and credit for RTV and it's corrections.
57 
58                          Procedure service_tax_accounting has been introduced to take care of
59                          accounting for the interim service tax account entries.
60 
61 17-feb-2005    4171469   ISO accounting for trading to trading ISO scenarios. Version#115.2
62 
63                          Eariler trading to trading ISO accounting was not happening. This was
64                          because this program unit was not called in that scenarios. Now it
65                          is being called from India receiving transaction processor.
66 
67                          Changes done for this scenario are, for trading to trading ISO following
68                          account entries are required.
69 
70                          debit inventory receiving
71                          credit intransit inventory account
72 
73                          Additional entry of inter org payable and inter org receivable are not required.
74 
75 
76                         No dependency.
77 
78 03-Mar-2005    Vijay Shankar for Bug#4215402, Version:115.3
79                  po_distribution_id is populated as null in rcv_Transactions for non inventory items.
80                  so to get accrue_on_receipt_flag from PO, we need line_location_id instead of
81                  po_distribution_id. So changes are made to pass line_location_id also to
82                  jai_rcv_trx_processing_pkg.get_accrue_on_receipt function
83 
84 
85 19/03/2005   Vijay Shankar for Bug#4250236(4245089). FileVersion: 116.0(115.5)
86                 .Modified regime_tax_accounting_interim to work for any regime taxes based on regime setup
87                 .Made a call to regime_tax_accounting_interim for VAT Regime if recoverable vat taxes exist in the transaction
88                 .two new parameters are added in get_tax_breakup and post_entries procedure
89                 . Removed the rounding that is happening in get_tax_breakup procedure
90                 Other changes for VAT Implementation are made in the package apart from above changes
91 
92  10/05/2005   Vijay Shankar for Bug#4346453. Version: 116.1
93                  Code is modified due to the Impact of Receiving Transactions DFF Elimination
94 
95               * High Dependancy for future Versions of this object *
96 
97 08-Jun-2005   File Version 116.2. Object is Modified to refer to New DB Entity names in place of Old DB Entity Names
98               as required for CASE COMPLAINCE.
99 
100 13-Jun-2005   Ramananda for bug#4428980. File Version: 116.3
101               Removal of SQL LITERALs is done
102 
103 06-Jul-2005   Sanjikum for Bug#4474501
104               Commented the Call to function - jai_general_pkg.get_accounting_method
105 
106               Ramananda for bug#4477004. File Version: 116.4
107               GL Sources and GL Categories got changed. Refer bug for the details
108 
109 27/07/2005   Ramananda for Bug#4516577. File Version 120.3
110              Problem
111              -------
112              ISO Accounting Entries from Trading to Excise bonded inventory are not generated in case of following Scenarios
113              1. Trading organization to Trading Organization (only  Source organizations with the 'Excise in RG23D' setup).
114              2. Trading organization to Manufacturing Organization (Source Organization with the 'Excise in RG23D' setup).
115 
116              Fix
117              ---
118              In the Procedure get_accounts made the following changes -
119              1. In the cursor - c_ja_in_hr_organization_units,
120                 added a new column - "NVL(manufacturing, 'N') receiving_org_manufacturing" in the select
121              2. Changed the if condition -
122                 "if  r_iso_from_org_type.source_org_trading = 'Y' and
123                     ( r_ja_in_hr_organization_units.receving_org_trading = 'Y'
124                       OR
125                       r_ja_in_hr_organization_units1.receving_org_trading = 'Y'
126                     )
127                TO
128                "if  r_iso_from_org_type.source_org_trading = 'Y' and
129                   ( r_ja_in_hr_organization_units.receving_org_trading = 'Y'
130                     OR
131                     r_ja_in_hr_organization_units1.receving_org_trading = 'Y'
132                     OR                                                           --Added the OR Condition by Ramananda for Bug #4516577
133                     r_ja_in_hr_organization_units.receiving_org_manufacturing = 'Y'
134                     OR                                                           --Added the OR Condition by Ramananda for Bug #4516577
135                     r_ja_in_hr_organization_units1.receiving_org_manufacturing = 'Y'
136                   )
137 
138              (Functional)  Dependency Due to This Bug
139              --------------------------
140              jai_rcv_trx_prc.plb  (120.2)
141              jai_om_rg.plb        (120.2)
142 
143 27/07/2005   Ramananda for Bug#4514461, File Version 120.3
144              Problem
145              -------
146              On creating the receipt, system is giving the error - Both Credit and Debit are Zero
147 
148              Fix
149              ---
150              In the Procedure ja_in_receive_rtv_pkg.regime_tax_accounting_interim, before calling ja_in_receipt_accounting_pkg
151              Commented the condition -- if (ln_debit is not null or ln_credit is not null) then
152              And added the condition -- if (NVL(ln_debit,0) <> 0 OR NVL(ln_credit,0) <> 0) then
153 
154              Future Dependency due to this Bug
155              ---------------------------------
156              None
157 
158 28/11/2005 Harshita for Bug 4762433, File Version 120.4
159            Issue :
160            a) lv_source_name was declared with length 15 and assigned the value
161               'Purchasing India' which is of length 16 .
162            b) Who column information missing in the insert to the table JAI_RCV_REP_ACCRUAL_T.
163            Fix :
164            a) Modified the size of the variable lv_source_name from 15 to 20.
165               Changes made in the post_entries and regime_tax_accounting_interim procedures.
166            b) Added the who columns in the insert of JAI_RCV_REP_ACCRUAL_T.
167               Change made in the post_entries procedures.
168             Future Dependency due to this Bug
169             ---------------------------------
170              None
171 
172 30/10/2006 sacsethi for bug 5228046, File version 120.5
173             Forward porting the change in 11i bug 5365523 (Additional CVD Enhancement).
174             This bug has datamodel and spec changes.
175 
176 23/02/07      bduvarag for bug#5527885,File version 120.4
177                Forward porting the changes done in 11i bug#5478427
178 	      bduvarag for bug#5632406,File version 120.4
179                Forward porting the changes done in 11i bug#5603081
180 13/04/2007	bduvarag for the Bug#5989740, file version 120.11
181 		Forward porting the changes done in 11i bug#5907436
182 
183 25-April-2007   ssawant for bug 5879769 ,File version 120.5
184                 Forward porting of
185 		ENH : SERVICE TAX BY INVENTORY ORGANIZATION AND SERVICE TYPE SOLUTION
186 		from 11.5( bug no 5694855) to R12 (bug no 5879769).
187 
188 17-aug-2007     vkaranam for bug 6030615,File version 120.11
189                 Fwdporting of 115 bug 2942973(Interorg)
190 21-aug-2007     vkaranam for bug 6030615,File version 120.12
191                 Issue:
192                 In R12 we should not use org_organization_defintions view as this will cause the performance degradation.
193                 Changes are done as per the requirement.
194 
195 03-dec-2007     Eric modified cursor c_ja_in_receipt_tax_lines  and cursor
196                 c_ja_in_tax_amt_by_account to pick up the exclusive taxes only
197 
198 18-FEB-2008:     Changes done by nprashar for Bug #6807023. Changed the value of variable lv_organization_type to jai_constants.orgn_type_io;
199 
200 15-Apr-2008     rchandan for bug#6971526, File version 120.21
201                   Issue : ST2-VAT CLAIM AMOUNT IS NOT RIGHT FOR PARTIALLY RECOVERABLE VAT TAX.
202                   Fix : Changes made for bug#6681800 in version 120.16 were missed out when
203                         120.17 was arcsed in. Redone the changes.
204 
205 12-Nov-2008  Modified by JMEENA for bug#7310836
206 		   Modified the procedure process_transaction and added condition that checks the count of pl/sql table tr_jv.
207 		   If count is greater than zero then only it will proceed for accounting.
208 
209 13-Nov-2008   Changes by nprashar for bug  6321337 , FP changes of 11i bug 6200218.Changes has been made in procedure
210                      get_accounts to pass the appropirate accounting entries while performing the ISO cycle.
211                      trading to trading.
212 
213 23-Jan-2009   Bug 7699476 File version 120.21.12010000.4 / 120.24
214               Issue : IRTP is ending with warning : Error - ORA-06502: PL/SQL:numeric or value error: NULL index table key value
215 	              Source of the error is procedure regime_tax_accounting_interim in this package.
216 	      Casue : Index variable l_jv_line_num_generator is used to access a pl sql table. This
217 	              variable is defined in case of VAT (in elsif part), but undefined for Service
218 		      regime (if part).
219 	      Fix   : Added code in the if part so that the index variable will be defined for Service
220 	              regime also.
221 
222 6-Apr-2009   Bug 8488470 File version 120.21.12010000.5 / 120.25
223                      Issue - Accounting entries are not properly rounded for VAT during CORRECT / RTV. This also causes EU02 error during
224                                 journal import (one entry used rounded amount, other entry used unrounded amount).
225                      Casue - Regime_tax_accounting_interim procedure uses rounding logic for recoverable tax. But the procedure get_tax_breakup
226                                   applied rounding only for partially recoverable taxes.
227                      Fix - Modified procedure get_tax_breakup so that rounding would be done for fully recoverable taxes also.
228 
229 12-DEC-2008  Bug 7640943 (FP for bug 7588482) File version 120.21.12010000.6 / 120.26
230              Issue : During RTV the balance in receiving inventory / AP accrual account is not
231              completely knocked off.
232              Cause : Cenvat reversal accounting is generated for the rounded off tax amount for
233              the return quantity (legal requirement). But the normal "Receiving" entry is passed
234              for the exact (quantity-apportioned) tax amount for the returned quantity. There
235              will be a net difference due to rounding.
236              Fix   : The normal "Receiving" accounting entry should be generated with the excise
237              tax amounts rounded off according to setup. Necessary changes are done in the
238              procedure get_tax_breakup.
239 17-jul-2009 vkaranam for bug#8691046
240  Issue:Wrong amount has been accounted for RMA receipt.
241 	    Fix:
242 	    ln_credit is wrongly calculated for p_attribute_category = 'CUSTOMER'
243             FWDPORTED THE CHANGES doen in 115 bug#6377961 (Replaced p_excise_edu_cess with p_excise_sh_edu_cess).
244 
245 01-Feb-2010   Bug 9319913 File version 120.21.12010000.8 / 120.28
246                Issue - Tax amount gets rounded in the accrual reconciliation report.
247                Fix - Removed the round() function for the accrual amount when inserting into table
248                      jai_rcv_rep_accrual_t.
249 
250 09-may-2011  vkaranam for bug#10167393
251              Issue: VALUE AND TAXES AS PER CORRECTION OF QTY IS NOT UPDATED IN SYSTEM
252              Fix:
253              Adhoc freight taxes shall not be apportioned during receipt correction and
254              there will not be any correction accounting for the adhoc freight taxes.
255 
256 13-may-2011 vkaranam for bug#10167393
257 Issue: VALUE AND TAXES AS PER CORRECTION OF QTY IS NOT UPDATED IN SYSTEM
258             Review comment:  taxes should get  proportioned in case of qty/rate based.
259             Fix : Added the qty/rate condition for apportioning logic in get_tax_breakup function.
260 07-jun-2011 vkaranam for bug#11936596
261              Issue: R12:POT - INCLUSIVE TAX ACCOUNTING NOT HAPPENING FOR PO MATCHED INVOICES
262              Fix details: Changes are done in get_Tax_breakup ,post_entries procedure
263 Accounting entry for inclusive service tax at receive event:
264 Dr Receiving Inventory (-service recoverable amt)
265 Cr AP Accrual account  (-service recoverable amt)
266 
267 20-Jan-2012  vkavulur for bug #13494816
268   			 Issue : ROUNDING DIFFERENCE IN RETURN TO VENDOR ACCOUNTING
269  			 Fix Details : Changes are done in get_Tax_breakup procedure to
270 			 multiply the taxes with the apportion factor once the excise
271 			 taxes are rounded
272 
273 04-Aug-2012  Bug 14185068
274              Description: VAT Inclusive Tax Accounting is incorrect in P2P flow. VAT Interim Account
275              is not set off ot Receiving Inventory Account when a Receipt is created
276              Fix: Added parameters to fetch the VAT Inclusive Tax in get_tax_breakup.
277              Passed the same to post_entries to create accounting in Receving Inventory.
278              Fetched VAT Inclusive Tax in regime_tax_accounting_interim to set off the entry
279              created in post_entries.
280 
281 21-Sep-2012  mmurtuza for bug 14307860
282 	 Description: WRONG ACCOUNTING FOR ISO SHIPMENT AND RECEIPT
283 	 Fix: Added code in procedure validate_transaction_tax_accnt such that  p_ap_accrual_account is picked as p_interorg_payables_account
284 	 when fob point is receipt (2)
285 
286 24-Jan-2013 mmurtuza for bug 16101545
287      Description: WRONG INCLUSIVE TAX ACCOUNTING AT RECEIPT FOR ISO
288 	 Fix: Added excise taxes and changed tax_types.tax_type to jtc.tax_type in cursor c_ja_in_receipt_tax_lines
289 	      Also chekced for excise taxes before setting ln_tax_amount to zero
290 
291 23-Apr-2013 qimeng for bug 16598602
292    Description: VAT INTERIM RECOVERY NOT DEBITED ON PO RECEIPT FOR INCLUSIVE VAT TAXES
293    Fix: Add condition: or nvl(ln_inclu_vat_recoverable,0) <> 0
294         before calling of regime_tax_accounting_interim
295 
296 
297 Dependency Section
298 ========== =======
299 
300 Date      Version    Bug         Remarks
301 --------- -------   ----------  -------------------------------------------------------------
302 6-sep-04  115.0     ER#3848010  This is a part of correction ER.
303 
304 28-jan-05 115.1     Er#4239736  This is a Service + Cess Solution.
305 
306 19-mar-05 115.4     ER#4245089  VAT Solution
307 10-may-05 116.1     ER#4346453  DFF Elimination Enh.
308 ----------------------------------------------------------------------------------------- */
309 /*Bug 5527885 Start*/
310 gn_currency_precision number;
311 gv_inv_receiving      constant  varchar2(30) := 'INVENTORY RECEIVING';
312 gv_ap_accrual         constant  varchar2(30) := 'AP ACCRUAL';
313 gv_boe                constant  varchar2(30) := 'BOE';
314 gv_rtv_expense        constant  varchar2(30) := 'RTV EXPENSE';
315 gv_iso_receivables    constant  varchar2(30) := 'ISO RECEIVABLES';
316 gv_iso_intransit_inv  constant  varchar2(30) := 'ISO INTRANSIT INVENTORY';
317 gv_vat_interim        constant  varchar2(30) := 'VAT INTERIM';
318 gv_service_interim    constant  varchar2(30) := 'SERVICE INTERIM';
319 gv_regime_interim     constant  varchar2(30) := 'REGIME INTERIM';
320 gv_credit             constant  varchar2(30) := 'CREDIT';
321 gv_debit              constant  varchar2(30) := 'DEBIT';
322 /*Bug 5527885 End*/
323 
324 /****************************** Start process_transaction  ****************************/
325 
326 
327   procedure process_transaction
328   (
329     p_transaction_id                          in                 number,
330     p_simulation                              in                 varchar2,  -- default 'N', File.Sql.35
331     p_debug                                   in                 varchar2,  -- default 'Y', File.Sql.35
332     p_process_flag                            out      nocopy    varchar2,
333     p_process_message                         out      nocopy    varchar2,
334     p_codepath                                in out   nocopy    varchar2
335   )is
336 
337   cursor c_ja_in_rcv_transactions(cp_transaction_id in number) is
338     select  organization_id,
339             location_id,
340             transaction_type,
341             parent_transaction_type,
342             currency_conversion_rate,
343             transaction_date,
344             parent_transaction_id,
345             inventory_item_id,
346             inv_item_flag /* Service */
347     from    JAI_RCV_TRANSACTIONS
348     where   transaction_id = cp_transaction_id;
349 
350   cursor    c_rcv_transactions(cp_transaction_id in number) is
351     select  shipment_header_id,
352             shipment_line_id,
353             po_distribution_id,
354             po_line_location_id,
355             currency_code, /*Bug 12543504*/
356             -- attribute5, Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh.
357             vendor_id
358             -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. , upper(attribute_category) attribute_category
359             -- , source_document_code
360             -- , decode(source_document_code, 'RMA', jai_rcv_trx_processing_pkg.india_rma_receipt,
361             --                                      jai_rcv_trx_processing_pkg.india_receipt) attribute_category
362     from    rcv_transactions
363     where   transaction_id = cp_transaction_id;
364 
365   cursor    c_rcv_shipment_lines(cp_shipment_line_id number) is
366     select  from_organization_id,
367             to_organization_id
368     from    rcv_shipment_lines
369     where   shipment_line_id = cp_shipment_line_id;
370 
371   cursor    c_rcv_shipment_headers(cp_shipment_header_id number) is
372     select  upper(receipt_source_code) receipt_source_code,
373             receipt_num
374     from    rcv_shipment_headers
375     where   shipment_header_id = cp_shipment_header_id;
376 
377 
378   r_ja_in_rcv_transactions            c_ja_in_rcv_transactions%rowtype;
379   r_rcv_transactions                  c_rcv_transactions%rowtype;
380   r_rcv_shipment_lines                c_rcv_shipment_lines%rowtype;
381   r_rcv_shipment_headers              c_rcv_shipment_headers%rowtype;
382 
383   ln_boe_account_id                   number;
384   ln_rtv_expense_account_id           number;
385   ln_excise_expense_account           number;
386   ln_excise_rcvble_account            number;
387   ln_receiving_account_id             number;
388   ln_ap_accrual_account               number;
389   ln_po_accrual_account_id            number;
390   ln_interorg_payables_account        number;
391   ln_intransit_inv_account            number;
392   ln_interorg_receivables_accnt       number;
393   ln_intransit_type                   number;
394   ln_fob_point                        number;
395 
396   ln_all_taxes                        number;
397   ln_tds_taxes                        number;
398   ln_modvat_recovery_taxes            number;
399   ln_cvd_taxes                        number;
400   ln_add_cvd_taxes                    number;/*5228046 Additional cvd Enhancement*/
401   ln_customs_taxes                    number;
402   ln_third_party_taxes                number;
403   ln_excise_tax                       number;
404   ln_service_not_recoverable          number; /* Service */
405   ln_service_recoverable              number; /* Service */
406     ln_inclu_service_recoverable        number;--POT 11936596
407   ln_inclu_vat_recoverable            number; /*Bug 14185068*/
408 
409   /* two variables added by Vijay Shankar for Bug#4250236(4245089). VAT Impl. */
410   ln_vat_not_recoverable              number;
411   ln_vat_recoverable                  number;
412 
413   --lv_accounting_method_option         ap_system_parameters_all.accounting_method_option%type;  /* Service */
414   --commented the above by Sanjikum for Bug#4474501
415   lv_accrue_on_receipt_flag           po_distributions_all.accrue_on_receipt_flag%type;
416   ln_excise_edu_cess                  number; /* Educational Cess */
417   ln_excise_sh_edu_cess               number; /*Bug 5989740 bduvarag*/
418   ln_cvd_edu_cess                     number; /* Educational Cess */
419   ln_cvd_sh_edu_cess                  number; /*Bug 5989740 bduvarag*/
420   ln_customs_edu_cess                 number; /* Educational Cess */
421   ln_customs_sh_edu_cess              number; /*Bug 5989740 bduvarag*/
422 
423   --Added by zhiwei for BOE ER bug 11684111 begin
424   --------------------------------------------
425   ln_boe_other1               number;
426   ln_boe_other2               number;
427   ln_boe_other3               number;
428   ln_boe_other4               number;
429   ln_boe_other5               number;
430   ln_boe_surcharge_duty       number;
431   ln_boe_add_customs          number;
432   --------------------------------------------
433   --Added by zhiwei for BOE ER  bug 11684111 end
434   lv_temp                             varchar2(50);
435 
436   lb_account_service_interim          boolean; /* Service */
437 
438   lv_trading_to_trading_iso           varchar2(1); /* Bug#4171469 */
439 /*Bug 5527885 STart*/
440 tr_jv                     JOURNAL_LINES;
441   ln_jv_num_of_max_rec      number;
442   ln_max_jv_abs_amt         number;
443   ln_max_jv_amt_type        varchar2(30);
444   ln_diff_amt_between_dr_cr number;
445 
446   ln_tmp_dr_amt number;
447   ln_tmp_cr_amt number;
448   ln_cum_dr_amt number;
449   ln_cum_cr_amt number;
450 
451    v_rounding_diff_from	number;
452   v_rounding_diff_to	number;
453   v_line_count		number;
454   /*Bug 5527885 End*/
455 begin
456 
457   -- this is to identify the path in SQL TRACE file if any problem occured
458   SELECT 'jai_rcv_rcv_rtv_pkg-'||p_transaction_id INTO lv_temp FROM DUAL;
459 
460   if p_debug = 'Y' then
461     Fnd_File.put_line(Fnd_File.LOG, '**** Start of procedure jai_rcv_rcv_rtv_pkg.process_transaction ****');
462   end if;
463 
464   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.process_transaction', 'START'); /* 1 */
465 
466   open c_rcv_transactions(p_transaction_id);
467   fetch c_rcv_transactions into r_rcv_transactions;
468   close c_rcv_transactions;
469 
470   p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
471   open c_ja_in_rcv_transactions(p_transaction_id);
472   fetch c_ja_in_rcv_transactions into r_ja_in_rcv_transactions;
473   close c_ja_in_rcv_transactions;
474 
475   p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
476   open c_rcv_shipment_headers(r_rcv_transactions.shipment_header_id);
477   fetch c_rcv_shipment_headers into r_rcv_shipment_headers;
478   close c_rcv_shipment_headers;
479 
480   p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
481   open c_rcv_shipment_lines(r_rcv_transactions.shipment_line_id);
482   fetch c_rcv_shipment_lines into r_rcv_shipment_lines;
483   close c_rcv_shipment_lines;
484 
485   if p_debug = 'Y' then
486     Fnd_File.put_line(Fnd_File.LOG, ' Call to -> get_accounts');
487  --   Fnd_File.put_line(Fnd_File.LOG, ' Code Path :' || p_codepath );/*Bug 5527885*/
488   end if;
489 
490   /* Get the Details for service tax interim accounting and check if it is needed */
491   p_codepath := jai_general_pkg.plot_codepath(4.11, p_codepath); /* 4.11 */
492   /*lv_accounting_method_option :=
493   jai_general_pkg.get_accounting_method
494   (
495     p_org_id            =>    null,
496     p_organization_id   =>    r_ja_in_rcv_transactions.organization_id,
497     p_sob_id            =>    null
498   );*/
499   --commented the above by Sanjikum for Bug#4474501
500 
501   p_codepath := jai_general_pkg.plot_codepath(4.12, p_codepath); /* 4.12 */
502   lv_accrue_on_receipt_flag :=
503   jai_rcv_trx_processing_pkg.get_accrue_on_receipt
504   (p_po_distribution_id =>   r_rcv_transactions.po_distribution_id,
505   -- added by Vijay Shankar for Bug#4215402
506   p_po_line_location_id =>   r_rcv_transactions.po_line_location_id
507   );
508 
509 
510   p_codepath := jai_general_pkg.plot_codepath(4.13, p_codepath); /* 4.13 */
511   /*if  ( (lv_accrue_on_receipt_flag = 'N')
512           or
513           (lv_accounting_method_option = 'Cash' and
514            nvl(r_ja_in_rcv_transactions.inv_item_flag, 'N') = 'N'
515           )
516         )*/
517   --commented the above and added the below for Bug#4474501
518   if  lv_accrue_on_receipt_flag = 'N'
519 
520   then
521     p_codepath := jai_general_pkg.plot_codepath(4.14, p_codepath); /* 4.14 */
522     lb_account_service_interim := false;
523   else
524     p_codepath := jai_general_pkg.plot_codepath(4.15, p_codepath); /* 4.15 */
525     lb_account_service_interim := true;
526   end if;
527 /*Bug 5527885 Start*/
528  gn_currency_precision :=
529       jai_general_pkg.get_currency_precision(r_ja_in_rcv_transactions.organization_id);
530   if gn_currency_precision is null then
531     p_process_flag := 'E';
532     p_process_message := 'Currency Precision is null. Organization:'||r_ja_in_rcv_transactions.organization_id;
533     goto exit_from_procedure;
534   end if;
535 /*Bug 5527885 End*/
536 
537   p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
538   get_accounts
539   (
540     p_organization_id                =>    r_ja_in_rcv_transactions.organization_id,
541     p_location_id                    =>    r_ja_in_rcv_transactions.location_id,
542     p_receipt_source_code            =>    r_rcv_shipment_headers.receipt_source_code,
543     p_from_organization_id           =>    r_rcv_shipment_lines.from_organization_id,
544     p_to_organization_id             =>    r_rcv_shipment_lines.to_organization_id ,
545     p_po_distribution_id             =>    r_rcv_transactions.po_distribution_id,
546     p_po_line_location_id            =>    r_rcv_transactions.po_line_location_id,
547     /** OUT parameters **/
548     p_boe_account_id                 =>    ln_boe_account_id,
549     p_rtv_expense_account_id         =>    ln_rtv_expense_account_id,
550     p_excise_expense_account         =>    ln_excise_expense_account,
551     p_excise_rcvble_account          =>    ln_excise_rcvble_account,
552     p_receiving_account_id           =>    ln_receiving_account_id,
553     p_ap_accrual_account             =>    ln_ap_accrual_account,
554     p_po_accrual_account_id          =>    ln_po_accrual_account_id,
555     p_interorg_payables_account      =>    ln_interorg_payables_account,
556     p_intransit_inv_account          =>    ln_intransit_inv_account,
557     p_interorg_receivables_account   =>    ln_interorg_receivables_accnt,
558     p_intransit_type                 =>    ln_intransit_type,
559     p_fob_point                      =>    ln_fob_point,
560     p_trading_to_trading_iso         =>    lv_trading_to_trading_iso,  /* Bug#4171469 */
561     p_process_flag                   =>    p_process_flag,
562     p_process_message                =>    p_process_message,
563     p_debug                          =>    p_debug,
564     p_codepath                       =>    p_codepath
565    );
566 
567   if p_process_flag <> 'Y' then
568     /* get_accounts procedure has hit an error, cannot continue processing */
569     goto exit_from_procedure;
570   end if;
571 
572 
573   if p_debug = 'Y' then
574     Fnd_File.put_line(Fnd_File.LOG, ' Call to -> get_tax_breakup');
575 --    Fnd_File.put_line(Fnd_File.LOG, ' Code Path :' || p_codepath );/*Bug 5527885*/
576   end if;
577 
578   p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
579   get_tax_breakup
580   (
581     p_transaction_id                 =>    p_transaction_id,
582     p_shipment_line_id               =>    r_rcv_transactions.shipment_line_id,
583     p_currency_conversion_rate       =>    r_ja_in_rcv_transactions.currency_conversion_rate,
584     p_po_vendor_id                   =>    r_rcv_transactions.vendor_id,
585     p_all_taxes                      =>    ln_all_taxes,
586     p_tds_taxes                      =>    ln_tds_taxes ,
587     p_modvat_recovery_taxes          =>    ln_modvat_recovery_taxes,
588     p_cvd_taxes                      =>    ln_cvd_taxes,
589     p_add_cvd_taxes                  =>    ln_add_cvd_taxes,/*5228046 Additional cvd Enhancement*/
590     p_customs_taxes                  =>    ln_customs_taxes,
591     p_third_party_taxes              =>    ln_third_party_taxes,
592     p_excise_tax                     =>    ln_excise_tax,
593     p_service_recoverable            =>    ln_service_recoverable,
594     p_service_not_recoverable        =>    ln_service_not_recoverable,
595     p_vat_recoverable                =>    ln_vat_recoverable,
596     p_vat_not_recoverable            =>    ln_vat_not_recoverable,
597     p_excise_edu_cess                =>    ln_excise_edu_cess,
598     p_excise_sh_edu_cess             =>    ln_excise_sh_edu_cess,/*Bug 5989740 bduvarag*/
599     p_cvd_edu_cess                   =>    ln_cvd_edu_cess,
600     p_cvd_sh_edu_cess                =>    ln_cvd_sh_edu_cess,/*Bug 5989740 bduvarag*/
601     p_customs_edu_cess               =>    ln_customs_edu_cess,
602     p_customs_sh_edu_cess            =>    ln_customs_sh_edu_cess,/*Bug 5989740 bduvarag*/
603     --Added by zhiwei for BOE ER bug 11684111 begin
604     --------------------------------------------------------------------------------
605     p_boe_other1                     =>    ln_boe_other1,
606     p_boe_other2                     =>    ln_boe_other2,
607     p_boe_other3                     =>    ln_boe_other3,
608     p_boe_other4                     =>    ln_boe_other4,
609     p_boe_other5                     =>    ln_boe_other5,
610     p_boe_surcharge_duty             =>    ln_boe_surcharge_duty,
611     p_boe_add_customs                =>    ln_boe_add_customs,
612     --------------------------------------------------------------------------------
613     --Added by zhiwei for BOE ER bug 11684111  end
614     p_process_flag                   =>    p_process_flag,
615     p_process_message                =>    p_process_message,
616     p_debug                          =>    p_debug,
617     p_codepath                       =>    p_codepath,
618     --POT 11936596
619     p_inclu_service_recoverable            =>    ln_inclu_service_recoverable,
620     p_inclu_vat_recoverable          =>    ln_inclu_vat_recoverable /*Bug 14185068*/
621   );
622 
623   if p_process_flag <> 'Y' then
624     /* get_tax_breakup procedure has hit an error, cannot continue processing */
625     goto exit_from_procedure;
626   end if;
627 
628 
629   if p_debug = 'Y' then
630     Fnd_File.put_line(Fnd_File.LOG, ' Call to -> validate_transaction_tax_accnt');
631 --    Fnd_File.put_line(Fnd_File.LOG, ' Code Path :' || p_codepath );/*Bug 5527885*/
632   end if;
633 
634   p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
635 
636   validate_transaction_tax_accnt
637   (
638     p_transaction_type               =>    r_ja_in_rcv_transactions.transaction_type,
639     p_parent_transaction_type        =>    r_ja_in_rcv_transactions.parent_transaction_type,
640     -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. p_attribute_category             =>    r_rcv_transactions.attribute_category,
641     p_receipt_source_code            =>    r_rcv_shipment_headers.receipt_source_code,
642     p_boe_account_id                 =>    ln_boe_account_id,
643     p_rtv_expense_account_id         =>    ln_rtv_expense_account_id,
644     p_excise_expense_account         =>    ln_excise_expense_account,
645     p_excise_rcvble_account          =>    ln_excise_rcvble_account,
646     p_receiving_account_id           =>    ln_receiving_account_id,
647     p_ap_accrual_account             =>    ln_ap_accrual_account,
648     p_po_accrual_account_id          =>    ln_po_accrual_account_id,
649     p_interorg_payables_account      =>    ln_interorg_payables_account,
650     p_intransit_inv_account          =>    ln_intransit_inv_account,
651     p_interorg_receivables_account   =>    ln_interorg_receivables_accnt,
652     p_intransit_type                 =>    ln_intransit_type,
653     p_fob_point                      =>    ln_fob_point,
654     p_cvd_taxes                      =>    ln_cvd_taxes,
655     p_add_cvd_taxes                  =>    ln_add_cvd_taxes,/*5228046 Additional cvd Enhancement*/
656     p_customs_taxes                  =>    ln_customs_taxes,
657     p_third_party_taxes              =>    ln_third_party_taxes,
658     p_excise_tax                     =>    ln_excise_tax,
659     p_trading_to_trading_iso         =>    lv_trading_to_trading_iso,  /* Bug#4171469 */
660     p_process_flag                   =>    p_process_flag,
661     p_process_message                =>    p_process_message,
662     p_debug                          =>    p_debug,
663     p_codepath                       =>    p_codepath
664   );
665 
666   if p_process_flag <> 'Y' then
667     /* validate_transaction_tax_accnt procedure has hit an error, cannot continue processing */
668     goto exit_from_procedure;
669   end if;
670 
671   if p_debug = 'Y' then
672     Fnd_File.put_line(Fnd_File.LOG, ' Call to -> apply_relieve_boe');
673 --    Fnd_File.put_line(Fnd_File.LOG, ' Code Path :' || p_codepath );/*Bug 5527885*/
674   end if;
675 
676   p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
677 
678   apply_relieve_boe
679   (
680     p_transaction_id                =>     p_transaction_id,
681     p_transaction_type              =>     r_ja_in_rcv_transactions.transaction_type,
682     p_parent_transaction_id         =>     r_ja_in_rcv_transactions.parent_transaction_id,
683     p_parent_transaction_type       =>     r_ja_in_rcv_transactions.parent_transaction_type,
684     p_shipment_line_id              =>     r_rcv_transactions.shipment_line_id,
685     p_shipment_header_id            =>     r_rcv_transactions.shipment_header_id,
686     p_organization_id               =>     r_ja_in_rcv_transactions.organization_id,
687     p_inventory_item_id             =>     r_ja_in_rcv_transactions.inventory_item_id,
688     p_cvd_taxes                     =>     ln_cvd_taxes,
689     p_add_cvd_taxes                  =>    ln_add_cvd_taxes,/*5228046 Additional cvd Enhancement*/
690     p_customs_taxes                 =>     ln_customs_taxes,
691     p_cvd_edu_cess                  =>     ln_cvd_edu_cess,     /* Educational Cess */
692     p_cvd_sh_edu_cess               =>     ln_cvd_sh_edu_cess, /*Bug 5989740 bduvarag*/
693     p_customs_edu_cess              =>     ln_customs_edu_cess, /* Educational Cess */
694     p_customs_sh_edu_cess           =>     ln_customs_sh_edu_cess,/*Bug 5989740 bduvarag*/
695     --Added by zhiwei for BOE ER  bug 11684111 begin
696     -------------------------------------------------------------
697     p_boe_other1                     =>    ln_boe_other1,
698     p_boe_other2                     =>    ln_boe_other2,
699     p_boe_other3                     =>    ln_boe_other3,
700     p_boe_other4                     =>    ln_boe_other4,
701     p_boe_other5                     =>    ln_boe_other5,
702     p_boe_surcharge_duty             =>    ln_boe_surcharge_duty,
703     p_boe_add_customs                =>    ln_boe_add_customs,
704     ----------------------------------------------------------------
705     --Added by zhiwei for BOE ER bug 11684111  end
706     p_simulation                    =>     p_simulation,
707     p_process_flag                  =>     p_process_flag,
708     p_process_message               =>     p_process_message,
709     p_debug                         =>     p_debug,
710     p_codepath                      =>     p_codepath
711   );
712 
713   if p_process_flag <> 'Y' then
714     /* apply_relieve_boe procedure has hit an error, cannot continue processing */
715     goto exit_from_procedure;
716   end if;
717 
718   if p_debug = 'Y' then
719     Fnd_File.put_line(Fnd_File.LOG, ' Call to -> post_entries');
720 --    Fnd_File.put_line(Fnd_File.LOG, ' Code Path :' || p_codepath );/*Bug 5527885*/
721   end if;
722       Fnd_File.put_line(Fnd_File.LOG, ' p_transaction_id:'||p_transaction_id);
723       Fnd_File.put_line(Fnd_File.LOG, ' ln_receiving_account_id:'||ln_receiving_account_id);
724       Fnd_File.put_line(Fnd_File.LOG, ' ln_ap_accrual_account:'||ln_ap_accrual_account);
725       Fnd_File.put_line(Fnd_File.LOG, ' ln_intransit_inv_account:'||ln_intransit_inv_account);
726       Fnd_File.put_line(Fnd_File.LOG, ' ln_interorg_receivables_accnt:'||ln_interorg_receivables_accnt);
727       Fnd_File.put_line(Fnd_File.LOG, ' p_interorg_payables_account:'||ln_interorg_payables_account);
728 Fnd_File.put_line(Fnd_File.LOG, 'ln_inclu_service_recoverable '||ln_inclu_service_recoverable);--11936596
729 
730   p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9 */
731   post_entries
732   (
733     p_transaction_id                 =>    p_transaction_id,
734     p_transaction_type               =>    r_ja_in_rcv_transactions.transaction_type,
735     p_parent_transaction_type        =>    r_ja_in_rcv_transactions.parent_transaction_type,
736     -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. p_attribute_category             =>    r_rcv_transactions.attribute_category,
737     p_receipt_source_code            =>    r_rcv_shipment_headers.receipt_source_code,
738     p_transaction_date               =>    r_ja_in_rcv_transactions.transaction_date,
739     p_receipt_num                    =>    r_rcv_shipment_headers.receipt_num,
740     p_receiving_account_id           =>    ln_receiving_account_id,
741     p_ap_accrual_account             =>    ln_ap_accrual_account,
742     p_boe_account_id                 =>    ln_boe_account_id,
743     p_rtv_expense_account_id         =>    ln_rtv_expense_account_id,
744     p_intransit_type                 =>    ln_intransit_type,
745     p_fob_point                      =>    ln_fob_point,
746     p_intransit_inv_account          =>    ln_intransit_inv_account,
747     p_interorg_receivables_account   =>    ln_interorg_receivables_accnt,
748     p_all_taxes                      =>    ln_all_taxes,
749     p_tds_taxes                      =>    ln_tds_taxes ,
750     p_modvat_recovery_taxes          =>    ln_modvat_recovery_taxes,
751     p_cvd_taxes                      =>    ln_cvd_taxes,
752     p_add_cvd_taxes                  =>    ln_add_cvd_taxes,/*5228046 Additional cvd Enhancement*/
753     p_customs_taxes                  =>    ln_customs_taxes,
754     p_third_party_taxes              =>    ln_third_party_taxes,
755     p_excise_tax                     =>    ln_excise_tax,
756     p_service_recoverable            =>    ln_service_recoverable,
757     p_service_not_recoverable        =>    ln_service_not_recoverable,
758     p_vat_recoverable                =>    ln_vat_recoverable,
759     p_vat_not_recoverable            =>    ln_vat_not_recoverable,
760     p_account_service_interim        =>    lb_account_service_interim,  /* Service */
761     p_excise_edu_cess                =>    ln_excise_edu_cess,  /* Educational Cess */
762     p_excise_sh_edu_cess             =>    ln_excise_sh_edu_cess, /*Bug 5989740 bduvarag*/
763     p_cvd_edu_cess                   =>    ln_cvd_edu_cess,     /* Educational Cess */
764     p_cvd_sh_edu_cess                =>    ln_cvd_sh_edu_cess,	/*Bug 5989740 bduvarag*/
765     p_customs_edu_cess               =>    ln_customs_edu_cess, /* Educational Cess */
766     p_customs_sh_edu_cess            =>    ln_customs_sh_edu_cess,/*Bug 5989740 bduvarag*/
767     --Added by zhiwei for BOE ER  bug 11684111 begin
768     ------------------------------------------------------------------
769     p_boe_other1                     =>    ln_boe_other1,
770     p_boe_other2                     =>    ln_boe_other2,
771     p_boe_other3                     =>    ln_boe_other3,
772     p_boe_other4                     =>    ln_boe_other4,
773     p_boe_other5                     =>    ln_boe_other5,
774     p_boe_surcharge_duty             =>    ln_boe_surcharge_duty,
775     p_boe_add_customs                =>    ln_boe_add_customs,
776     -------------------------------------------------------------------
777     --Added by zhiwei for BOE ER  bug 11684111 end
778     p_trading_to_trading_iso         =>    lv_trading_to_trading_iso,  /* Bug#4171469 */
779     ptr_jv                           =>    tr_jv,   /* 5527885 */
780     p_simulation                     =>    p_simulation,
781     p_process_flag                   =>    p_process_flag,
782     p_process_message                =>    p_process_message,
783     p_debug                          =>    'Y',
784     p_codepath                       =>    p_codepath,
785     --POT 11936596
786     p_inclu_service_recoverable      =>    ln_inclu_service_recoverable*-1 ,
787     p_inclu_vat_recoverable          =>    ln_inclu_vat_recoverable  /*Bug 14185068*/
788   );
789 
790 
791   if p_process_flag <> 'Y' then
792     /* post_entries procedure has hit an error, cannot continue processing */
793     goto exit_from_procedure;
794   end if;
795 
796   p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10 */
797 /*Bug 5632406 Start*/
798  if (lb_account_service_interim and nvl(ln_service_recoverable, 0) <> 0 )
799     and   r_rcv_shipment_headers.receipt_source_code <> 'CUSTOMER'
800     /* bug#5632406 - bduvarag used the p_receipt_source_code
801     instead of nvl(r_rcv_transactions.attribute_category, 'XX') <> 'INDIA RMA RECEIPT'*/
802   then
803 /*Bug 5632406 End*/
804     p_codepath := jai_general_pkg.plot_codepath(10.1, p_codepath); /* 10.1 */
805 
806     regime_tax_accounting_interim
807     (
808     p_transaction_id                 =>    p_transaction_id,
809     p_shipment_line_id               =>    r_rcv_transactions.shipment_line_id,
810     p_organization_id                =>    r_ja_in_rcv_transactions.organization_id,
811     p_location_id                    =>    r_ja_in_rcv_transactions.location_id,
812     p_transaction_type               =>    r_ja_in_rcv_transactions.transaction_type,
813     p_currency_conversion_rate       =>    r_ja_in_rcv_transactions.currency_conversion_rate,
814     p_parent_transaction_type        =>    r_ja_in_rcv_transactions.parent_transaction_type,
815     -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. p_attribute_category             =>    r_rcv_transactions.attribute_category,
816     p_receipt_source_code            =>    r_rcv_shipment_headers.receipt_source_code,
817     p_transaction_date               =>    r_ja_in_rcv_transactions.transaction_date,
818     p_receipt_num                    =>    r_rcv_shipment_headers.receipt_num,
819     p_regime_code                    =>    jai_constants.service_regime,
820     ptr_jv                           =>    tr_jv,/*Bug 5632406*/
821     p_simulation                     =>    p_simulation,
822     p_process_flag                   =>    p_process_flag,
823     p_process_message                =>    p_process_message,
824     p_debug                          =>    p_debug,
825     p_codepath                       =>    p_codepath
826     );
827 
828     if p_process_flag <> 'Y' then
829       /* post_entries procedure has hit an error, cannot continue processing */
830       goto exit_from_procedure;
831     end if;
832 
833   end if;
834 
835   /* following call added by Vijay Shankar for Bug#4250236(4245089). VAT Impl. */
836   if (nvl(ln_vat_recoverable, 0) <> 0 OR nvl(ln_inclu_vat_recoverable,0) <> 0) /*Bug 16598602 VAT interim accounting required as inclusive vat tax exists*/
837      and r_rcv_shipment_headers.receipt_source_code <> 'CUSTOMER'  then/*Bug 5527885*/
838     p_codepath := jai_general_pkg.plot_codepath(10.2, p_codepath); /* 10.2 */ /*Bug 5527885*/
839     /* VAT interim accounting required as recoverable vat tax exists */
840     regime_tax_accounting_interim
841     (
842     p_transaction_id                 =>    p_transaction_id,
843     p_shipment_line_id               =>    r_rcv_transactions.shipment_line_id,
844     p_organization_id                =>    r_ja_in_rcv_transactions.organization_id,
845     p_location_id                    =>    r_ja_in_rcv_transactions.location_id,
846     p_transaction_type               =>    r_ja_in_rcv_transactions.transaction_type,
847     p_currency_conversion_rate       =>    r_ja_in_rcv_transactions.currency_conversion_rate,
848     p_parent_transaction_type        =>    r_ja_in_rcv_transactions.parent_transaction_type,
849     -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. p_attribute_category             =>    r_rcv_transactions.attribute_category,
850     p_receipt_source_code            =>    r_rcv_shipment_headers.receipt_source_code,
851     p_transaction_date               =>    r_ja_in_rcv_transactions.transaction_date,
852     p_receipt_num                    =>    r_rcv_shipment_headers.receipt_num,
853     p_regime_code                    =>    jai_constants.vat_regime,
854     ptr_jv                           =>    tr_jv,/*Bug 5632406*/
855     p_simulation                     =>    p_simulation,
856     p_process_flag                   =>    p_process_flag,
857     p_process_message                =>    p_process_message,
858     p_debug                          =>    p_debug,
859     p_codepath                       =>    p_codepath
860     );
861 
862     if p_process_flag <> 'Y' then
863       /* post_entries procedure has hit an error, cannot continue processing */
864       goto exit_from_procedure;
865     end if;
866 
867   end if;  /* VAT interim accounting */
868 
869   /*Bug 12543504 - When an RMA Receipt is delivered, TCS must be moved from Liability to Interim Liability*/
870   jai_ar_tcs_rep_pkg.receipt_interim_accounting(p_shipment_line_id => r_rcv_transactions.shipment_line_id,
871                                                 p_shipment_header_id=> r_rcv_transactions.shipment_header_id,
872                                                 p_organization_id=>r_ja_in_rcv_transactions.organization_id,
873                                                 p_line_location_id=>r_ja_in_rcv_transactions.location_id,
874                                                 p_currency_conversion_rate=>r_ja_in_rcv_transactions.currency_conversion_rate,
875                                                 p_transaction_type=> r_ja_in_rcv_transactions.transaction_type,
876                                                 p_transaction_id=>p_transaction_id,
877                                                 v_currency_code=> r_rcv_transactions.currency_code,
878                                                 p_process_flag=>p_process_flag,
879                                                 p_process_message=>p_process_message);
880 
881 /*Bug 5527885 Start*/
882   p_codepath := jai_general_pkg.plot_codepath(10.3, p_codepath); /* 11 */
883   /* START 5478427 */
884   /* Code for rounding logic */
885   ln_cum_dr_amt := 0;
886   ln_cum_cr_amt := 0;
887   ln_max_jv_abs_amt := 0;
888    v_line_count := 0;/*Bug 5527885*/
889 Fnd_File.put_line(Fnd_File.LOG, ' Befor looping of table variable tr_jv tr_jv.count is :'||tr_jv.count);  --Added by JMEENA for bug#7310836
890 IF tr_jv.count > 0    /*added by JMEENA for bug #7310836*/ THEN
891   for jv_num in tr_jv.FIRST..tr_jv.LAST loop
892 
893     if tr_jv.exists(jv_num) = true then
894  v_line_count := v_line_count +1;/*Bug 5527885*/
895       ln_tmp_dr_amt := nvl(tr_jv(jv_num).entered_dr, 0);
896       ln_tmp_cr_amt := nvl(tr_jv(jv_num).entered_cr, 0);
897 
898       ln_cum_dr_amt := ln_cum_dr_amt + ln_tmp_dr_amt;
899       ln_cum_cr_amt := ln_cum_cr_amt + ln_tmp_cr_amt;
900 
901       ln_tmp_dr_amt := abs(ln_tmp_dr_amt);
902       ln_tmp_cr_amt := abs(ln_tmp_cr_amt);
903       if ln_max_jv_abs_amt < ln_tmp_dr_amt then
904         ln_jv_num_of_max_rec := jv_num;
905         ln_max_jv_abs_amt := ln_tmp_dr_amt;
906         ln_max_jv_amt_type := gv_debit;
907       elsif ln_max_jv_abs_amt < ln_tmp_cr_amt then
908         ln_jv_num_of_max_rec := jv_num;
909         ln_max_jv_abs_amt := ln_tmp_cr_amt;
910         ln_max_jv_amt_type := gv_credit;
911       end if;
912 
913     end if;
914 
915   end loop;
916   ln_diff_amt_between_dr_cr := ln_cum_dr_amt - ln_cum_cr_amt;
917   /*Bug 5527885*/
918     v_rounding_diff_to := (1/(2*(power(10,gn_currency_precision)))) * v_line_count;
919   v_rounding_diff_from := (-1) * v_rounding_diff_to;
920 
921 
922   p_codepath := jai_general_pkg.plot_codepath(10.4, p_codepath); /* 11 */
923   if p_debug = 'Y' then
924     Fnd_File.put_line(Fnd_File.LOG,
925       'For Rounding- CumDr:'||ln_cum_dr_amt||', CumCr:'||ln_cum_cr_amt||', ProbRec:'||ln_jv_num_of_max_rec
926       ||', v_rounding_diff_from:'||v_rounding_diff_from||', v_rounding_diff_to:'||v_rounding_diff_to
927       );
928   end if;
929   /* rounding logic starts */
930 
931 --  if ln_diff_amt_between_dr_cr <> 0 then
932  if (ln_diff_amt_between_dr_cr >= v_rounding_diff_from)
933 	and  (ln_diff_amt_between_dr_cr <= v_rounding_diff_to)  /* Added for Bug#5527885 */
934 then
935     p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11 */
936     if ln_max_jv_amt_type = gv_debit then
937       tr_jv(ln_jv_num_of_max_rec).entered_dr :=
938             tr_jv(ln_jv_num_of_max_rec).entered_dr - ln_diff_amt_between_dr_cr;
939     else /* means credit */
940       tr_jv(ln_jv_num_of_max_rec).entered_cr :=
941             tr_jv(ln_jv_num_of_max_rec).entered_cr + ln_diff_amt_between_dr_cr;
942     end if;
943   end if;
944 
945   /*
946   ptr_jv(2).line_num           := 2;
947   ptr_jv(2).acct_type          := lv_acct_type;
948   ptr_jv(2).acct_nature        := lv_acct_nature;
949   ptr_jv(2).source_name        := lv_source_name;
950   ptr_jv(2).category_name      := lv_category_name;
951   ptr_jv(2).ccid               := p_ap_accrual_account;
952   ptr_jv(2).entered_dr         := round(ln_debit, gn_currency_precision);
953   ptr_jv(2).entered_cr         := round(ln_credit, gn_currency_precision);
954   ptr_jv(2).currency_code      := ja_in_receipt_transactions_pkg.gv_func_curr;
955   ptr_jv(2).accounting_date    := p_transaction_date;
956   ptr_jv(2).reference_10       := lv_reference_10;
957   ptr_jv(2).reference_23       := lv_reference_23;
958   ptr_jv(2).reference_24       := lv_reference_24;
959   ptr_jv(2).reference_25       := lv_reference_25;
960   ptr_jv(2).reference_26       := lv_reference_26;
961   ptr_jv(2).destination        := 'G';
962   -- ptr_jv(2).reference_name     := ;
963   ptr_jv(2).reference_id       := p_transaction_id;
964   ptr_jv(2).non_rnd_entered_dr := ln_debit;
965   ptr_jv(2).non_rnd_entered_cr := ln_credit;
966   ptr_jv(2).account_name       := gv_ap_accrual;
967   ptr_jv(2).summary_jv_flag    := 'Y';
968   */
969 
970   if p_debug = 'Y' then
971     Fnd_File.put_line(Fnd_File.LOG, 'Account Name                   CCID                        Dr.                  Cr.          Non Rnd Dr.          Non Rnd Cr.'  );
972     Fnd_File.put_line(Fnd_File.LOG, '------------------------------ ---------- -------------------- -------------------- -------------------- --------------------'  );
973   end if;
974 
975   /* Code to Post Journals */
976   for jv_num in tr_jv.FIRST..tr_jv.LAST loop
977 
978     if tr_jv.exists(jv_num) = true then
979 
980       p_codepath := jai_general_pkg.plot_codepath('12.'||tr_jv(jv_num).line_num, p_codepath); /* 10 */
981       if p_debug = 'Y' then
982         Fnd_File.put_line(Fnd_File.LOG,
983               rpad(tr_jv(jv_num).account_name,30, ' ')
984               ||' '||rpad(tr_jv(jv_num).ccid,10, ' ')
985               ||' '||lpad(nvl(tr_jv(jv_num).entered_dr,0),20, ' ')
986               ||' '||lpad(nvl(tr_jv(jv_num).entered_cr,0),20, ' ')
987               ||' '||lpad(round(nvl(tr_jv(jv_num).non_rnd_entered_dr,0),8),20, ' ')
988               ||' '||lpad(round(nvl(tr_jv(jv_num).non_rnd_entered_cr,0),8),20, ' ')
989         );
990       end if;
991       IF nvl(tr_jv(jv_num).entered_dr,0) <> 0 OR nvl(tr_jv(jv_num).entered_cr,0) <> 0 THEN/*Bug 5527885*/
992       jai_rcv_accounting_pkg.process_transaction(
993         p_transaction_id            =>    p_transaction_id,
994         p_acct_type                 =>    tr_jv(jv_num).acct_type      ,
995         p_acct_nature               =>    tr_jv(jv_num).acct_nature    ,
996         p_source_name               =>    tr_jv(jv_num).source_name    ,
997         p_category_name             =>    tr_jv(jv_num).category_name  ,
998         p_code_combination_id       =>    tr_jv(jv_num).ccid           ,
999         p_entered_dr                =>    tr_jv(jv_num).entered_dr     ,
1000         p_entered_cr                =>    tr_jv(jv_num).entered_cr     ,
1001         p_currency_code             =>    tr_jv(jv_num).currency_code  ,
1002         p_accounting_date           =>    tr_jv(jv_num).accounting_date,
1003         p_reference_10              =>    tr_jv(jv_num).reference_10   ,
1004         p_reference_23              =>    tr_jv(jv_num).reference_23   ,
1005         p_reference_24              =>    tr_jv(jv_num).reference_24   ,
1006         p_reference_25              =>    tr_jv(jv_num).reference_25   ,
1007         p_reference_26              =>    tr_jv(jv_num).reference_26   ,
1008         p_destination               =>    tr_jv(jv_num).destination    ,
1009         p_simulate_flag             =>    p_simulation,
1010         p_codepath                  =>    p_codepath,
1011         p_process_status            =>    p_process_flag,
1012         p_process_message           =>    P_process_message
1013       );
1014      END IF; /*bug#5527885 */
1015       if p_process_flag <> 'Y' then
1016         goto exit_from_procedure;
1017       end if;
1018 
1019     end if;
1020 
1021   end loop;
1022   /* END OF 5527885 */
1023  END IF; --End of bug#7310836, added by JMEENA
1024  Fnd_File.put_line(Fnd_File.LOG, 'After tr_jv loop. Not processed for Accounting as pl/sql table count is Zero'); --Added by JMEENA for bug#7310836
1025 
1026   -- All the Processing Went Through fine. So Setting the process_flag to 'Y'
1027   p_process_flag := 'Y';
1028 
1029   << exit_from_procedure >>
1030   p_codepath := jai_general_pkg.plot_codepath(99, p_codepath, null, 'END'); /* 11 *//*Bug 5527885*/
1031 
1032   if p_debug = 'Y' then
1033 --    Fnd_File.put_line(Fnd_File.LOG, ' Code Path :' || p_codepath );/*Bug 5527885*/
1034     Fnd_File.put_line(Fnd_File.LOG, '**** End of procedure jai_rcv_rcv_rtv_pkg.process_transaction ****');
1035   end if;
1036 
1037   return;
1038 
1039 exception
1040   when others then
1041     p_process_flag    := 'E';
1042     p_process_message := 'RECEIVE_RTV_PKG.process_transaction:' || sqlerrm;
1043     FND_FILE.put_line(FND_FILE.log, 'Error in '||p_process_message);
1044     Fnd_File.put_line(Fnd_File.LOG, 'Code Path->' || p_codepath );
1045     return;
1046 
1047 end process_transaction;
1048 /****************************** End process_transaction  ****************************/
1049 
1050 /******************************** Start get_accounts  *******************************/
1051   procedure get_accounts
1052   (
1053     p_organization_id                         in                  number,
1054     p_location_id                             in                  number,
1055     p_receipt_source_code                     in                  varchar2,
1056     p_from_organization_id                    in                  number,
1057     p_to_organization_id                      in                  number,
1058     p_po_distribution_id                      in                  number,
1059     p_po_line_location_id                     in                  number,
1060     p_debug                                   in                  varchar2,  -- default 'N', File.Sql.35
1061     p_boe_account_id                          out                 nocopy number,
1062     p_rtv_expense_account_id                  out     nocopy      number,
1063     p_excise_expense_account                  out     nocopy      number,
1064     p_excise_rcvble_account                   out     nocopy      number,
1065     p_receiving_account_id                    out     nocopy      number,
1066     p_ap_accrual_account                      out     nocopy      number,
1067     p_po_accrual_account_id                   out     nocopy      number,
1068     p_interorg_payables_account               out     nocopy      number,
1069     p_intransit_inv_account                   out     nocopy      number,
1070     p_interorg_receivables_account            out     nocopy      number,
1071     p_intransit_type                          out     nocopy      number,
1072     p_fob_point                               out     nocopy      number,
1073     p_trading_to_trading_iso                  out     nocopy      varchar2, /* Bug#4171469 */
1074     p_process_flag                            out     nocopy      varchar2,
1075     p_process_message                         out     nocopy      varchar2,
1076     p_codepath                                in out  nocopy      varchar2
1077   )is
1078 
1079   cursor    c_ja_in_hr_organization_units
1080             (cp_organization_id number, cp_location_id   number) is
1081     select  boe_account_id,
1082             excise_expense_account,
1083             excise_rcvble_account,
1084             rtv_expense_account_id,
1085             nvl(trading, 'N') receving_org_trading,  /* Bug#4171469 */
1086             NVL(manufacturing, 'N') receiving_org_manufacturing --Added by Ramananda for Bug #4516577
1087     from    JAI_CMN_INVENTORY_ORGS
1088     where   organization_id = cp_organization_id
1089     and     location_id = cp_location_id;
1090 
1091   cursor    c_rcv_parameters(cp_organization_id number) is
1092     select  receiving_account_id
1093     from    rcv_parameters
1094     Where   organization_id = cp_organization_id;
1095 
1096   cursor    c_mtl_parameters(cp_organization_id number) is
1097     select  ap_accrual_account
1098     from    mtl_parameters
1099     where   organization_id = cp_organization_id;
1100 
1101   cursor    c_po_distributions_all(cp_po_distribution_id number) is
1102     select  accrual_account_id
1103     from    po_distributions_all
1104     where   po_distribution_id = cp_po_distribution_id;
1105 
1106   cursor    c_po_distributions_all_1(cp_po_line_location_id number) is
1107     select  accrual_account_id
1108     from    po_distributions_all
1109     where   po_distribution_id =
1110             (
1111               select max(po_distribution_id)
1112               from   po_distributions_all
1113               where  line_location_id = cp_po_line_location_id
1114             );
1115 
1116   cursor    c_mtl_interorg_parameters
1117             (cp_from_organization_id number, cp_to_organization_id number) is
1118     select  interorg_payables_account,
1119             intransit_inv_account,
1120             interorg_receivables_account,
1121             intransit_type,
1122             fob_point
1123     from    mtl_interorg_parameters
1124     where   from_organization_id = cp_from_organization_id
1125     and     to_organization_id = cp_to_organization_id;
1126 
1127   cursor c_iso_from_org_type(cp_organization_id number) is
1128     select   nvl(trading, 'N') source_org_trading  /* Bug#4171469 */
1129     from    JAI_CMN_INVENTORY_ORGS
1130     where   organization_id = cp_organization_id;
1131 
1132 
1133 
1134   r_ja_in_hr_organization_units       c_ja_in_hr_organization_units%rowtype;
1135   r_ja_in_hr_organization_units1      c_ja_in_hr_organization_units%rowtype;
1136   r_mtl_parameters                    c_mtl_parameters%rowtype;
1137   r_po_distributions_all              c_po_distributions_all%rowtype;
1138   r_po_distributions_all_1            c_po_distributions_all_1%rowtype;
1139   r_rcv_parameters                    c_rcv_parameters%rowtype;
1140   r_mtl_interorg_parameters           c_mtl_interorg_parameters%rowtype;
1141   r_iso_from_org_type                 c_iso_from_org_type%rowtype; /* Bug#4171469 */
1142 
1143 begin
1144 
1145   if p_debug = 'Y' then
1146     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.get_accounts **');
1147   end if;
1148 
1149   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.get_accounts', 'START'); /* 1 */
1150   open  c_ja_in_hr_organization_units(p_organization_id,p_location_id);
1151   fetch c_ja_in_hr_organization_units into r_ja_in_hr_organization_units;
1152   close c_ja_in_hr_organization_units;
1153 
1154 
1155   p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
1156   open  c_ja_in_hr_organization_units(p_organization_id, 0);
1157   fetch c_ja_in_hr_organization_units into r_ja_in_hr_organization_units1;
1158   close c_ja_in_hr_organization_units;
1159 
1160   /** check value for all accounts for the given location ..
1161       if null get value for null location  **/
1162 
1163   /** BOE account **/
1164   p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
1165   if  r_ja_in_hr_organization_units.boe_account_id is not null then
1166     p_boe_account_id := r_ja_in_hr_organization_units.boe_account_id ;
1167   elsif r_ja_in_hr_organization_units1.boe_account_id is not null then
1168     p_boe_account_id  := r_ja_in_hr_organization_units1.boe_account_id ;
1169   end if;
1170 
1171   /** rtv_expense_account_id **/
1172   p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
1173   if r_ja_in_hr_organization_units.rtv_expense_account_id is not null then
1174     p_rtv_expense_account_id := r_ja_in_hr_organization_units.rtv_expense_account_id ;
1175   elsif r_ja_in_hr_organization_units1.rtv_expense_account_id is not null then
1176     p_rtv_expense_account_id := r_ja_in_hr_organization_units1.rtv_expense_account_id ;
1177   end if;
1178 
1179   /** excise_expense_account **/
1180   p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
1181   if r_ja_in_hr_organization_units.excise_expense_account is not null then
1182     p_excise_expense_account := r_ja_in_hr_organization_units.excise_expense_account ;
1183   elsif r_ja_in_hr_organization_units1.excise_expense_account is not null then
1184     p_excise_expense_account := r_ja_in_hr_organization_units1.excise_expense_account ;
1185   end if;
1186 
1187   /** excise_rcvble_account **/
1188   p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
1189   if r_ja_in_hr_organization_units.excise_rcvble_account is not null then
1190     p_excise_rcvble_account := r_ja_in_hr_organization_units.excise_rcvble_account ;
1191   elsif r_ja_in_hr_organization_units1.excise_expense_account is not null then
1192     p_excise_rcvble_account := r_ja_in_hr_organization_units1.excise_rcvble_account ;
1193   end if;
1194 
1195   p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
1196   open c_rcv_parameters(p_organization_id);
1197   fetch c_rcv_parameters into r_rcv_parameters;
1198   close c_rcv_parameters;
1199 
1200   p_receiving_account_id := r_rcv_parameters.receiving_account_id;
1201 
1202   p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
1203   open c_mtl_parameters(p_organization_id);
1204   fetch c_mtl_parameters into r_mtl_parameters;
1205   close c_mtl_parameters;
1206 
1207   p_ap_accrual_account := r_mtl_parameters.ap_accrual_account;
1208 
1209 
1210   p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9 */
1211   if p_po_distribution_id is not null then
1212 
1213     p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10 */
1214     open  c_po_distributions_all(p_po_distribution_id);
1215     fetch c_po_distributions_all into r_po_distributions_all;
1216     close c_po_distributions_all;
1217 
1218     p_po_accrual_account_id := r_po_distributions_all.accrual_account_id;
1219 
1220   end if;
1221 
1222 
1223   if  r_po_distributions_all.accrual_account_id is null and
1224       p_po_line_location_id is not null then
1225 
1226       p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11 */
1227       open c_po_distributions_all_1(p_po_line_location_id);
1228       fetch c_po_distributions_all_1 into r_po_distributions_all_1;
1229       close c_po_distributions_all_1;
1230 
1231       p_po_accrual_account_id := r_po_distributions_all_1.accrual_account_id;
1232 
1233       p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12 */
1234 
1235   end if;
1236 
1237 
1238   p_codepath := jai_general_pkg.plot_codepath(13, p_codepath); /* 13 */
1239   p_trading_to_trading_iso := 'N';
1240   if p_receipt_source_code in('INTERNAL ORDER','INVENTORY')then  -- bug 6030615
1241 
1242     p_codepath := jai_general_pkg.plot_codepath(14, p_codepath); /* 14 */
1243     open  c_mtl_interorg_parameters(p_from_organization_id, p_to_organization_id);
1244     fetch c_mtl_interorg_parameters into r_mtl_interorg_parameters;
1245     close c_mtl_interorg_parameters;
1246 
1247     /* Bug#4171469 */
1248     open c_iso_from_org_type(p_from_organization_id);
1249     fetch c_iso_from_org_type into r_iso_from_org_type;
1250     close c_iso_from_org_type;
1251 
1252     if  r_iso_from_org_type.source_org_trading = 'Y' and
1253         ( r_ja_in_hr_organization_units.receving_org_trading = 'Y'
1254           OR
1255           r_ja_in_hr_organization_units1.receving_org_trading = 'Y'/*Changes from nprashar for bug 6321337
1256          Commented the other 2 OR conditions as forward as per Forward porting 11i bug 6200218
1257           OR                                                           Added the OR Condition by Ramananda for Bug #4516577
1258           r_ja_in_hr_organization_units.receiving_org_manufacturing = 'Y'
1259           OR                                                           Added the OR Condition by Ramananda for Bug #4516577
1260           r_ja_in_hr_organization_units1.receiving_org_manufacturing = 'Y' Commenting Ends here */
1261         )
1262 
1263     then
1264       p_codepath := jai_general_pkg.plot_codepath(14.1, p_codepath); /* 14.1 */
1265       p_trading_to_trading_iso := 'Y';
1266 
1267     end if;
1268 
1269     p_codepath := jai_general_pkg.plot_codepath(15, p_codepath); /* 15 */
1270     p_interorg_payables_account     := r_mtl_interorg_parameters.interorg_payables_account;
1271     p_intransit_inv_account         := r_mtl_interorg_parameters.intransit_inv_account;
1272     p_interorg_receivables_account  := r_mtl_interorg_parameters.interorg_receivables_account;
1273     p_intransit_type                := r_mtl_interorg_parameters.intransit_type;
1274     p_fob_point                     := r_mtl_interorg_parameters.fob_point;
1275 
1276   end if; /*p_receipt_source_code = 'INTERNAL ORDER'*/
1277 
1278 
1279   << exit_from_procedure >>
1280   p_codepath := jai_general_pkg.plot_codepath(16, p_codepath, null, 'END'); /* 16 */
1281   if p_process_flag is null then
1282     p_process_flag    := 'Y';
1283   end if;
1284 
1285   if p_debug = 'Y' then
1286 --    Fnd_File.put_line(Fnd_File.LOG, '  Code Path :' || p_codepath );
1287     Fnd_File.put_line(Fnd_File.LOG, '  ** End of procedure jai_rcv_rcv_rtv_pkg.get_accounts **  ');
1288   end if;
1289 
1290 
1291   return;
1292 
1293 exception
1294   when others then
1295     p_process_flag    := 'E';
1296     p_process_message := 'RECEIVE_RTV_PKG.get_accounts:' || sqlerrm;
1297     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
1298     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
1299     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END'); /* 24 */
1300     return;
1301 
1302 end get_accounts;
1303 
1304 /******************************** End get_accounts  *******************************/
1305 
1306 
1307 
1308 /******************************** Start get_tax_breakup *****************************/
1309 procedure get_tax_breakup
1310   (
1311     p_transaction_id                          in                  number,
1312     p_shipment_line_id                        in                  number,
1313     p_currency_conversion_rate                in                  number,
1314     p_po_vendor_id                            in                  number,
1315     p_debug                                   in                  varchar2,  -- default 'N', File.Sql.35
1316     p_all_taxes                               out     nocopy      number,
1317     p_tds_taxes                               out     nocopy      number,
1318     p_modvat_recovery_taxes                   out     nocopy      number,
1319     p_cvd_taxes                               out     nocopy      number,
1320     p_add_cvd_taxes                           out     nocopy      number, /*5228046 Additional cvd Enhancement*/
1321     p_customs_taxes                           out     nocopy      number,
1322     p_third_party_taxes                       out     nocopy      number,
1323     p_excise_tax                              out     nocopy      number,
1324     p_service_recoverable                     out     nocopy      number, /* service */
1325     p_service_not_recoverable                 out     nocopy      number, /* service */
1326     /* following two params added by Vijay Shankar for Bug#4250236(4245089). VAT Impl. */
1327     p_vat_recoverable                         out     nocopy      number,
1328     p_vat_not_recoverable                     out     nocopy      number,
1329     p_excise_edu_cess                         out     nocopy      number, /* educational cess */
1330     p_excise_sh_edu_cess                      out     nocopy      number,/*Bug 5989740 bduvarag*/
1331     p_cvd_edu_cess                            out     nocopy      number, /* educational cess */
1332     p_cvd_sh_edu_cess                         out     nocopy      number,/*Bug 5989740 bduvarag*/
1333     p_customs_edu_cess                        out     nocopy      number, /* educational cess */
1334     p_customs_sh_edu_cess                     out     nocopy      number,/*Bug 5989740 bduvarag*/
1335     --Added by zhiwei for BOE ER bug 11684111  begin
1336     -------------------------------------------------------------------
1337     p_boe_other1                              out     nocopy      number,
1338     p_boe_other2                              out     nocopy      number,
1339     p_boe_other3                              out     nocopy      number,
1340     p_boe_other4                              out     nocopy      number,
1341     p_boe_other5                              out     nocopy      number,
1342     p_boe_surcharge_duty                      out     nocopy      number,
1343     p_boe_add_customs                         out     nocopy      number,
1344     --------------------------------------------------------------------
1345     --Added by zhiwei for BOE ER bug 11684111  end
1346     p_process_flag                            out     nocopy      varchar2,
1347     p_process_message                         out     nocopy      varchar2,
1348     p_codepath                                in      out nocopy  varchar2
1349     ,
1350     --POT 11936596
1351     p_inclu_service_recoverable               out     nocopy      number,
1352     p_inclu_vat_recoverable                   out     nocopy      number /*Bug 14185068*/
1353   )
1354   is
1355 
1356   cursor c_ja_in_receipt_tax_lines(cp_shipment_line_id  number) is
1357     select  jrtl.tax_id tax_id,
1358             jrtl.tax_type tax_type,
1359             nvl(jrtl.tax_amount,0) tax_amount,
1360             jrtl.currency currency,
1361             nvl(jrtl.vendor_id, 0) vendor_id,
1362             nvl(jtc.rounding_factor, 0) rounding_factor,
1363             nvl(jtc.mod_cr_percentage, 0) recoverable,  /* Service */
1364             nvl(jrtl.modvat_flag, 'N') modvatable /* Service */
1365             , nvl(tax_types.regime_code, 'XXXX') regime_code    /* Vijay Shankar for Bug#4250236(4245089). VAT Impl. */
1366             ,jtc.vat_flag
1367              ,jtc.adhoc_flag   /*10167393*/
1368              ,jtc.inclusive_tax_flag --POT 11936596
1369     from    JAI_RCV_LINE_TAXES jrtl,
1370             JAI_CMN_TAXES_ALL jtc
1371             , jai_regime_tax_types_v tax_types     /*Vijay Shankar for Bug#4250236(4245089). VAT Impl. */
1372     where   jrtl.shipment_line_id = cp_shipment_line_id
1373       AND   jrtl.tax_id = jtc.tax_id
1374       AND   jtc.tax_type = tax_types.tax_type(+)
1375       AND   ( (NVL(jtc.inclusive_tax_flag,'N')='N'  AND NVL(jtc.reverse_charge_flag,'N')='N') -- Qiong for reverse charge bug#16001407
1376              --added the or condition for POT 11936596
1377               OR
1378               (NVL(jtc.inclusive_tax_flag,'N')='Y'
1379               and jtc.tax_type in ('Service','SERVICE_EDUCATION_CESS','SERVICE_SH_EDU_CESS','VALUE ADDED TAX', /*Bug 14185068*/
1380 			  jai_constants.tax_type_excise, jai_constants.tax_type_exc_additional, jai_constants.tax_type_exc_other,
1381 			  jai_constants.tax_type_exc_edu_cess, jai_constants.tax_type_sh_exc_edu_cess))
1382             );  /*Added excise taxes by mmurtuza for bug 16101545. Also changed tax_types.tax_type to jtc.tax_type*/
1383 
1384   cursor c_jai_regimes(p_regime_code varchar2) is
1385     select regime_id
1386     from   JAI_RGM_DEFINITIONS
1387     where  regime_code = p_regime_code;
1388 
1389   cursor c_is_tax_type_in_regime(cp_regime_id  number, cp_tax_type varchar2) is
1390     select attribute_code regime_tax_type
1391     from   JAI_RGM_REGISTRATIONS
1392     where  regime_id = cp_regime_id
1393     and    registration_type = jai_constants.regn_type_tax_types
1394     and    attribute_code = cp_tax_type;
1395 
1396   /*
1397   r_jai_regimes_servce            c_jai_regimes%rowtype;
1398   r_jai_regimes_vat               c_jai_regimes%rowtype;
1399   r_is_tax_type_in_regime         c_is_tax_type_in_regime%rowtype;
1400   */
1401 
1402   ln_tax_apportion_factor         number;
1403   ln_tax_amount                   number;
1404 
1405   --start addiitons by vkaranam for bug#10167393
1406   cursor c_ja_in_rcv_transactions(cp_transaction_id in number) is
1407     select  organization_id,
1408             location_id,
1409             transaction_type,
1410             parent_transaction_type,
1411             currency_conversion_rate,
1412             transaction_date,
1413             parent_transaction_id,
1414             inventory_item_id,
1415             inv_item_flag /* Service */
1416     from    JAI_RCV_TRANSACTIONS
1417     where   transaction_id = cp_transaction_id;
1418 
1419      r_ja_in_rcv_transactions            c_ja_in_rcv_transactions%rowtype;
1420 
1421 --end  addiitons by vkaranam for bug#10167393
1422 
1423 
1424 begin
1425 
1426   if p_debug = 'Y' then
1427     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.get_tax_breakup **');
1428   end if;
1429 
1430 
1431   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.get_tax_breakup', 'START'); /* 1 */
1432 
1433   ln_tax_apportion_factor   :=
1434   jai_rcv_trx_processing_pkg.get_apportion_factor(p_transaction_id);
1435 --start additions by vkaranam for bug#10167393
1436    open c_ja_in_rcv_transactions(p_transaction_id);
1437   fetch c_ja_in_rcv_transactions into r_ja_in_rcv_transactions;
1438   close c_ja_in_rcv_transactions;
1439   --end additions by vkaranam for bug#10167393
1440 
1441   p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
1442   p_all_taxes               := 0;
1443   p_tds_taxes               := 0;
1444   p_modvat_recovery_taxes   := 0;
1445   p_cvd_taxes               := 0;
1446   p_add_cvd_taxes           := 0; /*5228046 Additional cvd Enhancement*/
1447   p_customs_taxes           := 0;
1448   p_third_party_taxes       := 0;
1449   p_excise_tax              := 0;
1450   p_service_recoverable     := 0;
1451   p_service_not_recoverable := 0;
1452   p_vat_recoverable         := 0;
1453   p_vat_not_recoverable     := 0;
1454   p_excise_edu_cess         := 0;
1455   p_cvd_edu_cess            := 0;
1456   p_customs_edu_cess        := 0;
1457   p_excise_sh_edu_cess   		:= 0;	/*Bug 5989740 bduvarag*/
1458   p_cvd_sh_edu_cess      		:= 0;	/*Bug 5989740 bduvarag*/
1459   p_customs_sh_edu_cess  		:= 0;	/*Bug 5989740 bduvarag*/
1460    p_inclu_service_recoverable := 0; --pot 11936596
1461   p_inclu_vat_recoverable   := 0; /*Bug 14185068*/
1462 
1463   --Added by zhiwei for BOE ER bug 11684111  begin
1464   -------------------------------------------------
1465   p_boe_other1 := 0;
1466   p_boe_other2 := 0;
1467   p_boe_other3 := 0;
1468   p_boe_other4 := 0;
1469   p_boe_other5 := 0;
1470   p_boe_surcharge_duty := 0;
1471   p_boe_add_customs := 0;
1472   -------------------------------------------------
1473   --Added by zhiwei for BOE ER bug 11684111  end
1474   /*
1475   open  c_jai_regimes(jai_constants.service_regime);
1476   fetch c_jai_regimes into r_jai_regimes_servce;
1477   close c_jai_regimes;
1478 
1479   open  c_jai_regimes(jai_constants.vat_regime);
1480   fetch c_jai_regimes into r_jai_regimes_vat;
1481   close c_jai_regimes;
1482   */
1483 
1484   p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
1485 
1486   for cur_rec in c_ja_in_receipt_tax_lines(p_shipment_line_id) loop
1487 
1488     p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
1489  --start additions for POT 11936596
1490       if cur_rec.inclusive_tax_flag='Y' and cur_rec.tax_type not in (
1491 			  jai_constants.tax_type_excise, jai_constants.tax_type_exc_additional, jai_constants.tax_type_exc_other,
1492 			  jai_constants.tax_type_exc_edu_cess, jai_constants.tax_type_sh_exc_edu_cess) /*Added not in condition by mmurtuza for bug 16101545*/
1493        then
1494         ln_tax_amount :=  0;
1495       else
1496         ln_tax_amount :=  cur_rec.tax_amount;
1497       end if;
1498       -- end  additions for POT 11936596
1499 
1500     p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
1501    --start additions by vkaranam for bug#10167393
1502     if nvl(cur_rec.adhoc_flag,'N')='Y' and nvl(cur_rec.vat_flag,'N')<>'Q' and  cur_rec.tax_type  in ('Freight','Insurance','Octrai','Other','PURCHASE TAX','ENTRY TAX') and r_ja_in_rcv_transactions.transaction_type='CORRECT'
1503     then
1504         ln_tax_amount  := 0;
1505     else
1506         ln_tax_amount  := ln_tax_amount; -- * ln_tax_apportion_factor; --Commented for bug #13494816
1507     end if;
1508   --end additions by vkaranam for bug#12316065
1509 
1510     /* apportionment for uom and quantity change wrt the parent RECEIVE
1511       line for which taxes exist */
1512     p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
1513     if  nvl(cur_rec.currency, jai_rcv_trx_processing_pkg.gv_func_curr) <>
1514         jai_rcv_trx_processing_pkg.gv_func_curr
1515     then
1516       /* Tax not in functional currency, need to convert*/
1517       ln_tax_amount := ln_tax_amount * p_currency_conversion_rate;
1518     end if;
1519 
1520     /*bug 7640943 (FP for bug 7588482) - need to use rounded amounts for excise type of taxes while accounting
1521      *because amounts would be rounded for excise invoice (cenvat reversal)*/
1522       IF cur_rec.tax_type IN (jai_constants.tax_type_excise,jai_constants.tax_type_exc_additional,jai_constants.tax_type_exc_other,jai_constants.tax_type_exc_edu_cess,jai_constants.tax_type_sh_exc_edu_cess)
1523        THEN
1524        ln_tax_amount := Round(ln_tax_amount,Nvl(cur_rec.rounding_factor,0));
1525       END IF;
1526     /*end bug 7640943*/
1527 
1528 	 ln_tax_amount  := ln_tax_amount * ln_tax_apportion_factor; --Added for bug #13494816
1529 
1530 
1531     /* ln_tax_amount := round(ln_tax_amount, cur_rec.rounding_factor); Vijay. Final Observation */
1532     p_all_taxes := p_all_taxes + ln_tax_amount;
1533 
1534     p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
1535 
1536     if  cur_rec.tax_type = jai_constants.tax_type_tds then /* TDS*/
1537 
1538       p_codepath := jai_general_pkg.plot_codepath(7.1, p_codepath); /* 7.1 */
1539       p_tds_taxes := p_tds_taxes + ln_tax_amount;
1540 
1541 
1542     elsif   cur_rec.tax_type = jai_constants.tax_type_modvat_recovery then /* MODVAT RECOVERY*/
1543 
1544       p_codepath := jai_general_pkg.plot_codepath(7.2, p_codepath); /* 7.2 */
1545       p_modvat_recovery_taxes := p_modvat_recovery_taxes + ln_tax_amount;
1546 
1547     elsif   cur_rec.tax_type = jai_constants.tax_type_customs then /* CUSTOMS */
1548 
1549       p_codepath := jai_general_pkg.plot_codepath(7.3, p_codepath); /* 7.3 */
1550       p_customs_taxes := p_customs_taxes + ln_tax_amount;
1551 
1552     elsif   cur_rec.tax_type = jai_constants.tax_type_cvd then  /* CVD */
1553 
1554       p_codepath := jai_general_pkg.plot_codepath(7.4, p_codepath); /* 7.4 */
1555       p_cvd_taxes := p_cvd_taxes + ln_tax_amount;
1556 
1557     elsif   cur_rec.tax_type = jai_constants.tax_type_add_cvd then  /* ADDITIONAL CVD - Enhancement 5228046 */
1558 
1559       p_codepath := jai_general_pkg.plot_codepath(7.4, p_codepath); /* 7.4 */
1560       p_add_cvd_taxes := p_add_cvd_taxes + ln_tax_amount;
1561 
1562     elsif   cur_rec.tax_type = jai_constants.tax_type_exc_edu_cess  then /* Educational Cess Excise */
1563 
1564       p_codepath := jai_general_pkg.plot_codepath(7.5, p_codepath); /* 7.5 */
1565       p_excise_edu_cess :=  p_excise_edu_cess + ln_tax_amount;
1566 /*Bug 5989740 bduvarag start*/
1567 	  elsif   cur_rec.tax_type = jai_constants.tax_type_sh_exc_edu_cess  then /* Higher Secondary Educational Cess Excise */
1568 
1569 		  p_codepath := jai_general_pkg.plot_codepath(7.51, p_codepath); /* 7.51 */
1570 		  p_excise_sh_edu_cess :=  p_excise_sh_edu_cess + ln_tax_amount;
1571 
1572 /*Bug 5989740 bduvarag end*/
1573     elsif   cur_rec.tax_type = jai_constants.tax_type_cvd_edu_cess  then /* Educational Cess CVD */
1574 
1575       p_codepath := jai_general_pkg.plot_codepath(7.6, p_codepath); /* 7.6 */
1576       p_cvd_edu_cess :=  p_cvd_edu_cess + ln_tax_amount;
1577 /*Bug 5989740 bduvarag start*/
1578 	  elsif   cur_rec.tax_type = jai_constants.tax_type_sh_cvd_edu_cess  then /* Higher Secondary Educational Cess CVD */
1579 
1580 		  p_codepath := jai_general_pkg.plot_codepath(7.61, p_codepath); /* 7.61 */
1581 		  p_cvd_sh_edu_cess :=  p_cvd_sh_edu_cess + ln_tax_amount;
1582 
1583 /*Bug 5989740 bduvarag end*/
1584     elsif   cur_rec.tax_type = jai_constants.tax_type_customs_edu_cess  then /* Educational Cess CVD */
1585 
1586      p_codepath := jai_general_pkg.plot_codepath(7.7, p_codepath); /* 7.7 */
1587      p_customs_edu_cess :=  p_customs_edu_cess + ln_tax_amount;
1588 /*Bug 5989740 bduvarag start*/
1589     elsif   cur_rec.tax_type = jai_constants.tax_type_sh_customs_edu_cess  then /* Higher Secondary Educational Cess CVD */
1590 
1591 		 p_codepath := jai_general_pkg.plot_codepath(7.71, p_codepath); /* 7.71 */
1592 		 p_customs_sh_edu_cess :=  p_customs_sh_edu_cess + ln_tax_amount;
1593 /*Bug 5989740 bduvarag end*/
1594 
1595 
1596     --Added by zhiwei for BOE ER bug 11684111  begin
1597     ---------------------------------------------------------------------------------
1598 
1599     elsif  cur_rec.tax_type = jai_constants.tax_type_boe_other1 then
1600 
1601      p_codepath := jai_general_pkg.plot_codepath(7.72, p_codepath); /* 7.72 */
1602 		 p_boe_other1 :=  p_boe_other1 + ln_tax_amount;
1603 
1604     elsif  cur_rec.tax_type = jai_constants.tax_type_boe_other2 then
1605 
1606      p_codepath := jai_general_pkg.plot_codepath(7.73, p_codepath); /* 7.73 */
1607 		 p_boe_other2 :=  p_boe_other2 + ln_tax_amount;
1608 
1609     elsif  cur_rec.tax_type = jai_constants.tax_type_boe_other3 then
1610 
1611      p_codepath := jai_general_pkg.plot_codepath(7.74, p_codepath); /* 7.74 */
1612 		 p_boe_other3 :=  p_boe_other3 + ln_tax_amount;
1613 
1614     elsif  cur_rec.tax_type = jai_constants.tax_type_boe_other4 then
1615 
1616      p_codepath := jai_general_pkg.plot_codepath(7.75, p_codepath); /* 7.75 */
1617 		 p_boe_other4 :=  p_boe_other4 + ln_tax_amount;
1618 
1619     elsif  cur_rec.tax_type = jai_constants.tax_type_boe_other5 then
1620 
1621      p_codepath := jai_general_pkg.plot_codepath(7.76, p_codepath); /* 7.76 */
1622 		 p_boe_other5 :=  p_boe_other5 + ln_tax_amount;
1623 
1624     elsif  cur_rec.tax_type = jai_constants.tax_type_boe_surcharge_duty then
1625 
1626      p_codepath := jai_general_pkg.plot_codepath(7.77, p_codepath); /* 7.77 */
1627 		 p_boe_surcharge_duty :=  p_boe_surcharge_duty + ln_tax_amount;
1628 
1629     elsif  cur_rec.tax_type = jai_constants.tax_type_boe_add_customs then
1630 
1631      p_codepath := jai_general_pkg.plot_codepath(7.78, p_codepath); /* 7.78 */
1632 		 p_boe_add_customs :=  p_boe_add_customs + ln_tax_amount;
1633     ---------------------------------------------------------------------------------
1634     --Added by zhiwei for BOE ER bug 11684111  end
1635 
1636     elsif   cur_rec.tax_type in
1637             (
1638               jai_constants.tax_type_excise         , /* EXCISE */
1639               jai_constants.tax_type_exc_additional , /* EXCISE ADDITIONAL */
1640               jai_constants.tax_type_exc_other        /* EXCISE OTHERS */
1641             )
1642             then
1643 
1644      p_codepath := jai_general_pkg.plot_codepath(7.8, p_codepath); /* 7.8 */
1645      p_excise_tax := p_excise_tax + ln_tax_amount;
1646 
1647     else
1648 
1649       /* Check tax type by regime, Service and then VAT */
1650 
1651       p_codepath := jai_general_pkg.plot_codepath(7.9, p_codepath); /* 7.9 */
1652 
1653       /*
1654       r_is_tax_type_in_regime := null;
1655 
1656       open c_is_tax_type_in_regime(r_jai_regimes_servce.regime_id, cur_rec.tax_type);
1657       fetch c_is_tax_type_in_regime into r_is_tax_type_in_regime;
1658       close c_is_tax_type_in_regime;
1659 
1660       if   r_is_tax_type_in_regime.regime_tax_type is not null then*/
1661 
1662       /* Service type of Tax */
1663       if cur_rec.regime_code = jai_constants.service_regime then
1664         p_codepath := jai_general_pkg.plot_codepath(7.11, p_codepath); /* 7.11 */
1665 
1666         /*bug 8488470 - modified the if block.
1667           Issue - Unbalanced entries in GL for correct / RTV transactions.
1668           Cause - In case of recoverable VAT, the individual tax line is rounded, and the credit / debit
1669                   is done with the rounded amount for interim accounting. But the accrual accounting is
1670                   using the unrounded amount. This is because the tax amount is rounded only in case of
1671                   partially recoverable taxes here. Rounding should be applied for fully recoverable taxes
1672                   also. Moreover, the rounded amount should be considered for the total amount being stored
1673                   in p_all_taxes variable also.
1674                   Though issue was observed for VAT related transactions, same is possible with Service tax
1675                   also.*/
1676         if  ( cur_rec.modvatable = 'Y' ) then
1677           p_codepath := jai_general_pkg.plot_codepath(7.12, p_codepath); /* 7.12 */
1678           /*Bug 5527885 start*/
1679           p_service_recoverable := p_service_recoverable + Round(ln_tax_amount * cur_rec.recoverable/100, cur_rec.rounding_factor);
1680             --start additions for POT 11936596
1681           if cur_rec.inclusive_tax_flag='Y'
1682           then
1683           p_inclu_service_recoverable := p_inclu_service_recoverable + Round(cur_rec.tax_amount * cur_rec.recoverable/100, cur_rec.rounding_factor);
1684           end if;
1685           --end additions for POT 11936596
1686           p_service_not_recoverable := p_service_not_recoverable + (ln_tax_amount * (100-cur_rec.recoverable)/100);
1687           p_all_taxes := p_all_taxes - ln_tax_amount + Round(ln_tax_amount * cur_rec.recoverable/100, cur_rec.rounding_factor) + (ln_tax_amount * (100-cur_rec.recoverable)/100);
1688         else
1689           p_codepath := jai_general_pkg.plot_codepath(7.13, p_codepath); /* 7.13 */
1690           p_service_not_recoverable := p_service_not_recoverable + ln_tax_amount;
1691         end if;
1692 
1693 /*Bug 5527885 End*/
1694       else
1695 
1696         p_codepath := jai_general_pkg.plot_codepath(7.14, p_codepath); /* 7.14 */
1697 
1698         /*
1699         r_is_tax_type_in_regime := null;
1700         open c_is_tax_type_in_regime(r_jai_regimes_vat.regime_id, cur_rec.tax_type);
1701         fetch c_is_tax_type_in_regime into r_is_tax_type_in_regime;
1702         close c_is_tax_type_in_regime;
1703 
1704         if   r_is_tax_type_in_regime.regime_tax_type is not null then */
1705 
1706         /* VAT type of Tax */
1707         if cur_rec.regime_code = jai_constants.vat_regime then
1708           p_codepath := jai_general_pkg.plot_codepath(7.15, p_codepath); /* 7.15 */
1709 
1710         /*bug 8488470 - modified the if block.
1711           Issue - Unbalanced entries in GL for correct / RTV transactions.
1712           Cause - In case of recoverable VAT, the individual tax line is rounded, and the credit / debit
1713                   is done with the rounded amount for interim accounting. But the accrual accounting is
1714                   using the unrounded amount. This is because the tax amount is rounded only in case of
1715                   partially recoverable taxes here. Rounding should be applied for fully recoverable taxes
1716                   also. Moreover, the rounded amount should be considered for the total amount being stored
1717                   in p_all_taxes variable also..*/
1718           if  (cur_rec.modvatable = 'Y' ) then
1719             p_codepath := jai_general_pkg.plot_codepath(7.16, p_codepath); /* 7.16 */
1720             p_vat_recoverable := p_vat_recoverable + Round(ln_tax_amount * cur_rec.recoverable/100, cur_rec.rounding_factor);
1721             p_vat_not_recoverable := p_vat_not_recoverable + (ln_tax_amount * (100 - cur_rec.recoverable)/100);
1722             /*Bug 14185068 - VAT Inclusive Tax must also be accounted - Start*/
1723             /*VAT Interim Account is not set off to Receving Inventory Account*/
1724             if cur_rec.inclusive_tax_flag='Y'
1725             then
1726                 p_inclu_vat_recoverable := p_inclu_vat_recoverable + Round(cur_rec.tax_amount * cur_rec.recoverable/100, cur_rec.rounding_factor);
1727             end if;
1728             /*Bug 14185068 - Inclusive Tax must also be accounted - End*/
1729             p_all_taxes := p_all_taxes - ln_tax_amount + Round(ln_tax_amount * cur_rec.recoverable/100, cur_rec.rounding_factor) + (ln_tax_amount * (100 - cur_rec.recoverable)/100);
1730          -- End 6971526
1731           else
1732             p_codepath := jai_general_pkg.plot_codepath(7.17, p_codepath); /* 7.17 */
1733             p_vat_not_recoverable := p_vat_not_recoverable + ln_tax_amount;
1734           end if;
1735 
1736         end if; /* Service and VAT */
1737 
1738       end if; /* else after all tax types */
1739 
1740     end if; /* Check all tax and tax type */
1741 
1742 
1743     /* get third party amount */
1744     p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
1745     if
1746       cur_rec.vendor_id <> p_po_vendor_id and
1747       cur_rec.vendor_id > 0 and
1748       cur_rec.tax_type not in (jai_constants.tax_type_tds, jai_constants.tax_type_modvat_recovery)
1749     then
1750       p_third_party_taxes := p_third_party_taxes + ln_tax_amount;
1751     end if;
1752 
1753     /* To indicate second pass of the loop, first means F, statement id need not be incremented in code path*/
1754 
1755   end loop; /* c_ja_in_receipt_tax_lines */
1756 
1757   << exit_from_procedure >>
1758   p_codepath := jai_general_pkg.plot_codepath(9, p_codepath, null, 'END'); /* 9 */
1759 
1760   if p_process_flag is null then
1761     p_process_flag    := 'Y';
1762   end if;
1763 
1764   if p_debug = 'Y' then
1765     Fnd_File.put_line(Fnd_File.LOG, '  Code Path :' || p_codepath );
1766 --    Fnd_File.put_line(Fnd_File.LOG, '  ** End of procedure jai_rcv_rcv_rtv_pkg.get_tax_breakup **  ');/*Bug 5527885*/
1767   end if;
1768 
1769   return;
1770 
1771 exception
1772   when others then
1773     p_process_flag    := 'E';
1774     p_process_message := 'RECEIVE_RTV_PKG.get_tax_breakup:' || sqlerrm;
1775     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
1776     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
1777     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END'); /* 24 */
1778     return;
1779 
1780 end get_tax_breakup;
1781 
1782 /******************************** End get_tax_breakup *****************************/
1783 
1784 
1785 /****************************** Start validate_transaction_tax_accnt ******************************/
1786   procedure validate_transaction_tax_accnt
1787   (
1788     p_transaction_type                        in                  varchar2,
1789     p_parent_transaction_type                 in                  varchar2,
1790     -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. p_attribute_category                      in                  varchar2,
1791     p_receipt_source_code                     in                  varchar2,
1792     p_boe_account_id                          in                  number,
1793     p_rtv_expense_account_id                  in                  number,
1794     p_excise_expense_account                  in                  number,
1795     p_excise_rcvble_account                   in                  number,
1796     p_receiving_account_id                    in out  nocopy      number,
1797     p_ap_accrual_account                      in out  nocopy      number,
1798     p_po_accrual_account_id                   in                  number,
1799     p_interorg_payables_account               in                  number,
1800     p_intransit_inv_account                   in                  number,
1801     p_interorg_receivables_account            in                  number,
1802     p_intransit_type                          in                  number,
1803     p_fob_point                               in                  number,
1804     p_cvd_taxes                               in                  number,
1805     p_add_cvd_taxes                           in                  number,/*5228046 Additional cvd Enhancement*/
1806     p_customs_taxes                           in                  number,
1807     p_third_party_taxes                       in                  number,
1808     p_excise_tax                              in                  number,
1809     p_trading_to_trading_iso                  in                  varchar2, /* Bug#4171469 */
1810     p_debug                                   in                  varchar2,   -- default 'N', File.Sql.35
1811     p_process_flag                            out      nocopy     varchar2,
1812     p_process_message                         out      nocopy     varchar2,
1813     p_codepath                                in out   nocopy     varchar2
1814   )
1815 is
1816 
1817 
1818 begin
1819 
1820   /* Start Validate Receving Account p_receiving_account_id */
1821   if p_debug = 'Y' then
1822     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.validate_transaction_tax_accnt **');
1823   end if;
1824 
1825   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.validate_transaction_tax_accnt', 'START'); /* 1 */
1826 
1827   -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. if p_attribute_category  = 'INDIA RMA RECEIPT' then
1828   if p_receipt_source_code = 'CUSTOMER' then
1829 
1830     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
1831 
1832     if  p_excise_expense_account is null then
1833 
1834       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
1835       p_process_flag    := 'E';
1836       p_process_message := 'Excise Expense Account is not defined in JAI_CMN_INVENTORY_ORGS, ' ||
1837                            'for the organization location or null location, cannot proceed as transaction type is RMA';
1838 
1839       goto exit_from_procedure;
1840 
1841     else
1842 
1843       p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
1844       p_receiving_account_id := p_excise_expense_account;
1845 
1846     end if;
1847 
1848   elsif p_receiving_account_id is null then
1849 
1850     p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
1851     p_process_flag    := 'E';
1852     p_process_message := 'Receiving Account is not defined in rcv_parameters for the organization.';
1853     goto exit_from_procedure;
1854 
1855   end if; /*  if p_receipt_source_code = 'CUSTOMER' then
1856             (p_attribute_category  = 'INDIA RMA RECEIPT') */
1857 
1858   /* End Validate Receving Account p_receiving_account_id */
1859 
1860 
1861   /* Start Validate Accrual Account */
1862 
1863   p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
1864   if p_receipt_source_code in ('INTERNAL ORDER','INVENTORY') then /*added INVENTORY for bug #6030615 by vkaranam*/
1865 
1866 
1867     p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
1868     /*6488406*/
1869     if ( ( (p_intransit_type = 2) and (p_fob_point = 1) ) or
1870 (p_trading_to_trading_iso = 'Y'  and p_receipt_source_code = 'INTERNAL ORDER' and p_fob_point <> 2) )then /* Bug#4171469 */
1871 /*added condition of p_fob_point <> 2 by mmurtuza for bug 14307860 (In case of fob point as receipt, accrual account should be interorg payables)*/
1872 
1873       p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
1874       if p_intransit_inv_account is null then
1875 
1876         p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9 */
1877         p_process_flag    := 'E';
1878         p_process_message := 'Intransit Inventory Account is not defined in mtl_interorg_parameters for ' ||
1879                                'from and to organization of the ISO. ';
1880           goto exit_from_procedure;
1881       else
1882         p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10 */
1883         p_ap_accrual_account := p_intransit_inv_account;
1884       end if;
1885 
1886     else
1887 
1888       p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11  */
1889 
1890       if p_interorg_payables_account is null then
1891         p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12  */
1892         p_process_flag    := 'E';
1893         p_process_message := 'Inter-org Payables Account is not defined in mtl_interorg_parameters for ' ||
1894                              'from and to organization of the ISO. ';
1895         goto exit_from_procedure;
1896       else
1897         p_codepath := jai_general_pkg.plot_codepath(13, p_codepath); /* 13  */
1898         p_ap_accrual_account := p_interorg_payables_account;
1899       end if;
1900 
1901     end if;
1902 
1903   elsif p_receipt_source_code = 'CUSTOMER' then
1904    -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. if p_attribute_category  = 'INDIA RMA RECEIPT' then
1905 
1906     p_codepath := jai_general_pkg.plot_codepath(14, p_codepath); /* 14  */
1907 
1908     if  p_excise_rcvble_account is null then
1909       p_codepath := jai_general_pkg.plot_codepath(15, p_codepath); /* 15  */
1910       p_process_flag    := 'E';
1911       p_process_message := 'Excise Receivable Account is not defined in JAI_CMN_INVENTORY_ORGS, ' ||
1912                            'for the organization location or null location, cannot proceed as transaction type is RMA';
1913       goto exit_from_procedure;
1914     else
1915       p_codepath := jai_general_pkg.plot_codepath(16, p_codepath); /* 16  */
1916       p_ap_accrual_account := p_excise_rcvble_account;
1917     end if;
1918 
1919 
1920   elsif p_po_accrual_account_id is not null then
1921 
1922     p_codepath := jai_general_pkg.plot_codepath(17, p_codepath); /* 17  */
1923     p_ap_accrual_account := p_po_accrual_account_id;
1924 
1925   elsif p_ap_accrual_account is null then
1926 
1927     p_codepath := jai_general_pkg.plot_codepath(18, p_codepath); /* 18  */
1928     p_process_flag    := 'E';
1929     p_process_message := 'AP Accrual Account is not defined in mtl_parameters for the organization.';
1930     goto exit_from_procedure;
1931 
1932   end if; /* p_receipt_source_code = 'INTERNAL ORDER' */
1933 
1934   /* End Validate Accrual Account */
1935 
1936 
1937   /* Start 'RETURN TO VENDOR'  RTV expense account check */
1938 
1939   p_codepath := jai_general_pkg.plot_codepath(19, p_codepath); /* 19  */
1940   if ( (p_transaction_type = 'RETURN TO VENDOR')
1941         or
1942        (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RETURN TO VENDOR')
1943       )
1944   then
1945 
1946     /* Check if Customs, CVD (BOE) or third party type taxes exist */
1947     p_codepath := jai_general_pkg.plot_codepath(20,  p_codepath); /* 20  */
1948 
1949     if (  (p_cvd_taxes <> 0) OR
1950           (p_add_cvd_taxes     <> 0) OR  /*5228046 Additional cvd Enhancement*/
1951           (p_customs_taxes <> 0) OR
1952 	  (p_third_party_taxes <> 0)
1953 	) then
1954 
1955       p_codepath := jai_general_pkg.plot_codepath(21,  p_codepath); /* 21  */
1956 
1957       if  p_rtv_expense_account_id is null then
1958         p_codepath := jai_general_pkg.plot_codepath(22, p_codepath); /* 22  */
1959         p_process_flag    := 'E';
1960         p_process_message := 'RTV Expense Account is not defined in JAI_CMN_INVENTORY_ORGS, ' ||
1961                              'for the organization location or null location, cannot proceed as transaction type is RTV';
1962         goto exit_from_procedure;
1963       end if;
1964 
1965     end if; /* Custom / CVD /third party type of taxes exist  */
1966 
1967 
1968   end if;
1969 
1970   /* End 'RETURN TO VENDOR'  RTV expense account check */
1971 
1972 
1973   /* Start BOE a/c check */
1974   if ( (p_transaction_type = 'RECEIVE')
1975         or
1976        (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RECEIVE')
1977       )
1978   then
1979 
1980     if (  (p_cvd_taxes <> 0) or
1981           (p_add_cvd_taxes     <> 0) OR  /*5228046 Additional cvd Enhancement*/
1982           (p_customs_taxes <> 0)
1983 	) then
1984 
1985       p_codepath := jai_general_pkg.plot_codepath(23, p_codepath); /* 23  */
1986 
1987       if p_boe_account_id is null then
1988           p_codepath := jai_general_pkg.plot_codepath(24, p_codepath); /* 24  */
1989           p_process_flag    := 'E';
1990           p_process_message := 'BOE Account is not defined in JAI_CMN_INVENTORY_ORGS, ' ||
1991                                'for the organization location or null location.';
1992           goto exit_from_procedure;
1993       end if;
1994     end if;
1995 
1996   end if; /*'RECEIVE'*/
1997   /* End BOE a/c check */
1998 
1999 
2000   << exit_from_procedure >>
2001   p_codepath := jai_general_pkg.plot_codepath(25, p_codepath, null, 'END'); /* 25  */
2002 
2003   if p_process_flag is null then
2004     p_process_flag    := 'Y';
2005   end if;
2006 
2007   if p_debug = 'Y' then
2008 --    Fnd_File.put_line(Fnd_File.LOG, '  Code Path :' || p_codepath );/*Bug 5527885*/
2009     Fnd_File.put_line(Fnd_File.LOG, '  ** End of procedure jai_rcv_rcv_rtv_pkg.validate_transaction_tax_accnt **  ');
2010   end if;
2011 
2012   return;
2013 
2014 exception
2015   when others then
2016     p_process_flag    := 'E';
2017     p_process_message := 'RECEIVE_RTV_PKG.validate_transaction_tax_accnt:'|| sqlerrm;
2018     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
2019     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
2020     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END'); /* 24 */
2021     return;
2022 
2023 end validate_transaction_tax_accnt;
2024 
2025 /****************************** End validate_transaction_tax_accnt ******************************/
2026 
2027 /****************************** Start apply_relieve_boe ******************************/
2028   procedure apply_relieve_boe
2029   (
2030     p_transaction_id                           in                 number,
2031     p_transaction_type                         in                 varchar2,
2032     p_parent_transaction_id                    in                 number,
2033     p_parent_transaction_type                  in                 varchar2,
2034     p_shipment_line_id                         in                 number,
2035     p_shipment_header_id                       in                 number,
2036     p_organization_id                          in                 number,
2037     p_inventory_item_id                        in                 number,
2038     p_cvd_taxes                                in                 number,
2039     p_add_cvd_taxes                            in                 number,/*5228046 Additional cvd Enhancement*/
2040     p_customs_taxes                            in                 number,
2041     p_cvd_edu_cess                             in                 number, /* Educational Cess */
2042     p_cvd_sh_edu_cess                          in                 number, /*Bug 5989740 bduvarag*/
2043     p_customs_edu_cess                         in                 number, /* Educational Cess */
2044     p_customs_sh_edu_cess                      in                 number, /*Bug 5989740 bduvarag*/
2045     --Added by zhiwei for BOE ER  bug 11684111 begin
2046     ---------------------------------------------------------------------
2047     p_boe_other1                              in                  number,
2048     p_boe_other2                              in                  number,
2049     p_boe_other3                              in                  number,
2050     p_boe_other4                              in                  number,
2051     p_boe_other5                              in                  number,
2052     p_boe_surcharge_duty                      in                  number,
2053     p_boe_add_customs                         in                  number,
2054     ---------------------------------------------------------------------
2055     --Added by zhiwei for BOE ER bug 11684111  end
2056     p_simulation                               in                 varchar2,
2057     p_debug                                    in                 varchar2,  -- default 'N', File.Sql.35
2058     p_process_flag                             out     nocopy     varchar2,
2059     p_process_message                          out     nocopy     varchar2,
2060     p_codepath                                 in out  nocopy     varchar2
2061   )
2062   is
2063 
2064   cursor    c_is_boe_applied(cp_shipment_line_id number, cp_parent_transaction_id number) is
2065     select  count(boe_id)
2066     from    JAI_CMN_BOE_MATCHINGS
2067     where   shipment_line_id  =   cp_shipment_line_id
2068     and     transaction_id    =   cp_parent_transaction_id;
2069 
2070   ln_boe_count      number; -- :=0  File.Sql.35 by Brathod
2071 
2072 begin
2073   ln_boe_count := 0;  -- File.Sql.35 by Brathod
2074   if p_debug = 'Y' then
2075     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.apply_relieve_boe **');
2076   end if;
2077 
2078   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.apply_relieve_boe', 'START'); /* 1  */
2079 
2080   if not (p_transaction_type = 'CORRECT' and p_parent_transaction_type = 'RECEIVE') then
2081     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2  */
2082     -- ABC
2083     --p_process_flag := 'Y';
2084     --p_process_message := 'apply_relieve_boe is not required as this is not a case of CORRECT to RECEIVE';
2085     FND_FILE.put_line( FND_FILE.log, 'Apply_relieve_boe is not required as this is not a case of CORRECT to RECEIVE');
2086     goto exit_from_procedure;
2087   elsif (p_cvd_taxes + p_add_cvd_taxes + p_customs_taxes) = 0 then /*5228046 Additional cvd Enhancement added p_add_cvd_taxes*/
2088     p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3  */
2089     -- ABC
2090     --p_process_flag := 'Y';
2091     --p_process_message := 'apply_relieve_boe is not required as no CVD or Customs type of tax';
2092     FND_FILE.put_line( FND_FILE.log, 'Apply_relieve_boe is not required as no CVD or ADDITIONAL_CVD or Customs type of tax');
2093     goto exit_from_procedure;
2094   end if;
2095 
2096   /* Check if BOE has been applied for the parent transaction */
2097   p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4  */
2098   open c_is_boe_applied(p_shipment_line_id, p_parent_transaction_id);
2099   fetch c_is_boe_applied into ln_boe_count;
2100   close c_is_boe_applied;
2101 
2102   if nvl(ln_boe_count, 0) = 0 then
2103     p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5  */
2104     -- ABC
2105     --p_process_flag := 'Y';
2106     --p_process_message := 'apply_relieve_boe is not required parent transaction has no BOE applied';
2107     FND_FILE.put_line( FND_FILE.log, 'Apply_relieve_boe is not required parent transaction has no BOE applied');
2108     goto exit_from_procedure;
2109   end if;
2110 
2111 
2112   if (p_cvd_taxes + p_add_cvd_taxes + p_customs_taxes) > 0 then /*5228046 Additional cvd Enhancement added p_add_cvd_taxes*/
2113 
2114     if p_debug = 'Y' then
2115       Fnd_File.put_line(Fnd_File.LOG, ' Call to -> apply_boe');
2116     end if;
2117     p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6  */
2118     apply_boe
2119     (
2120       p_shipment_header_id      =>     p_shipment_header_id,
2121       p_shipment_line_id        =>     p_shipment_line_id,
2122       p_transaction_id          =>     p_transaction_id,
2123       p_organization_id         =>     p_organization_id,
2124       p_inventory_item_id       =>     p_inventory_item_id,
2125       p_boe_tax                 =>     p_cvd_taxes     +
2126                                        p_add_cvd_taxes + /*5228046 Additional cvd Enhancement added p_add_cvd_taxes*/
2127                                        p_customs_taxes +
2128                                        p_cvd_edu_cess  +
2129                                        p_cvd_sh_edu_cess  + /*Bug 5989740 bduvarag*/
2130                                        p_customs_edu_cess +
2131                                        p_customs_sh_edu_cess
2132                                        /*Added by Wenqiong for BOE enhancement bug 11684111 Begin*/
2133                                        + p_boe_other1         +
2134                                        p_boe_other2         +
2135                                        p_boe_other3         +
2136                                        p_boe_other4         +
2137                                        p_boe_other5         +
2138                                        p_boe_add_customs    +
2139                                        p_boe_surcharge_duty,
2140                                        /*Added by Wenqiong for BOE enhancement bug 11684111 End*/
2141       p_simulation              =>     p_simulation,
2142       p_process_flag            =>     p_process_flag,
2143       p_process_message         =>     p_process_message,
2144       p_debug                   =>     p_debug,
2145       p_codepath                =>     p_codepath
2146     );
2147 
2148   else
2149 
2150     if p_debug = 'Y' then
2151       Fnd_File.put_line(Fnd_File.LOG, ' Call to -> relieve_boe');
2152     end if;
2153     p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7  */
2154     relieve_boe
2155     (
2156       p_shipment_header_id      =>     p_shipment_header_id,
2157       p_shipment_line_id        =>     p_shipment_line_id,
2158       p_transaction_id          =>     p_transaction_id,
2159       p_parent_transaction_id   =>     p_parent_transaction_id,
2160       p_boe_tax                 =>     p_cvd_taxes     +
2161                                        p_add_cvd_taxes + /*5228046 Additional cvd Enhancement added p_add_cvd_taxes*/
2162                                        p_customs_taxes +
2163                                        p_cvd_edu_cess  +
2164 				       p_cvd_sh_edu_cess  + /*Bug 5989740 bduvarag*/
2165                                        p_customs_edu_cess +
2166                                        p_customs_sh_edu_cess
2167                                        /*Added by Wenqiong for BOE enhancement bug 11684111 Begin*/
2168                                        + p_boe_other1         +
2169                                        p_boe_other2         +
2170                                        p_boe_other3         +
2171                                        p_boe_other4         +
2172                                        p_boe_other5         +
2173                                        p_boe_add_customs    +
2174                                        p_boe_surcharge_duty,
2175                                        /*Added by Wenqiong for BOE enhancement bug 11684111 End*/
2176       p_simulation              =>     p_simulation,
2177       p_process_flag            =>     p_process_flag,
2178       p_process_message         =>     p_process_message,
2179       p_debug                   =>     p_debug,
2180       p_codepath                =>     p_codepath
2181     );
2182 
2183   end if;
2184 
2185   /* If apply relieve BOE has been done successfully, update the boe_applied_flag in ja_in_rcv_transaction */
2186   if p_process_flag = 'Y' and nvl(p_simulation , 'Y') <> 'Y'  then
2187 
2188     p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8  */
2189     update  JAI_RCV_TRANSACTIONS
2190     set     boe_applied_flag = 'Y'
2191     where   transaction_id = p_transaction_id;
2192 
2193   end if;
2194 
2195   << exit_from_procedure >>
2196   p_codepath := jai_general_pkg.plot_codepath(9, p_codepath, null, 'END'); /* 9  */
2197 
2198   if p_process_flag is null then
2199     p_process_flag    := 'Y';
2200   end if;
2201 
2202   return;
2203 
2204 exception
2205   when others then
2206     p_process_flag    := 'E';
2207     p_process_message := 'RECEIVE_RTV_PKG.apply_relieve_boe:' || sqlerrm;
2208     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
2209     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
2210     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END'); /* 24 */
2211     return;
2212 
2213 end apply_relieve_boe;
2214 
2215 
2216 /****************************** End   apply_relieve_boe ******************************/
2217 
2218 
2219 /****************************** Start apply_boe ******************************/
2220 
2221   procedure apply_boe
2222   (
2223     p_shipment_header_id                       in                 number,
2224     p_shipment_line_id                         in                 number,
2225     p_transaction_id                           in                 number,
2226     p_organization_id                          in                 number,
2227     p_inventory_item_id                        in                 number,
2228     p_boe_tax                                  in                 number,
2229     p_simulation                               in                 varchar2,
2230     p_debug                                    in                 varchar2,  -- default 'N', File.Sql.35
2231     p_process_flag                             out     nocopy     varchar2,
2232     p_process_message                          out     nocopy     varchar2,
2233     p_codepath                                 in out  nocopy     varchar2
2234   )
2235 is
2236 
2237   cursor c_ja_in_boe_hdr (cp_organization_id number, cp_inventory_item_id number) is
2238   select boe_id,
2239          ( nvl(boe_amount, 0) - nvl(amount_applied, 0) - nvl(amount_written_off, 0) )
2240          available_amount
2241   from   JAI_CMN_BOE_HDRS  jbh
2242   where  organization_id =  p_organization_id
2243   and    ( nvl(boe_amount, 0) - nvl(amount_applied, 0) - nvl(amount_written_off, 0) ) > 0
2244   and    ( ( nvl(consolidated_flag, 'Y') = 'Y' )
2245            or
2246            ( exists ( select '1'
2247                       from   JAI_CMN_BOE_DTLS
2248                       where  boe_id = jbh.boe_id
2249                       and    item_number = cp_inventory_item_id
2250                      )
2251            )
2252          );
2253 
2254   ln_bal_boe_amount         number;
2255   ln_boe_amount_to_apply    number;
2256 
2257 begin
2258 
2259   if p_debug = 'Y' then
2260     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.apply_boe **');
2261   end if;
2262 
2263   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.apply_boe', 'START'); /* 1  */
2264 
2265   ln_bal_boe_amount := p_boe_tax;
2266 
2267   for cur_available_boe in c_ja_in_boe_hdr(p_organization_id, p_inventory_item_id) loop
2268 
2269     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2  */
2270 
2271     if ln_bal_boe_amount <= 0 then
2272       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3  */
2273       goto finish_apply;
2274     end if;
2275 
2276     if cur_available_boe.available_amount <= ln_bal_boe_amount then
2277       p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4  */
2278       ln_boe_amount_to_apply := cur_available_boe.available_amount;
2279     else
2280       p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5  */
2281       ln_boe_amount_to_apply := ln_bal_boe_amount;
2282     end if;
2283 
2284     if nvl(p_simulation , 'Y') <> 'Y' then
2285 
2286       p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6  */
2287 
2288       /* Insert a apply record in JAI_CMN_BOE_MATCHINGS */
2289       insert into JAI_CMN_BOE_MATCHINGS
2290       (BOE_MATCHING_ID,
2291         transaction_id,
2292         shipment_header_id,
2293         shipment_line_id,
2294         boe_id,
2295         amount,
2296         creation_date,
2297         created_by,
2298         last_update_date,
2299         last_updated_by
2300        )
2301       values
2302       ( JAI_CMN_BOE_MATCHINGS_S.nextval,
2303         p_transaction_id,
2304         p_shipment_header_id,
2305         p_shipment_line_id,
2306         cur_available_boe.boe_id,
2307         ln_boe_amount_to_apply,
2308         sysdate,
2309         fnd_global.user_id,
2310         sysdate,
2311         fnd_global.user_id
2312       );
2313 
2314       p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7  */
2315       /* update the boe header amount */
2316       update  JAI_CMN_BOE_HDRS
2317       set     amount_applied = nvl(amount_applied, 0) + ln_boe_amount_to_apply,
2318               last_update_date = sysdate,
2319               last_updated_by = fnd_global.user_id,
2320               last_update_login = fnd_global.user_id
2321       where   boe_id = cur_available_boe.boe_id;
2322 
2323       ln_bal_boe_amount := ln_bal_boe_amount - ln_boe_amount_to_apply;
2324 
2325       p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8  */
2326 
2327     end if;
2328 
2329     /* To indicate second pass of the loop, first means F, statement id need not be incremented in code path*/
2330 
2331   end loop;
2332 
2333   << finish_apply >>
2334   if ln_bal_boe_amount > 0 then
2335     p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9  */
2336     p_process_flag    := 'E';
2337     P_process_message := 'Matching BOE not available for applying the BOE tax, cannot proceed ' ||
2338                          '(jai_rcv_rcv_rtv_pkg.apply_boe)';
2339   end if;
2340 
2341   << exit_from_procedure >>
2342   p_codepath := jai_general_pkg.plot_codepath(10, p_codepath, null, 'END'); /* 10  */
2343 
2344   if p_process_flag is null then
2345     p_process_flag    := 'Y';
2346   end if;
2347 
2348   if p_debug = 'Y' then
2349     Fnd_File.put_line(Fnd_File.LOG, '  Code Path :' || p_codepath );
2350     Fnd_File.put_line(Fnd_File.LOG, '  ** End of procedure jai_rcv_rcv_rtv_pkg.apply_boe **  ');
2351   end if;
2352 
2353   return;
2354 
2355 exception
2356   when others then
2357     p_process_flag    := 'E';
2358     p_process_message := 'RECEIVE_RTV_PKG.apply_boe:'|| sqlerrm;
2359     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
2360     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
2361     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END'); /* 24 */
2362     return;
2363 
2364 end apply_boe;
2365 
2366 /****************************** End apply_boe ******************************/
2367 
2368 
2369 /****************************** Start relieve_boe ******************************/
2370 
2371   procedure relieve_boe
2372   (
2373     p_shipment_header_id                       in                 number,
2374     p_shipment_line_id                         in                 number,
2375     p_transaction_id                           in                 number,
2376     p_parent_transaction_id                    in                 number,
2377     p_boe_tax                                  in                 number,
2378     p_simulation                               in                 varchar2,
2379     p_debug                                    in                 varchar2,  -- default 'N', File.Sql.35
2380     p_process_flag                             out     nocopy     varchar2,
2381     p_process_message                          out     nocopy     varchar2,
2382     p_codepath                                 in out  nocopy     varchar2
2383   )
2384   is
2385 
2386   cursor c_ja_in_rcp_boe(cp_shipment_line_id number, cp_transaction_id number) is
2387     select boe_id, amount
2388     from   JAI_CMN_BOE_MATCHINGS
2389     where  shipment_line_id = cp_shipment_line_id
2390     and    transaction_id =   cp_transaction_id;
2391 
2392   ln_bal_boe_amount         number;
2393   ln_boe_amount_to_unapply  number;
2394 
2395 begin
2396 
2397   if p_debug = 'Y' then
2398     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.relieve_boe **');
2399   end if;
2400 
2401   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.relieve_boe', 'START'); /* 1  */
2402   ln_bal_boe_amount :=  p_boe_tax;
2403 
2404   for applied_boe_rec in   c_ja_in_rcp_boe(p_shipment_line_id, p_parent_transaction_id) loop
2405 
2406     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2  */
2407     if  ln_bal_boe_amount = 0 then
2408       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3  */
2409       goto   finished_unapply;
2410     end if;
2411 
2412     if   applied_boe_rec.amount <= abs(ln_bal_boe_amount) then
2413       p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4  */
2414       ln_boe_amount_to_unapply := -1 * applied_boe_rec.amount;
2415     else
2416       p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5  */
2417       ln_boe_amount_to_unapply := ln_bal_boe_amount;
2418     end if;
2419 
2420     if nvl(p_simulation , 'Y') <> 'Y' then
2421       /* Insert a unapply record in JAI_CMN_BOE_MATCHINGS */
2422       p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6  */
2423       insert into JAI_CMN_BOE_MATCHINGS
2424       (BOE_MATCHING_ID,
2425         transaction_id,
2426         shipment_header_id,
2427         shipment_line_id,
2428         boe_id,
2429         amount,
2430         creation_date,
2431         created_by,
2432         last_update_date,
2433         last_updated_by
2434        )
2435       values
2436       ( JAI_CMN_BOE_MATCHINGS_S.nextval,
2437         p_transaction_id,
2438         p_shipment_header_id,
2439         p_shipment_line_id,
2440         applied_boe_rec.boe_id,
2441         ln_boe_amount_to_unapply,
2442         sysdate,
2443         fnd_global.user_id,
2444         sysdate,
2445         fnd_global.user_id
2446       );
2447 
2448       /* update the boe header amount */
2449       p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7  */
2450       update  JAI_CMN_BOE_HDRS
2451       set     amount_applied = nvl(amount_applied, 0) + ln_boe_amount_to_unapply,
2452               last_update_date = sysdate,
2453               last_updated_by = fnd_global.user_id,
2454               last_update_login = fnd_global.user_id
2455       where   boe_id = applied_boe_rec.boe_id;
2456 
2457     end if; /* p_simulation = 'Y' */
2458 
2459     p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8  */
2460     ln_bal_boe_amount := ln_bal_boe_amount - ln_boe_amount_to_unapply;
2461 
2462 
2463   end loop;
2464 
2465   << finished_unapply >>
2466     p_process_flag := 'Y';
2467 
2468   << exit_from_procedure >>
2469   p_codepath := jai_general_pkg.plot_codepath(9, p_codepath, null, 'END'); /* 9  */
2470 
2471   if p_process_flag is null then
2472     p_process_flag    := 'Y';
2473   end if;
2474 
2475   if p_debug = 'Y' then
2476     Fnd_File.put_line(Fnd_File.LOG, '  Code Path :' || p_codepath );
2477     Fnd_File.put_line(Fnd_File.LOG, '  ** End of procedure jai_rcv_rcv_rtv_pkg.relieve_boe **  ');
2478   end if;
2479 
2480   return;
2481 
2482 exception
2483   when others then
2484     p_process_flag    := 'E';
2485     p_process_message := 'RECEIVE_RTV_PKG.relieve_boe:' || sqlerrm;
2486     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
2487     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
2488     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END'); /* 24 */
2489     return;
2490 
2491 end relieve_boe;
2492 
2493 /****************************** End relieve_boe ******************************/
2494 
2495 
2496 /****************************** Start post_entries ******************************/
2497   procedure post_entries
2498   (
2499     p_transaction_id                            in                number,
2500     p_transaction_type                          in                varchar2,
2501     p_parent_transaction_type                   in                varchar2,
2502     -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. p_attribute_category                        in                varchar2,
2503     p_receipt_source_code                       in                varchar2,
2504     p_transaction_date                          in                date,
2505     p_receipt_num                               in                varchar2,
2506     p_receiving_account_id                      in                number,
2507     p_ap_accrual_account                        in                number,
2508     p_boe_account_id                            in                number,
2509     p_rtv_expense_account_id                    in                number,
2510     p_intransit_type                            in                number,
2511     p_fob_point                                 in                number,
2512     p_intransit_inv_account                     in                number,
2513     p_interorg_receivables_account              in                number,
2514     p_all_taxes                                 in                number,
2515     p_tds_taxes                                 in                number,
2516     p_modvat_recovery_taxes                     in                number,
2517     p_cvd_taxes                                 in                number,
2518     p_add_cvd_taxes                             in                number,/*5228046 Additional cvd Enhancement*/
2519     p_customs_taxes                             in                number,
2520     p_third_party_taxes                         in                number,
2521     p_excise_tax                                in                number,
2522     p_service_recoverable                       in                number, /* Service */
2523     p_service_not_recoverable                   in                number, /* Service */
2524     p_account_service_interim                   in                boolean, /* Service */
2525     /* following two params added by Vijay Shankar for Bug#4250236(4245089). VAT Impl. */
2526     p_vat_recoverable                           in                number,
2527     p_vat_not_recoverable                       in                number,
2528     p_excise_edu_cess                           in                number, /* Educational Cess */
2529     p_excise_sh_edu_cess                        in                number, /*Bug 5989740 bduvarag*/
2530     p_cvd_edu_cess                              in                number, /* Educational Cess */
2531     p_cvd_sh_edu_cess                           in                number, /*Bug 5989740 bduvarag*/
2532     p_customs_edu_cess                          in                number, /* Educational Cess */
2533     p_customs_sh_edu_cess                       in                number, /*Bug 5989740 bduvarag*/
2534     --Added by zhiwei for BOE ER bug 11684111  begin
2535     ---------------------------------------------
2536     p_boe_other1                                in                number,
2537     p_boe_other2                                in                number,
2538     p_boe_other3                                in                number,
2539     p_boe_other4                                in                number,
2540     p_boe_other5                                in                number,
2541     p_boe_surcharge_duty                        in                number,
2542     p_boe_add_customs                           in                number,
2543     ---------------------------------------------------
2544     --Added by zhiwei for BOE ER bug 11684111  end
2545     p_trading_to_trading_iso                    in                varchar2, /* Bug#4171469 */
2546     ptr_jv                                      in OUT NOCOPY JOURNAL_LINES,  /* 5527885 */
2547     p_simulation                                in                varchar2,
2548     p_debug                                     in                varchar2,  -- default 'N', File.Sql.35
2549     p_process_flag                              out     nocopy    varchar2,
2550     p_process_message                           out     nocopy    varchar2,
2551     p_codepath                                  in out  nocopy    varchar2,
2552     --added the below parameter for bug#11936596
2553     p_inclu_service_recoverable                 in number default null,
2554     p_inclu_vat_recoverable                     in number default null /*Bug 14185068*/
2555   )  is
2556 
2557 
2558   cursor c_ja_in_temp_po_accrual (cp_transaction_id number) is
2559     select  count(1)
2560     from    JAI_RCV_REP_ACCRUAL_T
2561     where   transaction_id = cp_transaction_id;
2562 
2563   ln_ja_in_temp_po_accrual      number;
2564 
2565   ln_credit                     number;
2566   ln_debit                      number;
2567 
2568   /* File.Sql.35 by Brathod */
2569   lv_source_name                varchar2(20); -- := 'Purchasing India'; -- Harshita . modified the size from 15 to 20 for Bug 4762433
2570   lv_category_name              varchar2(15); --:= 'Receiving India';
2571   lv_acct_nature                varchar2(15); --:= 'Receiving';
2572   lv_acct_type                  varchar2(15);  /* Regular or Reversal*/
2573 
2574   lv_reference_10               varchar2(240);
2575   lv_reference_23               varchar2(240); -- := 'jai_rcv_rcv_rtv_pkg.post_entries';
2576   lv_reference_24               varchar2(240); -- := 'rcv_transactions';
2577   lv_reference_25               varchar2(240); -- :=  'transaction_id';
2578   lv_reference_26               varchar2(240);
2579   /* End of File.Sql.35 by Brathod */
2580 
2581   ln_boe_account_id             number;--Added by zhiwei for BOE ER bug 11684111
2582   ln_organization_id            number;--Added by zhiwei for BOE ER bug 11684111
2583   ln_location_id                number;--Added by zhiwei for BOE ER bug 11684111
2584 begin
2585 /* -----------------------------------------------------------------------------------------------
2586 
2587 |  Type |  Additional  |  Account             | Debit/Credit    |  Tax details                     |
2588 |       |  Condition   |                      |                 |                                  |
2589 |  ==== |  ==========  |  ============        | ===========     |  ===========                     |
2590 |  RTV  |  None        |  Receiving           | Credit          | ALL -                            |
2591 |       |              |                      |                 | (TDS + Modvat Recovery +         |
2592 |       |              |                      |                 |  Recoverable Service Tax +       |
2593 |       |              |                      |                 |  Recoverable VAT Tax )           |
2594 |       |              |                      |                 |                                  |
2595 |       |              |                      |                 |                                  |
2596 |       |  None        |  AP Accrual          | Debit           |  ALL -                           |
2597 |       |              |                      |                 | (TDS + Modvat Recovery +         |
2598 |       |              |                      |                 |  3rd Party + CVD + Customs +     |
2599 |       |              |                      |                 |  Recoverable Service Tax** +     |
2600 |       |              |                      |                 |  Recoverable VAT     Tax** +     |
2601 |       |              |                      |                 |  CVD Edu Cess + Custom Edu Cess) |
2602 |       |              |                      |                 |                                  |
2603 |       |  None        |  RTV expense         | Debit           | 3rd Party + CVD + Customs        |
2604 |       |              |                      |                 | CVD Edu Cess + Custom Edu Cess   |
2605 |       |              |                      |                 |                                  |
2606 |       |              |                      |                 |                                  |
2607 |=======|==============|======================|=================|==================================|
2608 |       |              |                      |                 |                                  |
2609 |  RMA  |  SCRAP type  |  Excise Expense      | Debit           | Excise + CVD +                   |
2610 |       |              |                      |                 | Excise Edu Cess + CVD Edu Cess   |
2611 |       |              |  Excise Receivable   | Credit          | Excise + CVD                     |
2612 |       |              |                      |                 | Excise Edu Cess + CVD Edu Cess   |
2613 |       |              |                      |                 |                                  |
2614 |       |              |                      |                 |                                  |
2615 |=======|==============|======================|=================|==================================|
2616 |  ISO  |  None        |  Receiving           | Debit           |  ALL -                           |
2617 |       |              |                      |                 | (TDS + Modvat Recovery +         |
2618 |       |              |                      |                 |  Recoverable Service Tax )       |
2619 |       |              |                      |                 |                                  |
2620 |       |              |                      |                 |                                  |
2621 |       |              |                      |                 |                                  |
2622 |       |  None        |  Intransit Inventory | Credit          | ALL -                            |
2623 |       |              |                      |                 |(TDS + Modvat Recovery +          |
2624 |       |              |                      |                 | CVD + Customs                    |
2625 |       |              |                      |                 |                                  |
2626 |       |              |                      |                 |                                  |
2627 |       |  None        |  BOE                 | Credit          | CVD + Customs +                  |
2628 |       |              |                      |                 | CVD Edu Cess + Custom Edu Cess   |
2629 |       |--------------|----------------------|-----------------|----------------------------------|
2630 |       |              |                      |                 |                                  |
2631 |       |              |                      |                 |                                  |
2632 |       |  Intransit   |                      |                 |                                  |
2633 |       |  Type=2 &    |                      |                 |                                  |
2634 |       |  FOB point=2 |  Interorg Payables   | Credit          |  ALL -                           |
2635 |       |  and not     |                      |                 |  (TDS + Modvat Recovery +        |
2636 |       |  trading to  |                      |                 |   CVD + Customs +                |
2637 |       |  trading ISO |                      |                 |   CVD Edu Cess + Custom Edu Cess |
2638 |       |              |                      |                 |                                  |
2639 |       |  Intransit   |                      |                 |                                  |
2640 |       |  Type=2 &    |                      |                 |                                  |
2641 |       |  FOB point=2 |  Interorg Receivables| Debit           |  ALL -                           |
2642 |       |  and not     |                      |                 |  (TDS + Modvat Recovery +        |
2643 |       |  trading to  |                      |                 |   CVD + Customs +                |
2644 |       |  trading ISO |                      |                 |   CVD Edu Cess + Custom Edu Cess |
2645 |       |              |                      |                 |                                  |
2646 |       |              |                      |                 |                                  |
2647 |       |              |                      |                 |                                  |
2648 |=======|==============|======================|=================|================================= |
2649 |       |              |                      |                 |                                  |
2650 |PO     |  None        | Receiving            |Debit            | ALL -                            |
2651 |Receive|              |                      |                 | (TDS + Modvat Recovery +         |
2652 |       |              |                      |                 |  Recoverable Service Tax +       |
2653 |       |              |                      |                 |  Recoverable VAT Tax )           |
2654 |       |              |                      |                 |                                  |
2655 |       |              |                      |                 |                                  |
2656 |       |  None        |  AP Accrual          |Credit           | ALL -                            |
2657 |       |              |                      |                 |(TDS + Modvat Recovery +          |
2658 |       |              |                      |                 | CVD + Customs +                  |
2659 |       |              |                      |                 | Recoverable Service Tax** +      |
2660 |       |              |                      |                 | Recoverable VAT Tax** +          |
2661 |       |              |                      |                 | CVD Edu Cess + Custom Edu Cess)  |
2662 |       |              |                      |                 |                                  |
2663 |       |  None        |  BOE                 | Credit          | CVD + Customs                    |
2664 |       |              |                      |                 | CVD Edu Cess + Custom Edu Cess   |
2665 |=======|==============|======================|=================|================================= |
2666 |       |              |                      |                 |                                  |
2667 |Service Tax Accounting at Receive, RTV or their Correct when recoverable service/vat tax exists **|
2668 |       |              |                      |                 |                                  |
2669 |PO     |  None        | Service Tax Interim  | Debit           | Recoverable Service Tax          |
2670 |       |              | Recovery a/c         |                 | By tax type                      |
2671 |       |              | for org and tax type |                 |                                  |
2672 |       |              |                      |                 |                                  |
2673 |       |              |                      |                 |                                  |
2674 |PO     |  None        | VAT Tax Interim      | Debit           | Recoverable VAT Tax              |
2675 |       |              | Recovery a/c         |                 | By tax type                      |
2676 |       |              | for org and tax type |                 |                                  |
2677 |       |              |                      |                 |                                  |
2678 |       |              |                      |                 |                                  |
2679 |-------|--------------|----------------------|-----------------|--------------------------------  |
2680 |                                                                                                  |
2681 | References:                                                                                      |
2682 | ** - In addition to the existance of recoverable service tax, the following condition should also|
2683 | be NOT TRUE.                                                                                     |
2684 |                                                                                                  |
2685 | ( accrue on receipt = 'N' or (inventory item = 'N' and accounting method option = 'Cash') )      |
2686 |                                                                                                  |
2687 |-----------------------------------------------------------------------------------------------   */
2688   /* File.Sql.35 by Brathod */
2689   lv_source_name                := 'Purchasing India';
2690   lv_category_name              := 'Receiving India';
2691   lv_acct_nature                := 'Receiving';
2692   lv_reference_23               := 'jai_rcv_rcv_rtv_pkg.post_entries';
2693   lv_reference_24               := 'rcv_transactions';
2694   lv_reference_25               :=  'transaction_id';
2695   /* End of File.Sql.35 by Brathod*/
2696 
2697   if p_debug = 'Y' then
2698     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.post_entries **');
2699   end if;
2700 
2701   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.post_entries', 'START'); /* 1  */
2702   /* Set varaiable values for accounting entries with GL link */
2703   if ( (p_transaction_type = 'RETURN TO VENDOR')
2704         or
2705        (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RETURN TO VENDOR')
2706       )
2707   then
2708     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2  */
2709     lv_acct_type := 'REVERSAL';
2710   else
2711     p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3  */
2712     lv_acct_type := 'REGULAR';
2713   end if;
2714 
2715   p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4  */
2716   lv_reference_10 :=  'India Local Receiving Entry for the Receipt Number ' || p_receipt_num ||
2717                       ' for the Transaction Type ' || p_transaction_type ;
2718 
2719   if p_transaction_type = 'CORRECT' then
2720     lv_reference_10 := lv_reference_10 || ' of type ' || p_parent_transaction_type;
2721   end if;
2722 
2723 
2724   lv_reference_26 :=  to_char(p_transaction_id);
2725 
2726   /* Accounting Entry # 1 : Receiving Account Id */
2727   ln_credit := null;
2728   ln_debit  := null;
2729     Fnd_File.put_line(Fnd_File.LOG, ' p_receiving_account_id :' || p_receiving_account_id );
2730   if  p_receiving_account_id is not null then
2731 
2732     p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5  */
2733 
2734     if ( (p_transaction_type = 'RETURN TO VENDOR')
2735           or
2736          (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RETURN TO VENDOR')
2737         )
2738     then
2739 
2740        p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6  */
2741        ln_debit  := null;
2742        ln_credit :=
2743        p_all_taxes -
2744        (p_tds_taxes + p_modvat_recovery_taxes + p_service_recoverable + p_vat_recoverable); /* Service */
2745       /*Bug 14185068 - Start*/
2746       /*In case of RTV, Receiving Inventory Account must be debited to VAT Interim Recovery*/
2747       if nvl(p_inclu_vat_recoverable,0) <>0
2748       then
2749           ln_debit := nvl(ln_debit ,0) + nvl(p_inclu_vat_recoverable, 0) ;
2750       end if;
2751       /*Bug 14185068 - End*/
2752 
2753     elsif p_receipt_source_code = 'CUSTOMER' and /*RMA CASE*/
2754      -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. if p_attribute_category  = 'INDIA RMA RECEIPT' and
2755           ( (p_transaction_type = 'RECEIVE')
2756               or
2757             (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RECEIVE')
2758           )
2759     then
2760 
2761       p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7  */
2762       ln_debit  := p_cvd_taxes     +
2763                    p_add_cvd_taxes +  /*5228046 Additional cvd Enhancement*/
2764                    p_excise_tax    +
2765                    p_cvd_edu_cess  +
2766                    p_cvd_sh_edu_cess  +  /*Bug 5989740 bduvarag*/
2767                    p_excise_edu_cess + /* Educational Cess */
2768                    p_excise_sh_edu_cess;
2769       ln_credit := null;
2770 
2771     else
2772 
2773       p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8  */
2774 
2775       ln_debit  :=
2776       p_all_taxes -
2777       (p_tds_taxes + p_modvat_recovery_taxes + p_service_recoverable + p_vat_recoverable);
2778 
2779 
2780       ln_credit := null;
2781 --start additions by vkaranam for bug#11935696
2782       if nvl(p_inclu_service_recoverable,0) <>0
2783       then
2784           ln_debit  := nvl(  ln_debit ,0)+nvl(p_inclu_service_recoverable,0) ;
2785 
2786       end if;
2787  --end additions by vkaranam for bug#11936596
2788       /*Bug 14185068 - Start*/
2789       /*In case of Receive, Receiving Inventory Account must be credited from VAT Interim Recovery*/
2790       if nvl(p_inclu_vat_recoverable,0) <>0
2791       then
2792           ln_credit  := nvl(  ln_credit ,0)+nvl(p_inclu_vat_recoverable,0) ;
2793       end if;
2794       /*Bug 14185068 - End*/
2795 
2796     end if;
2797 
2798     p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9  */
2799         Fnd_File.put_line(Fnd_File.LOG, ' ln_debit :' || ln_debit );
2800           Fnd_File.put_line(Fnd_File.LOG, ' ln_credit :' || ln_credit );
2801     if ( nvl(ln_debit, 0) <> 0 or nvl(ln_credit, 0) <> 0 ) then
2802           p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10  */
2803       /* procedure to populate gl inetrface, JAI_RCV_JOURNAL_ENTRIES and receiving subledger */
2804        Fnd_File.put_line(Fnd_File.LOG, 'Acc for inventory  Receiving Account ' );
2805 
2806       ptr_jv(1).line_num           := 1;
2807       ptr_jv(1).acct_type          := lv_acct_type;
2808       ptr_jv(1).acct_nature        := lv_acct_nature;
2809       ptr_jv(1).source_name        := lv_source_name;
2810       ptr_jv(1).category_name      := lv_category_name;
2811       ptr_jv(1).ccid               := p_receiving_account_id;
2812       ptr_jv(1).entered_dr         := round(ln_debit, gn_currency_precision);
2813       ptr_jv(1).entered_cr         := round(ln_credit, gn_currency_precision);
2814       ptr_jv(1).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
2815       ptr_jv(1).accounting_date    := p_transaction_date;
2816       ptr_jv(1).reference_10       := lv_reference_10;
2817       ptr_jv(1).reference_23       := lv_reference_23;
2818       ptr_jv(1).reference_24       := lv_reference_24;
2819       ptr_jv(1).reference_25       := lv_reference_25;
2820       ptr_jv(1).reference_26       := lv_reference_26;
2821       ptr_jv(1).destination        := 'G';
2822       -- ptr_jv(1).reference_name     := ;
2823       ptr_jv(1).reference_id       := p_transaction_id;
2824       ptr_jv(1).non_rnd_entered_dr := ln_debit;
2825       ptr_jv(1).non_rnd_entered_cr := ln_credit;
2826       ptr_jv(1).account_name       := gv_inv_receiving;
2827       ptr_jv(1).summary_jv_flag    := 'Y';
2828 /*Bug 5527885 End*/
2829     end if;
2830 
2831   end if; /* Accounting Entry # 1. Receiving Account Id */
2832 
2833 
2834   /* Accounting Entry # 2 : AP Accrual Account Id. Non mandatory entry values may be 0*/
2835   p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12  */
2836 
2837   ln_credit := null;
2838   ln_debit  := null;
2839        Fnd_File.put_line(Fnd_File.LOG, 'p_ap_accrual_account:'||p_ap_accrual_account );
2840   if p_ap_accrual_account is not null then
2841 
2842     if ( (p_transaction_type = 'RETURN TO VENDOR')
2843           or
2844          (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RETURN TO VENDOR')
2845         )
2846     then
2847 
2848        p_codepath := jai_general_pkg.plot_codepath(13, p_codepath); /* 13  */
2849        ln_debit  := p_all_taxes -
2850                     ( p_tds_taxes             +
2851                       p_modvat_recovery_taxes +
2852                       p_cvd_taxes             +
2853                       p_add_cvd_taxes         + /*5228046 Additional cvd Enhancement*/
2854                       p_customs_taxes         +
2855                       p_third_party_taxes     +
2856                       p_cvd_edu_cess          +
2857           p_cvd_sh_edu_cess       +    /*Bug 5989740 bduvarag*/
2858                       p_customs_edu_cess      +
2859                       --Added by zhiwei for BOE ER  bug 11684111 begin
2860                       ----------------------------------
2861                       p_boe_other1 +
2862                       p_boe_other2 +
2863                       p_boe_other3 +
2864                       p_boe_other4 +
2865                       p_boe_other5 +
2866                       p_boe_surcharge_duty +
2867                       p_boe_add_customs +
2868                       ----------------------------------
2869                       --Added by zhiwei for BOE ER bug 11684111  end
2870                       p_customs_sh_edu_cess
2871                     );
2872        ln_credit := null;
2873 
2874        if  not p_account_service_interim then
2875          /* Separate Accounting for recoverable service tax not required */
2876          p_codepath := jai_general_pkg.plot_codepath(13.1, p_codepath); /* 13.1  */
2877          ln_debit :=  ln_debit - p_service_recoverable;
2878        end if;
2879 
2880 
2881     elsif p_receipt_source_code = 'CUSTOMER' then
2882       -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. if p_attribute_category  = 'INDIA RMA RECEIPT' then
2883 
2884       p_codepath := jai_general_pkg.plot_codepath(14, p_codepath); /* 14  */
2885       ln_debit  :=  null;
2886       ln_credit  := p_cvd_taxes + p_add_cvd_taxes /*5143906 Additional cvd Enhancement*/ + p_excise_tax + p_cvd_edu_cess+ p_cvd_sh_edu_cess /*Bug 5989740 bduvarag*/ + p_excise_edu_cess +p_excise_sh_edu_cess /*Bug 5989740 bduvarag*/;
2887 /* Replaced p_excise_edu_cess with p_excise_sh_edu_cess for bug# 8691046 */
2888 
2889     else
2890 
2891       p_codepath := jai_general_pkg.plot_codepath(15, p_codepath); /* 15  */
2892       ln_debit  :=  null;
2893       ln_credit  := p_all_taxes -
2894                    ( p_tds_taxes + p_modvat_recovery_taxes +
2895                      p_cvd_taxes + p_add_cvd_taxes /*5228046 Additional cvd Enhancement*/ +
2896                      p_customs_taxes +
2897                      p_cvd_edu_cess +
2898          p_cvd_sh_edu_cess +    /*Bug 5989740 bduvarag*/
2899                      p_customs_edu_cess +
2900                      --Added by zhiwei for BOE ER bug 11684111  begin
2901                      ---------------------------------
2902                      p_boe_other1 +
2903                      p_boe_other2 +
2904                      p_boe_other3 +
2905                      p_boe_other4 +
2906                      p_boe_other5 +
2907                      p_boe_surcharge_duty +
2908                      p_boe_add_customs +
2909                      ---------------------------------
2910                      --Added by zhiwei for BOE ER bug 11684111  end
2911                      p_customs_sh_edu_cess );
2912 
2913        if  not p_account_service_interim then
2914         /* Separate Accounting for recoverable service tax not required */
2915         p_codepath := jai_general_pkg.plot_codepath(15.1, p_codepath); /* 15.1  */
2916         ln_credit :=  ln_credit - p_service_recoverable;
2917            --start additions by vkaranam for bug#11935696
2918       if nvl(p_inclu_service_recoverable,0) <>0
2919       then
2920           ln_credit  := nvl(  ln_credit ,0)+nvl(p_inclu_service_recoverable,0) ;
2921 
2922       end if;
2923  --end additions by vkaranam for bug#11936596
2924        end if;
2925 
2926     end if;
2927 
2928            Fnd_File.put_line(Fnd_File.LOG, 'ln_debit:'||ln_debit );
2929             Fnd_File.put_line(Fnd_File.LOG, 'ln_credit:'||ln_credit );
2930     p_codepath := jai_general_pkg.plot_codepath(16, p_codepath); /* 16  */
2931     if ( nvl(ln_debit, 0) <> 0  or nvl(ln_credit, 0) <> 0 ) then
2932       p_codepath := jai_general_pkg.plot_codepath(17, p_codepath); /* 17  */
2933 
2934         Fnd_File.put_line(Fnd_File.LOG, 'Accounting for interorg payables Acc' );
2935 /*
2936       IF p_receipt_source_code = 'INVENTORY' THEN 6488406
2937         ln_inter_org_acct := p_interorg_payables_account;
2938   lv_acct_name      := gv_interorg_receiving;
2939       ELSE
2940         ln_inter_org_acct := p_ap_accrual_account;
2941   lv_acct_name      := gv_ap_accrual;
2942       END IF; */
2943 
2944       ptr_jv(2).line_num           := 2;
2945       ptr_jv(2).acct_type          := lv_acct_type;
2946       ptr_jv(2).acct_nature        := lv_acct_nature;
2947       ptr_jv(2).source_name        := lv_source_name;
2948       ptr_jv(2).category_name      := lv_category_name;
2949       ptr_jv(2).ccid               := p_ap_accrual_account;/*6488406*/
2950       ptr_jv(2).entered_dr         := round(ln_debit, gn_currency_precision);
2951       ptr_jv(2).entered_cr         := round(ln_credit, gn_currency_precision);
2952       ptr_jv(2).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
2953       ptr_jv(2).accounting_date    := p_transaction_date;
2954       ptr_jv(2).reference_10       := lv_reference_10;
2955       ptr_jv(2).reference_23       := lv_reference_23;
2956       ptr_jv(2).reference_24       := lv_reference_24;
2957       ptr_jv(2).reference_25       := lv_reference_25;
2958       ptr_jv(2).reference_26       := lv_reference_26;
2959       ptr_jv(2).destination        := 'G';
2960       -- ptr_jv(2).reference_name     := ;
2961       ptr_jv(2).reference_id       := p_transaction_id;
2962       ptr_jv(2).non_rnd_entered_dr := ln_debit;
2963       ptr_jv(2).non_rnd_entered_cr := ln_credit;
2964       ptr_jv(2).account_name       := gv_ap_accrual;/*6488406*/
2965       ptr_jv(2).summary_jv_flag    := 'Y';
2966 /*Bug 5527885 End*/
2967       /* Inserting into JAI_RCV_REP_ACCRUAL_T if no record is already inserted */
2968       p_codepath := jai_general_pkg.plot_codepath(18, p_codepath); /* 18  */
2969       open  c_ja_in_temp_po_accrual(p_transaction_id);
2970       fetch c_ja_in_temp_po_accrual into ln_ja_in_temp_po_accrual;
2971       close c_ja_in_temp_po_accrual;
2972 
2973       if nvl(ln_ja_in_temp_po_accrual, 0) = 0 then
2974         p_codepath := jai_general_pkg.plot_codepath(19, p_codepath); /* 19  */
2975         insert into JAI_RCV_REP_ACCRUAL_T
2976         (
2977           transaction_id,
2978           accrual_amount,
2979           -- Harshita, added the 4 parameters below for Bug 4762433
2980           created_by    ,
2981           creation_date ,
2982           last_updated_by,
2983           last_update_date,
2984           last_update_login
2985         )
2986         values
2987         (
2988           p_transaction_id,
2989           nvl(ln_credit, ln_debit) ,   /*bug 9319913*/
2990           fnd_global.user_id,
2991           sysdate,
2992           fnd_global.user_id,
2993           sysdate,
2994           fnd_global.login_id
2995         );
2996       end if;
2997 
2998     end if; /* (ln_debit is not 0/null or ln_credit is not 0/null) */
2999 
3000 
3001   end if; /* p_ap_accrual_account */
3002 
3003 
3004   /* Accounting Entry # 3 : BOE Accounting Entry. Non mandatory entry */
3005   p_codepath := jai_general_pkg.plot_codepath(21, p_codepath); /* 21  */
3006 
3007   ln_credit := null;
3008   ln_debit  := null;
3009 
3010   if ( (p_transaction_type = 'RECEIVE')
3011         or
3012        (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RECEIVE')
3013       )
3014   then
3015 
3016     p_codepath := jai_general_pkg.plot_codepath(22, p_codepath); /* 22  */
3017     --Comments by zhiwei for BOE ER bug 11684111  begin
3018     /*
3019     if   (p_cvd_taxes + p_add_cvd_taxes \*5228046 Additional cvd Enhancement*\
3020             + p_customs_taxes
3021       + p_cvd_edu_cess
3022       + p_cvd_sh_edu_cess  \*Bug 5989740 bduvarag*\
3023             + p_customs_edu_cess
3024             +p_customs_sh_edu_cess) <> 0 THEN
3025       p_codepath := jai_general_pkg.plot_codepath(23, p_codepath); \* 23  *\
3026       ln_debit    :=  null;
3027       ln_credit   :=  (p_cvd_taxes + p_add_cvd_taxes \*5228046 Additional cvd Enhancement*\
3028                      + p_customs_taxes
3029          + p_cvd_edu_cess
3030          +p_cvd_sh_edu_cess  \*Bug 5989740 bduvarag*\
3031               + p_customs_edu_cess
3032         +p_customs_sh_edu_cess);
3033 
3034       ptr_jv(3).line_num           := 3;
3035       ptr_jv(3).acct_type          := lv_acct_type;
3036       ptr_jv(3).acct_nature        := lv_acct_nature;
3037       ptr_jv(3).source_name        := lv_source_name;
3038       ptr_jv(3).category_name      := lv_category_name;
3039       ptr_jv(3).ccid               := p_boe_account_id;
3040       ptr_jv(3).entered_dr         := round(ln_debit, gn_currency_precision);
3041       ptr_jv(3).entered_cr         := round(ln_credit, gn_currency_precision);
3042       ptr_jv(3).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3043       ptr_jv(3).accounting_date    := p_transaction_date;
3044       ptr_jv(3).reference_10       := lv_reference_10;
3045       ptr_jv(3).reference_23       := lv_reference_23;
3046       ptr_jv(3).reference_24       := lv_reference_24;
3047       ptr_jv(3).reference_25       := lv_reference_25;
3048       ptr_jv(3).reference_26       := lv_reference_26;
3049       ptr_jv(3).destination        := 'G';
3050       -- ptr_jv(3).reference_name     := ;
3051       ptr_jv(3).reference_id       := p_transaction_id;
3052       ptr_jv(3).non_rnd_entered_dr := ln_debit;
3053       ptr_jv(3).non_rnd_entered_cr := ln_credit;
3054       ptr_jv(3).account_name       := gv_boe;
3055       ptr_jv(3).summary_jv_flag    := 'N';
3056 
3057       \*Bug 5527885*\
3058     end if;*/
3059     --Comments by zhiwei for BOE ER bug 11684111  end
3060     --Added by zhiwei for BOE ER bug 11684111  begin
3061     ------------------------------------------------------------------
3062     select  organization_id,
3063             location_id
3064     into    ln_organization_id,ln_location_id
3065     from    JAI_RCV_TRANSACTIONS
3066     where   transaction_id = p_transaction_id;
3067 
3068 
3069 
3070     if  p_cvd_taxes > 0 then
3071       p_codepath := jai_general_pkg.plot_codepath(23.01, p_codepath); /* 23.01  */
3072       ln_debit    :=  null;
3073       ln_credit   :=  p_cvd_taxes;
3074       ln_boe_account_id := jai_boe_general_pkg.get_boe_accounting(
3075                                               pv_tax_type_code   =>jai_constants.tax_type_cvd
3076                                              ,pv_account_type    =>'PAID_PAYABLES'
3077                                              ,pn_organization_id =>ln_organization_id
3078                                              ,pn_location_id     =>ln_location_id
3079                                              );
3080       Fnd_File.put_line(Fnd_File.LOG, ' Come in 7-> p_cvd_taxes account:'||ln_boe_account_id);
3081       Fnd_File.put_line(Fnd_File.LOG, ' Come in 7-> p_cvd_taxes amount:'||p_cvd_taxes);
3082 
3083 
3084       ptr_jv(7).line_num           := 7;
3085       ptr_jv(7).acct_type          := lv_acct_type;
3086       ptr_jv(7).acct_nature        := lv_acct_nature;
3087       ptr_jv(7).source_name        := lv_source_name;
3088       ptr_jv(7).category_name      := lv_category_name;
3089       ptr_jv(7).ccid               := ln_boe_account_id;
3090       ptr_jv(7).entered_dr         := round(ln_debit, gn_currency_precision);
3091       ptr_jv(7).entered_cr         := round(ln_credit, gn_currency_precision);
3092       ptr_jv(7).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3093       ptr_jv(7).accounting_date    := p_transaction_date;
3094       ptr_jv(7).reference_10       := lv_reference_10;
3095       ptr_jv(7).reference_23       := lv_reference_23;
3096       ptr_jv(7).reference_24       := lv_reference_24;
3097       ptr_jv(7).reference_25       := lv_reference_25;
3098       ptr_jv(7).reference_26       := lv_reference_26;
3099       ptr_jv(7).destination        := 'G';
3100       ptr_jv(7).reference_id       := p_transaction_id;
3101       ptr_jv(7).non_rnd_entered_dr := ln_debit;
3102       ptr_jv(7).non_rnd_entered_cr := ln_credit;
3103       ptr_jv(7).account_name       := gv_boe;
3104       ptr_jv(7).summary_jv_flag    := 'N';
3105     end if;
3106 
3107     if  p_add_cvd_taxes > 0 then
3108       p_codepath := jai_general_pkg.plot_codepath(23.02, p_codepath); /* 23.02  */
3109       ln_debit    :=  null;
3110       ln_credit   :=  p_add_cvd_taxes;
3111       ln_boe_account_id := jai_boe_general_pkg.get_boe_accounting(
3112                                               pv_tax_type_code   =>jai_constants.tax_type_add_cvd
3113                                              ,pv_account_type    =>'PAID_PAYABLES'
3114                                              ,pn_organization_id =>ln_organization_id
3115                                              ,pn_location_id     =>ln_location_id
3116                                              );
3117       Fnd_File.put_line(Fnd_File.LOG, ' Come in 8-> p_add_cvd_taxes account:'||ln_boe_account_id);
3118       Fnd_File.put_line(Fnd_File.LOG, ' Come in 8-> p_add_cvd_taxes amount:'||p_add_cvd_taxes);
3119 
3120 
3121       ptr_jv(8).line_num           := 8;
3122       ptr_jv(8).acct_type          := lv_acct_type;
3123       ptr_jv(8).acct_nature        := lv_acct_nature;
3124       ptr_jv(8).source_name        := lv_source_name;
3125       ptr_jv(8).category_name      := lv_category_name;
3126       ptr_jv(8).ccid               := ln_boe_account_id;
3127       ptr_jv(8).entered_dr         := round(ln_debit, gn_currency_precision);
3128       ptr_jv(8).entered_cr         := round(ln_credit, gn_currency_precision);
3129       ptr_jv(8).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3130       ptr_jv(8).accounting_date    := p_transaction_date;
3131       ptr_jv(8).reference_10       := lv_reference_10;
3132       ptr_jv(8).reference_23       := lv_reference_23;
3133       ptr_jv(8).reference_24       := lv_reference_24;
3134       ptr_jv(8).reference_25       := lv_reference_25;
3135       ptr_jv(8).reference_26       := lv_reference_26;
3136       ptr_jv(8).destination        := 'G';
3137       ptr_jv(8).reference_id       := p_transaction_id;
3138       ptr_jv(8).non_rnd_entered_dr := ln_debit;
3139       ptr_jv(8).non_rnd_entered_cr := ln_credit;
3140       ptr_jv(8).account_name       := gv_boe;
3141       ptr_jv(8).summary_jv_flag    := 'N';
3142     end if;
3143     if  p_customs_taxes > 0 then
3144       p_codepath := jai_general_pkg.plot_codepath(23.03, p_codepath); /* 23.03  */
3145       ln_debit    :=  null;
3146       ln_credit   :=  p_customs_taxes;
3147       ln_boe_account_id := jai_boe_general_pkg.get_boe_accounting(
3148                                               pv_tax_type_code   =>jai_constants.tax_type_customs
3149                                              ,pv_account_type    =>'PAID_PAYABLES'
3150                                              ,pn_organization_id =>ln_organization_id
3151                                              ,pn_location_id     =>ln_location_id
3152                                              );
3153       Fnd_File.put_line(Fnd_File.LOG, ' Come in 9-> p_customs_taxes account:'||ln_boe_account_id);
3154       Fnd_File.put_line(Fnd_File.LOG, ' Come in 9-> p_customs_taxes amount:'||p_customs_taxes);
3155 
3156       --ln_boe_account_id := 293920;
3157 
3158 
3159       ptr_jv(9).line_num           := 9;
3160       ptr_jv(9).acct_type          := lv_acct_type;
3161       ptr_jv(9).acct_nature        := lv_acct_nature;
3162       ptr_jv(9).source_name        := lv_source_name;
3163       ptr_jv(9).category_name      := lv_category_name;
3164       ptr_jv(9).ccid               := ln_boe_account_id;
3165       ptr_jv(9).entered_dr         := round(ln_debit, gn_currency_precision);
3166       ptr_jv(9).entered_cr         := round(ln_credit, gn_currency_precision);
3167       ptr_jv(9).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3168       ptr_jv(9).accounting_date    := p_transaction_date;
3169       ptr_jv(9).reference_10       := lv_reference_10;
3170       ptr_jv(9).reference_23       := lv_reference_23;
3171       ptr_jv(9).reference_24       := lv_reference_24;
3172       ptr_jv(9).reference_25       := lv_reference_25;
3173       ptr_jv(9).reference_26       := lv_reference_26;
3174       ptr_jv(9).destination        := 'G';
3175       ptr_jv(9).reference_id       := p_transaction_id;
3176       ptr_jv(9).non_rnd_entered_dr := ln_debit;
3177       ptr_jv(9).non_rnd_entered_cr := ln_credit;
3178       ptr_jv(9).account_name       := gv_boe;
3179       ptr_jv(9).summary_jv_flag    := 'N';
3180     end if;
3181     if  p_cvd_edu_cess > 0 then
3182       p_codepath := jai_general_pkg.plot_codepath(23.04, p_codepath); /* 23.04  */
3183       ln_debit    :=  null;
3184       ln_credit   :=  p_cvd_edu_cess;
3185       ln_boe_account_id := jai_boe_general_pkg.get_boe_accounting(
3186                                               pv_tax_type_code   =>jai_constants.tax_type_cvd_edu_cess
3187                                              ,pv_account_type    =>'PAID_PAYABLES'
3188                                              ,pn_organization_id =>ln_organization_id
3189                                              ,pn_location_id     =>ln_location_id
3190                                              );
3191       Fnd_File.put_line(Fnd_File.LOG, ' Come in 10-> p_cvd_edu_cess account:'||ln_boe_account_id);
3192       Fnd_File.put_line(Fnd_File.LOG, ' Come in 10-> p_cvd_edu_cess amount:'||p_cvd_edu_cess);
3193 
3194       --ln_boe_account_id := 293920;
3195 
3196       ptr_jv(10).line_num           := 10;
3197       ptr_jv(10).acct_type          := lv_acct_type;
3198       ptr_jv(10).acct_nature        := lv_acct_nature;
3199       ptr_jv(10).source_name        := lv_source_name;
3200       ptr_jv(10).category_name      := lv_category_name;
3201       ptr_jv(10).ccid               := ln_boe_account_id;
3202       ptr_jv(10).entered_dr         := round(ln_debit, gn_currency_precision);
3203       ptr_jv(10).entered_cr         := round(ln_credit, gn_currency_precision);
3204       ptr_jv(10).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3205       ptr_jv(10).accounting_date    := p_transaction_date;
3206       ptr_jv(10).reference_10       := lv_reference_10;
3207       ptr_jv(10).reference_23       := lv_reference_23;
3208       ptr_jv(10).reference_24       := lv_reference_24;
3209       ptr_jv(10).reference_25       := lv_reference_25;
3210       ptr_jv(10).reference_26       := lv_reference_26;
3211       ptr_jv(10).destination        := 'G';
3212       ptr_jv(10).reference_id       := p_transaction_id;
3213       ptr_jv(10).non_rnd_entered_dr := ln_debit;
3214       ptr_jv(10).non_rnd_entered_cr := ln_credit;
3215       ptr_jv(10).account_name       := gv_boe;
3216       ptr_jv(10).summary_jv_flag    := 'N';
3217     end if;
3218 
3219     if  p_cvd_sh_edu_cess > 0 then
3220       p_codepath := jai_general_pkg.plot_codepath(23.05, p_codepath); /* 23.05  */
3221       ln_debit    :=  null;
3222       ln_credit   :=  p_cvd_sh_edu_cess;
3223       ln_boe_account_id := jai_boe_general_pkg.get_boe_accounting(
3224                                               pv_tax_type_code   =>jai_constants.tax_type_sh_cvd_edu_cess
3225                                              ,pv_account_type    =>'PAID_PAYABLES'
3226                                              ,pn_organization_id =>ln_organization_id
3227                                              ,pn_location_id     =>ln_location_id
3228                                              );
3229 
3230       --ln_boe_account_id := 293920;
3231 
3232       Fnd_File.put_line(Fnd_File.LOG, ' Come in 11-> p_cvd_sh_edu_cess account:'||ln_boe_account_id);
3233       Fnd_File.put_line(Fnd_File.LOG, ' Come in 11-> p_cvd_sh_edu_cess amount:'||p_cvd_sh_edu_cess);
3234 
3235 
3236       ptr_jv(11).line_num           := 11;
3237       ptr_jv(11).acct_type          := lv_acct_type;
3238       ptr_jv(11).acct_nature        := lv_acct_nature;
3239       ptr_jv(11).source_name        := lv_source_name;
3240       ptr_jv(11).category_name      := lv_category_name;
3241       ptr_jv(11).ccid               := ln_boe_account_id;
3242       ptr_jv(11).entered_dr         := round(ln_debit, gn_currency_precision);
3243       ptr_jv(11).entered_cr         := round(ln_credit, gn_currency_precision);
3244       ptr_jv(11).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3245       ptr_jv(11).accounting_date    := p_transaction_date;
3246       ptr_jv(11).reference_10       := lv_reference_10;
3247       ptr_jv(11).reference_23       := lv_reference_23;
3248       ptr_jv(11).reference_24       := lv_reference_24;
3249       ptr_jv(11).reference_25       := lv_reference_25;
3250       ptr_jv(11).reference_26       := lv_reference_26;
3251       ptr_jv(11).destination        := 'G';
3252       ptr_jv(11).reference_id       := p_transaction_id;
3253       ptr_jv(11).non_rnd_entered_dr := ln_debit;
3254       ptr_jv(11).non_rnd_entered_cr := ln_credit;
3255       ptr_jv(11).account_name       := gv_boe;
3256       ptr_jv(11).summary_jv_flag    := 'N';
3257     end if;
3258     if  p_customs_edu_cess > 0 then
3259       p_codepath := jai_general_pkg.plot_codepath(23.06, p_codepath); /* 23.06  */
3260       ln_debit    :=  null;
3261       ln_credit   :=  p_customs_edu_cess;
3262       ln_boe_account_id := jai_boe_general_pkg.get_boe_accounting(
3263                                               pv_tax_type_code   =>jai_constants.tax_type_customs_edu_cess
3264                                              ,pv_account_type    =>'PAID_PAYABLES'
3265                                              ,pn_organization_id =>ln_organization_id
3266                                              ,pn_location_id     =>ln_location_id
3267                                              );
3268       Fnd_File.put_line(Fnd_File.LOG, ' Come in 12-> p_customs_edu_cess account:'||ln_boe_account_id);
3269       Fnd_File.put_line(Fnd_File.LOG, ' Come in 12-> p_customs_edu_cess amount:'||p_customs_edu_cess);
3270 
3271 
3272       ptr_jv(12).line_num           := 12;
3273       ptr_jv(12).acct_type          := lv_acct_type;
3274       ptr_jv(12).acct_nature        := lv_acct_nature;
3275       ptr_jv(12).source_name        := lv_source_name;
3276       ptr_jv(12).category_name      := lv_category_name;
3277       ptr_jv(12).ccid               := ln_boe_account_id;
3278       ptr_jv(12).entered_dr         := round(ln_debit, gn_currency_precision);
3279       ptr_jv(12).entered_cr         := round(ln_credit, gn_currency_precision);
3280       ptr_jv(12).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3281       ptr_jv(12).accounting_date    := p_transaction_date;
3282       ptr_jv(12).reference_10       := lv_reference_10;
3283       ptr_jv(12).reference_23       := lv_reference_23;
3284       ptr_jv(12).reference_24       := lv_reference_24;
3285       ptr_jv(12).reference_25       := lv_reference_25;
3286       ptr_jv(12).reference_26       := lv_reference_26;
3287       ptr_jv(12).destination        := 'G';
3288       ptr_jv(12).reference_id       := p_transaction_id;
3289       ptr_jv(12).non_rnd_entered_dr := ln_debit;
3290       ptr_jv(12).non_rnd_entered_cr := ln_credit;
3291       ptr_jv(12).account_name       := gv_boe;
3292       ptr_jv(12).summary_jv_flag    := 'N';
3293     end if;
3294     if  p_customs_sh_edu_cess > 0 then
3295       p_codepath := jai_general_pkg.plot_codepath(23.07, p_codepath); /* 23.07  */
3296       ln_debit    :=  null;
3297       ln_credit   :=  p_customs_sh_edu_cess;
3298       ln_boe_account_id := jai_boe_general_pkg.get_boe_accounting(
3299                                               pv_tax_type_code   =>jai_constants.tax_type_sh_customs_edu_Cess
3300                                              ,pv_account_type    =>'PAID_PAYABLES'
3301                                              ,pn_organization_id =>ln_organization_id
3302                                              ,pn_location_id     =>ln_location_id
3303                                              );
3304       Fnd_File.put_line(Fnd_File.LOG, ' Come in 13-> p_customs_sh_edu_cess account:'||ln_boe_account_id);
3305       Fnd_File.put_line(Fnd_File.LOG, ' Come in 13-> p_customs_sh_edu_cess amount:'||p_customs_sh_edu_cess);
3306       --ln_boe_account_id := 293920;
3307 
3308 
3309       ptr_jv(13).line_num           := 13;
3310       ptr_jv(13).acct_type          := lv_acct_type;
3311       ptr_jv(13).acct_nature        := lv_acct_nature;
3312       ptr_jv(13).source_name        := lv_source_name;
3313       ptr_jv(13).category_name      := lv_category_name;
3314       ptr_jv(13).ccid               := ln_boe_account_id;
3315       ptr_jv(13).entered_dr         := round(ln_debit, gn_currency_precision);
3316       ptr_jv(13).entered_cr         := round(ln_credit, gn_currency_precision);
3317       ptr_jv(13).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3318       ptr_jv(13).accounting_date    := p_transaction_date;
3319       ptr_jv(13).reference_10       := lv_reference_10;
3320       ptr_jv(13).reference_23       := lv_reference_23;
3321       ptr_jv(13).reference_24       := lv_reference_24;
3322       ptr_jv(13).reference_25       := lv_reference_25;
3323       ptr_jv(13).reference_26       := lv_reference_26;
3324       ptr_jv(13).destination        := 'G';
3325       ptr_jv(13).reference_id       := p_transaction_id;
3326       ptr_jv(13).non_rnd_entered_dr := ln_debit;
3327       ptr_jv(13).non_rnd_entered_cr := ln_credit;
3328       ptr_jv(13).account_name       := gv_boe;
3329       ptr_jv(13).summary_jv_flag    := 'N';
3330     end if;
3331     if  p_boe_other1 > 0 then
3332       p_codepath := jai_general_pkg.plot_codepath(23.08, p_codepath); /* 23.08  */
3333       ln_debit    :=  null;
3334       ln_credit   :=  p_boe_other1;
3335       ln_boe_account_id := jai_boe_general_pkg.get_boe_accounting(
3336                                               pv_tax_type_code   =>jai_constants.tax_type_boe_other1
3337                                              ,pv_account_type    =>'PAID_PAYABLES'
3338                                              ,pn_organization_id =>ln_organization_id
3339                                              ,pn_location_id     =>ln_location_id
3340                                              );
3341       Fnd_File.put_line(Fnd_File.LOG, ' Come in 14-> p_boe_other1 account:'||ln_boe_account_id);
3342       Fnd_File.put_line(Fnd_File.LOG, ' Come in 14-> p_boe_other1 amount:'||p_boe_other1);
3343       --ln_boe_account_id := 293920;
3344 
3345 
3346       ptr_jv(14).line_num           := 14;
3347       ptr_jv(14).acct_type          := lv_acct_type;
3348       ptr_jv(14).acct_nature        := lv_acct_nature;
3349       ptr_jv(14).source_name        := lv_source_name;
3350       ptr_jv(14).category_name      := lv_category_name;
3351       ptr_jv(14).ccid               := ln_boe_account_id;
3352       ptr_jv(14).entered_dr         := round(ln_debit, gn_currency_precision);
3353       ptr_jv(14).entered_cr         := round(ln_credit, gn_currency_precision);
3354       ptr_jv(14).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3355       ptr_jv(14).accounting_date    := p_transaction_date;
3356       ptr_jv(14).reference_10       := lv_reference_10;
3357       ptr_jv(14).reference_23       := lv_reference_23;
3358       ptr_jv(14).reference_24       := lv_reference_24;
3359       ptr_jv(14).reference_25       := lv_reference_25;
3360       ptr_jv(14).reference_26       := lv_reference_26;
3361       ptr_jv(14).destination        := 'G';
3362       ptr_jv(14).reference_id       := p_transaction_id;
3363       ptr_jv(14).non_rnd_entered_dr := ln_debit;
3364       ptr_jv(14).non_rnd_entered_cr := ln_credit;
3365       ptr_jv(14).account_name       := gv_boe;
3366       ptr_jv(14).summary_jv_flag    := 'N';
3367     end if;
3368 
3369     if  p_boe_other2 > 0 then
3370       p_codepath := jai_general_pkg.plot_codepath(23.09, p_codepath); /* 23.09  */
3371       ln_debit    :=  null;
3372       ln_credit   :=  p_boe_other2;
3373       ln_boe_account_id := jai_boe_general_pkg.get_boe_accounting(pv_tax_type_code   =>jai_constants.tax_type_boe_other2
3374                                              ,pv_account_type    =>'PAID_PAYABLES'
3375                                              ,pn_organization_id =>ln_organization_id
3376                                              ,pn_location_id     =>ln_location_id
3377                                              );
3378       Fnd_File.put_line(Fnd_File.LOG, ' Come in 15-> p_boe_other2 account:'||ln_boe_account_id);
3379       Fnd_File.put_line(Fnd_File.LOG, ' Come in 15-> p_boe_other2 amount:'||p_boe_other2);
3380 
3381 
3382       ptr_jv(15).line_num           := 15;
3383       ptr_jv(15).acct_type          := lv_acct_type;
3384       ptr_jv(15).acct_nature        := lv_acct_nature;
3385       ptr_jv(15).source_name        := lv_source_name;
3386       ptr_jv(15).category_name      := lv_category_name;
3387       ptr_jv(15).ccid               := ln_boe_account_id;
3388       ptr_jv(15).entered_dr         := round(ln_debit, gn_currency_precision);
3389       ptr_jv(15).entered_cr         := round(ln_credit, gn_currency_precision);
3390       ptr_jv(15).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3391       ptr_jv(15).accounting_date    := p_transaction_date;
3392       ptr_jv(15).reference_10       := lv_reference_10;
3393       ptr_jv(15).reference_23       := lv_reference_23;
3394       ptr_jv(15).reference_24       := lv_reference_24;
3395       ptr_jv(15).reference_25       := lv_reference_25;
3396       ptr_jv(15).reference_26       := lv_reference_26;
3397       ptr_jv(15).destination        := 'G';
3398       ptr_jv(15).reference_id       := p_transaction_id;
3399       ptr_jv(15).non_rnd_entered_dr := ln_debit;
3400       ptr_jv(15).non_rnd_entered_cr := ln_credit;
3401       ptr_jv(15).account_name       := gv_boe;
3402       ptr_jv(15).summary_jv_flag    := 'N';
3403     end if;
3404 
3405     if  p_boe_other3 > 0 then
3406       p_codepath := jai_general_pkg.plot_codepath(23.10, p_codepath); /* 23.10  */
3407       ln_debit    :=  null;
3408       ln_credit   :=  p_boe_other3;
3409       ln_boe_account_id := jai_boe_general_pkg.get_boe_accounting(
3410                                               pv_tax_type_code   =>jai_constants.tax_type_boe_other3
3411                                              ,pv_account_type    =>'PAID_PAYABLES'
3412                                              ,pn_organization_id =>ln_organization_id
3413                                              ,pn_location_id     =>ln_location_id
3414                                              );
3415       Fnd_File.put_line(Fnd_File.LOG, ' Come in 16-> p_boe_other3 account:'||ln_boe_account_id);
3416       Fnd_File.put_line(Fnd_File.LOG, ' Come in 16-> p_boe_other3 amount:'||p_boe_other3);
3417 
3418 
3419       ptr_jv(16).line_num           := 16;
3420       ptr_jv(16).acct_type          := lv_acct_type;
3421       ptr_jv(16).acct_nature        := lv_acct_nature;
3422       ptr_jv(16).source_name        := lv_source_name;
3423       ptr_jv(16).category_name      := lv_category_name;
3424       ptr_jv(16).ccid               := ln_boe_account_id;
3425       ptr_jv(16).entered_dr         := round(ln_debit, gn_currency_precision);
3426       ptr_jv(16).entered_cr         := round(ln_credit, gn_currency_precision);
3427       ptr_jv(16).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3428       ptr_jv(16).accounting_date    := p_transaction_date;
3429       ptr_jv(16).reference_10       := lv_reference_10;
3430       ptr_jv(16).reference_23       := lv_reference_23;
3431       ptr_jv(16).reference_24       := lv_reference_24;
3432       ptr_jv(16).reference_25       := lv_reference_25;
3433       ptr_jv(16).reference_26       := lv_reference_26;
3434       ptr_jv(16).destination        := 'G';
3435       ptr_jv(16).reference_id       := p_transaction_id;
3436       ptr_jv(16).non_rnd_entered_dr := ln_debit;
3437       ptr_jv(16).non_rnd_entered_cr := ln_credit;
3438       ptr_jv(16).account_name       := gv_boe;
3439       ptr_jv(16).summary_jv_flag    := 'N';
3440     end if;
3441 
3442     if  p_boe_other4 > 0 then
3443       p_codepath := jai_general_pkg.plot_codepath(23.11, p_codepath); /* 23.11  */
3444       ln_debit    :=  null;
3445       ln_credit   :=  p_boe_other4;
3446       ln_boe_account_id := jai_boe_general_pkg.get_boe_accounting(
3447                                               pv_tax_type_code   =>jai_constants.tax_type_boe_other4
3448                                              ,pv_account_type    =>'PAID_PAYABLES'
3449                                              ,pn_organization_id =>ln_organization_id
3450                                              ,pn_location_id     =>ln_location_id
3451                                              );
3452       Fnd_File.put_line(Fnd_File.LOG, ' Come in 17-> p_boe_other4 account:'||ln_boe_account_id);
3453       Fnd_File.put_line(Fnd_File.LOG, ' Come in 17-> p_boe_other4 amount:'||p_boe_other4);
3454 
3455 
3456       ptr_jv(17).line_num           := 17;
3457       ptr_jv(17).acct_type          := lv_acct_type;
3458       ptr_jv(17).acct_nature        := lv_acct_nature;
3459       ptr_jv(17).source_name        := lv_source_name;
3460       ptr_jv(17).category_name      := lv_category_name;
3461       ptr_jv(17).ccid               := ln_boe_account_id;
3462       ptr_jv(17).entered_dr         := round(ln_debit, gn_currency_precision);
3463       ptr_jv(17).entered_cr         := round(ln_credit, gn_currency_precision);
3464       ptr_jv(17).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3465       ptr_jv(17).accounting_date    := p_transaction_date;
3466       ptr_jv(17).reference_10       := lv_reference_10;
3467       ptr_jv(17).reference_23       := lv_reference_23;
3468       ptr_jv(17).reference_24       := lv_reference_24;
3469       ptr_jv(17).reference_25       := lv_reference_25;
3470       ptr_jv(17).reference_26       := lv_reference_26;
3471       ptr_jv(17).destination        := 'G';
3472       ptr_jv(17).reference_id       := p_transaction_id;
3473       ptr_jv(17).non_rnd_entered_dr := ln_debit;
3474       ptr_jv(17).non_rnd_entered_cr := ln_credit;
3475       ptr_jv(17).account_name       := gv_boe;
3476       ptr_jv(17).summary_jv_flag    := 'N';
3477     end if;
3478 
3479     if  p_boe_other5 > 0 then
3480       p_codepath := jai_general_pkg.plot_codepath(23.12, p_codepath); /* 23.12  */
3481       ln_debit    :=  null;
3482       ln_credit   :=  p_boe_other5;
3483       ln_boe_account_id := jai_boe_general_pkg.get_boe_accounting(
3484                                               pv_tax_type_code   =>jai_constants.tax_type_boe_other5
3485                                              ,pv_account_type    =>'PAID_PAYABLES'
3486                                              ,pn_organization_id =>ln_organization_id
3487                                              ,pn_location_id     =>ln_location_id
3488                                              );
3489       Fnd_File.put_line(Fnd_File.LOG, ' Come in 18-> p_boe_other5 account:'||ln_boe_account_id);
3490       Fnd_File.put_line(Fnd_File.LOG, ' Come in 18-> p_boe_other5 amount:'||p_boe_other5);
3491       --ln_boe_account_id := 293920;
3492 
3493 
3494       ptr_jv(18).line_num           := 18;
3495       ptr_jv(18).acct_type          := lv_acct_type;
3496       ptr_jv(18).acct_nature        := lv_acct_nature;
3497       ptr_jv(18).source_name        := lv_source_name;
3498       ptr_jv(18).category_name      := lv_category_name;
3499       ptr_jv(18).ccid               := ln_boe_account_id;
3500       ptr_jv(18).entered_dr         := round(ln_debit, gn_currency_precision);
3501       ptr_jv(18).entered_cr         := round(ln_credit, gn_currency_precision);
3502       ptr_jv(18).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3503       ptr_jv(18).accounting_date    := p_transaction_date;
3504       ptr_jv(18).reference_10       := lv_reference_10;
3505       ptr_jv(18).reference_23       := lv_reference_23;
3506       ptr_jv(18).reference_24       := lv_reference_24;
3507       ptr_jv(18).reference_25       := lv_reference_25;
3508       ptr_jv(18).reference_26       := lv_reference_26;
3509       ptr_jv(18).destination        := 'G';
3510       ptr_jv(18).reference_id       := p_transaction_id;
3511       ptr_jv(18).non_rnd_entered_dr := ln_debit;
3512       ptr_jv(18).non_rnd_entered_cr := ln_credit;
3513       ptr_jv(18).account_name       := gv_boe;
3514       ptr_jv(18).summary_jv_flag    := 'N';
3515     end if;
3516 
3517     if  p_boe_surcharge_duty > 0 then
3518       p_codepath := jai_general_pkg.plot_codepath(23.13, p_codepath); /* 23.13  */
3519       ln_debit    :=  null;
3520       ln_credit   :=  p_boe_surcharge_duty;
3521       ln_boe_account_id := jai_boe_general_pkg.get_boe_accounting(
3522                                               pv_tax_type_code   =>jai_constants.tax_type_boe_surcharge_duty
3523                                              ,pv_account_type    =>'PAID_PAYABLES'
3524                                              ,pn_organization_id =>ln_organization_id
3525                                              ,pn_location_id     =>ln_location_id
3526                                              );
3527       Fnd_File.put_line(Fnd_File.LOG, ' Come in 19-> p_boe_surcharge_duty account:'||ln_boe_account_id);
3528       Fnd_File.put_line(Fnd_File.LOG, ' Come in 19-> p_boe_surcharge_duty amount:'||p_boe_surcharge_duty);
3529 
3530 
3531       ptr_jv(19).line_num           := 19;
3532       ptr_jv(19).acct_type          := lv_acct_type;
3533       ptr_jv(19).acct_nature        := lv_acct_nature;
3534       ptr_jv(19).source_name        := lv_source_name;
3535       ptr_jv(19).category_name      := lv_category_name;
3536       ptr_jv(19).ccid               := ln_boe_account_id;
3537       ptr_jv(19).entered_dr         := round(ln_debit, gn_currency_precision);
3538       ptr_jv(19).entered_cr         := round(ln_credit, gn_currency_precision);
3539       ptr_jv(19).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3540       ptr_jv(19).accounting_date    := p_transaction_date;
3541       ptr_jv(19).reference_10       := lv_reference_10;
3542       ptr_jv(19).reference_23       := lv_reference_23;
3543       ptr_jv(19).reference_24       := lv_reference_24;
3544       ptr_jv(19).reference_25       := lv_reference_25;
3545       ptr_jv(19).reference_26       := lv_reference_26;
3546       ptr_jv(19).destination        := 'G';
3547       ptr_jv(19).reference_id       := p_transaction_id;
3548       ptr_jv(19).non_rnd_entered_dr := ln_debit;
3549       ptr_jv(19).non_rnd_entered_cr := ln_credit;
3550       ptr_jv(19).account_name       := gv_boe;
3551       ptr_jv(19).summary_jv_flag    := 'N';
3552     end if;
3553 
3554 
3555     if  p_boe_add_customs > 0 then
3556       p_codepath := jai_general_pkg.plot_codepath(23.14, p_codepath); /* 23.14  */
3557       ln_debit    :=  null;
3558       ln_credit   :=  p_boe_add_customs;
3559       ln_boe_account_id := jai_boe_general_pkg.get_boe_accounting(
3560                                               pv_tax_type_code   =>jai_constants.tax_type_boe_add_customs
3561                                              ,pv_account_type    =>'PAID_PAYABLES'
3562                                              ,pn_organization_id =>ln_organization_id
3563                                              ,pn_location_id     =>ln_location_id
3564                                              );
3565       Fnd_File.put_line(Fnd_File.LOG, ' Come in 20-> p_boe_surcharge_duty account:'||ln_boe_account_id);
3566       Fnd_File.put_line(Fnd_File.LOG, ' Come in 20-> p_boe_surcharge_duty amount:'||p_boe_surcharge_duty);
3567 
3568 
3569       ptr_jv(20).line_num           := 20;
3570       ptr_jv(20).acct_type          := lv_acct_type;
3571       ptr_jv(20).acct_nature        := lv_acct_nature;
3572       ptr_jv(20).source_name        := lv_source_name;
3573       ptr_jv(20).category_name      := lv_category_name;
3574       ptr_jv(20).ccid               := ln_boe_account_id;
3575       ptr_jv(20).entered_dr         := round(ln_debit, gn_currency_precision);
3576       ptr_jv(20).entered_cr         := round(ln_credit, gn_currency_precision);
3577       ptr_jv(20).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3578       ptr_jv(20).accounting_date    := p_transaction_date;
3579       ptr_jv(20).reference_10       := lv_reference_10;
3580       ptr_jv(20).reference_23       := lv_reference_23;
3581       ptr_jv(20).reference_24       := lv_reference_24;
3582       ptr_jv(20).reference_25       := lv_reference_25;
3583       ptr_jv(20).reference_26       := lv_reference_26;
3584       ptr_jv(20).destination        := 'G';
3585       ptr_jv(20).reference_id       := p_transaction_id;
3586       ptr_jv(20).non_rnd_entered_dr := ln_debit;
3587       ptr_jv(20).non_rnd_entered_cr := ln_credit;
3588       ptr_jv(20).account_name       := gv_boe;
3589       ptr_jv(20).summary_jv_flag    := 'N';
3590     end if;
3591 
3592     --------------------------------------------------------------------------------
3593     --Added by zhiwei for BOE ER bug 11684111  end
3594   end if; /* BOE Accounting Entry */
3595 
3596 
3597 
3598   /* Accounting Entry # 4 : RTV expense Accounting Entry, non mandatory entry */
3599   p_codepath := jai_general_pkg.plot_codepath(24, p_codepath); /* 24  */
3600 
3601   ln_credit := null;
3602   ln_debit  := null;
3603 
3604   if ( (p_transaction_type = 'RETURN TO VENDOR')
3605         or
3606        (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RETURN TO VENDOR')
3607       )
3608   then
3609 
3610     p_codepath := jai_general_pkg.plot_codepath(25, p_codepath); /* 25  */
3611 IF  ( p_cvd_taxes     +
3612           p_add_cvd_taxes + /*5228046 Additional cvd Enhancement*/
3613           p_customs_taxes +
3614           p_cvd_edu_cess  +
3615           p_cvd_sh_edu_cess  +   /*Bug 5989740 bduvarag*/
3616           p_customs_edu_cess +
3617           p_customs_sh_edu_cess +/*Bug 5989740 bduvarag*/
3618           p_third_party_taxes
3619         ) <> 0 THEN
3620 
3621 
3622       p_codepath := jai_general_pkg.plot_codepath(26, p_codepath); /* 26  */
3623       ln_debit    :=  ( p_cvd_taxes        + p_add_cvd_taxes /*5228046 Additional cvd Enhancement*/ +
3624                         p_customs_taxes    + p_cvd_edu_cess +
3625                         p_cvd_sh_edu_cess  /*Bug 5989740 bduvarag*/
3626                         +p_customs_edu_cess + p_customs_sh_edu_cess    + p_third_party_taxes
3627                       );
3628       ln_credit   :=  null;
3629       /*Bug 5527885 Start*/
3630 
3631       ptr_jv(4).line_num           := 4;
3632       ptr_jv(4).acct_type          := lv_acct_type;
3633       ptr_jv(4).acct_nature        := lv_acct_nature;
3634       ptr_jv(4).source_name        := lv_source_name;
3635       ptr_jv(4).category_name      := lv_category_name;
3636       ptr_jv(4).ccid               := p_rtv_expense_account_id;
3637       ptr_jv(4).entered_dr         := round(ln_debit, gn_currency_precision);
3638       ptr_jv(4).entered_cr         := round(ln_credit, gn_currency_precision);
3639       ptr_jv(4).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3640       ptr_jv(4).accounting_date    := p_transaction_date;
3641       ptr_jv(4).reference_10       := lv_reference_10;
3642       ptr_jv(4).reference_23       := lv_reference_23;
3643       ptr_jv(4).reference_24       := lv_reference_24;
3644       ptr_jv(4).reference_25       := lv_reference_25;
3645       ptr_jv(4).reference_26       := lv_reference_26;
3646       ptr_jv(4).destination        := 'G';
3647       -- ptr_jv(4).reference_name     := ;
3648       ptr_jv(4).reference_id       := p_transaction_id;
3649       ptr_jv(4).non_rnd_entered_dr := ln_debit;
3650       ptr_jv(4).non_rnd_entered_cr := ln_credit;
3651       ptr_jv(4).account_name       := gv_rtv_expense;
3652       ptr_jv(4).summary_jv_flag    := 'N';
3653 /*Bug 5527885*/
3654     end if;
3655 
3656   end if; /* RTV Expense Accounting Entry */
3657 
3658 
3659   p_codepath := jai_general_pkg.plot_codepath(27, p_codepath); /* 27  */
3660   ln_credit := null;
3661   ln_debit  := null;
3662 
3663   Fnd_File.put_line(Fnd_File.LOG, ' p_trading_to_trading_iso :' || p_trading_to_trading_iso );
3664    Fnd_File.put_line(Fnd_File.LOG, 'p_receipt_source_code:'||p_receipt_source_code );
3665   --bug 6030615 added inventory
3666   if p_receipt_source_code IN ('INTERNAL ORDER', 'INVENTORY')-- and  p_trading_to_trading_iso = 'N'
3667   then /* Bug#4171469 */
3668 
3669     p_codepath := jai_general_pkg.plot_codepath(28, p_codepath); /* 28  */
3670     Fnd_File.put_line(Fnd_File.LOG, 'p_intransit_type:'||p_intransit_type );
3671     Fnd_File.put_line(Fnd_File.LOG, 'p_fob_point:'||p_fob_point );
3672     if ( (p_intransit_type = 2) and  (p_fob_point = 2) ) then
3673       /* 2 extra accounting entries need to be passed */
3674 
3675       p_codepath := jai_general_pkg.plot_codepath(29, p_codepath); /* 29  */
3676       IF  p_all_taxes -
3677         ( p_tds_taxes + p_modvat_recovery_taxes +
3678           p_cvd_taxes + p_add_cvd_taxes /*5228046 Additional cvd Enhancement*/ +
3679           p_customs_taxes + p_cvd_edu_cess +p_cvd_sh_edu_cess     /*Bug 5989740 bduvarag*/
3680           + p_customs_edu_cess
3681           +p_customs_sh_edu_cess) <> 0
3682       THEN
3683 
3684         p_codepath := jai_general_pkg.plot_codepath(30, p_codepath); /* 30  */
3685         /* Accounting Entry # 5 : Debit InterOrg Receivable */
3686 
3687         ln_debit  :=  p_all_taxes -
3688                      ( p_tds_taxes + p_modvat_recovery_taxes + p_cvd_taxes + p_add_cvd_taxes /*5228046 Additional cvd Enhancement*/ + p_customs_taxes +
3689                        p_cvd_edu_cess + p_cvd_sh_edu_cess +    /*Bug 5989740 bduvarag*/
3690                        p_customs_edu_cess +
3691                        p_customs_sh_edu_cess);
3692 
3693         ln_credit  := null;
3694     Fnd_File.put_line(Fnd_File.LOG, 'ln_debit:'||ln_debit );
3695         Fnd_File.put_line(Fnd_File.LOG, 'Accounting for Inter Receibles Acc' );
3696         Fnd_File.put_line(Fnd_File.LOG, 'p_interorg_receivables_account:'||p_interorg_receivables_account );
3697 /*Bug 5527885 Start*/
3698 
3699         ptr_jv(5).line_num           := 5;
3700         ptr_jv(5).acct_type          := lv_acct_type;
3701         ptr_jv(5).acct_nature        := lv_acct_nature;
3702         ptr_jv(5).source_name        := lv_source_name;
3703         ptr_jv(5).category_name      := lv_category_name;
3704         ptr_jv(5).ccid               := p_interorg_receivables_account;
3705         ptr_jv(5).entered_dr         := round(ln_debit, gn_currency_precision);
3706         ptr_jv(5).entered_cr         := round(ln_credit, gn_currency_precision);
3707         ptr_jv(5).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3708         ptr_jv(5).accounting_date    := p_transaction_date;
3709         ptr_jv(5).reference_10       := lv_reference_10;
3710         ptr_jv(5).reference_23       := lv_reference_23;
3711         ptr_jv(5).reference_24       := lv_reference_24;
3712         ptr_jv(5).reference_25       := lv_reference_25;
3713         ptr_jv(5).reference_26       := lv_reference_26;
3714         ptr_jv(5).destination        := 'G';
3715         -- ptr_jv(5).reference_name     := ;
3716         ptr_jv(5).reference_id       := p_transaction_id;
3717         ptr_jv(5).non_rnd_entered_dr := ln_debit;
3718         ptr_jv(5).non_rnd_entered_cr := ln_credit;
3719         ptr_jv(5).account_name       := gv_iso_receivables;
3720         ptr_jv(5).summary_jv_flag    := 'N';
3721 
3722         /* Accounting Entry # 6 : Credit in-transit inventory */
3723 
3724         p_codepath := jai_general_pkg.plot_codepath(31, p_codepath); /* 31  */
3725         ln_credit  := ln_debit;
3726         ln_debit  :=  null;
3727 
3728     Fnd_File.put_line(Fnd_File.LOG, 'ln_credit:'||ln_credit );
3729         Fnd_File.put_line(Fnd_File.LOG, 'Accounting for p_intransit_inv_account Acc' );
3730         Fnd_File.put_line(Fnd_File.LOG, 'p_intransit_inv_account:'||p_interorg_receivables_account );
3731 
3732         ptr_jv(6).line_num           := 6;
3733         ptr_jv(6).acct_type          := lv_acct_type;
3734         ptr_jv(6).acct_nature        := lv_acct_nature;
3735         ptr_jv(6).source_name        := lv_source_name;
3736         ptr_jv(6).category_name      := lv_category_name;
3737         ptr_jv(6).ccid               := p_intransit_inv_account;
3738         ptr_jv(6).entered_dr         := round(ln_debit, gn_currency_precision);
3739         ptr_jv(6).entered_cr         := round(ln_credit, gn_currency_precision);
3740         ptr_jv(6).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3741         ptr_jv(6).accounting_date    := p_transaction_date;
3742         ptr_jv(6).reference_10       := lv_reference_10;
3743         ptr_jv(6).reference_23       := lv_reference_23;
3744         ptr_jv(6).reference_24       := lv_reference_24;
3745         ptr_jv(6).reference_25       := lv_reference_25;
3746         ptr_jv(6).reference_26       := lv_reference_26;
3747         ptr_jv(6).destination        := 'G';
3748         -- ptr_jv(6).reference_name     := ;
3749         ptr_jv(6).reference_id       := p_transaction_id;
3750         ptr_jv(6).non_rnd_entered_dr := ln_debit;
3751         ptr_jv(6).non_rnd_entered_cr := ln_credit;
3752         ptr_jv(6).account_name       := gv_iso_intransit_inv;
3753         ptr_jv(6).summary_jv_flag    := 'N';
3754 /*Bug 5527885 End*/
3755 
3756       end if; /* all - tds - mr - cvd - customs */
3757 
3758     end if; /* is  (p_intransit_type = 2) and  (p_fob_point = 2) */
3759 
3760   end if; /* p_receipt_source_code = 'INTERNAL ORDER'  */
3761 
3762 
3763   << exit_from_procedure >>
3764   p_codepath := jai_general_pkg.plot_codepath(32, p_codepath, null, 'END'); /* 32  */
3765 
3766   if p_process_flag is null then
3767     p_process_flag    := 'Y';
3768   end if;
3769 
3770   if p_debug = 'Y' then
3771     Fnd_File.put_line(Fnd_File.LOG, '  Code Path :' || p_codepath );
3772     Fnd_File.put_line(Fnd_File.LOG, '  ** End of procedure jai_rcv_rcv_rtv_pkg.post_entries **  ');
3773   end if;
3774 
3775   return;
3776 
3777 exception
3778   when others then
3779     p_process_flag    := 'E';
3780     p_process_message := 'RECEIVE_RTV_PKG.post_entries:' || sqlerrm;
3781     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
3782     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END');
3783     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
3784     return;
3785 
3786 end post_entries;
3787 
3788 /****************************** End post_entries ******************************/
3789 
3790 
3791 /****************************** Start regime_tax_accounting_interim ******************************/
3792   procedure regime_tax_accounting_interim
3793   (
3794     p_transaction_id                            in                number,
3795     p_shipment_line_id                          in                number,
3796     p_organization_id                           in                number,
3797     p_location_id                               in                number,
3798     p_transaction_type                          in                varchar2,
3799     p_currency_conversion_rate                  in                number,
3800     p_parent_transaction_type                   in                varchar2,
3801     -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. p_attribute_category                        in                varchar2,
3802     p_receipt_source_code                       in                varchar2,
3803     p_transaction_date                          in                date,
3804     p_receipt_num                               in                varchar2,
3805     p_regime_code                               in                varchar2,
3806     ptr_jv                                      in OUT NOCOPY JOURNAL_LINES,  /* 5527885 */
3807     p_simulation                                in                varchar2,
3808     p_debug                                     in                varchar2,  -- default 'N', File.Sql.35
3809     p_process_flag                              out     nocopy    varchar2,
3810     p_process_message                           out     nocopy    varchar2,
3811     p_codepath                                  in out  nocopy    varchar2
3812   )
3813   is
3814 
3815   ln_credit                     number;
3816   ln_debit                      number;
3817   /* File.Sql.35 by Brathod */
3818   lv_source_name                varchar2(20); -- := 'Purchasing India'; -- Harshita . modified the size from 15 to 20 for Bug 4762433
3819   lv_category_name              varchar2(15); -- := 'Receiving India';
3820   lv_acct_nature                varchar2(15); -- := 'Receiving';
3821   lv_acct_type                  varchar2(15);  /* Regular or Reversal*/
3822 
3823   lv_reference_10               varchar2(240);
3824   lv_reference_23               varchar2(240);-- := 'jai_rcv_rcv_rtv_pkg.regime_tax_accounting_interim';
3825   lv_reference_24               varchar2(240);-- := 'rcv_transactions';
3826   lv_reference_25               varchar2(240);-- :=  'transaction_id';
3827   /* End of File.Sql.35 by Brathod */
3828 
3829   lv_reference_26               varchar2(240);
3830   ln_tax_apportion_factor       number;
3831   ln_regime_recovery_interim   number;
3832 
3833   cursor c_jai_regimes (p_regime_code varchar2)is
3834     select regime_id
3835     from   JAI_RGM_DEFINITIONS
3836     where  regime_code = p_regime_code;
3837 
3838 --added tax_type in cursor definition for bug # 6807023
3839   cursor c_ja_in_tax_amt_by_account
3840   (
3841     cp_shipment_line_id             number,
3842     cp_regime_id                    number,
3843     cp_organization_type            varchar2,
3844     cp_organization_id              number,
3845     cp_location_id                  number,
3846     cp_account_name                 varchar2,
3847     cp_func_curr                    varchar2,
3848     cp_tax_apportion_factor         number,
3849     cp_currency_conversion_rate     number
3850   ) is
3851     select  jai_cmn_rgm_recording_pkg.get_account
3852             (
3853                cp_regime_id,
3854                cp_organization_type,
3855                cp_organization_id,
3856                cp_location_id, /* Location Not for service tax */
3857                jrtl.tax_type,
3858                cp_account_name
3859             )  interim_regime_account,
3860             sum
3861             (
3862              ROUND( --rchandan for bug#6971526
3863               decode
3864               (
3865                 nvl(jrtl.currency , cp_func_curr), cp_func_curr,
3866                 nvl(jrtl.tax_amount,0)* cp_tax_apportion_factor,
3867                 nvl(jrtl.tax_amount,0)* cp_tax_apportion_factor * cp_currency_conversion_rate
3868                ) * --rchandan for bug#6971526 start
3869                (decode(jtc.mod_cr_percentage,100,1,jtc.mod_cr_percentage/100)
3870                )
3871                , NVL(jtc.rounding_factor, 0)
3872                 )--rchandan for bug#6971526 end
3873               ) tax_amount_by_account
3874     from    JAI_RCV_LINE_TAXES jrtl,
3875             JAI_CMN_TAXES_ALL jtc
3876     where   jrtl.shipment_line_id = cp_shipment_line_id
3877     and     jrtl.tax_id = jtc.tax_id
3878     and     ( nvl(jtc.mod_cr_percentage,0) between 0 and 100 ) --rchandan for bug#6971526
3879     and     nvl(jrtl.modvat_flag, 'N') = 'Y'
3880     and     jrtl.tax_type in
3881             (
3882              select jrr.attribute_code
3883              from   JAI_RGM_DEFINITIONS jr,
3884                     JAI_RGM_REGISTRATIONS jrr
3885              where  jr.regime_id = jrr.regime_id
3886              and    jr.regime_code = p_regime_code
3887              and    jrr.registration_type = jai_constants.regn_type_tax_types
3888             )
3889       AND   (NVL(jtc.inclusive_tax_flag,'N')='N' --add by eric for inclusive tax,picking the exclusive tax only
3890              OR (NVL(jtc.inclusive_tax_flag,'N')='Y'
3891                  AND
3892                  jtc.tax_type = 'VALUE ADDED TAX')) /*Bug 14185068 - Added OR clause as Regime Interim Account must be done for VAT Inclusive Tax*/
3893       AND   NVL(jtc.reverse_charge_flag,'N')='N'  -- added by Qiong for reverse charge bug#16001407
3894       --add by eric for inclusive tax,picking the exclusive tax only
3895     group by  jai_cmn_rgm_recording_pkg.get_account
3896             (
3897                cp_regime_id,
3898                cp_organization_type,
3899                cp_organization_id,
3900                cp_location_id, /* Location Not for service tax */
3901                jrtl.tax_type,
3902                cp_account_name
3903             ) ;
3904 
3905   /*commented this cursor for bug#6030615,as part of performance issue check
3906   cursor c_org_organization_definitions(cp_organization_id  number) is
3907     select operating_unit
3908     from   org_organization_definitions
3909     where  organization_id = cp_organization_id;*/
3910     --added the below cursor for bug#6030615
3911     CURSOR c_get_ou (cp_organization_id  number)is
3912     SELECT org_information3 FROM HR_ORGANIZATION_INFORMATION
3913     WHERE organization_id=cp_organization_id
3914     AND ORG_INFORMATION_CONTEXT='Accounting Information';
3915 
3916   r_org_organization_definitions    c_get_ou%rowtype;
3917   r_jai_regimes                     c_jai_regimes%rowtype;
3918   lv_organization_type              varchar2(2);
3919   ln_organization_id                number;
3920   ln_location_id                    number;
3921   l_jv_line_num_generator           number; /*Bug 5527885*/
3922 begin
3923 
3924   /* File.Sql.35 by Brathod */
3925   lv_source_name                := 'Purchasing India';
3926   lv_category_name              := 'Receiving India';
3927   lv_acct_nature                := 'Receiving';
3928   lv_reference_23               := 'jai_rcv_rcv_rtv_pkg.regime_tax_accounting_interim';
3929   lv_reference_24               := 'rcv_transactions';
3930   lv_reference_25               :=  'transaction_id';
3931   /* End of File.Sql.35 by Brathod */
3932 
3933 
3934   if p_debug = 'Y' then
3935     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.regime_tax_accounting_interim **');
3936   end if;
3937 
3938   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.regime_tax_accounting_interim', 'START'); /* 1  */
3939   /* Set varaiable values for accounting entries with GL link */
3940   if ( (p_transaction_type = 'RETURN TO VENDOR')
3941         or
3942        (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RETURN TO VENDOR')
3943       )
3944   then
3945     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2  */
3946     lv_acct_type := 'REVERSAL';
3947   else
3948     p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3  */
3949     lv_acct_type := 'REGULAR';
3950   end if;
3951 
3952   p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4  */
3953   lv_reference_10 :=  p_regime_code||' Regime. India Local Receiving Entry for Receipt Number ' || p_receipt_num ||
3954                       ', for Transaction Type ' || p_transaction_type ;
3955 
3956   if p_transaction_type = 'CORRECT' then
3957     p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5  */
3958     lv_reference_10 := lv_reference_10 || ' of type ' || p_parent_transaction_type;
3959   end if;
3960 
3961   lv_reference_26 :=  to_char(p_transaction_id);
3962 
3963   ln_tax_apportion_factor := jai_rcv_trx_processing_pkg.get_apportion_factor(p_transaction_id);
3964 
3965   open  c_jai_regimes(p_regime_code);
3966   fetch c_jai_regimes into r_jai_regimes;
3967   close c_jai_regimes;
3968 
3969   if  p_regime_code = jai_constants.service_regime then
3970 
3971     p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6  */
3972     Fnd_File.put_line(Fnd_File.LOG, 'In Service Regime ');
3973    lv_organization_type := jai_constants.orgn_type_io;
3974    ln_organization_id  := p_organization_id;
3975    ln_location_id := p_location_id;
3976    l_jv_line_num_generator := 61;  /*added for bug 7699476*/
3977    -- added by nprashar  for Bug 6807023
3978    Fnd_File.put_line(Fnd_File.LOG, 'In Service Regime lv_organization_type =' ||lv_organization_type||' ln_organization_id='||p_organization_id||'ln_location_id='||p_location_id);
3979 
3980   elsif p_regime_code = jai_constants.vat_regime then
3981 
3982       p_codepath := jai_general_pkg.plot_codepath(6.1, p_codepath); /* 6.1  */
3983       lv_organization_type := jai_constants.orgn_type_io;
3984       ln_organization_id  := p_organization_id;
3985       ln_location_id := p_location_id;
3986     l_jv_line_num_generator := 41;/*Bug 5527885*/
3987   end if;
3988   /* Loop through Taxes of Service/VAT Regime by interim service/vat account
3989      of tax type and  pass the accounting entries  */
3990   p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7  */
3991 
3992   for cur_rec in
3993     c_ja_in_tax_amt_by_account
3994       (
3995         p_shipment_line_id,
3996         r_jai_regimes.regime_id,
3997         lv_organization_type,
3998         ln_organization_id,
3999         ln_location_id,
4000         jai_constants.recovery_interim,
4001         jai_rcv_trx_processing_pkg.gv_func_curr,
4002         ln_tax_apportion_factor,
4003         p_currency_conversion_rate
4004       )
4005   loop
4006     ln_regime_recovery_interim := cur_rec.interim_regime_account;
4007 
4008     if ln_regime_recovery_interim is null then
4009       p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8  */
4010       p_process_flag    := 'E';
4011       p_process_message :=
4012       'RECEIVE_RTV_PKG.service_tax_accounting: Interim Service/vat tax recovery account not defined for some tax type';
4013       goto   exit_from_procedure;
4014     end if;
4015 
4016     if ( (p_transaction_type = 'RETURN TO VENDOR')
4017           or
4018          (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RETURN TO VENDOR')
4019         )
4020     then
4021 
4022        p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9  */
4023        ln_debit  := null;
4024        ln_credit := cur_rec.tax_amount_by_account;  /* Service/Vat */
4025 
4026     else
4027 
4028       p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10  */
4029       ln_debit  := cur_rec.tax_amount_by_account;
4030       ln_credit := null;
4031 
4032     end if;
4033 
4034     p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11  */
4035 
4036     --if (ln_debit is not null or ln_credit is not null) then
4037     --commented the above and added the below by Ramananda for Bug#4514461
4038     if (NVL(ln_debit,0) <> 0 OR NVL(ln_credit,0) <> 0) then
4039       p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12  */
4040       /* procedure to populate gl inetrface, JAI_RCV_JOURNAL_ENTRIES and receiving subledger */
4041 /*Bug 5527885 Start*/
4042 /*
4043       if p_debug = 'Y' then
4044         Fnd_File.put_line(Fnd_File.LOG, ' Call to -> jai_rcv_accounting_pkg.process_transaction');
4045       end if;
4046 
4047 
4048 
4049       jai_rcv_accounting_pkg.process_transaction
4050       (
4051       p_transaction_id            =>    p_transaction_id,
4052       p_acct_type                 =>    lv_acct_type,
4053       p_acct_nature               =>    lv_acct_nature,
4054       p_source_name               =>    lv_source_name,
4055       p_category_name             =>    lv_category_name,
4056       p_code_combination_id       =>    ln_regime_recovery_interim,
4057       p_entered_dr                =>    ln_debit,
4058       p_entered_cr                =>    ln_credit,
4059       p_currency_code             =>    jai_rcv_trx_processing_pkg.gv_func_curr,
4060       p_accounting_date           =>    p_transaction_date,
4061       p_reference_10              =>    lv_reference_10,
4062       p_reference_23              =>    lv_reference_23,
4063       p_reference_24              =>    lv_reference_24,
4064       p_reference_25              =>    lv_reference_25,
4065       p_reference_26              =>    lv_reference_26,
4066       p_destination               =>    'G',
4067       p_simulate_flag             =>    p_simulation,
4068       p_codepath                  =>    p_codepath,
4069       p_process_status            =>    p_process_flag,
4070       p_process_message           =>    P_process_message
4071       );
4072 */
4073       ptr_jv(l_jv_line_num_generator).line_num           := l_jv_line_num_generator;
4074       ptr_jv(l_jv_line_num_generator).acct_type          := lv_acct_type;
4075       ptr_jv(l_jv_line_num_generator).acct_nature        := lv_acct_nature;
4076       ptr_jv(l_jv_line_num_generator).source_name        := lv_source_name;
4077       ptr_jv(l_jv_line_num_generator).category_name      := lv_category_name;
4078       ptr_jv(l_jv_line_num_generator).ccid               := ln_regime_recovery_interim;
4079       ptr_jv(l_jv_line_num_generator).entered_dr         := round(ln_debit, gn_currency_precision);
4080       ptr_jv(l_jv_line_num_generator).entered_cr         := round(ln_credit, gn_currency_precision);
4081       ptr_jv(l_jv_line_num_generator).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
4082       ptr_jv(l_jv_line_num_generator).accounting_date    := p_transaction_date;
4083       ptr_jv(l_jv_line_num_generator).reference_10       := lv_reference_10;
4084       ptr_jv(l_jv_line_num_generator).reference_23       := lv_reference_23;
4085       ptr_jv(l_jv_line_num_generator).reference_24       := lv_reference_24;
4086       ptr_jv(l_jv_line_num_generator).reference_25       := lv_reference_25;
4087       ptr_jv(l_jv_line_num_generator).reference_26       := lv_reference_26;
4088       ptr_jv(l_jv_line_num_generator).destination        := 'G';
4089       -- ptr_jv(l_jv_line_num_generator).reference_name     := ;
4090       ptr_jv(l_jv_line_num_generator).reference_id       := p_transaction_id;
4091       ptr_jv(l_jv_line_num_generator).non_rnd_entered_dr := ln_debit;
4092       ptr_jv(l_jv_line_num_generator).non_rnd_entered_cr := ln_credit;
4093       ptr_jv(l_jv_line_num_generator).summary_jv_flag    := 'N';
4094       if p_regime_code = jai_constants.service_regime then
4095         ptr_jv(l_jv_line_num_generator).account_name := gv_service_interim;
4096       elsif p_regime_code = jai_constants.vat_regime then
4097         ptr_jv(l_jv_line_num_generator).account_name := gv_vat_interim;
4098       else
4099         ptr_jv(l_jv_line_num_generator).account_name := gv_regime_interim;
4100       end if;
4101       l_jv_line_num_generator := l_jv_line_num_generator + 1;
4102       /*Bug 5527885 End*/
4103     end if;
4104 
4105 
4106   end loop;
4107 
4108 
4109   << exit_from_procedure >>
4110   p_codepath := jai_general_pkg.plot_codepath(32, p_codepath, null, 'END'); /* 32  */
4111 
4112   if p_process_flag is null then
4113     p_process_flag    := 'Y';
4114   end if;
4115 
4116   if p_debug = 'Y' then
4117     Fnd_File.put_line(Fnd_File.LOG, '  Code Path :' || p_codepath );
4118     Fnd_File.put_line(Fnd_File.LOG, '  ** End of procedure jai_rcv_rcv_rtv_pkg.regime_tax_accounting_interim **  ');
4119   end if;
4120 
4121   return;
4122 
4123 exception
4124   when others then
4125     p_process_flag    := 'E';
4126     p_process_message := 'RECEIVE_RTV_PKG.regime_tax_accounting_interim:' || sqlerrm;
4127     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
4128     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END');
4129     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
4130     return;
4131 
4132 end regime_tax_accounting_interim;
4133 /****************************** End service_tax_accounting ******************************/
4134 
4135 end jai_rcv_rcv_rtv_pkg;