|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622 。
您需要 登录 才可以下载或查看,没有帐号?注册
x
应付帐龄统计表取数逻辑
--取未付费用
select sum(nvl(ai.INVOICE_AMOUNT,0)-nvl(paid.amount,0)-nvl(applied.amount,0))
into v_amt
from ap_invoices ai,
(select invoice_id,sum(aip.AMOUNT) amount
from ap_invoice_payment_history_v aip
where aip.CHECK_DATE < to_date(:p_date,'YYYY/MM/DD HH24:MI:SS')--GL日期
group by invoice_id) paid,
(select invoice_id,sum(aup.prepay_amount_applied) amount
from AP_UNAPPLY_PREPAYS_V aup
where aup.ACCOUNTING_DATE < to_date(:p_date,'YYYY/MM/DD HH24:MI:SS')
group by invoice_id) applied
where ap_invoices_pkg.get_approval_status(ai.invoice_id,
ai.invoice_amount,
ai.payment_status_flag,
ai.invoice_type_lookup_code) = 'APPROVED'
and ai.invoice_id = paid.invoice_id(+)
and ai.invoice_id = applied.invoice_id(+)
and ai.INVOICE_TYPE_LOOKUP_CODE in ('STANDARD','CREDIT')
and ai.gl_date < to_date(:p_date,'YYYY/MM/DD HH24:MI:SS') + 1
and ai.VENDOR_ID = :vendor_id--供应商
and ai.VENDOR_SITE_ID = :vendor_site_id; --地点
问题一:ap_invoice_payment_history_v,AP_UNAPPLY_PREPAYS_V从这两张表中取了什么数据?
问题二:解释一下这两张表
--取未核销预付/借款
select sum(nvl(ai.INVOICE_AMOUNT,0)-nvl(applied.amount,0))
into v_amt
from ap_invoices ai,
(select aup.PREPAY_ID,sum(aup.prepay_amount_applied) amount
from ap_unapply_prepays_fr_prepay_v aup
where aup.ACCOUNTING_DATE < to_date(:p_date,'YYYY/MM/DD HH24:MI:SS')
group by aup.prepay_id) applied
where ap_invoices_pkg.get_approval_status(ai.invoice_id,
ai.invoice_amount,
ai.payment_status_flag,
ai.invoice_type_lookup_code) = 'AVAILABLE'
and ai.INVOICE_TYPE_LOOKUP_CODE in ('PREPAYMENT')----(预付款和预支款)
and ai.INVOICE_ID = applied.prepay_id(+)
and ai.GL_DATE < to_date(:p_date,'YYYY/MM/DD HH24:MI:SS') + 1
and ai.VENDOR_ID = :vendor_id
and ai.VENDOR_SITE_ID = :vendor_site_id;
问题一: ap_unapply_prepays_fr_prepay_v从这张表中取了什么数据?
问题二:ap_invoices_pkg.get_approval_status(ai.invoice_id,
ai.invoice_amount,
ai.payment_status_flag,
ai.invoice_type_lookup_code) = 'AVAILABLE'这个是什么意思? |
|