0% found this document useful (0 votes)
448 views

AP Invoice Query

The document contains a SQL query that selects data from various tables related to invoices, purchase orders, payments, and accounting codes. The query filters for specific invoice numbers and joins tables like invoices, invoice lines, purchase orders, vendors, payment methods, and accounting distributions to retrieve related data like invoice amounts, purchase order numbers, payment details, and accounting segment information.

Uploaded by

shankar680
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
448 views

AP Invoice Query

The document contains a SQL query that selects data from various tables related to invoices, purchase orders, payments, and accounting codes. The query filters for specific invoice numbers and joins tables like invoices, invoice lines, purchase orders, vendors, payment methods, and accounting distributions to retrieve related data like invoice amounts, purchase order numbers, payment details, and accounting segment information.

Uploaded by

shankar680
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

select ai.ORG_ID Org_id, hou.name Operating_unit, ai.invoice_num Invoice_num, ai.cust_registration_number Custemer_Taxpayer_Id, ai.invoice_type_lookup_code type, ph.segment1 Po_Number, pv.

VENDOR_NAME VENDOR_NAME, pv.segment1 Supplier_number, pvs.vendor_site_code VENDOR_Site, ai.invoice_date Invoice_date, ai.invoice_currency_code Currency_code, ai.invoice_amount Invoice_amount, ai.gl_date GL_DATE, ai.payment_currency_code Payment_currency, ai.TERMS_DATE TERMS_DATE, AT.NAME Terms_name, ai.PAYMENT_METHOD_CODE PAYMENT_METHOD, ail.INVOICE_ID INVOICE_ID, ail.line_number line_Number, ail.LINE_TYPE_LOOKUP_CODE LINE_TYPE, ail.AMOUNT AMOUNT, ail.ITEM_DESCRIPTION ITEM_DESCRIPTION, ail.po_release_id PO_RELEASE_ID, ail.po_header_id PO_HEADER_ID, ail.po_line_id PO_LINE_ID, ph1.segment1 Line_Po_number, pl.line_num Po_line_number, pll.shipment_num Po_shipment_number, alc.displayed_field Matching_basis, pd.distribution_num Po_distribution_number, to_char(ail.accounting_date,'dd-mon-yyyy') Line_Gl_Date, DECODE (aip.invoice_payment_type, 'PREPAY', alc1.displayed_field, iby.payment_method_name ) Line_Payment_method, DECODE (aip.invoice_payment_type, 'PREPAY', ai2.invoice_num, ac.check_number ) document_number , ac.check_date Check_date, aip.ACCOUNTING_DATE ACCOUNTING_DATE, aip.AMOUNT Payment_amount, apsc.DUE_DATE DUE_DATE, apsc.GROSS_AMOUNT GROSS_AMOUNT, apsc.payment_priority PRIORITY , apsc.payment_method_code METHOD , apsc.remit_to_supplier_name SUPPLIER_NAME , apsc.remit_to_supplier_site SUPPLIER_SITE, kfv.concatenated_segments "CONCATENATED_SEGMENTS" from ap_invoices_all ai, hr_operating_units hou, po_headers ph, po_vendors pv, po_vendor_sites_all pvs, ap_terms at, ap_invoice_lines_all ail, po_headers_all ph1, po_lines_all pl, po_line_locations_all pll,

ap_lookup_codes alc, po_distributions_all pd, ap_invoice_payments_all aip, ap_invoices_all ai2, ap_checks_all ac, ap_lookup_codes alc1, iby_payment_methods_vl iby , AP_PAYMENT_SCHEDULES_all apsc, ap_invoice_distributions_all aid, gl_code_combinations_kfv kfv where ai.ORG_ID=hou.ORGANIZATION_ID and ai.quick_po_header_id = ph.po_header_id(+) and ai.VENDOR_ID=pv.VENDOR_ID and ai.VENDOR_SITE_ID = pvs.VENDOR_SITE_ID and ai.TERMS_ID = at.TERM_ID(+) and ai.INVOICE_ID = ail.INVOICE_ID and ai.invoice_num in ('5728adv','5410-adv','5389-adv','5656-Advance') and ail.PO_HEADER_ID = ph1.PO_HEADER_ID and ail.PO_LINE_ID = pl.PO_LINE_ID(+) and ail.PO_LINE_LOCATION_ID = pll.LINE_LOCATION_ID and alc.lookup_type(+) = 'MATCHING BASIS' and alc.LOOKUP_CODE=pll.MATCHING_BASIS and ail.PO_DISTRIBUTION_ID = pd.PO_DISTRIBUTION_ID AND aip.invoice_id = ai.invoice_id AND aip.other_invoice_id = ai2.invoice_id(+) AND aip.check_id = ac.check_id AND alc1.lookup_type(+) = 'NLS TRANSLATION' AND alc1.lookup_code(+) = 'PREPAY' AND iby.payment_method_code(+) = ac.payment_method_code and ail.INVOICE_ID = apsc.INVOICE_ID AND aid.invoice_id = ail.invoice_id AND kfv.code_combination_id = aid.dist_code_combination_id;

--select aip.invoice_payment_type from ap_invoice_payments_all aip,ap_invoices_a ll ai where ai.INVOICE_ID = aip.INVOICE_ID and ai.INVOICE_NUM ='5656-Advance' ; --select * from AP_PAYMENT_SCHEDULES_all

You might also like