(cast(contract_amount as decimal(18,2))-(select cast(total_reback_view."sum" as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid)-cast(CASE WHEN deduct_amount IS NULL THEN 0 ELSE deduct_amount end as decimal(18,2))-cast(CASE WHEN stop_amount IS NULL THEN 0 ELSE stop_amount END as decimal(18,2))
(cast(contract_amount as decimal(18,2))-(select cast(case when total_reback_view.sum is null then 0 else total_reback_view.sum end as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid)-cast(CASE WHEN deduct_amount IS NULL THEN 0 ELSE deduct_amount end as decimal(18,2))-cast(CASE WHEN stop_amount IS NULL THEN 0 ELSE stop_amount END as decimal(18,2))
-cast(CASE WHEN exemptions_amount IS NULL THEN 0 ELSE exemptions_amount END as decimal(18,2))-cast(CASE WHEN bad_amount IS NULL THEN 0 ELSE bad_amount END as decimal(18,2))) as contract_remain,
-cast(CASE WHEN exemptions_amount IS NULL THEN 0 ELSE exemptions_amount END as decimal(18,2))-cast(CASE WHEN bad_amount IS NULL THEN 0 ELSE bad_amount END as decimal(18,2))) as contract_remain,
(select cast(total_reback_view.sum as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid) as total_reback_amount,
(select cast(total_reback_view.sum as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid) as total_reback_amount,
(select cast(total_recv_amount_view.total_recv_amount as decimal(18,2)) from total_recv_amount_view where tb_contract.contract_unid=total_recv_amount_view.contract_unid) as total_receive_amount ,
(select cast(total_recv_amount_view.total_recv_amount as decimal(18,2)) from total_recv_amount_view where tb_contract.contract_unid=total_recv_amount_view.contract_unid) as total_receive_amount ,
...
@@ -331,6 +331,13 @@
...
@@ -331,6 +331,13 @@
#{salesperson_unid}
#{salesperson_unid}
</foreach>
</foreach>
</if>
</if>
<iftest="amount_state_unids !=null and amount_state_unids.length > 0">
(cast(contract_amount as decimal(18,2))-(select cast(total_reback_view."sum" as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid)-cast(CASE WHEN deduct_amount IS NULL THEN 0 ELSE deduct_amount end as decimal(18,2))-cast(CASE WHEN stop_amount IS NULL THEN 0 ELSE stop_amount END as decimal(18,2))
(cast(CASE WHEN contract_amount IS NULL THEN 0 ELSE contract_amount END as decimal(18,2))-(select cast(CASE WHEN total_reback_view.sum IS NULL THEN 0 ELSE total_reback_view.sum END as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid)-cast(CASE WHEN deduct_amount IS NULL THEN 0 ELSE deduct_amount end as decimal(18,2))-cast(CASE WHEN stop_amount IS NULL THEN 0 ELSE stop_amount END as decimal(18,2))
-cast(CASE WHEN exemptions_amount IS NULL THEN 0 ELSE exemptions_amount END as decimal(18,2))-cast(CASE WHEN bad_amount IS NULL THEN 0 ELSE bad_amount END as decimal(18,2))) as contract_remain,
-cast(CASE WHEN exemptions_amount IS NULL THEN 0 ELSE exemptions_amount END as decimal(18,2))-cast(CASE WHEN bad_amount IS NULL THEN 0 ELSE bad_amount END as decimal(18,2))) as contract_remain,
(select cast(total_reback_view.sum as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid) as total_reback_amount,
(select cast(total_reback_view.sum as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid) as total_reback_amount,
(select cast(total_recv_amount_view.total_recv_amount as decimal(18,2)) from total_recv_amount_view where tb_contract.contract_unid=total_recv_amount_view.contract_unid) as total_receive_amount ,
(select cast(total_recv_amount_view.total_recv_amount as decimal(18,2)) from total_recv_amount_view where tb_contract.contract_unid=total_recv_amount_view.contract_unid) as total_receive_amount ,
...
@@ -475,6 +491,13 @@
...
@@ -475,6 +491,13 @@
#{salesperson_unid}
#{salesperson_unid}
</foreach>
</foreach>
</if>
</if>
<iftest="amount_state_unids !=null and amount_state_unids.length > 0">
<!-- cast(confirm_income_amount as decimal(18,2)) as confirm_income_amount, -->
<!-- cast(confirm_income_amount as decimal(18,2)) as confirm_income_amount, -->
(SELECT tb_payment_agree.payment_propority FROM tb_payment_agree WHERE tb_payment_agree.contract_unid = tb_contract.contract_unid AND tb_payment_agree.payment_type = '100001') as advance_pay_proporition,
(SELECT tb_payment_agree.payment_propority FROM tb_payment_agree WHERE tb_payment_agree.contract_unid = tb_contract.contract_unid AND tb_payment_agree.payment_type = '100002') as arrive_pay_proportion,
(SELECT tb_payment_agree.payment_propority FROM tb_payment_agree WHERE tb_payment_agree.contract_unid = tb_contract.contract_unid AND tb_payment_agree.payment_type = '100003') as acceptanc_pay_proportion,
(SELECT tb_payment_agree.payment_propority FROM tb_payment_agree WHERE tb_payment_agree.contract_unid = tb_contract.contract_unid AND (tb_payment_agree.payment_type = '100004' OR tb_payment_agree.payment_type = '100005')) as mainten_pay_proportition,
(SELECT tb_payment_agree.payment_requirement FROM tb_payment_agree WHERE tb_payment_agree.contract_unid = tb_contract.contract_unid AND tb_payment_agree.payment_type = '100001') as advance_pay_requirement,
(SELECT tb_payment_agree.payment_requirement FROM tb_payment_agree WHERE tb_payment_agree.contract_unid = tb_contract.contract_unid AND tb_payment_agree.payment_type = '100002') as arrive_pay_requirement,
(SELECT tb_payment_agree.payment_requirement FROM tb_payment_agree WHERE tb_payment_agree.contract_unid = tb_contract.contract_unid AND tb_payment_agree.payment_type = '100003') as acceptanc_pay_requirement,
(SELECT tb_payment_agree.payment_requirement FROM tb_payment_agree WHERE tb_payment_agree.contract_unid = tb_contract.contract_unid AND (tb_payment_agree.payment_type = '100004' OR tb_payment_agree.payment_type = '100005')) as mainten_pay_requirement,
(select cast(sum(receipt_amount) as decimal(18,2)) from tb_receipt where tb_receipt.contract_unid = tb_contract.contract_unid) as total_receipt_amount ,
(select cast(sum(receipt_amount) as decimal(18,2)) from tb_receipt where tb_receipt.contract_unid = tb_contract.contract_unid) as total_receipt_amount ,
to_char(sign_date,'yyyy') as year, to_char(sign_date,'MM') as month,
to_char(sign_date,'yyyy') as year, to_char(sign_date,'MM') as month,
(cast(contract_amount as decimal(18,2))-(select cast(total_reback_view."sum" as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid)-cast(CASE WHEN deduct_amount IS NULL THEN 0 ELSE deduct_amount end as decimal(18,2))-cast(CASE WHEN stop_amount IS NULL THEN 0 ELSE stop_amount END as decimal(18,2))
(cast(contract_amount as decimal(18,2))-(select cast(total_reback_view."sum" as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid)-cast(CASE WHEN deduct_amount IS NULL THEN 0 ELSE deduct_amount end as decimal(18,2))-cast(CASE WHEN stop_amount IS NULL THEN 0 ELSE stop_amount END as decimal(18,2))
...
@@ -641,6 +681,13 @@
...
@@ -641,6 +681,13 @@
#{salesperson_unid}
#{salesperson_unid}
</foreach>
</foreach>
</if>
</if>
<iftest="amount_state_unids !=null and amount_state_unids.length > 0">