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.21.12010000.4 2009/01/23 11:37:46 srjayara 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 Dependency Section
223 ========== =======
224 
225 Date      Version    Bug         Remarks
226 --------- -------   ----------  -------------------------------------------------------------
227 6-sep-04  115.0     ER#3848010  This is a part of correction ER.
228 
229 28-jan-05 115.1     Er#4239736  This is a Service + Cess Solution.
230 
231 19-mar-05 115.4     ER#4245089  VAT Solution
232 10-may-05 116.1     ER#4346453  DFF Elimination Enh.
233 ----------------------------------------------------------------------------------------- */
234 /*Bug 5527885 Start*/
235 gn_currency_precision number;
236 gv_inv_receiving      constant  varchar2(30) := 'INVENTORY RECEIVING';
237 gv_ap_accrual         constant  varchar2(30) := 'AP ACCRUAL';
238 gv_boe                constant  varchar2(30) := 'BOE';
239 gv_rtv_expense        constant  varchar2(30) := 'RTV EXPENSE';
240 gv_iso_receivables    constant  varchar2(30) := 'ISO RECEIVABLES';
241 gv_iso_intransit_inv  constant  varchar2(30) := 'ISO INTRANSIT INVENTORY';
242 gv_vat_interim        constant  varchar2(30) := 'VAT INTERIM';
243 gv_service_interim    constant  varchar2(30) := 'SERVICE INTERIM';
244 gv_regime_interim     constant  varchar2(30) := 'REGIME INTERIM';
245 gv_credit             constant  varchar2(30) := 'CREDIT';
246 gv_debit              constant  varchar2(30) := 'DEBIT';
247 /*Bug 5527885 End*/
248 
249 /****************************** Start process_transaction  ****************************/
250 
251 
252   procedure process_transaction
253   (
254     p_transaction_id                          in                 number,
255     p_simulation                              in                 varchar2,  -- default 'N', File.Sql.35
256     p_debug                                   in                 varchar2,  -- default 'Y', File.Sql.35
257     p_process_flag                            out      nocopy    varchar2,
258     p_process_message                         out      nocopy    varchar2,
259     p_codepath                                in out   nocopy    varchar2
260   )is
261 
262   cursor c_ja_in_rcv_transactions(cp_transaction_id in number) is
263     select  organization_id,
264             location_id,
265             transaction_type,
266             parent_transaction_type,
267             currency_conversion_rate,
268             transaction_date,
269             parent_transaction_id,
270             inventory_item_id,
271             inv_item_flag /* Service */
272     from    JAI_RCV_TRANSACTIONS
273     where   transaction_id = cp_transaction_id;
274 
275   cursor    c_rcv_transactions(cp_transaction_id in number) is
276     select  shipment_header_id,
277             shipment_line_id,
278             po_distribution_id,
279             po_line_location_id,
280             -- attribute5, Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh.
281             vendor_id
282             -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. , upper(attribute_category) attribute_category
283             -- , source_document_code
284             -- , decode(source_document_code, 'RMA', jai_rcv_trx_processing_pkg.india_rma_receipt,
285             --                                      jai_rcv_trx_processing_pkg.india_receipt) attribute_category
286     from    rcv_transactions
287     where   transaction_id = cp_transaction_id;
288 
289   cursor    c_rcv_shipment_lines(cp_shipment_line_id number) is
290     select  from_organization_id,
291             to_organization_id
292     from    rcv_shipment_lines
293     where   shipment_line_id = cp_shipment_line_id;
294 
295   cursor    c_rcv_shipment_headers(cp_shipment_header_id number) is
296     select  upper(receipt_source_code) receipt_source_code,
297             receipt_num
298     from    rcv_shipment_headers
299     where   shipment_header_id = cp_shipment_header_id;
300 
301 
302   r_ja_in_rcv_transactions            c_ja_in_rcv_transactions%rowtype;
303   r_rcv_transactions                  c_rcv_transactions%rowtype;
304   r_rcv_shipment_lines                c_rcv_shipment_lines%rowtype;
305   r_rcv_shipment_headers              c_rcv_shipment_headers%rowtype;
306 
307   ln_boe_account_id                   number;
308   ln_rtv_expense_account_id           number;
309   ln_excise_expense_account           number;
310   ln_excise_rcvble_account            number;
311   ln_receiving_account_id             number;
312   ln_ap_accrual_account               number;
313   ln_po_accrual_account_id            number;
314   ln_interorg_payables_account        number;
315   ln_intransit_inv_account            number;
316   ln_interorg_receivables_accnt       number;
317   ln_intransit_type                   number;
318   ln_fob_point                        number;
319 
320   ln_all_taxes                        number;
321   ln_tds_taxes                        number;
322   ln_modvat_recovery_taxes            number;
323   ln_cvd_taxes                        number;
324   ln_add_cvd_taxes                    number;/*5228046 Additional cvd Enhancement*/
325   ln_customs_taxes                    number;
326   ln_third_party_taxes                number;
327   ln_excise_tax                       number;
328   ln_service_not_recoverable          number; /* Service */
329   ln_service_recoverable              number; /* Service */
330 
331   /* two variables added by Vijay Shankar for Bug#4250236(4245089). VAT Impl. */
332   ln_vat_not_recoverable              number;
333   ln_vat_recoverable                  number;
334 
335   --lv_accounting_method_option         ap_system_parameters_all.accounting_method_option%type;  /* Service */
336   --commented the above by Sanjikum for Bug#4474501
337   lv_accrue_on_receipt_flag           po_distributions_all.accrue_on_receipt_flag%type;
338   ln_excise_edu_cess                  number; /* Educational Cess */
339   ln_excise_sh_edu_cess               number; /*Bug 5989740 bduvarag*/
340   ln_cvd_edu_cess                     number; /* Educational Cess */
341   ln_cvd_sh_edu_cess                  number; /*Bug 5989740 bduvarag*/
342   ln_customs_edu_cess                 number; /* Educational Cess */
343   ln_customs_sh_edu_cess              number; /*Bug 5989740 bduvarag*/
344 
345   lv_temp                             varchar2(50);
346 
347   lb_account_service_interim          boolean; /* Service */
348 
349   lv_trading_to_trading_iso           varchar2(1); /* Bug#4171469 */
350 /*Bug 5527885 STart*/
351 tr_jv                     JOURNAL_LINES;
352   ln_jv_num_of_max_rec      number;
353   ln_max_jv_abs_amt         number;
354   ln_max_jv_amt_type        varchar2(30);
355   ln_diff_amt_between_dr_cr number;
356 
357   ln_tmp_dr_amt number;
358   ln_tmp_cr_amt number;
359   ln_cum_dr_amt number;
360   ln_cum_cr_amt number;
361 
362    v_rounding_diff_from	number;
363   v_rounding_diff_to	number;
364   v_line_count		number;
365   /*Bug 5527885 End*/
366 begin
367 
368   -- this is to identify the path in SQL TRACE file if any problem occured
369   SELECT 'jai_rcv_rcv_rtv_pkg-'||p_transaction_id INTO lv_temp FROM DUAL;
370 
371   if p_debug = 'Y' then
372     Fnd_File.put_line(Fnd_File.LOG, '**** Start of procedure jai_rcv_rcv_rtv_pkg.process_transaction ****');
373   end if;
374 
375   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.process_transaction', 'START'); /* 1 */
376 
377   open c_rcv_transactions(p_transaction_id);
378   fetch c_rcv_transactions into r_rcv_transactions;
379   close c_rcv_transactions;
380 
381   p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
382   open c_ja_in_rcv_transactions(p_transaction_id);
383   fetch c_ja_in_rcv_transactions into r_ja_in_rcv_transactions;
384   close c_ja_in_rcv_transactions;
385 
386   p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
387   open c_rcv_shipment_headers(r_rcv_transactions.shipment_header_id);
388   fetch c_rcv_shipment_headers into r_rcv_shipment_headers;
389   close c_rcv_shipment_headers;
390 
391   p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
392   open c_rcv_shipment_lines(r_rcv_transactions.shipment_line_id);
393   fetch c_rcv_shipment_lines into r_rcv_shipment_lines;
394   close c_rcv_shipment_lines;
395 
396   if p_debug = 'Y' then
397     Fnd_File.put_line(Fnd_File.LOG, ' Call to -> get_accounts');
398  --   Fnd_File.put_line(Fnd_File.LOG, ' Code Path :' || p_codepath );/*Bug 5527885*/
399   end if;
400 
401   /* Get the Details for service tax interim accounting and check if it is needed */
402   p_codepath := jai_general_pkg.plot_codepath(4.11, p_codepath); /* 4.11 */
403   /*lv_accounting_method_option :=
404   jai_general_pkg.get_accounting_method
405   (
406     p_org_id            =>    null,
407     p_organization_id   =>    r_ja_in_rcv_transactions.organization_id,
408     p_sob_id            =>    null
409   );*/
410   --commented the above by Sanjikum for Bug#4474501
411 
412   p_codepath := jai_general_pkg.plot_codepath(4.12, p_codepath); /* 4.12 */
413   lv_accrue_on_receipt_flag :=
414   jai_rcv_trx_processing_pkg.get_accrue_on_receipt
415   (p_po_distribution_id =>   r_rcv_transactions.po_distribution_id,
416   -- added by Vijay Shankar for Bug#4215402
417   p_po_line_location_id =>   r_rcv_transactions.po_line_location_id
418   );
419 
420 
421   p_codepath := jai_general_pkg.plot_codepath(4.13, p_codepath); /* 4.13 */
422   /*if  ( (lv_accrue_on_receipt_flag = 'N')
423           or
424           (lv_accounting_method_option = 'Cash' and
425            nvl(r_ja_in_rcv_transactions.inv_item_flag, 'N') = 'N'
426           )
427         )*/
428   --commented the above and added the below for Bug#4474501
429   if  lv_accrue_on_receipt_flag = 'N'
430 
431   then
432     p_codepath := jai_general_pkg.plot_codepath(4.14, p_codepath); /* 4.14 */
433     lb_account_service_interim := false;
434   else
435     p_codepath := jai_general_pkg.plot_codepath(4.15, p_codepath); /* 4.15 */
436     lb_account_service_interim := true;
437   end if;
438 /*Bug 5527885 Start*/
439  gn_currency_precision :=
440       jai_general_pkg.get_currency_precision(r_ja_in_rcv_transactions.organization_id);
441   if gn_currency_precision is null then
442     p_process_flag := 'E';
443     p_process_message := 'Currency Precision is null. Organization:'||r_ja_in_rcv_transactions.organization_id;
444     goto exit_from_procedure;
445   end if;
446 /*Bug 5527885 End*/
447 
448   p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
449   get_accounts
450   (
451     p_organization_id                =>    r_ja_in_rcv_transactions.organization_id,
452     p_location_id                    =>    r_ja_in_rcv_transactions.location_id,
453     p_receipt_source_code            =>    r_rcv_shipment_headers.receipt_source_code,
454     p_from_organization_id           =>    r_rcv_shipment_lines.from_organization_id,
455     p_to_organization_id             =>    r_rcv_shipment_lines.to_organization_id ,
456     p_po_distribution_id             =>    r_rcv_transactions.po_distribution_id,
457     p_po_line_location_id            =>    r_rcv_transactions.po_line_location_id,
458     /** OUT parameters **/
459     p_boe_account_id                 =>    ln_boe_account_id,
460     p_rtv_expense_account_id         =>    ln_rtv_expense_account_id,
461     p_excise_expense_account         =>    ln_excise_expense_account,
462     p_excise_rcvble_account          =>    ln_excise_rcvble_account,
463     p_receiving_account_id           =>    ln_receiving_account_id,
464     p_ap_accrual_account             =>    ln_ap_accrual_account,
465     p_po_accrual_account_id          =>    ln_po_accrual_account_id,
466     p_interorg_payables_account      =>    ln_interorg_payables_account,
467     p_intransit_inv_account          =>    ln_intransit_inv_account,
468     p_interorg_receivables_account   =>    ln_interorg_receivables_accnt,
469     p_intransit_type                 =>    ln_intransit_type,
470     p_fob_point                      =>    ln_fob_point,
471     p_trading_to_trading_iso         =>    lv_trading_to_trading_iso,  /* Bug#4171469 */
472     p_process_flag                   =>    p_process_flag,
473     p_process_message                =>    p_process_message,
474     p_debug                          =>    p_debug,
475     p_codepath                       =>    p_codepath
476    );
477 
478   if p_process_flag <> 'Y' then
479     /* get_accounts procedure has hit an error, cannot continue processing */
480     goto exit_from_procedure;
481   end if;
482 
483 
484   if p_debug = 'Y' then
485     Fnd_File.put_line(Fnd_File.LOG, ' Call to -> get_tax_breakup');
486 --    Fnd_File.put_line(Fnd_File.LOG, ' Code Path :' || p_codepath );/*Bug 5527885*/
487   end if;
488 
489   p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
490   get_tax_breakup
491   (
492     p_transaction_id                 =>    p_transaction_id,
493     p_shipment_line_id               =>    r_rcv_transactions.shipment_line_id,
494     p_currency_conversion_rate       =>    r_ja_in_rcv_transactions.currency_conversion_rate,
495     p_po_vendor_id                   =>    r_rcv_transactions.vendor_id,
496     p_all_taxes                      =>    ln_all_taxes,
497     p_tds_taxes                      =>    ln_tds_taxes ,
498     p_modvat_recovery_taxes          =>    ln_modvat_recovery_taxes,
499     p_cvd_taxes                      =>    ln_cvd_taxes,
500     p_add_cvd_taxes                  =>    ln_add_cvd_taxes,/*5228046 Additional cvd Enhancement*/
501     p_customs_taxes                  =>    ln_customs_taxes,
502     p_third_party_taxes              =>    ln_third_party_taxes,
503     p_excise_tax                     =>    ln_excise_tax,
504     p_service_recoverable            =>    ln_service_recoverable,
505     p_service_not_recoverable        =>    ln_service_not_recoverable,
506     p_vat_recoverable                =>    ln_vat_recoverable,
507     p_vat_not_recoverable            =>    ln_vat_not_recoverable,
508     p_excise_edu_cess                =>    ln_excise_edu_cess,
509     p_excise_sh_edu_cess             =>    ln_excise_sh_edu_cess,/*Bug 5989740 bduvarag*/
510     p_cvd_edu_cess                   =>    ln_cvd_edu_cess,
511     p_cvd_sh_edu_cess                =>    ln_cvd_sh_edu_cess,/*Bug 5989740 bduvarag*/
512     p_customs_edu_cess               =>    ln_customs_edu_cess,
513     p_customs_sh_edu_cess            =>    ln_customs_sh_edu_cess,/*Bug 5989740 bduvarag*/
514     p_process_flag                   =>    p_process_flag,
515     p_process_message                =>    p_process_message,
516     p_debug                          =>    p_debug,
517     p_codepath                       =>    p_codepath
518   );
519 
520   if p_process_flag <> 'Y' then
521     /* get_tax_breakup procedure has hit an error, cannot continue processing */
522     goto exit_from_procedure;
523   end if;
524 
525 
526   if p_debug = 'Y' then
527     Fnd_File.put_line(Fnd_File.LOG, ' Call to -> validate_transaction_tax_accnt');
528 --    Fnd_File.put_line(Fnd_File.LOG, ' Code Path :' || p_codepath );/*Bug 5527885*/
529   end if;
530 
531   p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
532 
533   validate_transaction_tax_accnt
534   (
535     p_transaction_type               =>    r_ja_in_rcv_transactions.transaction_type,
536     p_parent_transaction_type        =>    r_ja_in_rcv_transactions.parent_transaction_type,
537     -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. p_attribute_category             =>    r_rcv_transactions.attribute_category,
538     p_receipt_source_code            =>    r_rcv_shipment_headers.receipt_source_code,
539     p_boe_account_id                 =>    ln_boe_account_id,
540     p_rtv_expense_account_id         =>    ln_rtv_expense_account_id,
541     p_excise_expense_account         =>    ln_excise_expense_account,
542     p_excise_rcvble_account          =>    ln_excise_rcvble_account,
543     p_receiving_account_id           =>    ln_receiving_account_id,
544     p_ap_accrual_account             =>    ln_ap_accrual_account,
545     p_po_accrual_account_id          =>    ln_po_accrual_account_id,
546     p_interorg_payables_account      =>    ln_interorg_payables_account,
547     p_intransit_inv_account          =>    ln_intransit_inv_account,
548     p_interorg_receivables_account   =>    ln_interorg_receivables_accnt,
549     p_intransit_type                 =>    ln_intransit_type,
550     p_fob_point                      =>    ln_fob_point,
551     p_cvd_taxes                      =>    ln_cvd_taxes,
552     p_add_cvd_taxes                  =>    ln_add_cvd_taxes,/*5228046 Additional cvd Enhancement*/
553     p_customs_taxes                  =>    ln_customs_taxes,
554     p_third_party_taxes              =>    ln_third_party_taxes,
555     p_excise_tax                     =>    ln_excise_tax,
556     p_trading_to_trading_iso         =>    lv_trading_to_trading_iso,  /* Bug#4171469 */
557     p_process_flag                   =>    p_process_flag,
558     p_process_message                =>    p_process_message,
559     p_debug                          =>    p_debug,
560     p_codepath                       =>    p_codepath
561   );
562 
563   if p_process_flag <> 'Y' then
564     /* validate_transaction_tax_accnt procedure has hit an error, cannot continue processing */
565     goto exit_from_procedure;
566   end if;
567 
568   if p_debug = 'Y' then
569     Fnd_File.put_line(Fnd_File.LOG, ' Call to -> apply_relieve_boe');
570 --    Fnd_File.put_line(Fnd_File.LOG, ' Code Path :' || p_codepath );/*Bug 5527885*/
571   end if;
572 
573   p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
574 
575   apply_relieve_boe
576   (
577     p_transaction_id                =>     p_transaction_id,
578     p_transaction_type              =>     r_ja_in_rcv_transactions.transaction_type,
579     p_parent_transaction_id         =>     r_ja_in_rcv_transactions.parent_transaction_id,
580     p_parent_transaction_type       =>     r_ja_in_rcv_transactions.parent_transaction_type,
581     p_shipment_line_id              =>     r_rcv_transactions.shipment_line_id,
582     p_shipment_header_id            =>     r_rcv_transactions.shipment_header_id,
583     p_organization_id               =>     r_ja_in_rcv_transactions.organization_id,
584     p_inventory_item_id             =>     r_ja_in_rcv_transactions.inventory_item_id,
585     p_cvd_taxes                     =>     ln_cvd_taxes,
586     p_add_cvd_taxes                  =>    ln_add_cvd_taxes,/*5228046 Additional cvd Enhancement*/
587     p_customs_taxes                 =>     ln_customs_taxes,
588     p_cvd_edu_cess                  =>     ln_cvd_edu_cess,     /* Educational Cess */
589     p_cvd_sh_edu_cess               =>     ln_cvd_sh_edu_cess, /*Bug 5989740 bduvarag*/
590     p_customs_edu_cess              =>     ln_customs_edu_cess, /* Educational Cess */
591     p_customs_sh_edu_cess           =>     ln_customs_sh_edu_cess,/*Bug 5989740 bduvarag*/
592     p_simulation                    =>     p_simulation,
593     p_process_flag                  =>     p_process_flag,
594     p_process_message               =>     p_process_message,
595     p_debug                         =>     p_debug,
596     p_codepath                      =>     p_codepath
597   );
598 
599   if p_process_flag <> 'Y' then
600     /* apply_relieve_boe procedure has hit an error, cannot continue processing */
601     goto exit_from_procedure;
602   end if;
603 
604   if p_debug = 'Y' then
605     Fnd_File.put_line(Fnd_File.LOG, ' Call to -> post_entries');
606 --    Fnd_File.put_line(Fnd_File.LOG, ' Code Path :' || p_codepath );/*Bug 5527885*/
607   end if;
608       Fnd_File.put_line(Fnd_File.LOG, ' p_transaction_id:'||p_transaction_id);
609       Fnd_File.put_line(Fnd_File.LOG, ' ln_receiving_account_id:'||ln_receiving_account_id);
610       Fnd_File.put_line(Fnd_File.LOG, ' ln_ap_accrual_account:'||ln_ap_accrual_account);
611       Fnd_File.put_line(Fnd_File.LOG, ' ln_intransit_inv_account:'||ln_intransit_inv_account);
612       Fnd_File.put_line(Fnd_File.LOG, ' ln_interorg_receivables_accnt:'||ln_interorg_receivables_accnt);
613       Fnd_File.put_line(Fnd_File.LOG, ' p_interorg_payables_account:'||ln_interorg_payables_account);
614 
615 
616   p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9 */
617   post_entries
618   (
619     p_transaction_id                 =>    p_transaction_id,
620     p_transaction_type               =>    r_ja_in_rcv_transactions.transaction_type,
621     p_parent_transaction_type        =>    r_ja_in_rcv_transactions.parent_transaction_type,
622     -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. p_attribute_category             =>    r_rcv_transactions.attribute_category,
623     p_receipt_source_code            =>    r_rcv_shipment_headers.receipt_source_code,
624     p_transaction_date               =>    r_ja_in_rcv_transactions.transaction_date,
625     p_receipt_num                    =>    r_rcv_shipment_headers.receipt_num,
626     p_receiving_account_id           =>    ln_receiving_account_id,
627     p_ap_accrual_account             =>    ln_ap_accrual_account,
628     p_boe_account_id                 =>    ln_boe_account_id,
629     p_rtv_expense_account_id         =>    ln_rtv_expense_account_id,
630     p_intransit_type                 =>    ln_intransit_type,
631     p_fob_point                      =>    ln_fob_point,
632     p_intransit_inv_account          =>    ln_intransit_inv_account,
633     p_interorg_receivables_account   =>    ln_interorg_receivables_accnt,
634     p_all_taxes                      =>    ln_all_taxes,
635     p_tds_taxes                      =>    ln_tds_taxes ,
636     p_modvat_recovery_taxes          =>    ln_modvat_recovery_taxes,
637     p_cvd_taxes                      =>    ln_cvd_taxes,
638     p_add_cvd_taxes                  =>    ln_add_cvd_taxes,/*5228046 Additional cvd Enhancement*/
639     p_customs_taxes                  =>    ln_customs_taxes,
640     p_third_party_taxes              =>    ln_third_party_taxes,
641     p_excise_tax                     =>    ln_excise_tax,
642     p_service_recoverable            =>    ln_service_recoverable,
643     p_service_not_recoverable        =>    ln_service_not_recoverable,
644     p_vat_recoverable                =>    ln_vat_recoverable,
645     p_vat_not_recoverable            =>    ln_vat_not_recoverable,
646     p_account_service_interim        =>    lb_account_service_interim,  /* Service */
647     p_excise_edu_cess                =>    ln_excise_edu_cess,  /* Educational Cess */
648     p_excise_sh_edu_cess             =>    ln_excise_sh_edu_cess, /*Bug 5989740 bduvarag*/
649     p_cvd_edu_cess                   =>    ln_cvd_edu_cess,     /* Educational Cess */
650     p_cvd_sh_edu_cess                =>    ln_cvd_sh_edu_cess,	/*Bug 5989740 bduvarag*/
651     p_customs_edu_cess               =>    ln_customs_edu_cess, /* Educational Cess */
652     p_customs_sh_edu_cess            =>    ln_customs_sh_edu_cess,/*Bug 5989740 bduvarag*/
653     p_trading_to_trading_iso         =>    lv_trading_to_trading_iso,  /* Bug#4171469 */
654     ptr_jv                           =>    tr_jv,   /* 5527885 */
655     p_simulation                     =>    p_simulation,
656     p_process_flag                   =>    p_process_flag,
657     p_process_message                =>    p_process_message,
658     p_debug                          =>    'Y',
659     p_codepath                       =>    p_codepath
660   );
661 
662   if p_process_flag <> 'Y' then
663     /* post_entries procedure has hit an error, cannot continue processing */
664     goto exit_from_procedure;
665   end if;
666 
667   p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10 */
668 /*Bug 5632406 Start*/
669  if (lb_account_service_interim and nvl(ln_service_recoverable, 0) <> 0 )
670     and   r_rcv_shipment_headers.receipt_source_code <> 'CUSTOMER'
671     /* bug#5632406 - bduvarag used the p_receipt_source_code
672     instead of nvl(r_rcv_transactions.attribute_category, 'XX') <> 'INDIA RMA RECEIPT'*/
673   then
674 /*Bug 5632406 End*/
675     p_codepath := jai_general_pkg.plot_codepath(10.1, p_codepath); /* 10.1 */
676 
677     regime_tax_accounting_interim
678     (
679     p_transaction_id                 =>    p_transaction_id,
680     p_shipment_line_id               =>    r_rcv_transactions.shipment_line_id,
681     p_organization_id                =>    r_ja_in_rcv_transactions.organization_id,
682     p_location_id                    =>    r_ja_in_rcv_transactions.location_id,
683     p_transaction_type               =>    r_ja_in_rcv_transactions.transaction_type,
684     p_currency_conversion_rate       =>    r_ja_in_rcv_transactions.currency_conversion_rate,
685     p_parent_transaction_type        =>    r_ja_in_rcv_transactions.parent_transaction_type,
686     -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. p_attribute_category             =>    r_rcv_transactions.attribute_category,
687     p_receipt_source_code            =>    r_rcv_shipment_headers.receipt_source_code,
688     p_transaction_date               =>    r_ja_in_rcv_transactions.transaction_date,
689     p_receipt_num                    =>    r_rcv_shipment_headers.receipt_num,
690     p_regime_code                    =>    jai_constants.service_regime,
691     ptr_jv                           =>    tr_jv,/*Bug 5632406*/
692     p_simulation                     =>    p_simulation,
693     p_process_flag                   =>    p_process_flag,
694     p_process_message                =>    p_process_message,
695     p_debug                          =>    p_debug,
696     p_codepath                       =>    p_codepath
697     );
698 
699     if p_process_flag <> 'Y' then
700       /* post_entries procedure has hit an error, cannot continue processing */
701       goto exit_from_procedure;
702     end if;
703 
704   end if;
705 
706   /* following call added by Vijay Shankar for Bug#4250236(4245089). VAT Impl. */
707   if nvl(ln_vat_recoverable, 0) <> 0 and r_rcv_shipment_headers.receipt_source_code <> 'CUSTOMER'  then/*Bug 5527885*/
708     p_codepath := jai_general_pkg.plot_codepath(10.2, p_codepath); /* 10.2 */ /*Bug 5527885*/
709     /* VAT interim accounting required as recoverable vat tax exists */
710     regime_tax_accounting_interim
711     (
712     p_transaction_id                 =>    p_transaction_id,
713     p_shipment_line_id               =>    r_rcv_transactions.shipment_line_id,
714     p_organization_id                =>    r_ja_in_rcv_transactions.organization_id,
715     p_location_id                    =>    r_ja_in_rcv_transactions.location_id,
716     p_transaction_type               =>    r_ja_in_rcv_transactions.transaction_type,
717     p_currency_conversion_rate       =>    r_ja_in_rcv_transactions.currency_conversion_rate,
718     p_parent_transaction_type        =>    r_ja_in_rcv_transactions.parent_transaction_type,
719     -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. p_attribute_category             =>    r_rcv_transactions.attribute_category,
720     p_receipt_source_code            =>    r_rcv_shipment_headers.receipt_source_code,
721     p_transaction_date               =>    r_ja_in_rcv_transactions.transaction_date,
722     p_receipt_num                    =>    r_rcv_shipment_headers.receipt_num,
723     p_regime_code                    =>    jai_constants.vat_regime,
724     ptr_jv                           =>    tr_jv,/*Bug 5632406*/
725     p_simulation                     =>    p_simulation,
726     p_process_flag                   =>    p_process_flag,
727     p_process_message                =>    p_process_message,
728     p_debug                          =>    p_debug,
729     p_codepath                       =>    p_codepath
730     );
731 
732     if p_process_flag <> 'Y' then
733       /* post_entries procedure has hit an error, cannot continue processing */
734       goto exit_from_procedure;
735     end if;
736 
737   end if;  /* VAT interim accounting */
738 /*Bug 5527885 Start*/
739   p_codepath := jai_general_pkg.plot_codepath(10.3, p_codepath); /* 11 */
740   /* START 5478427 */
741   /* Code for rounding logic */
742   ln_cum_dr_amt := 0;
743   ln_cum_cr_amt := 0;
744   ln_max_jv_abs_amt := 0;
745    v_line_count := 0;/*Bug 5527885*/
746 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
747 IF tr_jv.count > 0    /*added by JMEENA for bug #7310836*/ THEN
748   for jv_num in tr_jv.FIRST..tr_jv.LAST loop
749 
750     if tr_jv.exists(jv_num) = true then
751  v_line_count := v_line_count +1;/*Bug 5527885*/
752       ln_tmp_dr_amt := nvl(tr_jv(jv_num).entered_dr, 0);
753       ln_tmp_cr_amt := nvl(tr_jv(jv_num).entered_cr, 0);
754 
755       ln_cum_dr_amt := ln_cum_dr_amt + ln_tmp_dr_amt;
756       ln_cum_cr_amt := ln_cum_cr_amt + ln_tmp_cr_amt;
757 
758       ln_tmp_dr_amt := abs(ln_tmp_dr_amt);
759       ln_tmp_cr_amt := abs(ln_tmp_cr_amt);
760       if ln_max_jv_abs_amt < ln_tmp_dr_amt then
761         ln_jv_num_of_max_rec := jv_num;
762         ln_max_jv_abs_amt := ln_tmp_dr_amt;
763         ln_max_jv_amt_type := gv_debit;
764       elsif ln_max_jv_abs_amt < ln_tmp_cr_amt then
765         ln_jv_num_of_max_rec := jv_num;
766         ln_max_jv_abs_amt := ln_tmp_cr_amt;
767         ln_max_jv_amt_type := gv_credit;
768       end if;
769 
770     end if;
771 
772   end loop;
773   ln_diff_amt_between_dr_cr := ln_cum_dr_amt - ln_cum_cr_amt;
774   /*Bug 5527885*/
775     v_rounding_diff_to := (1/(2*(power(10,gn_currency_precision)))) * v_line_count;
776   v_rounding_diff_from := (-1) * v_rounding_diff_to;
777 
778 
779   p_codepath := jai_general_pkg.plot_codepath(10.4, p_codepath); /* 11 */
780   if p_debug = 'Y' then
781     Fnd_File.put_line(Fnd_File.LOG,
782       'For Rounding- CumDr:'||ln_cum_dr_amt||', CumCr:'||ln_cum_cr_amt||', ProbRec:'||ln_jv_num_of_max_rec
783       ||', v_rounding_diff_from:'||v_rounding_diff_from||', v_rounding_diff_to:'||v_rounding_diff_to
784       );
785   end if;
786   /* rounding logic starts */
787 
788 --  if ln_diff_amt_between_dr_cr <> 0 then
789  if (ln_diff_amt_between_dr_cr >= v_rounding_diff_from)
790 	and  (ln_diff_amt_between_dr_cr <= v_rounding_diff_to)  /* Added for Bug#5527885 */
791 then
792     p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11 */
793     if ln_max_jv_amt_type = gv_debit then
794       tr_jv(ln_jv_num_of_max_rec).entered_dr :=
795             tr_jv(ln_jv_num_of_max_rec).entered_dr - ln_diff_amt_between_dr_cr;
796     else /* means credit */
797       tr_jv(ln_jv_num_of_max_rec).entered_cr :=
798             tr_jv(ln_jv_num_of_max_rec).entered_cr + ln_diff_amt_between_dr_cr;
799     end if;
800   end if;
801 
802   /*
803   ptr_jv(2).line_num           := 2;
804   ptr_jv(2).acct_type          := lv_acct_type;
805   ptr_jv(2).acct_nature        := lv_acct_nature;
806   ptr_jv(2).source_name        := lv_source_name;
807   ptr_jv(2).category_name      := lv_category_name;
808   ptr_jv(2).ccid               := p_ap_accrual_account;
809   ptr_jv(2).entered_dr         := round(ln_debit, gn_currency_precision);
810   ptr_jv(2).entered_cr         := round(ln_credit, gn_currency_precision);
811   ptr_jv(2).currency_code      := ja_in_receipt_transactions_pkg.gv_func_curr;
812   ptr_jv(2).accounting_date    := p_transaction_date;
813   ptr_jv(2).reference_10       := lv_reference_10;
814   ptr_jv(2).reference_23       := lv_reference_23;
815   ptr_jv(2).reference_24       := lv_reference_24;
816   ptr_jv(2).reference_25       := lv_reference_25;
817   ptr_jv(2).reference_26       := lv_reference_26;
818   ptr_jv(2).destination        := 'G';
819   -- ptr_jv(2).reference_name     := ;
820   ptr_jv(2).reference_id       := p_transaction_id;
821   ptr_jv(2).non_rnd_entered_dr := ln_debit;
822   ptr_jv(2).non_rnd_entered_cr := ln_credit;
823   ptr_jv(2).account_name       := gv_ap_accrual;
824   ptr_jv(2).summary_jv_flag    := 'Y';
825   */
826 
827   if p_debug = 'Y' then
828     Fnd_File.put_line(Fnd_File.LOG, 'Account Name                   CCID                        Dr.                  Cr.          Non Rnd Dr.          Non Rnd Cr.'  );
829     Fnd_File.put_line(Fnd_File.LOG, '------------------------------ ---------- -------------------- -------------------- -------------------- --------------------'  );
830   end if;
831 
832   /* Code to Post Journals */
833   for jv_num in tr_jv.FIRST..tr_jv.LAST loop
834 
835     if tr_jv.exists(jv_num) = true then
836 
837       p_codepath := jai_general_pkg.plot_codepath('12.'||tr_jv(jv_num).line_num, p_codepath); /* 10 */
838       if p_debug = 'Y' then
839         Fnd_File.put_line(Fnd_File.LOG,
840               rpad(tr_jv(jv_num).account_name,30, ' ')
841               ||' '||rpad(tr_jv(jv_num).ccid,10, ' ')
842               ||' '||lpad(nvl(tr_jv(jv_num).entered_dr,0),20, ' ')
843               ||' '||lpad(nvl(tr_jv(jv_num).entered_cr,0),20, ' ')
844               ||' '||lpad(round(nvl(tr_jv(jv_num).non_rnd_entered_dr,0),8),20, ' ')
845               ||' '||lpad(round(nvl(tr_jv(jv_num).non_rnd_entered_cr,0),8),20, ' ')
846         );
847       end if;
848       IF nvl(tr_jv(jv_num).entered_dr,0) <> 0 OR nvl(tr_jv(jv_num).entered_cr,0) <> 0 THEN/*Bug 5527885*/
849       jai_rcv_accounting_pkg.process_transaction(
850         p_transaction_id            =>    p_transaction_id,
851         p_acct_type                 =>    tr_jv(jv_num).acct_type      ,
852         p_acct_nature               =>    tr_jv(jv_num).acct_nature    ,
853         p_source_name               =>    tr_jv(jv_num).source_name    ,
854         p_category_name             =>    tr_jv(jv_num).category_name  ,
855         p_code_combination_id       =>    tr_jv(jv_num).ccid           ,
856         p_entered_dr                =>    tr_jv(jv_num).entered_dr     ,
857         p_entered_cr                =>    tr_jv(jv_num).entered_cr     ,
858         p_currency_code             =>    tr_jv(jv_num).currency_code  ,
859         p_accounting_date           =>    tr_jv(jv_num).accounting_date,
860         p_reference_10              =>    tr_jv(jv_num).reference_10   ,
861         p_reference_23              =>    tr_jv(jv_num).reference_23   ,
862         p_reference_24              =>    tr_jv(jv_num).reference_24   ,
863         p_reference_25              =>    tr_jv(jv_num).reference_25   ,
864         p_reference_26              =>    tr_jv(jv_num).reference_26   ,
865         p_destination               =>    tr_jv(jv_num).destination    ,
866         p_simulate_flag             =>    p_simulation,
867         p_codepath                  =>    p_codepath,
868         p_process_status            =>    p_process_flag,
869         p_process_message           =>    P_process_message
870       );
871      END IF; /*bug#5527885 */
872       if p_process_flag <> 'Y' then
873         goto exit_from_procedure;
874       end if;
875 
876     end if;
877 
878   end loop;
879   /* END OF 5527885 */
880  END IF; --End of bug#7310836, added by JMEENA
881  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
882 
883   -- All the Processing Went Through fine. So Setting the process_flag to 'Y'
884   p_process_flag := 'Y';
885 
886   << exit_from_procedure >>
887   p_codepath := jai_general_pkg.plot_codepath(99, p_codepath, null, 'END'); /* 11 *//*Bug 5527885*/
888 
889   if p_debug = 'Y' then
890 --    Fnd_File.put_line(Fnd_File.LOG, ' Code Path :' || p_codepath );/*Bug 5527885*/
891     Fnd_File.put_line(Fnd_File.LOG, '**** End of procedure jai_rcv_rcv_rtv_pkg.process_transaction ****');
892   end if;
893 
894   return;
895 
896 exception
897   when others then
898     p_process_flag    := 'E';
899     p_process_message := 'RECEIVE_RTV_PKG.process_transaction:' || sqlerrm;
900     FND_FILE.put_line(FND_FILE.log, 'Error in '||p_process_message);
901     Fnd_File.put_line(Fnd_File.LOG, 'Code Path->' || p_codepath );
902     return;
903 
904 end process_transaction;
905 /****************************** End process_transaction  ****************************/
906 
907 /******************************** Start get_accounts  *******************************/
908   procedure get_accounts
909   (
910     p_organization_id                         in                  number,
911     p_location_id                             in                  number,
912     p_receipt_source_code                     in                  varchar2,
913     p_from_organization_id                    in                  number,
914     p_to_organization_id                      in                  number,
915     p_po_distribution_id                      in                  number,
916     p_po_line_location_id                     in                  number,
917     p_debug                                   in                  varchar2,  -- default 'N', File.Sql.35
918     p_boe_account_id                          out                 nocopy number,
919     p_rtv_expense_account_id                  out     nocopy      number,
920     p_excise_expense_account                  out     nocopy      number,
921     p_excise_rcvble_account                   out     nocopy      number,
922     p_receiving_account_id                    out     nocopy      number,
923     p_ap_accrual_account                      out     nocopy      number,
924     p_po_accrual_account_id                   out     nocopy      number,
925     p_interorg_payables_account               out     nocopy      number,
926     p_intransit_inv_account                   out     nocopy      number,
927     p_interorg_receivables_account            out     nocopy      number,
928     p_intransit_type                          out     nocopy      number,
929     p_fob_point                               out     nocopy      number,
930     p_trading_to_trading_iso                  out     nocopy      varchar2, /* Bug#4171469 */
931     p_process_flag                            out     nocopy      varchar2,
932     p_process_message                         out     nocopy      varchar2,
933     p_codepath                                in out  nocopy      varchar2
934   )is
935 
936   cursor    c_ja_in_hr_organization_units
937             (cp_organization_id number, cp_location_id   number) is
938     select  boe_account_id,
939             excise_expense_account,
940             excise_rcvble_account,
941             rtv_expense_account_id,
942             nvl(trading, 'N') receving_org_trading,  /* Bug#4171469 */
943             NVL(manufacturing, 'N') receiving_org_manufacturing --Added by Ramananda for Bug #4516577
944     from    JAI_CMN_INVENTORY_ORGS
945     where   organization_id = cp_organization_id
946     and     location_id = cp_location_id;
947 
948   cursor    c_rcv_parameters(cp_organization_id number) is
949     select  receiving_account_id
950     from    rcv_parameters
951     Where   organization_id = cp_organization_id;
952 
953   cursor    c_mtl_parameters(cp_organization_id number) is
954     select  ap_accrual_account
955     from    mtl_parameters
956     where   organization_id = cp_organization_id;
957 
958   cursor    c_po_distributions_all(cp_po_distribution_id number) is
959     select  accrual_account_id
960     from    po_distributions_all
961     where   po_distribution_id = cp_po_distribution_id;
962 
963   cursor    c_po_distributions_all_1(cp_po_line_location_id number) is
964     select  accrual_account_id
965     from    po_distributions_all
966     where   po_distribution_id =
967             (
968               select max(po_distribution_id)
969               from   po_distributions_all
970               where  line_location_id = cp_po_line_location_id
971             );
972 
973   cursor    c_mtl_interorg_parameters
974             (cp_from_organization_id number, cp_to_organization_id number) is
975     select  interorg_payables_account,
976             intransit_inv_account,
977             interorg_receivables_account,
978             intransit_type,
979             fob_point
980     from    mtl_interorg_parameters
981     where   from_organization_id = cp_from_organization_id
982     and     to_organization_id = cp_to_organization_id;
983 
984   cursor c_iso_from_org_type(cp_organization_id number) is
985     select   nvl(trading, 'N') source_org_trading  /* Bug#4171469 */
986     from    JAI_CMN_INVENTORY_ORGS
987     where   organization_id = cp_organization_id;
988 
989 
990 
991   r_ja_in_hr_organization_units       c_ja_in_hr_organization_units%rowtype;
992   r_ja_in_hr_organization_units1      c_ja_in_hr_organization_units%rowtype;
993   r_mtl_parameters                    c_mtl_parameters%rowtype;
994   r_po_distributions_all              c_po_distributions_all%rowtype;
995   r_po_distributions_all_1            c_po_distributions_all_1%rowtype;
996   r_rcv_parameters                    c_rcv_parameters%rowtype;
997   r_mtl_interorg_parameters           c_mtl_interorg_parameters%rowtype;
998   r_iso_from_org_type                 c_iso_from_org_type%rowtype; /* Bug#4171469 */
999 
1000 begin
1001 
1002   if p_debug = 'Y' then
1003     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.get_accounts **');
1004   end if;
1005 
1006   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.get_accounts', 'START'); /* 1 */
1007   open  c_ja_in_hr_organization_units(p_organization_id,p_location_id);
1008   fetch c_ja_in_hr_organization_units into r_ja_in_hr_organization_units;
1009   close c_ja_in_hr_organization_units;
1010 
1011 
1012   p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
1013   open  c_ja_in_hr_organization_units(p_organization_id, 0);
1014   fetch c_ja_in_hr_organization_units into r_ja_in_hr_organization_units1;
1015   close c_ja_in_hr_organization_units;
1016 
1017   /** check value for all accounts for the given location ..
1018       if null get value for null location  **/
1019 
1020   /** BOE account **/
1021   p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
1022   if  r_ja_in_hr_organization_units.boe_account_id is not null then
1023     p_boe_account_id := r_ja_in_hr_organization_units.boe_account_id ;
1024   elsif r_ja_in_hr_organization_units1.boe_account_id is not null then
1025     p_boe_account_id  := r_ja_in_hr_organization_units1.boe_account_id ;
1026   end if;
1027 
1028   /** rtv_expense_account_id **/
1029   p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
1030   if r_ja_in_hr_organization_units.rtv_expense_account_id is not null then
1031     p_rtv_expense_account_id := r_ja_in_hr_organization_units.rtv_expense_account_id ;
1032   elsif r_ja_in_hr_organization_units1.rtv_expense_account_id is not null then
1033     p_rtv_expense_account_id := r_ja_in_hr_organization_units1.rtv_expense_account_id ;
1034   end if;
1035 
1036   /** excise_expense_account **/
1037   p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
1038   if r_ja_in_hr_organization_units.excise_expense_account is not null then
1039     p_excise_expense_account := r_ja_in_hr_organization_units.excise_expense_account ;
1040   elsif r_ja_in_hr_organization_units1.excise_expense_account is not null then
1041     p_excise_expense_account := r_ja_in_hr_organization_units1.excise_expense_account ;
1042   end if;
1043 
1044   /** excise_rcvble_account **/
1045   p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
1046   if r_ja_in_hr_organization_units.excise_rcvble_account is not null then
1047     p_excise_rcvble_account := r_ja_in_hr_organization_units.excise_rcvble_account ;
1048   elsif r_ja_in_hr_organization_units1.excise_expense_account is not null then
1049     p_excise_rcvble_account := r_ja_in_hr_organization_units1.excise_rcvble_account ;
1050   end if;
1051 
1052   p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
1053   open c_rcv_parameters(p_organization_id);
1054   fetch c_rcv_parameters into r_rcv_parameters;
1055   close c_rcv_parameters;
1056 
1057   p_receiving_account_id := r_rcv_parameters.receiving_account_id;
1058 
1059   p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
1060   open c_mtl_parameters(p_organization_id);
1061   fetch c_mtl_parameters into r_mtl_parameters;
1062   close c_mtl_parameters;
1063 
1064   p_ap_accrual_account := r_mtl_parameters.ap_accrual_account;
1065 
1066 
1067   p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9 */
1068   if p_po_distribution_id is not null then
1069 
1070     p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10 */
1071     open  c_po_distributions_all(p_po_distribution_id);
1072     fetch c_po_distributions_all into r_po_distributions_all;
1073     close c_po_distributions_all;
1074 
1075     p_po_accrual_account_id := r_po_distributions_all.accrual_account_id;
1076 
1077   end if;
1078 
1079 
1080   if  r_po_distributions_all.accrual_account_id is null and
1081       p_po_line_location_id is not null then
1082 
1083       p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11 */
1084       open c_po_distributions_all_1(p_po_line_location_id);
1085       fetch c_po_distributions_all_1 into r_po_distributions_all_1;
1086       close c_po_distributions_all_1;
1087 
1088       p_po_accrual_account_id := r_po_distributions_all_1.accrual_account_id;
1089 
1090       p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12 */
1091 
1092   end if;
1093 
1094 
1095   p_codepath := jai_general_pkg.plot_codepath(13, p_codepath); /* 13 */
1096   p_trading_to_trading_iso := 'N';
1097   if p_receipt_source_code in('INTERNAL ORDER','INVENTORY')then  -- bug 6030615
1098 
1099     p_codepath := jai_general_pkg.plot_codepath(14, p_codepath); /* 14 */
1100     open  c_mtl_interorg_parameters(p_from_organization_id, p_to_organization_id);
1101     fetch c_mtl_interorg_parameters into r_mtl_interorg_parameters;
1102     close c_mtl_interorg_parameters;
1103 
1104     /* Bug#4171469 */
1105     open c_iso_from_org_type(p_from_organization_id);
1106     fetch c_iso_from_org_type into r_iso_from_org_type;
1107     close c_iso_from_org_type;
1108 
1109     if  r_iso_from_org_type.source_org_trading = 'Y' and
1110         ( r_ja_in_hr_organization_units.receving_org_trading = 'Y'
1111           OR
1112           r_ja_in_hr_organization_units1.receving_org_trading = 'Y'/*Changes from nprashar for bug 6321337
1113          Commented the other 2 OR conditions as forward as per Forward porting 11i bug 6200218
1114           OR                                                           Added the OR Condition by Ramananda for Bug #4516577
1115           r_ja_in_hr_organization_units.receiving_org_manufacturing = 'Y'
1116           OR                                                           Added the OR Condition by Ramananda for Bug #4516577
1117           r_ja_in_hr_organization_units1.receiving_org_manufacturing = 'Y' Commenting Ends here */
1118         )
1119 
1120     then
1121       p_codepath := jai_general_pkg.plot_codepath(14.1, p_codepath); /* 14.1 */
1122       p_trading_to_trading_iso := 'Y';
1123 
1124     end if;
1125 
1126     p_codepath := jai_general_pkg.plot_codepath(15, p_codepath); /* 15 */
1127     p_interorg_payables_account     := r_mtl_interorg_parameters.interorg_payables_account;
1128     p_intransit_inv_account         := r_mtl_interorg_parameters.intransit_inv_account;
1129     p_interorg_receivables_account  := r_mtl_interorg_parameters.interorg_receivables_account;
1130     p_intransit_type                := r_mtl_interorg_parameters.intransit_type;
1131     p_fob_point                     := r_mtl_interorg_parameters.fob_point;
1132 
1133   end if; /*p_receipt_source_code = 'INTERNAL ORDER'*/
1134 
1135 
1136   << exit_from_procedure >>
1137   p_codepath := jai_general_pkg.plot_codepath(16, p_codepath, null, 'END'); /* 16 */
1138   if p_process_flag is null then
1139     p_process_flag    := 'Y';
1140   end if;
1141 
1142   if p_debug = 'Y' then
1143 --    Fnd_File.put_line(Fnd_File.LOG, '  Code Path :' || p_codepath );
1144     Fnd_File.put_line(Fnd_File.LOG, '  ** End of procedure jai_rcv_rcv_rtv_pkg.get_accounts **  ');
1145   end if;
1146 
1147 
1148   return;
1149 
1150 exception
1151   when others then
1152     p_process_flag    := 'E';
1153     p_process_message := 'RECEIVE_RTV_PKG.get_accounts:' || sqlerrm;
1154     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
1155     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
1156     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END'); /* 24 */
1157     return;
1158 
1159 end get_accounts;
1160 
1161 /******************************** End get_accounts  *******************************/
1162 
1163 
1164 
1165 /******************************** Start get_tax_breakup *****************************/
1166 procedure get_tax_breakup
1167   (
1168     p_transaction_id                          in                  number,
1169     p_shipment_line_id                        in                  number,
1170     p_currency_conversion_rate                in                  number,
1171     p_po_vendor_id                            in                  number,
1172     p_debug                                   in                  varchar2,  -- default 'N', File.Sql.35
1173     p_all_taxes                               out     nocopy      number,
1174     p_tds_taxes                               out     nocopy      number,
1175     p_modvat_recovery_taxes                   out     nocopy      number,
1176     p_cvd_taxes                               out     nocopy      number,
1177     p_add_cvd_taxes                           out     nocopy      number, /*5228046 Additional cvd Enhancement*/
1178     p_customs_taxes                           out     nocopy      number,
1179     p_third_party_taxes                       out     nocopy      number,
1180     p_excise_tax                              out     nocopy      number,
1181     p_service_recoverable                     out     nocopy      number, /* service */
1182     p_service_not_recoverable                 out     nocopy      number, /* service */
1183     /* following two params added by Vijay Shankar for Bug#4250236(4245089). VAT Impl. */
1184     p_vat_recoverable                         out     nocopy      number,
1185     p_vat_not_recoverable                     out     nocopy      number,
1186     p_excise_edu_cess                         out     nocopy      number, /* educational cess */
1187     p_excise_sh_edu_cess                      out     nocopy      number,/*Bug 5989740 bduvarag*/
1188     p_cvd_edu_cess                            out     nocopy      number, /* educational cess */
1189     p_cvd_sh_edu_cess                         out     nocopy      number,/*Bug 5989740 bduvarag*/
1190     p_customs_edu_cess                        out     nocopy      number, /* educational cess */
1191     p_customs_sh_edu_cess                     out     nocopy      number,/*Bug 5989740 bduvarag*/
1192     p_process_flag                            out     nocopy      varchar2,
1193     p_process_message                         out     nocopy      varchar2,
1194     p_codepath                                in      out nocopy  varchar2
1195   )
1196   is
1197 
1198   cursor c_ja_in_receipt_tax_lines(cp_shipment_line_id  number) is
1199     select  jrtl.tax_id tax_id,
1200             jrtl.tax_type tax_type,
1201             nvl(jrtl.tax_amount,0) tax_amount,
1202             jrtl.currency currency,
1203             nvl(jrtl.vendor_id, 0) vendor_id,
1204             nvl(jtc.rounding_factor, 0) rounding_factor,
1205             nvl(jtc.mod_cr_percentage, 0) recoverable,  /* Service */
1206             nvl(jrtl.modvat_flag, 'N') modvatable /* Service */
1207             , nvl(tax_types.regime_code, 'XXXX') regime_code    /* Vijay Shankar for Bug#4250236(4245089). VAT Impl. */
1208 
1209     from    JAI_RCV_LINE_TAXES jrtl,
1210             JAI_CMN_TAXES_ALL jtc
1211             , jai_regime_tax_types_v tax_types     /*Vijay Shankar for Bug#4250236(4245089). VAT Impl. */
1212     where   jrtl.shipment_line_id = cp_shipment_line_id
1213       AND   jrtl.tax_id = jtc.tax_id
1214       AND   jtc.tax_type = tax_types.tax_type(+)
1215       AND   NVL(jtc.inclusive_tax_flag,'N')='N'; --add by eric for inclusive tax,picking the exclusive tax only
1216 
1217   cursor c_jai_regimes(p_regime_code varchar2) is
1218     select regime_id
1219     from   JAI_RGM_DEFINITIONS
1220     where  regime_code = p_regime_code;
1221 
1222   cursor c_is_tax_type_in_regime(cp_regime_id  number, cp_tax_type varchar2) is
1223     select attribute_code regime_tax_type
1224     from   JAI_RGM_REGISTRATIONS
1225     where  regime_id = cp_regime_id
1226     and    registration_type = jai_constants.regn_type_tax_types
1227     and    attribute_code = cp_tax_type;
1228 
1229   /*
1230   r_jai_regimes_servce            c_jai_regimes%rowtype;
1231   r_jai_regimes_vat               c_jai_regimes%rowtype;
1232   r_is_tax_type_in_regime         c_is_tax_type_in_regime%rowtype;
1233   */
1234 
1235   ln_tax_apportion_factor         number;
1236   ln_tax_amount                   number;
1237 
1238 begin
1239 
1240   if p_debug = 'Y' then
1241     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.get_tax_breakup **');
1242   end if;
1243 
1244 
1245   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.get_tax_breakup', 'START'); /* 1 */
1246 
1247   ln_tax_apportion_factor   :=
1248   jai_rcv_trx_processing_pkg.get_apportion_factor(p_transaction_id);
1249 
1250   p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
1251   p_all_taxes               := 0;
1252   p_tds_taxes               := 0;
1253   p_modvat_recovery_taxes   := 0;
1254   p_cvd_taxes               := 0;
1255   p_add_cvd_taxes           := 0; /*5228046 Additional cvd Enhancement*/
1256   p_customs_taxes           := 0;
1257   p_third_party_taxes       := 0;
1258   p_excise_tax              := 0;
1259   p_service_recoverable     := 0;
1260   p_service_not_recoverable := 0;
1261   p_vat_recoverable         := 0;
1262   p_vat_not_recoverable     := 0;
1263   p_excise_edu_cess         := 0;
1264   p_cvd_edu_cess            := 0;
1265   p_customs_edu_cess        := 0;
1266   p_excise_sh_edu_cess   		:= 0;	/*Bug 5989740 bduvarag*/
1267   p_cvd_sh_edu_cess      		:= 0;	/*Bug 5989740 bduvarag*/
1268   p_customs_sh_edu_cess  		:= 0;	/*Bug 5989740 bduvarag*/
1269 
1270 
1271   /*
1272   open  c_jai_regimes(jai_constants.service_regime);
1273   fetch c_jai_regimes into r_jai_regimes_servce;
1274   close c_jai_regimes;
1275 
1276   open  c_jai_regimes(jai_constants.vat_regime);
1277   fetch c_jai_regimes into r_jai_regimes_vat;
1278   close c_jai_regimes;
1279   */
1280 
1281   p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
1282 
1283   for cur_rec in c_ja_in_receipt_tax_lines(p_shipment_line_id) loop
1284 
1285     p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
1286     ln_tax_amount :=  cur_rec.tax_amount;
1287 
1288     p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
1289     ln_tax_amount  := ln_tax_amount * ln_tax_apportion_factor;
1290     /* apportionment for uom and quantity change wrt the parent RECEIVE
1291       line for which taxes exist */
1292     p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
1293     if  nvl(cur_rec.currency, jai_rcv_trx_processing_pkg.gv_func_curr) <>
1294         jai_rcv_trx_processing_pkg.gv_func_curr
1295     then
1296       /* Tax not in functional currency, need to convert*/
1297       ln_tax_amount := ln_tax_amount * p_currency_conversion_rate;
1298     end if;
1299 
1300     /* ln_tax_amount := round(ln_tax_amount, cur_rec.rounding_factor); Vijay. Final Observation */
1301     p_all_taxes := p_all_taxes + ln_tax_amount;
1302 
1303     p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
1304 
1305     if  cur_rec.tax_type = jai_constants.tax_type_tds then /* TDS*/
1306 
1307       p_codepath := jai_general_pkg.plot_codepath(7.1, p_codepath); /* 7.1 */
1308       p_tds_taxes := p_tds_taxes + ln_tax_amount;
1309 
1310 
1311     elsif   cur_rec.tax_type = jai_constants.tax_type_modvat_recovery then /* MODVAT RECOVERY*/
1312 
1313       p_codepath := jai_general_pkg.plot_codepath(7.2, p_codepath); /* 7.2 */
1314       p_modvat_recovery_taxes := p_modvat_recovery_taxes + ln_tax_amount;
1315 
1316     elsif   cur_rec.tax_type = jai_constants.tax_type_customs then /* CUSTOMS */
1317 
1318       p_codepath := jai_general_pkg.plot_codepath(7.3, p_codepath); /* 7.3 */
1319       p_customs_taxes := p_customs_taxes + ln_tax_amount;
1320 
1321     elsif   cur_rec.tax_type = jai_constants.tax_type_cvd then  /* CVD */
1322 
1323       p_codepath := jai_general_pkg.plot_codepath(7.4, p_codepath); /* 7.4 */
1324       p_cvd_taxes := p_cvd_taxes + ln_tax_amount;
1325 
1326     elsif   cur_rec.tax_type = jai_constants.tax_type_add_cvd then  /* ADDITIONAL CVD - Enhancement 5228046 */
1327 
1328       p_codepath := jai_general_pkg.plot_codepath(7.4, p_codepath); /* 7.4 */
1329       p_add_cvd_taxes := p_add_cvd_taxes + ln_tax_amount;
1330 
1331     elsif   cur_rec.tax_type = jai_constants.tax_type_exc_edu_cess  then /* Educational Cess Excise */
1332 
1333       p_codepath := jai_general_pkg.plot_codepath(7.5, p_codepath); /* 7.5 */
1334       p_excise_edu_cess :=  p_excise_edu_cess + ln_tax_amount;
1335 /*Bug 5989740 bduvarag start*/
1336 	  elsif   cur_rec.tax_type = jai_constants.tax_type_sh_exc_edu_cess  then /* Higher Secondary Educational Cess Excise */
1337 
1338 		  p_codepath := jai_general_pkg.plot_codepath(7.51, p_codepath); /* 7.51 */
1339 		  p_excise_sh_edu_cess :=  p_excise_sh_edu_cess + ln_tax_amount;
1340 
1341 /*Bug 5989740 bduvarag end*/
1342     elsif   cur_rec.tax_type = jai_constants.tax_type_cvd_edu_cess  then /* Educational Cess CVD */
1343 
1344       p_codepath := jai_general_pkg.plot_codepath(7.6, p_codepath); /* 7.6 */
1345       p_cvd_edu_cess :=  p_cvd_edu_cess + ln_tax_amount;
1346 /*Bug 5989740 bduvarag start*/
1347 	  elsif   cur_rec.tax_type = jai_constants.tax_type_sh_cvd_edu_cess  then /* Higher Secondary Educational Cess CVD */
1348 
1349 		  p_codepath := jai_general_pkg.plot_codepath(7.61, p_codepath); /* 7.61 */
1350 		  p_cvd_sh_edu_cess :=  p_cvd_sh_edu_cess + ln_tax_amount;
1351 
1352 /*Bug 5989740 bduvarag end*/
1353     elsif   cur_rec.tax_type = jai_constants.tax_type_customs_edu_cess  then /* Educational Cess CVD */
1354 
1355      p_codepath := jai_general_pkg.plot_codepath(7.7, p_codepath); /* 7.7 */
1356      p_customs_edu_cess :=  p_customs_edu_cess + ln_tax_amount;
1357 /*Bug 5989740 bduvarag start*/
1358     elsif   cur_rec.tax_type = jai_constants.tax_type_sh_customs_edu_cess  then /* Higher Secondary Educational Cess CVD */
1359 
1360 		 p_codepath := jai_general_pkg.plot_codepath(7.71, p_codepath); /* 7.71 */
1361 		 p_customs_sh_edu_cess :=  p_customs_sh_edu_cess + ln_tax_amount;
1362 /*Bug 5989740 bduvarag end*/
1363     elsif   cur_rec.tax_type in
1364             (
1365               jai_constants.tax_type_excise         , /* EXCISE */
1366               jai_constants.tax_type_exc_additional , /* EXCISE ADDITIONAL */
1367               jai_constants.tax_type_exc_other        /* EXCISE OTHERS */
1368             )
1369             then
1370 
1371      p_codepath := jai_general_pkg.plot_codepath(7.8, p_codepath); /* 7.8 */
1372      p_excise_tax := p_excise_tax + ln_tax_amount;
1373 
1374     else
1375 
1376       /* Check tax type by regime, Service and then VAT */
1377 
1378       p_codepath := jai_general_pkg.plot_codepath(7.9, p_codepath); /* 7.9 */
1379 
1380       /*
1381       r_is_tax_type_in_regime := null;
1382 
1383       open c_is_tax_type_in_regime(r_jai_regimes_servce.regime_id, cur_rec.tax_type);
1384       fetch c_is_tax_type_in_regime into r_is_tax_type_in_regime;
1385       close c_is_tax_type_in_regime;
1386 
1387       if   r_is_tax_type_in_regime.regime_tax_type is not null then*/
1388 
1389       /* Service type of Tax */
1390       if cur_rec.regime_code = jai_constants.service_regime then
1391         p_codepath := jai_general_pkg.plot_codepath(7.11, p_codepath); /* 7.11 */
1392 
1393         if  ( cur_rec.recoverable = 100 and cur_rec.modvatable = 'Y' ) then
1394           p_codepath := jai_general_pkg.plot_codepath(7.12, p_codepath); /* 7.12 */
1395           p_service_recoverable := p_service_recoverable + ln_tax_amount;
1396 	  /*Bug 5527885 start*/
1397        elsif cur_rec.modvatable = 'Y' then
1398 	        p_codepath := jai_general_pkg.plot_codepath(7.13, p_codepath); /* 7.13 */
1399 		      p_service_not_recoverable := p_service_not_recoverable +((ln_tax_amount * (100 - cur_rec.recoverable) ) /100);
1400 		      p_service_recoverable := p_service_recoverable +  round(((ln_tax_amount * cur_rec.recoverable)/100), cur_rec.rounding_factor) ; -- added By rchandan for bug 6971526
1401 
1402         else
1403           p_codepath := jai_general_pkg.plot_codepath(7.131, p_codepath); /* 7.13 */
1404           p_service_not_recoverable := p_service_not_recoverable + ln_tax_amount;
1405         end if;
1406 /*Bug 5527885 End*/
1407       else
1408 
1409         p_codepath := jai_general_pkg.plot_codepath(7.14, p_codepath); /* 7.14 */
1410 
1411         /*
1412         r_is_tax_type_in_regime := null;
1413         open c_is_tax_type_in_regime(r_jai_regimes_vat.regime_id, cur_rec.tax_type);
1414         fetch c_is_tax_type_in_regime into r_is_tax_type_in_regime;
1415         close c_is_tax_type_in_regime;
1416 
1417         if   r_is_tax_type_in_regime.regime_tax_type is not null then */
1418 
1419         /* VAT type of Tax */
1420         if cur_rec.regime_code = jai_constants.vat_regime then
1421           p_codepath := jai_general_pkg.plot_codepath(7.15, p_codepath); /* 7.15 */
1422 
1423           if  ( cur_rec.recoverable = 100 and cur_rec.modvatable = 'Y' ) then
1424             p_codepath := jai_general_pkg.plot_codepath(7.16, p_codepath); /* 7.16 */
1425             p_vat_recoverable := p_vat_recoverable + ln_tax_amount;
1426            /*  elsif added By rchandan for bug 6971526
1427             start */
1428           elsif cur_rec.modvatable = 'Y' then
1429                  p_codepath := jai_general_pkg.plot_codepath(7.16, p_codepath); /* 7.16 */
1430                  p_vat_recoverable := p_vat_recoverable + round(((ln_tax_amount * cur_rec.recoverable)/100) ,  cur_rec.rounding_factor) ;
1431                  p_vat_not_recoverable := p_vat_not_recoverable +round(((ln_tax_amount * (100 - cur_rec.recoverable) ) /100), cur_rec.rounding_factor);
1432          -- End 6971526
1433           else
1434             p_codepath := jai_general_pkg.plot_codepath(7.17, p_codepath); /* 7.17 */
1435             p_vat_not_recoverable := p_vat_not_recoverable + ln_tax_amount;
1436           end if;
1437 
1438         end if; /* Service and VAT */
1439 
1440       end if; /* else after all tax types */
1441 
1442     end if; /* Check all tax and tax type */
1443 
1444 
1445     /* get third party amount */
1446     p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
1447     if
1448       cur_rec.vendor_id <> p_po_vendor_id and
1449       cur_rec.vendor_id > 0 and
1450       cur_rec.tax_type not in (jai_constants.tax_type_tds, jai_constants.tax_type_modvat_recovery)
1451     then
1452       p_third_party_taxes := p_third_party_taxes + ln_tax_amount;
1453     end if;
1454 
1455     /* To indicate second pass of the loop, first means F, statement id need not be incremented in code path*/
1456 
1457   end loop; /* c_ja_in_receipt_tax_lines */
1458 
1459   << exit_from_procedure >>
1460   p_codepath := jai_general_pkg.plot_codepath(9, p_codepath, null, 'END'); /* 9 */
1461 
1462   if p_process_flag is null then
1463     p_process_flag    := 'Y';
1464   end if;
1465 
1466   if p_debug = 'Y' then
1467     Fnd_File.put_line(Fnd_File.LOG, '  Code Path :' || p_codepath );
1468 --    Fnd_File.put_line(Fnd_File.LOG, '  ** End of procedure jai_rcv_rcv_rtv_pkg.get_tax_breakup **  ');/*Bug 5527885*/
1469   end if;
1470 
1471   return;
1472 
1473 exception
1474   when others then
1475     p_process_flag    := 'E';
1476     p_process_message := 'RECEIVE_RTV_PKG.get_tax_breakup:' || sqlerrm;
1477     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
1478     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
1479     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END'); /* 24 */
1480     return;
1481 
1482 end get_tax_breakup;
1483 
1484 /******************************** End get_tax_breakup *****************************/
1485 
1486 
1487 /****************************** Start validate_transaction_tax_accnt ******************************/
1488   procedure validate_transaction_tax_accnt
1489   (
1490     p_transaction_type                        in                  varchar2,
1491     p_parent_transaction_type                 in                  varchar2,
1492     -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. p_attribute_category                      in                  varchar2,
1493     p_receipt_source_code                     in                  varchar2,
1494     p_boe_account_id                          in                  number,
1495     p_rtv_expense_account_id                  in                  number,
1496     p_excise_expense_account                  in                  number,
1497     p_excise_rcvble_account                   in                  number,
1498     p_receiving_account_id                    in out  nocopy      number,
1499     p_ap_accrual_account                      in out  nocopy      number,
1500     p_po_accrual_account_id                   in                  number,
1501     p_interorg_payables_account               in                  number,
1502     p_intransit_inv_account                   in                  number,
1503     p_interorg_receivables_account            in                  number,
1504     p_intransit_type                          in                  number,
1505     p_fob_point                               in                  number,
1506     p_cvd_taxes                               in                  number,
1507     p_add_cvd_taxes                           in                  number,/*5228046 Additional cvd Enhancement*/
1508     p_customs_taxes                           in                  number,
1509     p_third_party_taxes                       in                  number,
1510     p_excise_tax                              in                  number,
1511     p_trading_to_trading_iso                  in                  varchar2, /* Bug#4171469 */
1512     p_debug                                   in                  varchar2,   -- default 'N', File.Sql.35
1513     p_process_flag                            out      nocopy     varchar2,
1514     p_process_message                         out      nocopy     varchar2,
1515     p_codepath                                in out   nocopy     varchar2
1516   )
1517 is
1518 
1519 
1520 begin
1521 
1522   /* Start Validate Receving Account p_receiving_account_id */
1523   if p_debug = 'Y' then
1524     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.validate_transaction_tax_accnt **');
1525   end if;
1526 
1527   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.validate_transaction_tax_accnt', 'START'); /* 1 */
1528 
1529   -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. if p_attribute_category  = 'INDIA RMA RECEIPT' then
1530   if p_receipt_source_code = 'CUSTOMER' then
1531 
1532     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2 */
1533 
1534     if  p_excise_expense_account is null then
1535 
1536       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3 */
1537       p_process_flag    := 'E';
1538       p_process_message := 'Excise Expense Account is not defined in JAI_CMN_INVENTORY_ORGS, ' ||
1539                            'for the organization location or null location, cannot proceed as transaction type is RMA';
1540 
1541       goto exit_from_procedure;
1542 
1543     else
1544 
1545       p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4 */
1546       p_receiving_account_id := p_excise_expense_account;
1547 
1548     end if;
1549 
1550   elsif p_receiving_account_id is null then
1551 
1552     p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5 */
1553     p_process_flag    := 'E';
1554     p_process_message := 'Receiving Account is not defined in rcv_parameters for the organization.';
1555     goto exit_from_procedure;
1556 
1557   end if; /*  if p_receipt_source_code = 'CUSTOMER' then
1558             (p_attribute_category  = 'INDIA RMA RECEIPT') */
1559 
1560   /* End Validate Receving Account p_receiving_account_id */
1561 
1562 
1563   /* Start Validate Accrual Account */
1564 
1565   p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
1566   if p_receipt_source_code in ('INTERNAL ORDER','INVENTORY') then /*added INVENTORY for bug #6030615 by vkaranam*/
1567 
1568 
1569     p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
1570     /*6488406*/
1571     if ( ( (p_intransit_type = 2) and (p_fob_point = 1) ) or
1572 (p_trading_to_trading_iso = 'Y'  and p_receipt_source_code = 'INTERNAL ORDER') )then /* Bug#4171469 */
1573 
1574       p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
1575       if p_intransit_inv_account is null then
1576 
1577         p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9 */
1578         p_process_flag    := 'E';
1579         p_process_message := 'Intransit Inventory Account is not defined in mtl_interorg_parameters for ' ||
1580                                'from and to organization of the ISO. ';
1581           goto exit_from_procedure;
1582       else
1583         p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10 */
1584         p_ap_accrual_account := p_intransit_inv_account;
1585       end if;
1586 
1587     else
1588 
1589       p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11  */
1590 
1591       if p_interorg_payables_account is null then
1592         p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12  */
1593         p_process_flag    := 'E';
1594         p_process_message := 'Inter-org Payables Account is not defined in mtl_interorg_parameters for ' ||
1595                              'from and to organization of the ISO. ';
1596         goto exit_from_procedure;
1597       else
1598         p_codepath := jai_general_pkg.plot_codepath(13, p_codepath); /* 13  */
1599         p_ap_accrual_account := p_interorg_payables_account;
1600       end if;
1601 
1602     end if;
1603 
1604   elsif p_receipt_source_code = 'CUSTOMER' then
1605    -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. if p_attribute_category  = 'INDIA RMA RECEIPT' then
1606 
1607     p_codepath := jai_general_pkg.plot_codepath(14, p_codepath); /* 14  */
1608 
1609     if  p_excise_rcvble_account is null then
1610       p_codepath := jai_general_pkg.plot_codepath(15, p_codepath); /* 15  */
1611       p_process_flag    := 'E';
1612       p_process_message := 'Excise Receivable Account is not defined in JAI_CMN_INVENTORY_ORGS, ' ||
1613                            'for the organization location or null location, cannot proceed as transaction type is RMA';
1614       goto exit_from_procedure;
1615     else
1616       p_codepath := jai_general_pkg.plot_codepath(16, p_codepath); /* 16  */
1617       p_ap_accrual_account := p_excise_rcvble_account;
1618     end if;
1619 
1620 
1621   elsif p_po_accrual_account_id is not null then
1622 
1623     p_codepath := jai_general_pkg.plot_codepath(17, p_codepath); /* 17  */
1624     p_ap_accrual_account := p_po_accrual_account_id;
1625 
1626   elsif p_ap_accrual_account is null then
1627 
1628     p_codepath := jai_general_pkg.plot_codepath(18, p_codepath); /* 18  */
1629     p_process_flag    := 'E';
1630     p_process_message := 'AP Accrual Account is not defined in mtl_parameters for the organization.';
1631     goto exit_from_procedure;
1632 
1633   end if; /* p_receipt_source_code = 'INTERNAL ORDER' */
1634 
1635   /* End Validate Accrual Account */
1636 
1637 
1638   /* Start 'RETURN TO VENDOR'  RTV expense account check */
1639 
1640   p_codepath := jai_general_pkg.plot_codepath(19, p_codepath); /* 19  */
1641   if ( (p_transaction_type = 'RETURN TO VENDOR')
1642         or
1643        (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RETURN TO VENDOR')
1644       )
1645   then
1646 
1647     /* Check if Customs, CVD (BOE) or third party type taxes exist */
1648     p_codepath := jai_general_pkg.plot_codepath(20,  p_codepath); /* 20  */
1649 
1650     if (  (p_cvd_taxes <> 0) OR
1651           (p_add_cvd_taxes     <> 0) OR  /*5228046 Additional cvd Enhancement*/
1652           (p_customs_taxes <> 0) OR
1653 	  (p_third_party_taxes <> 0)
1654 	) then
1655 
1656       p_codepath := jai_general_pkg.plot_codepath(21,  p_codepath); /* 21  */
1657 
1658       if  p_rtv_expense_account_id is null then
1659         p_codepath := jai_general_pkg.plot_codepath(22, p_codepath); /* 22  */
1660         p_process_flag    := 'E';
1661         p_process_message := 'RTV Expense Account is not defined in JAI_CMN_INVENTORY_ORGS, ' ||
1662                              'for the organization location or null location, cannot proceed as transaction type is RTV';
1663         goto exit_from_procedure;
1664       end if;
1665 
1666     end if; /* Custom / CVD /third party type of taxes exist  */
1667 
1668 
1669   end if;
1670 
1671   /* End 'RETURN TO VENDOR'  RTV expense account check */
1672 
1673 
1674   /* Start BOE a/c check */
1675   if ( (p_transaction_type = 'RECEIVE')
1676         or
1677        (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RECEIVE')
1678       )
1679   then
1680 
1681     if (  (p_cvd_taxes <> 0) or
1682           (p_add_cvd_taxes     <> 0) OR  /*5228046 Additional cvd Enhancement*/
1683           (p_customs_taxes <> 0)
1684 	) then
1685 
1686       p_codepath := jai_general_pkg.plot_codepath(23, p_codepath); /* 23  */
1687 
1688       if p_boe_account_id is null then
1689           p_codepath := jai_general_pkg.plot_codepath(24, p_codepath); /* 24  */
1690           p_process_flag    := 'E';
1691           p_process_message := 'BOE Account is not defined in JAI_CMN_INVENTORY_ORGS, ' ||
1692                                'for the organization location or null location.';
1693           goto exit_from_procedure;
1694       end if;
1695     end if;
1696 
1697   end if; /*'RECEIVE'*/
1698   /* End BOE a/c check */
1699 
1700 
1701   << exit_from_procedure >>
1702   p_codepath := jai_general_pkg.plot_codepath(25, p_codepath, null, 'END'); /* 25  */
1703 
1704   if p_process_flag is null then
1705     p_process_flag    := 'Y';
1706   end if;
1707 
1708   if p_debug = 'Y' then
1709 --    Fnd_File.put_line(Fnd_File.LOG, '  Code Path :' || p_codepath );/*Bug 5527885*/
1710     Fnd_File.put_line(Fnd_File.LOG, '  ** End of procedure jai_rcv_rcv_rtv_pkg.validate_transaction_tax_accnt **  ');
1711   end if;
1712 
1713   return;
1714 
1715 exception
1716   when others then
1717     p_process_flag    := 'E';
1718     p_process_message := 'RECEIVE_RTV_PKG.validate_transaction_tax_accnt:'|| sqlerrm;
1719     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
1720     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
1721     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END'); /* 24 */
1722     return;
1723 
1724 end validate_transaction_tax_accnt;
1725 
1726 /****************************** End validate_transaction_tax_accnt ******************************/
1727 
1728 /****************************** Start apply_relieve_boe ******************************/
1729   procedure apply_relieve_boe
1730   (
1731     p_transaction_id                           in                 number,
1732     p_transaction_type                         in                 varchar2,
1733     p_parent_transaction_id                    in                 number,
1734     p_parent_transaction_type                  in                 varchar2,
1735     p_shipment_line_id                         in                 number,
1736     p_shipment_header_id                       in                 number,
1737     p_organization_id                          in                 number,
1738     p_inventory_item_id                        in                 number,
1739     p_cvd_taxes                                in                 number,
1740     p_add_cvd_taxes                            in                 number,/*5228046 Additional cvd Enhancement*/
1741     p_customs_taxes                            in                 number,
1742     p_cvd_edu_cess                             in                 number, /* Educational Cess */
1743     p_cvd_sh_edu_cess                          in                 number, /*Bug 5989740 bduvarag*/
1744     p_customs_edu_cess                         in                 number, /* Educational Cess */
1745     p_customs_sh_edu_cess                      in                 number, /*Bug 5989740 bduvarag*/
1746     p_simulation                               in                 varchar2,
1747     p_debug                                    in                 varchar2,  -- default 'N', File.Sql.35
1748     p_process_flag                             out     nocopy     varchar2,
1749     p_process_message                          out     nocopy     varchar2,
1750     p_codepath                                 in out  nocopy     varchar2
1751   )
1752   is
1753 
1754   cursor    c_is_boe_applied(cp_shipment_line_id number, cp_parent_transaction_id number) is
1755     select  count(boe_id)
1756     from    JAI_CMN_BOE_MATCHINGS
1757     where   shipment_line_id  =   cp_shipment_line_id
1758     and     transaction_id    =   cp_parent_transaction_id;
1759 
1760   ln_boe_count      number; -- :=0  File.Sql.35 by Brathod
1761 
1762 begin
1763   ln_boe_count := 0;  -- File.Sql.35 by Brathod
1764   if p_debug = 'Y' then
1765     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.apply_relieve_boe **');
1766   end if;
1767 
1768   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.apply_relieve_boe', 'START'); /* 1  */
1769 
1770   if not (p_transaction_type = 'CORRECT' and p_parent_transaction_type = 'RECEIVE') then
1771     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2  */
1772     -- ABC
1773     --p_process_flag := 'Y';
1774     --p_process_message := 'apply_relieve_boe is not required as this is not a case of CORRECT to RECEIVE';
1775     FND_FILE.put_line( FND_FILE.log, 'Apply_relieve_boe is not required as this is not a case of CORRECT to RECEIVE');
1776     goto exit_from_procedure;
1777   elsif (p_cvd_taxes + p_add_cvd_taxes + p_customs_taxes) = 0 then /*5228046 Additional cvd Enhancement added p_add_cvd_taxes*/
1778     p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3  */
1779     -- ABC
1780     --p_process_flag := 'Y';
1781     --p_process_message := 'apply_relieve_boe is not required as no CVD or Customs type of tax';
1782     FND_FILE.put_line( FND_FILE.log, 'Apply_relieve_boe is not required as no CVD or ADDITIONAL_CVD or Customs type of tax');
1783     goto exit_from_procedure;
1784   end if;
1785 
1786   /* Check if BOE has been applied for the parent transaction */
1787   p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4  */
1788   open c_is_boe_applied(p_shipment_line_id, p_parent_transaction_id);
1789   fetch c_is_boe_applied into ln_boe_count;
1790   close c_is_boe_applied;
1791 
1792   if nvl(ln_boe_count, 0) = 0 then
1793     p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5  */
1794     -- ABC
1795     --p_process_flag := 'Y';
1796     --p_process_message := 'apply_relieve_boe is not required parent transaction has no BOE applied';
1797     FND_FILE.put_line( FND_FILE.log, 'Apply_relieve_boe is not required parent transaction has no BOE applied');
1798     goto exit_from_procedure;
1799   end if;
1800 
1801 
1802   if (p_cvd_taxes + p_add_cvd_taxes + p_customs_taxes) > 0 then /*5228046 Additional cvd Enhancement added p_add_cvd_taxes*/
1803 
1804     if p_debug = 'Y' then
1805       Fnd_File.put_line(Fnd_File.LOG, ' Call to -> apply_boe');
1806     end if;
1807     p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6  */
1808     apply_boe
1809     (
1810       p_shipment_header_id      =>     p_shipment_header_id,
1811       p_shipment_line_id        =>     p_shipment_line_id,
1812       p_transaction_id          =>     p_transaction_id,
1813       p_organization_id         =>     p_organization_id,
1814       p_inventory_item_id       =>     p_inventory_item_id,
1815       p_boe_tax                 =>     p_cvd_taxes     +
1816                                        p_add_cvd_taxes + /*5228046 Additional cvd Enhancement added p_add_cvd_taxes*/
1817                                        p_customs_taxes +
1818                                        p_cvd_edu_cess  +
1819                                        p_cvd_sh_edu_cess  + /*Bug 5989740 bduvarag*/
1820                                        p_customs_edu_cess +
1821                                        p_customs_sh_edu_cess,
1822       p_simulation              =>     p_simulation,
1823       p_process_flag            =>     p_process_flag,
1824       p_process_message         =>     p_process_message,
1825       p_debug                   =>     p_debug,
1826       p_codepath                =>     p_codepath
1827     );
1828 
1829   else
1830 
1831     if p_debug = 'Y' then
1832       Fnd_File.put_line(Fnd_File.LOG, ' Call to -> relieve_boe');
1833     end if;
1834     p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7  */
1835     relieve_boe
1836     (
1837       p_shipment_header_id      =>     p_shipment_header_id,
1838       p_shipment_line_id        =>     p_shipment_line_id,
1839       p_transaction_id          =>     p_transaction_id,
1840       p_parent_transaction_id   =>     p_parent_transaction_id,
1841       p_boe_tax                 =>     p_cvd_taxes     +
1842                                        p_add_cvd_taxes + /*5228046 Additional cvd Enhancement added p_add_cvd_taxes*/
1843                                        p_customs_taxes +
1844                                        p_cvd_edu_cess  +
1845 				       p_cvd_sh_edu_cess  + /*Bug 5989740 bduvarag*/
1846                                        p_customs_edu_cess +
1847                                        p_customs_sh_edu_cess,
1848       p_simulation              =>     p_simulation,
1849       p_process_flag            =>     p_process_flag,
1850       p_process_message         =>     p_process_message,
1851       p_debug                   =>     p_debug,
1852       p_codepath                =>     p_codepath
1853     );
1854 
1855   end if;
1856 
1857   /* If apply relieve BOE has been done successfully, update the boe_applied_flag in ja_in_rcv_transaction */
1858   if p_process_flag = 'Y' and nvl(p_simulation , 'Y') <> 'Y'  then
1859 
1860     p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8  */
1861     update  JAI_RCV_TRANSACTIONS
1862     set     boe_applied_flag = 'Y'
1863     where   transaction_id = p_transaction_id;
1864 
1865   end if;
1866 
1867   << exit_from_procedure >>
1868   p_codepath := jai_general_pkg.plot_codepath(9, p_codepath, null, 'END'); /* 9  */
1869 
1870   if p_process_flag is null then
1871     p_process_flag    := 'Y';
1872   end if;
1873 
1874   return;
1875 
1876 exception
1877   when others then
1878     p_process_flag    := 'E';
1879     p_process_message := 'RECEIVE_RTV_PKG.apply_relieve_boe:' || sqlerrm;
1880     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
1881     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
1882     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END'); /* 24 */
1883     return;
1884 
1885 end apply_relieve_boe;
1886 
1887 
1888 /****************************** End   apply_relieve_boe ******************************/
1889 
1890 
1891 /****************************** Start apply_boe ******************************/
1892 
1893   procedure apply_boe
1894   (
1895     p_shipment_header_id                       in                 number,
1896     p_shipment_line_id                         in                 number,
1897     p_transaction_id                           in                 number,
1898     p_organization_id                          in                 number,
1899     p_inventory_item_id                        in                 number,
1900     p_boe_tax                                  in                 number,
1901     p_simulation                               in                 varchar2,
1902     p_debug                                    in                 varchar2,  -- default 'N', File.Sql.35
1903     p_process_flag                             out     nocopy     varchar2,
1904     p_process_message                          out     nocopy     varchar2,
1905     p_codepath                                 in out  nocopy     varchar2
1906   )
1907 is
1908 
1909   cursor c_ja_in_boe_hdr (cp_organization_id number, cp_inventory_item_id number) is
1910   select boe_id,
1911          ( nvl(boe_amount, 0) - nvl(amount_applied, 0) - nvl(amount_written_off, 0) )
1912          available_amount
1913   from   JAI_CMN_BOE_HDRS  jbh
1914   where  organization_id =  p_organization_id
1915   and    ( nvl(boe_amount, 0) - nvl(amount_applied, 0) - nvl(amount_written_off, 0) ) > 0
1916   and    ( ( nvl(consolidated_flag, 'Y') = 'Y' )
1917            or
1918            ( exists ( select '1'
1919                       from   JAI_CMN_BOE_DTLS
1920                       where  boe_id = jbh.boe_id
1921                       and    item_number = cp_inventory_item_id
1922                      )
1923            )
1924          );
1925 
1926   ln_bal_boe_amount         number;
1927   ln_boe_amount_to_apply    number;
1928 
1929 begin
1930 
1931   if p_debug = 'Y' then
1932     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.apply_boe **');
1933   end if;
1934 
1935   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.apply_boe', 'START'); /* 1  */
1936 
1937   ln_bal_boe_amount := p_boe_tax;
1938 
1939   for cur_available_boe in c_ja_in_boe_hdr(p_organization_id, p_inventory_item_id) loop
1940 
1941     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2  */
1942 
1943     if ln_bal_boe_amount <= 0 then
1944       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3  */
1945       goto finish_apply;
1946     end if;
1947 
1948     if cur_available_boe.available_amount <= ln_bal_boe_amount then
1949       p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4  */
1950       ln_boe_amount_to_apply := cur_available_boe.available_amount;
1951     else
1952       p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5  */
1953       ln_boe_amount_to_apply := ln_bal_boe_amount;
1954     end if;
1955 
1956     if nvl(p_simulation , 'Y') <> 'Y' then
1957 
1958       p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6  */
1959 
1960       /* Insert a apply record in JAI_CMN_BOE_MATCHINGS */
1961       insert into JAI_CMN_BOE_MATCHINGS
1962       (BOE_MATCHING_ID,
1963         transaction_id,
1964         shipment_header_id,
1965         shipment_line_id,
1966         boe_id,
1967         amount,
1968         creation_date,
1969         created_by,
1970         last_update_date,
1971         last_updated_by
1972        )
1973       values
1974       ( JAI_CMN_BOE_MATCHINGS_S.nextval,
1975         p_transaction_id,
1976         p_shipment_header_id,
1977         p_shipment_line_id,
1978         cur_available_boe.boe_id,
1979         ln_boe_amount_to_apply,
1980         sysdate,
1981         fnd_global.user_id,
1982         sysdate,
1983         fnd_global.user_id
1984       );
1985 
1986       p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7  */
1987       /* update the boe header amount */
1988       update  JAI_CMN_BOE_HDRS
1989       set     amount_applied = nvl(amount_applied, 0) + ln_boe_amount_to_apply,
1990               last_update_date = sysdate,
1991               last_updated_by = fnd_global.user_id,
1992               last_update_login = fnd_global.user_id
1993       where   boe_id = cur_available_boe.boe_id;
1994 
1995       ln_bal_boe_amount := ln_bal_boe_amount - ln_boe_amount_to_apply;
1996 
1997       p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8  */
1998 
1999     end if;
2000 
2001     /* To indicate second pass of the loop, first means F, statement id need not be incremented in code path*/
2002 
2003   end loop;
2004 
2005   << finish_apply >>
2006   if ln_bal_boe_amount > 0 then
2007     p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9  */
2008     p_process_flag    := 'E';
2009     P_process_message := 'Matching BOE not available for applying the BOE tax, cannot proceed ' ||
2010                          '(jai_rcv_rcv_rtv_pkg.apply_boe)';
2011   end if;
2012 
2013   << exit_from_procedure >>
2014   p_codepath := jai_general_pkg.plot_codepath(10, p_codepath, null, 'END'); /* 10  */
2015 
2016   if p_process_flag is null then
2017     p_process_flag    := 'Y';
2018   end if;
2019 
2020   if p_debug = 'Y' then
2021     Fnd_File.put_line(Fnd_File.LOG, '  Code Path :' || p_codepath );
2022     Fnd_File.put_line(Fnd_File.LOG, '  ** End of procedure jai_rcv_rcv_rtv_pkg.apply_boe **  ');
2023   end if;
2024 
2025   return;
2026 
2027 exception
2028   when others then
2029     p_process_flag    := 'E';
2030     p_process_message := 'RECEIVE_RTV_PKG.apply_boe:'|| sqlerrm;
2031     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
2032     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
2033     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END'); /* 24 */
2034     return;
2035 
2036 end apply_boe;
2037 
2038 /****************************** End apply_boe ******************************/
2039 
2040 
2041 /****************************** Start relieve_boe ******************************/
2042 
2043   procedure relieve_boe
2044   (
2045     p_shipment_header_id                       in                 number,
2046     p_shipment_line_id                         in                 number,
2047     p_transaction_id                           in                 number,
2048     p_parent_transaction_id                    in                 number,
2049     p_boe_tax                                  in                 number,
2050     p_simulation                               in                 varchar2,
2051     p_debug                                    in                 varchar2,  -- default 'N', File.Sql.35
2052     p_process_flag                             out     nocopy     varchar2,
2053     p_process_message                          out     nocopy     varchar2,
2054     p_codepath                                 in out  nocopy     varchar2
2055   )
2056   is
2057 
2058   cursor c_ja_in_rcp_boe(cp_shipment_line_id number, cp_transaction_id number) is
2059     select boe_id, amount
2060     from   JAI_CMN_BOE_MATCHINGS
2061     where  shipment_line_id = cp_shipment_line_id
2062     and    transaction_id =   cp_transaction_id;
2063 
2064   ln_bal_boe_amount         number;
2065   ln_boe_amount_to_unapply  number;
2066 
2067 begin
2068 
2069   if p_debug = 'Y' then
2070     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.relieve_boe **');
2071   end if;
2072 
2073   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.relieve_boe', 'START'); /* 1  */
2074   ln_bal_boe_amount :=  p_boe_tax;
2075 
2076   for applied_boe_rec in   c_ja_in_rcp_boe(p_shipment_line_id, p_parent_transaction_id) loop
2077 
2078     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2  */
2079     if  ln_bal_boe_amount = 0 then
2080       p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3  */
2081       goto   finished_unapply;
2082     end if;
2083 
2084     if   applied_boe_rec.amount <= abs(ln_bal_boe_amount) then
2085       p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4  */
2086       ln_boe_amount_to_unapply := -1 * applied_boe_rec.amount;
2087     else
2088       p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5  */
2089       ln_boe_amount_to_unapply := ln_bal_boe_amount;
2090     end if;
2091 
2092     if nvl(p_simulation , 'Y') <> 'Y' then
2093       /* Insert a unapply record in JAI_CMN_BOE_MATCHINGS */
2094       p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6  */
2095       insert into JAI_CMN_BOE_MATCHINGS
2096       (BOE_MATCHING_ID,
2097         transaction_id,
2098         shipment_header_id,
2099         shipment_line_id,
2100         boe_id,
2101         amount,
2102         creation_date,
2103         created_by,
2104         last_update_date,
2105         last_updated_by
2106        )
2107       values
2108       ( JAI_CMN_BOE_MATCHINGS_S.nextval,
2109         p_transaction_id,
2110         p_shipment_header_id,
2111         p_shipment_line_id,
2112         applied_boe_rec.boe_id,
2113         ln_boe_amount_to_unapply,
2114         sysdate,
2115         fnd_global.user_id,
2116         sysdate,
2117         fnd_global.user_id
2118       );
2119 
2120       /* update the boe header amount */
2121       p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7  */
2122       update  JAI_CMN_BOE_HDRS
2123       set     amount_applied = nvl(amount_applied, 0) + ln_boe_amount_to_unapply,
2124               last_update_date = sysdate,
2125               last_updated_by = fnd_global.user_id,
2126               last_update_login = fnd_global.user_id
2127       where   boe_id = applied_boe_rec.boe_id;
2128 
2129     end if; /* p_simulation = 'Y' */
2130 
2131     p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8  */
2132     ln_bal_boe_amount := ln_bal_boe_amount - ln_boe_amount_to_unapply;
2133 
2134 
2135   end loop;
2136 
2137   << finished_unapply >>
2138     p_process_flag := 'Y';
2139 
2140   << exit_from_procedure >>
2141   p_codepath := jai_general_pkg.plot_codepath(9, p_codepath, null, 'END'); /* 9  */
2142 
2143   if p_process_flag is null then
2144     p_process_flag    := 'Y';
2145   end if;
2146 
2147   if p_debug = 'Y' then
2148     Fnd_File.put_line(Fnd_File.LOG, '  Code Path :' || p_codepath );
2149     Fnd_File.put_line(Fnd_File.LOG, '  ** End of procedure jai_rcv_rcv_rtv_pkg.relieve_boe **  ');
2150   end if;
2151 
2152   return;
2153 
2154 exception
2155   when others then
2156     p_process_flag    := 'E';
2157     p_process_message := 'RECEIVE_RTV_PKG.relieve_boe:' || sqlerrm;
2158     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
2159     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
2160     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END'); /* 24 */
2161     return;
2162 
2163 end relieve_boe;
2164 
2165 /****************************** End relieve_boe ******************************/
2166 
2167 
2168 /****************************** Start post_entries ******************************/
2169   procedure post_entries
2170   (
2171     p_transaction_id                            in                number,
2172     p_transaction_type                          in                varchar2,
2173     p_parent_transaction_type                   in                varchar2,
2174     -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. p_attribute_category                        in                varchar2,
2175     p_receipt_source_code                       in                varchar2,
2176     p_transaction_date                          in                date,
2177     p_receipt_num                               in                varchar2,
2178     p_receiving_account_id                      in                number,
2179     p_ap_accrual_account                        in                number,
2180     p_boe_account_id                            in                number,
2181     p_rtv_expense_account_id                    in                number,
2182     p_intransit_type                            in                number,
2183     p_fob_point                                 in                number,
2184     p_intransit_inv_account                     in                number,
2185     p_interorg_receivables_account              in                number,
2186     p_all_taxes                                 in                number,
2187     p_tds_taxes                                 in                number,
2188     p_modvat_recovery_taxes                     in                number,
2189     p_cvd_taxes                                 in                number,
2190     p_add_cvd_taxes                             in                number,/*5228046 Additional cvd Enhancement*/
2191     p_customs_taxes                             in                number,
2192     p_third_party_taxes                         in                number,
2193     p_excise_tax                                in                number,
2194     p_service_recoverable                       in                number, /* Service */
2195     p_service_not_recoverable                   in                number, /* Service */
2196     p_account_service_interim                   in                boolean, /* Service */
2197     /* following two params added by Vijay Shankar for Bug#4250236(4245089). VAT Impl. */
2198     p_vat_recoverable                           in                number,
2199     p_vat_not_recoverable                       in                number,
2200     p_excise_edu_cess                           in                number, /* Educational Cess */
2201     p_excise_sh_edu_cess                        in                number, /*Bug 5989740 bduvarag*/
2202     p_cvd_edu_cess                              in                number, /* Educational Cess */
2203     p_cvd_sh_edu_cess                           in                number, /*Bug 5989740 bduvarag*/
2204     p_customs_edu_cess                          in                number, /* Educational Cess */
2205     p_customs_sh_edu_cess                       in                number, /*Bug 5989740 bduvarag*/
2206     p_trading_to_trading_iso                    in                varchar2, /* Bug#4171469 */
2207     ptr_jv                                      in OUT NOCOPY JOURNAL_LINES,  /* 5527885 */
2208     p_simulation                                in                varchar2,
2209     p_debug                                     in                varchar2,  -- default 'N', File.Sql.35
2210     p_process_flag                              out     nocopy    varchar2,
2211     p_process_message                           out     nocopy    varchar2,
2212     p_codepath                                  in out  nocopy    varchar2
2213   )  is
2214 
2215   cursor c_ja_in_temp_po_accrual (cp_transaction_id number) is
2216     select  count(1)
2217     from    JAI_RCV_REP_ACCRUAL_T
2218     where   transaction_id = cp_transaction_id;
2219 
2220   ln_ja_in_temp_po_accrual      number;
2221 
2222   ln_credit                     number;
2223   ln_debit                      number;
2224 
2225   /* File.Sql.35 by Brathod */
2226   lv_source_name                varchar2(20); -- := 'Purchasing India'; -- Harshita . modified the size from 15 to 20 for Bug 4762433
2227   lv_category_name              varchar2(15); --:= 'Receiving India';
2228   lv_acct_nature                varchar2(15); --:= 'Receiving';
2229   lv_acct_type                  varchar2(15);  /* Regular or Reversal*/
2230 
2231   lv_reference_10               varchar2(240);
2232   lv_reference_23               varchar2(240); -- := 'jai_rcv_rcv_rtv_pkg.post_entries';
2233   lv_reference_24               varchar2(240); -- := 'rcv_transactions';
2234   lv_reference_25               varchar2(240); -- :=  'transaction_id';
2235   lv_reference_26               varchar2(240);
2236   /* End of File.Sql.35 by Brathod */
2237 
2238 
2239 begin
2240 /* -----------------------------------------------------------------------------------------------
2241 
2242 |  Type |  Additional  |  Account             | Debit/Credit    |  Tax details                     |
2243 |       |  Condition   |                      |                 |                                  |
2244 |  ==== |  ==========  |  ============        | ===========     |  ===========                     |
2245 |  RTV  |  None        |  Receiving           | Credit          | ALL -                            |
2246 |       |              |                      |                 | (TDS + Modvat Recovery +         |
2247 |       |              |                      |                 |  Recoverable Service Tax +       |
2248 |       |              |                      |                 |  Recoverable VAT Tax )           |
2249 |       |              |                      |                 |                                  |
2250 |       |              |                      |                 |                                  |
2251 |       |  None        |  AP Accrual          | Debit           |  ALL -                           |
2252 |       |              |                      |                 | (TDS + Modvat Recovery +         |
2253 |       |              |                      |                 |  3rd Party + CVD + Customs +     |
2254 |       |              |                      |                 |  Recoverable Service Tax** +     |
2255 |       |              |                      |                 |  Recoverable VAT     Tax** +     |
2256 |       |              |                      |                 |  CVD Edu Cess + Custom Edu Cess) |
2257 |       |              |                      |                 |                                  |
2258 |       |  None        |  RTV expense         | Debit           | 3rd Party + CVD + Customs        |
2259 |       |              |                      |                 | CVD Edu Cess + Custom Edu Cess   |
2260 |       |              |                      |                 |                                  |
2261 |       |              |                      |                 |                                  |
2262 |=======|==============|======================|=================|==================================|
2263 |       |              |                      |                 |                                  |
2264 |  RMA  |  SCRAP type  |  Excise Expense      | Debit           | Excise + CVD +                   |
2265 |       |              |                      |                 | Excise Edu Cess + CVD Edu Cess   |
2266 |       |              |  Excise Receivable   | Credit          | Excise + CVD                     |
2267 |       |              |                      |                 | Excise Edu Cess + CVD Edu Cess   |
2268 |       |              |                      |                 |                                  |
2269 |       |              |                      |                 |                                  |
2270 |=======|==============|======================|=================|==================================|
2271 |  ISO  |  None        |  Receiving           | Debit           |  ALL -                           |
2272 |       |              |                      |                 | (TDS + Modvat Recovery +         |
2273 |       |              |                      |                 |  Recoverable Service Tax )       |
2274 |       |              |                      |                 |                                  |
2275 |       |              |                      |                 |                                  |
2276 |       |              |                      |                 |                                  |
2277 |       |  None        |  Intransit Inventory | Credit          | ALL -                            |
2278 |       |              |                      |                 |(TDS + Modvat Recovery +          |
2279 |       |              |                      |                 | CVD + Customs                    |
2280 |       |              |                      |                 |                                  |
2281 |       |              |                      |                 |                                  |
2282 |       |  None        |  BOE                 | Credit          | CVD + Customs +                  |
2283 |       |              |                      |                 | CVD Edu Cess + Custom Edu Cess   |
2284 |       |--------------|----------------------|-----------------|----------------------------------|
2285 |       |              |                      |                 |                                  |
2286 |       |              |                      |                 |                                  |
2287 |       |  Intransit   |                      |                 |                                  |
2288 |       |  Type=2 &    |                      |                 |                                  |
2289 |       |  FOB point=2 |  Interorg Payables   | Credit          |  ALL -                           |
2290 |       |  and not     |                      |                 |  (TDS + Modvat Recovery +        |
2291 |       |  trading to  |                      |                 |   CVD + Customs +                |
2292 |       |  trading ISO |                      |                 |   CVD Edu Cess + Custom Edu Cess |
2293 |       |              |                      |                 |                                  |
2294 |       |  Intransit   |                      |                 |                                  |
2295 |       |  Type=2 &    |                      |                 |                                  |
2296 |       |  FOB point=2 |  Interorg Receivables| Debit           |  ALL -                           |
2297 |       |  and not     |                      |                 |  (TDS + Modvat Recovery +        |
2298 |       |  trading to  |                      |                 |   CVD + Customs +                |
2299 |       |  trading ISO |                      |                 |   CVD Edu Cess + Custom Edu Cess |
2300 |       |              |                      |                 |                                  |
2301 |       |              |                      |                 |                                  |
2302 |       |              |                      |                 |                                  |
2303 |=======|==============|======================|=================|================================= |
2304 |       |              |                      |                 |                                  |
2305 |PO     |  None        | Receiving            |Debit            | ALL -                            |
2306 |Receive|              |                      |                 | (TDS + Modvat Recovery +         |
2307 |       |              |                      |                 |  Recoverable Service Tax +       |
2308 |       |              |                      |                 |  Recoverable VAT Tax )           |
2309 |       |              |                      |                 |                                  |
2310 |       |              |                      |                 |                                  |
2311 |       |  None        |  AP Accrual          |Credit           | ALL -                            |
2312 |       |              |                      |                 |(TDS + Modvat Recovery +          |
2313 |       |              |                      |                 | CVD + Customs +                  |
2314 |       |              |                      |                 | Recoverable Service Tax** +      |
2315 |       |              |                      |                 | Recoverable VAT Tax** +          |
2316 |       |              |                      |                 | CVD Edu Cess + Custom Edu Cess)  |
2317 |       |              |                      |                 |                                  |
2318 |       |  None        |  BOE                 | Credit          | CVD + Customs                    |
2319 |       |              |                      |                 | CVD Edu Cess + Custom Edu Cess   |
2320 |=======|==============|======================|=================|================================= |
2321 |       |              |                      |                 |                                  |
2322 |Service Tax Accounting at Receive, RTV or their Correct when recoverable service/vat tax exists **|
2323 |       |              |                      |                 |                                  |
2324 |PO     |  None        | Service Tax Interim  | Debit           | Recoverable Service Tax          |
2325 |       |              | Recovery a/c         |                 | By tax type                      |
2326 |       |              | for org and tax type |                 |                                  |
2327 |       |              |                      |                 |                                  |
2328 |       |              |                      |                 |                                  |
2329 |PO     |  None        | VAT Tax Interim      | Debit           | Recoverable VAT Tax              |
2330 |       |              | Recovery a/c         |                 | By tax type                      |
2331 |       |              | for org and tax type |                 |                                  |
2332 |       |              |                      |                 |                                  |
2333 |       |              |                      |                 |                                  |
2334 |-------|--------------|----------------------|-----------------|--------------------------------  |
2335 |                                                                                                  |
2336 | References:                                                                                      |
2337 | ** - In addition to the existance of recoverable service tax, the following condition should also|
2338 | be NOT TRUE.                                                                                     |
2339 |                                                                                                  |
2340 | ( accrue on receipt = 'N' or (inventory item = 'N' and accounting method option = 'Cash') )      |
2341 |                                                                                                  |
2342 |-----------------------------------------------------------------------------------------------   */
2343   /* File.Sql.35 by Brathod */
2344   lv_source_name                := 'Purchasing India';
2345   lv_category_name              := 'Receiving India';
2346   lv_acct_nature                := 'Receiving';
2347   lv_reference_23               := 'jai_rcv_rcv_rtv_pkg.post_entries';
2348   lv_reference_24               := 'rcv_transactions';
2349   lv_reference_25               :=  'transaction_id';
2350   /* End of File.Sql.35 by Brathod*/
2351 
2352   if p_debug = 'Y' then
2353     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.post_entries **');
2354   end if;
2355 
2356   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.post_entries', 'START'); /* 1  */
2357   /* Set varaiable values for accounting entries with GL link */
2358   if ( (p_transaction_type = 'RETURN TO VENDOR')
2359         or
2360        (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RETURN TO VENDOR')
2361       )
2362   then
2363     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2  */
2364     lv_acct_type := 'REVERSAL';
2365   else
2366     p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3  */
2367     lv_acct_type := 'REGULAR';
2368   end if;
2369 
2370   p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4  */
2371   lv_reference_10 :=  'India Local Receiving Entry for the Receipt Number ' || p_receipt_num ||
2372                       ' for the Transaction Type ' || p_transaction_type ;
2373 
2374   if p_transaction_type = 'CORRECT' then
2375     lv_reference_10 := lv_reference_10 || ' of type ' || p_parent_transaction_type;
2376   end if;
2377 
2378 
2379   lv_reference_26 :=  to_char(p_transaction_id);
2380 
2381   /* Accounting Entry # 1 : Receiving Account Id */
2382   ln_credit := null;
2383   ln_debit  := null;
2384     Fnd_File.put_line(Fnd_File.LOG, ' p_receiving_account_id :' || p_receiving_account_id );
2385   if  p_receiving_account_id is not null then
2386 
2387     p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5  */
2388 
2389     if ( (p_transaction_type = 'RETURN TO VENDOR')
2390           or
2391          (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RETURN TO VENDOR')
2392         )
2393     then
2394 
2395        p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6  */
2396        ln_debit  := null;
2397        ln_credit :=
2398        p_all_taxes -
2399        (p_tds_taxes + p_modvat_recovery_taxes + p_service_recoverable + p_vat_recoverable); /* Service */
2400 
2401 
2402     elsif p_receipt_source_code = 'CUSTOMER' and /*RMA CASE*/
2403      -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. if p_attribute_category  = 'INDIA RMA RECEIPT' and
2404           ( (p_transaction_type = 'RECEIVE')
2405               or
2406             (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RECEIVE')
2407           )
2408     then
2409 
2410       p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7  */
2411       ln_debit  := p_cvd_taxes     +
2412                    p_add_cvd_taxes +  /*5228046 Additional cvd Enhancement*/
2413                    p_excise_tax    +
2414                    p_cvd_edu_cess  +
2415                    p_cvd_sh_edu_cess  +  /*Bug 5989740 bduvarag*/
2416                    p_excise_edu_cess + /* Educational Cess */
2417                    p_excise_sh_edu_cess;
2418       ln_credit := null;
2419 
2420     else
2421 
2422       p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8  */
2423 
2424       ln_debit  :=
2425       p_all_taxes -
2426       (p_tds_taxes + p_modvat_recovery_taxes + p_service_recoverable + p_vat_recoverable);
2427 
2428 
2429       ln_credit := null;
2430 
2431     end if;
2432 
2433     p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9  */
2434         Fnd_File.put_line(Fnd_File.LOG, ' ln_debit :' || ln_debit );
2435 	        Fnd_File.put_line(Fnd_File.LOG, ' ln_credit :' || ln_credit );
2436     if ( nvl(ln_debit, 0) <> 0 or nvl(ln_credit, 0) <> 0 ) then
2437           p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10  */
2438       /* procedure to populate gl inetrface, JAI_RCV_JOURNAL_ENTRIES and receiving subledger */
2439        Fnd_File.put_line(Fnd_File.LOG, 'Acc for inventory  Receiving Account ' );
2440 
2441       ptr_jv(1).line_num           := 1;
2442       ptr_jv(1).acct_type          := lv_acct_type;
2443       ptr_jv(1).acct_nature        := lv_acct_nature;
2444       ptr_jv(1).source_name        := lv_source_name;
2445       ptr_jv(1).category_name      := lv_category_name;
2446       ptr_jv(1).ccid               := p_receiving_account_id;
2447       ptr_jv(1).entered_dr         := round(ln_debit, gn_currency_precision);
2448       ptr_jv(1).entered_cr         := round(ln_credit, gn_currency_precision);
2449       ptr_jv(1).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
2450       ptr_jv(1).accounting_date    := p_transaction_date;
2451       ptr_jv(1).reference_10       := lv_reference_10;
2452       ptr_jv(1).reference_23       := lv_reference_23;
2453       ptr_jv(1).reference_24       := lv_reference_24;
2454       ptr_jv(1).reference_25       := lv_reference_25;
2455       ptr_jv(1).reference_26       := lv_reference_26;
2456       ptr_jv(1).destination        := 'G';
2457       -- ptr_jv(1).reference_name     := ;
2458       ptr_jv(1).reference_id       := p_transaction_id;
2459       ptr_jv(1).non_rnd_entered_dr := ln_debit;
2460       ptr_jv(1).non_rnd_entered_cr := ln_credit;
2461       ptr_jv(1).account_name       := gv_inv_receiving;
2462       ptr_jv(1).summary_jv_flag    := 'Y';
2463 /*Bug 5527885 End*/
2464     end if;
2465 
2466   end if; /* Accounting Entry # 1. Receiving Account Id */
2467 
2468 
2469   /* Accounting Entry # 2 : AP Accrual Account Id. Non mandatory entry values may be 0*/
2470   p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12  */
2471 
2472   ln_credit := null;
2473   ln_debit  := null;
2474        Fnd_File.put_line(Fnd_File.LOG, 'p_ap_accrual_account:'||p_ap_accrual_account );
2475   if p_ap_accrual_account is not null then
2476 
2477     if ( (p_transaction_type = 'RETURN TO VENDOR')
2478           or
2479          (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RETURN TO VENDOR')
2480         )
2481     then
2482 
2483        p_codepath := jai_general_pkg.plot_codepath(13, p_codepath); /* 13  */
2484        ln_debit  := p_all_taxes -
2485                     ( p_tds_taxes             +
2486                       p_modvat_recovery_taxes +
2487                       p_cvd_taxes             +
2488                       p_add_cvd_taxes         + /*5228046 Additional cvd Enhancement*/
2489                       p_customs_taxes         +
2490                       p_third_party_taxes     +
2491                       p_cvd_edu_cess          +
2492 		      p_cvd_sh_edu_cess       +		/*Bug 5989740 bduvarag*/
2493                       p_customs_edu_cess			+
2494                       p_customs_sh_edu_cess
2495                     );
2496        ln_credit := null;
2497 
2498        if  not p_account_service_interim then
2499          /* Separate Accounting for recoverable service tax not required */
2500          p_codepath := jai_general_pkg.plot_codepath(13.1, p_codepath); /* 13.1  */
2501          ln_debit :=  ln_debit - p_service_recoverable;
2502        end if;
2503 
2504 
2505     elsif p_receipt_source_code = 'CUSTOMER' then
2506       -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. if p_attribute_category  = 'INDIA RMA RECEIPT' then
2507 
2508       p_codepath := jai_general_pkg.plot_codepath(14, p_codepath); /* 14  */
2509       ln_debit  :=  null;
2510       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_edu_cess /*Bug 5989740 bduvarag*/;
2511 
2512     else
2513 
2514       p_codepath := jai_general_pkg.plot_codepath(15, p_codepath); /* 15  */
2515       ln_debit  :=  null;
2516       ln_credit  := p_all_taxes -
2517                    ( p_tds_taxes + p_modvat_recovery_taxes +
2518                      p_cvd_taxes + p_add_cvd_taxes /*5228046 Additional cvd Enhancement*/ +
2519                      p_customs_taxes +
2520                      p_cvd_edu_cess +
2521 		     p_cvd_sh_edu_cess +		/*Bug 5989740 bduvarag*/
2522                      p_customs_edu_cess +
2523                      p_customs_sh_edu_cess );
2524 
2525        if  not p_account_service_interim then
2526         /* Separate Accounting for recoverable service tax not required */
2527         p_codepath := jai_general_pkg.plot_codepath(15.1, p_codepath); /* 15.1  */
2528         ln_credit :=  ln_credit - p_service_recoverable;
2529        end if;
2530 
2531     end if;
2532 
2533            Fnd_File.put_line(Fnd_File.LOG, 'ln_debit:'||ln_debit );
2534             Fnd_File.put_line(Fnd_File.LOG, 'ln_credit:'||ln_credit );
2535     p_codepath := jai_general_pkg.plot_codepath(16, p_codepath); /* 16  */
2536     if ( nvl(ln_debit, 0) <> 0  or nvl(ln_credit, 0) <> 0 ) then
2537       p_codepath := jai_general_pkg.plot_codepath(17, p_codepath); /* 17  */
2538 
2539 	      Fnd_File.put_line(Fnd_File.LOG, 'Accounting for interorg payables Acc' );
2540 /*
2541       IF p_receipt_source_code = 'INVENTORY' THEN 6488406
2542         ln_inter_org_acct := p_interorg_payables_account;
2543 	lv_acct_name      := gv_interorg_receiving;
2544       ELSE
2545         ln_inter_org_acct := p_ap_accrual_account;
2546 	lv_acct_name      := gv_ap_accrual;
2547       END IF; */
2548 
2549       ptr_jv(2).line_num           := 2;
2550       ptr_jv(2).acct_type          := lv_acct_type;
2551       ptr_jv(2).acct_nature        := lv_acct_nature;
2552       ptr_jv(2).source_name        := lv_source_name;
2553       ptr_jv(2).category_name      := lv_category_name;
2554       ptr_jv(2).ccid               := p_ap_accrual_account;/*6488406*/
2555       ptr_jv(2).entered_dr         := round(ln_debit, gn_currency_precision);
2556       ptr_jv(2).entered_cr         := round(ln_credit, gn_currency_precision);
2557       ptr_jv(2).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
2558       ptr_jv(2).accounting_date    := p_transaction_date;
2559       ptr_jv(2).reference_10       := lv_reference_10;
2560       ptr_jv(2).reference_23       := lv_reference_23;
2561       ptr_jv(2).reference_24       := lv_reference_24;
2562       ptr_jv(2).reference_25       := lv_reference_25;
2563       ptr_jv(2).reference_26       := lv_reference_26;
2564       ptr_jv(2).destination        := 'G';
2565       -- ptr_jv(2).reference_name     := ;
2566       ptr_jv(2).reference_id       := p_transaction_id;
2567       ptr_jv(2).non_rnd_entered_dr := ln_debit;
2568       ptr_jv(2).non_rnd_entered_cr := ln_credit;
2569       ptr_jv(2).account_name       := gv_ap_accrual;/*6488406*/
2570       ptr_jv(2).summary_jv_flag    := 'Y';
2571 /*Bug 5527885 End*/
2572       /* Inserting into JAI_RCV_REP_ACCRUAL_T if no record is already inserted */
2573       p_codepath := jai_general_pkg.plot_codepath(18, p_codepath); /* 18  */
2574       open  c_ja_in_temp_po_accrual(p_transaction_id);
2575       fetch c_ja_in_temp_po_accrual into ln_ja_in_temp_po_accrual;
2576       close c_ja_in_temp_po_accrual;
2577 
2578       if nvl(ln_ja_in_temp_po_accrual, 0) = 0 then
2579         p_codepath := jai_general_pkg.plot_codepath(19, p_codepath); /* 19  */
2580         insert into JAI_RCV_REP_ACCRUAL_T
2581         (
2582           transaction_id,
2583           accrual_amount,
2584           -- Harshita, added the 4 parameters below for Bug 4762433
2585           created_by    ,
2586           creation_date ,
2587           last_updated_by,
2588           last_update_date,
2589           last_update_login
2590         )
2591         values
2592         (
2593           p_transaction_id,
2594           round(nvl(ln_credit, ln_debit)) ,
2595           fnd_global.user_id,
2596           sysdate,
2597           fnd_global.user_id,
2598           sysdate,
2599           fnd_global.login_id
2600         );
2601       end if;
2602 
2603     end if; /* (ln_debit is not 0/null or ln_credit is not 0/null) */
2604 
2605 
2606   end if; /* p_ap_accrual_account */
2607 
2608 
2609   /* Accounting Entry # 3 : BOE Accounting Entry. Non mandatory entry */
2610   p_codepath := jai_general_pkg.plot_codepath(21, p_codepath); /* 21  */
2611 
2612   ln_credit := null;
2613   ln_debit  := null;
2614 
2615   if ( (p_transaction_type = 'RECEIVE')
2616         or
2617        (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RECEIVE')
2618       )
2619   then
2620 
2621     p_codepath := jai_general_pkg.plot_codepath(22, p_codepath); /* 22  */
2622     if   (p_cvd_taxes + p_add_cvd_taxes /*5228046 Additional cvd Enhancement*/
2623             + p_customs_taxes
2624 	    + p_cvd_edu_cess
2625 	    + p_cvd_sh_edu_cess  /*Bug 5989740 bduvarag*/
2626             + p_customs_edu_cess
2627             +p_customs_sh_edu_cess) <> 0 THEN
2628       p_codepath := jai_general_pkg.plot_codepath(23, p_codepath); /* 23  */
2629       ln_debit    :=  null;
2630       ln_credit   :=  (p_cvd_taxes + p_add_cvd_taxes /*5228046 Additional cvd Enhancement*/
2631                      + p_customs_taxes
2632 		     + p_cvd_edu_cess
2633 		     +p_cvd_sh_edu_cess  /*Bug 5989740 bduvarag*/
2634 	            + p_customs_edu_cess
2635 		    +p_customs_sh_edu_cess);
2636 
2637       ptr_jv(3).line_num           := 3;
2638       ptr_jv(3).acct_type          := lv_acct_type;
2639       ptr_jv(3).acct_nature        := lv_acct_nature;
2640       ptr_jv(3).source_name        := lv_source_name;
2641       ptr_jv(3).category_name      := lv_category_name;
2642       ptr_jv(3).ccid               := p_boe_account_id;
2643       ptr_jv(3).entered_dr         := round(ln_debit, gn_currency_precision);
2644       ptr_jv(3).entered_cr         := round(ln_credit, gn_currency_precision);
2645       ptr_jv(3).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
2646       ptr_jv(3).accounting_date    := p_transaction_date;
2647       ptr_jv(3).reference_10       := lv_reference_10;
2648       ptr_jv(3).reference_23       := lv_reference_23;
2649       ptr_jv(3).reference_24       := lv_reference_24;
2650       ptr_jv(3).reference_25       := lv_reference_25;
2651       ptr_jv(3).reference_26       := lv_reference_26;
2652       ptr_jv(3).destination        := 'G';
2653       -- ptr_jv(3).reference_name     := ;
2654       ptr_jv(3).reference_id       := p_transaction_id;
2655       ptr_jv(3).non_rnd_entered_dr := ln_debit;
2656       ptr_jv(3).non_rnd_entered_cr := ln_credit;
2657       ptr_jv(3).account_name       := gv_boe;
2658       ptr_jv(3).summary_jv_flag    := 'N';
2659 
2660       /*Bug 5527885*/
2661     end if;
2662 
2663   end if; /* BOE Accounting Entry */
2664 
2665 
2666 
2667   /* Accounting Entry # 4 : RTV expense Accounting Entry, non mandatory entry */
2668   p_codepath := jai_general_pkg.plot_codepath(24, p_codepath); /* 24  */
2669 
2670   ln_credit := null;
2671   ln_debit  := null;
2672 
2673   if ( (p_transaction_type = 'RETURN TO VENDOR')
2674         or
2675        (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RETURN TO VENDOR')
2676       )
2677   then
2678 
2679     p_codepath := jai_general_pkg.plot_codepath(25, p_codepath); /* 25  */
2680 IF  ( p_cvd_taxes     +
2681           p_add_cvd_taxes + /*5228046 Additional cvd Enhancement*/
2682           p_customs_taxes +
2683           p_cvd_edu_cess  +
2684           p_cvd_sh_edu_cess  +	 /*Bug 5989740 bduvarag*/
2685           p_customs_edu_cess +
2686           p_customs_sh_edu_cess +/*Bug 5989740 bduvarag*/
2687           p_third_party_taxes
2688         ) <> 0 THEN
2689 
2690 
2691       p_codepath := jai_general_pkg.plot_codepath(26, p_codepath); /* 26  */
2692       ln_debit    :=  ( p_cvd_taxes        + p_add_cvd_taxes /*5228046 Additional cvd Enhancement*/ +
2693                         p_customs_taxes    + p_cvd_edu_cess +
2694                         p_cvd_sh_edu_cess  /*Bug 5989740 bduvarag*/
2695                         +p_customs_edu_cess + p_customs_sh_edu_cess 	 + p_third_party_taxes
2696                       );
2697       ln_credit   :=  null;
2698       /*Bug 5527885 Start*/
2699 
2700       ptr_jv(4).line_num           := 4;
2701       ptr_jv(4).acct_type          := lv_acct_type;
2702       ptr_jv(4).acct_nature        := lv_acct_nature;
2703       ptr_jv(4).source_name        := lv_source_name;
2704       ptr_jv(4).category_name      := lv_category_name;
2705       ptr_jv(4).ccid               := p_rtv_expense_account_id;
2706       ptr_jv(4).entered_dr         := round(ln_debit, gn_currency_precision);
2707       ptr_jv(4).entered_cr         := round(ln_credit, gn_currency_precision);
2708       ptr_jv(4).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
2709       ptr_jv(4).accounting_date    := p_transaction_date;
2710       ptr_jv(4).reference_10       := lv_reference_10;
2711       ptr_jv(4).reference_23       := lv_reference_23;
2712       ptr_jv(4).reference_24       := lv_reference_24;
2713       ptr_jv(4).reference_25       := lv_reference_25;
2714       ptr_jv(4).reference_26       := lv_reference_26;
2715       ptr_jv(4).destination        := 'G';
2716       -- ptr_jv(4).reference_name     := ;
2717       ptr_jv(4).reference_id       := p_transaction_id;
2718       ptr_jv(4).non_rnd_entered_dr := ln_debit;
2719       ptr_jv(4).non_rnd_entered_cr := ln_credit;
2720       ptr_jv(4).account_name       := gv_rtv_expense;
2721       ptr_jv(4).summary_jv_flag    := 'N';
2722 /*Bug 5527885*/
2723     end if;
2724 
2725   end if; /* RTV Expense Accounting Entry */
2726 
2727 
2728   p_codepath := jai_general_pkg.plot_codepath(27, p_codepath); /* 27  */
2729   ln_credit := null;
2730   ln_debit  := null;
2731 
2732   Fnd_File.put_line(Fnd_File.LOG, ' p_trading_to_trading_iso :' || p_trading_to_trading_iso );
2733    Fnd_File.put_line(Fnd_File.LOG, 'p_receipt_source_code:'||p_receipt_source_code );
2734   --bug 6030615 added inventory
2735   if p_receipt_source_code IN ('INTERNAL ORDER', 'INVENTORY')-- and  p_trading_to_trading_iso = 'N'
2736   then /* Bug#4171469 */
2737 
2738     p_codepath := jai_general_pkg.plot_codepath(28, p_codepath); /* 28  */
2739     Fnd_File.put_line(Fnd_File.LOG, 'p_intransit_type:'||p_intransit_type );
2740     Fnd_File.put_line(Fnd_File.LOG, 'p_fob_point:'||p_fob_point );
2741     if ( (p_intransit_type = 2) and  (p_fob_point = 2) ) then
2742       /* 2 extra accounting entries need to be passed */
2743 
2744       p_codepath := jai_general_pkg.plot_codepath(29, p_codepath); /* 29  */
2745       IF  p_all_taxes -
2746         ( p_tds_taxes + p_modvat_recovery_taxes +
2747           p_cvd_taxes + p_add_cvd_taxes /*5228046 Additional cvd Enhancement*/ +
2748           p_customs_taxes + p_cvd_edu_cess +p_cvd_sh_edu_cess  	 /*Bug 5989740 bduvarag*/
2749           + p_customs_edu_cess
2750           +p_customs_sh_edu_cess) <> 0
2751       THEN
2752 
2753         p_codepath := jai_general_pkg.plot_codepath(30, p_codepath); /* 30  */
2754         /* Accounting Entry # 5 : Debit InterOrg Receivable */
2755 
2756         ln_debit  :=  p_all_taxes -
2757                      ( p_tds_taxes + p_modvat_recovery_taxes + p_cvd_taxes + p_add_cvd_taxes /*5228046 Additional cvd Enhancement*/ + p_customs_taxes +
2758                        p_cvd_edu_cess + p_cvd_sh_edu_cess + 	 /*Bug 5989740 bduvarag*/
2759                        p_customs_edu_cess +
2760                        p_customs_sh_edu_cess);
2761 
2762         ln_credit  := null;
2763     Fnd_File.put_line(Fnd_File.LOG, 'ln_debit:'||ln_debit );
2764         Fnd_File.put_line(Fnd_File.LOG, 'Accounting for Inter Receibles Acc' );
2765         Fnd_File.put_line(Fnd_File.LOG, 'p_interorg_receivables_account:'||p_interorg_receivables_account );
2766 /*Bug 5527885 Start*/
2767 
2768         ptr_jv(5).line_num           := 5;
2769         ptr_jv(5).acct_type          := lv_acct_type;
2770         ptr_jv(5).acct_nature        := lv_acct_nature;
2771         ptr_jv(5).source_name        := lv_source_name;
2772         ptr_jv(5).category_name      := lv_category_name;
2773         ptr_jv(5).ccid               := p_interorg_receivables_account;
2774         ptr_jv(5).entered_dr         := round(ln_debit, gn_currency_precision);
2775         ptr_jv(5).entered_cr         := round(ln_credit, gn_currency_precision);
2776         ptr_jv(5).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
2777         ptr_jv(5).accounting_date    := p_transaction_date;
2778         ptr_jv(5).reference_10       := lv_reference_10;
2779         ptr_jv(5).reference_23       := lv_reference_23;
2780         ptr_jv(5).reference_24       := lv_reference_24;
2781         ptr_jv(5).reference_25       := lv_reference_25;
2782         ptr_jv(5).reference_26       := lv_reference_26;
2783         ptr_jv(5).destination        := 'G';
2784         -- ptr_jv(5).reference_name     := ;
2785         ptr_jv(5).reference_id       := p_transaction_id;
2786         ptr_jv(5).non_rnd_entered_dr := ln_debit;
2787         ptr_jv(5).non_rnd_entered_cr := ln_credit;
2788         ptr_jv(5).account_name       := gv_iso_receivables;
2789         ptr_jv(5).summary_jv_flag    := 'N';
2790 
2791         /* Accounting Entry # 6 : Credit in-transit inventory */
2792 
2793         p_codepath := jai_general_pkg.plot_codepath(31, p_codepath); /* 31  */
2794         ln_credit  := ln_debit;
2795         ln_debit  :=  null;
2796 
2797     Fnd_File.put_line(Fnd_File.LOG, 'ln_credit:'||ln_credit );
2798         Fnd_File.put_line(Fnd_File.LOG, 'Accounting for p_intransit_inv_account Acc' );
2799         Fnd_File.put_line(Fnd_File.LOG, 'p_intransit_inv_account:'||p_interorg_receivables_account );
2800 
2801         ptr_jv(6).line_num           := 6;
2802         ptr_jv(6).acct_type          := lv_acct_type;
2803         ptr_jv(6).acct_nature        := lv_acct_nature;
2804         ptr_jv(6).source_name        := lv_source_name;
2805         ptr_jv(6).category_name      := lv_category_name;
2806         ptr_jv(6).ccid               := p_intransit_inv_account;
2807         ptr_jv(6).entered_dr         := round(ln_debit, gn_currency_precision);
2808         ptr_jv(6).entered_cr         := round(ln_credit, gn_currency_precision);
2809         ptr_jv(6).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
2810         ptr_jv(6).accounting_date    := p_transaction_date;
2811         ptr_jv(6).reference_10       := lv_reference_10;
2812         ptr_jv(6).reference_23       := lv_reference_23;
2813         ptr_jv(6).reference_24       := lv_reference_24;
2814         ptr_jv(6).reference_25       := lv_reference_25;
2815         ptr_jv(6).reference_26       := lv_reference_26;
2816         ptr_jv(6).destination        := 'G';
2817         -- ptr_jv(6).reference_name     := ;
2818         ptr_jv(6).reference_id       := p_transaction_id;
2819         ptr_jv(6).non_rnd_entered_dr := ln_debit;
2820         ptr_jv(6).non_rnd_entered_cr := ln_credit;
2821         ptr_jv(6).account_name       := gv_iso_intransit_inv;
2822         ptr_jv(6).summary_jv_flag    := 'N';
2823 /*Bug 5527885 End*/
2824 
2825       end if; /* all - tds - mr - cvd - customs */
2826 
2827     end if; /* is  (p_intransit_type = 2) and  (p_fob_point = 2) */
2828 
2829   end if; /* p_receipt_source_code = 'INTERNAL ORDER'  */
2830 
2831 
2832   << exit_from_procedure >>
2833   p_codepath := jai_general_pkg.plot_codepath(32, p_codepath, null, 'END'); /* 32  */
2834 
2835   if p_process_flag is null then
2836     p_process_flag    := 'Y';
2837   end if;
2838 
2839   if p_debug = 'Y' then
2840     Fnd_File.put_line(Fnd_File.LOG, '  Code Path :' || p_codepath );
2841     Fnd_File.put_line(Fnd_File.LOG, '  ** End of procedure jai_rcv_rcv_rtv_pkg.post_entries **  ');
2842   end if;
2843 
2844   return;
2845 
2846 exception
2847   when others then
2848     p_process_flag    := 'E';
2849     p_process_message := 'RECEIVE_RTV_PKG.post_entries:' || sqlerrm;
2850     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
2851     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END');
2852     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
2853     return;
2854 
2855 end post_entries;
2856 
2857 /****************************** End post_entries ******************************/
2858 
2859 
2860 /****************************** Start regime_tax_accounting_interim ******************************/
2861   procedure regime_tax_accounting_interim
2862   (
2863     p_transaction_id                            in                number,
2864     p_shipment_line_id                          in                number,
2865     p_organization_id                           in                number,
2866     p_location_id                               in                number,
2867     p_transaction_type                          in                varchar2,
2868     p_currency_conversion_rate                  in                number,
2869     p_parent_transaction_type                   in                varchar2,
2870     -- Vijay Shankar for Bug#4346453. RCV DFF Elim. Enh. p_attribute_category                        in                varchar2,
2871     p_receipt_source_code                       in                varchar2,
2872     p_transaction_date                          in                date,
2873     p_receipt_num                               in                varchar2,
2874     p_regime_code                               in                varchar2,
2875     ptr_jv                                      in OUT NOCOPY JOURNAL_LINES,  /* 5527885 */
2876     p_simulation                                in                varchar2,
2877     p_debug                                     in                varchar2,  -- default 'N', File.Sql.35
2878     p_process_flag                              out     nocopy    varchar2,
2879     p_process_message                           out     nocopy    varchar2,
2880     p_codepath                                  in out  nocopy    varchar2
2881   )
2882   is
2883 
2884   ln_credit                     number;
2885   ln_debit                      number;
2886   /* File.Sql.35 by Brathod */
2887   lv_source_name                varchar2(20); -- := 'Purchasing India'; -- Harshita . modified the size from 15 to 20 for Bug 4762433
2888   lv_category_name              varchar2(15); -- := 'Receiving India';
2889   lv_acct_nature                varchar2(15); -- := 'Receiving';
2890   lv_acct_type                  varchar2(15);  /* Regular or Reversal*/
2891 
2892   lv_reference_10               varchar2(240);
2893   lv_reference_23               varchar2(240);-- := 'jai_rcv_rcv_rtv_pkg.regime_tax_accounting_interim';
2894   lv_reference_24               varchar2(240);-- := 'rcv_transactions';
2895   lv_reference_25               varchar2(240);-- :=  'transaction_id';
2896   /* End of File.Sql.35 by Brathod */
2897 
2898   lv_reference_26               varchar2(240);
2899   ln_tax_apportion_factor       number;
2900   ln_regime_recovery_interim   number;
2901 
2902   cursor c_jai_regimes (p_regime_code varchar2)is
2903     select regime_id
2904     from   JAI_RGM_DEFINITIONS
2905     where  regime_code = p_regime_code;
2906 
2907 --added tax_type in cursor definition for bug # 6807023
2908   cursor c_ja_in_tax_amt_by_account
2909   (
2910     cp_shipment_line_id             number,
2911     cp_regime_id                    number,
2912     cp_organization_type            varchar2,
2913     cp_organization_id              number,
2914     cp_location_id                  number,
2915     cp_account_name                 varchar2,
2916     cp_func_curr                    varchar2,
2917     cp_tax_apportion_factor         number,
2918     cp_currency_conversion_rate     number
2919   ) is
2920     select  jai_cmn_rgm_recording_pkg.get_account
2921             (
2922                cp_regime_id,
2923                cp_organization_type,
2924                cp_organization_id,
2925                cp_location_id, /* Location Not for service tax */
2926                jrtl.tax_type,
2927                cp_account_name
2928             )  interim_regime_account,
2929             sum
2930             (
2931              ROUND( --rchandan for bug#6971526
2932               decode
2933               (
2934                 nvl(jrtl.currency , cp_func_curr), cp_func_curr,
2935                 nvl(jrtl.tax_amount,0)* cp_tax_apportion_factor,
2936                 nvl(jrtl.tax_amount,0)* cp_tax_apportion_factor * cp_currency_conversion_rate
2937                ) * --rchandan for bug#6971526 start
2938 							 (decode(jtc.mod_cr_percentage,100,1,jtc.mod_cr_percentage/100)
2939 							 )
2940 							 , NVL(jtc.rounding_factor, 0)
2941  	             )--rchandan for bug#6971526 end
2942               ) tax_amount_by_account
2943     from    JAI_RCV_LINE_TAXES jrtl,
2944             JAI_CMN_TAXES_ALL jtc
2945     where   jrtl.shipment_line_id = cp_shipment_line_id
2946     and     jrtl.tax_id = jtc.tax_id
2947     and     ( nvl(jtc.mod_cr_percentage,0) between 0 and 100 ) --rchandan for bug#6971526
2948     and     nvl(jrtl.modvat_flag, 'N') = 'Y'
2949     and     jrtl.tax_type in
2950             (
2951              select jrr.attribute_code
2952              from   JAI_RGM_DEFINITIONS jr,
2953                     JAI_RGM_REGISTRATIONS jrr
2954              where  jr.regime_id = jrr.regime_id
2955              and    jr.regime_code = p_regime_code
2956              and    jrr.registration_type = jai_constants.regn_type_tax_types
2957             )
2958       AND   NVL(jtc.inclusive_tax_flag,'N')='N' --add by eric for inclusive tax,picking the exclusive tax only
2959     group by  jai_cmn_rgm_recording_pkg.get_account
2960             (
2961                cp_regime_id,
2962                cp_organization_type,
2963                cp_organization_id,
2964                cp_location_id, /* Location Not for service tax */
2965                jrtl.tax_type,
2966                cp_account_name
2967             ) ;
2968 
2969   /*commented this cursor for bug#6030615,as part of performance issue check
2970   cursor c_org_organization_definitions(cp_organization_id  number) is
2971     select operating_unit
2972     from   org_organization_definitions
2973     where  organization_id = cp_organization_id;*/
2974     --added the below cursor for bug#6030615
2975     CURSOR c_get_ou (cp_organization_id  number)is
2976     SELECT org_information3 FROM HR_ORGANIZATION_INFORMATION
2977     WHERE organization_id=cp_organization_id
2978     AND ORG_INFORMATION_CONTEXT='Accounting Information';
2979 
2980   r_org_organization_definitions    c_get_ou%rowtype;
2981   r_jai_regimes                     c_jai_regimes%rowtype;
2982   lv_organization_type              varchar2(2);
2983   ln_organization_id                number;
2984   ln_location_id                    number;
2985   l_jv_line_num_generator           number; /*Bug 5527885*/
2986 begin
2987 
2988   /* File.Sql.35 by Brathod */
2989   lv_source_name                := 'Purchasing India';
2990   lv_category_name              := 'Receiving India';
2991   lv_acct_nature                := 'Receiving';
2992   lv_reference_23               := 'jai_rcv_rcv_rtv_pkg.regime_tax_accounting_interim';
2993   lv_reference_24               := 'rcv_transactions';
2994   lv_reference_25               :=  'transaction_id';
2995   /* End of File.Sql.35 by Brathod */
2996 
2997 
2998   if p_debug = 'Y' then
2999     Fnd_File.put_line(Fnd_File.LOG, '  **    Start of procedure jai_rcv_rcv_rtv_pkg.regime_tax_accounting_interim **');
3000   end if;
3001 
3002   p_codepath := jai_general_pkg.plot_codepath(1, p_codepath, 'jai_rcv_rcv_rtv_pkg.regime_tax_accounting_interim', 'START'); /* 1  */
3003   /* Set varaiable values for accounting entries with GL link */
3004   if ( (p_transaction_type = 'RETURN TO VENDOR')
3005         or
3006        (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RETURN TO VENDOR')
3007       )
3008   then
3009     p_codepath := jai_general_pkg.plot_codepath(2, p_codepath); /* 2  */
3010     lv_acct_type := 'REVERSAL';
3011   else
3012     p_codepath := jai_general_pkg.plot_codepath(3, p_codepath); /* 3  */
3013     lv_acct_type := 'REGULAR';
3014   end if;
3015 
3016   p_codepath := jai_general_pkg.plot_codepath(4, p_codepath); /* 4  */
3017   lv_reference_10 :=  p_regime_code||' Regime. India Local Receiving Entry for Receipt Number ' || p_receipt_num ||
3018                       ', for Transaction Type ' || p_transaction_type ;
3019 
3020   if p_transaction_type = 'CORRECT' then
3021     p_codepath := jai_general_pkg.plot_codepath(5, p_codepath); /* 5  */
3022     lv_reference_10 := lv_reference_10 || ' of type ' || p_parent_transaction_type;
3023   end if;
3024 
3025   lv_reference_26 :=  to_char(p_transaction_id);
3026 
3027   ln_tax_apportion_factor := jai_rcv_trx_processing_pkg.get_apportion_factor(p_transaction_id);
3028 
3029   open  c_jai_regimes(p_regime_code);
3030   fetch c_jai_regimes into r_jai_regimes;
3031   close c_jai_regimes;
3032 
3033   if  p_regime_code = jai_constants.service_regime then
3034 
3035     p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6  */
3036     Fnd_File.put_line(Fnd_File.LOG, 'In Service Regime ');
3037    lv_organization_type := jai_constants.orgn_type_io;
3038    ln_organization_id  := p_organization_id;
3039    ln_location_id := p_location_id;
3040    l_jv_line_num_generator := 61;  /*added for bug 7699476*/
3041    -- added by nprashar  for Bug 6807023
3042    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);
3043 
3044   elsif p_regime_code = jai_constants.vat_regime then
3045 
3046       p_codepath := jai_general_pkg.plot_codepath(6.1, p_codepath); /* 6.1  */
3047       lv_organization_type := jai_constants.orgn_type_io;
3048       ln_organization_id  := p_organization_id;
3049       ln_location_id := p_location_id;
3050     l_jv_line_num_generator := 41;/*Bug 5527885*/
3051   end if;
3052   /* Loop through Taxes of Service/VAT Regime by interim service/vat account
3053      of tax type and  pass the accounting entries  */
3054   p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7  */
3055 
3056   for cur_rec in
3057     c_ja_in_tax_amt_by_account
3058       (
3059         p_shipment_line_id,
3060         r_jai_regimes.regime_id,
3061         lv_organization_type,
3062         ln_organization_id,
3063         ln_location_id,
3064         jai_constants.recovery_interim,
3065         jai_rcv_trx_processing_pkg.gv_func_curr,
3066         ln_tax_apportion_factor,
3067         p_currency_conversion_rate
3068       )
3069   loop
3070     ln_regime_recovery_interim := cur_rec.interim_regime_account;
3071 
3072     if ln_regime_recovery_interim is null then
3073       p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8  */
3074       p_process_flag    := 'E';
3075       p_process_message :=
3076       'RECEIVE_RTV_PKG.service_tax_accounting: Interim Service/vat tax recovery account not defined for some tax type';
3077       goto   exit_from_procedure;
3078     end if;
3079 
3080     if ( (p_transaction_type = 'RETURN TO VENDOR')
3081           or
3082          (p_transaction_type = 'CORRECT' and p_parent_transaction_type  = 'RETURN TO VENDOR')
3083         )
3084     then
3085 
3086        p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9  */
3087        ln_debit  := null;
3088        ln_credit := cur_rec.tax_amount_by_account;  /* Service/Vat */
3089 
3090     else
3091 
3092       p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10  */
3093       ln_debit  := cur_rec.tax_amount_by_account;
3094       ln_credit := null;
3095 
3096     end if;
3097 
3098     p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11  */
3099 
3100     --if (ln_debit is not null or ln_credit is not null) then
3101     --commented the above and added the below by Ramananda for Bug#4514461
3102     if (NVL(ln_debit,0) <> 0 OR NVL(ln_credit,0) <> 0) then
3103       p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12  */
3104       /* procedure to populate gl inetrface, JAI_RCV_JOURNAL_ENTRIES and receiving subledger */
3105 /*Bug 5527885 Start*/
3106 /*
3107       if p_debug = 'Y' then
3108         Fnd_File.put_line(Fnd_File.LOG, ' Call to -> jai_rcv_accounting_pkg.process_transaction');
3109       end if;
3110 
3111 
3112 
3113       jai_rcv_accounting_pkg.process_transaction
3114       (
3115       p_transaction_id            =>    p_transaction_id,
3116       p_acct_type                 =>    lv_acct_type,
3117       p_acct_nature               =>    lv_acct_nature,
3118       p_source_name               =>    lv_source_name,
3119       p_category_name             =>    lv_category_name,
3120       p_code_combination_id       =>    ln_regime_recovery_interim,
3121       p_entered_dr                =>    ln_debit,
3122       p_entered_cr                =>    ln_credit,
3123       p_currency_code             =>    jai_rcv_trx_processing_pkg.gv_func_curr,
3124       p_accounting_date           =>    p_transaction_date,
3125       p_reference_10              =>    lv_reference_10,
3126       p_reference_23              =>    lv_reference_23,
3127       p_reference_24              =>    lv_reference_24,
3128       p_reference_25              =>    lv_reference_25,
3129       p_reference_26              =>    lv_reference_26,
3130       p_destination               =>    'G',
3131       p_simulate_flag             =>    p_simulation,
3132       p_codepath                  =>    p_codepath,
3133       p_process_status            =>    p_process_flag,
3134       p_process_message           =>    P_process_message
3135       );
3136 */
3137       ptr_jv(l_jv_line_num_generator).line_num           := l_jv_line_num_generator;
3138       ptr_jv(l_jv_line_num_generator).acct_type          := lv_acct_type;
3139       ptr_jv(l_jv_line_num_generator).acct_nature        := lv_acct_nature;
3140       ptr_jv(l_jv_line_num_generator).source_name        := lv_source_name;
3141       ptr_jv(l_jv_line_num_generator).category_name      := lv_category_name;
3142       ptr_jv(l_jv_line_num_generator).ccid               := ln_regime_recovery_interim;
3143       ptr_jv(l_jv_line_num_generator).entered_dr         := round(ln_debit, gn_currency_precision);
3144       ptr_jv(l_jv_line_num_generator).entered_cr         := round(ln_credit, gn_currency_precision);
3145       ptr_jv(l_jv_line_num_generator).currency_code      := jai_rcv_trx_processing_pkg.gv_func_curr;
3146       ptr_jv(l_jv_line_num_generator).accounting_date    := p_transaction_date;
3147       ptr_jv(l_jv_line_num_generator).reference_10       := lv_reference_10;
3148       ptr_jv(l_jv_line_num_generator).reference_23       := lv_reference_23;
3149       ptr_jv(l_jv_line_num_generator).reference_24       := lv_reference_24;
3150       ptr_jv(l_jv_line_num_generator).reference_25       := lv_reference_25;
3151       ptr_jv(l_jv_line_num_generator).reference_26       := lv_reference_26;
3152       ptr_jv(l_jv_line_num_generator).destination        := 'G';
3153       -- ptr_jv(l_jv_line_num_generator).reference_name     := ;
3154       ptr_jv(l_jv_line_num_generator).reference_id       := p_transaction_id;
3155       ptr_jv(l_jv_line_num_generator).non_rnd_entered_dr := ln_debit;
3156       ptr_jv(l_jv_line_num_generator).non_rnd_entered_cr := ln_credit;
3157       ptr_jv(l_jv_line_num_generator).summary_jv_flag    := 'N';
3158       if p_regime_code = jai_constants.service_regime then
3159         ptr_jv(l_jv_line_num_generator).account_name := gv_service_interim;
3160       elsif p_regime_code = jai_constants.vat_regime then
3161         ptr_jv(l_jv_line_num_generator).account_name := gv_vat_interim;
3162       else
3163         ptr_jv(l_jv_line_num_generator).account_name := gv_regime_interim;
3164       end if;
3165       l_jv_line_num_generator := l_jv_line_num_generator + 1;
3166       /*Bug 5527885 End*/
3167     end if;
3168 
3169 
3170   end loop;
3171 
3172 
3173   << exit_from_procedure >>
3174   p_codepath := jai_general_pkg.plot_codepath(32, p_codepath, null, 'END'); /* 32  */
3175 
3176   if p_process_flag is null then
3177     p_process_flag    := 'Y';
3178   end if;
3179 
3180   if p_debug = 'Y' then
3181     Fnd_File.put_line(Fnd_File.LOG, '  Code Path :' || p_codepath );
3182     Fnd_File.put_line(Fnd_File.LOG, '  ** End of procedure jai_rcv_rcv_rtv_pkg.regime_tax_accounting_interim **  ');
3183   end if;
3184 
3185   return;
3186 
3187 exception
3188   when others then
3189     p_process_flag    := 'E';
3190     p_process_message := 'RECEIVE_RTV_PKG.regime_tax_accounting_interim:' || sqlerrm;
3191     FND_FILE.put_line( FND_FILE.log, 'Error in '||p_process_message);
3192     p_codepath := jai_general_pkg.plot_codepath(999, p_codepath, null, 'END');
3193     Fnd_File.put_line(Fnd_File.LOG, 'Code Path:' || p_codepath );
3194     return;
3195 
3196 end regime_tax_accounting_interim;
3197 /****************************** End service_tax_accounting ******************************/
3198 
3199 end jai_rcv_rcv_rtv_pkg;