<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-7-7 下午02:40:06  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:fields>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="contract_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="employee_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="employee_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="loan_contract_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="loan_contract_number" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="business_type" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="business_type_desc" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="project_type" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="project_type_desc" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="loan_date_from" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="loan_date_to" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="recorder" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="recorder_id" databaseType="NUMBER" datatype="java.lang.Long"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select t1.*
  from (select cc.contract_id,
               cc.contract_number,
               cc.contract_name,
               cc.employee_id,
               cc.employee_name,
               lc.loan_contract_id,
               lc.loan_contract_number,
               lc.business_type,
               (select tv.description
                  from hls_business_type_v tv
                 where tv.business_type = lc.business_type) business_type_desc,
               lc.ref_v01 project_type,
               (select v.code_value_name
                  from sys_code_values_v v
                 where v.code = 'TRE_LOAN_PROJECT_TYPE'
                   and v.code_value = lc.ref_v01) project_type_desc,
               lc.loan_date_from,
               lc.loan_date_to,
               i.last_updated_by recorder_id,
               (select uv.employee_name
                  from sys_user_v uv
                 where i.last_updated_by = uv.user_id) recorder
          from con_contract_v              cc,
               tre_loan_contract           lc,
               tre_loan_contract_note_info i
         where cc.contract_id = lc.contract_id(+)
           and cc.contract_id = i.contract_id(+)) t1
            #WHERE_CLAUSE#
            order by t1.contract_number desc
             ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="employee_id" queryOperator="="/>
        <bm:query-field field="business_type" queryOperator="="/>
        <bm:query-field field="project_type" queryOperator="="/>
        <bm:query-field field="contract_number" queryOperator="like"/>
        <bm:query-field field="contract_name" queryOperator="like"/>
        <bm:query-field field="loan_contract_number" queryOperator="like"/>
        <bm:query-field field="recorder_id" queryOperator="="/>
    </bm:query-fields>
</bm:model>
