<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-1-7 下午02:49:19  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select t1.* from 
            (select c.bank_account_id,
			        c.bank_branch_name,
                    (select b.bank_branch_id
                                 from csh_bank_account_v b
                                where b.bank_account_id = c.bank_account_id) bank_branch_id,
                    (select b.bank_account_name
                                 from csh_bank_account_v b
                                where b.bank_account_id = c.bank_account_id) bank_account_name,    
                    (select b.bank_account_code
                                 from csh_bank_account_v b
                                where b.bank_account_id = c.bank_account_id) bank_account_code,     
			       c.loan_contract_number,
			       c.bank_account_num,
			       c.int_rate_fixing_way,
			       (select v.code_value_name 
			                from sys_code_values_v v 
			                where v.code='TRE502_INT_RATE_FIXING_WAY' 
                                and v.code_value=c.int_rate_fixing_way)int_rate_fixing_way_desc,
                   c.int_rate_fixing_range,
                   c.flt_execute_times_day,
                   (select v.code_value_name 
			                from sys_code_values_v v 
			                where v.code='TRE502_FLT_EXECUTE_TIMES_DAY' 
                                and v.code_value=c.flt_execute_times_day)flt_execute_times_day_desc,
                   c.adjust_day,
                   (select v.code_value_name 
			                from sys_code_values_v v 
			                where v.code='TRE502_ADJUST_DAY' 
                                and v.code_value=c.adjust_day)adjust_day_desc,
                   c.rate_float_cycle,
                   (select v.code_value_name 
			                from sys_code_values_v v 
			                where v.code='TRE502_RATE_FLOAT_CYCLE' 
                                and v.code_value=c.rate_float_cycle)rate_float_cycle_desc,
                   c.base_rate,
                   c.interest_rate,
			       w.withdraw_id,
			       w.loan_contract_id,
			       w.withdraw_number,
			       w.withdraw_amount,
			       w.withdraw_date,
			       w.int_rate,
			       w.status,
			       w.reversed_flag
			  from tre_loan_contract_v c, tre_loan_contract_withdraw w
			  where  c.loan_contract_id = w.loan_contract_id   
			  and  w.reversed_flag='N'
			  and  w.status='REVIEWED'
			  AND  c.company_id=${/session/@company_id})t1
			  #WHERE_CLAUSE#
			  order by bank_account_code ,loan_contract_number,withdraw_date desc
 ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="bank_account_id"/>
        <bm:field name="bank_branch_id"/>
        <bm:field name="bank_branch_name"/>
        <bm:field name="loan_contract_number" forDisplay="true" forQuery="true" prompt="借款合同编号"/>
        <bm:field name="bank_account_num"/>
        <bm:field name="bank_account_code"/>
        <bm:field name="bank_account_name"/>
        <bm:field name="int_rate_fixing_way"/>
        <bm:field name="int_rate_fixing_way_desc"/>
        <bm:field name="int_rate_fixing_range" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="flt_execute_times_day"/>
        <bm:field name="flt_execute_times_day_desc"/>
        <bm:field name="adjust_day"/>
        <bm:field name="adjust_day_desc"/>
        <bm:field name="base_rate" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="rate_float_cycle"/>
        <bm:field name="rate_float_cycle_desc"/>
        <bm:field name="withdraw_id"/>
        <bm:field name="loan_contract_id"/>
        <bm:field name="withdraw_number"/>
        <bm:field name="withdraw_amount" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="withdraw_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="int_rate" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="status"/>
        <bm:field name="reversed_flag"/>
        <bm:field name="interest_rate" databaseType="NUMBER" datatype="java.lang.Double"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="loan_contract_number" queryOperator="like"/>
        <bm:query-field field="bank_branch_id" queryOperator="="/>
        <bm:query-field field="withdraw_number" queryOperator="like"/>
        <bm:query-field name="withdraw_date_from" queryExpression="t1.withdraw_date &gt;=to_date(${@withdraw_date_from},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="withdraw_date_to" queryExpression="t1.withdraw_date &lt;=to_date(${@withdraw_date_to},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="loan_contract_number_from" queryExpression="t1.loan_contract_number &gt;=${@loan_contract_number_from}"/>
        <bm:query-field name="loan_contract_number_to" queryExpression="t1.loan_contract_number &lt;=${@loan_contract_number_to}"/>
        <bm:query-field name="int_rate_from" queryExpression="t1.int_rate &gt;=${@int_rate_from}"/>
        <bm:query-field name="int_rate_to" queryExpression="t1.int_rate &lt;=${@int_rate_to}"/>
    </bm:query-fields>
</bm:model>
