is_archive, cast(bad_amount as decimal(18,2)), bad_amount_note, (cast(confirm_income_amount as decimal(18,2))) as confirm_income_amount,
is_archive, cast(bad_amount as decimal(18,2)), bad_amount_note, (cast(confirm_income_amount as decimal(18,2))) as confirm_income_amount,
amount_state_unid, to_char(start_guarantee_date, 'yyyy-MM-dd') as start_guarantee_date, to_char(end_guarantee_date, 'yyyy-MM-dd') as end_guarantee_date,
amount_state_unid, to_char(start_guarantee_date, 'yyyy-MM-dd') as start_guarantee_date, to_char(end_guarantee_date, 'yyyy-MM-dd') as end_guarantee_date,
<!-- 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))