apzl_leasing/config/fenix/flow/PenaltyReductionFlow.xml

133 lines
9.1 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<fenixs namespace="flow.PenaltyReductionFlow">
<!-- 审批页面-租金回笼计划 -->
<fenix id="queryRentPlanList">
select tt.*,
tt.rent - tt.fact_rent as rent_over,
tt.corpus - tt.fact_corpus - tt.corpus_adjust as corpus_over,
tt.interest - tt.fact_interest - tt.interest_adjust as interest_over,
tt.penalty - tt.fact_penalty - tt.penalty_adjust as penalty_over,
case
when tt.rent = tt.fact_rent and tt.penalty = tt.fact_penalty + tt.penalty_adjust then '已回笼'
when tt.fact_rent > 0 then '部分回笼'
else '未回笼' end as planstatus
from (select lcf.id as id,
lbc.project_id as project_id,
lbc.id as contract_id,
lbc.contract_status as contract_status,
lbc.businesstype as businesstype,
lbc.subjectid as subjectid,
lbc.distributor_id as distributor_id,
lbc.contract_number as contract_number,
lcf.payment_number as payment_number,
ifnull(lbu.customername, '') as customername,
lbc.project_name as project_name,
lcf.plan_list as plan_list,
lcf.plan_date as plan_date,
lcf.rent as rent,
lcf.corpus as corpus,
lcf.interest as interest,
getrentpenalty(lcf.payment_number, lcf.plan_list, date_format(now(), '%Y/%m/%d')) as penalty,
round(ifnull(lcfd.rent, 0) + ifnull(lcfi.rent, 0), 2) as fact_rent,
round(ifnull(lcfd.corpus, 0) + ifnull(lcfi.corpus, 0), 2) as fact_corpus,
round(ifnull(lcfd.interest, 0) + ifnull(lcfi.interest, 0), 2) as fact_interest,
round(ifnull(lcfd.penalty, 0) + ifnull(lcfi.penalty, 0), 2) as fact_penalty,
round(ifnull(lcfd.corpus_adjust, 0) + ifnull(lcfi.corpus_adjust, 0), 2) as corpus_adjust,
round(ifnull(lcfd.interest_adjust, 0) + ifnull(lcfi.interest_adjust, 0), 2) as interest_adjust,
round(ifnull(lcfd.penalty_adjust, 0) + ifnull(lcfi.penalty_adjust, 0), 2) as penalty_adjust
from lc_rent_plan lcf
left join lb_contract_info lbc
on lcf.contract_id = lbc.id
left join lc_calc_condition_status lccs
on lccs.payment_number = lcf.payment_number
left join lb_union_lessee_transfer lbu
on lcf.contract_id = lbu.contract_id
left join (select lri.payment_number as payment_number,
lri.plan_list as plan_list,
lri.plan_id as plan_id,
sum(lri.rent) as rent,
sum(lri.corpus) as corpus,
sum(lri.interest) as interest,
sum(lri.penalty) as penalty,
sum(lri.corpus_adjust) as corpus_adjust,
sum(lri.interest_adjust) as interest_adjust,
sum(lri.penalty_adjust) as penalty_adjust
from lc_rent_income lri
where payment_number = #{paramstr}
and lri.roll_back = '0'
group by lri.payment_number, lri.plan_list
) lcfd
on lcf.payment_number = lcfd.payment_number and
lcf.plan_list = lcfd.plan_list
left join (select lrit.payment_number as payment_number,
lrit.plan_list as plan_list,
sum(lrit.rent) as rent,
sum(lrit.corpus) as corpus,
sum(lrit.interest) as interest,
sum(lrit.penalty) as penalty,
sum(lrit.corpus_adjust) as corpus_adjust,
sum(lrit.interest_adjust) as interest_adjust,
sum(lrit.penalty_adjust) as penalty_adjust
from lc_rent_income_temp lrit
where payment_number = #{paramstr}
and lrit.is_flowing = 0
and lrit.roll_back = '0'
group by lrit.payment_number, lrit.plan_list
) lcfi
on lcf.payment_number = lcfi.payment_number and lcf.plan_list = lcfi.plan_list
where lcf.payment_number = #{paramstr}
) tt
where tt.rent > tt.fact_rent or tt.penalty > tt.fact_penalty
order by tt.payment_number, tt.plan_list
</fenix>
<fenix id="queryRentPlanRemainPenalty">
select round(getRentPenalty(lrp.PAYMENT_NUMBER, lrp.PLAN_LIST, date_format(now(), '%Y/%m/%d')) -
ifnull((select sum(lri.PENALTY + PENALTY_ADJUST)
from lc_rent_income lri
where roll_back = '0' and lri.PAYMENT_NUMBER = lrp.PAYMENT_NUMBER
and lri.PLAN_LIST = lrp.PLAN_LIST
), 0) - ifnull((select sum(lri.PENALTY + PENALTY_ADJUST)
from lc_rent_income_temp lri
where is_flowing = '0' and roll_back = '0' and lri.PAYMENT_NUMBER = lrp.PAYMENT_NUMBER
and lri.PLAN_LIST = lrp.PLAN_LIST
), 0),
2) as over_penalty
from lc_rent_plan lrp
where lrp.id = #{planId}
</fenix>
<fenix id="queryRentPlanPenalty">
select tt.penalty,
tt.fact_penalty,
tt.penalty_adjust,
tt.penalty - tt.fact_penalty - tt.penalty_adjust as penalty_over
from (select round(getrentpenalty(lrp.payment_number, lrp.plan_list, date_format(now(), '%Y/%m/%d')),
2) as penalty,
round(ifnull(lri.fact_penalty, 0) + ifnull(lrit.fact_penalty, 0), 2) as fact_penalty,
round(ifnull(lri.penalty_adjust, 0) + ifnull(lrit.penalty_adjust, 0), 2) as penalty_adjust
from lc_rent_plan lrp
left join (select payment_number,
plan_list,
sum(penalty) as fact_penalty,
sum(penalty_adjust) as penalty_adjust
from lc_rent_income
where roll_back = '0'
and payment_number = #{paymentNumber}
and plan_list = #{planList}
) lri on lrp.payment_number = lri.payment_number and lrp.plan_list = lri.plan_list
left join (select payment_number,
plan_list,
sum(penalty) as fact_penalty,
sum(penalty_adjust) as penalty_adjust
from lc_rent_income_temp
where is_flowing = '0'
and roll_back = '0'
and payment_number = #{paymentNumber}
and plan_list = #{planList}
) lrit on lrp.payment_number = lrit.payment_number and lrp.plan_list = lrit.plan_list
where lrp.payment_number = #{paymentNumber}
and lrp.plan_list = #{planList}
) tt
</fenix>
</fenixs>