优化对账单接口,扣除退货单的欠款金额
This commit is contained in:
@@ -591,6 +591,13 @@
|
||||
and dh.type=#{type} and dh.sub_type=#{subType}
|
||||
and dh.oper_time <= #{beginTime}
|
||||
and ifnull(dh.delete_flag,'0') !='1') preDebtMoney,
|
||||
(select
|
||||
ifnull(sum(dh.discount_last_money),0)+ifnull(sum(dh.other_money),0)-ifnull(sum(dh.deposit),0)-abs(ifnull(sum(dh.change_amount),0))
|
||||
from jsh_depot_head dh
|
||||
where dh.organ_id=s.id
|
||||
and dh.type=#{typeBack} and dh.sub_type=#{subTypeBack}
|
||||
and dh.oper_time <= #{beginTime}
|
||||
and ifnull(dh.delete_flag,'0') !='1') preReturnDebtMoney,
|
||||
(select abs(ifnull(sum(ai.each_amount),0)) from jsh_account_item ai
|
||||
left join jsh_depot_head dh on ai.bill_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
|
||||
where dh.organ_id=s.id
|
||||
@@ -603,6 +610,13 @@
|
||||
and dh.type=#{type} and dh.sub_type=#{subType}
|
||||
and dh.oper_time>#{beginTime} and dh.oper_time <= #{endTime}
|
||||
and ifnull(dh.delete_flag,'0') !='1') debtMoney,
|
||||
(select
|
||||
ifnull(sum(dh.discount_last_money),0)+ifnull(sum(dh.other_money),0)-ifnull(sum(dh.deposit),0)-abs(ifnull(sum(dh.change_amount),0))
|
||||
from jsh_depot_head dh
|
||||
where dh.organ_id=s.id
|
||||
and dh.type=#{typeBack} and dh.sub_type=#{subTypeBack}
|
||||
and dh.oper_time>#{beginTime} and dh.oper_time <= #{endTime}
|
||||
and ifnull(dh.delete_flag,'0') !='1') returnDebtMoney,
|
||||
(select abs(ifnull(sum(ai.each_amount),0)) from jsh_account_item ai
|
||||
left join jsh_depot_head dh on ai.bill_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
|
||||
where dh.organ_id=s.id
|
||||
@@ -623,7 +637,7 @@
|
||||
</if>
|
||||
and ifnull(s.delete_flag,'0') !='1') tb
|
||||
where begin_need+preDebtMoney-preBackMoney+debtMoney-backMoney>0
|
||||
order by begin_need+preDebtMoney-preBackMoney+debtMoney-backMoney desc
|
||||
order by begin_need+preDebtMoney-preReturnDebtMoney-preBackMoney+debtMoney-returnDebtMoney-backMoney desc
|
||||
<if test="offset != null and rows != null">
|
||||
limit #{offset},#{rows}
|
||||
</if>
|
||||
@@ -640,6 +654,13 @@
|
||||
and dh.type=#{type} and dh.sub_type=#{subType}
|
||||
and dh.oper_time <= #{beginTime}
|
||||
and ifnull(dh.delete_flag,'0') !='1') preDebtMoney,
|
||||
(select
|
||||
ifnull(sum(dh.discount_last_money),0)+ifnull(sum(dh.other_money),0)-ifnull(sum(dh.deposit),0)-abs(ifnull(sum(dh.change_amount),0))
|
||||
from jsh_depot_head dh
|
||||
where dh.organ_id=s.id
|
||||
and dh.type=#{typeBack} and dh.sub_type=#{subTypeBack}
|
||||
and dh.oper_time <= #{beginTime}
|
||||
and ifnull(dh.delete_flag,'0') !='1') preReturnDebtMoney,
|
||||
(select abs(ifnull(sum(ai.each_amount),0)) from jsh_account_item ai
|
||||
left join jsh_depot_head dh on ai.bill_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
|
||||
where dh.organ_id=s.id
|
||||
@@ -652,6 +673,13 @@
|
||||
and dh.type=#{type} and dh.sub_type=#{subType}
|
||||
and dh.oper_time>#{beginTime} and dh.oper_time <= #{endTime}
|
||||
and ifnull(dh.delete_flag,'0') !='1') debtMoney,
|
||||
(select
|
||||
ifnull(sum(dh.discount_last_money),0)+ifnull(sum(dh.other_money),0)-ifnull(sum(dh.deposit),0)-abs(ifnull(sum(dh.change_amount),0))
|
||||
from jsh_depot_head dh
|
||||
where dh.organ_id=s.id
|
||||
and dh.type=#{typeBack} and dh.sub_type=#{subTypeBack}
|
||||
and dh.oper_time>#{beginTime} and dh.oper_time <= #{endTime}
|
||||
and ifnull(dh.delete_flag,'0') !='1') returnDebtMoney,
|
||||
(select abs(ifnull(sum(ai.each_amount),0)) from jsh_account_item ai
|
||||
left join jsh_depot_head dh on ai.bill_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
|
||||
where dh.organ_id=s.id
|
||||
@@ -671,12 +699,12 @@
|
||||
)
|
||||
</if>
|
||||
and ifnull(s.delete_flag,'0') !='1') tb
|
||||
where begin_need+preDebtMoney-preBackMoney+debtMoney-backMoney>0
|
||||
where begin_need+preDebtMoney-preReturnDebtMoney-preBackMoney+debtMoney-returnDebtMoney-backMoney>0
|
||||
</select>
|
||||
|
||||
<select id="getStatementAccountTotalPay" resultType="com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount">
|
||||
select sum(begin_need) begin_need, sum(preDebtMoney) preDebtMoney, sum(preBackMoney) preBackMoney,
|
||||
sum(debtMoney) debtMoney, sum(backMoney) backMoney from
|
||||
select sum(begin_need) begin_need, sum(preDebtMoney) preDebtMoney, sum(preReturnDebtMoney) preReturnDebtMoney, sum(preBackMoney) preBackMoney,
|
||||
sum(debtMoney) debtMoney, sum(returnDebtMoney) returnDebtMoney, sum(backMoney) backMoney from
|
||||
(select s.id,
|
||||
(case when s.type='供应商' then ifnull(s.begin_need_pay,0) else ifnull(s.begin_need_get,0) end) begin_need,
|
||||
(select
|
||||
@@ -686,6 +714,13 @@
|
||||
and dh.type=#{type} and dh.sub_type=#{subType}
|
||||
and dh.oper_time <= #{beginTime}
|
||||
and ifnull(dh.delete_flag,'0') !='1') preDebtMoney,
|
||||
(select
|
||||
ifnull(sum(dh.discount_last_money),0)+ifnull(sum(dh.other_money),0)-ifnull(sum(dh.deposit),0)-abs(ifnull(sum(dh.change_amount),0))
|
||||
from jsh_depot_head dh
|
||||
where dh.organ_id=s.id
|
||||
and dh.type=#{typeBack} and dh.sub_type=#{subTypeBack}
|
||||
and dh.oper_time <= #{beginTime}
|
||||
and ifnull(dh.delete_flag,'0') !='1') preReturnDebtMoney,
|
||||
(select abs(ifnull(sum(ai.each_amount),0)) from jsh_account_item ai
|
||||
left join jsh_depot_head dh on ai.bill_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
|
||||
where dh.organ_id=s.id
|
||||
@@ -698,6 +733,13 @@
|
||||
and dh.type=#{type} and dh.sub_type=#{subType}
|
||||
and dh.oper_time>#{beginTime} and dh.oper_time <= #{endTime}
|
||||
and ifnull(dh.delete_flag,'0') !='1') debtMoney,
|
||||
(select
|
||||
ifnull(sum(dh.discount_last_money),0)+ifnull(sum(dh.other_money),0)-ifnull(sum(dh.deposit),0)-abs(ifnull(sum(dh.change_amount),0))
|
||||
from jsh_depot_head dh
|
||||
where dh.organ_id=s.id
|
||||
and dh.type=#{typeBack} and dh.sub_type=#{subTypeBack}
|
||||
and dh.oper_time>#{beginTime} and dh.oper_time <= #{endTime}
|
||||
and ifnull(dh.delete_flag,'0') !='1') returnDebtMoney,
|
||||
(select abs(ifnull(sum(ai.each_amount),0)) from jsh_account_item ai
|
||||
left join jsh_depot_head dh on ai.bill_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
|
||||
where dh.organ_id=s.id
|
||||
@@ -717,7 +759,7 @@
|
||||
)
|
||||
</if>
|
||||
and ifnull(s.delete_flag,'0') !='1') tb
|
||||
where begin_need+preDebtMoney-preBackMoney+debtMoney-backMoney>0
|
||||
where begin_need+preDebtMoney-preReturnDebtMoney-preBackMoney+debtMoney-returnDebtMoney-backMoney>0
|
||||
</select>
|
||||
|
||||
<select id="findAllMoney" resultType="java.math.BigDecimal">
|
||||
|
||||
Reference in New Issue
Block a user