<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: 9874 pc
    $Date: 2019-1-22 下午6:44:09
    $Revision: 1.0
    $Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="LON_AMOUNT_MONTH_v">
    <bm:fields>
        <bm:field name="widthdrawal_plan_id" databaseType="NUMBER" datatype="java.lang.Double" physicalName="widthdrawal_plan_id" expression="(SELECT WIDTHDRAWAL_PLAN_ID  FROM tre_loan_con_withdrawal_plan  WHERE withdrawal_number like ${@withdrawal_number} )" forInsert="false" forUpdate="false"/>
        <!--<bm:field name="lon_month_id" databaseType="NUMBER" datatype="java.lang.Double" physicalName="LON_MONTH_ID" prompt="LON_AMOUNT_MONTH.LON_MONTH_ID"/>-->
        <bm:field name="loan_contract_id" databaseType="NUMBER" datatype="java.lang.Double" physicalName="LOAN_CONTRACT_ID" prompt="LON_AMOUNT_MONTH.LOAN_CONTRACT_ID"/>
        <bm:field name="first_calc_year" databaseType="VARCHAR2" datatype="java.lang.String"  />
        <bm:field name="first_calc_date" databaseType="DATE" datatype="java.util.Date"  />
        <bm:field name="first_maturity_date_1" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="first_maturity_date_2" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="first_maturity_date_3" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="first_maturity_date_4" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="first_maturity_date_5" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="first_maturity_date_6" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="first_maturity_date_7" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="first_maturity_date_8" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="first_maturity_date_9" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="first_maturity_date_10" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="first_maturity_date_11" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="first_maturity_date_12" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="first_repayment_amount_1" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_amount_2" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_amount_3" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_amount_4" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_amount_5" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_amount_6" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_amount_7" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_amount_8" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_amount_9" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_amount_10" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_amount_11" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_amount_12" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_interest_1" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_interest_2" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_interest_3" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_interest_4" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_interest_5" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_interest_6" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_interest_7" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_interest_8" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_interest_9" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_interest_10" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_interest_11" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_repayment_interest_12" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_amount_1" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_amount_2" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_amount_3" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_amount_4" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_amount_5" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_amount_6" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_amount_7" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_amount_8" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_amount_9" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_amount_10" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_amount_11" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_amount_12" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_withdraw_amount_1" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_withdraw_amount_2" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_withdraw_amount_3" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_withdraw_amount_4" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_withdraw_amount_5" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_withdraw_amount_6" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_withdraw_amount_7" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_withdraw_amount_8" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_withdraw_amount_9" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_withdraw_amount_10" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_withdraw_amount_11" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="first_withdraw_amount_12" databaseType="NUMBER" datatype="java.lang.Double" />

        <bm:field name="second_calc_year" databaseType="VARCHAR2" datatype="java.lang.String"  />
        <bm:field name="second_calc_date" databaseType="DATE" datatype="java.util.Date"  />
        <bm:field name="second_maturity_date_1" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="second_maturity_date_2" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="second_maturity_date_3" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="second_maturity_date_4" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="second_maturity_date_5" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="second_maturity_date_6" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="second_maturity_date_7" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="second_maturity_date_8" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="second_maturity_date_9" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="second_maturity_date_10" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="second_maturity_date_11" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="second_maturity_date_12" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="second_repayment_amount_1" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_amount_2" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_amount_3" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_amount_4" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_amount_5" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_amount_6" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_amount_7" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_amount_8" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_amount_9" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_amount_10" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_amount_11" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_amount_12" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_interest_1" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_interest_2" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_interest_3" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_interest_4" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_interest_5" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_interest_6" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_interest_7" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_interest_8" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_interest_9" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_interest_10" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_interest_11" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_repayment_interest_12" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_amount_1" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_amount_2" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_amount_3" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_amount_4" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_amount_5" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_amount_6" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_amount_7" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_amount_8" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_amount_9" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_amount_10" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_amount_11" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_amount_12" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_withdraw_amount_1" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_withdraw_amount_2" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_withdraw_amount_3" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_withdraw_amount_4" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_withdraw_amount_5" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_withdraw_amount_6" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_withdraw_amount_7" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_withdraw_amount_8" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_withdraw_amount_9" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_withdraw_amount_10" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_withdraw_amount_11" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="second_withdraw_amount_12" databaseType="NUMBER" datatype="java.lang.Double" />

        <bm:field name="third_calc_year" databaseType="VARCHAR2" datatype="java.lang.String"  />
        <bm:field name="third_calc_date" databaseType="DATE" datatype="java.util.Date"  />
        <bm:field name="third_maturity_date_1" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="third_maturity_date_2" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="third_maturity_date_3" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="third_maturity_date_4" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="third_maturity_date_5" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="third_maturity_date_6" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="third_maturity_date_7" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="third_maturity_date_8" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="third_maturity_date_9" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="third_maturity_date_10" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="third_maturity_date_11" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="third_maturity_date_12" databaseType="DATE" datatype="java.util.Date" />
        <bm:field name="third_repayment_amount_1" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_amount_2" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_amount_3" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_amount_4" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_amount_5" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_amount_6" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_amount_7" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_amount_8" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_amount_9" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_amount_10" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_amount_11" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_amount_12" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_interest_1" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_interest_2" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_interest_3" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_interest_4" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_interest_5" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_interest_6" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_interest_7" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_interest_8" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_interest_9" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_interest_10" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_interest_11" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_repayment_interest_12" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_amount_1" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_amount_2" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_amount_3" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_amount_4" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_amount_5" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_amount_6" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_amount_7" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_amount_8" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_amount_9" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_amount_10" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_amount_11" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_amount_12" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_withdraw_amount_1" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_withdraw_amount_2" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_withdraw_amount_3" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_withdraw_amount_4" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_withdraw_amount_5" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_withdraw_amount_6" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_withdraw_amount_7" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_withdraw_amount_8" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_withdraw_amount_9" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_withdraw_amount_10" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_withdraw_amount_11" databaseType="NUMBER" datatype="java.lang.Double" />
        <bm:field name="third_withdraw_amount_12" databaseType="NUMBER" datatype="java.lang.Double" />

        <bm:field name="loan_con_bp_n" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select bp.bp_name from tre_loan_contract t,hls_bp_master bp where bp.bp_id = t.loan_con_bp and t.loan_contract_id=t1.loan_contract_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="loan_deposit" databaseType="NUMBER" datatype="java.lang.Double" expression="(select t.loan_deposit from tre_loan_contract t where t.loan_contract_id=t1.loan_contract_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="loan_change_rate" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select t.loan_change_rate from tre_loan_contract t where t.loan_contract_id=t1.loan_contract_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="change_money" databaseType="NUMBER" datatype="java.lang.Double" expression="(select t.change_money from tre_loan_contract t where t.loan_contract_id=t1.loan_contract_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="change_money_rate" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select t.change_money_rate from tre_loan_contract t where t.loan_contract_id=t1.loan_contract_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="withdrawal_number" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select tp.withdrawal_number from tre_loan_con_withdrawal_plan tp where tp.widthdrawal_plan_id=t1.widthdrawal_plan_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="widthdrawal_date" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select to_char(tp.widthdrawal_date,'yyyy-mm-dd') from tre_loan_con_withdrawal_plan tp where tp.widthdrawal_plan_id=t1.widthdrawal_plan_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="maturity_date" databaseType="VARCHAR2" datatype="java.lang.String" expression="(SELECT to_char(max(t2.maturity_date), 'yyyy-mm-dd') FROM tre_loan_con_repayment_plan t2, tre_loan_con_withdrawal_plan   tc WHERE t2.withdrawal_id = tc.widthdrawal_plan_id AND tc.widthdrawal_plan_id = t1.widthdrawal_plan_id AND t2.repayment_type = 'RENTAL' AND t2.times = (SELECT MAX(t2.times) FROM tre_loan_con_repayment_plan t2, tre_loan_con_withdrawal_plan   tc WHERE t2.withdrawal_id = tc.widthdrawal_plan_id AND tc.widthdrawal_plan_id = t1.widthdrawal_plan_id  AND t2.repayment_type = 'RENTAL' AND tc.widthdrawal_wfl_status = 'CONFIRM') AND tc.widthdrawal_wfl_status = 'CONFIRM' )" forInsert="false" forUpdate="false"/>
        <bm:field name="remaining_amount" databaseType="NUMBER" datatype="java.lang.Double" expression="(SELECT SUM(nvl(t2.principal, 0)) FROM tre_loan_con_repayment_plan t2, tre_loan_con_withdrawal_plan   tc WHERE t2.withdrawal_id = tc.widthdrawal_plan_id AND tc.widthdrawal_plan_id = t1.widthdrawal_plan_id  AND t2.repayment_type = 'RENTAL' AND t2.maturity_date > SYSDATE AND tc.widthdrawal_wfl_status = 'CONFIRM')" forInsert="false" forUpdate="false"/>
        <bm:field name="interest_rate" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select t.interest_rate from tre_loan_contract t where t.loan_contract_id=t1.loan_contract_id)" forInsert="false" forUpdate="false"/>

    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>

    <bm:query-fields>
        <bm:query-field name="loan_con_bp_n" queryExpression="exists(select 1 from tre_loan_contract t,hls_bp_master bp where bp.bp_id = t.loan_con_bp and t.loan_contract_id=t1.loan_contract_id and bp.bp_name like ${@loan_con_bp_n})"/>
        <bm:query-field name="withdrawal_number" queryExpression="exists(select 1 from tre_loan_con_withdrawal_plan tp where tp.widthdrawal_plan_id=t1.widthdrawal_plan_id and tp.withdrawal_number like ${@withdrawal_number})"/>
        <bm:query-field name="maturity_date_from" queryExpression="(SELECT trunc(max(t2.maturity_date ))
  FROM tre_loan_con_repayment_plan t2, tre_loan_con_withdrawal_plan tc
 WHERE t2.withdrawal_id = tc.widthdrawal_plan_id
   AND tc.widthdrawal_plan_id = t1.widthdrawal_plan_id
   AND t2.repayment_type = 'RENTAL'
   AND t2.times = (SELECT MAX(t2.times)
                     FROM tre_loan_con_repayment_plan  t2,
                          tre_loan_con_withdrawal_plan tc
                    WHERE t2.withdrawal_id = tc.widthdrawal_plan_id
                      AND tc.widthdrawal_plan_id = t1.widthdrawal_plan_id
                      AND t2.repayment_type = 'RENTAL'
                      AND tc.widthdrawal_wfl_status = 'CONFIRM')
   AND tc.widthdrawal_wfl_status = 'CONFIRM' ) &gt;= to_date(${@maturity_date_from},'yyyy-mm-dd')
"/>
        <bm:query-field name="maturity_date_to" queryExpression="(SELECT trunc(max(t2.maturity_date) )
  FROM tre_loan_con_repayment_plan t2, tre_loan_con_withdrawal_plan tc
 WHERE t2.withdrawal_id = tc.widthdrawal_plan_id
   AND tc.widthdrawal_plan_id = t1.widthdrawal_plan_id
   AND t2.repayment_type = 'RENTAL'
   AND t2.times = (SELECT MAX(t2.times)
                     FROM tre_loan_con_repayment_plan  t2,
                          tre_loan_con_withdrawal_plan tc
                    WHERE t2.withdrawal_id = tc.widthdrawal_plan_id
                      AND tc.widthdrawal_plan_id = t1.widthdrawal_plan_id
                      AND t2.repayment_type = 'RENTAL'
                      AND tc.widthdrawal_wfl_status = 'CONFIRM')
   AND tc.widthdrawal_wfl_status = 'CONFIRM' ) &lt;= to_date(${@maturity_date_to},'yyyy-mm-dd')
"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="t1.first_calc_year = ${@year}"/>
    </bm:data-filters>
</bm:model>
