<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="CON_CONTRACT" defaultOrderBy="contract_number,version_display">
    <bm:fields>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" prompt="CON_CONTRACT.CONTRACT_ID"/>
        <bm:field name="data_class" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select v.code_value_name from sys_code_values_v v, sys_codes c where v.code_id = c.code_id and  c.code = &apos;HLS_DATA_CLASS&apos; and v.code_value = t1.DATA_CLASS)" physicalName="DATA_CLASS" prompt="CON_CONTRACT.DATA_CLASS"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NUMBER" prompt="CON_CONTRACT.CONTRACT_NUMBER"/>
        <bm:field name="contract_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NAME" prompt="CON_CONTRACT.CONTRACT_NAME"/>
        <bm:field name="total_rental" databaseType="NUMBER" datatype="java.lang.Double" physicalName="TOTAL_RENTAL" prompt="CON_CONTRACT.TOTAL_RENTAL"/>
        <bm:field name="total_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="TOTAL_INTEREST" prompt="CON_CONTRACT.TOTAL_INTEREST"/>
        <bm:field name="finance_income" databaseType="NUMBER" datatype="java.lang.Double" physicalName="FINANCE_INCOME" prompt="CON_CONTRACT.FINANCE_INCOME"/>
        <bm:field name="int_rate_fixing_way" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select v.code_value_name from sys_code_values_v v, sys_codes c where v.code_id = c.code_id and c.code = &apos;TRE502_INT_RATE_FIXING_WAY&apos; and v.code_value = t1.INT_RATE_FIXING_WAY)" physicalName="INT_RATE_FIXING_WAY" prompt="CON_CONTRACT.INT_RATE_FIXING_WAY"/>
        <bm:field name="base_rate" databaseType="NUMBER" datatype="java.lang.Double" expression="t1.base_rate*100" physicalName="BASE_RATE" prompt="CON_CONTRACT.BASE_RATE"/>
        <bm:field name="int_rate" databaseType="NUMBER" datatype="java.lang.Double" expression="t1.int_rate*100" physicalName="INT_RATE" prompt="CON_CONTRACT.INT_RATE"/>
        <bm:field name="version_date" databaseType="DATE" datatype="java.util.Date" physicalName="VERSION_DATE" prompt="CON_CONTRACT.VERSION_DATE"/>
        <bm:field name="version_display" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="VERSION_DISPLAY" prompt="CON_CONTRACT.VERSION_DISPLAY"/>
        <bm:field name="adjust_rate_type" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select v.code_value_name from sys_code_values_v v, sys_codes c where v.code_id = c.code_id and c.code = &apos;ADJUST_RATE_TYPE&apos; and v.code_value = t1.ADJUST_RATE_TYPE)" physicalName="ADJUST_RATE_TYPE" prompt="CON_CONTRACT.ADJUST_RATE_TYPE"/>
        <bm:field name="version_reason" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="VERSION_REASON" prompt="CON_CONTRACT.VERSION_REASON"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="contract_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field name="contract_id" field="contract_id" queryOperator="="/>
        <bm:query-field name="contract_number" field="contract_number" queryOperator="="/>
        <bm:query-field name="interest_start_date_from" queryExpression="version_date &gt;= to_date(${@interest_start_date_from},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="interest_start_date_to" queryExpression="version_date &lt;= to_date(${@interest_start_date_to},&apos;yyyy-mm-dd&apos;)"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter name="contract_number" expression="t1.contract_number = ${@contract_number}"/>
        <bm:data-filter name="data_class" expression="t1.data_class in (&apos;NORMAL&apos;,&apos;HISTORY&apos;)"/>
        <!--<bm:data-filter name="version_reason" expression="(t1.version_reason = &apos;ADJUST_INTEREST&apos; or (t1.data_class = &apos;HISTORY&apos; and t1.version_reason = &apos;CONTRACT_CREATION&apos; )) "/> -->
    </bm:data-filters>
</bm:model>
