<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hty
    $Date: Wed Jul 04 20:06:59 CST 2018  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:e="leaf.service.exception" xmlns:o="leaf.database.local.oracle" xmlns:f="leaf.database.features" alias="t1" baseTable="LON_CREDIT_CONTRACT_LV" defaultOrderBy="t1.valid_from desc">
    <bm:fields>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID" prompt="LON_CREDIT_CONTRACT_LV.COMPANY_ID"/>
        <bm:field name="currency" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENCY" prompt="LON_CREDIT_CONTRACT_LV.CURRENCY"/>
        <bm:field name="currency_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENCY_N" prompt="LON_CREDIT_CONTRACT_LV.CURRENCY_N"/>
        <bm:field name="credit_contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CREDIT_CONTRACT_ID" prompt="LON_CREDIT_CONTRACT_LV.CREDIT_CONTRACT_ID"/>
        <bm:field name="credit_contract_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CREDIT_CONTRACT_STATUS" prompt="LON_CREDIT_CONTRACT_LV.CREDIT_CONTRACT_STATUS"/>
        <bm:field name="credit_contract_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CREDIT_CONTRACT_NAME" prompt="LON_CREDIT_CONTRACT_LV.CREDIT_CONTRACT_NAME"/>
        <bm:field name="document_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_TYPE" prompt="LON_CREDIT_CONTRACT_LV.DOCUMENT_TYPE"/>
        <bm:field name="document_type_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_TYPE_N" prompt="LON_CREDIT_CONTRACT_LV.DOCUMENT_TYPE_N"/>
        <bm:field name="credit_line_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CREDIT_LINE_ID" prompt="LON_CREDIT_CONTRACT_LV.CREDIT_LINE_ID"/>
        <bm:field name="credit_line_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CREDIT_LINE_TYPE" prompt="LON_CREDIT_CONTRACT_LV.CREDIT_LINE_TYPE"/>
        <bm:field name="credit_line_type_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CREDIT_LINE_TYPE_N" prompt="LON_CREDIT_CONTRACT_LV.CREDIT_LINE_TYPE_N"/>
        <bm:field name="now_rate" databaseType="NUMBER" datatype="java.lang.Double" physicalName="NOW_RATE" prompt="LON_CREDIT_CONTRACT_LV.NOW_RATE"/>
        <bm:field name="credit_line_amt" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CREDIT_LINE_AMT" prompt="LON_CREDIT_CONTRACT_LV.CREDIT_LINE_AMT"/>
        <bm:field name="credit_exposure_amt" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CREDIT_EXPOSURE_AMT" prompt="LON_CREDIT_CONTRACT_LV.CREDIT_EXPOSURE_AMT"/>
        <bm:field name="open_to_buy" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OPEN_TO_BUY" prompt="LON_CREDIT_CONTRACT_LV.OPEN_TO_BUY"/>
        <bm:field name="valid_from" databaseType="DATE" datatype="java.util.Date" physicalName="VALID_FROM" prompt="LON_CREDIT_CONTRACT_LV.VALID_FROM"/>
        <bm:field name="valid_to" databaseType="DATE" datatype="java.util.Date" physicalName="VALID_TO" prompt="LON_CREDIT_CONTRACT_LV.VALID_TO"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="LON_CREDIT_CONTRACT_LV.DESCRIPTION"/>
        <bm:field name="credit_bp_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CREDIT_BP_ID" prompt="LON_CREDIT_CONTRACT_LV.CREDIT_BP_ID"/>
        <bm:field name="lon_des" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LON_DES" prompt="LON_CREDIT_CONTRACT_LV.LON_DES"/>
        <bm:field name="credit_bp_name" expression="(select t2.bp_name from hls_bp_master t2 where t1.credit_bp_id = t2.bp_id)"/>
        <bm:field name="confirm_flag"/>
    </bm:fields>
    <bm:features>
        <f:standard-who xmlns:f="leaf.database.features"/>
    </bm:features>
    <bm:query-fields>
        <bm:query-field name="credit_bp_name" queryExpression="t1.credit_bp_id in (SELECT hbm.BP_ID FROM HLS_BP_MASTER hbm WHERE hbm.BP_NAME LIKE &apos;%&apos;||${@credit_bp_name}||&apos;%&apos;)"/>
        <bm:query-field name="valid_from" queryExpression="t1.valid_from &gt;= to_date(${@valid_from},'yyyy-MM-dd')"/>
        <bm:query-field name="valid_to" queryExpression="t1.valid_to &lt;= to_date(${@valid_to},'yyyy-MM-dd')"/>
        <bm:query-field name="credit_line_type" queryExpression="t1.credit_line_type in ${:@credit_line_type}"/>
        <bm:query-field name="money_from" queryExpression="t1.open_to_buy &gt;= ${@money_from}"/>
        <bm:query-field name="money_to" queryExpression="t1.open_to_buy &lt;= ${@money_to}"/>
        <bm:query-field name="search_msg" queryExpression="(t1.credit_contract_name like &apos;%&apos;||${@search_msg}||&apos;%&apos; or (select t2.bp_name from hls_bp_master t2 where t1.credit_bp_id = t2.bp_id) like  &apos;%&apos;||${@search_msg}||&apos;%&apos;)"/>
    </bm:query-fields>
    <bm:operations>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                begin
                    update
                        lon_credit_contract t1
                    set
                        t1.confirm_flag = 'Y'
                    where
                        t1.credit_contract_id = ${@credit_contract_id};
                end;
                ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>