[Home] [Help]
25: third party invoices only once. All RECEIVE and CORRECT of RECEIVE
26: type of transactions are considered for generating third party invoices.
27:
28: If a CORRECT to RECEIVE happens after third party invoice is
29: generated, third_party_flag in JAI_RCV_TRANSACTIONS is set to 'G'
30: to indicate that third party invoice has already been generated.
31:
32: This clean up also has introduced two tables which help in tracking
33: third party invoices.
75: (1) Added conditions in procedure process_receipt
76: in cursor c_thirdparty_tax_rec.
77: (a) Added shipment header id condition
78: (b) added aliases.
79: (c) Removed two separate conditions on jai_rcv_Transactions
80: and clubbed into a single one.
81: (2) Added aliases for the following cursors.
82: (a) c_get_thirdparty_count
83: (b) c_get_thirdparty_null_site_cnt
176: )
177: is
178:
179: /* Added by Ramananda for removal of SQL LITERALs */
180: lv_ttype_receive JAI_RCV_TRANSACTIONS.transaction_type%type;
181: lv_ttype_correct JAI_RCV_TRANSACTIONS.transaction_type%type;
182:
183: cursor c_pending_tp_receipts(cp_org_id number) is /* modified the cursor query for bug 8567640 */
184: SELECT
177: is
178:
179: /* Added by Ramananda for removal of SQL LITERALs */
180: lv_ttype_receive JAI_RCV_TRANSACTIONS.transaction_type%type;
181: lv_ttype_correct JAI_RCV_TRANSACTIONS.transaction_type%type;
182:
183: cursor c_pending_tp_receipts(cp_org_id number) is /* modified the cursor query for bug 8567640 */
184: SELECT
185: /*+ no_expand */ jrt.shipment_header_id
182:
183: cursor c_pending_tp_receipts(cp_org_id number) is /* modified the cursor query for bug 8567640 */
184: SELECT
185: /*+ no_expand */ jrt.shipment_header_id
186: FROM jai_rcv_transactions jrt,
187: jai_rcv_lines jrl
188: WHERE(jrt.transaction_type = 'RECEIVE' OR(jrt.transaction_type = 'CORRECT'
189: AND jrt.parent_transaction_type = 'RECEIVE'))
190: AND jrt.third_party_flag = 'N'
318: );
319:
320:
321: if nvl(p_simulation, 'N') <> 'Y' then
322: update JAI_RCV_TRANSACTIONS jrt
323: set third_party_flag = lv_process_flag
324: where shipment_header_id = r_pending_tp_receipts.shipment_header_id
325: and ( transaction_type = 'RECEIVE'
326: or
441: where shipment_header_id = p_shipment_header_id
442: and transaction_type = 'RECEIVE';
443:
444: /* Added by Ramananda for removal of SQL LITERALs */
445: lv_ttype_receive JAI_RCV_TRANSACTIONS.transaction_type%type;
446: lv_ttype_correct JAI_RCV_TRANSACTIONS.transaction_type%type;
447:
448: /* Bug 4941642. Added by Lakshmi Gopalsami
449: Added aliases for the following cursors and
442: and transaction_type = 'RECEIVE';
443:
444: /* Added by Ramananda for removal of SQL LITERALs */
445: lv_ttype_receive JAI_RCV_TRANSACTIONS.transaction_type%type;
446: lv_ttype_correct JAI_RCV_TRANSACTIONS.transaction_type%type;
447:
448: /* Bug 4941642. Added by Lakshmi Gopalsami
449: Added aliases for the following cursors and
450: Added alias and shipment_header_id and
465: where jrlt.shipment_header_id = p_shipment_header_id
466: and EXISTS
467: (
468: select 1
469: from JAI_RCV_TRANSACTIONS jrt
470: where jrt.shipment_header_id = jrlt.shipment_header_id
471: AND jrt.shipment_line_id = jrlt.shipment_line_id
472: AND ( jrt.transaction_type = lv_ttype_receive --'RECEIVE'
473: or
498: where jrlt.shipment_header_id = p_shipment_header_id
499: and EXISTS
500: (
501: select 1
502: from JAI_RCV_TRANSACTIONS jrt
503: where jrt.shipment_header_id = jrlt.shipment_header_id
504: AND jrt.shipment_line_id = jrlt.shipment_line_id
505: AND ( jrt.transaction_type = lv_ttype_receive --'RECEIVE'
506: or
532: where jrlt.shipment_header_id = p_shipment_header_id
533: and EXISTS
534: (
535: select 1
536: from JAI_RCV_TRANSACTIONS jrt
537: where jrt.shipment_header_id = jrlt.shipment_header_id
538: AND jrt.shipment_line_id = jrlt.shipment_line_id
539: AND ( jrt.transaction_type = lv_ttype_receive
540: or
621: from dual;
622:
623: cursor c_check_if_already_processed(p_shipment_header_id number) is
624: select count(transaction_id)
625: from JAI_RCV_TRANSACTIONS
626: where shipment_header_id = p_shipment_header_id
627: and third_party_flag in ('N', 'X'); -- for bug 14172169 by anupgupt
628:
629: cursor c_jai_regimes (cpv_regime_code jai_rgm_definitions.regime_code%type) is /* added by vumaasha for bug 8238608 */
712: , jai_cmn_taxes_all jcta --added by eric for inclusive tax
713: where
714: ( jrtv.transaction_id, jrtv.shipment_line_id ) IN
715: ( select transaction_id, shipment_line_id
716: from JAI_RCV_TRANSACTIONS jrt
717: where shipment_header_id = pn_shipment_header_id
718: and ( transaction_type = lv_ttype_receive --'RECEIVE'
719: or
720: (transaction_type = lv_ttype_correct
907: (
908: /*Bug 4941642. Added by Lakshmi Gopalsami
909: (1) Added shipment header id condition
910: (2) added aliases.
911: (3) Removed two separate conditions on jai_rcv_Transactions
912: and clubbed into a single one.
913: */
914: select
915: jrtv.vendor_id
923: , jai_cmn_taxes_all jcta --added by eric for inclusive tax
924: where
925: ( jrtv.transaction_id, jrtv.shipment_line_id ) IN
926: ( select transaction_id, shipment_line_id
927: from JAI_RCV_TRANSACTIONS jrt
928: where shipment_header_id = p_shipment_header_id
929: and ( transaction_type = lv_ttype_receive --'RECEIVE'
930: or
931: (transaction_type = lv_ttype_correct
1099: DECLARE
1100: /* cursor to fetch tax lines of shipment header id and shipment line id */
1101: CURSOR c_third_party_trans IS
1102: SELECT jrlt.transaction_id, jrlt.shipment_header_id, jrlt.shipment_line_id, jrlt.tax_type, jrlt.tax_amount, jcta.vat_flag, jcta.adhoc_flag, jcta.tax_name
1103: FROM JAI_RCV_TRANSACTIONS jrt, JAI_RCV_LINE_TAXES jrlt, jai_cmn_taxes_all jcta
1104: WHERE jrt.transaction_id = jrlt.transaction_id
1105: AND jrt.shipment_header_id = jrlt.shipment_header_id
1106: AND jrt.shipment_line_id = jrlt.shipment_line_id
1107: AND jrt.shipment_header_id = p_shipment_header_id
1115: AND jrlt.vendor_site_id = c_thirdparty_tax_rec.vendor_site_id
1116: AND jrlt.currency = c_thirdparty_tax_rec.currency
1117: AND jrlt.tax_id = jcta.tax_id;
1118:
1119: v_transaction_type jai_rcv_transactions.transaction_type%type;
1120: v_transaction_id jai_rcv_transactions.transaction_id%type;
1121: v_parent_transaction_id jai_rcv_transactions.transaction_id%type;
1122: v_corrected_quantity NUMBER;
1123: v_original_quantity NUMBER;
1116: AND jrlt.currency = c_thirdparty_tax_rec.currency
1117: AND jrlt.tax_id = jcta.tax_id;
1118:
1119: v_transaction_type jai_rcv_transactions.transaction_type%type;
1120: v_transaction_id jai_rcv_transactions.transaction_id%type;
1121: v_parent_transaction_id jai_rcv_transactions.transaction_id%type;
1122: v_corrected_quantity NUMBER;
1123: v_original_quantity NUMBER;
1124: BEGIN
1117: AND jrlt.tax_id = jcta.tax_id;
1118:
1119: v_transaction_type jai_rcv_transactions.transaction_type%type;
1120: v_transaction_id jai_rcv_transactions.transaction_id%type;
1121: v_parent_transaction_id jai_rcv_transactions.transaction_id%type;
1122: v_corrected_quantity NUMBER;
1123: v_original_quantity NUMBER;
1124: BEGIN
1125: ln_tax_amount := 0;
1126: FOR v_third_party_trans IN c_third_party_trans
1127: LOOP
1128: /* fetch transaction type of receive event transaction */
1129: SELECT transaction_type INTO v_transaction_type
1130: FROM jai_rcv_transactions
1131: WHERE transaction_id = v_third_party_trans.transaction_id;
1132:
1133: Fnd_File.put_line(Fnd_File.LOG, ' DEBUG : 1.1. before apportion v_third_party_trans.transaction_id > '||v_third_party_trans.transaction_id
1134: ||' > v_third_party_trans.tax_name > '||v_third_party_trans.tax_name||' > v_third_party_trans.tax_type > '||v_third_party_trans.tax_type ||' > v_third_party_trans.tax_amount > '
1139: IF v_third_party_trans.tax_type NOT IN ('Freight','Insurance','Octrai','Other','PURCHASE TAX','ENTRY TAX') AND (NVL(v_third_party_trans.adhoc_flag,'N') = 'N'
1140: OR (NVL(v_third_party_trans.adhoc_flag,'N') = 'Y' AND NVL(v_third_party_trans.vat_flag,'N') = 'Q')) AND v_transaction_type <> lv_ttype_correct THEN
1141: /* fetch transaction id of receive event */
1142: SELECT transaction_id, quantity INTO v_parent_transaction_id, v_original_quantity
1143: FROM jai_rcv_transactions
1144: WHERE shipment_header_id = v_third_party_trans.shipment_header_id
1145: AND shipment_line_id = v_third_party_trans.shipment_line_id
1146: AND transaction_type = lv_ttype_receive;
1147:
1146: AND transaction_type = lv_ttype_receive;
1147:
1148: /* fetch total of quantity corrections done on receive event */
1149: SELECT NVL(SUM(quantity),0) INTO v_corrected_quantity
1150: FROM JAI_RCV_TRANSACTIONS
1151: WHERE parent_transaction_id = v_parent_transaction_id
1152: AND transaction_type = lv_ttype_correct;
1153:
1154: /* apportion tax amount based on before correction quantity and corrected quantity and add it to invoice header amount */
1379:
1380: /*Bug 4941642. Added by Lakshmi Gopalsami
1381: (1) Added shipment header id condition
1382: (2) added aliases.
1383: (3) Removed two separate conditions on jai_rcv_Transactions
1384: and clubbed into a single one.
1385: */
1386: FOR Tax_rec IN
1387: ( SELECT
1394: , jai_cmn_taxes_all jcta --added by eric for inclusive tax
1395: WHERE jrlt.shipment_header_id = p_shipment_header_id
1396: AND (jrlt.transaction_id, jrlt.shipment_header_id,jrlt.shipment_line_id) in /*modified for bug 8567640 */
1397: ( SELECT jrt.transaction_id,jrt.shipment_header_id,jrt.shipment_line_id
1398: FROM JAI_RCV_TRANSACTIONS jrt
1399: WHERE jrt.shipment_header_id = p_shipment_header_id
1400: AND ( jrt.transaction_type = lv_ttype_receive
1401: or
1402: (jrt.transaction_type = lv_ttype_correct
1432:
1433: -- start for bug 13528285 by anupgupt
1434: /* code added to apportioning of third party invoice lines amounts based on correction of quantity in receipt*/
1435: DECLARE
1436: v_transaction_type jai_rcv_transactions.transaction_type%type;
1437: v_transaction_id jai_rcv_transactions.transaction_id%type;
1438: v_parent_transaction_id jai_rcv_transactions.transaction_id%type;
1439: v_corrected_quantity NUMBER;
1440: v_original_quantity NUMBER;
1433: -- start for bug 13528285 by anupgupt
1434: /* code added to apportioning of third party invoice lines amounts based on correction of quantity in receipt*/
1435: DECLARE
1436: v_transaction_type jai_rcv_transactions.transaction_type%type;
1437: v_transaction_id jai_rcv_transactions.transaction_id%type;
1438: v_parent_transaction_id jai_rcv_transactions.transaction_id%type;
1439: v_corrected_quantity NUMBER;
1440: v_original_quantity NUMBER;
1441: BEGIN
1434: /* code added to apportioning of third party invoice lines amounts based on correction of quantity in receipt*/
1435: DECLARE
1436: v_transaction_type jai_rcv_transactions.transaction_type%type;
1437: v_transaction_id jai_rcv_transactions.transaction_id%type;
1438: v_parent_transaction_id jai_rcv_transactions.transaction_id%type;
1439: v_corrected_quantity NUMBER;
1440: v_original_quantity NUMBER;
1441: BEGIN
1442: /* fetch transaction type of transaction*/
1440: v_original_quantity NUMBER;
1441: BEGIN
1442: /* fetch transaction type of transaction*/
1443: SELECT transaction_type INTO v_transaction_type
1444: FROM jai_rcv_transactions
1445: WHERE transaction_id = tax_rec.transaction_id;
1446:
1447: Fnd_File.put_line(Fnd_File.LOG, ' DEBUG : 7.1. before apportion tax_rec.transaction_id > '||tax_rec.transaction_id||' > tax_rec.tax_name > '||tax_rec.tax_name||' > tax_rec.tax_type > '
1448: ||tax_rec.tax_type ||' > tax_Rec.tax_amount > '||tax_Rec.tax_amount||' > tax_rec.adhoc_flag > '||tax_rec.adhoc_flag||' > tax_rec.vat_flag > '||tax_rec.vat_flag||' > tax_rec.tax_type > '||tax_rec.tax_type
1452: IF tax_rec.tax_type NOT IN ('Freight','Insurance','Octrai','Other','PURCHASE TAX','ENTRY TAX') AND (NVL(tax_rec.adhoc_flag,'N') = 'N' OR (NVL(tax_rec.adhoc_flag,'N') = 'Y'
1453: AND NVL(tax_rec.vat_flag,'N') = 'Q')) AND v_transaction_type <> lv_ttype_correct THEN
1454: /* fetch transaction id of receive event */
1455: SELECT transaction_id, quantity INTO v_parent_transaction_id, v_original_quantity
1456: FROM jai_rcv_transactions
1457: WHERE shipment_header_id = Tax_rec.shipment_header_id
1458: AND shipment_line_id = Tax_rec.shipment_line_id
1459: AND transaction_type = lv_ttype_receive;
1460:
1459: AND transaction_type = lv_ttype_receive;
1460:
1461: /* fetch total correction of quantity done on receive event */
1462: SELECT NVL(SUM(quantity),0) INTO v_corrected_quantity
1463: FROM JAI_RCV_TRANSACTIONS
1464: WHERE parent_transaction_id = v_parent_transaction_id
1465: AND transaction_type = lv_ttype_correct;
1466:
1467: /* apportion tax amount based on quantity of receive before correction and quantity correccted */