<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Guoxuezhao  
    $Date: 2013-5-28 下午1:19:35  
    $Revision: 1.0  
    $Purpose: 授信合同管理
-->
<bm:model xmlns:ns2="leaf.database.local.oracle" xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:fields>
        <bm:field name="credit_contract_id" databaseType="NUMBER" datatype="java.lang.Long" prompt="TRE_BANK_CREDIT_CONTRACT.CREDIT_CONTRACT_ID"/>
        <bm:field name="credit_limit_type" databaseType="VARCHAR2" datatype="java.lang.String" prompt="TRE_BANK_CREDIT_CONTRACT.CREDIT_LIMIT_TYPE"/>
        <bm:field name="credit_contract_number" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" prompt="TRE_LOAN_CONTRACT.BANK_CREDIT_CONTRACT_ID"/>
        <bm:field name="bp_id" databaseType="NUMBER" datatype="java.lang.Long" prompt="TRE_BANK_CREDIT_CONTRACT.BANK_ID"/>
        <bm:field name="bank_branch_name" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" prompt="TRE501.TRE_BANK_CREDIT_CONTRACT.BANK_ID"/>
        <bm:field name="credit_amount" databaseType="NUMBER" datatype="java.lang.Double" displayWidth="120" forDisplay="true" prompt="TRE501.TRE_BANK_CREDIT_CONTRACT.CREDIT_AMOUNT"/>
        <bm:field name="available_amount" databaseType="NUMBER" datatype="java.lang.Double" displayWidth="120" forDisplay="true" prompt="TRE501.TRE_BANK_CREDIT_CONTRACT.AVAILABLE_AMOUNT"/>
        <bm:field name="credit_limit_type_desc" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="90" forDisplay="true" prompt="TRE501.TRE_BANK_CREDIT_CONTRACT.CREDIT_LIMIT_TYPE"/>
        <bm:field name="currency" databaseType="VARCHAR2" datatype="java.lang.String" prompt="TRE_BANK_CREDIT_CONTRACT.CURRENCY"/>
        <bm:field name="currency_name" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="80" forDisplay="true" prompt="TRE501.TRE_BANK_CREDIT_CONTRACT.CURRENCY"/>
        <bm:field name="credit_date_from" databaseType="DATE" datatype="java.util.Date" displayWidth="90" forDisplay="true" prompt="TRE501.TRE_BANK_CREDIT_CONTRACT.CREDIT_DATE_FROM"/>
        <bm:field name="credit_date_to" databaseType="DATE" datatype="java.util.Date" displayWidth="90" forDisplay="true" prompt="TRE501.TRE_BANK_CREDIT_CONTRACT.CREDIT_DATE_TO"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    *
                FROM
                    (SELECT
                        t1.credit_contract_id,
                        t1.credit_limit_type,
                        (select v.code_value_name
				          from sys_code_values_v v
				         where v.code = 'TRE501_CREDIT_LIMIT_TYPE'
				           and v.code_value = t1.credit_limit_type) credit_limit_type_desc,
                        t1.bp_id,
                        cbb.bank_branch_name,
                        t1.credit_contract_number,
                        t1.credit_amount,
                        tre_bank_credit_contract_pkg.get_available_amount(t1.credit_contract_id) AS available_amount,
                        t1.currency,
                        gcv.currency_name,
                        t1.credit_date_from,
                        t1.credit_date_to
                    FROM
                        tre_bank_credit_contract t1,
                        csh_bank_branch cbb,
                        gld_currency_v gcv
                    WHERE
                        t1.bp_id    = cbb.bank_branch_id AND
                        t1.currency = gcv.currency_code
                    ) t #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="credit_contract_number" queryOperator="like"/>
        <bm:query-field field="bank_branch_name" queryOperator="like"/>
    </bm:query-fields>
</bm:model>
