apzl_leasing/config/fenix/flow/PenaltyReductionFlow.xml

141 lines
10 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<fenixs namespace="flow.PenaltyReductionFlow">
<!-- 审批页面-租金回笼计划 -->
<fenix id="queryRentPlanList">
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,
(ifnull(lcfd.rent, 0) + ifnull(lcfi.rent, 0)) AS fact_rent,
(ifnull(lcfd.corpus, 0) + ifnull(lcfi.corpus, 0)) AS fact_corpus,
(ifnull(lcfd.interest, 0) + ifnull(lcfi.interest, 0)) AS fact_interest,
(ifnull(lcfd.penalty, 0) + ifnull(lcfi.penalty, 0)) AS fact_penalty,
(ifnull(lcfd.corpus_adjust, 0) + ifnull(lcfi.corpus_adjust, 0)) AS corpus_adjust,
(ifnull(lcfd.interest_adjust, 0) + ifnull(lcfi.interest_adjust, 0)) AS interest_adjust,
(ifnull(lcfd.penalty_adjust, 0) + ifnull(lcfi.penalty_adjust, 0)) AS penalty_adjust,
(lcf.RENT - (ifnull(lcfd.rent, 0) + ifnull(lcfi.rent, 0))) AS rent_over,
(lcf.CORPUS -
(((ifnull(lcfd.corpus, 0) + ifnull(lcfi.corpus, 0)) + ifnull(lcfd.corpus_adjust, 0)) +
ifnull(lcfi.corpus_adjust, 0))) AS corpus_over,
(lcf.INTEREST -
(((ifnull(lcfd.interest, 0) + ifnull(lcfi.interest, 0)) + ifnull(lcfd.interest_adjust, 0)) +
ifnull(lcfi.interest_adjust, 0))) AS interest_over,
round((getRentPenalty(lcf.PAYMENT_NUMBER, lcf.PLAN_LIST, date_format(now(), '%Y/%m/%d')) -
((ifnull(lcfd.penalty, 0) + ifnull(lcfi.penalty, 0)) +
(ifnull(lcfd.penalty_adjust, 0) + ifnull(lcfi.penalty_adjust, 0)))), 2) AS penalty_over,
(case
when (((ifnull(lcfd.rent, 0) + ifnull(lcfi.rent, 0)) = lcf.RENT) and (round((getRentPenalty(
lcf.PAYMENT_NUMBER,
lcf.PLAN_LIST,
date_format(now(), '%Y/%m/%d')) -
((ifnull(lcfd.penalty, 0) + ifnull(lcfi.penalty, 0)) +
(ifnull(lcfd.penalty_adjust, 0) +
ifnull(lcfi.penalty_adjust, 0)))),
2) = '0.00'))
then '已回笼'
when ((ifnull(lcfd.rent, 0) + ifnull(lcfi.rent, 0)) > 0) then '部分回笼'
else '未回笼' end) AS planstatus
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 lc_rent_income.PAYMENT_NUMBER AS payment_number,
lc_rent_income.PLAN_LIST AS plan_list,
lc_rent_income.PLAN_ID AS plan_id,
sum(lc_rent_income.RENT) AS rent,
sum(lc_rent_income.CORPUS) AS corpus,
sum(lc_rent_income.INTEREST) AS interest,
sum(lc_rent_income.PENALTY) AS penalty,
sum(lc_rent_income.CORPUS_ADJUST) AS corpus_adjust,
sum(lc_rent_income.INTEREST_ADJUST) AS interest_adjust,
sum(lc_rent_income.PENALTY_ADJUST) AS penalty_adjust
from lc_rent_income
where lc_rent_income.ROLL_BACK = '0'
and PAYMENT_NUMBER = #{paymentNumber}
group by lc_rent_income.PAYMENT_NUMBER, lc_rent_income.PLAN_LIST) lcfd
on lcf.PAYMENT_NUMBER = lcfd.payment_number and
lcf.PLAN_LIST = lcfd.plan_list
left join (select lc_rent_income_temp.PAYMENT_NUMBER AS payment_number,
lc_rent_income_temp.PLAN_LIST AS plan_list,
sum(lc_rent_income_temp.RENT) AS rent,
sum(lc_rent_income_temp.CORPUS) AS corpus,
sum(lc_rent_income_temp.INTEREST) AS interest,
sum(lc_rent_income_temp.PENALTY) AS penalty,
sum(lc_rent_income_temp.CORPUS_ADJUST) AS corpus_adjust,
sum(lc_rent_income_temp.INTEREST_ADJUST) AS interest_adjust,
sum(lc_rent_income_temp.PENALTY_ADJUST) AS penalty_adjust
from lc_rent_income_temp
where lc_rent_income_temp.IS_FLOWING = 0
and lc_rent_income_temp.ROLL_BACK = '0'
and PAYMENT_NUMBER = #{paymentNumber}
group by lc_rent_income_temp.PAYMENT_NUMBER, lc_rent_income_temp.PLAN_LIST) lcfi
on lcf.PAYMENT_NUMBER = lcfi.payment_number and lcf.PLAN_LIST = lcfi.plan_list
where lcf.PAYMENT_NUMBER = #{paymentNumber}
</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>