demand: TMS系统 - 客户账单管理 - 收款明细查询 - 开票金额、开票状态取值不准确问题修复
committer: heyu
This commit is contained in:
parent
fae230d502
commit
20a9c5a5e7
@ -655,7 +655,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="getInvoiceAmountsByPayIds" parameterType="java.util.List" resultType="map">
|
||||
select
|
||||
espbr.pay_id,
|
||||
SUM(esir.money) as total_amount
|
||||
(
|
||||
SUM(esir.money)
|
||||
+ COALESCE(
|
||||
(
|
||||
select SUM(COALESCE(r.add_open_money, 0))
|
||||
from emis_settle_invoice_record r
|
||||
where r.del_flag = '0' and r.invoice_status = '2'
|
||||
and r.apply_seq_no in (
|
||||
select distinct esir2.apply_seq_no
|
||||
from emis_settle_pay_bill_rel espbr2
|
||||
left join emis_settle_sub_bill essb2 on espbr2.settle_bill_no = essb2.settle_bill_no
|
||||
left join emis_settle_invoice_rel esir2 on essb2.bill_code = esir2.bill_no
|
||||
where espbr2.del_flag = '0' and essb2.del_flag = '0' and esir2.del_flag = '0'
|
||||
and espbr2.pay_id = espbr.pay_id
|
||||
)
|
||||
), 0)
|
||||
) as total_amount
|
||||
from emis_settle_pay_bill_rel espbr
|
||||
left join emis_settle_sub_bill essb on espbr.settle_bill_no = essb.settle_bill_no
|
||||
left join emis_settle_invoice_rel esir on essb.bill_code = esir.bill_no
|
||||
@ -708,7 +724,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
select
|
||||
espbr.pay_id,
|
||||
DATE(esir_record.op_date) as invoice_date,
|
||||
SUM(esir.money) as invoice_amount,
|
||||
(
|
||||
SUM(esir.money)
|
||||
+ COALESCE(
|
||||
(
|
||||
select SUM(COALESCE(r.add_open_money, 0))
|
||||
from emis_settle_invoice_record r
|
||||
where r.del_flag = '0' and r.invoice_status = '2'
|
||||
and DATE(r.op_date) = DATE(esir_record.op_date)
|
||||
and r.company_name = esir_record.company_name
|
||||
and r.apply_seq_no in (
|
||||
select distinct esir2.apply_seq_no
|
||||
from emis_settle_pay_bill_rel espbr2
|
||||
left join emis_settle_sub_bill essb2 on espbr2.settle_bill_no = essb2.settle_bill_no
|
||||
left join emis_settle_invoice_rel esir2 on essb2.bill_code = esir2.bill_no
|
||||
where espbr2.del_flag = '0' and essb2.del_flag = '0' and esir2.del_flag = '0'
|
||||
and espbr2.pay_id = espbr.pay_id
|
||||
)
|
||||
), 0)
|
||||
) as invoice_amount,
|
||||
GROUP_CONCAT(DISTINCT esir_record.company_name SEPARATOR ' ') as company_name,
|
||||
0 as total_invoice_amount,
|
||||
0 as bill_amount
|
||||
@ -732,7 +766,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
NULL as invoice_date,
|
||||
0 as invoice_amount,
|
||||
'' as company_name,
|
||||
SUM(CASE WHEN esir_record.invoice_status = '2' THEN esir.money ELSE 0 END) as total_invoice_amount,
|
||||
(
|
||||
SUM(CASE WHEN esir_record.invoice_status = '2' THEN esir.money ELSE 0 END)
|
||||
+ COALESCE(
|
||||
(
|
||||
select SUM(COALESCE(r.add_open_money, 0))
|
||||
from emis_settle_invoice_record r
|
||||
where r.del_flag = '0' and r.invoice_status = '2'
|
||||
and r.apply_seq_no in (
|
||||
select distinct esir2.apply_seq_no
|
||||
from emis_settle_pay_bill_rel espbr2
|
||||
left join emis_settle_sub_bill essb2 on espbr2.settle_bill_no = essb2.settle_bill_no
|
||||
left join emis_settle_invoice_rel esir2 on essb2.bill_code = esir2.bill_no
|
||||
where espbr2.del_flag = '0' and essb2.del_flag = '0' and esir2.del_flag = '0'
|
||||
and espbr2.pay_id = espbr.pay_id
|
||||
)
|
||||
), 0)
|
||||
) as total_invoice_amount,
|
||||
MAX(esb.rec_money) as bill_amount
|
||||
from emis_settle_pay_bill_rel espbr
|
||||
left join emis_settle_sub_bill essb on espbr.settle_bill_no = essb.settle_bill_no
|
||||
|
||||
Loading…
Reference in New Issue
Block a user