Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
44 views3 pages

Query Pago Payment

This document contains multiple SQL queries that select data from various tables related to invoices, payments, suppliers and accounting. The queries include joins across these tables to retrieve invoice numbers, amounts, dates, currencies, supplier names and other financial information for analysis and reporting.

Uploaded by

alexorctrainning
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views3 pages

Query Pago Payment

This document contains multiple SQL queries that select data from various tables related to invoices, payments, suppliers and accounting. The queries include joins across these tables to retrieve invoice numbers, amounts, dates, currencies, supplier names and other financial information for analysis and reporting.

Uploaded by

alexorctrainning
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

select aia.

invoice_num,
aia.invoice_date,
aia.invoice_amount,
aila.amount line_amount,
pha.segment1 po_number,
aila.line_type_lookup_code,
aps.vendor_name,
apss.vendor_site_code,
aca.check_number "Payment Number",
aipa.amount "Check Amount",
apsa.amount_remaining "Payment Left",
hou.name operating_unit,
gl.name ledger_name,
aila.line_number,
apt.name Term_name,
gcc.segment1 || '.' || gcc.segment2 distributed_code_combinations,
DECODE(aia.PAYMENT_STATUS_FLAG,
'N',
'UN-PAID',
'P',
'Partial Paid',
'Y',
'PAID') PAYMENT_STATUS_FLAG
from apps.ap_invoices_all aia,
ap_invoice_lines_all aila,
ap_invoice_distributions_all aida,
poz_suppliers aps,
poz_supplier_sites_all apss,
po_headers_all pha,
gl_code_combinations gcc,
ap_invoice_payments_all aipa,
ap_checks_all aca,
ap_payment_schedules_all apsa,
ap_terms apt,
hr_operating_units hou,
gl_ledgers gl

where 1 = 1
and aia.vendor_id = aps.vendor_id
and aia.VENDOR_SITE_ID = APSS.VENDOR_SITE_ID
AND aps.vendor_id = apss.VENDOR_ID
and aia.po_header_id = pha.po_header_id(+)
and aia.invoice_id = aila.invoice_id
and aila.invoice_id = aida.invoice_id
and aila.line_number = aida.invoice_line_number
and aca.check_id(+) = aipa.check_id
and apsa.invoice_id = aia.invoice_id
and apt.term_id = aia.terms_id
and hou.organization_id = aia.org_id
and gl.ledger_id = aia.set_of_books_id
and aida.dist_code_combination_id = gcc.code_combination_id
and aipa.invoice_id(+) = aia.invoice_id

-----
---

SELECT
FABV.BU_NAME
, AIA.INVOICE_NUM INVOICE_NUM
,AIA.ACCTS_PAY_CODE_COMBINATION_ID ACCTS_PAY_CODE_COMBINATION_ID
,AIA.INVOICE_CURRENCY_CODE INVOICE_CURRENCY_CODE
,AIA.PAYMENT_CURRENCY_CODE PAYMENT_CURRENCY_CODE
,AIA.INVOICE_AMOUNT INVOICE_AMOUNT
,TO_CHAR(AIA.INVOICE_DATE , 'DD-Mon-RRRR' ) INVOICE_DATE
,AIA.SOURCE INVOICE_SOURCE
,AIA.INVOICE_TYPE_LOOKUP_CODE INVOICE_TYPE_LOOKUP_CODE
,AIA.DOC_SEQUENCE_VALUE DOC_SEQUENCE_VALUE
,AIA.GL_DATE GL_DATE
,AIA.CUST_REGISTRATION_NUMBER CUST_REGISTRATION_NUMBER
,AIPA.AMOUNT TRX_AMOUNT
, AIPA.PERIOD_NAME PERIOD_NAME
, AIA.DESCRIPTION DESCRIPTION
, GL.CURRENCY_CODE FUNCTIONAL_CURRENCY
, DECODE( AIA.PAYMENT_CURRENCY_CODE , GL.CURRENCY_CODE , AIPA.AMOUNT ,
AIPA.PAYMENT_BASE_AMOUNT) PAYMENT_BASE_AMOUNT

FROM AP_CHECKS_ALL ACA


, AP_INVOICE_PAYMENTS_ALL AIPA
, AP_INVOICES_ALL AIA
, POZ_SUPPLIERS_V PSV
, POZ_SUPPLIER_SITES_V PSSV
, FND_LOOKUP_VALUES FLV
, XLE_ENTITY_PROFILES XLP
, FUN_ALL_BUSINESS_UNITS_V FABV
, GL_LEDGERS GL

WHERE ACA.CHECK_ID = AIPA.CHECK_ID


AND AIA.INVOICE_ID = AIPA.INVOICE_ID
AND ACA.VENDOR_ID = PSV.VENDOR_ID
AND PSSV.VENDOR_ID = PSV.VENDOR_ID
AND PSSV.VENDOR_SITE_ID = ACA.VENDOR_SITE_ID
AND FLV.LOOKUP_CODE = ACA.PAYMENT_METHOD_CODE
AND FLV.LOOKUP_TYPE = 'PAYMENT METHOD'
AND FLV.LANGUAGE = 'US'
AND XLP.LEGAL_ENTITY_ID = ACA.LEGAL_ENTITY_ID
AND ACA.ORG_ID = FABV.BU_ID
AND FABV.PRIMARY_LEDGER_ID = GL.LEDGER_ID

------------------------------------------------
----------------------------------------------
select aia.invoice_num,
hp.party_name Supplier_Name
,site.vendor_site_code,
aia.invoice_currency_code Invoice_Currency,
aia.payment_currency_code Payment_Currency,
aia.invoice_amount,
aia.amount_paid,
TO_CHAR(aia.invoice_date, �MM/DD/YYYY�) Invoice_Date,
ats.name terms,
TO_CHAR(aia.terms_date, �MM/DD/YYYY�) Terms_Date,
inv_typ_lookup.meaning Invoice_Type,
pay_grp_lookup.meaning Pay_Group,
pmnt.meaning Payment_Method,
TO_CHAR(aia.gl_date, �MM/DD/YYYY�) GL_DATE,
aia.vendor_site_id
from ap_Invoices_all aia,
fnd_lookup_values pmnt,
ap_terms ats,
fnd_lookup_values pay_grp_lookup,
hz_parties hp
, poz_supplier_sites_all_m site
,fnd_lookup_values Inv_Typ_lookup
Where aia.invoice_num = �10416111_SAPC INTERNAL�
AND pmnt.lookup_type(+) = �PAYMENT METHOD�
AND pmnt.lookup_code(+) = aia.payment_method_code
AND ats.term_id (+) = aia.terms_id
AND pay_grp_lookup.lookup_type(+) = �PAY GROUP�
AND pay_grp_lookup.lookup_code (+) = aia.PAY_GROUP_LOOKUP_CODE
AND hp.party_id = aia.party_id
AND site.vendor_site_id = aia.vendor_site_id
AND Inv_Typ_lookup.lookup_type = �INVOICE TYPE�
AND inv_typ_lookup.lookup_code = aia.INVOICE_TYPE_LOOKUP_CODE

You might also like