追溯AR收款核销的日记账的SQL

问题描述:
如何用SQL从应收的收款核销追溯到该核销生成的日记账

解决方法
可以用如下SQL
SELECT cr.receipt_number,
cr.cash_receipt_id,
arp.receivable_application_id,
xal.entered_dr,
xal.entered_cr,
xal.code_combination_id,
xah.event_id,
xal.ae_header_id
FROM ar_cash_receipts_all cr,
ar_receivable_applications_all arp,
ar_distributions_all ard,
xla_ae_headers xah,
xla_ae_lines xal,
xla_events xet,
xla_distribution_links xdl,
gl_code_combinations gcc
WHERE xal.ae_header_id = xah.ae_header_id
AND xet.event_id = xah.event_id
AND xdl.event_id = xet.event_id
AND xdl.ae_header_id = xah.ae_header_id
AND xdl.ae_line_num = xal.ae_line_num
AND xdl.source_distribution_type IN (‘AR_DISTRIBUTIONS_ALL’,
‘MFAR_DISTRIBUTIONS_ALL’)
AND xdl.source_distribution_id_num_1 = ard.line_id
AND ard.source_id = arp.receivable_application_id
AND ard.source_table = ‘RA’
AND xdl.application_id = 222
AND arp.cash_receipt_id = cr.cash_receipt_id
AND cr.cash_receipt_id = :receipt_id
AND gcc.code_combination_id = xal.code_combination_id
AND gcc.segment1 != ‘00000000000000’
参考信息
SQL中各表的连接关系如下图:
在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值