|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622 。
您需要 登录 才可以下载或查看,没有帐号?注册
x
发票,付款,PO追溯过程:
1. 发票到凭证的过程:
----------------------------------------------------------------------------------------------
1.1.根据发票号找到invoice_id=39207;发票批:batch_id=12096;
select api.invoice_id,api.batch_id from ap_invoices_all api where api.invoice_num='EZ00064968';
1.2.发票批信息
select * from ap_batches_all apb where apb.batch_id=12096;
1.3根据发票id获取凭证编号 '221000601000334','221001008000567','221001002000570'
SELECT SUBLEDGER_DOC_SEQUENCE_VALUE
FROM cap_doc_sequence_v
WHERE (INVOICE_ID = 39207)
order by SUBLEDGER_DOC_SEQUENCE_VALUE
;
--或者
select distinct ael.subledger_doc_sequence_value
from ap_ae_lines_all ael
,ap_ae_headers_all aeh
,ap_accounting_events_all ae
where ael.ae_header_id = aeh.ae_header_id
and aeh.accounting_event_id = ae.accounting_event_id
and ae.source_id=39207
order by 1
;
1.4.根据凭证编号查财务事件表 accounting_event_id(70641,1383791,1525729)
select aeh.accounting_event_id
from ap_ae_headers_all aeh
where exists(select NULL from ap_ae_lines_all ael
where ael.subledger_doc_sequence_value in ('221000601000334','221001008000567','221001002000570')
and ael.source_table='AP_INVOICE_DISTRIBUTIONS'
and ael.ae_header_id = aeh.ae_header_id)
;
--或者直接根据source_id[即发票ID]来查也可以:
select ae.accounting_event_id from ap_accounting_events_all ae where ae.source_id=39207 and source_table='AP_INVOICES';
1.5 付款事务暂记表(头) 取得ae_header_id 为(68793,1392964,1535376)
select * from ap_ae_headers_all aeh where aeh.accounting_event_id in (70641,1383791,1525729);
1.6 付款事务暂记表(行) 取得凭证编号:221010603000036 关联id,gl_sl_link_id为271268,271269
select * from ap_ae_lines_all ael where ael.ae_header_id in (68793,1392964,1535376);
1.7 根据凭证编号获取凭证信息
1.7.1 根据凭证编号获取凭证批(204431,2106157,2307459),凭证头(103796,1539007,1673012)
SELECT distinct gir.je_batch_id,gir.je_header_id
from GL_IMPORT_REFERENCES GIR
WHERE exists(
select 1 from ap_ae_lines_all ael
where ael.subledger_doc_sequence_value in ('221000601000334','221001008000567','221001002000570')
and ael.source_table='AP_INVOICE_DISTRIBUTIONS'
and ael.gl_sl_link_id = gir.gl_sl_link_id
and ael.subledger_doc_sequence_value = gir.subledger_doc_sequence_value
)
;
1.7.2 凭证批信息
select * from gl_je_batches gjb where gjb.je_batch_id in (204431,2106157,2307459);
1.7.3 凭证头信息
select * from gl_je_headers gjh where gjh.je_header_id in (103796,1539007,1673012);
1.7.4 凭证行信息
select * from gl_je_lines gjl
where exists(
SELECT 1
from GL_IMPORT_REFERENCES GIR
WHERE exists(
select 1 from ap_ae_lines_all ael
where ael.subledger_doc_sequence_value in ('221000601000334','221001008000567','221001002000570')
and ael.source_table='AP_INVOICE_DISTRIBUTIONS'
and ael.gl_sl_link_id = gir.gl_sl_link_id
and ael.subledger_doc_sequence_value = gir.subledger_doc_sequence_value
)
and gir.je_header_id = gjl.je_header_id
and gir.je_line_num = gjl.je_line_num
)
and gjl.je_header_id in (103796,1539007,1673012)
;
2. 发票到付款,凭证的过程:
------------------------------------------------------------------------------------------
2.1 根据发票id,查找对应的付款id,即check_id=1786591,财务事件id,即accounting_event_id=84959
select * from ap_invoice_payments_all aip where aip.invoice_id=39207;
2.2 付款表
select ac.* from ap_checks_all ac where ac.check_id=1786591 ;
2.3 付款事件
select * from ap_accounting_events_all ae where ae.accounting_event_id=84959;
2.4 付款事务暂记表(头) 取得ae_header_id=83191
select * from ap_ae_headers_all aeh where aeh.accounting_event_id=84959;
2.5 付款事务暂记表(行) 取得凭证编号:221010603000036 关联id,gl_sl_link_id为271268,271269
select * from ap_ae_lines_all ael where ael.ae_header_id=83191;
2.6 根据发票id获取凭证信息
2.6.1 根据凭证编号获取凭证批(242851),凭证头(141766)
SELECT distinct gir.je_batch_id,gir.je_header_id
from GL_IMPORT_REFERENCES GIR
WHERE gir.subledger_doc_sequence_value='221010603000036'
and gir.gl_sl_link_id in (271268,271269)
;
2.6.2 凭证批信息
select * from gl_je_batches gjb where gjb.je_batch_id in (242851);
2.6.3 凭证头信息
select * from gl_je_headers gjh where gjh.je_header_id in (141766);
2.6.4 凭证行信息
select * from gl_je_lines gjl
where exists(
SELECT 1
from GL_IMPORT_REFERENCES GIR
WHERE gir.subledger_doc_sequence_value='221010603000036'
and gir.gl_sl_link_id in (271268,271269)
and gir.je_header_id = gjl.je_header_id
and gir.je_line_num = gjl.je_line_num
)
and gjl.je_header_id in (141766)
;
3.追溯PO相关信息
-------------------------------------------------------------------------------------
3.1 从发票分配表获取po_distribution_id,rcv_transaction_id
select aid.po_distribution_id
,aid.rcv_transaction_id
from ap_invoice_distributions_all aid
where aid.invoice_id=39207
;
3.2 从po分配表获取po_header_id,po_line_id,line_location_id,po_release_id等信息
select from po_distributions_all pod
where pod.po_distribution_id in (
select aid.po_distribution_id
from ap_invoice_distributions_all aid
where aid.invoice_id=39207
)
;
3.3 po头信息
select * from po_headers_all ph where ph.po_header_id=901;
3.4 po行信息
select * from po_lines_all pl where pl.po_header_id=901;
3.5 po发运信息
select * from po_line_locations_all pl where pl.po_header_id=901;
3.6 库存事务信息
select * from rcv_transactions rt
where exists(
select NULL
from ap_invoice_distributions_all aid
where aid.invoice_id=39207
and aid.rcv_transaction_id = rt.transaction_id
)
;
3.6 po收货头信息
select * from rcv_shipment_headers rsh
where rsh.shipment_header_id in (
select distinct rt.shipment_header_id
from rcv_transactions rt
where exists(
select NULL
from ap_invoice_distributions_all aid
where aid.invoice_id=39207
and aid.rcv_transaction_id = rt.transaction_id
)
)
;
3.7 po收货行信息
select * from rcv_shipment_lines rsl
where rsl.shipment_line_id in
(
select distinct rt.shipment_line_id
from rcv_transactions rt
where exists(
select NULL
from ap_invoice_distributions_all aid
where aid.invoice_id=39207
and aid.rcv_transaction_id = rt.transaction_id
)
)
;
3.8 可能涉及的成本
select * from mtl_material_transactions mmt
where exists(
select NULL
from rcv_transactions rt
where rt.po_header_id=901
and rt.transaction_id=mmt.rcv_transaction_id
)
;
|
|