[Home] [Help]
PACKAGE BODY: APPS.JAI_MTL_TRXS_PKG
Source
1 PACKAGE BODY JAI_MTL_TRXS_PKG AS
2 /* $Header: jai_mtl_trxs_pkg.plb 120.15.12010000.2 2008/11/19 12:10:26 mbremkum ship $ */
3
4 /*----------------------------------------------------------------------------------------------------------------------
5 CHANGE HISTORY: FILENAME: jai_mtl_trxs_pkg.plb
6 S.No Date Author and Details
7 ------------------------------------------------------------------------------------------------------------------------
8 1 24-Jan-2007 rchandan for #2942973 for File Version 115.6 (INTER ORG Impl.)
9 The parameter p_receipt_num in claim_balance_cgvat was defined as NUMBER and
10 so the query was not happening properly. Now it is defined as VARCHAR2.
11 Also removed a delete statement which was deleting from jai_rgm_trm_schedules_t if
12 there were any installments generated already.
13
14 2 26/01/2007 cbabu for bug#2942973 Version: 115.9 (INTER ORG Impl.)
15 Added the procedures
16 default_taxes - This defaults or redefaults the taxes. Incase of redefaultation, deletes the
17 entire data that is saved before base transaction is saved
18
19 sync_with_base_trx - This deletes IL data where in record PKs do not exist in base transaction tables
20 this internally uses delete_trx_autonomous or delete_trx procedures
21
22 These changes are done as part of ReArch. Inter Org Form
23
24 3 29-Jan-2007 rchandan for #2942973 for File Version 115.11 (INTER ORG Impl.)
25 Modified procedure DEFAULT_TAXES to recalculate taxes if the quantity alone
26 is changed. In other cases it would redefault taxes
27
28 4 30-Jan-2007 rchandan for bug#942973 for File Version 115.11 (INTER ORG Impl.)
29 Deletion from JAI_CMN_MATCH_TAXES was missing when quantity is changed after matching.
30 So added this statement now
31
32 5. 5-mar-2007 kunkumar - bug#5907436 -file branch 6107 on 115 main code line.
33 Added higher education cess needed for implementing requirements imposed by budget of 2007.
34 Introduces huge dependencies as there are data model changes associated with this bug.
35
36 6. 14-apr-2007 Vkaranam for bug #5907436 ,File version #115.16.6107.4 / 115.19
37 ENH:Handling Secondary And Higher Education Cess.
38 Fix:
39 Code changes are done in do_cenvat_acctg and cenvat_process procedures.
40
41 7. 01-08-2007 rchandan for bug#6030615 , Version 120.0
42 Issue : Inter org Forward porting
43 This is a new file in R12 now.
44 8. 21-aug-2007 vkaranam for bug#6030615,File version 120.3
45 1.Changed std_cost_entry procedure.
46 2.added journal_entry_id column in the insert stmt of jai_mtl_trx_jrnls
47 9. 21-aug-2007 vkaranam for bug#6030615,File version 120.4
48 Changes are done as part of the performance issue.
49
50 10. 27-sep-2007 forward porting of bug 6377964
51
52 11. 09-Oct-2007 rchandan for bug#6487364,File version 120.8
53 Issue : QA observations for Inter org
54 Fix : For receiving organization no cess entries were made For RG23D.
55 Added calls to do this
56
57 12 10/10/2007 rchandan for bug#6487803, File version 120.10
58 Issue : R12RUP04.I/ORG.QA.ST1:NOT ABLE TO DO RECEIVING IN NON BONDED SUB INVENTORY
59 Fix : When Direct org transfer is done to a Non Bonded Subinventory, the excise processing
60 should not happen for receiving org , but the transaction should go through fine.
61 Added an elsif condiftion to do nothing for receiving org.
62 For accounting as well added condition so that the excise entries will be accounted
63 only for trading organization or Manufacturing org for a Bonded subinventory.
64
65 13. 12/10/2007 rchandan for bug#6497301,6487489. File version 120.12
66 Issue : R12RUP04.I/ORG.QA.ST1: NOT ABLE TO MAKE A CAPTIAL GOODS TRANSFER FOR INTRANSIT
67 Fix : It is identified that there are new columns added to table jai_rcv_journal_entries
68 and these are not null. As the impact of this is not taken care in cenvat_auto_claim
69 procedure this issue was coming.
70 Now added these columns in the insert into JAI_RCV_JOURNAL_ENTRIES
71 Issue : R12RUP04.I/ORG.QA.ST1: PPV ENTRY TO BE GENERATED FOR STD COST REC ORG
72 Fix : For standard costing , Purchase price variance entry needs to generated
73 for the non - recoverable tax amount.
74 Made changes in std_cost_entry procedure to this effect.
75 PPV account is debited and Inventory receiving account is credited.
76
77 14. 15/10/2007 rchandan for bug#6487489. File version 120.13
78 Issue : R12RUP04.I/ORG.QA.ST1: PPV ENTRY TO BE GENERATED FOR STD COST REC ORG
79 Fix : The PPV generated should be for the sum of all non recoverable taxes and excisable
80 recoverable taxes in case of non bonded sub inventory. In case of Bonded it should be
81 generated only for Non receoverable tax only. Changes for this effect are made.
82
83 15. 15/10/2007 rchandan for bug#6501436, File Version 120.14
84 Issue : R12RUP04.I/ORG.QA.ST1:PART 2 SHOULD NOT BE UPDATED FOR REC ORG IN CASE OF FGIN
85 Fix : For receiving org when the item class is FGIN or FGEX, no register updates should
86 haappen and also accounting for this amount should also not happen.
87 A check for the item class is put wherever applicable.
88
89 Fix for the previous bug#6487489 is also made. In this ln_oth_modvat_amt is removed
90 from the calculation of ln_cost_amount.
91 Moreover for FGIN and FGEX clas also PPV entry needs to be modified to include the
92 recoverable tax which was not hitting the register and also not included in the accounting.
93
94 16. 16/10/2007 rchandan for bug#6504150, File Version 120.15
95 Issue : R12RUP04.I/ORG.QA.ST1:USER_JE_CATEGORY_NAM TO BE CHANGED FOR PPV ENTRY
96 Fix : In the gl_interface table the user_je_category_name should be populated as
97 'MTL' for PPV entry which is being generated for the receiving org in the
98 Direct Org Transfer. Made a change to this effect.
99
100 17. 12-May-2008 Changes by nprashar for bug # 6710747. Forward ported from 11i bug#6086452.
101 Issue:
102 When trying to save the IL interorg transfer a error message pops up and also
103 not allowing close the form. Which makes to close the application and login again.
104
105 The above mentioned issue is happening because of the deadlock on jai_mtl_trxs table.
106 1.on the key commit trigger of mtl_trx_line in interorg form(JAINVMTX.fmb),there is an update stmt on jai_mtl_trxs table.
107 If any error occurs in this trigger and the user tries to comeout of the form there is a call to sync_with_base_trx
108 which will delete the error record in jai_mtl_trxs table.
109 since it is trying to delete the same record which has been locked by the update stmt,deadlock error occurs waiting for the resource .
110
111 Fix:
112 changes are done in cenvat_process procedure
113
114
115 ------------------------------------------------------------------------------------------------------------------------
116 */
117
118 TYPE gl_params IS RECORD (
119 amount NUMBER,
120 credit_account gl_interface.code_combination_id%TYPE,
121 debit_account gl_interface.code_combination_id%TYPE,
122 organization_id NUMBER,
123 organization_code gl_interface.reference1%TYPE,
124 remarks VARCHAR2(64));
125
126 TYPE gl_entries IS TABLE OF gl_params INDEX BY PLS_INTEGER;
127
128
129 PROCEDURE get_cost_amt
130 (
131 p_source_line_id IN NUMBER,
132 p_organization_id IN NUMBER,
133 p_location_id IN NUMBER,
134 p_item_id IN NUMBER,
135 p_excise_amount OUT NOCOPY NUMBER,
136 p_non_modvat_amount OUT NOCOPY NUMBER,
137 p_other_modvat_amount OUT NOCOPY NUMBER,
138 p_process_message OUT NOCOPY VARCHAR2,
139 p_process_status OUT NOCOPY VARCHAR2
140 ) IS
141
142 ln_modvat_amount NUMBER := 0;
143 ln_non_modvat_amount NUMBER := 0;
144 ln_other_modvat_amount NUMBER := 0;
145 ln_conv_factor NUMBER := 1;
146 lv_tax_modvat_flag JAI_RCV_LINE_TAXES.modvat_flag%type;
147
148 ln_precision number:= 2 ;
149 ln_recoverable_amt number;
150 ln_converted_tax_amt number;
151
152 lv_item_trading_flag VARCHAR2(20);
153 lv_excise_in_trading VARCHAR2(20);
154 lv_item_excisable VARCHAR2(20);
155 lv_organization_type VARCHAR2(20);
156 lv_manufacturing VARCHAR2(20);
157 lv_trading VARCHAR2(20);
158
159
160
161 cursor c_get_org_info IS
162 SELECT excise_in_RG23D excise_in_trading , NVL(manufacturing,'N') , NVL(trading ,'N')
163 FROM JAI_CMN_INVENTORY_ORGS
164 WHERE organization_id = p_organization_id
165 AND location_id = p_location_id;
166
167 cursor c_get_item_info IS
168 select item_Trading_flag , excise_flag
169 from JAI_INV_ITM_SETUPS
170 where inventory_item_id = p_item_id
171 and organization_id = p_organization_id;
172
173 BEGIN
174
175
176 OPEN c_get_org_info;
177 FETCH c_get_org_info INTO lv_excise_in_trading ,lv_manufacturing , lv_trading ;
178 CLOSE c_get_org_info;
179
180 OPEN c_get_item_info;
181 FETCH c_get_item_info INTO lv_item_trading_flag,lv_item_excisable ;
182 CLOSE c_get_item_info;
183
184 IF lv_manufacturing = 'Y' THEN
185 lv_organization_type := 'M';
186 ELSIF lv_trading = 'Y' THEN
187 lv_organization_type := 'T';
188 END IF;
189
190 FOR tax_rec IN
191 (
192 SELECT
193 rtl.tax_type,
194 nvl(rtl.tax_amt, 0) tax_amount,
195 nvl(rtl.modvat_flag, 'N') modvat_flag,
196 nvl(rtl.currency_code, 'INR') currency,
197 nvl(jtc.mod_cr_percentage, 0) mod_cr_percentage
198 FROM
199 jai_cmn_document_taxes rtl,
200 jai_cmn_taxes_all jtc
201 WHERE
202 source_doc_line_id = p_source_line_id
203 AND jtc.tax_id = rtl.tax_id
204 AND source_doc_type = 'INTERORG_XFER'
205
206 )
207 LOOP
208
209 ln_converted_tax_amt := tax_rec.tax_amount;
210 ln_converted_tax_amt := nvl(ln_converted_tax_amt,0);
211
212 if tax_rec.modvat_flag = 'Y'
213 and upper(tax_rec.tax_type) IN ('EXCISE', 'ADDL. EXCISE', 'OTHER EXCISE', 'CVD',
214 'ADDITIONAL_CVD', 'TDS', 'MODVAT RECOVERY',
215 jai_constants.tax_type_exc_edu_cess, jai_constants.tax_type_cvd_edu_cess, jai_constants.tax_type_sh_exc_edu_cess, jai_constants.tax_type_sh_cvd_edu_cess) --Added higher education cess by kundan kumar for bug#5907436
216
217 then
218
219
220 lv_tax_modvat_flag := 'Y';
221
222
223 elsif tax_rec.modvat_flag = 'Y'
224 and upper(tax_rec.tax_type) NOT IN ('EXCISE', 'ADDL. EXCISE', 'OTHER EXCISE', 'CVD',
225 'ADDITIONAL_CVD',
226 jai_constants.tax_type_exc_edu_cess,jai_constants.tax_type_sh_exc_edu_cess,jai_constants.tax_type_sh_cvd_edu_cess, jai_constants.tax_type_cvd_edu_cess) --Added higher education cess by kundan kumar for bug#5907436
227
228 then
229
230
231 lv_tax_modvat_flag := 'Y';
232
233 elsif tax_rec.modvat_flag = 'N'
234 and lv_item_trading_flag = 'Y' /* Excise IN RG23D scenario */
235 and lv_excise_in_trading = 'Y'
236 and lv_item_excisable = 'Y'
237 and lv_organization_type = 'T'
238 and upper(tax_rec.tax_type) IN ('EXCISE', 'ADDL. EXCISE', 'OTHER EXCISE', 'CVD',
239 'ADDITIONAL_CVD',
240 jai_constants.tax_type_exc_edu_cess,jai_constants.tax_type_sh_exc_edu_cess, --Added higher education cess by kundan kumar for bug#5907436
241
242
243 jai_constants.tax_type_sh_cvd_edu_cess, jai_constants.tax_type_cvd_edu_cess) --Added higher education cess by kundan kumar for bug#5907436
244
245 then
246
247 lv_tax_modvat_flag := 'Y';
248
249 else
250 lv_tax_modvat_flag := 'N';
251
252 end if; --tax_rec.modvat_flag = 'Y'
253
254
255 if upper(tax_rec.tax_type) NOT IN ('TDS', 'MODVAT RECOVERY') THEN
256
257
258 if lv_tax_modvat_flag = 'Y'
259 and upper(tax_rec.tax_type) IN ( 'EXCISE', 'ADDL. EXCISE', 'OTHER EXCISE', 'CVD',
260 'ADDITIONAL_CVD',
261 jai_constants.tax_type_exc_edu_cess,jai_constants.tax_type_sh_exc_edu_cess, --Added higher education cess by kundan kumar for bug#5907436
262
263 jai_constants.tax_type_sh_cvd_edu_cess, --Added higher education cess by kundan kumar for bug#5907436
264
265 jai_constants.tax_type_cvd_edu_cess)
266 then
267
268
269 ln_recoverable_amt :=
270 round( tax_rec.tax_amount * (tax_rec.mod_cr_percentage/100) * ln_conv_factor, ln_precision);
271 ln_modvat_amount := ln_modvat_amount + ln_recoverable_amt;
272 ln_non_modvat_amount := ln_non_modvat_amount + ( ln_converted_tax_amt - ln_recoverable_amt);
273
274
275 elsif lv_tax_modvat_flag = 'Y'
276 and upper(tax_rec.tax_type) NOT IN ('EXCISE', 'ADDL. EXCISE', 'OTHER EXCISE', 'CVD',
277 'ADDITIONAL_CVD',
278 jai_constants.tax_type_exc_edu_cess,jai_constants.tax_type_sh_exc_edu_cess, --Added higher education cess by kundan kumar for bug#5907436
279
280 jai_constants.tax_type_sh_cvd_edu_cess, --Added higher education cess by kundan kumar for bug#5907436
281
282 jai_constants.tax_type_cvd_edu_cess)
283 then
284
285 ln_recoverable_amt :=
286 round( tax_rec.tax_amount * (tax_rec.mod_cr_percentage/100) * ln_conv_factor, ln_precision);
287 ln_other_modvat_amount := ln_other_modvat_amount + ln_recoverable_amt;
288 ln_non_modvat_amount := ln_non_modvat_amount + ( ln_converted_tax_amt - ln_recoverable_amt);
289
290 ELSIF lv_tax_modvat_flag ='N' and upper(tax_rec.tax_type) NOT IN ('TDS', 'MODVAT RECOVERY') THEN
291
292 ln_non_modvat_amount := ln_non_modvat_amount + tax_rec.tax_amount * ln_conv_factor;
293
294 end if;
295
296 end if;
297
298 END LOOP;
299
300
301 p_excise_amount := ln_modvat_amount;
302 p_non_modvat_amount := ln_non_modvat_amount;
303 p_other_modvat_amount := ln_other_modvat_amount;
304
305 EXCEPTION
306 WHEN OTHERS THEN
307 p_process_status := 'E';
308 p_process_message := 'get_tax_amount_breakup:' || sqlerrm;
309 END get_cost_amt;
310
311
312
313 PROCEDURE cenvat_process(
314 p_transaction_temp_id IN NUMBER,
315 p_transaction_type in varchar2,
316 p_excise_inv_no in varchar2, /*Added by nprashar for bug # 6710747*/
317 p_process_status OUT NOCOPY VARCHAR2,
318 p_process_message OUT NOCOPY VARCHAR2)
319 IS
320 CURSOR main_cur IS
321 SELECT trx.transaction_date,
322 trx.inventory_item_id,
323 trx.transaction_uom,
324 trx.transaction_type_id,
325 trx.from_organization,
326 trx.to_organization,
327 trx.to_subinventory,
328 trx.transaction_temp_id,
329 --trx.excise_invoice_no,/*Added by nprashar for bug 6710747*/
330 trx.assessable_value,
331 subinv.bonded,
332 itm.excise_flag,
333 itm.item_class,
334 itm.item_trading_flag,
335 subinv.trading,
336 trx.location_id,
337 trx.quantity,
338 trx.creation_date,
339 trx.created_by,
340 trx.last_update_date,
341 trx.last_update_login
342 FROM jai_mtl_trxs trx,
343 JAI_INV_SUBINV_DTLS subinv,
344 JAI_INV_ITM_SETUPS itm
345 WHERE subinv.organization_id = trx.to_organization
346 AND itm.organization_id = trx.to_organization
347 AND itm.inventory_item_id = trx.inventory_item_id
348 AND subinv.sub_inventory_name = trx.to_subinventory
349 AND trx.transaction_temp_id = p_transaction_temp_id
350 AND trx.quantity > 0 ;
351 /*Commented by nprashar for bug # 6710747 AND trx.excise_invoice_no IS NOT NULL;*/
352
353 CURSOR organization_type_cur(p_org_id number,p_loc_id number) IS
354 SELECT trading, manufacturing, excise_duty_range, excise_duty_division
355 FROM JAI_CMN_INVENTORY_ORGS
356 WHERE organization_id = p_org_id
357 AND location_id = p_loc_id;
358
359
360 CURSOR excise_cur(trx_temp_id number) IS
361 SELECT SUM(decode(tax_type, 'Excise', round(tax_amt), 0)) exc,
362 SUM(decode(tax_type, 'Addl. Excise', round(tax_amt), 0)) additional_ed,
363 SUM(decode(tax_type, 'Other Excise', round(tax_amt), 0)) other_ed,
364 SUM(decode(tax_type, jai_constants.tax_type_exc_edu_cess, round(tax_amt), 0)) other_cess,
365 sum(decode(tax_type, jai_constants.tax_type_sh_exc_edu_cess, round(tax_amt), 0)) other_sh_cess --Added higher education cess constants by vkaranam for bug#5907436
366 FROM jai_cmn_document_taxes tax,
367 jai_mtl_trxs trx
368 WHERE tax.source_doc_line_id = trx.transaction_temp_id
369 AND trx.transaction_header_id = tax.source_doc_id
370 AND trx.transaction_temp_id = trx_temp_id;
371
372 CURSOR c_excise_tax_rate(cp_temp_id number)
373 IS
374 SELECT NVL(sum(tax_rate),0) , count(1)
375 FROM jai_cmn_document_taxes
376 WHERE source_doc_line_id = cp_temp_id
377 AND TAX_TYPE in ('Addl. Excise','Excise','Other Excise');
378
379 cursor c_rcpts_match (cp_temp_id IN NUMBER) IS
380 select sum(a.quantity_applied) quantity_applied , sum(b.excise_duty_rate) excise_duty_rate
381 from JAI_CMN_MATCH_RECEIPTS a ,JAI_CMN_RG_23D_TRXS b
382 where a.receipt_id = b.register_id
383 and a.ref_line_id = cp_temp_id
384 and a.order_invoice = 'X';
385
386
387 r_rcpts_match c_rcpts_match%rowtype;
388
389 l_trading JAI_CMN_INVENTORY_ORGS.trading%TYPE;
390 l_manufacturing JAI_CMN_INVENTORY_ORGS.manufacturing%TYPE;
391 l_range JAI_CMN_RG_I_TRXS.range_no%TYPE;
392 l_division JAI_CMN_RG_I_TRXS.division_no%TYPE;
393 l_register_id JAI_CMN_RG_I_TRXS.register_id%TYPE;
394 l_register_id_ii JAI_CMN_RG_I_TRXS.register_id_part_ii%TYPE;
395 l_slno JAI_CMN_RG_I_TRXS.slno%TYPE;
396 l_fin_year JAI_CMN_FIN_YEARS.fin_year%TYPE;
397 l_register_type VARCHAR2(3);
398 l_excise_duty NUMBER;
399 l_additional_ed NUMBER;
400 l_other_ed NUMBER;
401 ln_cess_amount number;
402 ln_other_sh_cess number; --Added higher education cess by kundan kumar for bug#5907436
403 main_rec main_cur%ROWTYPE;
404 l_process_status VARCHAR2(5) DEFAULT NULL;
405 l_process_message VARCHAR2(256) DEFAULT NULL;
406 v_register_id number;
407 lv_source_name varchar2(10);
408 processed_flag VARCHAR2(32) := '0';
409 stmt_name VARCHAR2(64);
410 ln_total_tax_rate NUMBER;
411 ln_number_of_Taxes NUMBER;
412 v_tax_rate NUMBER;
413 l_duty_amt number;
414
415 BEGIN
416
417 stmt_name := 'Opening main_cur';
418 OPEN main_cur;
419 FETCH main_cur INTO main_rec;
420 IF main_cur%NOTFOUND THEN
421 stmt_name := 'Fetching main_cur Cursor';
422 RAISE NO_DATA_FOUND;
423 END IF;
424
425 stmt_name := 'Opening Organization_type_cur';
426 OPEN organization_type_cur( main_rec.to_organization ,main_rec.location_id );
427 FETCH organization_type_cur INTO l_trading, l_manufacturing, l_range, l_division;
428 IF organization_type_cur%NOTFOUND THEN
429 stmt_name := 'Fetching organization_type Cursor '||':'||main_rec.to_organization||':'||main_rec.location_id;
430 CLOSE organization_type_cur;
431 RAISE NO_DATA_FOUND;
432 END IF;
433 CLOSE organization_type_cur;
434
435 stmt_name := 'Selecting fin_year from JAI_CMN_FIN_YEARS';
436 SELECT fin_year
437 INTO l_fin_year
438 FROM JAI_CMN_FIN_YEARS
439 WHERE organization_id = main_rec.to_organization
440 AND fin_active_flag = 'Y';
441
442 stmt_name := 'Opening excise_cur';
443 OPEN excise_cur(main_rec.transaction_temp_id);
444 FETCH excise_cur INTO l_excise_duty, l_additional_ed, l_other_ed,ln_cess_amount,ln_other_sh_cess;
445 CLOSE excise_cur;
446
447 l_duty_amt:=nvl(l_excise_duty,0)+nvl(l_additional_ed,0)+nvl(l_other_ed,0);
448
449 OPEN c_excise_tax_rate(main_rec.transaction_temp_id);
450 FETCH c_excise_tax_rate INTO ln_total_tax_rate , ln_number_of_Taxes ;
451 CLOSE c_excise_tax_rate;
452
453 IF NVL(ln_number_of_Taxes,0) = 0 THEN
454 ln_number_of_Taxes := 1;
455 END IF;
456
457 v_tax_rate := ln_total_tax_rate / ln_number_of_Taxes;
458
459 IF main_rec.item_class IN ('FGIN','FGEX','CCEX','CCIN','RMIN', 'RMEX') THEN
460 l_register_type := 'A';
461 ELSE
462 l_register_type := 'C';
463 END IF;
464
465 IF l_manufacturing = 'Y' THEN
466 IF main_rec.excise_flag = 'Y' AND main_rec.bonded = 'Y' AND
467 main_rec.item_class IN ('FGIN','FGEX','CCEX','CCIN') THEN
468 stmt_name := 'Calling JAI_CMN_RG_I_TRXS_pkg.create_rg1_entry';
469 JAI_CMN_RG_I_TRXS_pkg.create_rg1_entry(
470 P_REGISTER_ID => l_register_id,
471 P_REGISTER_ID_PART_II => null,
472 P_FIN_YEAR => l_fin_year,
473 P_SLNO => l_slno,
474 P_TRANSACTION_ID => 3,
475 P_ORGANIZATION_ID => main_rec.to_organization,
476 P_LOCATION_ID => main_rec.location_id,
477 P_TRANSACTION_DATE => main_rec.transaction_date,
478 P_INVENTORY_ITEM_ID => main_rec.inventory_item_id,
479 P_TRANSACTION_TYPE => 'R',
480 P_REF_DOC_ID => main_rec.transaction_temp_id,
481 P_QUANTITY => main_rec.quantity,
482 P_TRANSACTION_UOM_CODE => main_rec.transaction_uom,
483 P_ISSUE_TYPE => null,
484 P_EXCISE_DUTY_AMOUNT => null,
485 P_EXCISE_INVOICE_NUMBER => p_excise_inv_no /*Replacing main_rec.excise_invoice_no for bug # 6710747*/,
486 P_EXCISE_INVOICE_DATE => null,
487 P_PAYMENT_REGISTER => null,
488 P_CHARGE_ACCOUNT_ID => null,
489 P_RANGE_NO => l_range,
490 P_DIVISION_NO => l_division,
491 P_REMARKS => 'Inter Org transfer from '||main_rec.from_organization||' To '||main_rec.to_organization,
492 P_BASIC_ED => l_excise_duty,
493 P_ADDITIONAL_ED => l_additional_ed,
494 P_OTHER_ED => l_other_ed,
495 P_ASSESSABLE_VALUE => main_rec.assessable_value,
496 P_EXCISE_DUTY_RATE => null,
497 P_VENDOR_ID => main_rec.to_organization,
498 P_VENDOR_SITE_ID => main_rec.location_id,
499 P_CUSTOMER_ID => null,
500 P_CUSTOMER_SITE_ID => null,
501 P_CREATION_DATE => main_rec.creation_date,
502 P_CREATED_BY => main_rec.created_by,
503 P_LAST_UPDATE_DATE => sysdate,
504 P_LAST_UPDATED_BY => fnd_global.user_id,
505 P_LAST_UPDATE_LOGIN => main_rec.last_update_login,
506 P_CALLED_FROM => 'XFER',
507 P_CESS_AMOUNT => ln_cess_amount ,
508 P_SH_CESS_AMOUNT =>ln_other_sh_cess
509 );
510 processed_flag :='RG1';
511 ELSIF main_rec.excise_flag = 'Y' AND main_rec.bonded = 'Y' AND
512 main_rec.item_class IN ('RMIN', 'RMEX', 'CGIN', 'CGEX') THEN
513 stmt_name := 'Calling jai_cmn_rg_23ac_i_trxs_pkg.insert_row';
514 jai_cmn_rg_23ac_i_trxs_pkg.insert_row(
515 P_REGISTER_ID => l_register_id,
516 P_INVENTORY_ITEM_ID => main_rec.inventory_item_id,
517 P_ORGANIZATION_ID => main_rec.to_organization,
518 P_QUANTITY_RECEIVED => main_rec.quantity,
519 P_RECEIPT_ID => main_rec.transaction_temp_id,
520 P_TRANSACTION_TYPE => 'R',
521 P_RECEIPT_DATE => main_rec.transaction_date,
522 P_PO_HEADER_ID => null,
523 P_PO_HEADER_DATE => null,
524 P_PO_LINE_ID => null,
525 P_PO_LINE_LOCATION_ID => null,
526 P_VENDOR_ID => main_rec.from_organization,
527 P_VENDOR_SITE_ID => NULL,
528 P_CUSTOMER_ID => null,
529 P_CUSTOMER_SITE_ID => null,
530 P_GOODS_ISSUE_ID => null,
531 P_GOODS_ISSUE_DATE => null,
532 P_GOODS_ISSUE_QUANTITY => null,
533 P_SALES_INVOICE_ID => null,
534 P_SALES_INVOICE_DATE => null,
535 P_SALES_INVOICE_QUANTITY => null,
536 P_EXCISE_INVOICE_ID => p_excise_inv_no /*Replacing main_rec.excise_invoice_no for bug # 6710747*/,
537 P_EXCISE_INVOICE_DATE => sysdate,
538 P_OTH_RECEIPT_QUANTITY => null,
539 P_OTH_RECEIPT_ID => null,
540 P_OTH_RECEIPT_DATE => null,
541 P_REGISTER_TYPE => l_register_type,
542 P_IDENTIFICATION_NO => null,
543 P_IDENTIFICATION_MARK => null,
544 P_BRAND_NAME => null,
545 P_DATE_OF_VERIFICATION => null,
546 P_DATE_OF_INSTALLATION => null,
547 P_DATE_OF_COMMISSION => null,
548 P_REGISER_ID_PART_II => null,
549 P_PLACE_OF_INSTALL => null,
550 P_REMARKS => 'Inter Org transfer from '||main_rec.from_organization||' To '||main_rec.to_organization,
551 P_LOCATION_ID => main_rec.location_id,
552 P_TRANSACTION_UOM_CODE => main_rec.transaction_uom,
553 P_TRANSACTION_DATE => main_rec.transaction_date,
554 P_BASIC_ED => l_excise_duty,
555 P_ADDITIONAL_ED => l_additional_ed,
556 P_ADDITIONAL_CVD => null,
557 P_OTHER_ED => l_other_ed,
558 P_CHARGE_ACCOUNT_ID => null,
559 P_TRANSACTION_SOURCE => null,
560 P_CALLED_FROM => 'XFER',
561 P_SIMULATE_FLAG => null,
562 P_PROCESS_STATUS => l_process_status,
563 P_PROCESS_MESSAGE => l_process_message
564 );
565 if l_process_status='E' then
566 app_exception.raise_exception;
567 end if;
568 processed_flag :='RG23';
569
570 ELSIF main_rec.bonded = 'N' THEN /*6487803*/
571 l_process_status := 'N'; /*Do Nothing for Non Bonded subinventory*/
572 l_process_message := NULL;
573 processed_flag := 'N';
574 END IF;
575 ELSIF l_trading = 'Y' AND main_rec.trading = 'Y' AND main_rec.item_trading_flag = 'Y' THEN
576 stmt_name := 'Calling jai_cmn_rg_23d_trxs_pkg.insert_row';
577
578 if main_Rec.quantity <> 0 then
579 v_tax_rate := round((l_duty_amt / main_Rec.quantity),2);
580 end if;
581 OPEN c_rcpts_match (main_rec.transaction_temp_id);
582 fetch c_rcpts_match INTO r_rcpts_match;
583 close c_rcpts_match;
584 if r_rcpts_match.quantity_applied <> 0 THEN
585 ln_total_tax_rate := round (( ( r_rcpts_match.excise_duty_rate *r_rcpts_match.quantity_applied ) / r_rcpts_match.quantity_applied),2);
586 end if;
587
588 jai_cmn_rg_23d_trxs_pkg.insert_row(
589 P_REGISTER_ID => l_register_id,
590 P_ORGANIZATION_ID => main_rec.to_organization,
591 P_LOCATION_ID => main_rec.location_id,
592 P_TRANSACTION_TYPE => 'R',
593 P_RECEIPT_ID => main_rec.transaction_temp_id,
594 P_QUANTITY_RECEIVED => main_rec.quantity,
595 P_INVENTORY_ITEM_ID => main_rec.inventory_item_id,
596 P_SUBINVENTORY => main_rec.to_subinventory,
597 P_REFERENCE_LINE_ID => null,
598 P_TRANSACTION_UOM_CODE => main_rec.transaction_uom,
599 P_CUSTOMER_ID => null,
600 P_BILL_TO_SITE_ID => null,
601 P_SHIP_TO_SITE_ID => null,
602 P_QUANTITY_ISSUED => null,
603 P_REGISTER_CODE => null,
604 P_RELEASED_DATE => null,
605 P_COMM_INVOICE_NO => p_excise_inv_no /*Replacing main_rec.excise_invoice_no for bug # 6710747*/,
606 P_COMM_INVOICE_DATE => sysdate,
607 P_RECEIPT_BOE_NUM => null,
608 P_OTH_RECEIPT_ID => null,
609 P_OTH_RECEIPT_DATE => null,
610 P_OTH_RECEIPT_QUANTITY => null,
611 P_REMARKS => 'Inter Org transfer from '||main_rec.from_organization||' To '||main_rec.to_organization,
612 P_QTY_TO_ADJUST => main_rec.quantity,
613 P_RATE_PER_UNIT => v_tax_rate,
614 P_EXCISE_DUTY_RATE => ln_total_tax_rate,
615 P_CHARGE_ACCOUNT_ID => null,
616 P_DUTY_AMOUNT => round(l_duty_amt,0),
617 P_RECEIPT_DATE => sysdate,
618 P_GOODS_ISSUE_ID => null,
619 P_GOODS_ISSUE_DATE => null,
620 P_GOODS_ISSUE_QUANTITY => null,
621 P_TRANSACTION_DATE => main_rec.transaction_date,
622 P_BASIC_ED => round(l_excise_duty,0),
623 P_ADDITIONAL_ED => round(l_additional_ed,0),
624 P_ADDITIONAL_CVD => null,
625 P_OTHER_ED => round(l_other_ed,0),
626 P_CVD => null,
627 P_VENDOR_ID => main_rec.from_organization,
628 P_VENDOR_SITE_ID => NULL,
629 P_RECEIPT_NUM => null,
630 P_ATTRIBUTE1 => null,
631 P_ATTRIBUTE2 => null,
632 P_ATTRIBUTE3 => null,
633 P_ATTRIBUTE4 => null,
634 P_ATTRIBUTE5 => null,
635 P_CONSIGNEE => null,
636 P_MANUFACTURER_NAME => null,
637 P_MANUFACTURER_ADDRESS => null,
638 P_MANUFACTURER_RATE_AMT_PER_UN => null,
639 P_QTY_RECEIVED_FROM_MANUFACTUR => null,
640 P_TOT_AMT_PAID_TO_MANUFACTURER => null,
641 P_OTHER_TAX_CREDIT => NVL(ln_cess_amount,0)+NVL(ln_other_sh_cess,0) ,--ADDED ln_other_sh_cessby vkaranam for bug #5907436
642 P_OTHER_TAX_DEBIT => null,
643 P_TRANSACTION_SOURCE => p_transaction_type,
644 P_CALLED_FROM => 'XFER',
645 P_SIMULATE_FLAG => null,
646 P_PROCESS_STATUS => l_process_status,
647 P_PROCESS_MESSAGE => l_process_message
648 );
649 processed_flag :='RG23D';
650
651 -- rchandan for bug#6487364 start
652
653 IF NVL(ln_cess_amount,0) <> 0 then
654
655 stmt_name := 'Calling jai_cmn_rg_others_pkg.insert_row for Cess of RG23D';
656
657 jai_cmn_rg_others_pkg.insert_row(p_source_type => 3,
658 p_source_name => 'RG23D',
659 p_source_id => l_register_id,
660 p_tax_type => jai_constants.tax_type_exc_edu_cess,
661 debit_amt => NULL,
662 credit_amt => ln_cess_amount,
663 p_process_flag => p_process_status,
664 p_process_msg => p_process_message
665 );
666 IF p_process_status <> 'SS' THEN
667 app_exception.raise_exception;
668 END IF;
669
670 END IF;
671 IF NVL(ln_other_sh_cess,0) <> 0 then
672
673 stmt_name := 'Calling jai_cmn_rg_others_pkg.insert_row for SH Cess of RG23D';
674
675 jai_cmn_rg_others_pkg.insert_row(p_source_type => 3,
676 p_source_name => 'RG23D',
677 p_source_id => l_register_id,
678 p_tax_type => jai_constants.tax_type_sh_exc_edu_cess,
679 debit_amt => NULL,
680 credit_amt => ln_other_sh_cess,
681 p_process_flag => p_process_status,
682 p_process_msg => p_process_message
683 );
684 IF p_process_status <> 'SS' THEN
685 app_exception.raise_exception;
686 END IF;
687
688 END IF;
689
690 -- rchandan for bug#6487364 end
691
692 END IF;
693 IF processed_flag = '0' THEN
694 l_process_status := 'E';
695 l_process_message := 'No data Processed';
696 ELSIF processed_flag IN ('RG1','RG23') and main_rec.item_class NOT IN ('FGIN', 'FGEX') THEN /*6501436*/
697 stmt_name := 'Calling jai_cmn_rg_23ac_ii_pkg.insert_row';
698 jai_cmn_rg_23ac_ii_pkg.insert_row(
699 P_REGISTER_ID => l_register_id_ii,
700 P_INVENTORY_ITEM_ID => main_rec.inventory_item_id,
701 P_ORGANIZATION_ID => main_rec.to_organization,
702 P_RECEIPT_ID => main_rec.transaction_temp_id,
703 P_RECEIPT_DATE => null,
704 P_CR_BASIC_ED => l_excise_duty,
705 P_CR_ADDITIONAL_ED => l_additional_ed,
706 P_CR_ADDITIONAL_CVD => null,
707 P_CR_OTHER_ED => l_other_ed,
708 P_DR_BASIC_ED => null,
709 P_DR_ADDITIONAL_ED => null,
710 P_DR_ADDITIONAL_CVD => null,
711 P_DR_OTHER_ED => null,
712 P_EXCISE_INVOICE_NO => p_excise_inv_no /*Replacing main_rec.excise_invoice_no for bug # 6710747*/,
713 P_EXCISE_INVOICE_DATE => sysdate,
714 P_REGISTER_TYPE => l_register_type,
715 P_REMARKS => 'Inter Org transfer from '||main_rec.from_organization||' To '||main_rec.to_organization,
716 P_VENDOR_ID => main_rec.from_organization,
717 P_VENDOR_SITE_ID => NULL,
718 P_CUSTOMER_ID => null,
719 P_CUSTOMER_SITE_ID => null,
720 P_LOCATION_ID => main_rec.location_id,
721 P_TRANSACTION_DATE => main_rec.transaction_date,
722 P_CHARGE_ACCOUNT_ID => null,
723 P_REGISTER_ID_PART_I => l_register_id ,
724 P_REFERENCE_NUM => null,
725 P_ROUNDING_ID => null,
726 P_OTHER_TAX_CREDIT =>nvl(ln_cess_amount,0)+NVL(ln_other_sh_cess,0) ,--ADDED ln_other_sh_cessby vkaranam for bug #5907436,
727 P_OTHER_TAX_DEBIT => null,
728 p_transaction_type => 'R',
729 P_TRANSACTION_SOURCE => null,
730 P_CALLED_FROM => null,
731 P_SIMULATE_FLAG => null,
732 P_PROCESS_STATUS => l_process_status,
733 P_PROCESS_MESSAGE => l_process_message
734 );
735 IF processed_flag = 'RG1' THEN
736 UPDATE JAI_CMN_RG_I_TRXS
737 SET register_id_part_ii = l_register_id_ii,cess_amt = ln_Cess_amount
738 WHERE register_id = l_register_id;
739 ELSE
740 UPDATE JAI_CMN_RG_23AC_I_TRXS SET register_id_part_ii = l_register_id_ii WHERE register_id = l_register_id;
741 END IF;
742 IF SQL%NOTFOUND THEN
743 stmt_name := 'UPDATE register_id = '||l_register_id||': processed_flag = '||processed_flag;
744 RAISE no_data_found;
745 END IF;
746 IF nvl(ln_cess_amount,0)<>0 THEN
747 /*
748 BEGIN
749 SELECT JAI_CMN_RG_23AC_I_TRXSI_S.CURRVAL INTO v_register_id FROM dual;
750 EXCEPTION when others THEN
751 SELECT JAI_CMN_RG_23AC_I_TRXSI_S.CURRVAL INTO v_register_id FROM dual;
752 END;
753 *//*commented the above by vkaranam for bug #5907436*/
754 BEGIN
755 stmt_name := 'Calling jai_cmn_rg_others_pkg.insert_row';
756 if l_register_type='A' THEN
757 lv_source_name:='RG23A_P2';
758 elsif l_register_type='C' THEN
759 lv_source_name:='RG23C_P2';
760 end if;
761 jai_cmn_rg_others_pkg.insert_row(
762 P_SOURCE_TYPE => 1 ,
763 P_SOURCE_NAME => lv_source_name ,
764 P_SOURCE_ID => l_register_id_ii ,
765 P_TAX_TYPE => 'EXCISE_EDUCATION_CESS' ,
766 DEBIT_AMT =>null ,
767 CREDIT_AMT =>ln_cess_amount ,
768 P_PROCESS_FLAG =>l_process_status ,
769 P_PROCESS_MSG =>l_process_message
770 );
771 END;
772
773 END IF;
774 /*added the following for shcess by vkaranam for bug #5907436*/
775 --start 5907436
776 IF nvl(ln_other_sh_cess,0)<>0 THEN
777 BEGIN
778 stmt_name := 'Calling jai_cmn_rg_others_pkg.insert_row';
779 if l_register_type='A' THEN
780 lv_source_name:='RG23A_P2';
781 elsif l_register_type='C' THEN
782 lv_source_name:='RG23C_P2';
783 end if;
784 jai_cmn_rg_others_pkg.insert_row(
785 P_SOURCE_TYPE => 1 ,
786 P_SOURCE_NAME => lv_source_name ,
787 P_SOURCE_ID => l_register_id_ii ,
788 P_TAX_TYPE => jai_constants.tax_type_sh_exc_edu_cess ,
789 DEBIT_AMT =>null ,
790 CREDIT_AMT =>ln_other_sh_cess ,
791 P_PROCESS_FLAG =>l_process_status ,
792 P_PROCESS_MSG =>l_process_message
793 );
794 END;
795 --end bug #5907436
796
797 END IF;
798
799
800 END IF;
801 CLOSE main_cur;
802 p_process_status := l_process_status;
803 p_process_message := l_process_message;
804 EXCEPTION
805 WHEN OTHERS THEN
806 p_process_status := 'E';
807 p_process_message := 'Encounterd an error when doing '||stmt_name||' :'||sqlcode||': '||l_process_message;
808 END;
809 PROCEDURE recv_vat_process(p_organization_id IN NUMBER,
810 p_location_id IN NUMBER,
811 p_Set_of_books_id IN number,
812 p_currency in varchar2,
813 p_transaction_header_id IN NUMBER,
814 p_transaction_temp_id IN NUMBER,
815 p_vat_invoice_no IN VARCHAR2,
816 p_process_status OUT NOCOPY VARCHAR2,
817 p_process_message OUT NOCOPY VARCHAR2)
818 IS
819 ln_regime_id NUMBER;
820 lv_inv_gen_process_flag VARCHAR2(10);
821 lv_inv_gen_process_message VARCHAR2(2000);
822 ln_repository_id NUMBER;
823 lv_source_trx_type VARCHAR2(30):='RECEIVING';
824 table_rcv_transactions VARCHAR2(30):= 'JAI_MTL_TRXS';
825 lv_account_name VARCHAR2(50);
826 ln_code_combination_id NUMBER;
827 ln_interim_recovery_account NUMBER;
828 ln_entered_dr NUMBER;
829 ln_entered_cr NUMBER;
830 lv_process_status VARCHAR2(2);
831 lv_process_message VARCHAR2(1000);
832 v_source_name VARCHAR2(100) := 'Register India' ; -- bug 6487405
833 v_category_name VARCHAR2(100) := 'VAT India' ; -- bug 6487405
834
835 --regime varchar2(100):=jai_constants.vat_regime;
836 CURSOR c_regime_cur IS
837 SELECT regime_id
838 FROM jai_rgm_definitions
839 WHERE regime_code = 'VAT';
840 /*added the below cursor for performance issue*/
841 --start
842 CURSOR c_chk_rgm_trxs(cp_transaction_header_id in number,cp_transaction_temp_id in number,cp_tax_id in number) IS
843 SELECT 1
844 FROM
845 jai_rgm_trx_records jrtr
846 WHERE
847 jrtr.attribute1 = cp_transaction_header_id AND
848 jrtr.source_document_id = cp_transaction_temp_id AND
849 jrtr.reference_id = cp_tax_id AND
850 jrtr.organization_id=p_organization_id AND
851 jrtr.location_id=p_location_id;
852 CURSOR get_tax_id(cp_transaction_header_id in number,cp_transaction_temp_id in number)
853 IS
854 select tax_id
855 from jai_cmn_document_taxes
856 where source_doc_id=cp_transaction_header_id
857 and source_doc_line_id=cp_transaction_temp_id
858 and source_doc_type='INTERORG_XFER';
859 ---END----
860 CURSOR cur_get_mtltxns
861 IS
862 SELECT
863 jtc.tax_type,
864 jtc.tax_rate,
865 --jtc.tax_id,
866 jmt.transaction_temp_id,
867 jmt.transaction_header_id,
868 --jmt.creation_date,
869 sum(jcdt.tax_amt) tax_amt
870 FROM
871 jai_mtl_trxs jmt,
872 jai_cmn_document_taxes jcdt,
873 jai_cmn_taxes_all jtc,
874 jai_rgm_registrations jrg,
875 jai_rgm_definitions jrr
876 WHERE
877 jmt.to_organization = p_organization_id
878 AND jmt.location_id = p_location_id
879 AND jmt.transaction_header_id = p_transaction_header_id
880 AND jmt.transaction_temp_id=p_transaction_temp_id
881 AND jmt.transaction_header_id=jcdt.source_doc_id
882 AND jmt.transaction_temp_id=jcdt.source_doc_line_id
883 AND jcdt.tax_id=jtc.tax_id
884 AND jtc.tax_type= jrg.attribute_code -- bug 6436781
885 AND jrr.regime_code = jai_constants.vat_regime
886 AND jrg.regime_id = jrr.regime_id
887 AND jrg.registration_type = 'TAX_TYPES'
888 AND upper(jrg.attribute_code) <> 'VAT REVERSAL'
889 GROUP BY jtc.tax_type,
890 jtc.tax_rate,
891 jmt.transaction_temp_id,
892 jmt.transaction_header_id;
893
894
895 stmt_name VARCHAR2(64);
896 ln_rgm_cnt number;--bug #6030615
897 r_get_tax_id get_tax_id%rowtype;--bug #6030615
898 BEGIN
899 OPEN c_regime_cur;
900 FETCH c_regime_cur into ln_regime_id;
901 CLOSE c_regime_cur;
902 FOR rec_claims IN cur_get_mtltxns
903 LOOP
904 ln_rgm_cnt:=0;
905 FOR r_get_tax_id in get_tax_id(rec_claims.transaction_header_id,rec_claims.transaction_temp_id)
906 LOOP
907 open c_chk_rgm_trxs(rec_claims.transaction_header_id,rec_claims.transaction_temp_id,r_get_tax_id.tax_id);
908 fetch c_chk_rgm_trxs into ln_rgm_cnt;
909 close c_chk_rgm_trxs;
910 if ln_rgm_cnt=1 then
911 exit;
912 end if;
913 END LOOP;
914 --added this if condition for performance issue
915 if nvl(ln_rgm_cnt,0) = 0 then
916 lv_account_name := jai_constants.recovery;
917 stmt_name:='Getting the interim recovery amount';
918 ln_interim_recovery_account :=
919 jai_cmn_rgm_recording_pkg.get_account(
920 p_regime_id => ln_regime_id,
921 p_organization_type => jai_constants.orgn_type_io,
922 p_organization_id => p_organization_id,
923 p_location_id => p_location_id,
924 p_tax_type => rec_claims.tax_type,
925 p_account_name => jai_constants.recovery_interim);
926 IF ln_interim_recovery_account IS NULL THEN
927 p_process_status := jai_constants.expected_error;
928 p_process_message := 'Interim recovery Account not defined in VAT Setup';
929 RETURN;
930 END IF;
931 stmt_name:='Getting the code combination id';
932 ln_code_combination_id :=
933 jai_cmn_rgm_recording_pkg.get_account(
934 p_regime_id => ln_regime_id,
935 p_organization_type => jai_constants.orgn_type_io,
936 p_organization_id => p_organization_id,
937 p_location_id => p_location_id,
938 p_tax_type => rec_claims.tax_type,
939 p_account_name => jai_constants.recovery);
940 IF ln_code_combination_id IS NULL THEN
941 p_process_status := jai_constants.expected_error;
942 p_process_message := 'Recovery Account not defined in VAT Setup';
943 RETURN;
944 END IF;
945 ln_entered_dr := NULL;
946 ln_entered_cr := rec_claims.tax_amt;
947 IF ln_entered_cr < 0 THEN
948 ln_entered_dr := ln_entered_cr*-1;
949 ln_entered_cr := NULL;
950 END IF;
951 stmt_name:='Calling insert vat repository entry';
952 jai_cmn_rgm_recording_pkg.insert_vat_repository_entry(
953 pn_repository_id => ln_repository_id,
954 pn_regime_id => ln_regime_id,
955 pv_tax_type => rec_claims.tax_type,
956 pv_organization_type => jai_constants.orgn_type_io,
957 pn_organization_id => p_organization_id,
958 pn_location_id => p_location_id,
959 pv_source => jai_constants.source_rcv,
960 pv_source_trx_type => lv_source_trx_type,
961 pv_source_table_name => table_rcv_transactions,
962 pn_source_id => p_transaction_temp_id,
963 pd_transaction_date => trunc(sysdate),
964 pv_account_name => lv_account_name,
965 pn_charge_account_id => ln_code_combination_id,
966 pn_balancing_account_id => ln_interim_recovery_account,
967 pn_credit_amount => ln_entered_cr,
968 pn_debit_amount => ln_entered_dr,
969 pn_assessable_value => NULL,
970 pn_tax_rate => NULL,
971 pn_reference_id => p_transaction_temp_id,/*r_claim_schedule.claim_schedule_id,*/
972 pn_batch_id => NULL,
973 pn_inv_organization_id => P_organization_id,
974 pv_invoice_no => p_vat_invoice_no,
975 pd_invoice_date => trunc(sysdate),
976 pv_called_from => 'JAINVMTX',
977 pv_process_flag => lv_process_status,
978 pv_process_message => lv_process_message,
979 pv_attribute_context => NULL,
980 pv_attribute1 => NULL,
981 pv_attribute2 => NULL,
982 pv_attribute3 => NULL,
983 pv_attribute4 => NULL,
984 pv_attribute5 => NULL);
985 IF lv_process_status <> jai_constants.successful THEN
986 p_process_status := lv_process_status;
987 p_process_message := lv_process_message;
988 RETURN;
989 END IF;
990 begin
991 jai_mtl_trxs_pkg.do_cenvat_Acctg(
992 p_set_of_books_id => p_set_of_books_id ,
993 p_transaction_temp_id =>p_transaction_temp_id ,
994 p_je_source_name =>v_source_name ,
995 p_je_category_name =>v_category_name,
996 p_currency_code => p_currency ,
997 p_register_type => 'RVAT',
998 p_process_status => lv_process_status,
999 p_process_message =>lv_process_message
1000 );
1001 if lv_process_message is not null then
1002 p_process_message:=lv_process_message;
1003 app_exception.raise_exception;
1004 end if;
1005 exception when others then
1006 app_exception.raise_exception;
1007 end;
1008
1009
1010 /*COMMENTED BY VASAVI*/
1011 ---CR Vat Recovery
1012 /*
1013 ln_entered_dr := NULL;
1014 ln_entered_cr := rec_claims.tax_amt;
1015 stmt_name:='calling do vat accounting procedure for credit';
1016 jai_cmn_rgm_recording_pkg.do_vat_accounting(
1017 pn_regime_id => ln_regime_id,
1018 pn_repository_id => ln_repository_id,
1019 pv_organization_type => jai_constants.orgn_type_io,
1020 pn_organization_id => p_organization_id,
1021 pd_accounting_date => trunc(sysdate),
1022 pd_transaction_date => trunc(sysdate),
1023 pn_credit_amount => ln_entered_cr,
1024 pn_debit_amount => ln_entered_dr,
1025 pn_credit_ccid => ln_interim_recovery_account ,
1026 pn_debit_ccid => ln_code_combination_id,
1027 pv_called_from => NULL,
1028 pv_process_flag => lv_process_status,
1029 pv_process_message => lv_process_message,
1030 pv_tax_type => rec_claims.tax_type,
1031 pv_source => jai_constants.source_rcv,
1032 pv_source_trx_type => lv_source_trx_type,
1033 pv_source_table_name => table_rcv_transactions,
1034 pn_source_id => p_transaction_temp_id,
1035 pv_reference_name => NULL,
1036 pn_reference_id => NULL
1037 );
1038 ---Dr Vat Recovery
1039 ln_entered_dr := rec_claims.tax_amt;
1040 ln_entered_cr:= NULL;
1041 stmt_name:='calling do vat accounting procedure for debit';
1042 jai_cmn_rgm_recording_pkg.do_vat_accounting(
1043 pn_regime_id => ln_regime_id,
1044 pn_repository_id => ln_repository_id,
1045 pv_organization_type => jai_constants.orgn_type_io,
1046 pn_organization_id => p_organization_id,
1047 pd_accounting_date => trunc(sysdate),
1048 pd_transaction_date => trunc(sysdate),
1049 pn_credit_amount => ln_entered_cr,
1050 pn_debit_amount => ln_entered_dr,
1051 pn_credit_ccid => ln_interim_recovery_account ,
1052 pn_debit_ccid => ln_code_combination_id,
1053 pv_called_from => NULL,
1054 pv_process_flag => lv_process_status,
1055 pv_process_message => lv_process_message,
1056 pv_tax_type => rec_claims.tax_type,
1057 pv_source => jai_constants.source_rcv,
1058 pv_source_trx_type => lv_source_trx_type,
1059 pv_source_table_name => table_rcv_transactions,
1060 pn_source_id => p_transaction_temp_id,
1061 pv_reference_name => NULL,
1062 pn_reference_id => NULL
1063 );
1064 */
1065 end if; --ln_rgm_cnt
1066 END LOOP;
1067 EXCEPTION
1068 WHEN OTHERS THEN
1069 p_process_status := 'E';
1070 p_process_message := 'SQL error @ '||stmt_name||' :'||sqlcode||': '||sqlerrm;
1071 END;
1072
1073 procedure cenvat_recpt_det(block_data in out NOCOPY claimcur,
1074 p_organization_id in number)
1075 is
1076 begin
1077 open block_data for
1078 select rcv.receipt_num,
1079 rcv.quantity,
1080 cen.cenvat_claimed_ptg,
1081 cen.quantity_for_2nd_claim,
1082 cen.cenvat_amt_for_2nd_claim,
1083 cen.shipment_line_id,
1084 cen.cenvat_claimed_amt,
1085 cen.other_cenvat_claimed_amt ,
1086 cen.other_cenvat_amt_for_2nd_claim,
1087 cen.cenvat_amount,
1088 cen.other_cenvat_amt,
1089 cen.transaction_id ,
1090 rcv.excise_invoice_no ,
1091 rcv.excise_invoice_date
1092 from
1093 JAI_RCV_TRANSACTIONS rcv,
1094 JAI_RCV_CENVAT_CLAIMS cen
1095 where
1096 rcv.shipment_line_id=cen.shipment_line_id
1097 and rcv.item_class in ('CGIN','CGEX')
1098 and rcv.transaction_type='RECEIVE'
1099 and cen.cenvat_claimed_ptg<>0
1100 and cen.quantity_for_2nd_claim is not null
1101 and organization_id=p_organization_id
1102 order by receipt_num;
1103 end cenvat_recpt_det;
1104
1105 PROCEDURE gl_entry(p_params IN gl_entries,
1106 p_set_of_books_id IN NUMBER,
1107 p_je_source_name IN VARCHAR2,
1108 p_je_category_name IN VARCHAR2,
1109 p_currency_code IN VARCHAR2,
1110 p_transaction_temp_id IN NUMBER,
1111 p_process_status OUT NOCOPY VARCHAR2,
1112 p_process_message OUT NOCOPY VARCHAR2)
1113 IS
1114 stmt_name VARCHAR2(256);
1115 BEGIN
1116
1117 FOR i IN 0..p_params.COUNT-1
1118 LOOP
1119
1120 IF p_params(i).amount IS NOT NULL AND
1121 p_params(i).debit_account IS NOT NULL AND
1122 p_params(i).credit_account IS NOT NULL
1123 THEN
1124 stmt_name := 'Calling insert into gl_interface debit';
1125 insert into gl_interface
1126 ( status,
1127 set_of_books_id,
1128 user_je_source_name,
1129 user_je_category_name,
1130 accounting_date,
1131 currency_code,
1132 date_created,
1133 created_by,
1134 actual_flag,
1135 entered_cr,
1136 entered_dr,
1137 transaction_date,
1138 code_combination_id,
1139 currency_conversion_date,
1140 user_currency_conversion_type,
1141 currency_conversion_rate,
1142 reference1,
1143 reference10,
1144 reference23,
1145 reference24,
1146 reference25,
1147 reference26,
1148 reference27,
1149 reference22
1150 )
1151 VALUES
1152 ('NEW',
1153 p_set_of_books_id,
1154 p_je_source_name,
1155 p_je_category_name,
1156 sysdate,
1157 p_currency_code,
1158 sysdate,
1159 fnd_global.user_id,
1160 'A',
1161 null,
1162 p_params(i).amount,
1163 sysdate,
1164 p_params(i).debit_account, -- Derived Value from JAI_CMN_INVENTORY_ORGS / mtl_interorg_parameters
1165 null,
1166 null,
1167 null,
1168 p_params(i).organization_code, -- From mtl_parameters
1169 'India Localization Entry for Interorg-XFER ',
1170 'jai_mtl_trx_pkg.do_cenvat_Acctg',
1171 'jai_mtl_trxs',
1172 p_transaction_temp_id,
1173 'transaction_temp_id',
1174 to_char(p_params(i).organization_id),
1175 'India Localization Entry' -- bug 6487405
1176 );
1177
1178
1179 stmt_name := 'Calling insert into jai_mtl_trx_jrnls debit';
1180 insert into jai_mtl_trx_jrnls
1181 (journal_entry_id,
1182 status,
1183 set_of_books_id,
1184 user_je_source_name,
1185 user_je_category_name,
1186 accounting_date,
1187 currency_code,
1188 date_created,
1189 created_by,
1190 entered_cr,
1191 entered_dr,
1192 transaction_date,
1193 code_combination_id,
1194 currency_conversion_date,
1195 user_currency_conversion_type,
1196 currency_conversion_rate,
1197 reference1,
1198 reference10,
1199 reference23,
1200 reference24,
1201 reference25,
1202 reference26,
1203 reference27,
1204 creation_Date,
1205 last_updated_by,
1206 last_update_date,
1207 last_update_login,
1208 transaction_temp_id
1209
1210 )
1211 VALUES
1212 (jai_mtl_trx_jrnls_s.nextval,
1213 'NEW',
1214 p_set_of_books_id,
1215 p_je_source_name,
1216 p_je_category_name,
1217 sysdate,
1218 p_currency_code,
1219 sysdate,
1220 fnd_global.user_id,
1221 null,
1222 p_params(i).amount,
1223 sysdate,
1224 p_params(i).debit_account, -- Derived Value from JAI_CMN_INVENTORY_ORGS / mtl_interorg_parameters
1225 null,
1226 null,
1227 null,
1228 p_params(i).organization_code, -- From mtl_parameters
1229 'India Localization Entry for Interorg-XFER ',
1230 'jai_mtl_trx_pkg.do_cenvat_Acctg',
1231 'jai_mtl_trxs',
1232 p_transaction_temp_id,
1233 'transaction_temp_id',
1234 to_char(p_params(i).organization_id),
1235 sysdate,
1236 fnd_global.user_id,
1237 sysdate,
1238 fnd_global.login_id,
1239 p_transaction_temp_id
1240 );
1241
1242
1243 stmt_name := 'Calling insert int gl_interface credit';
1244 insert into gl_interface
1245 ( status,
1246 set_of_books_id,
1247 user_je_source_name,
1248 user_je_category_name,
1249 accounting_date,
1250 currency_code,
1251 date_created,
1252 created_by,
1253 actual_flag,
1254 entered_cr,
1255 entered_dr,
1256 transaction_date,
1257 code_combination_id,
1258 currency_conversion_date,
1259 user_currency_conversion_type,
1260 currency_conversion_rate,
1261 reference1,
1262 reference10,
1263 reference23,
1264 reference24,
1265 reference25,
1266 reference26,
1267 reference27,
1268 reference22
1269 )
1270 VALUES
1271 ('NEW',
1272 p_set_of_books_id,
1273 p_je_source_name,
1274 p_je_category_name,
1275 sysdate,
1276 p_currency_code,
1277 sysdate,
1278 fnd_global.user_id,
1279 'A',
1280 p_params(i).amount,
1281 null,
1282 sysdate,
1283 p_params(i).credit_account,
1284 null,
1285 null,
1286 null,
1287 p_params(i).organization_code,
1288 'India Localization Entry for Interorg-XFER ',
1289 'jai_mtl_trx_pkg.do_cenvat_Acctg',
1290 'jai_mtl_trxs',
1291 p_transaction_temp_id,
1292 'transaction_temp_id',
1293 to_char(p_params(i).organization_id),
1294 'India Localization Entry' -- bug 6487405
1295 );
1296
1297
1298 stmt_name := 'Calling insert int jai_mtl_trx_jrnls credit';
1299 insert into jai_mtl_trx_jrnls
1300 (journal_entry_id,
1301 status,
1302 set_of_books_id,
1303 user_je_source_name,
1304 user_je_category_name,
1305 accounting_date,
1306 currency_code,
1307 date_created,
1308 created_by,
1309 entered_cr,
1310 entered_dr,
1311 transaction_date,
1312 code_combination_id,
1313 currency_conversion_date,
1314 user_currency_conversion_type,
1315 currency_conversion_rate,
1316 reference1,
1317 reference10,
1318 reference23,
1319 reference24,
1320 reference25,
1321 reference26,
1322 reference27,
1323 creation_Date,
1324 last_updated_by,
1325 last_update_date,
1326 last_update_login,
1327 transaction_temp_id
1328 )
1329 VALUES
1330 (jai_mtl_trx_jrnls_s.nextval,
1331 'NEW',
1332 p_set_of_books_id,
1333 p_je_source_name,
1334 p_je_category_name,
1335 sysdate,
1336 p_currency_code,
1337 sysdate,
1338 fnd_global.user_id,
1339 p_params(i).amount,
1340 null,
1341 sysdate,
1342 p_params(i).credit_account,
1343 null,
1344 null,
1345 null,
1346 p_params(i).organization_code,
1347 'India Localization Entry for Interorg-XFER ',
1348 'jai_mtl_trx_pkg.do_cenvat_Acctg',
1349 'jai_mtl_trxs',
1350 p_transaction_temp_id,
1351 'transaction_temp_id',
1352 to_char(p_params(i).organization_id),
1353 sysdate,
1354 fnd_global.user_id,
1355 sysdate,
1356 fnd_global.login_id,
1357 p_transaction_temp_id
1358 );
1359
1360 END IF;
1361 END LOOP;
1362
1363 EXCEPTION
1364 WHEN OTHERS THEN
1365 p_process_status := 'E';
1366 p_process_message := 'Stmt'||stmt_name||'-'||sqlcode||':'||sqlerrm;
1367 ROLLBACK TO gl_acctg;
1368 END;
1369
1370
1371
1372 PROCEDURE do_cenvat_Acctg(
1373 p_set_of_books_id IN NUMBER,
1374 p_transaction_temp_id IN NUMBER,
1375 p_je_source_name IN VARCHAR2,
1376 p_je_category_name IN VARCHAR2,
1377 p_currency_code IN VARCHAR2,
1378 p_register_type IN VARCHAR2,
1379 p_process_status OUT NOCOPY VARCHAR2,
1380 p_process_message OUT NOCOPY VARCHAR2
1381 )
1382 IS
1383 CURSOR main_cur IS
1384 SELECT A.Tax_Id,
1385 DECODE(aa.regime_code, 'VAT', 4, DECODE( UPPER( A.Tax_Type ),
1386 'EXCISE', 1,
1387 'ADDL. EXCISE', 1,
1388 'OTHER EXCISE', 1,
1389 jai_constants.tax_type_exc_edu_cess, 5,jai_constants.tax_type_sh_exc_edu_cess,6, /*changed taxtype_val to 6 for sh_cess by vkaranam for bug #5907436*/--Added higher education cess by kundan kumar for bug#5907436
1390
1391 'TDS', 2, 0)) tax_type_val,
1392 A.Tax_Amt tax_amount,
1393 b.tax_account_id ,
1394 A.Tax_Type tax_type,
1395 d.from_organization ,
1396 d.from_subinventory ,
1397 d.to_organization ,
1398 d.to_subinventory ,
1399 d.location_id,
1400 d.inventory_item_id
1401 FROM Jai_cmn_document_Taxes A,
1402 jai_cmn_taxes_all B,
1403 jai_mtl_trxs D,
1404 jai_regime_tax_types_v aa
1405 WHERE source_doc_line_id = p_transaction_temp_id
1406 AND d.transaction_temp_id = p_transaction_temp_id
1407 AND a.source_doc_type = 'INTERORG_XFER'
1408 AND A.Tax_Id = B.Tax_Id
1409 AND aa.tax_type(+) = b.tax_type;
1410
1411
1412 l_process_status VARCHAR2(5) DEFAULT NULL;
1413 l_process_message VARCHAR2(256) DEFAULT NULL;
1414 processed_flag VARCHAR2(32) := '0';
1415 stmt_name VARCHAR2(256);
1416
1417 ln_from_loc_id NUMBER;
1418
1419 -- Parameter Table
1420 t_gl_entries gl_entries;
1421 rec NUMBER := 0;
1422 /*
1423 ccids from organization additional information setup
1424 */
1425 r_from_ja_in_hr_org JAI_CMN_INVENTORY_ORGS%rowtype;
1426 r_to_ja_in_hr_org JAI_CMN_INVENTORY_ORGS%rowtype;
1427
1428 /*
1429 ccids from mtl interorg parameters
1430 */
1431 r_mtl_interorg mtl_interorg_parameters%rowtype;
1432
1433 /*
1434 cc id of inventory recvng accnt
1435 */
1436 ln_inv_recvng NUMBER;
1437
1438
1439
1440 CURSOR c_get_location(p_organization_id IN NUMBER , p_subinventory IN VARCHAR2)
1441 IS
1442 SELECT location_id
1443 FROM JAI_INV_SUBINV_DTLS
1444 WHERE organization_id = p_organization_id
1445 AND sub_inventory_name = p_subinventory;
1446
1447 CURSOR c_get_ja_accts(p_organization_id NUMBER , p_location_id number) IS
1448 SELECT *
1449 FROM JAI_CMN_INVENTORY_ORGS
1450 WHERE organization_id = p_organization_id
1451 AND location_id = p_location_id;
1452
1453 CURSOR c_get_interorg_params( p_from_organization_id IN NUMBER, p_to_organization_id IN NUMBER ) IS
1454 SELECT *
1455 FROM mtl_interorg_parameters
1456 WHERE from_organization_id = p_from_organization_id
1457 AND to_organization_id = p_to_organization_id ;
1458
1459 CURSOR c_get_trx_info IS
1460 SELECT * FROM jai_mtl_trxs
1461 WHERE transaction_temp_id = p_transaction_temp_id;
1462
1463 CURSOR c_rcv_params (p_organization_id IN NUMBER) IS
1464 select receiving_account_id
1465 FROM rcv_parameters
1466 WHERE organization_id = p_organization_id;
1467
1468 CURSOR c_org_code(p_org_id IN NUMBER) IS
1469 SELECT organization_code
1470 FROM mtl_parameters
1471 WHERE organization_id = p_org_id;
1472
1473 CURSOR c_item_class (cp_inv_item_id IN NUMBER , cp_orgn_id IN NUMBER) IS
1474 select item_class
1475 from JAI_INV_ITM_SETUPS
1476 where inventory_item_id = cp_inv_item_id
1477 and organization_id = cp_orgn_id ;
1478
1479 r_item_class c_item_class%rowtype;
1480
1481
1482 r_mtl_trx_info c_get_trx_info%ROWTYPE;
1483 r_rcv_params c_rcv_params%ROWTYPE;
1484 r_get_interorg_params c_get_interorg_params%ROWTYPE;
1485 l_from_org_cd mtl_parameters.organization_code%TYPE;
1486 l_to_org_cd mtl_parameters.organization_code%TYPE;
1487 l_regime_id NUMBER;
1488
1489 lv_process_flag VARCHAR2(20);
1490 lv_process_message VARCHAR2(2000);
1491
1492 CURSOR c_get_bonded(p_organization_id IN NUMBER , p_subinventory IN VARCHAR2)/*6487803*/
1493 IS
1494 SELECT bonded
1495 FROM JAI_INV_SUBINV_DTLS
1496 WHERE organization_id = p_organization_id
1497 AND sub_inventory_name = p_subinventory;
1498
1499 lv_bonded JAI_INV_SUBINV_DTLS.bonded%TYPE; /*6487803*/
1500
1501
1502
1503 BEGIN
1504 SAVEPOINT gl_acctg;
1505
1506 stmt_name := 'Opening main_cur';
1507 OPEN c_get_trx_info;
1508 FETCH c_get_trx_info INTO r_mtl_trx_info;
1509 CLOSE c_get_trx_info;
1510
1511 stmt_name := 'Selecting From_organization_code';
1512 OPEN c_org_code(r_mtl_trx_info.from_organization);
1513 FETCH c_org_code INTO l_from_org_cd;
1514 CLOSE c_org_code;
1515
1516 stmt_name := 'Selecting to_organization_code';
1517 OPEN c_org_code(r_mtl_trx_info.to_organization);
1518 FETCH c_org_code INTO l_to_org_cd;
1519 CLOSE c_org_code;
1520
1521 stmt_name := 'Selecting regime id';
1522 SELECT regime_id
1523 INTO l_regime_id
1524 FROM jai_rgm_definitions
1525 WHERE regime_Code = 'VAT';
1526
1527 stmt_name := 'Opening c_get_interorg_params';
1528 OPEN c_get_interorg_params(r_mtl_trx_info.from_organization, r_mtl_trx_info.to_organization) ;
1529 FETCH c_get_interorg_params INTO r_get_interorg_params;
1530 CLOSE c_get_interorg_params;
1531
1532 /*
1533 get the from org accts from org additional info setup
1534 */
1535
1536
1537 /*
1538 1. get the FROM location
1539 2. get the accounts FROM ja_in_hr_organization units FOR FROM org AND TO org
1540 3. get the accounts FROM mtl_interorg_parameters based ON FROM org AND TO org
1541 4. get the inventory recvng accnt FROM rcv_parameters
1542 */
1543
1544 stmt_name := 'Opening c_get_location';
1545 OPEN c_get_location(r_mtl_trx_info.from_organization , r_mtl_trx_info.from_subinventory);
1546 FETCH c_get_location INTO ln_from_loc_id;
1547 CLOSE c_get_location;
1548
1549 stmt_name := 'Opening c_get_bonded'; /*6487803*/
1550 OPEN c_get_bonded(r_mtl_trx_info.to_organization , r_mtl_trx_info.to_subinventory);
1551 FETCH c_get_bonded INTO lv_bonded;
1552 CLOSE c_get_bonded;
1553
1554 stmt_name := 'Opening c_get_ja_accts';
1555 OPEN c_get_ja_accts ( r_mtl_trx_info.from_organization , ln_from_loc_id);
1556 FETCH c_get_ja_accts INTO r_from_ja_in_hr_org;
1557 CLOSE c_get_ja_accts;
1558
1559 stmt_name := 'Opening c_get_ja_accts';
1560 OPEN c_get_ja_accts ( r_mtl_trx_info.to_organization , r_mtl_trx_info.location_id);
1561 FETCH c_get_ja_accts INTO r_to_ja_in_hr_org;
1562 CLOSE c_get_ja_accts;
1563
1564 stmt_name := 'Opening c_rcv_params';
1565 OPEN c_rcv_params(r_mtl_trx_info.to_organization);
1566 FETCH c_rcv_params INTO r_rcv_params;
1567 CLOSE c_rcv_params;
1568
1569
1570
1571 FOR main_rec IN main_cur
1572 LOOP
1573
1574
1575
1576 IF main_rec.tax_type_val = 1 and p_register_type IN ('A','C','PLA','RG23D' ) THEN
1577
1578 IF r_from_ja_in_hr_org.TRADING <> 'Y' THEN -- bug 6740006
1579
1580 t_gl_entries(rec).amount := main_rec.tax_amount;
1581 t_gl_entries(rec).debit_account := r_from_ja_in_hr_org.excise_rcvble_account;
1582
1583
1584 IF t_gl_entries(rec).debit_account IS NULL THEN
1585 p_process_status := 'E';
1586 p_process_message := 'Excise paid/payables a/c is null';
1587 RETURN;
1588 END IF;
1589
1590 IF r_from_ja_in_hr_org.excise_paid_account IS NULL THEN
1591 p_process_status := 'E';
1592 p_process_message := '';
1593 END IF;
1594 IF p_register_type = 'A' THEN
1595 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.modvat_rm_account_id;
1596 IF t_gl_entries(rec).credit_account IS NULL THEN
1597 p_process_status := 'E';
1598 p_process_message := 'Modvat RM a/c is null';
1599 RETURN;
1600 END IF;
1601 ELSIF p_register_type = 'PLA' THEN
1602 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.modvat_pla_account_id;
1603 IF t_gl_entries(rec).credit_account IS NULL THEN
1604 p_process_status := 'E';
1605 p_process_message := 'Modvat PLA a/c is null';
1606 RETURN;
1607 END IF;
1608 ELSIF p_register_type = 'C' THEN
1609 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.modvat_cg_account_id;
1610 IF t_gl_entries(rec).credit_account IS NULL THEN
1611 p_process_status := 'E';
1612 p_process_message := 'Modvat CG a/c is null';
1613 RETURN;
1614 END IF;
1615 ELSIF p_register_type = 'RG23D' THEN
1616 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_23d_account;
1617 IF t_gl_entries(rec).credit_account IS NULL THEN
1618 p_process_status := 'E';
1619 p_process_message := 'Excise 23D a/c is null';
1620 RETURN;
1621 END IF;
1622
1623 END IF;
1624 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
1625 t_gl_entries(rec).organization_code := l_from_org_cd;
1626 rec := rec + 1;
1627 END IF ; -- bug 6740006
1628
1629
1630 IF r_get_interorg_params.intransit_type = 2 /* Intransit */ THEN
1631
1632 IF r_get_interorg_params.fob_point = 1 THEN -- SHIPMENTS
1633
1634 t_gl_entries(rec).amount := main_rec.tax_amount;
1635 t_gl_entries(rec).debit_account := r_get_interorg_params.interorg_receivables_account;
1636 IF r_from_ja_in_hr_org.TRADING = 'Y' THEN -- BUG 6488406
1637 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_23d_account;
1638 ELSE
1639 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_rcvble_account;
1640 END if;
1641 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
1642 t_gl_entries(rec).organization_code := l_from_org_cd;
1643
1644 IF t_gl_entries(rec).debit_account IS NULL THEN
1645 p_process_status := 'E';
1646 p_process_message := 'Interorg Receivables a/c is null';
1647 RETURN;
1648 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
1649 p_process_status := 'E';
1650 p_process_message := 'Excise paid/payables a/c is null';
1651 RETURN;
1652 END IF;
1653 rec := rec + 1;
1654
1655 t_gl_entries(rec).amount := main_rec.tax_amount;
1656 t_gl_entries(rec).debit_account := r_get_interorg_params.intransit_inv_account ;
1657 t_gl_entries(rec).credit_account := r_get_interorg_params.interorg_payables_account;
1658 t_gl_entries(rec).organization_id := r_mtl_trx_info.to_organization;
1659 t_gl_entries(rec).organization_code := l_to_org_cd;
1660 IF t_gl_entries(rec).debit_account IS NULL THEN
1661 p_process_status := 'E';
1662 p_process_message := 'Intransit inventory a/c is null';
1663 RETURN;
1664 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
1665 p_process_status := 'E';
1666 p_process_message := 'InterOrg Payables a/c is null';
1667 RETURN;
1668 END IF;
1669 rec := rec + 1;
1670
1671 ELSIF r_get_interorg_params.fob_point = 2 THEN -- Receipt
1672
1673 t_gl_entries(rec).amount := main_rec.tax_amount;
1674 t_gl_entries(rec).debit_account := r_get_interorg_params.intransit_inv_account ;
1675 IF r_from_ja_in_hr_org.TRADING = 'Y' THEN -- BUG 6488406
1676 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_23d_account;
1677 ELSE
1678 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_rcvble_account;
1679 END if;
1680 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
1681 t_gl_entries(rec).organization_code := l_from_org_cd;
1682 IF t_gl_entries(rec).debit_account IS NULL THEN
1683 p_process_status := 'E';
1684 p_process_message := 'Intransit inventory a/c is null';
1685 RETURN;
1686 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
1687 p_process_status := 'E';
1688 p_process_message := 'Excise paid/payables a/c is null';
1689 RETURN;
1690 END IF;
1691 rec := rec + 1;
1692
1693 END IF;
1694
1695 ELSIF r_get_interorg_params.intransit_type = 1 THEN -- Direct
1696
1697 t_gl_entries(rec).amount := main_rec.tax_amount;
1698 t_gl_entries(rec).debit_account := r_get_interorg_params.interorg_receivables_account;
1699
1700 IF r_from_ja_in_hr_org.TRADING = 'Y' THEN -- BUG 6740006
1701 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_23d_account;
1702 ELSE
1703 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_rcvble_account;
1704 END IF;
1705
1706 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
1707 t_gl_entries(rec).organization_code := l_from_org_cd;
1708
1709
1710 IF t_gl_entries(rec).debit_account IS NULL THEN
1711 p_process_status := 'E';
1712 p_process_message := 'InterOrg receivables a/c is null';
1713 RETURN;
1714 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
1715 p_process_status := 'E';
1716 p_process_message := 'Excise paid payables a/c is null';
1717 RETURN;
1718 END IF;
1719 rec := rec + 1;
1720
1721 t_gl_entries(rec).amount := main_rec.tax_amount;
1722 t_gl_entries(rec).debit_account := r_rcv_params.receiving_account_id;
1723 t_gl_entries(rec).credit_account := r_get_interorg_params.interorg_payables_account;
1724 t_gl_entries(rec).organization_id := r_mtl_trx_info.to_organization;
1725 t_gl_entries(rec).organization_code := l_to_org_cd;
1726
1727
1728
1729 IF t_gl_entries(rec).debit_account IS NULL THEN
1730 p_process_status := 'E';
1731 p_process_message := 'Inventory Receiving a/c is null';
1732 RETURN;
1733 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
1734 p_process_status := 'E';
1735 p_process_message := 'InterOrg Payables a/c is null';
1736 RETURN;
1737 END IF;
1738 rec := rec + 1;
1739
1740 open c_item_class(main_rec.inventory_item_id, r_mtl_trx_info.to_organization);
1741 FETCH c_item_class INTO r_item_class;
1742 close c_item_class;
1743
1744 IF (r_to_ja_in_hr_org.TRADING = 'Y' or lv_bonded = 'Y') AND /*6487803*/
1745 r_item_class.item_class NOT IN ('FGIN','FGEX') THEN /*6501436*/
1746
1747 t_gl_entries(rec).amount := main_rec.tax_amount;
1748 -- CHANGES FOR START BUG 6740006
1749
1750
1751 IF r_to_ja_in_hr_org.TRADING = 'Y' THEN
1752 t_gl_entries(rec).debit_account := r_to_ja_in_hr_org.excise_23d_account;
1753 IF r_to_ja_in_hr_org.excise_23d_account IS NULL THEN
1754 p_process_status :='E';
1755 p_process_message :='RG23D Account not defined in Receiving Org';
1756 RETURN;
1757 END IF;
1758 ELSIF r_item_class.item_class IN ('RMIN', 'RMEX', 'CCIN', 'CCEX') then /*/*6501436.removed FGIN and FGEX*/
1759 t_gl_entries(rec).debit_account := r_to_ja_in_hr_org.modvat_rm_account_id;
1760 IF r_to_ja_in_hr_org.modvat_rm_account_id IS NULL THEN
1761 p_process_status := 'E';
1762 p_process_message := 'Modvat RM Account not defined in Receiving Org';
1763 RETURN;
1764 END IF;
1765 ELSIF r_item_class.item_class IN ('CGIN', 'CGEX') then
1766 t_gl_entries(rec).debit_account := r_to_ja_in_hr_org.modvat_cg_account_id;
1767 IF r_to_ja_in_hr_org.modvat_cg_account_id IS NULL THEN
1768 p_process_status :='E';
1769 p_process_message :='Modvat CG Account not defined in Receiving Org';
1770 RETURN;
1771 END IF;
1772 end if;
1773
1774
1775 -- CHANGES FOR END BUG 6740006
1776
1777
1778 t_gl_entries(rec).credit_account := r_rcv_params.receiving_account_id;
1779 IF t_gl_entries(rec).credit_account IS NULL THEN
1780 p_process_Status := 'E';
1781 p_process_message := 'Receiving Inventory ACcount is not defined for Receiving Org';
1782 RETURN;
1783 END IF;
1784 t_gl_entries(rec).organization_id := r_mtl_trx_info.to_organization;
1785 t_gl_entries(rec).organization_code := l_to_org_cd;
1786 rec := rec + 1;
1787 END IF;/*6487803*/
1788
1789 END IF;
1790 ELSIF main_rec.tax_type_val = 5 and p_register_type IN ('A','C','PLA','RG23D' ) THEN -- excise education cess
1791
1792 IF r_from_ja_in_hr_org.TRADING <> 'Y' THEN -- bug 6740006
1793
1794 t_gl_entries(rec).amount := main_rec.tax_amount;
1795 t_gl_entries(rec).debit_account := r_from_ja_in_hr_org.cess_paid_payable_account_id;
1796
1797
1798
1799
1800 IF p_register_type = 'A' THEN
1801 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_edu_cess_rm_account;
1802 IF t_gl_entries(rec).credit_account IS NULL THEN
1803 p_process_status := 'E';
1804 p_process_message := 'Excise cess RM a/c is null';
1805 RETURN;
1806 END IF;
1807 ELSIF p_register_type = 'PLA' THEN
1808 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.modvat_pla_account_id;
1809 IF t_gl_entries(rec).credit_account IS NULL THEN
1810 p_process_status := 'E';
1811 p_process_message := 'Modvat PLA a/c is null';
1812 RETURN;
1813 END IF;
1814 ELSIF p_register_type = 'C' THEN
1815 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_edu_cess_cg_account;
1816 IF t_gl_entries(rec).credit_account IS NULL THEN
1817 p_process_status := 'E';
1818 p_process_message := 'Excise cess cg a/c is null';
1819 RETURN;
1820 END IF;
1821 ELSIF p_register_type = 'RG23D' THEN
1822 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_23d_account;
1823 IF t_gl_entries(rec).credit_account IS NULL THEN
1824 p_process_status := 'E';
1825 p_process_message := 'Excise RG23D a/c is null';
1826 RETURN;
1827 END IF;
1828
1829 END IF;
1830 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
1831 t_gl_entries(rec).organization_code := l_from_org_cd;
1832 IF t_gl_entries(rec).debit_account IS NULL THEN
1833 p_process_status := 'E';
1834 p_process_message := 'Cess-Paid Payables a/c is null';
1835 RETURN;
1836 END IF;
1837
1838
1839
1840
1841 rec := rec + 1;
1842
1843 END IF; -- bug 6740006
1844
1845 IF r_get_interorg_params.intransit_type = 2 THEN -- IN TRANSIT
1846
1847 IF r_get_interorg_params.fob_point = 1 THEN -- Shipments
1848 t_gl_entries(rec).amount := main_rec.tax_amount;
1849 t_gl_entries(rec).debit_account := r_get_interorg_params.interorg_receivables_account;
1850 IF r_from_ja_in_hr_org.TRADING = 'Y' THEN -- BUG 6488406
1851 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_23d_account;
1852 ELSE
1853 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.cess_paid_payable_account_id;
1854 END if;
1855 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
1856 t_gl_entries(rec).organization_code := l_from_org_cd;
1857 IF t_gl_entries(rec).debit_account IS NULL THEN
1858 p_process_status := 'E';
1859 p_process_message := 'InterOrg recevables a/c is null';
1860 RETURN;
1861 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
1862 p_process_status := 'E';
1863 p_process_message := 'Cess-paid Payables a/c is null';
1864 RETURN;
1865 END IF;
1866 rec := rec + 1;
1867
1868 t_gl_entries(rec).amount := main_rec.tax_amount;
1869 t_gl_entries(rec).debit_account := r_get_interorg_params.intransit_inv_account;
1870 t_gl_entries(rec).credit_account := r_get_interorg_params.interorg_payables_account;
1871 t_gl_entries(rec).organization_id := r_mtl_trx_info.to_organization;
1872 t_gl_entries(rec).organization_code := l_to_org_cd;
1873 IF t_gl_entries(rec).debit_account IS NULL THEN
1874 p_process_status := 'E';
1875 p_process_message := 'Intransit inventory a/c is null';
1876 RETURN;
1877 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
1878 p_process_status := 'E';
1879 p_process_message := 'InterOrg Payables a/c is null';
1880 RETURN;
1881 END IF;
1882 rec := rec + 1;
1883
1884 ELSIF r_get_interorg_params.fob_point = 2 THEN -- Receipts
1885
1886 t_gl_entries(rec).amount := main_rec.tax_amount;
1887 t_gl_entries(rec).debit_account := r_get_interorg_params.intransit_inv_account;
1888 IF r_from_ja_in_hr_org.TRADING = 'Y' THEN -- BUG 6488406
1889 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_23d_account;
1890 ELSE
1891 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.cess_paid_payable_account_id;
1892 END if;
1893 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
1894 t_gl_entries(rec).organization_code := l_from_org_cd;
1895 IF t_gl_entries(rec).debit_account IS NULL THEN
1896 p_process_status := 'E';
1897 p_process_message := 'Intransit Inventory a/c is null';
1898 RETURN;
1899 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
1900 p_process_status := 'E';
1901 p_process_message := 'Cess-paid Payables a/c is null';
1902 RETURN;
1903 END IF;
1904 rec := rec + 1;
1905
1906 END IF;
1907
1908 ELSIF r_get_interorg_params.intransit_type = 1 THEN -- Direct
1909
1910 t_gl_entries(rec).amount := main_rec.tax_amount;
1911 t_gl_entries(rec).debit_account := r_get_interorg_params.interorg_receivables_account;
1912
1913 IF r_from_ja_in_hr_org.TRADING = 'Y' THEN -- BUG 6740006
1914 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_23d_account;
1915 ELSE
1916 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.cess_paid_payable_account_id;
1917 END IF;
1918
1919 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
1920 t_gl_entries(rec).organization_code := l_from_org_cd;
1921
1922
1923
1924
1925 IF t_gl_entries(rec).debit_account IS NULL THEN
1926 p_process_status := 'E';
1927 p_process_message := 'Inventory receiving a/c is null';
1928 RETURN;
1929 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
1930 p_process_status := 'E';
1931 p_process_message := 'Cess-paid Payables a/c is null';
1932 RETURN;
1933 END IF;
1934 rec := rec + 1;
1935
1936 t_gl_entries(rec).amount := main_rec.tax_amount;
1937 t_gl_entries(rec).debit_account := r_rcv_params.receiving_account_id;
1938 t_gl_entries(rec).credit_account := r_get_interorg_params.interorg_payables_account;
1939 t_gl_entries(rec).organization_id := r_mtl_trx_info.to_organization;
1940 t_gl_entries(rec).organization_code := l_to_org_cd;
1941
1942
1943
1944 IF t_gl_entries(rec).debit_account IS NULL THEN
1945 p_process_status := 'E';
1946 p_process_message := 'Inventory receiving a/c is null';
1947 RETURN;
1948 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
1949 p_process_status := 'E';
1950 p_process_message := 'InterOrg Payables a/c is null';
1951 RETURN;
1952 END IF;
1953 rec := rec + 1;
1954
1955 -- start entries for cenvat in direct org
1956
1957 open c_item_class(main_rec.inventory_item_id, r_mtl_trx_info.to_organization);
1958 FETCH c_item_class INTO r_item_class;
1959 close c_item_class;
1960
1961 IF r_to_ja_in_hr_org.TRADING = 'Y' or lv_bonded = 'Y' /*6487803*/
1962 AND r_item_class.item_class NOT IN ( 'FGIN', 'FGEX' ) THEN /*6501436*/
1963
1964
1965 t_gl_entries(rec).amount := main_rec.tax_amount;
1966
1967 -- CHANGES FOR START BUG 6740006
1968
1969 IF r_to_ja_in_hr_org.TRADING = 'Y' THEN
1970 t_gl_entries(rec).debit_account := r_to_ja_in_hr_org.excise_23d_account;
1971 IF r_to_ja_in_hr_org.excise_23d_account IS NULL THEN
1972 p_process_status :='E';
1973 p_process_message :='RG23D Account not defined in Receiving Org';
1974 RETURN;
1975 END IF;
1976 ELSIF r_item_class.item_class IN ('RMIN', 'RMEX', 'CCIN', 'CCEX') then /*6501436..removed FGIN FGEX*/
1977 t_gl_entries(rec).debit_account := r_to_ja_in_hr_org.excise_edu_cess_rm_account;
1978 IF r_to_ja_in_hr_org.excise_edu_cess_rm_account IS NULL THEN
1979 p_process_status := 'E';
1980 p_process_message := 'Cess RM Account not defined in Receiving Org';
1981 RETURN;
1982 END IF;
1983 ELSIF r_item_class.item_class IN ('CGIN', 'CGEX') then
1984 t_gl_entries(rec).debit_account := r_to_ja_in_hr_org.excise_edu_cess_cg_account;
1985 IF r_to_ja_in_hr_org.excise_edu_cess_cg_account IS NULL THEN
1986 p_process_status :='E';
1987 p_process_message :='Cess CG Account not defined in Receiving Org';
1988 RETURN;
1989 END IF;
1990 END if;
1991
1992 -- CHANGES FOR END BUG 6740006
1993
1994
1995 t_gl_entries(rec).credit_account := r_rcv_params.receiving_account_id;
1996 IF t_gl_entries(rec).credit_account IS NULL THEN
1997 p_process_status := 'E';
1998 p_process_message := 'Receiving Inventory Account not defined for receiving org';
1999 RETURN;
2000 END IF;
2001 t_gl_entries(rec).organization_id := r_mtl_trx_info.to_organization;
2002 t_gl_entries(rec).organization_code := l_to_org_cd;
2003
2004 rec := rec + 1;
2005
2006 END IF; /*6487803*/
2007 -- end
2008
2009 END IF;
2010 /*following elsif condition added for shcess by vkaranam for bug #5907436*/
2011 --start 5907436
2012
2013 ELSIF main_rec.tax_type_val = 6 and p_register_type IN ('A','C','PLA','RG23D' ) THEN
2014
2015
2016 IF r_from_ja_in_hr_org.TRADING <> 'Y' THEN -- bug 6740006
2017
2018 t_gl_entries(rec).amount := main_rec.tax_amount;
2019 t_gl_entries(rec).debit_account := r_from_ja_in_hr_org.sh_cess_paid_payable_acct_id;
2020 IF p_register_type = 'A' THEN
2021 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.sh_cess_rm_account;
2022 IF t_gl_entries(rec).credit_account IS NULL THEN
2023 p_process_status := 'E';
2024 p_process_message := 'SH Excise cess RM a/c is null';
2025 RETURN;
2026 END IF;
2027 ELSIF p_register_type = 'PLA' THEN
2028 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.modvat_pla_account_id;
2029 IF t_gl_entries(rec).credit_account IS NULL THEN
2030 p_process_status := 'E';
2031 p_process_message := 'Modvat PLA a/c is null';
2032 RETURN;
2033 END IF;
2034 ELSIF p_register_type = 'C' THEN
2035 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.sh_cess_cg_account_id;
2036 IF t_gl_entries(rec).credit_account IS NULL THEN
2037 p_process_status := 'E';
2038 p_process_message := 'SH Excise cess cg a/c is null';
2039 RETURN;
2040 END IF;
2041 ELSIF p_register_type = 'RG23D' THEN
2042 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_23d_account;
2043 IF t_gl_entries(rec).credit_account IS NULL THEN
2044 p_process_status := 'E';
2045 p_process_message := 'Excise RG23D a/c is null';
2046 RETURN;
2047 END IF;
2048
2049 END IF;
2050 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
2051 t_gl_entries(rec).organization_code := l_from_org_cd;
2052
2053
2054 IF t_gl_entries(rec).debit_account IS NULL THEN
2055 p_process_status := 'E';
2056 p_process_message := 'SH Cess-Paid Payables a/c is null';
2057 RETURN;
2058 END IF;
2059 rec := rec + 1;
2060
2061 END IF ; -- bug 6740006
2062
2063 IF r_get_interorg_params.intransit_type = 2 THEN -- IN TRANSIT
2064
2065 IF r_get_interorg_params.fob_point = 1 THEN -- Shipments
2066 t_gl_entries(rec).amount := main_rec.tax_amount;
2067 t_gl_entries(rec).debit_account := r_get_interorg_params.interorg_receivables_account;--1102
2068 IF r_from_ja_in_hr_org.TRADING = 'Y' THEN -- BUG 6488406
2069 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_23d_account;
2070 ELSE
2071 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.sh_cess_paid_payable_acct_id;
2072 END if;
2073 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
2074 t_gl_entries(rec).organization_code := l_from_org_cd;
2075 IF t_gl_entries(rec).debit_account IS NULL THEN
2076 p_process_status := 'E';
2077 p_process_message := 'InterOrg recevables a/c is null';
2078 RETURN;
2079 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
2080 p_process_status := 'E';
2081 p_process_message := 'SH Cess-paid Payables a/c is null';
2082 RETURN;
2083 END IF;
2084 rec := rec + 1;
2085
2086 t_gl_entries(rec).amount := main_rec.tax_amount;
2087 t_gl_entries(rec).debit_account := r_get_interorg_params.intransit_inv_account;
2088 t_gl_entries(rec).credit_account := r_get_interorg_params.interorg_payables_account;
2089 t_gl_entries(rec).organization_id := r_mtl_trx_info.to_organization;
2090 t_gl_entries(rec).organization_code := l_to_org_cd;
2091 IF t_gl_entries(rec).debit_account IS NULL THEN
2092 p_process_status := 'E';
2093 p_process_message := 'Intransit inventory a/c is null';
2094 RETURN;
2095 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
2096 p_process_status := 'E';
2097 p_process_message := 'InterOrg Payables a/c is null';
2098 RETURN;
2099 END IF;
2100 rec := rec + 1;
2101
2102 ELSIF r_get_interorg_params.fob_point = 2 THEN -- Receipts
2103
2104 t_gl_entries(rec).amount := main_rec.tax_amount;
2105 t_gl_entries(rec).debit_account := r_get_interorg_params.intransit_inv_account;
2106 IF r_from_ja_in_hr_org.TRADING = 'Y' THEN -- BUG 6488406
2107 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_23d_account;
2108 ELSE
2109 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.sh_cess_paid_payable_acct_id;
2110 END if;
2111 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
2112 t_gl_entries(rec).organization_code := l_from_org_cd;
2113 IF t_gl_entries(rec).debit_account IS NULL THEN
2114 p_process_status := 'E';
2115 p_process_message := 'Intransit Inventory a/c is null';
2116 RETURN;
2117 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
2118 p_process_status := 'E';
2119 p_process_message := 'SH Cess-paid Payables a/c is null';
2120 RETURN;
2121 END IF;
2122 rec := rec + 1;
2123
2124 END IF;
2125
2126 ELSIF r_get_interorg_params.intransit_type = 1 THEN -- Direct
2127
2128
2129 t_gl_entries(rec).amount := main_rec.tax_amount;
2130 t_gl_entries(rec).debit_account := r_get_interorg_params.interorg_receivables_account;
2131
2132 IF r_from_ja_in_hr_org.TRADING = 'Y' THEN -- BUG 6740006
2133 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.excise_23d_account;
2134 ELSE
2135 t_gl_entries(rec).credit_account := r_from_ja_in_hr_org.sh_cess_paid_payable_acct_id;
2136 END IF;
2137
2138 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
2139 t_gl_entries(rec).organization_code := l_from_org_cd;
2140
2141
2142
2143 IF t_gl_entries(rec).debit_account IS NULL THEN
2144 p_process_status := 'E';
2145 p_process_message := 'Inventory receiving a/c is null';
2146 RETURN;
2147 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
2148 p_process_status := 'E';
2149 p_process_message := 'SH Cess-paid Payables a/c is null';
2150 RETURN;
2151 END IF;
2152 rec := rec + 1;
2153
2154 t_gl_entries(rec).amount := main_rec.tax_amount;
2155 t_gl_entries(rec).debit_account := r_rcv_params.receiving_account_id;
2156 t_gl_entries(rec).credit_account := r_get_interorg_params.interorg_payables_account;
2157 t_gl_entries(rec).organization_id := r_mtl_trx_info.to_organization;
2158 t_gl_entries(rec).organization_code := l_to_org_cd;
2159 IF t_gl_entries(rec).debit_account IS NULL THEN
2160 p_process_status := 'E';
2161 p_process_message := 'Inventory receiving a/c is null';
2162 RETURN;
2163 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
2164 p_process_status := 'E';
2165 p_process_message := 'InterOrg Payables a/c is null';
2166 RETURN;
2167 END IF;
2168 rec := rec + 1;
2169
2170 open c_item_class(main_rec.inventory_item_id, r_mtl_trx_info.to_organization);
2171 FETCH c_item_class INTO r_item_class;
2172 close c_item_class;
2173
2174 IF r_to_ja_in_hr_org.TRADING = 'Y' or lv_bonded = 'Y' /*6487803*/
2175 AND r_item_class.item_class NOT IN ('FGIN','FGEX') THEN /*6501436*/
2176 -- start entries for cenvat in direct org
2177 t_gl_entries(rec).amount := main_rec.tax_amount;
2178
2179
2180 -- CHANGES FOR START BUG 6740006
2181
2182
2183 IF r_to_ja_in_hr_org.TRADING = 'Y' THEN
2184 t_gl_entries(rec).debit_account := r_to_ja_in_hr_org.excise_23d_account;
2185 IF r_to_ja_in_hr_org.excise_23d_account IS NULL THEN
2186 p_process_status :='E';
2187 p_process_message :='RG23D Account not defined in Receiving Org';
2188 RETURN;
2189 END IF;
2190
2191 ELSIF r_item_class.item_class IN ('RMIN', 'RMEX', 'CCIN', 'CCEX') then /*6501436.removed FGIN FGEX*/
2192 t_gl_entries(rec).debit_account := r_to_ja_in_hr_org.sh_cess_rm_account;
2193 IF r_to_ja_in_hr_org.sh_cess_rm_account IS NULL THEN
2194 p_process_status := 'E';
2195 p_process_message := 'SH Cess RM Account not defined in Receiving Org';
2196 RETURN;
2197 END IF;
2198 ELSIF r_item_class.item_class IN ('CGIN', 'CGEX') then
2199 t_gl_entries(rec).debit_account := r_to_ja_in_hr_org.sh_cess_cg_account_id;
2200 IF r_to_ja_in_hr_org.sh_cess_cg_account_id IS NULL THEN
2201 p_process_status :='E';
2202 p_process_message :='SH Cess CG Account not defined in Receiving Org';
2203 RETURN;
2204 END IF;
2205 end if;
2206
2207 -- CHANGES FOR END BUG 6740006
2208
2209
2210 t_gl_entries(rec).credit_account := r_rcv_params.receiving_account_id;
2211 IF t_gl_entries(rec).credit_account IS NULL THEN
2212 p_process_status := 'E';
2213 p_process_message := 'Receiving Inventory Account not defined for receiving org';
2214 RETURN;
2215 END IF;
2216 t_gl_entries(rec).organization_id := r_mtl_trx_info.to_organization;
2217 t_gl_entries(rec).organization_code := l_to_org_cd;
2218
2219
2220 rec := rec + 1;
2221
2222 END IF;/*6487803*/
2223 -- end
2224
2225 END IF;
2226 --END 5907436
2227
2228 ELSIF main_rec.tax_type_val = 4 and p_register_type IN ('SVAT','RVAT') THEN /* value added tax*/
2229
2230 IF p_register_type='SVAT' and main_rec.tax_type <> 'VAT REVERSAL' then
2231 t_gl_entries(rec).amount := main_rec.tax_amount;
2232 stmt_name := 'Calling:4 jai_cmn_rgm_recording_pkg.get_account()';
2233 t_gl_entries(rec).debit_account := jai_cmn_rgm_recording_pkg.get_account(
2234 p_regime_id => l_regime_id,
2235 p_organization_type => jai_constants.orgn_type_io,
2236 p_organization_id => r_mtl_trx_info.from_organization,
2237 p_location_id => ln_from_loc_id,
2238 p_tax_type => main_rec.tax_type,
2239 p_account_name => jai_constants.liability_interim
2240 );
2241 stmt_name := 'Calling:3 jai_cmn_rgm_recording_pkg.get_account()';
2242 t_gl_entries(rec).credit_account := jai_cmn_rgm_recording_pkg.get_account(
2243 p_regime_id => l_regime_id,
2244 p_organization_type => jai_constants.orgn_type_io,
2245 p_organization_id => r_mtl_trx_info.from_organization,
2246 p_location_id => ln_from_loc_id,
2247 p_tax_type => main_rec.tax_type,
2248 p_account_name => jai_constants.liability
2249 ) ;
2250 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
2251 t_gl_entries(rec).organization_code := l_from_org_cd;
2252
2253 IF t_gl_entries(rec).debit_account IS NULL THEN
2254 p_process_status := 'E';
2255 p_process_message := 'Interim Liability a/c is null for '||main_rec.tax_type;
2256 RETURN;
2257 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
2258 p_process_status := 'E';
2259 p_process_message := 'Liability a/c is null for '||main_rec.tax_type;
2260 RETURN;
2261 END IF;
2262 rec := rec + 1;
2263
2264 -- ELSIF p_register_type='SVAT' and main_rec.tax_type = 'VAT REVERSAL' then
2265 /*
2266 debit expense accnt
2267 credit VAT recovery Account
2268 */
2269 -- t_gl_entries(rec).amount := main_rec.tax_amount;
2270 -- t_gl_entries(rec).debit_account := jai_cmn_rgm_recording_pkg.get_account(
2271 -- p_regime_id => l_regime_id,
2272 -- p_organization_type => jai_constants.orgn_type_io,
2273 -- p_organization_id => r_mtl_trx_info.from_organization,
2274 -- p_location_id => ln_from_loc_id,
2275 -- p_tax_type => main_rec.tax_type,
2276 -- p_account_name => 'EXPENSE'
2277 -- );
2278
2279 -- t_gl_entries(rec).credit_account := jai_cmn_rgm_recording_pkg.get_account(
2280 -- p_regime_id => l_regime_id,
2281 -- p_organization_type => jai_constants.orgn_type_io,
2282 -- p_organization_id => r_mtl_trx_info.from_organization,
2283 -- p_location_id => ln_from_loc_id,
2284 -- p_tax_type => main_rec.tax_type,
2285 -- p_account_name => 'RECOVERY'
2286 -- );
2287 -- IF t_gl_entries(rec).credit_account IS NULL THEN
2288 -- p_process_status := 'E';
2289 -- p_process_message := 'Recovery Account not setup in receiving Org for ' || main_rec.tax_type ;
2290 -- RETURN;
2291 -- END IF;
2292 -- IF t_gl_entries(rec).debit_account IS NULL THEN
2293 -- p_process_status := 'E';
2294 -- p_process_message := 'Expense Account not setup in receiving Org for ' || main_rec.tax_type ;
2295 -- RETURN;
2296 -- END IF;
2297 -- t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
2298 -- t_gl_entries(rec).organization_code := l_from_org_cd;
2299
2300 -- rec := rec + 1;
2301 END IF;
2302
2303 IF r_get_interorg_params.intransit_type = 2 and main_Rec.tax_type <> 'VAT REVERSAL' THEN /* Intransit */
2304
2305 IF r_get_interorg_params.fob_point = 1 THEN -- Shippment
2306 t_gl_entries(rec).amount := main_rec.tax_amount;
2307 t_gl_entries(rec).debit_account := r_get_interorg_params.interorg_receivables_account;
2308 stmt_name := 'Calling:2 jai_cmn_rgm_recording_pkg.get_account()';
2309 t_gl_entries(rec).credit_account := jai_cmn_rgm_recording_pkg.get_account(
2310 p_regime_id => l_regime_id,
2311 p_organization_type => jai_constants.orgn_type_io,
2312 p_organization_id => r_mtl_trx_info.from_organization,
2313 p_location_id => ln_from_loc_id,
2314 p_tax_type => main_rec.tax_type,
2315 p_account_name => jai_constants.liability_interim
2316 );
2317 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
2318 t_gl_entries(rec).organization_code := l_from_org_cd;
2319 IF t_gl_entries(rec).debit_account IS NULL THEN
2320 p_process_status := 'E';
2321 p_process_message := 'InterOrg receivable a/c is null';
2322 RETURN;
2323 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
2324 p_process_status := 'E';
2325 p_process_message := 'Interim Liablility a/c is null for '||main_rec.tax_type;
2326 RETURN;
2327 END IF;
2328 rec := rec + 1;
2329
2330 t_gl_entries(rec).amount := main_rec.tax_amount;
2331 t_gl_entries(rec).debit_account := r_get_interorg_params.intransit_inv_account;
2332 t_gl_entries(rec).credit_account := r_get_interorg_params.interorg_payables_account;
2333 t_gl_entries(rec).organization_id := r_mtl_trx_info.to_organization;
2334 t_gl_entries(rec).organization_code := l_to_org_cd;
2335 IF t_gl_entries(rec).debit_account IS NULL THEN
2336 p_process_status := 'E';
2337 p_process_message := 'Intransit Inventory a/c is null';
2338 RETURN;
2339 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
2340 p_process_status := 'E';
2341 p_process_message := 'InterOrg Payables a/c is null';
2342 RETURN;
2343 END IF;
2344 rec := rec + 1;
2345
2346 ELSIF r_get_interorg_params.fob_point = 2 THEN --Receipt
2347 t_gl_entries(rec).amount := main_rec.tax_amount;
2348 t_gl_entries(rec).debit_account := r_get_interorg_params.intransit_inv_account;
2349 stmt_name := 'Calling:1 jai_cmn_rgm_recording_pkg.get_account()';
2350 t_gl_entries(rec).credit_account := jai_cmn_rgm_recording_pkg.get_account(
2351 p_regime_id => l_regime_id,
2352 p_organization_type => jai_constants.orgn_type_io,
2353 p_organization_id => r_mtl_trx_info.from_organization,
2354 p_location_id => ln_from_loc_id,
2355 p_tax_type => main_rec.tax_type,
2356 p_account_name => jai_constants.liability_interim
2357 );
2358 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
2359 t_gl_entries(rec).organization_code := l_from_org_cd;
2360 IF t_gl_entries(rec).debit_account IS NULL THEN
2361 p_process_status := 'E';
2362 p_process_message := 'Intransit Inventory a/c is null for '||main_rec.tax_type;
2363 RETURN;
2364 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
2365 p_process_status := 'E';
2366 p_process_message := 'Interim Liablility a/c is null for'||main_rec.tax_type;
2367 RETURN;
2368 END IF;
2369 rec := rec + 1;
2370
2371 END IF;
2372
2373 ELSIF r_get_interorg_params.intransit_type = 1
2374 and p_register_type = 'RVAT' and main_rec.tax_type <> 'VAT RECOVERY' /* Direct */ THEN
2375 t_gl_entries(rec).amount := main_rec.tax_amount;
2376 t_gl_entries(rec).debit_account := r_get_interorg_params.interorg_receivables_account;
2377 stmt_name := 'Calling jai_cmn_rgm_recording_pkg.get_account()';
2378 t_gl_entries(rec).credit_account := jai_cmn_rgm_recording_pkg.get_account(
2379 p_regime_id => l_regime_id,
2380 p_organization_type => jai_constants.orgn_type_io,
2381 p_organization_id => r_mtl_trx_info.from_organization,
2382 p_location_id => ln_from_loc_id,
2383 p_tax_type => main_rec.tax_type,
2384 p_account_name => jai_constants.liability_interim
2385 );
2386 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
2387 t_gl_entries(rec).organization_code := l_from_org_cd;
2388 IF t_gl_entries(rec).debit_account IS NULL THEN
2389 p_process_status := 'E';
2390 p_process_message := 'InterOrg Receivable a/c is null';
2391 RETURN;
2392 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
2393 p_process_status := 'E';
2394 p_process_message := 'Interim Liablility a/c is null for'||main_rec.tax_type;
2395 RETURN;
2396 END IF;
2397 rec := rec + 1;
2398
2399 t_gl_entries(rec).amount := main_rec.tax_amount;
2400 t_gl_entries(rec).debit_account := r_rcv_params.receiving_account_id;
2401 t_gl_entries(rec).credit_account := r_get_interorg_params.interorg_payables_account;
2402 t_gl_entries(rec).organization_id := r_mtl_trx_info.to_organization;
2403 t_gl_entries(rec).organization_code := l_to_org_cd;
2404 IF t_gl_entries(rec).debit_account IS NULL THEN
2405 p_process_status := 'E';
2406 p_process_message := 'Inventory Receiving a/c is Null';
2407 RETURN;
2408 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
2409 p_process_status := 'E';
2410 p_process_message := 'InterOrg Payables a/c is null';
2411 RETURN;
2412 END IF;
2413 rec := rec + 1;
2414
2415 -- starts here code for VAT
2416 t_gl_entries(rec).amount := main_rec.tax_amount;
2417 t_gl_entries(rec).debit_account := jai_cmn_rgm_recording_pkg.get_account(
2418 p_regime_id => l_regime_id,
2419 p_organization_type => jai_constants.orgn_type_io,
2420 p_organization_id => r_mtl_trx_info.to_organization,
2421 p_location_id => r_mtl_trx_info.location_id,
2422 p_tax_type => main_rec.tax_type,
2423 p_account_name => jai_constants.recovery_interim
2424 );
2425 IF t_gl_entries(rec).debit_account IS NULL THEN
2426 p_process_status := 'E';
2427 p_process_message := 'Interim Recovery Account is not defined for ' || main_rec.tax_type;
2428 RETURN;
2429 END IF;
2430 t_gl_entries(rec).credit_account := r_rcv_params.receiving_account_id;
2431 IF t_gl_entries(rec).credit_account IS NULL THEN
2432 p_process_status := 'E';
2433 p_process_message := 'Receiving Invetory is not defined ';
2434 RETURN;
2435 END IF;
2436 t_gl_entries(rec).organization_id := r_mtl_trx_info.to_organization;
2437 t_gl_entries(rec).organization_code := l_to_org_cd;
2438 rec := rec + 1;
2439
2440
2441 t_gl_entries(rec).amount := main_rec.tax_amount;
2442 t_gl_entries(rec).debit_account := jai_cmn_rgm_recording_pkg.get_account(
2443 p_regime_id => l_regime_id,
2444 p_organization_type => jai_constants.orgn_type_io,
2445 p_organization_id => r_mtl_trx_info.to_organization,
2446 p_location_id => r_mtl_trx_info.location_id,
2447 p_tax_type => main_rec.tax_type,
2448 p_account_name => jai_constants.recovery
2449 );
2450
2451 IF t_gl_entries(rec).debit_account IS NULL THEN
2452 p_process_status := 'E';
2453 p_process_message := 'Recovery Account not defined for ' || main_rec.tax_type;
2454 RETURN;
2455 END IF;
2456 t_gl_entries(rec).credit_account := jai_cmn_rgm_recording_pkg.get_account(
2457 p_regime_id => l_regime_id,
2458 p_organization_type => jai_constants.orgn_type_io,
2459 p_organization_id => r_mtl_trx_info.to_organization,
2460 p_location_id => r_mtl_trx_info.location_id,
2461 p_tax_type => main_rec.tax_type,
2462 p_account_name => jai_constants.recovery_interim
2463 );
2464 IF t_gl_entries(rec).credit_account IS NULL THEN
2465 p_process_status := 'E';
2466 p_process_message := 'Interim Recovery Account not defined for ' || main_rec.tax_type;
2467 RETURN;
2468 END IF;
2469 t_gl_entries(rec).organization_id := r_mtl_trx_info.to_organization;
2470 t_gl_entries(rec).organization_code := l_to_org_cd;
2471 rec := rec + 1;
2472
2473 -- ends here
2474 END IF;
2475
2476 ELSIF main_rec.tax_type_val =0 and p_register_type is null then
2477 /* other tax types */
2478 IF r_get_interorg_params.intransit_type = 2 THEN /* Intransit */
2479 IF main_rec.tax_type <> 'VAT REVERSAL' THEN
2480 IF r_get_interorg_params.fob_point = 1 THEN -- Shippments
2481
2482 t_gl_entries(rec).amount := main_rec.tax_amount;
2483 t_gl_entries(rec).debit_account := r_get_interorg_params.interorg_receivables_account;
2484 t_gl_entries(rec).credit_account := main_rec.tax_account_id;
2485 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
2486 t_gl_entries(rec).organization_code := l_from_org_cd;
2487 IF t_gl_entries(rec).debit_account IS NULL THEN
2488 p_process_status := 'E';
2489 p_process_message := 'InterOrg Receivables a/c is Null';
2490 RETURN;
2491 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
2492 p_process_status := 'E';
2493 p_process_message := 'Other Taxes account is null';
2494 RETURN;
2495 END IF;
2496 rec := rec + 1;
2497
2498 t_gl_entries(rec).amount := main_rec.tax_amount;
2499 t_gl_entries(rec).debit_account := r_get_interorg_params.intransit_inv_account;
2500 t_gl_entries(rec).credit_account := r_get_interorg_params.interorg_payables_account;
2501 t_gl_entries(rec).organization_id := r_mtl_trx_info.to_organization;
2502 t_gl_entries(rec).organization_code := l_to_org_cd;
2503 IF t_gl_entries(rec).debit_account IS NULL THEN
2504 p_process_status := 'E';
2505 p_process_message := 'Intransit Inventory a/c is Null';
2506 RETURN;
2507 ELSIF t_gl_entries(rec).credit_account IS NULL THEN
2508 p_process_status := 'E';
2509 p_process_message := 'InterOrg Payable a/c is null';
2510 RETURN;
2511 END IF;
2512 rec := rec + 1;
2513 ELSIF r_get_interorg_params.fob_point = 2 THEN -- Receipts
2514
2515 IF r_get_interorg_params.intransit_inv_account IS NULL THEN
2516 p_process_status := 'E';
2517 p_process_message := 'Intransit Inventory a/c is Null';
2518 RETURN;
2519 ELSIF main_rec.tax_account_id IS NULL THEN
2520 p_process_status := 'E';
2521 p_process_message := 'Other Taxes a/c is null';
2522 RETURN;
2523 END IF;
2524 t_gl_entries(rec).amount := main_rec.tax_amount;
2525 t_gl_entries(rec).debit_account := r_get_interorg_params.intransit_inv_account;
2526 t_gl_entries(rec).credit_account := main_rec.tax_account_id;
2527 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
2528 t_gl_entries(rec).organization_code := l_from_org_cd;
2529 rec := rec + 1;
2530 END IF;
2531 -- do for vat reversal here
2532 ELSIF main_rec.tax_type = 'VAT REVERSAL' then
2533 /*
2534 debit expense accnt
2535 credit VAT recovery Account
2536 */
2537 t_gl_entries(rec).amount := main_rec.tax_amount;
2538 t_gl_entries(rec).debit_account := jai_cmn_rgm_recording_pkg.get_account(
2539 p_regime_id => l_regime_id,
2540 p_organization_type => jai_constants.orgn_type_io,
2541 p_organization_id => r_mtl_trx_info.from_organization,
2542 p_location_id => ln_from_loc_id,
2543 p_tax_type => main_rec.tax_type,
2544 p_account_name => 'EXPENSE'
2545 );
2546
2547 t_gl_entries(rec).credit_account := jai_cmn_rgm_recording_pkg.get_account(
2548 p_regime_id => l_regime_id,
2549 p_organization_type => jai_constants.orgn_type_io,
2550 p_organization_id => r_mtl_trx_info.from_organization,
2551 p_location_id => ln_from_loc_id,
2552 p_tax_type => main_rec.tax_type,
2553 p_account_name => 'RECOVERY'
2554 );
2555 IF t_gl_entries(rec).credit_account IS NULL THEN
2556 p_process_status := 'E';
2557 p_process_message := 'Recovery Account not setup in receiving Org for ' || main_rec.tax_type ;
2558 RETURN;
2559 END IF;
2560 IF t_gl_entries(rec).debit_account IS NULL THEN
2561 p_process_status := 'E';
2562 p_process_message := 'Expense Account not setup in receiving Org for ' || main_rec.tax_type ;
2563 RETURN;
2564 END IF;
2565 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
2566 t_gl_entries(rec).organization_code := l_from_org_cd;
2567
2568 rec := rec + 1;
2569 -- ends here for vat reversal
2570 END IF;
2571 ELSIF r_get_interorg_params.intransit_type = 1 and main_rec.tax_type <> 'VAT REVERSAL' /* Direct */ THEN
2572
2573 IF r_get_interorg_params.interorg_receivables_account IS NULL THEN
2574 p_process_status := 'E';
2575 p_process_message := 'Inter-Organization Recevable a/c is Null';
2576 RETURN;
2577 ELSIF main_rec.tax_account_id IS NULL THEN
2578 p_process_status := 'E';
2579 p_process_message := 'Other Taxes a/c is null';
2580 RETURN;
2581 END IF;
2582 t_gl_entries(rec).amount := main_rec.tax_amount;
2583 t_gl_entries(rec).debit_account := r_get_interorg_params.interorg_receivables_account;
2584 t_gl_entries(rec).credit_account := main_rec.tax_account_id;
2585 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
2586 t_gl_entries(rec).organization_code := l_from_org_cd;
2587 rec := rec + 1;
2588
2589 IF r_get_interorg_params.interorg_payables_account IS NULL THEN
2590 p_process_status := 'E';
2591 p_process_message := 'Inter-org Payables a/c is null';
2592 RETURN;
2593 ELSIF r_rcv_params.receiving_account_id IS NULL THEN
2594 p_process_status := 'E';
2595 p_process_message := 'Inventory Receiving a/c is null';
2596 RETURN;
2597 END IF;
2598 t_gl_entries(rec).amount := main_rec.tax_amount;
2599 t_gl_entries(rec).debit_account := r_rcv_params.receiving_account_id;
2600 t_gl_entries(rec).credit_account := r_get_interorg_params.interorg_payables_account;
2601 t_gl_entries(rec).organization_id := r_mtl_trx_info.to_organization;
2602 t_gl_entries(rec).organization_code := l_to_org_cd;
2603 rec := rec + 1;
2604 -- for vat reversal in direct org transfer
2605 ELSIF main_rec.tax_type = 'VAT REVERSAL' then
2606 /*
2607 debit expense accnt
2608 credit VAT recovery Account
2609 */
2610 t_gl_entries(rec).amount := main_rec.tax_amount;
2611 t_gl_entries(rec).debit_account := jai_cmn_rgm_recording_pkg.get_account(
2612 p_regime_id => l_regime_id,
2613 p_organization_type => jai_constants.orgn_type_io,
2614 p_organization_id => r_mtl_trx_info.from_organization,
2615 p_location_id => ln_from_loc_id,
2616 p_tax_type => main_rec.tax_type,
2617 p_account_name => 'EXPENSE'
2618 );
2619
2620 t_gl_entries(rec).credit_account := jai_cmn_rgm_recording_pkg.get_account(
2621 p_regime_id => l_regime_id,
2622 p_organization_type => jai_constants.orgn_type_io,
2623 p_organization_id => r_mtl_trx_info.from_organization,
2624 p_location_id => ln_from_loc_id,
2625 p_tax_type => main_rec.tax_type,
2626 p_account_name => 'RECOVERY'
2627 );
2628 IF t_gl_entries(rec).credit_account IS NULL THEN
2629 p_process_status := 'E';
2630 p_process_message := 'Recovery Account not setup in receiving Org for ' || main_rec.tax_type ;
2631 RETURN;
2632 END IF;
2633 IF t_gl_entries(rec).debit_account IS NULL THEN
2634 p_process_status := 'E';
2635 p_process_message := 'Expense Account not setup in receiving Org for ' || main_rec.tax_type ;
2636 RETURN;
2637 END IF;
2638 t_gl_entries(rec).organization_id := r_mtl_trx_info.from_organization;
2639 t_gl_entries(rec).organization_code := l_from_org_cd;
2640
2641 rec := rec + 1;
2642 -- ends here for vat reversal
2643 END IF;
2644
2645 END IF;
2646
2647 END LOOP;
2648 IF r_get_interorg_params.intransit_type = 1 and p_register_type is NULL THEN
2649 do_costing(p_transaction_temp_id,
2650 lv_process_flag,
2651 lv_process_message);
2652 END IF;
2653
2654
2655 stmt_name := 'Calling gl_entry()';
2656 gl_entry(t_gl_entries,
2657 p_set_of_books_id,
2658 p_je_source_name,
2659 p_je_category_name,
2660 p_currency_code,
2661 p_transaction_temp_id,
2662 p_process_status,
2663 p_process_message);
2664
2665 EXCEPTION
2666 WHEN OTHERS THEN
2667 p_process_status := 'E';
2668 p_process_message := 'Encountered an error when doing GL Entries '||stmt_name||' :'||sqlcode||': '||sqlerrm;
2669 ROLLBACK TO gl_acctg;
2670 END;
2671
2672
2673 procedure do_costing
2674 (
2675 transaction_id IN NUMBER,
2676 process_flag OUT NOCOPY varchar2,
2677 process_msg OUT NOCOPY varchar2
2678 )
2679 is
2680 CURSOR c_mtl_types(cp_transaction_type_name IN VARCHAR2) IS
2681 SELECT transaction_type_id, transaction_source_type_id, transaction_action_id
2682 FROM mtl_transaction_types
2683 WHERE transaction_type_name = cp_transaction_type_name;
2684
2685 CURSOR c_costing_group ( cp_organization_id IN NUMBER) IS
2686 SELECT mp.default_cost_group_id
2687 FROM mtl_parameters mp
2688 WHERE mp.organization_id = cp_organization_id
2689 AND mp.primary_cost_method = 2; --Average
2690
2691 CURSOR c_rcv_params( cp_organization_id IN NUMBER) IS
2692 SELECT * from rcv_parameters
2693 WHERE organization_id = cp_organization_id;
2694
2695 CURSOR c_mtl_params(cp_organization_id IN NUMBER) IS
2696 SELECT *
2697 FROM mtl_parameters
2698 WHERE organization_id = cp_organization_id;
2699
2700 CURSOR c_jai_mtl_Trxs ( cp_Trx_temp_id IN NUMBER ) is
2701 SELECT * from jai_mtl_Trxs
2702 WHERE transaction_Temp_id = cp_Trx_temp_id;
2703
2704
2705 CURSOR c_proc_exists(cp_object_name user_procedures.object_name%type ,
2706 cp_procedure_name user_procedures.procedure_name%type) IS
2707
2708 SELECT 1
2709 FROM user_procedures
2710 WHERE object_name = cp_object_name
2711 AND procedure_name = cp_procedure_name ;
2712
2713 /*rchandan for bug#6487489..start*/
2714
2715 CURSOR c_ppv_acct(cp_from_organization_id NUMBER,cp_to_organization_id NUMBER)
2716 IS
2717 SELECT INTERORG_PRICE_VAR_ACCOUNT
2718 FROM mtl_interorg_parameters
2719 WHERE from_organization_id = cp_from_organization_id
2720 AND to_organization_id = cp_to_organization_id ;
2721
2722 CURSOR cur_get_bonded(cp_organization_id NUMBER,
2723 cp_sub_inventory VARCHAR2)
2724 IS
2725 SELECT bonded
2726 FROM jai_inv_subinv_dtls
2727 WHERE organization_id = cp_organization_id
2728 AND sub_inventory_name = cp_sub_inventory;
2729
2730 ln_cost_amount NUMBER;
2731 lv_bonded jai_inv_subinv_dtls.bonded%TYPE;
2732 ln_ppv_acct_id NUMBER;/*6487489*/
2733
2734
2735 /*rchandan for bug#6487489..end*/
2736
2737 p_trx_temp_id NUMBER:= transaction_id ;--11015556;
2738
2739 ln_txn_header_id NUMBER;
2740 r_mtl_types c_mtl_types%ROWTYPE;
2741 r_Rcv_params c_rcv_params%ROWTYPE;
2742 r_mtl_params c_mtl_params%Rowtype;
2743 ln_costing_grp_id NUMBER;
2744 lv_trx_type_name VARCHAR2(30);
2745 r_mtl_Trxs c_jai_mtl_Trxs%ROWTYPE;
2746
2747 ln_Excise_amt NUMBER;
2748 ln_non_modvat_amt NUMBER;
2749 ln_oth_modvat_amt NUMBER;
2750 lv_process_msg VARCHAR2(2000);
2751 lv_process_status VARCHAR2(20);
2752 lv_object_name user_procedures.object_name%type ;
2753 lv_procedure_name user_procedures.procedure_name%type ;
2754 ln_exists NUMBER := 0 ;
2755 lv_sqlstmt VARCHAR2(2000) ;
2756 ln_retval NUMBER;
2757 lv_return_status VARCHAR2(10);
2758 ln_msg_cnt NUMBER;
2759 lv_msg_data VARCHAR2(2000);
2760 ln_trans_count NUMBER;
2761
2762
2763 cursor cur_item_class /*6501436*/
2764 IS
2765 SELECT jiis.item_class
2766 FROM jai_mtl_trxs jmt,
2767 JAI_INV_ITM_SETUPS jiis
2768 WHERE jmt.inventory_item_id = jiis.inventory_item_id
2769 AND jmt.transaction_temp_id = p_trx_temp_id;
2770
2771 lv_item_class jai_inv_itm_setups.item_class%TYPE;/*6501436*/
2772 BEGIN
2773
2774 lv_trx_type_name := 'Average cost update' ;--'Direct Org Transfer';
2775
2776 OPEN c_jai_mtl_Trxs(p_trx_temp_id);
2777 FETCH c_jai_mtl_Trxs INTO r_mtl_Trxs;
2778 CLOSE c_jai_mtl_Trxs;
2779
2780 Open c_mtl_types(lv_trx_type_name);
2781 FETCH c_mtl_types INTO r_mtl_types;
2782 CLOSE c_mtl_types;
2783
2784 OPEN c_costing_group(r_mtl_Trxs.to_organization);
2785 FETCH c_costing_group INTO ln_costing_grp_id;
2786 CLOSE c_costing_group;
2787
2788 OPEN c_rcv_params(r_mtl_Trxs.to_organization);
2789 FETCH c_rcv_params INTO r_Rcv_params;
2790 CLOSE c_rcv_params;
2791
2792 OPEN c_mtl_params(r_mtl_Trxs.to_organization);
2793 FETCH c_mtl_params INTO r_mtl_params;
2794 CLOSE c_mtl_params;
2795
2796
2797 /*
2798 || This procedure would get the cost amount
2799 || Need to pass the transaction_temp_id as the param for p_trx_temp_id
2800 || ln_non_modvat_amt variable would have the cost.
2801 */
2802
2803 get_cost_amt
2804 ( p_source_line_id => p_trx_temp_id ,
2805 p_organization_id => r_mtl_Trxs.to_organization,
2806 p_location_id => r_mtl_Trxs.location_id,
2807 p_item_id => r_mtl_Trxs.inventory_item_id,
2808 p_excise_amount => ln_Excise_amt,
2809 p_non_modvat_amount => ln_non_modvat_amt,
2810 p_other_modvat_amount => ln_oth_modvat_amt,
2811 p_process_message => lv_process_msg,
2812 p_process_status => lv_process_status );
2813
2814 /*
2815 || avg costing if r_mtl_params.primary cost thod = 2
2816 */
2817
2818 If r_mtl_params.primary_cost_method=2 then
2819 avg_cost_entry( p_txn_header_id => ln_txn_header_id ,
2820 p_item_id => r_mtl_Trxs.inventory_item_id,
2821 p_organization_id => r_mtl_Trxs.to_organization,
2822 p_uom_code => r_mtl_Trxs.transaction_uom,
2823 p_transaction_date => r_mtl_Trxs.transaction_Date,
2824 p_transaction_type_id => r_mtl_types.transaction_type_id,
2825 p_transaction_source_type_id => r_mtl_types.transaction_source_type_id ,
2826 p_transaction_id => p_trx_temp_id ,
2827 p_cost_group_id => ln_costing_grp_id ,
2828 p_receiving_account_id => r_Rcv_params.receiving_account_id,
2829 p_absorption_account_id => r_Rcv_params.receiving_account_id,
2830 p_value_change => ln_non_modvat_amt,
2831 p_transaction_action_id => r_mtl_types.transaction_action_id,
2832 p_from_organization_id => r_mtl_trxs.from_organization,
2833 p_from_subinventory => r_mtl_trxs.from_subinventory,
2834 p_to_subinventory => r_mtl_trxs.to_subinventory,
2835 p_txn_quantity => 0
2836 );
2837
2838 lv_object_name := 'INV_TXN_MANAGER_PUB' ;
2839 lv_procedure_name := 'PROCESS_TRANSACTIONS' ;
2840
2841 OPEN c_proc_exists(lv_object_name, lv_procedure_name) ;
2842 FETCH c_proc_exists INTO ln_exists ;
2843 CLOSE c_proc_exists ;
2844
2845 IF ln_exists = 1 THEN
2846 lv_sqlstmt := 'BEGIN
2847 :ln_retval := inv_txn_manager_pub.process_transactions (
2848 p_api_version => 1,
2849 p_init_msg_list => :fnd_api_g_false ,
2850 p_commit => :fnd_api_g_false1 ,
2851 p_validation_level => :fnd_api_g_valid_level_full ,
2852 x_return_status => :lv_return_status,
2853 x_msg_count => :ln_msg_cnt,
2854 x_msg_data => :lv_msg_data,
2855 x_trans_count => :ln_trans_count,
2856 p_table => 1,
2857 p_header_id => :ln_txn_header_id
2858 );
2859 END; ';
2860 EXECUTE IMMEDIATE lv_sqlstmt USING OUT ln_retval ,
2861 IN fnd_api.g_false ,
2862 IN fnd_api.g_false ,
2863 IN fnd_api.g_valid_level_full ,
2864 OUT lv_return_status ,
2865 OUT ln_msg_cnt ,
2866 OUT lv_msg_data ,
2867 OUT ln_trans_count ,
2868 IN ln_txn_header_id ;
2869
2870
2871 END IF;
2872
2873
2874 /*
2875 || std costing if r_mtl_params.primary cost thod = 1
2876 */
2877
2878 elsif r_mtl_params.primary_cost_method=1 then
2879
2880 OPEN cur_item_class;/*6501436*/
2881 FETCH cur_item_class INTO lv_item_class;
2882 CLOSE cur_item_class;
2883
2884 /*6487489 start*/
2885
2886 OPEN c_ppv_acct(r_mtl_Trxs.from_organization,r_mtl_Trxs.to_organization);
2887 FETCH c_ppv_acct INTO ln_ppv_acct_id;
2888 CLOSE c_ppv_acct;
2889
2890 OPEN cur_get_bonded(r_mtl_Trxs.to_organization,r_mtl_Trxs.to_subinventory);
2891 FETCH cur_get_bonded INTO lv_bonded;
2892 CLOSE cur_get_bonded;
2893
2894 IF lv_bonded = 'N' or lv_item_class IN ('FGIN','FGEX') THEN /*6501436..Included item check*/
2895
2896 ln_cost_amount := nvl(ln_Excise_amt,0) + nvl(ln_non_modvat_amt,0) ; /*it should include Excisable recoverable taxes and Non recoverable taxes*/
2897
2898 ELSE
2899
2900 ln_cost_amount := nvl(ln_non_modvat_amt,0);
2901
2902 END IF;
2903
2904 /*6487489 end*/
2905
2906
2907 IF ln_cost_amount <> 0 THEN /*6487489*/
2908
2909 std_cost_entry(
2910 p_transaction_id => p_trx_temp_id,
2911 p_reference_account => ln_ppv_acct_id,/*6487489..replaced material account*/
2912 p_inventory_item_id => r_mtl_Trxs.inventory_item_id,
2913 p_organization_id => r_mtl_Trxs.to_organization,
2914 p_transaction_source_id => p_trx_temp_id,
2915 p_transaction_source_type_id => r_mtl_types.transaction_source_type_id,
2916 p_primary_quantity => r_mtl_Trxs.quantity,
2917 p_transaction_date => r_mtl_Trxs.transaction_Date,
2918 p_cost_amount => ln_cost_amount,
2919 p_process_flag => lv_process_status ,
2920 p_process_msg => lv_process_msg);
2921
2922 end if;
2923
2924 end if;
2925
2926
2927 END do_costing;
2928
2929 PROCEDURE avg_cost_entry(
2930 p_txn_header_id IN OUT NOCOPY NUMBER,
2931 p_item_id IN NUMBER,
2932 p_organization_id IN NUMBER,
2933 p_uom_code IN VARCHAR2,
2934 p_transaction_date IN DATE,
2935 p_transaction_type_id IN NUMBER,
2936 p_transaction_source_type_id IN NUMBER,
2937 p_transaction_id IN NUMBER,
2938 p_cost_group_id IN NUMBER,
2939 p_receiving_account_id IN NUMBER,
2940 p_absorption_account_id IN NUMBER,
2941 p_value_change IN NUMBER,
2942 p_transaction_action_id IN NUMBER,
2943 p_from_organization_id IN NUMBER,
2944 p_from_subinventory IN VARCHAR2,
2945 p_to_subinventory IN VARCHAR2,
2946 p_txn_quantity IN NUMBER
2947 ) IS
2948
2949 ln_txn_interface_id NUMBER;
2950
2951 -- Default Values
2952 lv_transaction_source_name VARCHAR2(30) := 'Avg Cost Update Conversion';
2953 lv_source_code VARCHAR2(50) := 'IL-Value Change - Direct Org';
2954 ln_src_line_id NUMBER := -1;
2955 ln_src_header_id NUMBER := -1;
2956 ln_process_flag NUMBER := 1;
2957 ln_transaction_mode NUMBER := 3;
2958 ln_quantity NUMBER := p_txn_quantity;
2959 ln_lock_flag NUMBER := 2; -- No Lock
2960 ln_material_cost_element_id NUMBER := 1; -- Material
2961 ln_overhead_cost_element_id NUMBER := 2; -- Material
2962 ln_level_type NUMBER := 1; -- This Level
2963
2964 BEGIN
2965
2966 INSERT INTO mtl_transactions_interface (
2967 source_code ,
2968 source_line_id ,
2969 source_header_id ,
2970 process_flag ,
2971 transaction_mode ,
2972 transaction_interface_id ,
2973 transaction_header_id ,
2974 inventory_item_id ,
2975 organization_id ,
2976 revision ,
2977 transaction_quantity ,
2978 transaction_uom ,
2979 transaction_date ,
2980 transaction_source_name ,
2981 transaction_type_id ,
2982 transaction_source_type_Id ,
2983 rcv_transaction_id ,
2984 transaction_reference ,-- mtl_transaction Id.
2985 last_update_date ,
2986 last_updated_by ,
2987 creation_date ,
2988 created_by ,
2989 cost_group_id ,
2990 material_account ,
2991 material_overhead_account ,--overhead absorption account
2992 resource_account ,
2993 overhead_account ,
2994 outside_processing_account ,
2995 lock_flag ,
2996 transaction_action_id ,
2997 transfer_organization,
2998 transfer_subinventory ,
2999 subinventory_code ,
3000 value_change
3001 )
3002 VALUES (
3003 lv_source_code ,
3004 ln_src_line_id ,
3005 ln_src_header_id ,
3006 ln_process_flag ,
3007 ln_transaction_mode ,
3008 mtl_material_transactions_s.nextval ,
3009 decode( p_txn_header_id, null ,
3010 mtl_material_transactions_s.currval ,
3011 p_txn_header_id
3012 ) ,
3013 p_item_id ,
3014 p_organization_id ,
3015 null ,
3016 ln_quantity , -- No Qty
3017 p_uom_code ,
3018 p_transaction_date ,
3019 lv_transaction_source_name ,
3020 p_transaction_type_id , -- Avg Cost Update
3021 p_transaction_source_type_id , -- Inventory
3022 p_transaction_id ,
3023 to_char(p_transaction_id) ,
3024 sysdate ,
3025 fnd_global.user_id ,
3026 sysdate ,
3027 fnd_global.user_id ,
3028 p_cost_group_id ,
3029 p_receiving_account_id ,
3030 p_absorption_account_id ,
3031 p_receiving_account_id ,
3032 p_receiving_account_id ,
3033 p_receiving_account_id ,
3034 ln_lock_flag ,
3035 p_transaction_action_id ,
3036 p_from_organization_id ,
3037 p_from_subinventory,
3038 p_to_subinventory ,
3039 p_value_change
3040 )
3041 RETURNING transaction_interface_id ,
3042 transaction_header_id
3043 INTO ln_txn_interface_id ,
3044 p_txn_header_id ;
3045
3046
3047
3048
3049
3050 INSERT INTO JAI_MTL_TXN_CST_HDR_T (
3051 source_code ,
3052 source_line_id ,
3053 source_header_id ,
3054 process_flag ,
3055 transaction_mode ,
3056 transaction_interface_id ,
3057 transaction_header_id ,
3058 inventory_item_id ,
3059 organization_id ,
3060 revision ,
3061 transaction_quantity ,
3062 transaction_uom ,
3063 transaction_date ,
3064 transaction_source_name ,
3065 transaction_type_id ,
3066 transaction_source_type_Id , --PVI
3067 rcv_transaction_id ,
3068 transaction_reference , -- rcv_transaction Id.
3069 last_update_date ,
3070 last_updated_by ,
3071 creation_date ,
3072 created_by ,
3073 cost_group_id ,
3074 material_account ,
3075 material_overhead_account , --overhead absorption account
3076 resource_account ,
3077 overhead_account ,
3078 outside_processing_account ,
3079 lock_flag ,
3080 transaction_id
3081 )
3082
3083
3084 VALUES (
3085 lv_source_code ,
3086 ln_src_line_id ,
3087 ln_src_header_id ,
3088 ln_process_flag ,
3089 ln_transaction_mode ,
3090 ln_txn_interface_id ,
3091 p_txn_header_id ,
3092 p_item_id ,
3093 p_organization_id ,
3094 null ,
3095 ln_quantity , -- No Qty
3096 p_uom_code ,
3097 p_transaction_date ,
3098 lv_transaction_source_name ,
3099 p_transaction_type_id , -- Avg Cost Update
3100 p_transaction_source_type_id , -- Inventory
3101 p_transaction_id ,
3102 to_char(p_transaction_id) ,
3103 sysdate ,
3104 fnd_global.user_id ,
3105 sysdate ,
3106 fnd_global.user_id ,
3107 p_cost_group_id ,
3108 p_receiving_account_id ,
3109 p_absorption_account_id ,
3110 p_receiving_account_id ,
3111 p_receiving_account_id ,
3112 p_receiving_account_id ,
3113 ln_lock_flag ,
3114 ln_txn_interface_id
3115 ) ;
3116
3117
3118 INSERT INTO mtl_txn_cost_det_interface (
3119 transaction_interface_id ,
3120 last_update_date ,
3121 last_updated_by ,
3122 creation_date ,
3123 created_by ,
3124 organization_id ,
3125 cost_element_id ,
3126 level_type ,
3127 value_change
3128 )
3129 VALUES (
3130 ln_txn_interface_id ,
3131 sysdate ,
3132 fnd_global.user_id ,
3133 sysdate ,
3134 fnd_global.user_id ,
3135 p_organization_id ,
3136 ln_material_cost_element_id ,
3137 ln_level_type ,
3138 p_value_change
3139 );
3140
3141 INSERT INTO JAI_MTL_TXN_CST_DTL_T(
3142 transaction_interface_id ,
3143 last_update_date ,
3144 last_updated_by ,
3145 creation_date ,
3146 created_by ,
3147 organization_id ,
3148 cost_element_id ,
3149 level_type ,
3150 value_change
3151 )
3152 VALUES (
3153 ln_txn_interface_id ,
3154 sysdate ,
3155 fnd_global.user_id ,
3156 sysdate ,
3157 fnd_global.user_id ,
3158 p_organization_id ,
3159 ln_material_cost_element_id ,
3160 ln_level_type ,
3161 p_value_change
3162 );
3163
3164
3165
3166
3167 INSERT INTO mtl_txn_cost_det_interface
3168 (
3169 transaction_interface_id,
3170 last_update_date,
3171 last_updated_by,
3172 creation_date,
3173 created_by,
3174 organization_id,
3175 cost_element_id,
3176 level_type,
3177 value_change
3178 )
3179 (SELECT
3180 ln_txn_interface_id ,
3181 sysdate ,
3182 fnd_global.user_id ,
3183 sysdate ,
3184 fnd_global.user_id ,
3185 p_organization_id ,
3186 clcd.cost_element_id ,
3187 clcd.level_type ,
3188 0
3189 FROM
3190 cst_layer_cost_details clcd,
3191 cst_quantity_layers cql
3192 WHERE
3193 cql.organization_id = p_organization_id
3194 and cql.inventory_item_id = p_item_id
3195 and cql.cost_group_id = p_cost_group_id
3196 and clcd.layer_id = cql.layer_id
3197 and (clcd.cost_element_id,clcd.level_type) NOT IN
3198 ( SELECT
3199 mctcd1.cost_element_id,
3200 mctcd1.level_type
3201 FROM
3202 mtl_txn_cost_det_interface mctcd1
3203 WHERE
3204 mctcd1.transaction_interface_id = ln_txn_interface_id
3205 )
3206 );
3207
3208 INSERT INTO JAI_MTL_TXN_CST_DTL_T
3209 (
3210 transaction_interface_id,
3211 last_update_date,
3212 last_updated_by,
3213 creation_date,
3214 created_by,
3215 organization_id,
3216 cost_element_id,
3217 level_type,
3218 value_change
3219 )
3220 (SELECT
3221 ln_txn_interface_id ,
3222 sysdate ,
3223 fnd_global.user_id ,
3224 sysdate ,
3225 fnd_global.user_id ,
3226 p_organization_id ,
3227 clcd.cost_element_id ,
3228 clcd.level_type ,
3229 0
3230 FROM
3231 cst_layer_cost_details clcd,
3232 cst_quantity_layers cql
3233 WHERE
3234 cql.organization_id = p_organization_id
3235 and cql.inventory_item_id = p_item_id
3236 and cql.cost_group_id = p_cost_group_id
3237 and clcd.layer_id = cql.layer_id
3238 and (clcd.cost_element_id,clcd.level_type) NOT IN
3239 ( SELECT
3240 mctcd1.cost_element_id,
3241 mctcd1.level_type
3242 FROM
3243 jai_mtl_txn_cst_dtl_t mctcd1
3244 WHERE
3245 mctcd1.transaction_interface_id = ln_txn_interface_id
3246 )
3247 );
3248
3249 end avg_cost_entry;
3250
3251 PROCEDURE std_cost_entry(
3252 p_transaction_id IN NUMBER,
3253 p_reference_account IN NUMBER,
3254 p_inventory_item_id IN NUMBER,
3255 p_organization_id IN NUMBER,
3256 p_transaction_source_id IN NUMBER,
3257 p_transaction_source_type_id IN NUMBER,
3258 p_primary_quantity IN NUMBER,
3259 p_transaction_date IN DATE,
3260 p_cost_amount IN NUMBER,
3261 p_process_flag OUT NOCOPY VARCHAR2,
3262 p_process_msg OUT NOCOPY VARCHAR2
3263 )
3264 is
3265 lv_organization_code org_organization_definitions.organization_code%type;
3266 ln_set_of_books_id org_organization_definitions.set_of_books_id%type;
3267
3268 l_func_curr_det jai_plsql_cache_pkg.func_curr_details;
3269 lv_status gl_interface.status%type;
3270 lv_reference_entry gl_interface.reference22%type;
3271 lv_reference_10 gl_interface.reference10%TYPE;
3272 lv_reference_23 gl_interface.reference23%TYPE;
3273 lv_reference_24 gl_interface.reference24%TYPE;
3274 lv_reference_25 gl_interface.reference25%TYPE;
3275 lv_reference_26 gl_interface.reference26%TYPE;
3276 lv_source_name gl_interface.user_je_source_name%TYPE;
3277 lv_category_name gl_interface.user_je_category_name%TYPE;
3278 lv_currency_code gl_interface.currency_code%TYPE;
3279
3280 cursor cur_rcv_accnt(cp_organization_id NUMBER) /*6487489..added the cursor*/
3281 IS
3282 select receiving_account_id
3283 from rcv_parameters
3284 Where organization_id = cp_organization_id;
3285
3286 ln_receiving_accnt_id NUMBER;
3287
3288
3289 BEGIN
3290 l_func_curr_det := jai_plsql_cache_pkg.return_sob_curr
3291 (p_org_id => p_organization_id);
3292 lv_organization_code := l_func_curr_det.organization_code;
3293 ln_set_of_books_id := l_func_curr_det.ledger_id;
3294 lv_source_name := 'Purchasing India';
3295 lv_category_name:='MMT';/*6504150*/
3296 lv_reference_10 :='India Local Standard Cost Entry For INTERORG_XFER and Organization_code= '|| lv_organization_code ;
3297 lv_reference_entry := 'India Localization Entry';
3298 lv_reference_23:='jai_mtl_trxs_pkg.std_cost_entry';
3299 lv_reference_24:='jai_mtl_trxs';
3300 lv_reference_26:='transaction_id';
3301 lv_currency_code :='INR';
3302
3303 OPEN cur_rcv_accnt(p_organization_id);
3304 FETCH cur_rcv_accnt INTO ln_receiving_accnt_id;
3305 CLOSE cur_rcv_accnt;
3306
3307 p_process_flag := 'SUCCESS';
3308
3309 lv_status := 'NEW' ;
3310
3311
3312 /*The following code is all added/modified for rchandan for bug#6487489 to generate PPV accounting*/
3313 insert into gl_interface
3314 (
3315 status,
3316 set_of_books_id,
3317 user_je_source_name,
3318 user_je_category_name,
3319 accounting_date,
3320 currency_code,
3321 date_created,
3322 created_by,
3323 actual_flag,
3324 entered_cr,
3325 entered_dr,
3326 transaction_date,
3327 code_combination_id,
3328 currency_conversion_date,
3329 user_currency_conversion_type,
3330 currency_conversion_rate,
3331 reference1,
3332 reference10,
3333 reference22,
3334 reference23,
3335 reference24,
3336 reference25,
3337 reference26,
3338 reference27
3339 )
3340 VALUES
3341 (
3342 lv_status , --'NEW',
3343 ln_set_of_books_id,
3344 lv_source_name,
3345 lv_category_name,
3346 trunc(sysdate),
3347 lv_currency_code,
3348 sysdate,
3349 fnd_global.user_id,
3350 'A',
3351 p_cost_amount,
3352 NULL,
3353 sysdate,
3354 ln_receiving_accnt_id,/*Inventory receiving Account*/
3355 NULL,
3356 NULL,
3357 NULL,
3358 lv_organization_code,
3359 lv_reference_10,
3360 lv_reference_entry,
3361 lv_reference_23,
3362 lv_reference_24,
3363 p_transaction_id,
3364 lv_reference_26,
3365 to_char(p_organization_id)
3366 );
3367
3368 insert into jai_mtl_trx_jrnls
3369 (journal_entry_id,
3370 status,
3371 set_of_books_id,
3372 user_je_source_name,
3373 user_je_category_name,
3374 accounting_date,
3375 currency_code,
3376 date_created,
3377 created_by,
3378 entered_cr,
3379 entered_dr,
3380 transaction_date,
3381 code_combination_id,
3382 currency_conversion_date,
3383 user_currency_conversion_type,
3384 currency_conversion_rate,
3385 reference1,
3386 reference10,
3387 reference23,
3388 reference24,
3389 reference25,
3390 reference26,
3391 reference27,
3392 creation_Date,
3393 last_updated_by,
3394 last_update_date,
3395 last_update_login,
3396 transaction_temp_id
3397
3398 )
3399 VALUES
3400 (jai_mtl_trx_jrnls_s.nextval,
3401 lv_status,
3402 ln_set_of_books_id,
3403 lv_source_name,
3404 lv_category_name,
3405 sysdate,
3406 lv_currency_code,
3407 sysdate,
3408 fnd_global.user_id,
3409 p_cost_amount,
3410 NULL,
3411 sysdate,
3412 ln_receiving_accnt_id,
3413 null,
3414 null,
3415 null,
3416 lv_organization_code,
3417 lv_reference_10,
3418 lv_reference_23,
3419 lv_reference_24,
3420 p_transaction_id,
3421 lv_reference_26,
3422 to_char(p_organization_id),
3423 sysdate,
3424 fnd_global.user_id,
3425 sysdate,
3426 fnd_global.login_id,
3427 p_transaction_id
3428 );
3429
3430
3431 /*removed the insert to MTA by vkaranam for bug #6030615 as part of SLA uptake*/
3432
3433
3434 insert into gl_interface
3435 (
3436 status,
3437 set_of_books_id,
3438 user_je_source_name,
3439 user_je_category_name,
3440 accounting_date,
3441 currency_code,
3442 date_created,
3443 created_by,
3444 actual_flag,
3445 entered_cr,
3446 entered_dr,
3447 transaction_date,
3448 code_combination_id,
3449 currency_conversion_date,
3450 user_currency_conversion_type,
3451 currency_conversion_rate,
3452 reference1,
3453 reference10,
3454 reference22,
3455 reference23,
3456 reference24,
3457 reference25,
3458 reference26,
3459 reference27
3460 )
3461 VALUES
3462 (
3463 lv_status , --'NEW',
3464 ln_set_of_books_id,
3465 lv_source_name,
3466 lv_category_name,
3467 trunc(sysdate),
3468 lv_currency_code,
3469 sysdate,
3470 fnd_global.user_id,
3471 'A',
3472 NULL,
3473 p_cost_amount,
3474 sysdate,
3475 p_reference_account,/*PPV Account*/
3476 NULL,
3477 NULL,
3478 NULL,
3479 lv_organization_code,
3480 lv_reference_10,
3481 lv_reference_entry,
3482 lv_reference_23,
3483 lv_reference_24,
3484 p_transaction_id,
3485 lv_reference_26,
3486 to_char(p_organization_id)
3487 );
3488
3489 insert into jai_mtl_trx_jrnls
3490 (journal_entry_id,
3491 status,
3492 set_of_books_id,
3493 user_je_source_name,
3494 user_je_category_name,
3495 accounting_date,
3496 currency_code,
3497 date_created,
3498 created_by,
3499 entered_cr,
3500 entered_dr,
3501 transaction_date,
3502 code_combination_id,
3503 currency_conversion_date,
3504 user_currency_conversion_type,
3505 currency_conversion_rate,
3506 reference1,
3507 reference10,
3508 reference23,
3509 reference24,
3510 reference25,
3511 reference26,
3512 reference27,
3513 creation_Date,
3514 last_updated_by,
3515 last_update_date,
3516 last_update_login,
3517 transaction_temp_id
3518
3519 )
3520 VALUES
3521 (jai_mtl_trx_jrnls_s.nextval,
3522 lv_status,
3523 ln_set_of_books_id,
3524 lv_source_name,
3525 lv_category_name,
3526 sysdate,
3527 lv_currency_code,
3528 sysdate,
3529 fnd_global.user_id,
3530 NULL,
3531 p_cost_amount,
3532 sysdate,
3533 p_reference_account,
3534 null,
3535 null,
3536 null,
3537 lv_organization_code,
3538 lv_reference_10,
3539 lv_reference_23,
3540 lv_reference_24,
3541 p_transaction_id,
3542 lv_reference_26,
3543 to_char(p_organization_id),
3544 sysdate,
3545 fnd_global.user_id,
3546 sysdate,
3547 fnd_global.login_id,
3548 p_transaction_id
3549 );
3550
3551
3552 exception
3553 WHEN OTHERS THEN
3554 p_process_flag := 'ERROR';
3555 p_process_msg := SQLERRM;
3556 end std_cost_entry;
3557
3558
3559 procedure cenvat_auto_claim
3560 (p_transaction_Temp_id IN NUMBER ,
3561 p_shipment_line_id IN NUMBER ,
3562 p_applied_quantity IN NUMBER
3563 ) IS
3564 CURSOR c_rcpt_dtls(cp_shipment_line_id IN NUMBER) Is
3565 SELECT * from jai_rcv_lines
3566 WHERE shipment_line_id = cp_shipment_line_id;
3567
3568 CURSOR c_recpt_tax_dtls(cp_shipment_line_id IN NUMBER) IS
3569 SELECT * from JAI_RCV_LINE_TAXES
3570 WHERE shipment_line_id = cp_shipment_line_id;
3571
3572 CURSOR c_trx (cp_transaction_id IN NUMBER) IS
3573 SELECT * from JAI_RCV_TRANSACTIONS
3574 WHERE transaction_id = cp_transaction_id ;
3575
3576 CURSOR c_base_trx (cp_transaction_id IN NUMBER) IS
3577 SELECT vendor_id , vendor_site_id , transaction_id , shipment_line_id from rcv_transactions
3578 WHERE transaction_id = cp_transaction_id;
3579
3580 CURSOR c_mtl_params(cp_organization_id IN NUMBER) IS
3581 SELECT * from mtl_parameters
3582 WHERE organization_id = cp_organization_id;
3583
3584 CURSOR c_cenvat_accts (cp_organization_id IN NUMBER , cp_location_id IN NUMBER) IS
3585 select *
3586 FROM JAI_CMN_INVENTORY_ORGS
3587 WHERE organization_id = cp_organization_id
3588 AND location_id = cp_location_id ;
3589
3590 CURSOR c_gl_periods(cp_set_of_books_id IN NUMBER) IS
3591 SELECT period_name
3592 FROM gl_period_statuses
3593 where set_of_books_id = cp_set_of_books_id
3594 and sysdate between start_Date and end_Date
3595 and application_id = 101;
3596
3597
3598 lv_period_name gl_period_statuses.period_name%type;
3599 ln_shipment_line_id NUMBER;
3600 ln_register_id NUMBER;
3601 lv_process_status VARCHAR2(20);
3602 lv_process_message VARCHAR2(2000);
3603 ln_Excise_amt NUMBER;
3604 ln_addl_excise_amt NUMBER;
3605 ln_oth_excise_amt NUMBER;
3606 ln_excise_cess_amt NUMBER;
3607 ln_cvd_cess_amt NUMBER;
3608 ln_Cess_amt NUMBER;
3609 ln_add_cvd_amt NUMBER;
3610 ln_addl_cvd_amt NUMBER;
3611 r_base_trx c_base_trx%rowtype;
3612 r_trx c_trx%rowtype;
3613 ln_Factor NUMBER := 0.5;
3614 ln_applied_qty NUMBER;
3615 r_rcpt_Dtls c_rcpt_dtls%ROWTYPE;
3616 lv_reference_num VARCHAR2(100);
3617 r_mtl_params c_mtl_params%ROWTYPE;
3618 r_cenvat_accts c_cenvat_accts%ROWTYPE;
3619 ln_tot_cenvat_amt NUMBER;
3620 ln_set_of_books_id NUMBER;
3621
3622 lv_reference_10 VARCHAR2(240);
3623 ln_created_by NUMBER := fnd_global.user_id;
3624
3625
3626 BEGIN
3627
3628
3629 ln_shipment_line_id := p_shipment_line_id;
3630 ln_applied_qty := p_applied_quantity;
3631
3632 fnd_profile.get('GL_SET_OF_BKS_ID',ln_set_of_books_id);
3633
3634 OPEN c_rcpt_dtls(ln_shipment_line_id);
3635 FETCH c_rcpt_dtls INTO r_rcpt_Dtls;
3636 CLOSE c_rcpt_dtls;
3637
3638 OPEN c_trx(r_rcpt_Dtls.transaction_id);
3639 FETCH c_trx INTO r_Trx;
3640 CLOSE c_trx;
3641
3642 OPEN c_base_trx(r_rcpt_Dtls.transaction_id);
3643 FETCH c_base_Trx INTO r_base_trx;
3644 CLOSE c_base_trx;
3645
3646 OPEN c_mtl_params(r_Trx.organization_id);
3647 FETCH c_mtl_params INTO r_mtl_params;
3648 CLOSE c_mtl_params;
3649
3650 OPEN c_cenvat_accts(r_trx.organization_id , r_trx.location_id);
3651 FETCH c_cenvat_accts INTO r_cenvat_accts;
3652 CLOSE c_cenvat_accts;
3653
3654 OPEN c_gl_periods(ln_set_of_books_id);
3655 FETCH c_gl_periods INTO lv_period_name;
3656 CLOSE c_gl_periods;
3657
3658 ln_factor := ln_factor * ( ln_applied_qty/ r_Trx.quantity);
3659
3660
3661 FOR r_rcpt_Tax_dtls IN c_recpt_tax_dtls(ln_shipment_line_id)
3662 LOOP
3663
3664 IF NVL(r_rcpt_Tax_dtls.modvat_flag,'N') = 'Y' THEN
3665
3666 if UPPER(r_rcpt_Tax_dtls.tax_type) = 'EXCISE' THEN
3667 ln_Excise_amt := NVL(ln_Excise_amt,0) + NVL(r_rcpt_Tax_dtls.tax_amount,0);
3668 ELSIF UPPER(r_rcpt_Tax_dtls.tax_type) IN ('ADDL. EXCISE' ,'CVD') THEN
3669 ln_addl_excise_amt := NVL(ln_addl_excise_amt,0) + NVL(r_rcpt_Tax_dtls.tax_amount,0);
3670 ELSIF UPPER(r_rcpt_Tax_dtls.tax_type) IN ('ADDITIONAL_CVD') THEN
3671 ln_addl_cvd_amt := NVL(ln_addl_cvd_amt,0) + NVL(r_rcpt_Tax_dtls.tax_amount,0);
3672 ELSIF UPPER(r_rcpt_Tax_dtls.tax_type) = 'OTHER EXCISE' THEN
3673 ln_oth_excise_amt := NVL(ln_oth_excise_amt,0) + NVL(r_rcpt_Tax_dtls.tax_amount,0);
3674 ELSIF UPPER(r_rcpt_Tax_dtls.tax_type) = 'EXCISE_EDUCATION_CESS' THEN
3675 ln_excise_cess_amt := NVL(ln_excise_cess_amt,0) + NVL(r_rcpt_Tax_dtls.tax_amount,0);
3676 ELSIF UPPER(r_rcpt_Tax_dtls.tax_type) = 'CVD_EDUCATION_CESS' THEN
3677 ln_cvd_cess_amt := NVL(ln_cvd_cess_amt,0) + NVL(r_rcpt_Tax_dtls.tax_amount,0);
3678 END IF;
3679
3680 END IF;
3681
3682 END LOOP;
3683
3684 ln_tot_cenvat_amt := NVL(ln_Excise_amt,0) + NVL(ln_addl_excise_amt,0) + NVL(ln_oth_excise_amt,0) ;
3685
3686 ln_Cess_amt := NVL(ln_cvd_cess_amt,0) + NVL(ln_excise_cess_amt,0);
3687
3688
3689 lv_reference_num := r_Trx.receipt_num || p_transaction_Temp_id;
3690
3691 ln_Excise_amt := ln_Excise_amt * ln_factor;
3692 ln_addl_excise_amt := ln_addl_excise_amt * ln_factor;
3693 ln_add_cvd_amt := ln_add_cvd_amt * ln_factor;
3694 ln_oth_excise_amt := ln_oth_excise_amt * ln_factor;
3695 ln_Cess_amt := ln_Cess_amt * ln_factor;
3696
3697 ln_tot_cenvat_amt := NVL(ln_Excise_amt,0) + NVL(ln_addl_excise_amt,0) + NVL(ln_oth_excise_amt,0) ;
3698
3699 --ln_Cess_amt := NVL(ln_cvd_cess_amt,0) + NVL(ln_excise_cess_amt,0);
3700
3701
3702 jai_cmn_rg_23ac_ii_pkg.insert_row
3703 (
3704 P_REGISTER_ID => ln_register_id ,
3705 P_INVENTORY_ITEM_ID => r_trx.inventory_item_id,
3706 P_ORGANIZATION_ID => r_trx.organization_id,
3707 P_RECEIPT_ID => r_Trx.transaction_id,
3708 P_RECEIPT_DATE => r_Trx.transaction_date,
3709 P_CR_BASIC_ED => ln_Excise_amt,
3710 P_CR_ADDITIONAL_ED => ln_addl_excise_amt,
3711 P_CR_ADDITIONAL_CVD => ln_add_cvd_amt,
3712 P_CR_OTHER_ED => ln_oth_excise_amt,
3713 P_DR_BASIC_ED => Null,
3714 P_DR_ADDITIONAL_ED => null,
3715 P_DR_ADDITIONAL_CVD => null,
3716 P_DR_OTHER_ED => null,
3717 P_EXCISE_INVOICE_NO => r_Trx.excise_invoice_no,
3718 P_EXCISE_INVOICE_DATE => r_trx.excise_invoice_date,
3719 P_REGISTER_TYPE => 'C',
3720 P_REMARKS => 'AutoClaim of remaining 50% for CG in interorg XFER',
3721 P_VENDOR_ID => r_base_Trx.vendor_id,
3722 P_VENDOR_SITE_ID => r_base_trx.vendor_site_id,
3723 P_CUSTOMER_ID => null,
3724 P_CUSTOMER_SITE_ID => null,
3725 P_LOCATION_ID => r_trx.location_id,
3726 P_TRANSACTION_DATE => trunc(sysdate),
3727 P_CHARGE_ACCOUNT_ID => null,
3728 P_REGISTER_ID_PART_I => null,
3729 P_REFERENCE_NUM => lv_reference_num ,
3730 P_ROUNDING_ID => null,
3731 P_OTHER_TAX_CREDIT => ln_Cess_amt,
3732 P_OTHER_TAX_DEBIT => null,
3733 P_TRANSACTION_TYPE => 'R',
3734 P_TRANSACTION_SOURCE => 'INTERORG_XFER',
3735 P_CALLED_FROM => 'INTERORG_XFER',
3736 P_SIMULATE_FLAG => 'N',
3737 P_PROCESS_STATUS => lv_process_status,
3738 P_PROCESS_MESSAGE => lv_process_message
3739 );
3740
3741 lv_Reference_10 := 'India Local Receiving Entry for the Receipt Number' || r_trx.receipt_num || 'for the Trx Type RECEIVE for the Organization code' || r_mtl_params.organization_code ;
3742
3743 insert into JAI_RCV_JOURNAL_ENTRIES
3744 (
3745 JOURNAL_ENTRY_ID,
3746 ORGANIZATION_CODE,
3747 RECEIPT_NUM,
3748 TRANSACTION_ID ,
3749 CREATION_DATE ,
3750 TRANSACTION_DATE ,
3751 SHIPMENT_LINE_ID ,
3752 ACCT_TYPE ,
3753 ACCT_NATURE ,
3754 SOURCE_NAME ,
3755 CATEGORY_NAME ,
3756 CODE_COMBINATION_ID ,
3757 ENTERED_DR ,
3758 ENTERED_CR ,
3759 TRANSACTION_TYPE ,
3760 PERIOD_NAME ,
3761 CREATED_BY ,
3762 CURRENCY_CODE ,
3763 CURRENCY_CONVERSION_TYPE,
3764 CURRENCY_CONVERSION_DATE,
3765 CURRENCY_CONVERSION_RATE,
3766 REFERENCE_ID ,
3767 REFERENCE_NAME ,
3768 last_update_date ,/*6497301*/
3769 last_updated_by ,/*6497301*/
3770 last_update_login /*6497301*/
3771
3772 )
3773 VALUES
3774 (jai_rcv_journal_entries_s.nextval,/*6497301*/
3775 r_mtl_params.organization_code ,
3776 r_trx.receipt_num ,
3777 r_trx.transaction_id ,
3778 sysdate ,
3779 sysdate ,
3780 r_Trx.shipment_line_id,
3781 'REGULAR',
3782 'CENVAT-AUTOCLAIM-INTERORG-XFER',
3783 'Purchasing',
3784 'Receiving India',
3785 r_cenvat_accts.excise_rcvble_account,
3786 ln_tot_cenvat_amt,
3787 Null,
3788 'Receive',
3789 lv_period_name,
3790 ln_created_by,
3791 'INR',
3792 NULL,
3793 NULL,
3794 NULL,
3795 NULL,
3796 NULL,
3797 sysdate, /*6497301*/
3798 fnd_global.user_id,/*6497301*/
3799 fnd_global.login_id/*6497301*/
3800 );
3801
3802 INSERT INTO GL_INTERFACE
3803 (
3804 status,
3805 set_of_books_id,
3806 user_je_source_name,
3807 user_je_category_name,
3808 accounting_date,
3809 currency_code,
3810 date_created,
3811 created_by,
3812 actual_flag,
3813 entered_cr,
3814 entered_dr,
3815 transaction_date,
3816 code_combination_id,
3817 currency_conversion_date,
3818 user_currency_conversion_type,
3819 currency_conversion_rate,
3820 reference1,
3821 reference10,
3822 reference22 ,
3823 reference23,
3824 reference24,
3825 reference25,
3826 reference26,
3827 reference27
3828 )
3829 VALUES
3830 (
3831 'NEW',
3832 ln_set_of_books_id,
3833 'Purchasing',
3834 'Receiving India',
3835 trunc(sysdate),
3836 'INR',
3837 sysdate,
3838 ln_created_by,
3839 'A',
3840 ln_tot_cenvat_amt,
3841 NULL,
3842 sysdate,
3843 r_cenvat_accts.excise_rcvble_account,
3844 Null,
3845 NULL,
3846 NULL,
3847 r_mtl_params.organization_code,
3848 lv_reference_10,
3849 'India Localization Entry',
3850 'jai_mtl_trxs_pkg.auto_claim',
3851 'rcv_transactions',
3852 'rcv_Transaction_id',
3853 r_Trx.transaction_id,
3854 r_trx.organization_id
3855 );
3856
3857
3858 INSERT INTO JAI_RCV_JOURNAL_ENTRIES
3859 (
3860 JOURNAL_ENTRY_ID ,
3861 ORGANIZATION_CODE ,
3862 RECEIPT_NUM ,
3863 TRANSACTION_ID ,
3864 CREATION_DATE ,
3865 TRANSACTION_DATE ,
3866 SHIPMENT_LINE_ID ,
3867 ACCT_TYPE ,
3868 ACCT_NATURE ,
3869 SOURCE_NAME ,
3870 CATEGORY_NAME ,
3871 CODE_COMBINATION_ID ,
3872 ENTERED_DR ,
3873 ENTERED_CR ,
3874 TRANSACTION_TYPE ,
3875 PERIOD_NAME ,
3876 CREATED_BY ,
3877 CURRENCY_CODE ,
3878 CURRENCY_CONVERSION_TYPE,
3879 CURRENCY_CONVERSION_DATE,
3880 CURRENCY_CONVERSION_RATE,
3881 REFERENCE_ID ,
3882 REFERENCE_NAME ,
3883 last_update_date ,/*6497301*/
3884 last_updated_by ,/*6497301*/
3885 last_update_login /*6497301*/
3886 )
3887 VALUES
3888 (jai_rcv_journal_entries_s.nextval,
3889 r_mtl_params.organization_code ,
3890 r_trx.receipt_num ,
3891 r_trx.transaction_id ,
3892 sysdate ,
3893 sysdate ,
3894 r_Trx.shipment_line_id,
3895 'REGULAR',
3896 'CENVAT-AUTOCLAIM-INTERORG-XFER',
3897 'Purchasing',
3898 'Receiving India',
3899 r_cenvat_accts.modvat_cg_account_id ,
3900 NULL,
3901 ln_tot_cenvat_amt,
3902 'Receive',
3903 lv_period_name,
3904 ln_created_by,
3905 'INR',
3906 NULL,
3907 NULL,
3908 NULL,
3909 NULL,
3910 NULL,
3911 sysdate, /*6497301*/
3912 fnd_global.user_id,/*6497301*/
3913 fnd_global.login_id/*6497301*/
3914 );
3915
3916 INSERT INTO GL_INTERFACE
3917 (
3918 status,
3919 set_of_books_id,
3920 user_je_source_name,
3921 user_je_category_name,
3922 accounting_date,
3923 currency_code,
3924 date_created,
3925 created_by,
3926 actual_flag,
3927 entered_cr,
3928 entered_dr,
3929 transaction_date,
3930 code_combination_id,
3931 currency_conversion_date,
3932 user_currency_conversion_type,
3933 currency_conversion_rate,
3934 reference1,
3935 reference10,
3936 reference22 ,
3937 reference23,
3938 reference24,
3939 reference25,
3940 reference26,
3941 reference27
3942 )
3943 VALUES
3944 (
3945 'NEW',
3946 ln_set_of_books_id,
3947 'Purchasing',
3948 'Receiving India',
3949 trunc(sysdate),
3950 'INR',
3951 sysdate,
3952 ln_created_by,
3953 'A',
3954 NULL,
3955 ln_tot_cenvat_amt,
3956 sysdate,
3957 r_cenvat_accts.modvat_cg_account_id,
3958 Null,
3959 NULL,
3960 NULL,
3961 r_mtl_params.organization_code,
3962 lv_reference_10,
3963 'India Localization Entry',
3964 'jai_mtl_trxs_pkg.auto_claim',
3965 'rcv_transactions',
3966 'rcv_Transaction_id',
3967 r_Trx.transaction_id,
3968 r_trx.organization_id
3969 );
3970
3971
3972
3973 IF ln_cvd_cess_amt IS NOT NULL THEN
3974
3975 jai_cmn_rg_others_pkg.insert_row
3976 (
3977 P_SOURCE_TYPE => 1,
3978 P_SOURCE_NAME => 'RG23C_P2',
3979 P_SOURCE_ID => ln_register_id,
3980 P_TAX_TYPE => 'CVD_EDUCATION_CESS',
3981 DEBIT_AMT => null,
3982 CREDIT_AMT => ln_cvd_cess_amt * ln_factor,
3983 P_PROCESS_FLAG => lv_process_status,
3984 P_PROCESS_MSG => lv_process_message
3985 );
3986
3987 END IF;
3988
3989 IF ln_excise_cess_amt IS NOT NULL THEN
3990 jai_cmn_rg_others_pkg.insert_row
3991 (
3992 P_SOURCE_TYPE => 1,
3993 P_SOURCE_NAME => 'RG23C_P2',
3994 P_SOURCE_ID => ln_register_id,
3995 P_TAX_TYPE => 'EXCISE_EDUCATION_CESS',
3996 DEBIT_AMT => null,
3997 CREDIT_AMT => ln_excise_cess_amt * ln_factor,
3998 P_PROCESS_FLAG => lv_process_status,
3999 P_PROCESS_MSG => lv_process_message
4000 );
4001 END IF;
4002
4003 IF ln_Cess_amt IS NOT NULL THEN
4004
4005 INSERT INTO JAI_RCV_JOURNAL_ENTRIES
4006 (
4007 JOURNAL_ENTRY_ID,
4008 ORGANIZATION_CODE ,
4009 RECEIPT_NUM ,
4010 TRANSACTION_ID ,
4011 CREATION_DATE ,
4012 TRANSACTION_DATE ,
4013 SHIPMENT_LINE_ID ,
4014 ACCT_TYPE ,
4015 ACCT_NATURE ,
4016 SOURCE_NAME ,
4017 CATEGORY_NAME ,
4018 CODE_COMBINATION_ID ,
4019 ENTERED_DR ,
4020 ENTERED_CR ,
4021 TRANSACTION_TYPE ,
4022 PERIOD_NAME ,
4023 CREATED_BY ,
4024 CURRENCY_CODE ,
4025 CURRENCY_CONVERSION_TYPE ,
4026 CURRENCY_CONVERSION_DATE ,
4027 CURRENCY_CONVERSION_RATE ,
4028 REFERENCE_ID ,
4029 REFERENCE_NAME ,
4030 last_update_date ,/*6497301*/
4031 last_updated_by ,/*6497301*/
4032 last_update_login /*6497301*/
4033 )
4034 VALUES
4035 (jai_rcv_journal_entries_s.nextval,/*6497301*/
4036 r_mtl_params.organization_code ,
4037 r_trx.receipt_num ,
4038 r_trx.transaction_id ,
4039 sysdate ,
4040 sysdate ,
4041 r_Trx.shipment_line_id,
4042 'REGULAR',
4043 'CENVAT-AUTOCLAIM-INTERORG-XFER',
4044 'Purchasing',
4045 'Receiving India',
4046 r_cenvat_accts.excise_edu_cess_rcvble_accnt,
4047 ln_Cess_amt,
4048 Null,
4049 'Receive',
4050 lv_period_name,
4051 ln_created_by,
4052 'INR',
4053 NULL,
4054 NULL,
4055 NULL,
4056 NULL,
4057 NULL,
4058 sysdate, /*6497301*/
4059 fnd_global.user_id,/*6497301*/
4060 fnd_global.login_id/*6497301*/
4061 );
4062
4063 INSERT INTO GL_INTERFACE
4064 (
4065 status,
4066 set_of_books_id,
4067 user_je_source_name,
4068 user_je_category_name,
4069 accounting_date,
4070 currency_code,
4071 date_created,
4072 created_by,
4073 actual_flag,
4074 entered_cr,
4075 entered_dr,
4076 transaction_date,
4077 code_combination_id,
4078 currency_conversion_date,
4079 user_currency_conversion_type,
4080 currency_conversion_rate,
4081 reference1,
4082 reference10,
4083 reference22 ,
4084 reference23,
4085 reference24,
4086 reference25,
4087 reference26,
4088 reference27
4089 )
4090 VALUES
4091 (
4092 'NEW',
4093 ln_set_of_books_id,
4094 'Purchasing',
4095 'Receiving India',
4096 trunc(sysdate),
4097 'INR',
4098 sysdate,
4099 ln_created_by,
4100 'A',
4101 NULL,
4102 ln_cess_amt,
4103 sysdate,
4104 r_cenvat_accts.excise_edu_cess_rcvble_accnt,
4105 Null,
4106 NULL,
4107 NULL,
4108 r_mtl_params.organization_code,
4109 lv_reference_10,
4110 'India Localization Entry',
4111 'jai_mtl_trxs_pkg.auto_claim',
4112 'rcv_transactions',
4113 'rcv_Transaction_id',
4114 r_Trx.transaction_id,
4115 r_trx.organization_id
4116 );
4117
4118
4119 INSERT INTO JAI_RCV_JOURNAL_ENTRIES
4120 (
4121 JOURNAL_ENTRY_ID,
4122 ORGANIZATION_CODE ,
4123 RECEIPT_NUM ,
4124 TRANSACTION_ID ,
4125 CREATION_DATE ,
4126 TRANSACTION_DATE ,
4127 SHIPMENT_LINE_ID ,
4128 ACCT_TYPE ,
4129 ACCT_NATURE ,
4130 SOURCE_NAME ,
4131 CATEGORY_NAME ,
4132 CODE_COMBINATION_ID ,
4133 ENTERED_DR ,
4134 ENTERED_CR ,
4135 TRANSACTION_TYPE ,
4136 PERIOD_NAME ,
4137 CREATED_BY ,
4138 CURRENCY_CODE ,
4139 CURRENCY_CONVERSION_TYPE ,
4140 CURRENCY_CONVERSION_DATE ,
4141 CURRENCY_CONVERSION_RATE ,
4142 REFERENCE_ID ,
4143 REFERENCE_NAME ,
4144 last_update_date ,/*6497301*/
4145 last_updated_by ,/*6497301*/
4146 last_update_login /*6497301*/
4147 )
4148 VALUES
4149 (
4150 jai_rcv_journal_entries_s.nextval,/*6497301*/
4151 r_mtl_params.organization_code ,
4152 r_trx.receipt_num,
4153 r_trx.transaction_id ,
4154 sysdate ,
4155 sysdate ,
4156 r_Trx.shipment_line_id,
4157 'REGULAR',
4158 'CENVAT-AUTOCLAIM-INTERORG-XFER',
4159 'Purchasing',
4160 'Receiving India',
4161 r_cenvat_accts.excise_edu_cess_cg_account,
4162 NULL,
4163 ln_Cess_amt,
4164 'Receive',
4165 lv_period_name,
4166 ln_created_by,
4167 'INR',
4168 NULL,
4169 NULL,
4170 NULL,
4171 NULL,
4172 NULL,
4173 sysdate, /*6497301*/
4174 fnd_global.user_id,/*6497301*/
4175 fnd_global.login_id/*6497301*/
4176 );
4177
4178 INSERT INTO GL_INTERFACE
4179 (
4180 status,
4181 set_of_books_id,
4182 user_je_source_name,
4183 user_je_category_name,
4184 accounting_date,
4185 currency_code,
4186 date_created,
4187 created_by,
4188 actual_flag,
4189 entered_cr,
4190 entered_dr,
4191 transaction_date,
4192 code_combination_id,
4193 currency_conversion_date,
4194 user_currency_conversion_type,
4195 currency_conversion_rate,
4196 reference1,
4197 reference10,
4198 reference22 ,
4199 reference23,
4200 reference24,
4201 reference25,
4202 reference26,
4203 reference27
4204 )
4205 VALUES
4206 (
4207 'NEW',
4208 ln_set_of_books_id,
4209 'Purchasing',
4210 'Receiving India',
4211 trunc(sysdate),
4212 'INR',
4213 sysdate,
4214 ln_created_by,
4215 'A',
4216 NULL,
4217 ln_cess_amt,
4218 sysdate,
4219 r_cenvat_accts.excise_edu_cess_cg_account,
4220 Null,
4221 NULL,
4222 NULL,
4223 r_mtl_params.organization_code,
4224 lv_reference_10,
4225 'India Localization Entry',
4226 'jai_mtl_trxs_pkg.auto_claim',
4227 'rcv_transactions',
4228 'rcv_Transaction_id',
4229 r_Trx.transaction_id,
4230 r_trx.organization_id
4231 );
4232 END IF;
4233 END;
4234 PROCEDURE CGVAT_REPOSIT_ENTRY(p_organization_id IN NUMBER,
4235 p_location_id IN NUMBER,
4236 p_Set_of_books_id IN number,
4237 p_currency in varchar2,
4238 p_transaction_header_id IN NUMBER,
4239 p_transaction_temp_id IN NUMBER,
4240 p_transaction_id IN NUMBER,
4241 p_vat_invoice_no IN VARCHAR2,
4242 p_tax_type in varchar2,
4243 p_amount in number,
4244 p_claim_schedule_id in number,
4245 p_process_status OUT NOCOPY VARCHAR2,
4246 p_process_message OUT NOCOPY VARCHAR2)
4247 IS
4248 ln_regime_id NUMBER;
4249 lv_inv_gen_process_flag VARCHAR2(10);
4250 lv_inv_gen_process_message VARCHAR2(2000);
4251 ln_repository_id NUMBER;
4252 lv_source_trx_type VARCHAR2(30):='RECEIVING';
4253 table_rcv_transactions VARCHAR2(30):= 'JAI_MTL_TRXS';
4254 lv_account_name VARCHAR2(50);
4255 ln_code_combination_id NUMBER;
4256 ln_interim_recovery_account NUMBER;
4257 ln_entered_dr NUMBER;
4258 ln_entered_cr NUMBER;
4259 lv_process_status VARCHAR2(2);
4260 lv_process_message VARCHAR2(1000);
4261 CURSOR c_regime_cur IS
4262 SELECT regime_id
4263 FROM jai_rgm_definitions
4264 WHERE regime_code = 'VAT';
4265 stmt_name VARCHAR2(64);
4266 BEGIN
4267 OPEN c_regime_cur;
4268 FETCH c_regime_cur into ln_regime_id;
4269 CLOSE c_regime_cur;
4270 lv_account_name := jai_constants.recovery;
4271 stmt_name:='Getting the interim recovery amount';
4272 ln_interim_recovery_account :=
4273 jai_cmn_rgm_recording_pkg.get_account(
4274 p_regime_id => ln_regime_id,
4275 p_organization_type => jai_constants.orgn_type_io,
4276 p_organization_id => p_organization_id,
4277 p_location_id => p_location_id,
4278 p_tax_type => p_tax_type,
4279 p_account_name => jai_constants.recovery_interim);
4280 IF ln_interim_recovery_account IS NULL THEN
4281 p_process_status := jai_constants.expected_error;
4282 p_process_message := 'Interim recovery Account not defined in VAT Setup';
4283 RETURN;
4284 END IF;
4285 stmt_name:='Getting the code combination id';
4286 ln_code_combination_id :=
4287 jai_cmn_rgm_recording_pkg.get_account(
4288 p_regime_id => ln_regime_id,
4289 p_organization_type => jai_constants.orgn_type_io,
4290 p_organization_id => p_organization_id,
4291 p_location_id => p_location_id,
4292 p_tax_type => p_tax_type,
4293 p_account_name => jai_constants.recovery);
4294 IF ln_code_combination_id IS NULL THEN
4295 p_process_status := jai_constants.expected_error;
4296 p_process_message := 'Recovery Account not defined in VAT Setup';
4297 RETURN;
4298 END IF;
4299 ln_entered_cr:=p_amount;
4300 stmt_name:='Calling insert vat repository entry';
4301 jai_cmn_rgm_recording_pkg.insert_vat_repository_entry(
4302 pn_repository_id => ln_repository_id,
4303 pn_regime_id => ln_regime_id,
4304 pv_tax_type => p_tax_type,
4305 pv_organization_type => jai_constants.orgn_type_io,
4306 pn_organization_id => p_organization_id,
4307 pn_location_id => p_location_id,
4308 pv_source => jai_constants.source_rcv,
4309 pv_source_trx_type => lv_source_trx_type,
4310 pv_source_table_name => table_rcv_transactions,
4311 pn_source_id => p_transaction_id,
4312 pd_transaction_date => trunc(sysdate),
4313 pv_account_name => lv_account_name,
4314 pn_charge_account_id => ln_code_combination_id,
4315 pn_balancing_account_id => ln_interim_recovery_account,
4316 pn_credit_amount =>ln_entered_cr ,
4317 pn_debit_amount =>ln_entered_dr ,
4318 pn_assessable_value => NULL,
4319 pn_tax_rate => NULL,
4320 pn_reference_id => p_claim_schedule_id,/*r_claim_schedule.claim_schedule_id,*/
4321 pn_batch_id => NULL,
4322 pn_inv_organization_id => P_organization_id,
4323 pv_invoice_no => p_vat_invoice_no,
4324 pd_invoice_date => trunc(sysdate),
4325 pv_called_from => 'JAINVMTX',
4326 pv_process_flag => lv_process_status,
4327 pv_process_message => lv_process_message,
4328 pv_attribute_context => NULL,
4329 pv_attribute1 => NULL,
4330 pv_attribute2 => NULL,
4331 pv_attribute3 => NULL,
4332 pv_attribute4 => NULL,
4333 pv_attribute5 => NULL);
4334 IF lv_process_status <> jai_constants.successful THEN
4335 p_process_status := lv_process_status;
4336 p_process_message := lv_process_message;
4337 RETURN;
4338 END IF;
4339
4340 process_vat_claim_acctg(
4341 ln_repository_id ,
4342 lv_procesS_status,
4343 lv_process_message);
4344 if lv_process_status<> jai_constants.successful THEN
4345 app_exception.raise_exception;
4346 end if;
4347
4348
4349 exception when others then
4350 p_process_status := lv_process_status;
4351 p_process_message := lv_process_message;
4352 end cgvat_reposit_entry;
4353 PROCEDURE claim_balance_cgvat(
4354 p_term_id IN jai_rgm_terms.term_id%TYPE DEFAULT NULL,
4355 p_shipment_header_id IN rcv_shipment_headers.shipment_header_id%TYPE DEFAULT NULL,
4356 p_shipment_line_id IN rcv_shipment_lines.shipment_line_id%TYPE DEFAULT NULL,
4357 p_transaction_id IN rcv_transactions.transaction_id%TYPE DEFAULT NULL,
4358 p_tax_type IN jai_cmn_taxes_all.tax_type%TYPE DEFAULT NULL,
4359 p_tax_id IN jai_cmn_taxes_all.tax_id%TYPE DEFAULT NULL,
4360 p_receipt_num IN VARCHAR2,
4361 P_applied_qty IN NUMBER,
4362 p_organization_id IN NUMBER,
4363 p_inventory_item_id IN NUMBER,
4364 p_location_id IN NUMBER,
4365 p_Set_of_books_id IN NUMBER,
4366 p_currency IN VARCHAR2,
4367 p_transaction_header_id IN NUMBER,
4368 p_transaction_temp_id IN NUMBER,
4369 p_vat_invoice_no IN VARCHAR2,
4370 p_process_status OUT NOCOPY VARCHAR2,
4371 p_process_message OUT NOCOPY VARCHAR2)
4372 IS
4373
4374 CURSOR cur_lines(cp_shipment_header_id IN rcv_shipment_headers.shipment_header_id%TYPE,
4375 cp_shipment_line_id IN rcv_shipment_lines.shipment_line_id%TYPE)
4376 IS
4377 SELECT shipment_header_id, shipment_line_id
4378 FROM jai_rcv_lines
4379 WHERE shipment_header_id = NVL(cp_shipment_header_id, shipment_header_id)
4380 AND shipment_line_id = NVL(cp_shipment_line_id, shipment_line_id)
4381 AND receipt_num=p_receipt_num
4382 and organization_id=p_organization_id
4383 and inventory_item_id=p_inventory_item_id
4384 ORDER BY shipment_line_id;
4385
4386
4387 CURSOR cur_txns(cp_shipment_line_id IN rcv_shipment_lines.shipment_line_id%TYPE,
4388 cp_transaction_id IN rcv_transactions.transaction_id%TYPE)
4389 IS
4390 SELECT transaction_id,
4391 transaction_type,
4392 transaction_date,
4393 tax_transaction_id,
4394 parent_transaction_type,
4395 currency_conversion_rate,
4396 quantity
4397 FROM JAI_RCV_TRANSACTIONS
4398 WHERE shipment_line_id = NVL(cp_shipment_line_id, shipment_line_id)
4399 AND transaction_id = NVL(cp_transaction_id, transaction_id)
4400 and organization_id=p_organization_id
4401 and inventory_item_id=p_inventory_item_id
4402 AND (
4403 transaction_type IN ('RECEIVE', 'RETURN TO VENDOR')
4404 OR
4405 ( transaction_type = 'CORRECT'
4406 AND parent_transaction_type IN ('RECEIVE', 'RETURN TO VENDOR')
4407 )
4408 )
4409 ORDER BY transaction_id;
4410
4411
4412
4413 CURSOR cur_tax(cp_shipment_line_id IN rcv_transactions.shipment_line_id%TYPE,
4414 cp_currency_conversion_rate IN JAI_RCV_TRANSACTIONS.currency_conversion_rate%TYPE)
4415 IS
4416 SELECT ROUND(
4417 DECODE(a.currency, jai_constants.func_curr, a.tax_amount, a.tax_amount*cp_currency_conversion_rate),
4418 NVL(b.rounding_factor, 0)
4419 ) tax_amount,
4420 a.tax_type,
4421 a.tax_id,
4422 NVL(b.rounding_factor,0) rounding_factor,
4423 c.qty_received
4424 FROM JAI_RCV_LINE_TAXES a,
4425 jai_cmn_taxes_all b,
4426 jai_rcv_lines c
4427 WHERE a.shipment_line_id =c.shipment_line_id
4428 AND a.shipment_line_id = cp_shipment_line_id
4429 AND a.tax_type IN ( select tax_type
4430 from jai_regime_tax_types_v
4431 where regime_code = jai_constants.vat_regime
4432 )
4433 AND a.tax_id = b.tax_id
4434 AND a.modvat_flag = 'Y'
4435 AND NVL(a.tax_amount,0) <> 0;
4436
4437 CURSOR cur_term(cp_shipment_line_id IN rcv_shipment_lines.shipment_line_id%TYPE)
4438 IS
4439 SELECT term_id, rcv_rgm_line_id, receipt_date
4440 FROM jai_rcv_rgm_lines
4441 WHERE shipment_line_id = cp_shipment_line_id
4442 AND receipt_num=p_receipt_num
4443 and organization_id=p_organization_id
4444 and inventory_item_id=p_inventory_item_id
4445 AND regime_code=jai_constants.vat_regime;
4446
4447 CURSOR cur_sum_schedules(cp_schedule_id IN NUMBER)
4448 IS
4449 SELECT SUM(installment_amount) total_installment_amount, MAX(installment_no) max_installment_no
4450 FROM jai_rgm_trm_schedules_t
4451 WHERE schedule_id = cp_schedule_id;
4452
4453
4454 CURSOR cur_installment_count( cp_rcv_rgm_line_id IN NUMBER,
4455 cp_transaction_id IN NUMBER,
4456 cp_tax_id IN NUMBER,
4457 cp_schedule_id IN NUMBER)
4458 IS
4459 SELECT COUNT(*) count
4460 FROM jai_rcv_rgm_claims
4461 WHERE rcv_rgm_line_id = cp_rcv_rgm_line_id
4462 AND transaction_id = cp_transaction_id
4463 AND tax_id = cp_tax_id
4464 AND installment_no IN ( SELECT installment_no
4465 FROM jai_rgm_trm_schedules_t
4466 WHERE schedule_id = cp_schedule_id);
4467 CURSOR cur_installpaid_count( cp_rcv_rgm_line_id IN NUMBER,
4468 cp_transaction_id IN NUMBER,
4469 cp_tax_id IN NUMBER)
4470 IS
4471 SELECT COUNT(*) count
4472 FROM jai_rcv_rgm_claims
4473 WHERE rcv_rgm_line_id = cp_rcv_rgm_line_id
4474 AND transaction_id = cp_transaction_id
4475 AND tax_id = cp_tax_id
4476 AND installment_amount <> 0
4477 and status='Y';
4478
4479
4480
4481 cursor cur_get_schedule(cp_schedule_id in number)
4482 is
4483 select * from jai_rgm_trm_schedules_t
4484 where schedule_id=cp_schedule_id
4485 order by installment_no;
4486
4487 r_term cur_term%ROWTYPE;
4488 ln_schedule_id NUMBER;
4489 lv_process_flag VARCHAR2(2);
4490 lv_process_msg VARCHAR2(1000);
4491 ln_amount NUMBER;
4492 r_sum_schedules cur_sum_schedules%ROWTYPE;
4493 r_installment_count cur_installment_count%ROWTYPE;
4494 ln_apportion_factor NUMBER;
4495 ln_claim_schedule_id NUMBER;
4496 ln_instpaid_cnt NUMBER;
4497 ln_debit_amt NUMBER;
4498 LN_CNT NUMBER;
4499
4500
4501 BEGIN
4502
4503 p_process_status := jai_constants.successful;
4504 p_process_message := NULL;
4505
4506 FOR rec_lines IN cur_lines(p_shipment_header_id, p_shipment_line_id)
4507 LOOP
4508
4509
4510 OPEN cur_term(rec_lines.shipment_line_id);
4511 FETCH cur_term INTO r_term;
4512 CLOSE cur_term;
4513
4514 FOR rec_txns IN cur_txns(rec_lines.shipment_line_id, p_transaction_id)
4515 LOOP
4516 ln_apportion_factor := ABS(jai_rcv_trx_processing_pkg.get_apportion_factor(rec_txns.transaction_id));
4517
4518
4519 FOR tax_rec IN cur_tax(rec_lines.shipment_line_id , rec_txns.currency_conversion_rate) -- Harshita for Bug 4995579
4520 LOOP
4521 ln_cnt := 0;
4522 if tax_rec.qty_received<>0 then
4523 ln_amount := (tax_rec.tax_amount * ln_apportion_factor)*(p_applied_qty/nvl(tax_rec.qty_received,1));
4524 end if;
4525
4526 jai_cmn_rgm_terms_pkg.generate_term_schedules(p_term_id => NVL(p_term_id,r_term.term_id),
4527 p_amount => ln_amount,
4528 p_register_date => r_term.receipt_date,
4529 p_schedule_id => ln_schedule_id,
4530 p_process_flag => lv_process_flag,
4531 p_process_msg => lv_process_msg);
4532
4533 IF lv_process_flag <> jai_constants.successful THEN
4534
4535 DELETE jai_rgm_trm_schedules_t
4536 WHERE schedule_id = ln_schedule_id;
4537
4538 p_process_status := lv_process_flag;
4539 p_process_message := lv_process_msg;
4540 RETURN;
4541 END IF;
4542
4543
4544 UPDATE jai_rgm_trm_schedules_t
4545 SET installment_amount = ROUND(installment_amount, tax_rec.rounding_factor)
4546 WHERE schedule_id = ln_schedule_id;
4547
4548 OPEN cur_sum_schedules(ln_schedule_id);
4549 FETCH cur_sum_schedules INTO r_sum_schedules;
4550 CLOSE cur_sum_schedules;
4551
4552 IF NVL(r_sum_schedules.total_installment_amount,0) <> NVL(ln_amount,0) THEN
4553 UPDATE jai_rgm_trm_schedules_t
4554 SET installment_amount = installment_amount + ln_amount - r_sum_schedules.total_installment_amount
4555 WHERE installment_no = r_sum_schedules.max_installment_no
4556 AND schedule_id = ln_schedule_id;
4557 END IF;
4558 OPEN cur_installpaid_count( cp_rcv_rgm_line_id => r_term.rcv_rgm_line_id,
4559 cp_transaction_id => rec_txns.transaction_id,
4560 cp_tax_id => tax_rec.tax_id);
4561
4562 FETCH cur_installpaid_count INTO ln_instpaid_cnt;
4563 CLOSE cur_installpaid_count;
4564
4565 UPDATE jai_rgm_trm_schedules_t
4566 SET installment_amount = installment_amount * (-1) /*This is to reduce the quantity available for claim*/
4567 WHERE schedule_id = ln_schedule_id;
4568
4569
4570 for sch_det in cur_get_schedule(ln_schedule_id)
4571 loop
4572 select jai_rcv_rgm_claims_s.NEXTVAL into ln_claim_schedule_id from dual;
4573 INSERT
4574 INTO jai_rcv_rgm_claims
4575 (
4576 CLAIM_SCHEDULE_ID,
4577 RCV_RGM_LINE_ID,
4578 Shipment_header_id,
4579 Shipment_line_id,
4580 Regime_code,
4581 Tax_transaction_id,
4582 Transaction_type,
4583 Transaction_id,
4584 Parent_transaction_type,
4585 Installment_no,
4586 Installment_amount,
4587 Claimed_amount,
4588 Scheduled_date,
4589 claimed_date,
4590 Status,
4591 Manual_claim_flag,
4592 Remarks,
4593 Tax_type,
4594 Tax_id,
4595 Trx_tax_id,
4596 CREATED_BY,
4597 CREATION_DATE,
4598 LAST_UPDATED_BY,
4599 LAST_UPDATE_DATE,
4600 LAST_UPDATE_LOGIN
4601 )values
4602 (ln_claim_schedule_id,
4603 r_term.rcv_rgm_line_id,
4604 rec_lines.shipment_header_id,
4605 rec_lines.shipment_line_id,
4606 jai_constants.vat_regime,
4607 rec_txns.tax_transaction_id,
4608 rec_txns.transaction_type,
4609 rec_txns.transaction_id,
4610 rec_txns.parent_transaction_type,
4611 sch_det.installment_no,
4612 sch_det.installment_amount,
4613 NULL,
4614 sch_det.installment_date,
4615 NULL,
4616 'N',
4617 NULL,
4618 NULL,
4619 tax_rec.tax_type,
4620 tax_rec.tax_id,
4621 NULL,
4622 fnd_global.user_id,
4623 SYSDATE,
4624 fnd_global.user_id,
4625 SYSDATE,
4626 fnd_global.login_id);
4627 if ln_instpaid_cnt>nvl(ln_cnt,0) then
4628 update jai_rcv_rgm_claims
4629 set claimed_amount=0,
4630 claimed_date=sysdate,
4631 status='Y',
4632 installment_amount=0
4633 where claim_schedule_id=ln_claim_schedule_id;
4634 ln_cnt:=nvl(ln_cnt,0)+1;
4635 else
4636 ln_debit_amt:=nvl(ln_debit_amt,0)+ sch_det.installment_amount;
4637 end if;
4638
4639 end loop;
4640 update jai_rcv_rgm_lines
4641 set recoverable_amount = nvl(recoverable_amount,0) + nvl(ln_debit_amt,0)
4642 where rcv_rgm_line_id = r_term.rcv_rgm_line_id;
4643
4644 cgvat_reposit_entry(p_organization_id ,
4645 p_location_id ,
4646 p_Set_of_books_id ,
4647 p_currency ,
4648 p_transaction_header_id,
4649 p_transaction_temp_id ,
4650 rec_txns.transaction_id,
4651 p_vat_invoice_no ,
4652 tax_rec.tax_type ,
4653 (-1) * ln_debit_amt ,
4654 ln_schedule_id ,
4655 lv_process_flag ,
4656 lv_process_msg );
4657
4658 if lv_process_flag<> jai_constants.successful THEN
4659 app_exception.raise_exception;
4660 end if;
4661
4662 DELETE jai_rgm_trm_schedules_t
4663 WHERE schedule_id = ln_schedule_id;
4664
4665 END LOOP;
4666
4667 END LOOP;
4668
4669 END LOOP;
4670 EXCEPTION
4671 WHEN OTHERS THEN
4672 p_process_status := lv_process_flag;
4673 p_process_message := lv_process_msg;
4674 END claim_balance_cgvat;
4675
4676 PROCEDURE process_vat_claim_acctg(
4677 p_repository_id IN NUMBER,
4678 p_process_status OUT NOCOPY VARCHAR2,
4679 p_process_message OUT NOCOPY VARCHAR2)
4680 IS
4681 CURSOR cur_claims
4682 IS
4683 SELECT REPOSITORY_ID,
4684 REGIME_CODE,
4685 TAX_TYPE,
4686 SOURCE_DOCUMENT_ID,
4687 DEBIT_AMOUNT,
4688 CREDIT_AMOUNT,
4689 ORGANIZATION_ID,
4690 LOCATION_ID
4691 FROM jai_rgm_trx_records
4692 WHERE repository_id = p_repository_id;
4693
4694 CURSOR cur_regimes(cp_regime_code VARCHAR2)
4695 IS
4696 SELECT regime_id
4697 FROM jai_rgm_definitions
4698 WHERE regime_code = cp_regime_code;
4699
4700 lv_accounting_type VARCHAR2(100);
4701 lv_account_nature VARCHAR2(100);
4702 lv_source_name VARCHAR2(100);
4703 lv_category_name VARCHAR2(100);
4704 ln_debit_ac NUMBER;
4705 ln_credit_ac NUMBER;
4706 lv_currency_code VARCHAR2(10);
4707 ln_entered_dr NUMBER;
4708 ln_entered_cr NUMBER;
4709 ld_accounting_date DATE;
4710 ln_repository_id jai_rgm_trx_records.repository_id%TYPE;
4711 lv_destination VARCHAR2(10);
4712 lv_code_path JAI_RCV_TRANSACTIONS.codepath%TYPE;
4713 lv_process_status VARCHAR2(2);
4714 lv_process_message VARCHAR2(1000);
4715 ln_regime_id jai_rgm_definitions.regime_id%TYPE;
4716
4717 rec_claims cur_claims%ROWTYPE;
4718
4719 lv_reference_10 gl_interface.reference10%TYPE;
4720 lv_reference_23 gl_interface.reference23%TYPE;
4721 lv_reference_24 gl_interface.reference24%TYPE;
4722 lv_reference_26 gl_interface.reference26%TYPE;
4723
4724 sqlstmt VARCHAR2(512);
4725 BEGIN
4726
4727 lv_accounting_type := 'REVERSAL';
4728 lv_account_nature := 'VAT CLAIM';
4729 lv_source_name := 'Purchasing';
4730 lv_category_name := 'Receiving India';
4731 lv_reference_10 := 'VAT claim accounting';
4732 lv_reference_23 := 'jai_mtl_trxs_pkg.process_vat_claim_acctg';
4733 lv_reference_24 := 'jai_rgm_trx_records';
4734 lv_reference_26 := 'repository_id';
4735 lv_currency_code := jai_constants.func_curr;
4736 ld_accounting_date := TRUNC(SYSDATE);
4737 lv_destination := 'G';
4738
4739 sqlstmt := 'opening cur_claims cursor';
4740 OPEN cur_claims;
4741 FETCH cur_claims INTO rec_claims;
4742 CLOSE cur_claims;
4743
4744 sqlstmt := 'opening cur_regimes cursor';
4745 OPEN cur_regimes(rec_claims.regime_code);
4746 FETCH cur_regimes INTO ln_regime_id;
4747 CLOSE cur_regimes;
4748
4749 sqlstmt := 'jai_cmn_rgm_recording_pkg.get_account for interim recovery account';
4750 ln_debit_ac := jai_cmn_rgm_recording_pkg.get_account(
4751 p_regime_id => ln_regime_id,
4752 p_organization_type => jai_constants.orgn_type_io,
4753 p_organization_id => rec_claims.organization_id,
4754 p_location_id => rec_claims.location_id,
4755 p_tax_type => rec_claims.tax_type,
4756 p_account_name => jai_constants.recovery_interim);
4757
4758 sqlstmt := 'jai_cmn_rgm_recording_pkg.get_account for recovery account';
4759 ln_credit_ac := jai_cmn_rgm_recording_pkg.get_account(
4760 p_regime_id => ln_regime_id,
4761 p_organization_type => jai_constants.orgn_type_io,
4762 p_organization_id => rec_claims.organization_id,
4763 p_location_id => rec_claims.location_id,
4764 p_tax_type => rec_claims.tax_type,
4765 p_account_name => jai_constants.recovery);
4766
4767
4768 ln_entered_dr := rec_claims.credit_amount;
4769 ln_entered_cr := NULL;
4770 lv_reference_10 := 'India Local VAT Claim Entries For Repository id'||rec_claims.repository_id;
4771
4772 sqlstmt := 'jai_rcv_accounting_pkg.process_transaction for debit';
4773 IF NVL(ln_entered_dr,0) <> 0 THEN
4774 jai_rcv_accounting_pkg.process_transaction(
4775 p_transaction_id => rec_claims.source_document_id,
4776 p_acct_type => lv_accounting_type,
4777 p_acct_nature => lv_account_nature,
4778 p_source_name => lv_source_name,
4779 p_category_name => lv_category_name,
4780 p_code_combination_id => ln_debit_ac,
4781 p_entered_dr => ln_entered_dr,
4782 p_entered_cr => ln_entered_cr,
4783 p_currency_code => lv_currency_code,
4784 p_accounting_date => ld_accounting_date,
4785 p_reference_10 => lv_reference_10,
4786 p_reference_23 => lv_reference_23,
4787 p_reference_24 => lv_reference_24,
4788 p_reference_25 => p_repository_id,
4789 p_reference_26 => lv_reference_26,
4790 p_destination => lv_destination,
4791 p_simulate_flag => 'N',
4792 p_codepath => lv_code_path,
4793 p_process_message => lv_process_message,
4794 p_process_status => lv_process_status,
4795 p_reference_name => jai_constants.repository_name,
4796 p_reference_id => p_repository_id);
4797
4798 IF lv_process_status <> jai_constants.successful THEN
4799 p_process_status := lv_process_status;
4800 p_process_message := lv_process_message;
4801 RETURN;
4802 END IF;
4803 END IF;
4804
4805 ln_entered_dr := NULL;
4806 ln_entered_cr := rec_claims.credit_amount;
4807 sqlstmt := 'jai_rcv_accounting_pkg.process_transaction for credit';
4808 IF NVL(ln_entered_cr,0) <> 0 THEN
4809 jai_rcv_accounting_pkg.process_transaction(
4810 p_transaction_id => rec_claims.source_document_id,
4811 p_acct_type => lv_accounting_type,
4812 p_acct_nature => lv_account_nature,
4813 p_source_name => lv_source_name,
4814 p_category_name => lv_category_name,
4815 p_code_combination_id => ln_credit_ac,
4816 p_entered_dr => ln_entered_dr,
4817 p_entered_cr => ln_entered_cr,
4818 p_currency_code => lv_currency_code,
4819 p_accounting_date => ld_accounting_date,
4820 p_reference_10 => lv_reference_10,
4821 p_reference_23 => lv_reference_23,
4822 p_reference_24 => lv_reference_24,
4823 p_reference_25 => p_repository_id,
4824 p_reference_26 => lv_reference_26,
4825 p_destination => lv_destination,
4826 p_simulate_flag => 'N',
4827 p_codepath => lv_code_path,
4828 p_process_message => lv_process_message,
4829 p_process_status => lv_process_status,
4830 p_reference_name => jai_constants.repository_name,
4831 p_reference_id => p_repository_id);
4832
4833 IF lv_process_status <> jai_constants.successful THEN
4834 p_process_status := lv_process_status;
4835 p_process_message := lv_process_message;
4836 RETURN;
4837 END IF;
4838 END IF;
4839
4840 p_process_status := jai_constants.successful;
4841 EXCEPTION
4842 WHEN OTHERS THEN
4843 p_process_status := jai_constants.unexpected_error;
4844 p_process_message := 'SQL error while calling '||sqlstmt||' :'||SQLCODE||' : '||SQLERRM;
4845 END process_vat_claim_acctg;
4846
4847 PROCEDURE delete_trx(p_transaction_header_id IN NUMBER,
4848 p_transaction_temp_id IN NUMBER)
4849 IS
4850 BEGIN
4851
4852 DELETE jai_mtl_match_receipts
4853 WHERE transaction_temp_id in
4854 (
4855 SELECT transaction_temp_id
4856 FROM jai_mtl_trxs
4857 WHERE transaction_header_id = p_transaction_header_id
4858 AND transaction_temp_id = nvl(p_transaction_temp_id, transaction_temp_id )
4859 AND transaction_commit_date is null
4860 );
4861
4862 DELETE jai_cmn_document_taxes
4863 WHERE source_doc_type = 'INTERORG_XFER'
4864 and source_table_name = 'MTL_MATERIAL_TRANSACTIONS_TEMP'
4865 AND source_doc_line_id IN
4866 (
4867 SELECT transaction_temp_id
4868 FROM jai_mtl_trxs
4869 WHERE transaction_header_id = p_transaction_header_id
4870 AND transaction_temp_id = nvl(p_transaction_temp_id, transaction_temp_id )
4871 AND transaction_commit_date is null
4872 );
4873
4874 DELETE JAI_CMN_MATCH_TAXES
4875 WHERE ref_line_id IN
4876 (
4877 SELECT transaction_temp_id
4878 FROM jai_mtl_trxs
4879 WHERE transaction_header_id = p_transaction_header_id
4880 AND transaction_temp_id = nvl(p_transaction_temp_id, transaction_temp_id )
4881 AND transaction_commit_date is null
4882 )
4883 AND order_invoice='X';
4884
4885 DELETE JAI_CMN_MATCH_RECEIPTS
4886 WHERE ref_line_id IN
4887 (
4888 SELECT transaction_temp_id
4889 FROM jai_mtl_trxs
4890 WHERE transaction_header_id = p_transaction_header_id
4891 AND transaction_temp_id = nvl(p_transaction_temp_id, transaction_temp_id )
4892 AND transaction_commit_date is null
4893 )
4894 AND order_invoice='X';
4895
4896 DELETE jai_mtl_trxs
4897 WHERE transaction_header_id = p_transaction_header_id
4898 AND transaction_temp_id = nvl(p_transaction_temp_id, transaction_temp_id )
4899 AND transaction_commit_date is null;
4900
4901 END delete_trx;
4902
4903 PROCEDURE default_taxes(
4904 p_to_organization_id number ,
4905 p_to_location_code VARCHAR2 ,
4906 p_transfer_subinventory varchar2 ,
4907 p_toorg_location_id number ,
4908 p_organization_id number ,
4909 p_subinventory_code varchar2 ,
4910 p_transaction_type_id number ,
4911 p_header_id NUMBER ,
4912 p_line_id NUMBER ,
4913 p_inventory_item_id NUMBER ,
4914 p_uom_code VARCHAR2 ,
4915 p_line_quantity NUMBER ,
4916 p_item_cost NUMBER ,
4917 p_currency VARCHAR2 ,
4918 p_currency_conv_factor NUMBER ,
4919 p_date_order DATE ,
4920 p_Iproc_profile_val number ,
4921 p_assessable_value OUT NOCOPY NUMBER ,
4922 p_vat_assessable_value OUT NOCOPY NUMBER ,
4923 p_tax_amount IN OUT NOCOPY NUMBER
4924 )
4925 IS
4926
4927 PRAGMA AUTONOMOUS_TRANSACTION;
4928
4929 cursor c_cust_dtl is
4930 SELECT su.site_use_id,cas.cust_account_id
4931 FROM
4932 hz_cust_acct_sites_all cas,
4933 hz_cust_site_uses_all su,
4934 po_location_associations_all pla,
4935 hr_locations hrl
4936 WHERE cas.cust_acct_site_id = su.cust_acct_site_id
4937 AND su.site_use_id = pla.site_use_id(+)
4938 AND pla.location_id = hrl.location_id(+)
4939 AND su.site_use_code = 'SHIP_TO'
4940 AND RTRIM(Ltrim(hrl.location_code)) = LTRIM(Rtrim(p_to_location_code))
4941 AND hrl.inventory_organization_id = p_to_organization_id ; -- bug 6444945
4942
4943 cursor c_jai_mtl_trxs is
4944 SELECT to_subinventory ,
4945 inventory_item_id ,
4946 quantity ,
4947 transaction_uom
4948 FROM jai_mtl_trxs
4949 WHERE transaction_header_id = p_header_id
4950 AND transaction_temp_id = p_line_id;
4951
4952 r_jai_mtl_trxs c_jai_mtl_trxs%ROWTYPE;
4953 ln_site_use_id number(15);
4954 ln_cust_account_id number(15);
4955 ln_tax_category_id number(15);
4956 ln_user_id number(15);
4957
4958 ln_assessable_value number(15);
4959 ln_vat_assessable_value number(15);
4960
4961 BEGIN
4962
4963 ln_user_id := fnd_global.user_id;
4964
4965 open c_jai_mtl_trxs;
4966 fetch c_jai_mtl_trxs into r_jai_mtl_trxs;
4967 close c_jai_mtl_trxs;
4968
4969 /*
4970 ||The following condition is to see if only quantity is changed
4971 ||In this scenario the taxes need to be recalculated and not redefaulted.
4972 ||If any match information is present this would also be deleted
4973 */
4974 IF r_jai_mtl_trxs.quantity <> p_line_quantity THEN
4975
4976 IF r_jai_mtl_trxs.inventory_item_id = p_inventory_item_id AND
4977 r_jai_mtl_trxs.transaction_uom = p_uom_code AND
4978 r_jai_mtl_trxs.to_subinventory = p_transfer_subinventory THEN
4979
4980 UPDATE jai_cmn_document_taxes
4981 SET tax_amt = ( p_line_quantity / r_jai_mtl_trxs.quantity ) * tax_amt,
4982 FUNC_TAX_AMT = ( p_line_quantity / r_jai_mtl_trxs.quantity ) * func_tax_amt,
4983 last_update_date = sysdate,
4984 last_updated_by = ln_user_id
4985 WHERE source_doc_id = p_header_id
4986 AND source_doc_line_id = p_line_id;
4987
4988 UPDATE jai_mtl_trxs
4989 SET quantity = p_line_quantity,
4990 last_update_date = sysdate,
4991 last_updated_by = ln_user_id
4992 WHERE transaction_header_id = p_header_id
4993 AND transaction_temp_id = p_line_id;
4994
4995 DELETE JAI_CMN_MATCH_RECEIPTS
4996 WHERE ref_line_id = p_line_id
4997 AND order_invoice = 'X';
4998
4999 DELETE jai_mtl_match_receipts
5000 WHERE transaction_temp_id = p_line_id ;
5001
5002 DELETE JAI_CMN_MATCH_TAXES
5003 WHERE ref_line_id = p_line_id
5004 AND order_invoice = 'X' ;
5005
5006 COMMIT;
5007
5008 RETURN;
5009
5010 END IF;
5011
5012 END IF;
5013
5014 open c_cust_dtl;
5015 fetch c_cust_dtl into ln_site_use_id, ln_cust_account_id;
5016 close c_cust_dtl;
5017
5018
5019 /* following deletes all the IL data sofar saved as the taxes are going to redefault */
5020 delete_trx(
5021 p_transaction_header_id => p_header_id,
5022 p_transaction_temp_id => p_line_id
5023 );
5024
5025 -- lv_Iproc_profile_val := fnd_profile.value_specific(NAME =>'GL_SET_OF_BKS_ID',user_id=>ln_user_id);
5026 jai_cmn_tax_defaultation_pkg.ja_in_cust_default_taxes (
5027 p_org_id =>p_to_organization_id,
5028 p_customer_id =>ln_cust_account_id,
5029 p_ship_to_site_use_id =>ln_site_use_id ,
5030 p_inventory_item_id =>p_inventory_item_id ,
5031 p_header_id =>p_header_id ,
5032 p_line_id =>p_line_id ,
5033 p_tax_category_id =>ln_tax_category_id
5034 );
5035
5036 ln_assessable_value := jai_om_utils_pkg.get_oe_assessable_value
5037 (
5038 p_customer_id => ln_cust_account_id,
5039 p_ship_to_site_use_id => ln_site_use_id,
5040 p_inventory_item_id => p_inventory_item_id,
5041 p_uom_code => p_uom_code,
5042 p_default_price => p_item_cost,
5043 p_ass_value_date => p_date_order,
5044 p_sob_id => p_Iproc_profile_val,
5045 p_curr_conv_code => null,
5046 p_conv_rate => null
5047 );
5048
5049 -- copy(v_assessable_value,'MTL_TRX_LINE.ASSESSABLE_VALUE');
5050
5051 ln_vat_assessable_value := jai_general_pkg.ja_in_vat_assessable_value
5052 (
5053 p_party_id => ln_cust_account_id ,
5054 p_party_site_id => ln_site_use_id ,
5055 p_inventory_item_id => p_inventory_item_id ,
5056 p_uom_code => p_uom_code ,
5057 p_default_price => p_item_cost,
5058 p_ass_value_date => p_date_order ,
5059 p_party_type => 'C'
5060 );
5061
5062 ln_vat_assessable_value := nvl(ln_vat_assessable_value,0) * p_line_quantity;
5063
5064 -- copy(ln_vat_assessable_value,'MTL_TRX_LINE.VAT_ASSESSABLE_VALUE');
5065
5066 INSERT INTO jai_mtl_trxs(
5067 transaction_id,
5068 transaction_header_id ,
5069 transaction_temp_id ,
5070 transaction_type_id ,
5071 from_organization ,
5072 to_organization ,
5073 inventory_item_id ,
5074 from_subinventory ,
5075 to_subinventory ,
5076 location_id ,
5077 quantity ,
5078 taxcategory_id ,
5079 selling_price ,
5080 assessable_value ,
5081 vat_assessable_value ,
5082 transaction_date,
5083 transaction_uom ,
5084 creation_date,
5085 created_by,
5086 last_update_date,
5087 last_updated_by,
5088 last_update_login
5089 ) VALUES (
5090 jai_mtl_trxs_s.nextval,
5091 p_header_id, -- :mtl_trx_line.transaction_header_id,
5092 p_line_id, -- :mtl_trx_line.transaction_temp_id,
5093 p_transaction_type_id, -- :mtl_trx_line.transaction_type_id,
5094 p_organization_id, -- :mtl_trx_line.organization_id,
5095 p_to_organization_id, -- :org.to_org_id,
5096 p_inventory_item_id, -- :mtl_trx_line.inventory_item_id,
5097 p_subinventory_code, -- :mtl_trx_line.subinventory_code,
5098 p_transfer_subinventory, -- :mtl_trx_line.transfer_subinventory,
5099 p_toorg_location_id, -- :mtl_trx_line.toorg_location_id
5100 p_line_quantity, -- :mtl_trx_line.transaction_quantity
5101 ln_tax_category_id, -- :ja_in_tax.tax_category_id,
5102 p_item_cost, -- :mtl_trx_line.item_cost,
5103 ln_assessable_value, -- v_assessable_value,
5104 ln_vat_assessable_value, -- :mtl_trx_line.vat_assessable_value,
5105 sysdate, -- p_date_order
5106 p_uom_code, -- :mtl_trx_line.transaction_uom,
5107 sysdate,
5108 ln_user_id,
5109 sysdate,
5110 ln_user_id,
5111 fnd_global.login_id
5112 );
5113
5114 ln_assessable_value := nvl(ln_assessable_value,0)* p_line_quantity; /* value returned is excise assessable value of the line */
5115
5116 jai_cmn_tax_defaultation_pkg.ja_in_calc_prec_taxes(
5117 transaction_name => 'INTERORG_XFER',
5118 p_tax_category_id => ln_tax_category_id,
5119 p_header_id => p_header_id,
5120 p_line_id => p_line_id,
5121 p_assessable_value => ln_assessable_value ,
5122 p_tax_amount => p_tax_amount ,
5123 p_inventory_item_id => p_inventory_item_id ,
5124 p_line_quantity => p_line_quantity ,
5125 p_uom_code => p_uom_code,
5126 p_vendor_id => NULL,
5127 p_currency => 'INR',
5128 p_currency_conv_factor => p_currency_conv_factor,
5129 p_creation_date => sysdate ,
5130 p_created_by => ln_user_id,
5131 p_last_update_date => sysdate ,
5132 p_last_updated_by => ln_user_id,
5133 p_last_update_login => fnd_global.login_id ,
5134 p_operation_flag => NULL,
5135 p_vat_assessable_value => ln_vat_assessable_value
5136 ) ;
5137
5138 COMMIT;
5139
5140 p_assessable_value := ln_assessable_value; /* value returned is excise assessable value of the line */
5141 p_vat_assessable_value := nvl(ln_vat_assessable_value,0); /* value returned is VAT assessable value of the line */
5142
5143 exception
5144 when others then
5145 app_exception.raise_exception;
5146
5147 END default_taxes;
5148
5149 PROCEDURE delete_trx_autonomous(p_transaction_header_id IN NUMBER,
5150 p_transaction_temp_id IN NUMBER)
5151 IS
5152 PRAGMA AUTONOMOUS_TRANSACTION;
5153 BEGIN
5154
5155 delete_trx(p_transaction_header_id,p_transaction_temp_id) ;
5156 COMMIT;
5157
5158 END delete_trx_autonomous;
5159
5160
5161 PROCEDURE sync_with_base_trx(
5162 p_transaction_header_id IN NUMBER,
5163 p_transaction_temp_id IN NUMBER,
5164 p_event IN VARCHAR2
5165 ) IS
5166 BEGIN
5167
5168 IF p_event <> 'KEY-COMMIT' THEN
5169
5170 delete_trx_autonomous(p_transaction_header_id ,
5171 p_transaction_temp_id);
5172
5173 ELSE
5174
5175 delete_trx(
5176 p_transaction_header_id ,
5177 p_transaction_temp_id
5178 );
5179 END IF;
5180
5181 END sync_with_base_trx;
5182
5183 END;