拆分日记账追溯视图4-来源于应付类型应付发票
来源于应付类型应付发票(这个拆分的比较彻底)
select gjl.je_header_id,
gjl.je_line_num,
gjh.je_source,
gjh.name,
gjh.doc_sequence_value,
pv.vendor_id,
pv.vendor_name,
vs.vendor_site_id,
vs.vendor_site_code vendor_address,
null gl_desc,
ai.description invoice_desc, --发票说明(摘要)
gjh.default_effective_date, --GL日期
gcc.segment4, --科目
ael.entered_dr,
ael.entered_cr,
decode(ael.entered_cr, null, '借方', '贷方') entered_cls,
'B'
from gl_je_headers_v gjh,
gl_je_lines_v gjl,
gl_import_references r,
ap_ae_lines_all ael,
ap_ae_headers_all aeh,
ap_accounting_events_all ae,
ap_invoices_all ai,
gl_code_combinations_kfv gcc,
po_vendors pv,
po_vendor_sites_all vs
where gjh.je_source = 'Payables'
and gjl.je_header_id = gjh.je_header_id
and gjh.status = 'P'
and r.je_header_id = gjl.je_header_id
and r.je_line_num = gjl.je_line_num
and gjl.code_combination_id = gcc.code_combination_id
and gcc.segment4 = '220201' --科目段---应付有票
and ael.third_party_id = pv.vendor_id
and ael.third_party_sub_id = vs.vendor_site_id
and ael.gl_sl_link_id = r.gl_sl_link_id
and ae.accounting_event_id = aeh.accounting_event_id
and ai.invoice_id = ae.source_id
and ae.source_table = 'AP_INVOICES'
and aeh.ae_header_id = ael.ae_header_id
and gcc.segment2 = nvl(p_syb_name, gcc.segment2) --事业部
and pv.vendor_id = nvl(p_vendor_name, pv.vendor_id)
and vs.vendor_site_id = nvl(p_vendor_site, vs.vendor_site_id)
and gjh.period_name between p_begin_date and p_end_date
and r.gl_sl_link_table = 'APECL'
成长
/ | \
学习 总结 分享
QQ交流群:122230156