<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-11-24 下午04:34:31  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="CON_CONTRACT_V">
    <bm:fields>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" prompt="CON_CONTRACT_V.CONTRACT_ID"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="200" forDisplay="true" forQuery="true" physicalName="CONTRACT_NUMBER" prompt="合同编号"/>
        <bm:field name="contract_name" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="200" forDisplay="true" forQuery="true" physicalName="CONTRACT_NAME" prompt="合同名称"/>
        <bm:field name="business_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BUSINESS_TYPE" prompt="CON_CONTRACT_V.BUSINESS_TYPE"/>
        <bm:field name="business_type_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BUSINESS_TYPE_DESC" prompt="CON_CONTRACT_V.BUSINESS_TYPE_DESC"/>
        <bm:field name="document_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_TYPE" prompt="CON_CONTRACT_V.DOCUMENT_TYPE"/>
        <bm:field name="document_type_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_TYPE_DESC" prompt="CON_CONTRACT_V.DOCUMENT_TYPE_DESC"/>
        <bm:field name="document_category" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_CATEGORY" prompt="CON_CONTRACT_V.DOCUMENT_CATEGORY"/>
        <bm:field name="document_category_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_CATEGORY_DESC" prompt="CON_CONTRACT_V.DOCUMENT_CATEGORY_DESC"/>
        <bm:field name="lease_organization" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_ORGANIZATION" prompt="CON_CONTRACT_V.LEASE_ORGANIZATION"/>
        <bm:field name="lease_organization_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_ORGANIZATION_DESC" prompt="CON_CONTRACT_V.LEASE_ORGANIZATION_DESC"/>
        <bm:field name="lease_channel" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_CHANNEL" prompt="CON_CONTRACT_V.LEASE_CHANNEL"/>
        <bm:field name="lease_channel_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_CHANNEL_DESC" prompt="CON_CONTRACT_V.LEASE_CHANNEL_DESC"/>
        <bm:field name="bp_id_tenant" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID_TENANT" prompt="CON_CONTRACT_V.BP_ID_TENANT"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_NAME" prompt="CON_CONTRACT_V.BP_NAME"/>
        <bm:field name="bp_type_desc" expression="(select bt.description from hls_bp_type bt where bt.bp_type = (select m.bp_type from hls_bp_master m where m.bp_id=t1.bp_id_tenant))"/>
        <bm:field name="hls_lease_channel_desc" expression="(select lc.description  from hls_lease_channel lc where lc.lease_channel = t1.lease_channel)"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="company_id"/>
        <bm:field name="spv_company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="spv_company_id"/>
        <bm:field name="invoice_agent_desc" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" prompt="经销商"/>
        <bm:field name="division_desc" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="bp_class_desc" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="docu_number_reg" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select docu_number from CON_CONTRACT_LOCATION_LN c where  c.contract_id=t1.contract_id and c.doc_type=&apos;20&apos;)" forInsert="false" forUpdate="false"/>
        <bm:field name="docu_numberr_archive" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select docu_number from CON_CONTRACT_LOCATION_LN c where  c.contract_id=t1.contract_id and c.doc_type=&apos;10&apos;)" forInsert="false" forUpdate="false"/>
        <bm:field name="archive_status_n" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="reg_status_n" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="invoice_agent" databaseType="NUMBER" datatype="java.lang.Long"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:query-fields>
        <bm:query-field field="contract_number" queryExpression="upper(t1.contract_number) like &apos;%&apos; || upper(${@contract_number}) || &apos;%&apos;"/>
        <bm:query-field field="contract_name" queryExpression="upper(t1.contract_name) like &apos;%&apos; || upper(${@contract_name}) || &apos;%&apos;"/>
        <bm:query-field field="invoice_agent_desc" queryExpression="upper(t1.invoice_agent_desc) like &apos;%&apos; || upper(${@invoice_agent_desc}) || &apos;%&apos;"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter name="contract_id" expression="t1.contract_id in (select  ccll.contract_id  from CON_CONTRACT_LOCATION_LN ccll)"/>
        <bm:data-filter name="invoice_agent" expression="(t1.invoice_agent=(select  su.bp_id  from sys_user su where su.bp_category=&apos;AGENT&apos; and su.user_id=${/session/@user_id}) or (select su.bp_category from sys_user su where su.user_id = ${/session/@user_id}) !=&apos;AGENT&apos;)"/>
    </bm:data-filters>
    <!--  <bm:data-filters>
        <bm:data-filter name="1" enforcedQuery="query" expression="(t1.company_id = ${/session/@company_id} or t1.spv_company_id = ${/session/@company_id})"/>
    </bm:data-filters> -->
</bm:model>
