拆分日記賬追溯視圖4-來源於應付類型應付發票

來源:互聯網
上載者:User
來源於應付類型應付發票(這個拆分的比較徹底)


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'

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.