SELECT chk.doc_sequence_value payment_voucher
,chk.currency_code payment_currency
,chk.check_date payment_date
,check_number payment_number
,chk.future_pay_due_date check_date
,chk.payment_method_code payment_type
,bank.bank_name bank_name
,chk.bank_account_num bank_account_num
,chk.vendor_name paid_to
,chk.amount
,aia.invoice_num invoice_number
,aia.invoice_date invoice_date
,aia.description invoice_description
,aia.invoice_amount invoice_amount
,supplier_bank.bank_name paid_to_bank_name
,supplier_bank.bank_account_num paid_to_bank_account_num
,chk.exchange_rate conversion_rate
,TO_CHAR ( (NVL (chk.exchange_rate, 1) * chk.amount), '999,999,999.99') functional_amount
FROM ap_invoice_payments_all ipa
,ap_checks_all chk
,ap_invoices_all aia
,fnd_user u
,ce_bank_accounts bank_acct
,ce_banks_v bank
,xle_entity_profiles le
,(SELECT aps.vendor_id,
hop_bank.organization_name bank_name,
ieba.bank_account_num
FROM hz_parties hzp,
ap_suppliers aps,
iby_external_payees_all hepa,
iby_pmt_instr_uses_all ipiua,
iby_ext_bank_accounts ieba,
hz_parties hzp_bank,
hz_organization_profiles hop_bank
WHERE hzp.party_id = aps.party_id
AND hzp.party_id = hepa.payee_party_id
AND hepa.ext_payee_id = ipiua.ext_pmt_party_id(+)
AND ipiua.instrument_id = ieba.ext_bank_account_id(+)
AND ieba.bank_id = hzp_bank.party_id(+)
AND hop_bank.party_id(+) = hzp_bank.party_id
AND hepa.supplier_site_id IS NULL) supplier_bank
WHERE le.legal_entity_id = chk.legal_entity_id
AND chk.check_id = ipa.check_id
AND bank.bank_party_id = bank_acct.bank_id
AND bank_acct.bank_account_name = chk.bank_account_name
AND bank_acct.bank_account_num = chk.bank_account_num
AND aia.invoice_id = ipa.invoice_id
AND aia.vendor_id = supplier_bank.vendor_id(+)
AND chk.created_by = u.user_id(+)
AND chk.last_updated_by = u.user_id(+)
AND chk.status_lookup_code <> 'VOIDED'
--and chk.check_id = 1234567890
AND chk.check_number = NVL (:p_check_number, chk.check_number)
AND NVL (chk.doc_sequence_value, 0) BETWEEN NVL (
:p_voucher_no_from,
NVL (
chk.doc_sequence_value,
0))
AND NVL (
:p_voucher_no_to,
NVL (
chk.doc_sequence_value,
0))
AND ipa.org_id = NVL (:p_org_id, ipa.org_id)
AND chk.check_date BETWEEN NVL (:p_from_date, chk.check_date)
AND NVL (:p_to_date, chk.check_date)
ORDER BY chk.doc_sequence_value,
chk.check_number,
aia.invoice_num,
aia.invoice_date
Thanks for sharing information
ReplyDelete