[Home] [Help]
435: from jai_ap_tds_thhold_grps
436: where threshold_grp_id = p_threshold_grp_id;
437:
438:
439: cursor c_jai_ap_tds_thhold_slabs
440: ( p_threshold_hdr_id number, p_threshold_type varchar2, p_amount number) is
441: select threshold_slab_id, threshold_type_id, from_amount, to_amount
442: from jai_ap_tds_thhold_slabs
443: where threshold_hdr_id = p_threshold_hdr_id
438:
439: cursor c_jai_ap_tds_thhold_slabs
440: ( p_threshold_hdr_id number, p_threshold_type varchar2, p_amount number) is
441: select threshold_slab_id, threshold_type_id, from_amount, to_amount
442: from jai_ap_tds_thhold_slabs
443: where threshold_hdr_id = p_threshold_hdr_id
444: and threshold_type_id in
445: ( select threshold_type_id
446: from jai_ap_tds_thhold_types
543: ln_tax_amount number;
544: ln_threshold_grp_id number;
545: lv_vendor_type_lookup_code po_vendors.vendor_type_lookup_code%type;
546: ln_threshold_hdr_id number;
547: r_jai_ap_tds_thhold_slabs c_jai_ap_tds_thhold_slabs%rowtype;
548: ln_total_invoice_amount number;
549: ln_threshold_slab_id_before number;
550: ln_threshold_slab_id_after number;
551: ln_threshold_slab_id_single number;
784: ln_total_invoice_amount);
785:
786: /* Get the threshold position before this invoice impact */
787: p_codepath := jai_general_pkg.plot_codepath(15, p_codepath); /* 15 */
788: open c_jai_ap_tds_thhold_slabs(ln_threshold_hdr_id , 'CUMULATIVE' , ln_total_invoice_amount);
789: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
790: close c_jai_ap_tds_thhold_slabs;
791:
792: ln_threshold_slab_id_before := nvl(r_jai_ap_tds_thhold_slabs.threshold_slab_id, 0);
785:
786: /* Get the threshold position before this invoice impact */
787: p_codepath := jai_general_pkg.plot_codepath(15, p_codepath); /* 15 */
788: open c_jai_ap_tds_thhold_slabs(ln_threshold_hdr_id , 'CUMULATIVE' , ln_total_invoice_amount);
789: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
790: close c_jai_ap_tds_thhold_slabs;
791:
792: ln_threshold_slab_id_before := nvl(r_jai_ap_tds_thhold_slabs.threshold_slab_id, 0);
793:
786: /* Get the threshold position before this invoice impact */
787: p_codepath := jai_general_pkg.plot_codepath(15, p_codepath); /* 15 */
788: open c_jai_ap_tds_thhold_slabs(ln_threshold_hdr_id , 'CUMULATIVE' , ln_total_invoice_amount);
789: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
790: close c_jai_ap_tds_thhold_slabs;
791:
792: ln_threshold_slab_id_before := nvl(r_jai_ap_tds_thhold_slabs.threshold_slab_id, 0);
793:
794: fnd_file.put_line(FND_FILE.LOG, '15. Threshold slab id before '||
788: open c_jai_ap_tds_thhold_slabs(ln_threshold_hdr_id , 'CUMULATIVE' , ln_total_invoice_amount);
789: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
790: close c_jai_ap_tds_thhold_slabs;
791:
792: ln_threshold_slab_id_before := nvl(r_jai_ap_tds_thhold_slabs.threshold_slab_id, 0);
793:
794: fnd_file.put_line(FND_FILE.LOG, '15. Threshold slab id before '||
795: ln_threshold_slab_id_before);
796:
796:
797: /* Get the threshold position after this invoice impact */
798: p_codepath := jai_general_pkg.plot_codepath(16, p_codepath); /* 16 */
799: /* FP Bug 6345725 - Removed the assignments for p_codepath without ja_in_general_pkg*/
800: r_jai_ap_tds_thhold_slabs := null;
801: open c_jai_ap_tds_thhold_slabs
802: (ln_threshold_hdr_id , 'CUMULATIVE' , ln_total_invoice_amount + cur_rec_section.invoice_amount);
803: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
804: close c_jai_ap_tds_thhold_slabs;
797: /* Get the threshold position after this invoice impact */
798: p_codepath := jai_general_pkg.plot_codepath(16, p_codepath); /* 16 */
799: /* FP Bug 6345725 - Removed the assignments for p_codepath without ja_in_general_pkg*/
800: r_jai_ap_tds_thhold_slabs := null;
801: open c_jai_ap_tds_thhold_slabs
802: (ln_threshold_hdr_id , 'CUMULATIVE' , ln_total_invoice_amount + cur_rec_section.invoice_amount);
803: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
804: close c_jai_ap_tds_thhold_slabs;
805:
799: /* FP Bug 6345725 - Removed the assignments for p_codepath without ja_in_general_pkg*/
800: r_jai_ap_tds_thhold_slabs := null;
801: open c_jai_ap_tds_thhold_slabs
802: (ln_threshold_hdr_id , 'CUMULATIVE' , ln_total_invoice_amount + cur_rec_section.invoice_amount);
803: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
804: close c_jai_ap_tds_thhold_slabs;
805:
806: ln_threshold_slab_id_after := nvl(r_jai_ap_tds_thhold_slabs.threshold_slab_id, 0);
807:
800: r_jai_ap_tds_thhold_slabs := null;
801: open c_jai_ap_tds_thhold_slabs
802: (ln_threshold_hdr_id , 'CUMULATIVE' , ln_total_invoice_amount + cur_rec_section.invoice_amount);
803: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
804: close c_jai_ap_tds_thhold_slabs;
805:
806: ln_threshold_slab_id_after := nvl(r_jai_ap_tds_thhold_slabs.threshold_slab_id, 0);
807:
808: /*start addition for FP bug 6345725 - check for active slabs. if there are no active*/
802: (ln_threshold_hdr_id , 'CUMULATIVE' , ln_total_invoice_amount + cur_rec_section.invoice_amount);
803: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
804: close c_jai_ap_tds_thhold_slabs;
805:
806: ln_threshold_slab_id_after := nvl(r_jai_ap_tds_thhold_slabs.threshold_slab_id, 0);
807:
808: /*start addition for FP bug 6345725 - check for active slabs. if there are no active*/
809: /*slabs throw an error message*/
810: ln_check_slab_exists := NULL;
837:
838: /* Check for Single Invoice threshold if cumulative has not been reached */
839: if lv_generate_all_invoices = 'N' then
840: /* Cumulative threshold not reached */
841: r_jai_ap_tds_thhold_slabs := null;
842: open c_jai_ap_tds_thhold_slabs(ln_threshold_hdr_id , 'SINGLE' , cur_rec_section.invoice_amount);
843: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
844: close c_jai_ap_tds_thhold_slabs;
845: ln_threshold_slab_id_single := nvl(r_jai_ap_tds_thhold_slabs.threshold_slab_id, 0);
838: /* Check for Single Invoice threshold if cumulative has not been reached */
839: if lv_generate_all_invoices = 'N' then
840: /* Cumulative threshold not reached */
841: r_jai_ap_tds_thhold_slabs := null;
842: open c_jai_ap_tds_thhold_slabs(ln_threshold_hdr_id , 'SINGLE' , cur_rec_section.invoice_amount);
843: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
844: close c_jai_ap_tds_thhold_slabs;
845: ln_threshold_slab_id_single := nvl(r_jai_ap_tds_thhold_slabs.threshold_slab_id, 0);
846: end if;
839: if lv_generate_all_invoices = 'N' then
840: /* Cumulative threshold not reached */
841: r_jai_ap_tds_thhold_slabs := null;
842: open c_jai_ap_tds_thhold_slabs(ln_threshold_hdr_id , 'SINGLE' , cur_rec_section.invoice_amount);
843: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
844: close c_jai_ap_tds_thhold_slabs;
845: ln_threshold_slab_id_single := nvl(r_jai_ap_tds_thhold_slabs.threshold_slab_id, 0);
846: end if;
847:
840: /* Cumulative threshold not reached */
841: r_jai_ap_tds_thhold_slabs := null;
842: open c_jai_ap_tds_thhold_slabs(ln_threshold_hdr_id , 'SINGLE' , cur_rec_section.invoice_amount);
843: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
844: close c_jai_ap_tds_thhold_slabs;
845: ln_threshold_slab_id_single := nvl(r_jai_ap_tds_thhold_slabs.threshold_slab_id, 0);
846: end if;
847:
848: /* Loop and generate invoices */
841: r_jai_ap_tds_thhold_slabs := null;
842: open c_jai_ap_tds_thhold_slabs(ln_threshold_hdr_id , 'SINGLE' , cur_rec_section.invoice_amount);
843: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
844: close c_jai_ap_tds_thhold_slabs;
845: ln_threshold_slab_id_single := nvl(r_jai_ap_tds_thhold_slabs.threshold_slab_id, 0);
846: end if;
847:
848: /* Loop and generate invoices */
849:
3340: AND pan_no = p_pan_num
3341: AND section_type = p_section_type
3342: AND section_code = p_section_code;
3343:
3344: CURSOR c_jai_ap_tds_thhold_slabs( p_threshold_hdr_id NUMBER,
3345: p_threshold_type VARCHAR2,
3346: p_amount NUMBER)
3347: IS
3348: SELECT threshold_slab_id, threshold_type_id, from_amount, to_amount, tax_rate
3345: p_threshold_type VARCHAR2,
3346: p_amount NUMBER)
3347: IS
3348: SELECT threshold_slab_id, threshold_type_id, from_amount, to_amount, tax_rate
3349: FROM jai_ap_tds_thhold_slabs
3350: WHERE threshold_hdr_id = p_threshold_hdr_id
3351: AND threshold_type_id in
3352: ( SELECT threshold_type_id
3353: FROM jai_ap_tds_thhold_types
3360: ORDER BY from_amount asc;
3361:
3362: r_get_threshold_grp_dtl c_get_threshold_grp_dtl%ROWTYPE;
3363: ln_effective_invoice_amt NUMBER;
3364: r_jai_ap_tds_thhold_slabs c_jai_ap_tds_thhold_slabs%ROWTYPE;
3365: lv_threshold_type jai_ap_tds_thhold_types.threshold_type%TYPE;
3366:
3367: BEGIN
3368: IF p_threshold_grp_id IS NULL THEN
3392:
3393: lv_threshold_type := 'CUMULATIVE';
3394:
3395: --check if the current amount falls in the cumulative threshold
3396: OPEN c_jai_ap_tds_thhold_slabs(p_threshold_hdr_id,
3397: lv_threshold_type,
3398: ln_effective_invoice_amt);
3399: FETCH c_jai_ap_tds_thhold_slabs INTO r_jai_ap_tds_thhold_slabs;
3400: CLOSE c_jai_ap_tds_thhold_slabs;
3395: --check if the current amount falls in the cumulative threshold
3396: OPEN c_jai_ap_tds_thhold_slabs(p_threshold_hdr_id,
3397: lv_threshold_type,
3398: ln_effective_invoice_amt);
3399: FETCH c_jai_ap_tds_thhold_slabs INTO r_jai_ap_tds_thhold_slabs;
3400: CLOSE c_jai_ap_tds_thhold_slabs;
3401:
3402: IF r_jai_ap_tds_thhold_slabs.threshold_slab_id IS NULL THEN
3403:
3396: OPEN c_jai_ap_tds_thhold_slabs(p_threshold_hdr_id,
3397: lv_threshold_type,
3398: ln_effective_invoice_amt);
3399: FETCH c_jai_ap_tds_thhold_slabs INTO r_jai_ap_tds_thhold_slabs;
3400: CLOSE c_jai_ap_tds_thhold_slabs;
3401:
3402: IF r_jai_ap_tds_thhold_slabs.threshold_slab_id IS NULL THEN
3403:
3404: lv_threshold_type := 'SINGLE';
3398: ln_effective_invoice_amt);
3399: FETCH c_jai_ap_tds_thhold_slabs INTO r_jai_ap_tds_thhold_slabs;
3400: CLOSE c_jai_ap_tds_thhold_slabs;
3401:
3402: IF r_jai_ap_tds_thhold_slabs.threshold_slab_id IS NULL THEN
3403:
3404: lv_threshold_type := 'SINGLE';
3405:
3406: --check if the current amount falls in the single threshold
3403:
3404: lv_threshold_type := 'SINGLE';
3405:
3406: --check if the current amount falls in the single threshold
3407: OPEN c_jai_ap_tds_thhold_slabs(p_threshold_hdr_id,
3408: lv_threshold_type,
3409: 99999999999999);
3410: FETCH c_jai_ap_tds_thhold_slabs INTO r_jai_ap_tds_thhold_slabs;
3411: CLOSE c_jai_ap_tds_thhold_slabs;
3406: --check if the current amount falls in the single threshold
3407: OPEN c_jai_ap_tds_thhold_slabs(p_threshold_hdr_id,
3408: lv_threshold_type,
3409: 99999999999999);
3410: FETCH c_jai_ap_tds_thhold_slabs INTO r_jai_ap_tds_thhold_slabs;
3411: CLOSE c_jai_ap_tds_thhold_slabs;
3412: END IF;
3413:
3414: p_threshold_slab_id := r_jai_ap_tds_thhold_slabs.threshold_slab_id;
3407: OPEN c_jai_ap_tds_thhold_slabs(p_threshold_hdr_id,
3408: lv_threshold_type,
3409: 99999999999999);
3410: FETCH c_jai_ap_tds_thhold_slabs INTO r_jai_ap_tds_thhold_slabs;
3411: CLOSE c_jai_ap_tds_thhold_slabs;
3412: END IF;
3413:
3414: p_threshold_slab_id := r_jai_ap_tds_thhold_slabs.threshold_slab_id;
3415: p_threshold_type := lv_threshold_type;
3410: FETCH c_jai_ap_tds_thhold_slabs INTO r_jai_ap_tds_thhold_slabs;
3411: CLOSE c_jai_ap_tds_thhold_slabs;
3412: END IF;
3413:
3414: p_threshold_slab_id := r_jai_ap_tds_thhold_slabs.threshold_slab_id;
3415: p_threshold_type := lv_threshold_type;
3416:
3417: EXCEPTION
3418: WHEN OTHERS THEN
3445: SELECT b.tax_rate,
3446: b.from_amount,
3447: a.tax_id
3448: FROM jai_ap_tds_thhold_taxes a,
3449: jai_ap_tds_thhold_slabs b
3450: WHERE a.threshold_slab_id = b.threshold_slab_id
3451: AND a.operating_unit_id = p_org_id
3452: AND b.threshold_slab_id = p_threshold_slab_id;
3453: