<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2013-12-7 下午03:37:38  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:e="leaf.service.exception" xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="CON_CONTRACT_INSURANCE" defaultOrderBy="project_number desc,contract_number desc,insurance_policy_no desc ">
    <bm:fields>
        <bm:field name="insurance_policy_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INSURANCE_POLICY_ID" prompt="CON_CONTRACT_INSURANCE.INSURANCE_POLICY_ID"/>
        <bm:field name="insurance_policy_no" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INSURANCE_POLICY_NO" prompt="CON_CONTRACT_INSURANCE.INSURANCE_POLICY_NO"/>
        <bm:field name="insurance_company" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INSURANCE_COMPANY" prompt="CON_CONTRACT_INSURANCE.INSURANCE_COMPANY"/>
        <!-- <bm:field name="insurance_company_desc" expression="(select v.code_value_name from sys_code_values_v v where v.code=&apos;CON511_INSURANCE_COMPANY&apos; and v.code_value=t1.insurance_company) " forInsert="false" forUpdate="false"/> -->
        <bm:field name="insurance_description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INSURANCE_DESCRIPTION" prompt="CON_CONTRACT_INSURANCE.INSURANCE_DESCRIPTION"/>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" prompt="CON_CONTRACT_INSURANCE.CONTRACT_ID"/>
        <bm:field name="insurance_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="INSURANCE_AMOUNT" prompt="CON_CONTRACT_INSURANCE.INSURANCE_AMOUNT"/>
        <bm:field name="fact_insurance_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="FACT_INSURANCE_AMOUNT" prompt="CON_CONTRACT_INSURANCE.FACT_INSURANCE_AMOUNT"/>
        <bm:field name="insurance_date_from" databaseType="DATE" datatype="java.util.Date" physicalName="INSURANCE_DATE_FROM" prompt="CON_CONTRACT_INSURANCE.INSURANCE_DATE_FROM"/>
        <bm:field name="insurance_date_to" databaseType="DATE" datatype="java.util.Date" physicalName="INSURANCE_DATE_TO" prompt="CON_CONTRACT_INSURANCE.INSURANCE_DATE_TO"/>
        <bm:field name="year_seq" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="YEAR_SEQ" prompt="CON_CONTRACT_INSURANCE.YEAR_SEQ"/>
        <bm:field name="contract_name" expression="(select c.contract_name from con_contract c where c.contract_id=t1.contract_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="contract_number" expression="(select c.contract_number from con_contract c where c.contract_id=t1.contract_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="project_name" expression="( select p.project_name     from prj_project p,con_contract c    where p.project_id = c.project_id and c.contract_id=t1.contract_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="project_number" expression="( select p.project_number     from prj_project p,con_contract c    where p.project_id = c.project_id and c.contract_id=t1.contract_id)" forInsert="false" forUpdate="false"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="insurance_policy_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field field="contract_id" queryOperator="="/>
        <bm:query-field name="contract_name" queryExpression="exists (select 1 from con_contract c where c.contract_name like ${@contract_name})"/>
        <bm:query-field name="insurance_policy_no" queryExpression="upper(t1.insurance_policy_no) like upper(${@insurance_policy_no})"/>
        <!-- <bm:query-field name="insurance_year" dataType="java.lang.Long" queryExpression="(${@insurance_year} &gt;=to_char(t1.insurance_date_from,&apos;yyyy&apos;) and ${@insurance_year} &lt;=to_char(t1.insurance_date_to,&apos;yyyy&apos; ))"/> -->
        <bm:query-field field="insurance_date_from" queryExpression="t1.insurance_date_from &gt;= ${@insurance_date_from}"/>
        <bm:query-field field="insurance_date_to" queryExpression="t1.insurance_date_to &lt;= ${@insurance_date_to}"/>
    </bm:query-fields>
    <e:exception-descriptor-config>
        <e:exception-descriptor exception="java.sql.SQLException" handleClass="leaf.database.SQLExceptionDescriptor">
            <e:error-message code="1" message="CON511.INSURANCE_POLICY_NO_UNIQUE_ERROR"/>
        </e:exception-descriptor>
    </e:exception-descriptor-config>
</bm:model>
