The following lines contain the word 'select', 'insert', 'update' or 'delete':
select
rsh.invoice_num,
rsh.invoice_date,
rsh.vendor_id,
NVL(rsh.remit_to_site_id, NVL(pvss.default_pay_site_id, pvss.vendor_site_id)) default_pay_site_id,
rsh.invoice_amount,
rsh.tax_name,
rsh.tax_amount,
rsh.freight_amount,
NVL(rsh.currency_code, poh.currency_code) currency_code,
NVL(rsh.payment_terms_id, poh.terms_id) payment_terms_id,
NVL(rsh.conversion_rate_type, poh.rate_type) exchange_rate_type,
NVL(rsh.conversion_date, poh.rate_date) exchange_rate_date,
NVL(rsh.conversion_rate, poh.rate) exchange_rate,
poh.org_id
from
po_vendor_sites pvss,
po_headers poh,
rcv_shipment_headers rsh
where
poh.vendor_site_id = pvss.vendor_site_id and
poh.pcard_id is null and
rsh.receipt_source_code = 'VENDOR' and
rsh.asn_type = 'ASBN' and
NVL(rsh.invoice_status_code, 'PENDING') IN ('PENDING', 'REJECTED') and
rsh.shipment_header_id = p_shipment_header_id and
poh.po_header_id = (
select rsl.po_header_id
from rcv_shipment_lines rsl
where rsl.shipment_header_id = rsh.shipment_header_id
and rownum = 1 );
select
rsl.po_header_id,
rsl.po_line_id,
rsl.po_line_location_id,
rsl.po_release_id,
rsl.shipment_line_id,
pol.item_id,
pol.item_description,
pol.unit_meas_lookup_code, --1890025
rsl.unit_of_measure,
rsl.quantity_shipped,
rsl.notice_unit_price,
NVL(rsl.notice_unit_price, pll.price_override) unit_price,
pll.taxable_flag,
rsl.tax_name tax_name,
DECODE(pll.taxable_flag, 'Y', pll.tax_code_id, NULL) tax_code_id,
rsl.tax_amount,
pll.match_option
from
po_line_locations pll,
po_lines pol,
rcv_shipment_lines rsl
where
rsl.shipment_header_id = p_shipment_header_id and
pll.line_location_id = rsl.po_line_location_id and
pol.po_line_id = rsl.po_line_id and
NVL(rsl.invoice_status_code, 'PENDING') IN ('PENDING','REJECTED');
select ap_invoices_interface_s.nextval
into l_invoice_id
from sys.dual;
UPDATE ap_invoices_interface
SET calc_tax_during_import_flag = 'Y',
control_amount = X_asbn_header.tax_amount
WHERE invoice_id = l_invoice_id;
insert into AP_INVOICES_INTERFACE (
INVOICE_ID,
INVOICE_NUM,
INVOICE_DATE,
VENDOR_ID,
VENDOR_SITE_ID,
INVOICE_AMOUNT,
INVOICE_CURRENCY_CODE,
--EXCHANGE_RATE,
--EXCHANGE_RATE_TYPE,
--EXCHANGE_DATE,
TERMS_ID,
GROUP_ID,
SOURCE,
INVOICE_RECEIVED_DATE,
CREATION_DATE,
ORG_ID )
VALUES (
p_invoice_id,
p_invoice_num,
p_invoice_date,
p_vendor_id,
p_vendor_site_id,
p_invoice_amount,
p_invoice_currency_code,
--p_exchange_rate,
--p_exchange_rate_type,
--p_exchange_date,
p_payment_terms_id,
x_group_id,
'ASBN',
sysdate,
sysdate,
p_org_id );
select ap_invoice_lines_interface_s.nextval
into x_invoice_line_id
from sys.dual;
select freight_code_combination_id
into l_freight_ccid
from ap_system_parameters_all
where org_id = p_org_id;
insert into ap_invoice_lines_interface (
INVOICE_ID,
INVOICE_LINE_ID,
LINE_NUMBER,
LINE_TYPE_LOOKUP_CODE,
AMOUNT,
AMOUNT_INCLUDES_TAX_FLAG,
PRORATE_ACROSS_FLAG,
PO_HEADER_ID,
PO_LINE_ID,
PO_LINE_LOCATION_ID,
PO_RELEASE_ID,
PO_UNIT_OF_MEASURE,
INVENTORY_ITEM_ID,
ITEM_DESCRIPTION,
QUANTITY_INVOICED,
SHIP_TO_LOCATION_ID,
UNIT_PRICE,
LAST_UPDATE_DATE,
CREATION_DATE,
ORG_ID,
TAXABLE_FLAG,
TAX_CODE_OVERRIDE_FLAG,
TAX_CODE,
TAX_CLASSIFICATION_CODE
)
VALUES (
p_invoice_id,
x_invoice_line_id,
null,
p_line_type,
p_amount,
null,
l_prorate_across_flag,
p_po_header_id,
p_po_line_id,
p_po_line_location_id,
p_po_release_id,
p_uom,
p_item_id,
p_item_description,
p_qty_invoiced,
p_ship_to_location_id,
p_unit_price,
sysdate,
sysdate,
p_org_id,
p_taxable_flag,
'N',
p_tax_code,
p_tax_classification_code
);