<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-6-24 下午04:30:53  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="CON_CONTRACT_CLOSED_LV" defaultOrderBy="t1.project_number desc">
    <bm:fields>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" prompt="CON301.CON_CONTRACT_CLOSED_LV.CONTRACT_ID"/>
        <bm:field name="calc_session_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CALC_SESSION_ID" prompt="CON301.CON_CONTRACT_CLOSED_LV.CALC_SESSION_ID"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NUMBER" prompt="CON301.CON_CONTRACT_CLOSED_LV.CONTRACT_NUMBER"/>
        <bm:field name="contract_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NAME" prompt="CON301.CON_CONTRACT_CLOSED_LV.CONTRACT_NAME"/>
        <bm:field name="business_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BUSINESS_TYPE" prompt="CON301.CON_CONTRACT_CLOSED_LV.BUSINESS_TYPE"/>
        <bm:field name="business_type_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BUSINESS_TYPE_N" prompt="CON301.CON_CONTRACT_CLOSED_LV.BUSINESS_TYPE_N"/>
        <bm:field name="project_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PROJECT_ID" prompt="CON301.CON_CONTRACT_CLOSED_LV.PROJECT_ID"/>
        <bm:field name="project_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_NUMBER" prompt="CON301.CON_CONTRACT_CLOSED_LV.PROJECT_NUMBER"/>
        <bm:field name="project_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_NAME" prompt="CON301.CON_CONTRACT_CLOSED_LV.PROJECT_NAME"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID" prompt="CON301.CON_CONTRACT_CLOSED_LV.COMPANY_ID"/>
        <bm:field name="lease_organization" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_ORGANIZATION" prompt="CON301.CON_CONTRACT_CLOSED_LV.LEASE_ORGANIZATION"/>
        <bm:field name="lease_organization_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_ORGANIZATION_DESC" prompt="CON301.CON_CONTRACT_CLOSED_LV.LEASE_ORGANIZATION_DESC"/>
        <bm:field name="lease_channel" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_CHANNEL" prompt="CON301.CON_CONTRACT_CLOSED_LV.LEASE_CHANNEL"/>
        <bm:field name="lease_channel_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_CHANNEL_N" prompt="CON301.CON_CONTRACT_CLOSED_LV.LEASE_CHANNEL_N"/>
        <bm:field name="bp_id_tenant" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID_TENANT" prompt="CON301.CON_CONTRACT_CLOSED_LV.BP_ID_TENANT"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_NAME" prompt="CON301.CON_CONTRACT_CLOSED_LV.BP_NAME"/>
        <bm:field name="bp_id_agent_level1" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID_AGENT_LEVEL1" prompt="CON301.CON_CONTRACT_CLOSED_LV.BP_ID_AGENT_LEVEL1"/>
        <bm:field name="bp_id_agent_level2" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID_AGENT_LEVEL2" prompt="CON301.CON_CONTRACT_CLOSED_LV.BP_ID_AGENT_LEVEL2"/>
        <bm:field name="bp_id_agent_level3" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID_AGENT_LEVEL3" prompt="CON301.CON_CONTRACT_CLOSED_LV.BP_ID_AGENT_LEVEL3"/>
        <bm:field name="owner_user_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OWNER_USER_ID" prompt="CON301.CON_CONTRACT_CLOSED_LV.OWNER_USER_ID"/>
        <!--<bm:field name="owner_user_id_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OWNER_USER_ID_N" prompt="CON301.CON_CONTRACT_CLOSED_LV.OWNER_USER_ID_N"/>-->
        <bm:field name="employee_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="EMPLOYEE_ID" prompt="CON301.CON_CONTRACT_CLOSED_LV.EMPLOYEE_ID"/>
        <bm:field name="employee_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EMPLOYEE_CODE" prompt="CON301.CON_CONTRACT_CLOSED_LV.EMPLOYEE_CODE"/>
        <bm:field name="employee_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EMPLOYEE_NAME" prompt="CON301.CON_CONTRACT_CLOSED_LV.EMPLOYEE_NAME"/>
        <bm:field name="down_payment" databaseType="NUMBER" datatype="java.lang.Double" physicalName="DOWN_PAYMENT" prompt="CON301.CON_CONTRACT_CLOSED_LV.DOWN_PAYMENT"/>
        <bm:field name="contract_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_STATUS" prompt="CON301.CON_CONTRACT_CLOSED_LV.CONTRACT_STATUS"/>
        <bm:field name="contract_status_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_STATUS_N" prompt="CON301.CON_CONTRACT_CLOSED_LV.CONTRACT_STATUS_N"/>
        <bm:field name="user_status_1" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="USER_STATUS_1" prompt="CON301.CON_CONTRACT_CLOSED_LV.USER_STATUS_1"/>
        <!--<bm:field name="user_status_1_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="USER_STATUS_1_DESC" prompt="CON301.CON_CONTRACT_CLOSED_LV.USER_STATUS_1_DESC"/>-->
        <bm:field name="user_status_2" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="USER_STATUS_2" prompt="CON301.CON_CONTRACT_CLOSED_LV.USER_STATUS_2"/>
        <bm:field name="user_status_3" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="USER_STATUS_3" prompt="CON301.CON_CONTRACT_CLOSED_LV.USER_STATUS_3"/>
        <bm:field name="lease_item_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="LEASE_ITEM_AMOUNT" prompt="CON301.CON_CONTRACT_CLOSED_LV.LEASE_ITEM_AMOUNT"/>
        <!--<bm:field name="company_id_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COMPANY_ID_N" prompt="CON301.CON_CONTRACT_CLOSED_LV.COMPANY_ID_N"/>-->
        <bm:field name="signing_location" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SIGNING_LOCATION"/>
        <!--<bm:field name="signing_user" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SIGNING_USER"/>
        <bm:field name="signing_user_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SIGNING_USER_ID"/>-->
        <bm:field name="signing_date" databaseType="DATE" datatype="java.util.Date" physicalName="SIGNING_DATE"/>
        <!--<bm:field name="bp_vender" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_VENDER"/>-->
        <bm:field name="document_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_TYPE"/>
        <bm:field name="document_type_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_TYPE_DESC"/>
        <bm:field name="print_date" databaseType="DATE" datatype="java.util.Date" physicalName="PRINT_DATE"/>
        <bm:field name="bp_class" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CLASS"/>
    </bm:fields>
    <bm:primary-key>
        <bm:pk-field name="contract_id"/>
    </bm:primary-key>
    <bm:features>
        <f:standard-who/>
        <!--  <s:bm-script><![CDATA[
            var cx = Packages.leaf.javascript.Context.getCurrentContext();
            Packages.leaf.plugin.script.engine.ScriptImportor.defineExternScript(cx, this, $ctx.getData(), "aut_authority_bm_validate.js");
        ]]></s:bm-script> -->
    </bm:features>
    <bm:query-fields>
        <bm:query-field name="contract_number" queryExpression="t1.contract_number like ${@contract_number}"/>
        <bm:query-field field="project_number" queryExpression="project_number like upper(&apos;%&apos;||${@project_number}||&apos;%&apos;)"/>
        <bm:query-field field="bp_id_tenant" queryOperator="="/>
        <bm:query-field name="lease_item_amount_from" queryExpression="lease_item_amount &gt;= ${@lease_item_amount_from}"/>
        <bm:query-field name="lease_item_amount_to" queryExpression="lease_item_amount &lt;= ${@lease_item_amount_to}"/>
        <bm:query-field field="lease_channel" queryOperator="="/>
        <bm:query-field field="business_type" queryOperator="="/>
        <bm:query-field field="lease_organization" queryOperator="="/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter name="query" expression="t1.contract_status  in (&apos;NEW&apos;,&apos;SIGN&apos;)"/>
        <!-- <bm:data-filter name="query" expression="not EXISTS (SELECT 1                 FROM con_contract_cashflow                WHERE contract_id = t1.contract_id                      AND (write_off_flag IN (&apos;PARTIAL&apos;,                                              &apos;FULL&apos;) OR received_amount IS NOT NULL OR                      received_principal IS NOT NULL OR received_interest IS NOT NULL))"/> -->
        <!--<bm:data-filter enforceOperations="query" expression="t1.user_status_1 IN (&apos;APPROVED&apos;)" field="user_status_1"/>-->
        <!--<bm:data-filter enforceOperations="query" expression=" NOT EXISTS (SELECT 1                 FROM con_contract_cashflow                WHERE contract_id = t1.contract_id                      AND times &gt;= 0                      AND (write_off_flag IN (&apos;PARTIAL&apos;, &apos;FULL&apos;) OR received_amount IS NOT NULL OR                      received_principal IS NOT NULL OR received_interest IS NOT NULL))"/>-->
        <!--<bm:data-filter enforceOperations="query" expression="exists (select 1 from con_contract where contract_id = t1.contract_id and created_by = ${/session/@user_id})"/>-->
    </bm:data-filters>
</bm:model>
