表名:GL_IMPORT_REFERENCES
说明:总账导入附加信息表
用途:用来追溯从子模块传入总账模块的明细,对于报表开发很有帮助
SQL 语句:
select * from gl_je_headers gjh, gl_je_lines gjl, gl_import_references gir where gjh.je_header_id = gjl.je_header_id and gjl.je_header_id = gir.je_header_id and gjl.je_line_num = gir.je_line_num;
1、gjh.je_source = 'Payables':
1)与 AP 模块关联表:ap_ae_lines_all
2)SQL 语句:
select * from gl_je_headers gjh, gl_je_lines gjl, gl_import_references gir, ap_ae_lines_all ael, ap_ae_headers_all aeh where gjh.je_header_id = gjl.je_header_id and gjl.je_header_id = gir.je_header_id and gjl.je_line_num = gir.je_line_num and gjh.je_source = 'Payables' and gir.gl_sl_link_id = ael.gl_sl_link_id and ael.ae_header_id = aeh.ae_header_id;
3)根据 aeh.ae_category 或 aeh.accounting_event_id 判断业务性质,从而关联以下数据
库表进行取值;
ap_invoices_all
ap_invoice_distributions_all
ap_checks_all
ap_invoice_payments_all
ap_accounting_events_all
4)借贷金额计算逻辑:
直接取 ap_ae_lines_all 的 ael.accounted_dr,ael.accounted_cr 字段值
借项:
ael.accounted_dr;
贷项:
ael.accounted_cr;
2、gjh.je_source = 'Receivables':
1)gjh.je_category in ('Credit Memos', 'Sales Invoices')
A. 与 AR 关联表:ra_cust_trx_line_gl_dist_all
2
B. SQL 语句:
select * from gl_je_headers gjh, gl_je_lines gjl, gl_import_references gir, ra_cust_trx_line_gl_dist_all rcl where gjh.je_header_id = gjl.je_header_id and gjl.je_header_id = gir.je_header_id and gjl.je_line_num = gir.je_line_num and gjh.je_source = 'Receivables' and gjh.je_category in ('Credit Memos', 'Sales Invoices') and gir.reference_3 = to_char(rcl.cust_trx_line_gl_dist_id);
C. 根据 rcl.customer_trx_id、rcl.customer_trx_line_id 关联以下表:
ra_customer_trx_all
ra_customer_trx_lines_all
D. 借贷金额计算逻辑:
根据自总账模块所追溯科目的性质,判断 sign(rcl.acctd_amount)的符号和
gjl.accounted_dr 是否为空,分别列在借方和贷方金额栏。
以下为应收账款科目借贷方金额计算逻辑,仅供参考:
借项:
decode(sign(rcl.acctd_amount), 1, rcl.acctd_amount, 0, 0, -1, 0) acctd_dr;
贷项:
decode(sign(rcl.acctd_amount), 1, 0, 0, 0, -1, rcl.acctd_amount * -1) acctd_cr;
2)gjh.je_category in ('Trade Receipts', 'Credit Memo Applications')
A. 与 AR 关联表:ar_receivable_applications_all
B. SQL 语句:
select * from gl_je_headers gjh, gl_je_lines gjl, gl_import_references gir, ar_receivable_applications_all ara where gjh.je_header_id = gjl.je_header_id and gjl.je_header_id = gir.je_header_id 3 and gjl.je_line_num = gir.je_line_num and gjh.je_source = 'Receivables' and gjh.je_category in ('Trade Receipts', 'Credit Memo Applications') and decode(gjh.je_category, 'Trade Receipts', substr(gir.reference_2, instr(gir.reference_2, 'C', 1) + 1), gir.reference_2) = ara.receivable_application_id;
C. 根据 ara.cash_receipt_id、 ara.customer_trx_id、 ara.applied_customer_trx_id
关联以下表:
ar_cash_receipts_all
ra_customer_trx_all
D. 借贷金额计算逻辑:
根据自总账模块所追溯科目的性质,判断 sign(ara.acctd_amount_applied_to)
的符号和 gjl.accounted_dr 是否为空,分别列在借方和贷方金额栏。
以下为应收账款科目借贷方金额计算逻辑,仅供参考:
借项:
decode(gjh.je_category, 'Trade Receipts', decode(sign(ara.acctd_amount_applied_to), 0, 0, 1, 0, ara.acctd_amount_applied_to * -1), decode(sign(ara.acctd_amount_applied_to), 0, 0, 1, decode(gjl.accounted_dr, null, 0, ara.acctd_amount_applied_to), decode(gjl.accounted_dr, null, 0, ara.acctd_amount_applied_to * -1))) acctd_dr;
贷项:
decode(gjh.je_category, 'Trade Receipts', decode(sign(ara.acctd_amount_applied_to), 0, 0, 1, ara.acctd_amount_applied_to, 4 0), decode(sign(ara.acctd_amount_applied_to), 0, 0, 1, decode(gjl.accounted_dr, null, ara.acctd_amount_applied_to, 0), decode(gjl.accounted_dr, null, ara.acctd_amount_applied_to * -1, 0))) acctd_cr;
3、gjh.je_source = 'Inventory':
1)与 INV 关联表:mtl_transaction_accounts
2)SQL 语句:
select * from gl_je_headers gjh, gl_je_lines gjl, gl_import_references gir, mtl_transaction_accounts mta, mtl_material_transactions mmt where gjh.je_header_id = gjl.je_header_id and gir.je_header_id = gjl.je_header_id and gir.je_line_num = gjl.je_line_num and gjh.je_source = 'Inventory' and gir.reference_1 = to_char(mta.gl_batch_id) and mta.transaction_id = mmt.transaction_id;
3)根据 mmt.transaction_type_id 关联以下表:
mtl_transaction_types
oe_order_headers_all
oe_order_liness_all
rcv_transactions
po_hedaers_all
po_lines_all
mtl_txn_request_headers
mtl_txn_request_lines
mtl_generic_dispositions
4)借贷金额计算逻辑:
根据自总账模块所追溯科目的性质,判断 sign(mta.base_transaction_value)的符
号,分别列在借方和贷方金额栏
以下为销售成本科目借贷方借计算逻辑,仅供参考:
借项:
decode(sign(mta.base_transaction_value), 5 1, mta.base_transaction_value, 0) acctd_dr; 贷项: decode(sign(mta.base_transaction_value), -1, mta.base_transaction_value * -1, 0) acctd_cr;
4、gjh.je_source = 'Purchasing':
1)与 PO 关联表:rcv_receiving_sub_ledger
2)SQL 语句:
select * from gl_je_headers gjh, gl_je_lines gjl, gl_import_references gir, rcv_receiving_sub_ledger rcs where gjh.je_header_id = gjl.je_header_id and gir.je_header_id = gjl.je_header_id and gir.je_line_num = gjl.je_line_num and gjh.je_source = 'Purchasing' and gir.reference_5 = to_char(rcs.rcv_transaction_id);
3)根据 rcs.rcv_transaction_id 关联以下表:
rcv_transactions
po_headers_all
po_lines_all
po_line_locations_all
po_distributions_all
4)借贷金额计算逻辑:
直接取 rcv_receiving_sub_ledger 的 rcs.accounted_dr 和 rcs.accounted_cr 字
段值
借项:
rcs.accounted_dr;
贷项:
rcs.accounted_cr;
5、gjh.je_source = 'Assets':
1)与 FA 关联表:fa_adjustments
2)SQL 语句:
select * from gl_je_headers gjh, gl_je_lines gjl, gl_import_references gir, fa_adjustments fad where gjh.je_header_id = gjl.je_header_id and gir.je_header_id = gjl.je_header_id 6 and gir.je_line_num = gjl.je_line_num and gjh.je_source = 'Assets' and gir.je_header_id = fad.je_header_id and gir.je_line_num = fad.je_line_num;
3)根据 source_type_code 关联以下表:
fa_additions_b
fa_additions_tl
fa_books
fa_deprn_detail
fa_deprn_summary
fa_retirements
fa_transfer_details
fa_distribution_accounts
fa_distribution_history
fa_transaction_headers
4)借贷金额计算逻辑:
根据 fad.debit_credit_flag 的性质,判断 fad.adjustment_amount 的借贷方属性
借项:
decode(fad.debit_credit_flag,
'DR',
fad.adjustment_amount,
0) acctd_dr;
贷项:
decode(fad.debit_credit_flag,
'CR',
fad.adjustment_amount,
0) acctd_cr;