2642: )
2643: and p_accounting_date between start_date and end_date;*/
2644: -------------------------------------------------------------------------
2645: --Comment by Zhiwei Hou on 20120111 end
2646: cursor c_gl_sets_of_books(cp_set_of_books_id number) is
2647: select currency_code
2648: from gl_sets_of_books
2649: where set_of_books_id = cp_set_of_books_id;
2650:
2644: -------------------------------------------------------------------------
2645: --Comment by Zhiwei Hou on 20120111 end
2646: cursor c_gl_sets_of_books(cp_set_of_books_id number) is
2647: select currency_code
2648: from gl_sets_of_books
2649: where set_of_books_id = cp_set_of_books_id;
2650:
2651: /*Bug 5751783. Selected non-rounded value for calculation*/
2652:
2749: --Addec by Jia for FP Bug#7431371, End
2750:
2751: ln_prepayment_app_amt number :=0; --xiao for Bug#6596019
2752: r_jai_ap_tds_thhold_grps c_jai_ap_tds_thhold_grps%rowtype;
2753: r_gl_sets_of_books c_gl_sets_of_books%rowtype;
2754: r_ja_in_tax_codes c_ja_in_tax_codes%rowtype;
2755:
2756: ln_count number:= 0;
2757: ln_cnt_already_processed number:= 0;
3316: END IF; -- p_call_from = G_CALL_FROM_ROLLBACK --Added by Chong for Bug#13802244 2012/09/17
3317:
3318: p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
3319:
3320: open c_gl_sets_of_books(p_set_of_books_id);
3321: fetch c_gl_sets_of_books into r_gl_sets_of_books;
3322: close c_gl_sets_of_books;
3323:
3324: if r_gl_sets_of_books.currency_code <> p_invoice_currency_code then
3317:
3318: p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
3319:
3320: open c_gl_sets_of_books(p_set_of_books_id);
3321: fetch c_gl_sets_of_books into r_gl_sets_of_books;
3322: close c_gl_sets_of_books;
3323:
3324: if r_gl_sets_of_books.currency_code <> p_invoice_currency_code then
3325: /* Foreign currency invoice */
3318: p_codepath := jai_general_pkg.plot_codepath(6, p_codepath); /* 6 */
3319:
3320: open c_gl_sets_of_books(p_set_of_books_id);
3321: fetch c_gl_sets_of_books into r_gl_sets_of_books;
3322: close c_gl_sets_of_books;
3323:
3324: if r_gl_sets_of_books.currency_code <> p_invoice_currency_code then
3325: /* Foreign currency invoice */
3326: p_codepath := jai_general_pkg.plot_codepath(6.1, p_codepath); /* 6.1 */
3320: open c_gl_sets_of_books(p_set_of_books_id);
3321: fetch c_gl_sets_of_books into r_gl_sets_of_books;
3322: close c_gl_sets_of_books;
3323:
3324: if r_gl_sets_of_books.currency_code <> p_invoice_currency_code then
3325: /* Foreign currency invoice */
3326: p_codepath := jai_general_pkg.plot_codepath(6.1, p_codepath); /* 6.1 */
3327: ln_exchange_rate := p_exchange_rate;
3328: end if;
5904: from JAI_CMN_TAXES_ALL
5905: where tax_id = pn_tax_id;
5906:
5907:
5908: cursor c_gl_sets_of_books(cp_set_of_books_id number) is
5909: select currency_code
5910: from gl_sets_of_books
5911: where set_of_books_id = cp_set_of_books_id;
5912:
5906:
5907:
5908: cursor c_gl_sets_of_books(cp_set_of_books_id number) is
5909: select currency_code
5910: from gl_sets_of_books
5911: where set_of_books_id = cp_set_of_books_id;
5912:
5913: cursor c_get_ja_in_ap_inv_id is
5914: select to_char(JAI_AP_TDS_THHOLD_TRXS_S1.nextval)--to_char(JAI_AP_TDS_INVOICE_NUM_S.nextval)commented by rchandan for bug#4487676
5946: r_ap_invoices_all c_ap_invoices_all%rowtype;
5947: r_ja_in_tax_codes c_ja_in_tax_codes%rowtype;
5948: r_po_vendor_sites_all c_po_vendor_sites_all%rowtype;
5949: r_po_vendors c_po_vendors%rowtype;
5950: r_gl_sets_of_books c_gl_sets_of_books%rowtype;
5951: r_ap_payment_schedules_all c_ap_payment_schedules_all%rowtype;
5952:
5953:
5954: lv_source varchar2(30); --File.Sql.35 Cbabu := 'TDS';
6065: open c_po_vendor_sites_all(r_ja_in_tax_codes.vendor_id, r_ja_in_tax_codes.vendor_site_id);
6066: fetch c_po_vendor_sites_all into r_po_vendor_sites_all;
6067: close c_po_vendor_sites_all;
6068:
6069: open c_gl_sets_of_books(r_ap_invoices_all.set_of_books_id);
6070: fetch c_gl_sets_of_books into r_gl_sets_of_books;
6071: close c_gl_sets_of_books;
6072:
6073: /*Bug # 7410219 - Derive the Section Name*/
6066: fetch c_po_vendor_sites_all into r_po_vendor_sites_all;
6067: close c_po_vendor_sites_all;
6068:
6069: open c_gl_sets_of_books(r_ap_invoices_all.set_of_books_id);
6070: fetch c_gl_sets_of_books into r_gl_sets_of_books;
6071: close c_gl_sets_of_books;
6072:
6073: /*Bug # 7410219 - Derive the Section Name*/
6074: if (r_ja_in_tax_codes.section_type = 'TDS_SECTION') then
6067: close c_po_vendor_sites_all;
6068:
6069: open c_gl_sets_of_books(r_ap_invoices_all.set_of_books_id);
6070: fetch c_gl_sets_of_books into r_gl_sets_of_books;
6071: close c_gl_sets_of_books;
6072:
6073: /*Bug # 7410219 - Derive the Section Name*/
6074: if (r_ja_in_tax_codes.section_type = 'TDS_SECTION') then
6075: --lv_section_name := 'TDS'; --commented by Chong for bug#16048702 20130130
6311: p_gl_date => ld_accounting_date, --Added by Bgowrava for Bug#9186263
6312: p_vendor_id => r_ja_in_tax_codes.vendor_id,
6313: p_vendor_site_id => r_ja_in_tax_codes.vendor_site_id,
6314: p_invoice_amount => ln_invoice_to_tds_amount,
6315: p_invoice_currency_code => r_gl_sets_of_books.currency_code,
6316: p_exchange_rate => null,
6317: p_exchange_rate_type => null,
6318: p_exchange_date => null,
6319: p_terms_id => ln_terms_id,
6376: /* Bug 12965614. Added by Avanija
6377: * Added the following condition to handle for prepayment unapplication for foreign currency invoices.
6378: */
6379: IF pv_tds_event = 'PREPAYMENT UNAPPLICATION' THEN --2
6380: IF r_ap_invoices_all.invoice_currency_code <> r_gl_sets_of_books.currency_code THEN --3
6381: ln_invoice_to_vendor_amount := round( ln_invoice_to_vendor_amount, g_inr_currency_rounding);
6382: IF trunc(pd_creation_date) >= trunc(jai_ap_tds_generation_pkg.gd_tds_rounding_effective_date) THEN
6383: ln_invoice_to_vendor_amount := get_rnded_value(ln_invoice_to_vendor_amount);
6384: END IF;
6386: END IF; --3
6387:
6388: ELSE --2
6389:
6390: if r_ap_invoices_all.invoice_currency_code <> r_gl_sets_of_books.currency_code then
6391: /*START, Bgowrava for Bug#8995604 , Adding below IF statement to round the INR TDS CM invoice to
6392: the TDS rounding factor before converting it to a foreign currency CM*/
6393: ln_invoice_to_vendor_amount := round( ln_invoice_to_vendor_amount, g_inr_currency_rounding);
6394: IF trunc(pd_creation_date) >= trunc(jai_ap_tds_generation_pkg.gd_tds_rounding_effective_date)
6612: ln_tds_rnding_factor := 0;
6613: ln_tds_rnded_amt := pn_tax_amount;
6614: /* Added the below if condition for bug 12965614 */
6615: IF pv_tds_event = 'PREPAYMENT UNAPPLICATION' THEN --2
6616: IF r_ap_invoices_all.invoice_currency_code <> r_gl_sets_of_books.currency_code THEN --3
6617: ln_tds_rnded_amt := ROUND(pn_calc_tax_amount , g_inr_currency_rounding);
6618: IF (trunc(pd_creation_date) >= trunc(jai_ap_tds_generation_pkg.gd_tds_rounding_effective_date)) THEN --4
6619: ln_tds_rnding_factor := jai_ap_tds_generation_pkg.gn_tds_rounding_factor;
6620: ln_tds_rnded_amt := get_rnded_value(ln_tds_rnded_amt);
6624: ELSE --2
6625: /*IF pv_tds_event NOT IN
6626: -- Bug 7280925. commented by Lakshmi Gopalsami ('INVOICE CANCEL',
6627: ('PREPAYMENT UNAPPLICATION') THEN */
6628: IF r_ap_invoices_all.invoice_currency_code = r_gl_sets_of_books.currency_code THEN
6629: ln_tds_rnded_amt := ROUND(pn_tax_amount , g_inr_currency_rounding);
6630: --moved this if-endif block from below to here for bug#8995604
6631: ELSE
6632: ln_tds_rnded_amt := ROUND(pn_tax_amount , g_inr_currency_rounding);
6706: r_ja_in_tax_codes.vendor_id ,
6707: r_ja_in_tax_codes.vendor_site_id ,
6708: lv_invoice_to_tds_num ,
6709: lv_invoice_to_tds_type ,
6710: r_gl_sets_of_books.currency_code ,
6711: ln_invoice_to_tds_amount ,
6712: r_ap_invoices_all.vendor_id ,
6713: r_ap_invoices_all.vendor_site_id ,
6714: lv_invoice_to_vendor_num ,
6823: from JAI_CMN_TAXES_ALL
6824: where tax_id = pn_tax_id;
6825:
6826:
6827: cursor c_gl_sets_of_books(cp_set_of_books_id number) is
6828: select currency_code
6829: from gl_sets_of_books
6830: where set_of_books_id = cp_set_of_books_id;
6831:
6825:
6826:
6827: cursor c_gl_sets_of_books(cp_set_of_books_id number) is
6828: select currency_code
6829: from gl_sets_of_books
6830: where set_of_books_id = cp_set_of_books_id;
6831:
6832: cursor c_get_ja_in_ap_inv_id is
6833: select to_char(JAI_AP_TDS_THHOLD_TRXS_S1.nextval)--to_char(JAI_AP_TDS_INVOICE_NUM_S.nextval)commented by rchandan for bug#4487676
6841: r_ap_invoices_all c_ap_invoices_all%rowtype;
6842: r_ja_in_tax_codes c_ja_in_tax_codes%rowtype;
6843: r_po_vendor_sites_all c_po_vendor_sites_all%rowtype;
6844: r_po_vendors c_po_vendors%rowtype;
6845: r_gl_sets_of_books c_gl_sets_of_books%rowtype;
6846: r_ap_payment_schedules_all c_ap_payment_schedules_all%rowtype;
6847:
6848:
6849: lv_source varchar2(30); --File.Sql.35 Cbabu := 'TDS';
7106: || moved this up from the under the cursor - c_po_vendor_sites_all by Ramananda for Bug#4562793
7107: */
7108:
7109:
7110: open c_gl_sets_of_books(r_ap_invoices_all.set_of_books_id);
7111: fetch c_gl_sets_of_books into r_gl_sets_of_books;
7112: close c_gl_sets_of_books;
7113:
7114: /*Bug # 7410219 - Derive the Section Name*/
7107: */
7108:
7109:
7110: open c_gl_sets_of_books(r_ap_invoices_all.set_of_books_id);
7111: fetch c_gl_sets_of_books into r_gl_sets_of_books;
7112: close c_gl_sets_of_books;
7113:
7114: /*Bug # 7410219 - Derive the Section Name*/
7115: if (pv_section_type = 'TDS_SECTION') then
7108:
7109:
7110: open c_gl_sets_of_books(r_ap_invoices_all.set_of_books_id);
7111: fetch c_gl_sets_of_books into r_gl_sets_of_books;
7112: close c_gl_sets_of_books;
7113:
7114: /*Bug # 7410219 - Derive the Section Name*/
7115: if (pv_section_type = 'TDS_SECTION') then
7116: --lv_section_name := 'TDS'; --commented by Chong for bug#16048702 20130130
7318: --------------------------------------------------------------------------------------------
7319: if lv_invoice_to_vendor_num is not null and lv_invoice_to_vendor_type is not null then
7320:
7321: IF pv_tds_event = 'PREPAYMENT UNAPPLICATION' THEN --2
7322: IF r_ap_invoices_all.invoice_currency_code <> r_gl_sets_of_books.currency_code THEN --3
7323: ln_invoice_to_vendor_amount := round( ln_invoice_to_vendor_amount, g_inr_currency_rounding);
7324: IF trunc(pd_creation_date) >= trunc(jai_ap_dtc_generation_pkg.gd_tds_rounding_effective_date) THEN
7325: ln_invoice_to_vendor_amount := get_rnded_value(ln_invoice_to_vendor_amount);
7326: END IF;
7328: END IF; --3
7329:
7330: ELSE --2
7331:
7332: if r_ap_invoices_all.invoice_currency_code <> r_gl_sets_of_books.currency_code then
7333: /*START, Bgowrava for Bug#8995604 , Adding below IF statement to round the INR TDS CM invoice to
7334: the TDS rounding factor before converting it to a foreign currency CM*/
7335: ln_invoice_to_vendor_amount := round( ln_invoice_to_vendor_amount, g_inr_currency_rounding);
7336: IF trunc(pd_creation_date) >= trunc(jai_ap_dtc_generation_pkg.gd_tds_rounding_effective_date)
7491: p_gl_date => ld_accounting_date, --Added by Bgowrava for Bug#9186263
7492: p_vendor_id => ln_vendor_id,
7493: p_vendor_site_id => ln_vendor_site_id,
7494: p_invoice_amount => ln_invoice_to_tds_amount,
7495: p_invoice_currency_code => r_gl_sets_of_books.currency_code,
7496: p_exchange_rate => null,
7497: p_exchange_rate_type => null,
7498: p_exchange_date => null,
7499: p_terms_id => ln_terms_id,
7814: ln_tds_rnding_factor := 0;
7815: ln_tds_rnded_amt := pn_tax_amount;
7816: /* Added the below if condition for bug 12965614 */
7817: IF pv_tds_event = 'PREPAYMENT UNAPPLICATION' THEN --2
7818: IF r_ap_invoices_all.invoice_currency_code <> r_gl_sets_of_books.currency_code THEN --3
7819: ln_tds_rnded_amt := ROUND(pn_calc_tax_amount , g_inr_currency_rounding);
7820: IF (trunc(pd_creation_date) >= trunc(jai_ap_dtc_generation_pkg.gd_tds_rounding_effective_date)) THEN --4
7821: ln_tds_rnding_factor := jai_ap_dtc_generation_pkg.gn_tds_rounding_factor;
7822: ln_tds_rnded_amt := get_rnded_value(ln_tds_rnded_amt);
7826: ELSE --2
7827: /*IF pv_tds_event NOT IN
7828: -- Bug 7280925. commented by Lakshmi Gopalsami ('INVOICE CANCEL',
7829: ('PREPAYMENT UNAPPLICATION') THEN */
7830: IF r_ap_invoices_all.invoice_currency_code = r_gl_sets_of_books.currency_code THEN
7831: ln_tds_rnded_amt := ROUND(pn_tax_amount , g_inr_currency_rounding);
7832: --moved this if-endif block from below to here for bug#8995604
7833: ELSE
7834: ln_tds_rnded_amt := ROUND(pn_tax_amount , g_inr_currency_rounding);
7911: ln_vendor_id ,
7912: ln_vendor_site_id ,
7913: lv_invoice_to_tds_num ,
7914: lv_invoice_to_tds_type ,
7915: r_gl_sets_of_books.currency_code ,
7916: ln_invoice_to_tds_amount ,
7917: r_ap_invoices_all.vendor_id ,
7918: r_ap_invoices_all.vendor_site_id ,
7919: lv_invoice_to_vendor_num ,
10352: and jattt.tds_rollbacked is null
10353: --and jcta.tax_account_id = cn_tax_account; --Change to tax_id by Chong for bug#16414088 20130320
10354: and jcta.tax_id = cn_tax_id; --Change to tax_id by Chong for bug#16414088 20130320
10355:
10356: cursor c_gl_sets_of_books(cp_set_of_books_id number) is
10357: select currency_code
10358: from gl_sets_of_books
10359: where set_of_books_id = cp_set_of_books_id;
10360:
10354: and jcta.tax_id = cn_tax_id; --Change to tax_id by Chong for bug#16414088 20130320
10355:
10356: cursor c_gl_sets_of_books(cp_set_of_books_id number) is
10357: select currency_code
10358: from gl_sets_of_books
10359: where set_of_books_id = cp_set_of_books_id;
10360:
10361: cursor c_get_ja_in_ap_inv_id is
10362: select to_char(JAI_AP_TDS_THHOLD_TRXS_S1.nextval)--to_char(JAI_AP_TDS_INVOICE_NUM_S.nextval)commented by rchandan for bug#4487676
10370: r_ap_invoices_all c_ap_invoices_all%rowtype;
10371: r_ja_in_tax_codes c_ja_in_tax_codes%rowtype;
10372: r_po_vendor_sites_all c_po_vendor_sites_all%rowtype;
10373: r_po_vendors c_po_vendors%rowtype;
10374: r_gl_sets_of_books c_gl_sets_of_books%rowtype;
10375: r_ap_payment_schedules_all c_ap_payment_schedules_all%rowtype;
10376:
10377:
10378: lv_source varchar2(30); --File.Sql.35 Cbabu := 'TDS';
10517: fetch c_ap_invoices_all into r_ap_invoices_all;
10518: close c_ap_invoices_all;
10519:
10520:
10521: open c_gl_sets_of_books(r_ap_invoices_all.set_of_books_id);
10522: fetch c_gl_sets_of_books into r_gl_sets_of_books;
10523: close c_gl_sets_of_books;
10524:
10525: /*Bug # 7410219 - Derive the Section Name*/
10518: close c_ap_invoices_all;
10519:
10520:
10521: open c_gl_sets_of_books(r_ap_invoices_all.set_of_books_id);
10522: fetch c_gl_sets_of_books into r_gl_sets_of_books;
10523: close c_gl_sets_of_books;
10524:
10525: /*Bug # 7410219 - Derive the Section Name*/
10526: if (pv_section_type = 'TDS_SECTION') then
10519:
10520:
10521: open c_gl_sets_of_books(r_ap_invoices_all.set_of_books_id);
10522: fetch c_gl_sets_of_books into r_gl_sets_of_books;
10523: close c_gl_sets_of_books;
10524:
10525: /*Bug # 7410219 - Derive the Section Name*/
10526: if (pv_section_type = 'TDS_SECTION') then
10527: lv_section_name := 'TDS';
10629: END IF ; -- pv_tds_event not in
10630: if lv_invoice_to_vendor_num is not null and lv_invoice_to_vendor_type is not null then
10631:
10632: IF pv_tds_event = 'PREPAYMENT UNAPPLICATION' THEN --2
10633: IF r_ap_invoices_all.invoice_currency_code <> r_gl_sets_of_books.currency_code THEN --3
10634: ln_invoice_to_vendor_amount := round( ln_invoice_to_vendor_amount, g_inr_currency_rounding);
10635: IF trunc(pd_creation_date) >= trunc(jai_ap_dtc_generation_pkg.gd_tds_rounding_effective_date) THEN
10636: ln_invoice_to_vendor_amount := get_rnded_value(ln_invoice_to_vendor_amount);
10637: END IF;
10639: END IF; --3
10640:
10641: ELSE --2
10642:
10643: if r_ap_invoices_all.invoice_currency_code <> r_gl_sets_of_books.currency_code then
10644: /*START, Bgowrava for Bug#8995604 , Adding below IF statement to round the INR TDS CM invoice to
10645: the TDS rounding factor before converting it to a foreign currency CM*/
10646: ln_invoice_to_vendor_amount := round( ln_invoice_to_vendor_amount, g_inr_currency_rounding);
10647: IF trunc(pd_creation_date) >= trunc(jai_ap_dtc_generation_pkg.gd_tds_rounding_effective_date)
10775: p_gl_date => ld_accounting_date, --Added by Bgowrava for Bug#9186263
10776: p_vendor_id => ln_vendor_id,
10777: p_vendor_site_id => ln_vendor_site_id,
10778: p_invoice_amount => ln_invoice_to_tds_amount,
10779: p_invoice_currency_code => r_gl_sets_of_books.currency_code,
10780: p_exchange_rate => null,
10781: p_exchange_rate_type => null,
10782: p_exchange_date => null,
10783: p_terms_id => ln_terms_id,
10994: ln_tds_rnding_factor := 0;
10995: ln_tds_rnded_amt := pn_tax_amount;
10996: /* Added the below if condition for bug 12965614 */
10997: IF pv_tds_event = 'PREPAYMENT UNAPPLICATION' THEN --2
10998: IF r_ap_invoices_all.invoice_currency_code <> r_gl_sets_of_books.currency_code THEN --3
10999: ln_tds_rnded_amt := ROUND(pn_calc_tax_amount , jai_ap_dtc_generation_pkg.g_inr_currency_rounding);
11000: IF (trunc(pd_creation_date) >= trunc(jai_ap_dtc_generation_pkg.gd_tds_rounding_effective_date)) THEN --4
11001: ln_tds_rnding_factor := jai_ap_dtc_generation_pkg.gn_tds_rounding_factor;
11002: ln_tds_rnded_amt := get_rnded_value(ln_tds_rnded_amt);
11007: ELSE --2
11008: /*IF pv_tds_event NOT IN
11009: -- Bug 7280925. commented by Lakshmi Gopalsami ('INVOICE CANCEL',
11010: ('PREPAYMENT UNAPPLICATION') THEN */
11011: IF r_ap_invoices_all.invoice_currency_code = r_gl_sets_of_books.currency_code THEN
11012: ln_tds_rnded_amt := ROUND(pn_tax_amount , jai_ap_dtc_generation_pkg.g_inr_currency_rounding);
11013: --moved this if-endif block from below to here for bug#8995604
11014: ELSE
11015: ln_tds_rnded_amt := ROUND(pn_tax_amount , jai_ap_dtc_generation_pkg.g_inr_currency_rounding);
11083: ln_vendor_id ,
11084: ln_vendor_site_id ,
11085: lv_invoice_to_tds_num ,
11086: lv_invoice_to_tds_type ,
11087: r_gl_sets_of_books.currency_code ,
11088: ln_invoice_to_tds_amount ,
11089: r_ap_invoices_all.vendor_id ,
11090: r_ap_invoices_all.vendor_site_id ,
11091: lv_invoice_to_vendor_num ,