select ai.invoice_id 发票ID,
ai.invoice_num 发票编号,
ail.line_number 发票行号,
ap_prepay_utils_pkg.get_line_prepay_amt_remaining(ail.invoice_id,
ail.line_number) 待核销金额,
aps.vendor_name 供应商名称
from ap_invoices_all ai,
ap_invoice_lines_all ail,
ap_invoice_distributions_all aid,
gl_code_combinations gcc,
ap_suppliers aps
where 1 = 1
and ai.invoice_id = ail.invoice_id
and aps.vendor_id = ai.vendor_id
and ail.invoice_id = aid.invoice_id
and ail.line_number = aid.invoice_line_number
and aps.enabled_flag = 'Y'
and (aps.end_date_active is null or aps.end_date_active > sysdate)
and ai.invoice_type_lookup_code = 'PREPAYMENT'
–获取为可用状态的预付款发票,即已经对预付款系统内付款完成
and ap_invoices_utility_pkg.get_approval_status(ai.invoice_id,
ai.invoice_amount,
ai.payment_status_flag,
ai.invoice_type_lookup_code) =
'AVAILABLE'
and decode(ai.invoice_type_lookup_code,
'PREPAYMENT',
decode(ai.earliest_settlement_date,
'',
'PERMANENT',
'TEMPORARY')) = 'TEMPORARY'
and ai.accts_pay_code_combination_id = gcc.code_combination_id;