[Home] [Help]
322:
323: BEGIN
324:
325: lv_statement := '0';
326: lv_codepath := jai_general_pkg.plot_codepath(1, lv_codepath, 'Insert_Repository_Entry', 'START');
327:
328: OPEN c_regime_code(p_regime_id);
329: FETCH c_regime_code INTO lv_regime_code;
330: CLOSE c_regime_code;
336:
337: lv_statement := '1';
338: -- REGIME Validation
339: IF lv_regime_code <> jai_constants.service_regime THEN
340: lv_codepath := jai_general_pkg.plot_codepath(2, lv_codepath);
341: p_process_flag := jai_constants.expected_error;
342: p_process_message := 'Transactions other than SERVICE regime are not supported';
343: FND_FILE.put_line( FND_FILE.log, p_process_message);
344: fnd_file.put_line(fnd_file.log,p_process_message);
356:
357: lv_statement := '2';
358: IF p_source IN (jai_constants.source_settle_in, jai_constants.source_settle_out) THEN
359: ld_transaction_date := p_transaction_date;
360: lv_codepath := jai_general_pkg.plot_codepath(2.1, lv_codepath);
361:
362: ELSE
363: ld_last_settlement_date := jai_cmn_rgm_settlement_pkg.get_last_settlement_date(pn_regime_id => p_regime_id,pn_org_id => p_organization_id,pn_location_id => p_location_id);/* added location id by ssawant for bug 5989740 */
364: IF ld_last_settlement_date > p_transaction_date THEN /*for bug 5662296 ,org_settlement. Replaced >= with >*/
362: ELSE
363: ld_last_settlement_date := jai_cmn_rgm_settlement_pkg.get_last_settlement_date(pn_regime_id => p_regime_id,pn_org_id => p_organization_id,pn_location_id => p_location_id);/* added location id by ssawant for bug 5989740 */
364: IF ld_last_settlement_date > p_transaction_date THEN /*for bug 5662296 ,org_settlement. Replaced >= with >*/
365: ld_transaction_date := ld_last_settlement_date + 1;
366: lv_codepath := jai_general_pkg.plot_codepath(2.2, lv_codepath);
367: ELSIF ld_last_settlement_date IS NULL or ld_last_settlement_date <= p_transaction_date THEN /* for bug 5662296 , org_settlement. Replaced < with <=*/
368: ld_transaction_date := p_transaction_date;
369: lv_codepath := jai_general_pkg.plot_codepath(2.3, lv_codepath);
370: END IF;
365: ld_transaction_date := ld_last_settlement_date + 1;
366: lv_codepath := jai_general_pkg.plot_codepath(2.2, lv_codepath);
367: ELSIF ld_last_settlement_date IS NULL or ld_last_settlement_date <= p_transaction_date THEN /* for bug 5662296 , org_settlement. Replaced < with <=*/
368: ld_transaction_date := p_transaction_date;
369: lv_codepath := jai_general_pkg.plot_codepath(2.3, lv_codepath);
370: END IF;
371: END IF;
372:
373: lv_statement := '2.1';
374: -- ~~~~~~~~~~~~~~~~~~~~~~~ Start of Repository Entry ~~~~~~~~~~~~~~~~~~~
375:
376: IF p_source = jai_constants.source_ap THEN
377: lv_statement := '3';
378: lv_codepath := jai_general_pkg.plot_codepath(3, lv_codepath);
379: lv_register_entry_type := jai_constants.credit;
380: lv_account_name := jai_constants.recovery;
381: lv_charge_entry_type := jai_constants.debit;
382: lv_balancing_accnt_name := jai_constants.recovery_interim;
383: lv_balancing_entry_type := jai_constants.credit;
384:
385: ELSIF p_source = jai_constants.source_ar THEN
386: lv_statement := '4';
387: lv_codepath := jai_general_pkg.plot_codepath(4, lv_codepath);
388: lv_register_entry_type := jai_constants.debit;
389: lv_account_name := jai_constants.liability;
390: lv_charge_entry_type := jai_constants.credit;
391: lv_balancing_accnt_name := jai_constants.liability_interim;
394: ELSIF p_source = jai_constants.source_manual_entry THEN
395: /*No need to Set Balancing Account Name as there is no need to derive balancing account because User ENTERs it in MANUAL
396: ENTRY Form*/
397: lv_statement := '5';
398: lv_codepath := jai_general_pkg.plot_codepath(5, lv_codepath);
399: lv_account_name := p_account_name;
400: IF lv_account_name IN (jai_constants.recovery, jai_constants.recovery_interim) THEN
401: lv_codepath := jai_general_pkg.plot_codepath(6, lv_codepath);
402: lv_register_entry_type := jai_constants.credit;
397: lv_statement := '5';
398: lv_codepath := jai_general_pkg.plot_codepath(5, lv_codepath);
399: lv_account_name := p_account_name;
400: IF lv_account_name IN (jai_constants.recovery, jai_constants.recovery_interim) THEN
401: lv_codepath := jai_general_pkg.plot_codepath(6, lv_codepath);
402: lv_register_entry_type := jai_constants.credit;
403: lv_charge_entry_type := jai_constants.debit;
404: lv_balancing_entry_type := jai_constants.credit;
405: ELSIF lv_account_name IN (jai_constants.liability, jai_constants.liability_interim) THEN
402: lv_register_entry_type := jai_constants.credit;
403: lv_charge_entry_type := jai_constants.debit;
404: lv_balancing_entry_type := jai_constants.credit;
405: ELSIF lv_account_name IN (jai_constants.liability, jai_constants.liability_interim) THEN
406: lv_codepath := jai_general_pkg.plot_codepath(7, lv_codepath);
407: lv_register_entry_type := jai_constants.debit;
408: lv_charge_entry_type := jai_constants.credit;
409: lv_balancing_entry_type := jai_constants.debit;
410: END IF;
412: /* Incase of Distributions and settlements, we hit only recovery account and decrease/increase
413: repository amounts as per _OUT/_IN trxns*/
414: ELSIF p_source IN (jai_constants.service_src_distribute_out, jai_constants.source_settle_out) THEN
415: lv_statement := '6';
416: lv_codepath := jai_general_pkg.plot_codepath(8, lv_codepath);
417: lv_register_entry_type := jai_constants.debit;
418: /* following is changed as per Shekhars finding. this is because incase of distributions and settlements,
419: we should hit only recovery accounts*/
420: lv_account_name := jai_constants.recovery; -- jai_constants.liability; This is changed as per Shekhars finding
423: lv_balancing_entry_type := jai_constants.debit;
424:
425: ELSIF p_source IN (jai_constants.service_src_distribute_in, jai_constants.source_settle_in) THEN
426: lv_statement := '7';
427: lv_codepath := jai_general_pkg.plot_codepath(9, lv_codepath);
428: lv_register_entry_type := jai_constants.credit;
429: lv_account_name := jai_constants.recovery;
430: lv_charge_entry_type := jai_constants.debit;
431: lv_balancing_entry_type := jai_constants.credit;
433: END IF;
434:
435: IF lv_register_entry_type = jai_constants.debit THEN
436: lv_statement := '8';
437: lv_codepath := jai_general_pkg.plot_codepath(10, lv_codepath);
438: ln_debit := p_amount;
439: ln_credit := NULL;
440: ln_trx_debit := nvl(ln_trx_amount, p_amount);
441: ln_trx_credit := null;
440: ln_trx_debit := nvl(ln_trx_amount, p_amount);
441: ln_trx_credit := null;
442: ELSE
443: lv_statement := '9';
444: lv_codepath := jai_general_pkg.plot_codepath(11, lv_codepath);
445: ln_debit := NULL;
446: ln_credit := p_amount;
447: ln_trx_debit := null;
448: ln_trx_credit := nvl(ln_trx_amount, p_amount);
449: END IF;
450:
451: lv_statement := '13';
452: IF p_charge_account_id IS NULL THEN
453: lv_codepath := jai_general_pkg.plot_codepath(12, lv_codepath);
454: ln_charge_account_id := get_account(
455: p_regime_id => p_regime_id,
456: p_organization_type => p_organization_type,
457: p_organization_id => p_organization_id,
472: lv_balancing_accnt_name := nvl(p_balancing_accnt_name, lv_balancing_accnt_name);
473:
474: lv_statement := '12';
475: IF ln_balancing_orgn_id IS NULL THEN
476: lv_codepath := jai_general_pkg.plot_codepath(13, lv_codepath);
477: lv_balancing_orgn_type := p_organization_type;
478: ln_balancing_orgn_id := p_organization_id;
479: ln_balancing_location_id := p_location_id;
480: lv_balancing_tax_type := p_tax_type;
481: END IF;
482:
483: lv_statement := '17';
484: IF p_balancing_account_id IS NULL THEN -- AND lv_balancing_accnt_name IS NOT NULL THEN
485: lv_codepath := jai_general_pkg.plot_codepath(14, lv_codepath);
486: ln_balancing_account_id := get_account(
487: p_regime_id => p_regime_id,
488: p_organization_type => lv_balancing_orgn_type,
489: p_organization_id => ln_balancing_orgn_id,
503: OPEN c_primary_regno('PRIMARY'); --rchandan for bug#4428980
504: FETCH c_primary_regno into lv_primary_regime_regno;
505: CLOSE c_primary_regno;
506:
507: lv_codepath := jai_general_pkg.plot_codepath(15, lv_codepath);
508: INSERT INTO jai_rgm_trx_records(
509: repository_id, regime_code, tax_type, source,
510: source_document_id, source_table_name, transaction_date, debit_amount, credit_amount,
511: settled_amount, settled_flag, settlement_id, organization_type,
532: lv_statement := '11';
533: IF p_accntg_required_flag = jai_constants.yes THEN
534:
535: lv_statement := '15';
536: lv_codepath := jai_general_pkg.plot_codepath(16, lv_codepath);
537: IF ln_charge_account_id IS NULL THEN
538: lv_codepath := jai_general_pkg.plot_codepath(17, lv_codepath);
539: p_process_flag := jai_constants.expected_error;
540: p_process_message := 'Charge Account('||lv_account_name||') not defined for tax type '||p_tax_type;
534:
535: lv_statement := '15';
536: lv_codepath := jai_general_pkg.plot_codepath(16, lv_codepath);
537: IF ln_charge_account_id IS NULL THEN
538: lv_codepath := jai_general_pkg.plot_codepath(17, lv_codepath);
539: p_process_flag := jai_constants.expected_error;
540: p_process_message := 'Charge Account('||lv_account_name||') not defined for tax type '||p_tax_type;
541: FND_FILE.put_line( FND_FILE.log, p_process_message); fnd_file.put_line(fnd_file.log,p_process_message);
542: GOTO end_of_repository_entry;
551: END IF;
552:
553: lv_statement := '18';
554: IF ln_balancing_account_id IS NULL THEN
555: lv_codepath := jai_general_pkg.plot_codepath(18, lv_codepath);
556: p_process_flag := jai_constants.expected_error;
557: p_process_message := 'Balancing Account('||lv_balancing_accnt_name||') not defined for tax type '||lv_balancing_tax_type;
558: FND_FILE.put_line( FND_FILE.log, p_process_message); fnd_file.put_line(fnd_file.log,p_process_message);
559: GOTO end_of_repository_entry;
566:
567: lv_statement := '19';
568: -- INITIAL_ENTRY
569: IF lv_charge_entry_type = jai_constants.debit THEN
570: lv_codepath := jai_general_pkg.plot_codepath(19, lv_codepath);
571: ln_debit := p_amount;
572: ln_credit := NULL;
573: ln_trx_debit := nvl(ln_trx_amount, p_amount);
574: ln_trx_credit := null;
579: ln_trx_credit := nvl(ln_trx_amount, p_amount);
580: END IF;
581:
582: lv_statement := '20';
583: lv_codepath := jai_general_pkg.plot_codepath(20, lv_codepath);
584: -- make a call to post_accounting procedure
585: post_accounting(
586: p_regime_code => lv_regime_code,
587: p_tax_type => p_tax_type,
612: /* START of DISCOUNT ACCOUNTING */
613: IF nvl(p_discounted_amount, 0) <> 0 THEN
614: -- Discount related code needs to be added here
615: lv_statement := '20.1';
616: lv_codepath := jai_general_pkg.plot_codepath(21, lv_codepath);
617:
618: IF p_source = jai_constants.source_ar THEN
619:
620: lv_codepath := jai_general_pkg.plot_codepath(21.1, lv_codepath);
616: lv_codepath := jai_general_pkg.plot_codepath(21, lv_codepath);
617:
618: IF p_source = jai_constants.source_ar THEN
619:
620: lv_codepath := jai_general_pkg.plot_codepath(21.1, lv_codepath);
621: jai_ar_rgm_processing_pkg.get_ar_tax_disc_accnt (
622: p_receivable_application_id => p_source_document_id,
623: p_org_id => ln_org_id,/* added by ssawant for bug 5879769 */
624: p_total_disc_amount => p_discounted_amount, /* added by ssumaith - for bug# 4193633*/
630: p_process_message => p_process_message
631: );
632:
633: IF p_process_flag IN (jai_constants.expected_error, jai_constants.unexpected_error) THEN
634: lv_codepath := jai_general_pkg.plot_codepath(21.2, lv_codepath);
635: -- some problem in the above call
636: RETURN;
637: ELSIF nvl(ln_earned_discount, 0) + nvl(ln_unearned_discount, 0) <> NVL(p_discounted_amount,0) THEN
638: lv_codepath := jai_general_pkg.plot_codepath(21.3, lv_codepath);
634: lv_codepath := jai_general_pkg.plot_codepath(21.2, lv_codepath);
635: -- some problem in the above call
636: RETURN;
637: ELSIF nvl(ln_earned_discount, 0) + nvl(ln_unearned_discount, 0) <> NVL(p_discounted_amount,0) THEN
638: lv_codepath := jai_general_pkg.plot_codepath(21.3, lv_codepath);
639: p_process_flag := jai_constants.expected_error;
640: p_process_message := 'There is a discrepency in earned + unearned = discounted';
641: RETURN;
642: END IF;
644: --- following will be used for first accounting entry incase of AR Receipt Application
645: IF nvl(ln_earned_discount,0) <> 0 THEN
646: ln_discount_ccid := ln_earned_disc_accnt;
647: IF lv_charge_entry_type = jai_constants.debit THEN
648: lv_codepath := jai_general_pkg.plot_codepath(21.4, lv_codepath);
649: ln_disc_credit := null;
650: ln_disc_debit := ln_earned_discount;
651: ELSE
652: lv_codepath := jai_general_pkg.plot_codepath(21.5, lv_codepath);
648: lv_codepath := jai_general_pkg.plot_codepath(21.4, lv_codepath);
649: ln_disc_credit := null;
650: ln_disc_debit := ln_earned_discount;
651: ELSE
652: lv_codepath := jai_general_pkg.plot_codepath(21.5, lv_codepath);
653: ln_disc_credit := ln_earned_discount;
654: ln_disc_debit := null;
655: END IF;
656:
671: p_account_name => jai_cmn_rgm_recording_pkg.ap_discount_accnt
672: );
673:
674: IF ln_discount_ccid IS NULL THEN
675: lv_codepath := jai_general_pkg.plot_codepath(18, lv_codepath);
676: p_process_flag := jai_constants.expected_error;
677: p_process_message := 'Discount Account is not defined in '||p_source;
678: FND_FILE.put_line( FND_FILE.log, p_process_message); fnd_file.put_line(fnd_file.log,p_process_message);
679: FND_FILE.put_line( FND_FILE.log, ln_org_id);
690:
691: END IF;
692:
693: IF ln_disc_debit IS NOT NULL OR ln_disc_credit IS NOT NULL THEN
694: lv_codepath := jai_general_pkg.plot_codepath(21.6, lv_codepath);
695: -- make a call to post_accounting procedure
696: post_accounting(
697: p_regime_code => lv_regime_code,
698: p_tax_type => p_tax_type,
723: END IF;
724:
725: -- following entry will happen only in case of AR Transactions
726: IF nvl(ln_unearned_discount,0) <> 0 THEN
727: lv_codepath := jai_general_pkg.plot_codepath(21.7, lv_codepath);
728: ln_discount_ccid := ln_unearned_disc_accnt;
729: IF lv_charge_entry_type = jai_constants.debit THEN
730: ln_disc_credit := null;
731: ln_disc_debit := ln_unearned_discount;
762: );
763:
764: END IF;
765:
766: lv_codepath := jai_general_pkg.plot_codepath(21.8, lv_codepath);
767: END IF;
768: /* END of DISCOUNT ACCOUNTING */
769:
770:
770:
771: lv_statement := '21';
772: -- BALANCING_ENTRY
773: IF lv_balancing_entry_type = jai_constants.debit THEN
774: lv_codepath := jai_general_pkg.plot_codepath(22, lv_codepath);
775: ln_debit := p_amount + nvl(p_discounted_amount,0);
776: ln_credit := NULL;
777: ln_trx_debit := nvl(ln_trx_amount, p_amount)+ nvl(p_discounted_amount,0);
778: ln_trx_credit := null;
819: p_process_message := 'Successful';
820:
821: lv_statement := '24';
822: <
823: lv_codepath := jai_general_pkg.plot_codepath(23, lv_codepath, 'Insert_Repository_entry', 'END');
824:
825: EXCEPTION
826: WHEN OTHERS THEN
827: p_process_flag := jai_constants.unexpected_error;
825: EXCEPTION
826: WHEN OTHERS THEN
827: p_process_flag := jai_constants.unexpected_error;
828: p_process_message := 'Repository Error(Stmt:'||lv_statement||') Occured:'||SQLERRM;
829: lv_codepath := jai_general_pkg.plot_codepath(-999, lv_codepath);
830: Fnd_file.put_line( fnd_file.log, 'Error in Insert_Repository_entry. Codepath:'||lv_codepath);
831:
832: END insert_repository_entry;
833:
991: lv_message := 'Account not given';
992: RAISE_APPLICATION_ERROR( -20011, lv_message);
993: END IF;
994:
995: ln_currency_precision := jai_general_pkg.get_currency_precision(null); -- CURRENCY is INR
996:
997: -- Use of Currency Precision to round off the values when posting to GL is mandatory thing
998: ln_entered_dr := round(p_entered_dr, ln_currency_precision);
999: ln_entered_cr := round(p_entered_cr, ln_currency_precision);
1743: EXCEPTION
1744: WHEN OTHERS THEN
1745: pv_process_flag := jai_constants.unexpected_error;
1746: pv_process_message := 'insert_vat_repository_entry Error(Stmt:'||lv_statement_id||') Occured:'||SQLERRM;
1747: --lv_codepath := jai_general_pkg.plot_codepath(-999, lv_codepath);
1748: Fnd_file.put_line( fnd_file.log, 'Error in insert_vat_repository_entry. Stmt:'||lv_statement_id);
1749: END insert_vat_repository_entry;
1750:
1751:
1943: EXCEPTION
1944: WHEN OTHERS THEN
1945: pv_process_flag := jai_constants.unexpected_error;
1946: pv_process_message := 'doVatAccounting Error(Stmt:'||lv_statement_id||') Occured:'||SQLERRM;
1947: --lv_codepath := jai_general_pkg.plot_codepath(-999, lv_codepath);
1948: jai_cmn_utils_pkg.print_log('6395039.log', 'Error in doVatAccounting. Stmt:'||lv_statement_id);
1949: Fnd_file.put_line( fnd_file.log, 'Error in doVatAccounting. Stmt:'||lv_statement_id);
1950:
1951: END do_vat_accounting;