[Home] [Help]
1108: total_invoice_amount
1109: from jai_ap_tds_thhold_grps
1110: where threshold_grp_id = p_threshold_grp_id;
1111:
1112: cursor c_jai_ap_tds_thhold_slabs
1113: ( p_threshold_hdr_id number, p_threshold_type varchar2, p_amount number) is
1114: select threshold_slab_id, threshold_type_id, from_amount, to_amount
1115: from jai_ap_tds_thhold_slabs
1116: where threshold_hdr_id = p_threshold_hdr_id
1111:
1112: cursor c_jai_ap_tds_thhold_slabs
1113: ( p_threshold_hdr_id number, p_threshold_type varchar2, p_amount number) is
1114: select threshold_slab_id, threshold_type_id, from_amount, to_amount
1115: from jai_ap_tds_thhold_slabs
1116: where threshold_hdr_id = p_threshold_hdr_id
1117: and threshold_type_id in
1118: ( select threshold_type_id
1119: from jai_ap_tds_thhold_types
1179: and vendor_pan_num = p_pan_no
1180: and fin_year = p_fin_year;
1181:
1182: r_get_threshold c_get_threshold%rowtype;
1183: r_jai_ap_tds_thhold_slabs c_jai_ap_tds_thhold_slabs%rowtype;
1184: r_jai_ap_tds_thhold_taxes c_jai_ap_tds_thhold_taxes%rowtype;
1185:
1186: lv_pan_no jai_ap_tds_vendor_hdrs.pan_no%type;
1187: lv_tan_no jai_ap_tds_org_tan_v.org_tan_num %type;--- JAI_AP_TDS_ORG_TANS is changed to view jai_ap_tds_org_tan_v 4323338
1262: ln_total_invoice_amount := nvl(ln_total_invoice_amount, 0 ) ;
1263:
1264: p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
1265: /* Check if Cumulative threshold is reached */
1266: open c_jai_ap_tds_thhold_slabs
1267: (r_get_threshold.threshold_hdr_id, 'CUMULATIVE', ln_total_invoice_amount + ln_amount + ln_amount_for_redefault);
1268: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
1269: close c_jai_ap_tds_thhold_slabs;
1270:
1264: p_codepath := jai_general_pkg.plot_codepath(7, p_codepath); /* 7 */
1265: /* Check if Cumulative threshold is reached */
1266: open c_jai_ap_tds_thhold_slabs
1267: (r_get_threshold.threshold_hdr_id, 'CUMULATIVE', ln_total_invoice_amount + ln_amount + ln_amount_for_redefault);
1268: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
1269: close c_jai_ap_tds_thhold_slabs;
1270:
1271: p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
1272:
1265: /* Check if Cumulative threshold is reached */
1266: open c_jai_ap_tds_thhold_slabs
1267: (r_get_threshold.threshold_hdr_id, 'CUMULATIVE', ln_total_invoice_amount + ln_amount + ln_amount_for_redefault);
1268: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
1269: close c_jai_ap_tds_thhold_slabs;
1270:
1271: p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
1272:
1273: p_cumulative_threshold_slab_id := r_jai_ap_tds_thhold_slabs.threshold_slab_id;
1269: close c_jai_ap_tds_thhold_slabs;
1270:
1271: p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
1272:
1273: p_cumulative_threshold_slab_id := r_jai_ap_tds_thhold_slabs.threshold_slab_id;
1274:
1275: if ln_total_invoice_amount >= r_jai_ap_tds_thhold_slabs.from_amount then
1276: /* Cumulative threshold amount is already reached */
1277: p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9 */
1271: p_codepath := jai_general_pkg.plot_codepath(8, p_codepath); /* 8 */
1272:
1273: p_cumulative_threshold_slab_id := r_jai_ap_tds_thhold_slabs.threshold_slab_id;
1274:
1275: if ln_total_invoice_amount >= r_jai_ap_tds_thhold_slabs.from_amount then
1276: /* Cumulative threshold amount is already reached */
1277: p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9 */
1278: p_cumulative_threshold_stage := 'AFTER THRESHOLD';
1279:
1276: /* Cumulative threshold amount is already reached */
1277: p_codepath := jai_general_pkg.plot_codepath(9, p_codepath); /* 9 */
1278: p_cumulative_threshold_stage := 'AFTER THRESHOLD';
1279:
1280: elsif (ln_total_invoice_amount + ln_amount + ln_amount_for_redefault) >= r_jai_ap_tds_thhold_slabs.from_amount then
1281:
1282: /* Threshold reached with this transaction */
1283: p_codepath := jai_general_pkg.plot_codepath(10, p_codepath); /* 10 */
1284: p_cumulative_threshold_stage := 'AT THRESHOLD';
1289:
1290: /* Cumulative threshold is not reached, default the tax id anyway but
1291: check for SINGLE invoice threshold. This has to be checked with only invoice amount */
1292:
1293: r_jai_ap_tds_thhold_slabs:= null;
1294: p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11 */
1295: open c_jai_ap_tds_thhold_slabs(r_get_threshold.threshold_hdr_id, 'SINGLE', ln_amount + ln_amount_for_redefault);
1296: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
1297: close c_jai_ap_tds_thhold_slabs;
1291: check for SINGLE invoice threshold. This has to be checked with only invoice amount */
1292:
1293: r_jai_ap_tds_thhold_slabs:= null;
1294: p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11 */
1295: open c_jai_ap_tds_thhold_slabs(r_get_threshold.threshold_hdr_id, 'SINGLE', ln_amount + ln_amount_for_redefault);
1296: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
1297: close c_jai_ap_tds_thhold_slabs;
1298:
1299: if ln_amount + ln_amount_for_redefault >= r_jai_ap_tds_thhold_slabs.from_amount then
1292:
1293: r_jai_ap_tds_thhold_slabs:= null;
1294: p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11 */
1295: open c_jai_ap_tds_thhold_slabs(r_get_threshold.threshold_hdr_id, 'SINGLE', ln_amount + ln_amount_for_redefault);
1296: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
1297: close c_jai_ap_tds_thhold_slabs;
1298:
1299: if ln_amount + ln_amount_for_redefault >= r_jai_ap_tds_thhold_slabs.from_amount then
1300: /* Cumulative threshold amount is reached */
1293: r_jai_ap_tds_thhold_slabs:= null;
1294: p_codepath := jai_general_pkg.plot_codepath(11, p_codepath); /* 11 */
1295: open c_jai_ap_tds_thhold_slabs(r_get_threshold.threshold_hdr_id, 'SINGLE', ln_amount + ln_amount_for_redefault);
1296: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
1297: close c_jai_ap_tds_thhold_slabs;
1298:
1299: if ln_amount + ln_amount_for_redefault >= r_jai_ap_tds_thhold_slabs.from_amount then
1300: /* Cumulative threshold amount is reached */
1301: p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12 */
1295: open c_jai_ap_tds_thhold_slabs(r_get_threshold.threshold_hdr_id, 'SINGLE', ln_amount + ln_amount_for_redefault);
1296: fetch c_jai_ap_tds_thhold_slabs into r_jai_ap_tds_thhold_slabs;
1297: close c_jai_ap_tds_thhold_slabs;
1298:
1299: if ln_amount + ln_amount_for_redefault >= r_jai_ap_tds_thhold_slabs.from_amount then
1300: /* Cumulative threshold amount is reached */
1301: p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12 */
1302: p_single_threshold_slab_id := r_jai_ap_tds_thhold_slabs.threshold_slab_id;
1303: end if;
1298:
1299: if ln_amount + ln_amount_for_redefault >= r_jai_ap_tds_thhold_slabs.from_amount then
1300: /* Cumulative threshold amount is reached */
1301: p_codepath := jai_general_pkg.plot_codepath(12, p_codepath); /* 12 */
1302: p_single_threshold_slab_id := r_jai_ap_tds_thhold_slabs.threshold_slab_id;
1303: end if;
1304:
1305: end if; /* Cumulative or single threshold amount */
1306: