=================实现核销AR收款明细/未核销收款查询=================
SELECT hca.account_number customer_number,
SUBSTR (hp.party_name,
1,
DECODE (INSTR (hp.party_name, ' '),
0, 50,
INSTR (hp.party_name, ' ')
)
) customer_name,
rec.receipt_number, rec.amount receipt_amount, rec.receipt_date,
rec.currency_code, rec.status, rt.trx_number trx_number,
DECODE (interface_header_context,
'ORDER ENTRY', rt.purchase_order,
''
) cust_po_number,
rt.interface_header_attribute1 sales_order, app.apply_date,
app.amount_applied applied_amount, bank.bank_account_name
FROM ar.ar_cash_receipts_all rec,
ar.ar_payment_schedules_all ps,
ar.ar_receivable_applications_all app,
ar.ra_customer_trx_all rt,
ar.hz_cust_accounts hca,
ar.hz_parties hp,
ap.ap_bank_accounts_all bank
WHERE rec.cash_receipt_id = ps.cash_receipt_id
AND ps.payment_schedule_id = app.payment_schedule_id(+)
AND app.display(+) = 'Y'
AND app.applied_customer_trx_id = rt.customer_trx_id(+)
AND hp.party_id = hca.party_id
AND hca.cust_account_id = ps.customer_id
AND rec.status <> 'REV'
AND rec.set_of_books_id = 63
AND rec.org_id = 211
AND bank.bank_account_id = rec.remittance_bank_account_id
AND rec.status = '&Status' --Value: APP,UNAPP
AND hp.party_name LIKE '%&Customer_Name%'
AND TO_CHAR (rec.receipt_date, 'YYYY-MM-DD') BETWEEN '&start_date'
AND '&end_date'
阅读(4673) | 评论(0) | 转发(0) |