150: SELECT tax_line_no, precedence_1, precedence_2, precedence_3, precedence_4,
151: precedence_5, precedence_6, precedence_7, precedence_8,
152: precedence_9, precedence_10, tax_id, currency, tax_rate, qty_rate,
153: tax_amount, tax_type, modvat_flag, vendor_id, tax_category_id
154: FROM jai_po_taxes
155: WHERE po_line_id = v_frm_po_line_id AND
156: nvl(line_location_id,0) = nvl(v_line_loc_id,0)
157: ORDER BY tax_line_no;
158:
168: nvl(line_location_id,0) = nvl(p_line_location_id,0);
169:
170: CURSOR Fetch_Sum_Cur IS
171: SELECT SUM( NVL( Tax_Amount, 0 ) )
172: FROM JAI_PO_TAXES
173: WHERE Po_Line_Id = v_po_line_id
174: AND nvl(Line_Location_Id,0) = nvl(v_line_loc_id,0)
175: AND Tax_Type <> jai_constants.tax_type_tds;
176:
385: );
386: END IF;
387:
388: ELSE --p_tax_category_id is not null then
389: DELETE Jai_Po_Taxes WHERE Po_Line_Id = v_po_line_id
390: AND NVL( Line_Location_Id, 0 ) = NVL( v_line_loc_id, 0 );
391:
392: UPDATE Jai_Po_Line_Locations
393: SET Tax_Amount = NULL,
477: END IF;
478: --This Part of code is placed after END IF, to correct the tax_amount , Total_Amount
479: --Entry into Localization tables
480: IF ( v_quot_class_code = 'CATALOG' ) OR ( v_type_lookup_code = 'BLANKET' ) THEN
481: UPDATE JAI_PO_TAXES
482: SET Tax_Amount = NULL,
483: Tax_Target_Amount = NULL,
484: Last_Updated_By = v_last_upd_by,
485: Last_Update_Date = v_last_upd_dt,
526: REM SubProgram Name : process_po_tax_wrapper
527: REM Type : processing API
528: REM Purpose : process tax related logic when the event of Create and Update for PO Documents.
529: REM The main logic is insert/update data into JAI_PO_LINE_LOCATIONS table
530: REM and JAI_PO_TAXES table.
531: REM TDD Reference :
532: REM
533: REM Assumptions :
534: REM
791: IF v_old_qty IS NULL OR v_old_qty = 0 THEN
792: v_old_qty := 1;
793: END IF;
794:
795: UPDATE JAI_PO_TAXES a
796: SET tax_amount = (tax_amount * v_qty/ v_old_qty ),
797: tax_target_amount = (tax_target_amount * v_qty/ v_old_qty)
798: WHERE line_location_id = v_line_loc_id
799: AND EXISTS (select 1 from JAI_CMN_TAXES_ALL b where b.tax_id = a.tax_id and b.adhoc_flag = 'Y');
1056: AND po_header_id = p_from_hdr_id
1057: AND ( line_location_id IS NULL
1058: OR line_location_id = 0 );
1059:
1060: -- Cursor definition for picking values from JAI_PO_TAXES
1061: CURSOR fetch_jain_line_tax_cur IS
1062: SELECT line_location_id,
1063: tax_line_no,
1064: po_line_id,
1089: last_update_date,
1090: last_updated_by,
1091: last_update_login,
1092: tax_category_id
1093: FROM JAI_PO_TAXES
1094: WHERE Po_Line_Id = v_line_id
1095: AND po_header_id = p_from_hdr_id
1096: AND ( line_location_id IS NULL
1097: OR line_location_id = 0 );
1104: tax_category_id,item_id, quantity,PRICE_OVERRIDE,currency
1105: FROM JAI_PO_LINE_LOCATIONS
1106: WHERE Line_Location_Id = v_ln_loc_id;
1107:
1108: -- Cursor definition for picking values from JAI_PO_TAXES
1109: -- using line_location_id as where clause
1110: CURSOR fetch_po_ln_loc_tax_cur IS
1111: SELECT line_location_id,
1112: tax_line_no,
1138: last_update_date,
1139: last_updated_by,
1140: last_update_login,
1141: tax_category_id
1142: FROM JAI_PO_TAXES
1143: WHERE Line_Location_Id = v_ln_loc_id;
1144:
1145: cursor fetch_vendor_id_cur IS
1146: select vendor_id,vendor_site_id
1385: a.precedence_10,
1386: a.currency, a.tax_rate, a.qty_rate, a.uom, a.tax_amount, a.tax_type,
1387: a.vendor_id, a.modvat_flag,
1388: tax_category_id
1389: FROM JAI_PO_TAXES a
1390: WHERE ((a.line_location_id IS NULL AND v_quot_line_loc_id=-999) OR (a.line_location_id = v_quot_line_loc_id))
1391: AND Po_Line_Id = p_frm_line_id
1392: ORDER BY a.tax_line_no;
1393:
2624: REM Creation Date : Jun 1, 2012
2625: REM Bug Number/ER Name : 14040855/JAI Triggers Elimination
2626: REM SubProgram Name : update_currency
2627: REM Type : table handler API
2628: REM Purpose : Update currency in JAI_PO_LINE_LOCATIONS and JAI_PO_TAXES
2629: REM
2630: REM TDD Reference :
2631: REM
2632: REM Assumptions :
2652:
2653: IF ( G_LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2654: FND_LOG.STRING(G_LEVEL_PROCEDURE,G_MODULE_NAME||l_api_name||'.BEGIN',G_PKG_NAME||': '||l_api_name||'()+');
2655: END IF;
2656: UPDATE JAI_PO_TAXES
2657: SET Currency = pv_currency,
2658: Last_Update_Date = pd_last_upd_dt,
2659: Last_Updated_By = pn_last_upd_by,
2660: Last_Update_Login = pn_last_upd_login
2686: REM Creation Date : Jun 1, 2012
2687: REM Bug Number/ER Name : 14040855/JAI Triggers Elimination
2688: REM SubProgram Name : update_vendor
2689: REM Type : table handler API
2690: REM Purpose : Update currency in JAI_PO_LINE_LOCATIONS and JAI_PO_TAXES
2691: REM
2692: REM TDD Reference :
2693: REM
2694: REM Assumptions :
2722: IF (g_level_procedure >= fnd_log.g_current_runtime_level) THEN
2723: fnd_log.STRING(g_level_procedure,g_module_name || l_api_name || '.BEGIN',g_pkg_name || ': ' || l_api_name || '()+');
2724: END IF;
2725:
2726: UPDATE jai_po_taxes
2727: SET vendor_id = pn_vendor_id, last_update_date = pd_last_upd_dt,
2728: last_updated_by = pn_last_upd_by, last_update_login = pn_last_upd_login
2729: WHERE po_header_id = pn_po_header_id
2730: AND vendor_id = pn_old_vendor_id;
2801: REM Creation Date : Jun 1, 2012
2802: REM Bug Number/ER Name : 14040855/JAI Triggers Elimination
2803: REM SubProgram Name : delete_po_taxes
2804: REM Type : table handler API
2805: REM Purpose : delete data from JAI_PO_TAXES
2806: REM
2807: REM TDD Reference :
2808: REM
2809: REM Assumptions :
2825: IF ( G_LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2826: FND_LOG.STRING(G_LEVEL_PROCEDURE,G_MODULE_NAME||l_api_name||'.BEGIN',G_PKG_NAME||': '||l_api_name||'()+');
2827: END IF;
2828: IF pn_po_hdr_id IS NOT NULL THEN
2829: DELETE FROM JAI_PO_TAXES
2830: WHERE po_header_id = pn_po_hdr_id;
2831: ELSIF pn_po_line_id IS NOT NULL THEN
2832: DELETE FROM JAI_PO_TAXES
2833: WHERE Po_Line_Id = pn_po_line_id
2828: IF pn_po_hdr_id IS NOT NULL THEN
2829: DELETE FROM JAI_PO_TAXES
2830: WHERE po_header_id = pn_po_hdr_id;
2831: ELSIF pn_po_line_id IS NOT NULL THEN
2832: DELETE FROM JAI_PO_TAXES
2833: WHERE Po_Line_Id = pn_po_line_id
2834: AND NVL( Line_Location_Id, -999 ) = NVL( pn_line_loc_id, -999 );
2835: END IF;
2836: IF ( G_LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3215: WHERE line_location_id = pn_orig_ship_id;
3216:
3217: CURSOR c_get_po_taxes (p_line_location_id IN NUMBER) IS
3218: SELECT *
3219: FROM JAI_PO_TAXES
3220: WHERE line_location_id = p_line_location_id;
3221:
3222: l_prev_quantity NUMBER;
3223: l_ship_line_amount NUMBER;
3285:
3286: END LOOP;
3287:
3288: select sum(tax_amount) into l_tax_amount
3289: from jai_po_taxes
3290: where line_location_id = pn_line_loc_id;
3291:
3292: l_ship_line_amount := pn_QUANTITY * pn_price;
3293:
4506: a.tax_type ,
4507: a.vendor_id ,
4508: a.modvat_flag ,
4509: tax_category_id
4510: FROM JAI_PO_TAXES a
4511: WHERE po_line_id = p_po_line_id
4512: AND nvl(line_location_id,-999) = p_line_location_id
4513: ORDER BY a.tax_line_no;
4514:
4837: v_assessable_value NUMBER;
4838: v_vat_assess_value NUMBER;
4839: v_loc_count NUMBER;
4840:
4841: v_tax_category_id JAI_PO_TAXES.tax_category_id%TYPE;
4842: v_tax_category_id_holder JAI_PO_LINE_LOCATIONS.tax_category_id%TYPE;
4843: v_style_id po_headers_all.style_id%TYPE;
4844:
4845: ------------------------------>
4907: WHERE Vendor_Name = v_sugg_vendor_name;
4908:
4909: CURSOR Tot_Amt_Cur IS
4910: SELECT SUM( NVL( Tax_Amount, 0 ) )
4911: FROM JAI_PO_TAXES
4912: WHERE line_location_id = v_line_loc_id
4913: AND Tax_Type <> jai_constants.tax_type_tds ; /* 'TDS';*/
4914:
4915:
4965: where line_location_id = v_line_loc_id;
4966:
4967: Cursor fetch_Tax_cnt( cp_line_loc_id in number ) is
4968: select count(1)
4969: from JAI_PO_TAXES
4970: where line_location_id = cp_line_loc_id;
4971:
4972: CURSOR Fetch_Hdr_Curr_Cur IS
4973: SELECT NVL( Currency_Code, '$' )
5243:
5244: /*
5245: Fetch the line_focus_id for the current line and current
5246: line location id */
5247: SELECT COUNT(1) INTO tax_cnt FROM JAI_PO_TAXES WHERE
5248: Po_Line_Id = v_po_line_id
5249: AND Line_Location_Id = v_line_loc_id;
5250: IF ( G_LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5251: FND_LOG.STRING(G_LEVEL_PROCEDURE,G_MODULE_NAME||l_api_name,'before insert taxes, tax_cnt is '||tax_cnt);
5342:
5343: END LOOP;
5344:
5345: CLOSE Fetch_Taxes_Cur;
5346: SELECT COUNT(1) INTO tax_cnt FROM JAI_PO_TAXES WHERE
5347: Po_Line_Id = v_po_line_id
5348: AND Line_Location_Id = v_line_loc_id;
5349: IF ( G_LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5350: FND_LOG.STRING(G_LEVEL_PROCEDURE,G_MODULE_NAME||l_api_name,'after insert taxes, tax_cnt is '||tax_cnt);
5657: Precedence_6, Precedence_7, Precedence_8, Precedence_9,Precedence_10,
5658: Tax_Id, Currency, Tax_Rate, Qty_Rate, UOM, Tax_Amount, Tax_Type,
5659: Vendor_Id, Modvat_Flag, Tax_Target_Amount,
5660: tax_category_id
5661: FROM JAI_PO_TAXES
5662: WHERE NVL( Line_Location_Id, -999 ) = llid
5663: AND Po_Line_Id = lineid
5664: ORDER BY Tax_Line_No;
5665:
5669: precedence_6, precedence_7, precedence_8, precedence_9, precedence_10,
5670: tax_id, currency, tax_rate, qty_rate, uom, tax_amount, tax_type,
5671: vendor_id, modvat_flag, tax_target_amount,
5672: tax_category_id
5673: FROM JAI_PO_TAXES
5674: WHERE line_location_id = p_src_ship_id
5675: AND po_line_id = v_po_line_id;
5676:
5677:
5746: WHERE Unit_Of_Measure = uom;
5747:
5748: CURSOR Fetch_Tot_Sum_Cur( llid IN NUMBER ) IS
5749: SELECT SUM( NVL( Tax_Amount, 0 ) )
5750: FROM JAI_PO_TAXES
5751: WHERE Line_Location_Id = llid
5752: AND Tax_Type <> jai_constants.tax_type_tds; --'TDS';
5753:
5754: CURSOR Get_Assessable_Val_Cur IS
5986: v_tax_amt := ( NVL( Tax_Rec.Tax_Amount, 0 ) * NVL( v_qty, 0 ) ) / NVL( v_old_qty, 1 );
5987:
5988: BEGIN
5989: SELECT COUNT(1) INTO v_tax_count FROM
5990: JAI_PO_TAXES
5991: WHERE Line_Location_Id = Tax_Rec.Line_Location_Id AND
5992: TAX_ID = Tax_Rec.Tax_id;
5993: END;
5994:
6192: FOR Tax_Rec IN Fetch_Taxes_Cur( v_line_id, v_line_loc_id ) LOOP
6193:
6194: BEGIN
6195: SELECT COUNT(1) INTO v_tax_count FROM
6196: JAI_PO_TAXES
6197: WHERE Line_Location_Id = p_line_Loc_Id AND
6198: TAX_ID = Tax_Rec.Tax_id;
6199: END;
6200:
6316: REM Creation Date : Jun 1, 2012
6317: REM Bug Number/ER Name : 14040855/JAI Triggers Elimination
6318: REM SubProgram Name : insert_po_taxes
6319: REM Type : Table Handler API
6320: REM Purpose : Insert data into JAI_PO_TAXES.
6321: REM
6322: REM
6323: REM TDD Reference :
6324: REM
6401: END IF;
6402:
6403:
6404:
6405: INSERT INTO JAI_PO_TAXES(
6406: Line_Focus_Id, Line_Location_Id, Tax_Line_No,
6407: Po_Line_Id, Po_Header_Id,
6408: Precedence_1, Precedence_2, Precedence_3, Precedence_4, Precedence_5,
6409: Precedence_6, Precedence_7, Precedence_8, Precedence_9, Precedence_10,
7556: SELECT
7557: nvl(a.tax_amount,0) tax_amount,
7558: nvl(b.adhoc_flag, 'N') adhoc_flag
7559: FROM
7560: JAI_PO_TAXES a ,
7561: JAI_CMN_TAXES_ALL b
7562: WHERE
7563: a.tax_id = b.tax_id AND
7564: a.po_line_id = v_po_line_id AND
7567:
7568: CURSOR rec_calc_total_tax
7569: IS
7570: SELECT sum(tax_amount )
7571: FROM JAI_PO_TAXES
7572: WHERE
7573: po_line_id = v_po_line_id AND
7574: po_header_id = v_po_hdr_id AND
7575: line_location_id = v_line_loc_id AND
7592: IF nvl(v_quantity_cancelled,-9999) = nvl(v_qty,0) THEN
7593: /*
7594: Indicating that the entire line has been cancelled and no receipt has been made for ths line,
7595: then delete the line and associated taxes from JAI_PO_LINE_LOCATIONS
7596: and JAI_PO_TAXES and return .
7597: */
7598: IF ( G_LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7599: FND_LOG.STRING(G_LEVEL_PROCEDURE,G_MODULE_NAME||l_api_name,G_PKG_NAME||': '||l_api_name||': entire line been cancelled.');
7600: END IF;
7605: /*
7606: Indicating that a partial receipt has been made for the line and then the line has been cancelled.
7607: In such a case the cancelled quantity would be lesser than the quantity in table po_line_locations_all.
7608: Now in this scenario update the line and the associated apportioned taxes in the table JAI_PO_LINE_LOCATIONS
7609: and JAI_PO_TAXES
7610: */
7611:
7612: /*
7613: Update the JAI_PO_TAXES with the apportioned tax_amount
7609: and JAI_PO_TAXES
7610: */
7611:
7612: /*
7613: Update the JAI_PO_TAXES with the apportioned tax_amount
7614: The tax amounts are apportioned in a ratio of the (quantity_received\quantity)
7615: Only the taxes which have a adhoc flag set to 'N' can be apportioned.
7616: Taxes which have adhoc flag set to 'Y' would remain unaffected .
7617:
7619: FOR cur_rec_get_tax_amount IN rec_get_tax_amount
7620: LOOP
7621:
7622: UPDATE
7623: JAI_PO_TAXES
7624: SET
7625: tax_amount = (nvl(v_quantity_received,0) / nvl(v_qty,1)) * nvl(cur_rec_get_tax_amount.tax_amount,0)
7626: WHERE
7627: CURRENT OF rec_get_tax_amount;
7629: -- END IF;
7630: END LOOP;
7631:
7632: /*
7633: The record in ja_in_po_line_location has to be updated with the total of all taxes from JAI_PO_TAXES
7634: excluding the TDS type of taxes. The total_amount should be calculated as (quantity_received * price_override) + total of tax amount
7635: */
7636:
7637: OPEN rec_calc_total_tax ;
8265: v_assessable_value NUMBER;
8266: v_vat_assess_value NUMBER;
8267: v_loc_count NUMBER;
8268:
8269: v_tax_category_id JAI_PO_TAXES.tax_category_id%TYPE;
8270: v_tax_category_id_holder JAI_PO_LINE_LOCATIONS.tax_category_id%TYPE;
8271: v_style_id po_headers_all.style_id%TYPE;
8272:
8273: ------------------------------>
8335: WHERE Vendor_Name = v_sugg_vendor_name;
8336:
8337: CURSOR Tot_Amt_Cur IS
8338: SELECT SUM( NVL( Tax_Amount, 0 ) )
8339: FROM JAI_PO_TAXES
8340: WHERE line_location_id = v_line_loc_id
8341: AND Tax_Type <> jai_constants.tax_type_tds ; /* 'TDS';*/
8342:
8343:
8393: where line_location_id = v_line_loc_id;
8394:
8395: Cursor fetch_Tax_cnt( cp_line_loc_id in number ) is
8396: select count(1)
8397: from JAI_PO_TAXES
8398: where line_location_id = cp_line_loc_id;
8399:
8400: CURSOR Fetch_Hdr_Curr_Cur IS
8401: SELECT NVL( Currency_Code, '$' )
8672:
8673: /*
8674: Fetch the line_focus_id for the current line and current
8675: line location id */
8676: SELECT COUNT(1) INTO tax_cnt FROM JAI_PO_TAXES WHERE
8677: Po_Line_Id = v_po_line_id
8678: AND Line_Location_Id = v_line_loc_id;
8679: IF ( G_LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
8680: FND_LOG.STRING(G_LEVEL_PROCEDURE,G_MODULE_NAME||l_api_name,'before insert taxes, tax_cnt is '||tax_cnt);
8773: END LOOP;
8774: CLOSE Fetch_Taxes_Cur;
8775:
8776:
8777: SELECT COUNT(1) INTO tax_cnt FROM JAI_PO_TAXES WHERE
8778: Po_Line_Id = v_po_line_id
8779: AND Line_Location_Id = v_line_loc_id;
8780: IF ( G_LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
8781: FND_LOG.STRING(G_LEVEL_PROCEDURE,G_MODULE_NAME||l_api_name,'after insert taxes, tax_cnt is '||tax_cnt);