<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select * from(
            select hac.contract_id,
            	   hac.abs_contract_id,
			       (select cc.contract_number from con_contract cc where cc.contract_id = hac.contract_id and cc.data_class = 'NORMAL' and 
			               NVL(cc.hn_adjust_review_flag, 'N') = 'Y') contract_number,--合同号
			       (select cc.contract_name from con_contract cc where cc.contract_id = hac.contract_id and cc.data_class = 'NORMAL' and 
			               NVL(cc.hn_adjust_review_flag, 'N') = 'Y') contract_name,--合同名称
			       (SELECT hbm.bp_name
						          FROM hls_bp_master hbm
						         WHERE hbm.bp_id = (select cc.bp_id_tenant from con_contract cc where cc.contract_id = hac.contract_id and cc.data_class = 'NORMAL' and 
			               NVL(cc.hn_adjust_review_flag, 'N') = 'Y')) lessee_name, --承租人名称
			       (SELECT ee.name FROM exp_employees ee WHERE ee.employee_id = (select cc.employee_id from con_contract cc where cc.contract_id = hac.contract_id and
			       			cc.data_class = 'NORMAL' and NVL(cc.hn_adjust_review_flag, 'N') = 'Y')) manager, --项目经理
			       hac.start_times,--起始期数
			       hac.end_times,--终止期数
			       hac.receive_amount,--累计以偿付租金
			       hac.remain_amount,--累计到期未支付租金  
			       hac.partial_receive_amount,--承租人违约时相应回收款
			       hac.ninety_remain_amount,--累计逾期90天未支付租金 
			       hac.quantity,--基础资产数量 
			       TO_CHAR(hac.default_rate*100,'FM90.00')|| '%' default_rate_n, --累计违约率 
			       TO_CHAR(hac.early_repayment_rate*100,'FM90.00')|| '%' early_repayment_rate_n  --累计早偿率 
			from hn_abs_contract hac 
			where hac.abs_id = ${@abs_id}
			) t1 #WHERE_CLAUSE#
			ORDER BY t1.contract_number
				]]></bm:query-sql>
            <bm:parameters>
                <bm:parameter name="abs_id"/>
            </bm:parameters>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
			begin
				delete from hn_abs_contract where abs_contract_id= ${@abs_contract_id};
				end;
			]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="contract_number" queryExpression="t1.contract_number like &apos;%&apos;||${@contract_number}||&apos;%&apos;"/>
        <bm:query-field name="contract_name" queryExpression="t1.contract_name like &apos;%&apos;||${@contract_name}||&apos;%&apos;"/>
        <bm:query-field name="lessee_name" queryExpression="t1.lessee_name like &apos;%&apos;||${@lessee_name}||&apos;%&apos;"/>
        <bm:query-field name="manager" queryExpression="t1.manager like &apos;%&apos;||${@manager}||&apos;%&apos;"/>
    </bm:query-fields>
</bm:model>
