<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Foreinyel  
    $Date: 2013-11-26 上午10:15:11  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="con_contract_offset_v" defaultOrderBy="contract_id desc">
    <bm:fields>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" prompt="CON_CONTRACT_OFFSET_V.CONTRACT_ID"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NUMBER" prompt="CON_CONTRACT_OFFSET_V.CONTRACT_NUMBER"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_NAME" prompt="CON_CONTRACT_OFFSET_V.BP_NAME"/>
        <bm:field name="lease_item_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="LEASE_ITEM_AMOUNT" prompt="CON_CONTRACT_OFFSET_V.LEASE_ITEM_AMOUNT"/>
        <bm:field name="down_payment" databaseType="NUMBER" datatype="java.lang.Double" physicalName="DOWN_PAYMENT" prompt="CON_CONTRACT_OFFSET_V.DOWN_PAYMENT"/>
        <bm:field name="contract_status_disp" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_STATUS_DISP"/>
        <bm:field name="offset_amount" expression="(nvl(t1.down_payment,0) + nvl(t1.deposit,0) + nvl(t1.lease_charge,0) + nvl(t1.consulting_service,0) + nvl(t1.first_rent,0))" forInsert="false" forUpdate="false"/>
        <bm:field name="deposit" databaseType="NUMBER" datatype="java.lang.Double" physicalName="DEPOSIT"/>
        <bm:field name="first_rent" databaseType="NUMBER" datatype="java.lang.Double" physicalName="FIRST_RENT"/>
        <bm:field name="consulting_service" databaseType="NUMBER" datatype="java.lang.Double" physicalName="CONSULTING_SERVICE"/>
        <bm:field name="lease_charge" databaseType="NUMBER" datatype="java.lang.Double" physicalName="LEASE_CHARGE"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:query-fields>
        <bm:query-field field="contract_id" queryOperator="="/>
        <bm:query-field field="contract_number" queryOperator="="/>
        <bm:query-field field="bp_name" queryOperator="like"/>
    </bm:query-fields>
    <bm:data-filters>
        <!-- <bm:data-filter enforceOperations="query" expression="NOT EXISTS (SELECT 1                 FROM con_contract_cashflow                WHERE contract_id = t1.contract_id                      AND cf_item IN (2)  AND (write_off_flag IN (&apos;FULL&apos;) and received_amount = due_amount))"/> -->
        <bm:data-filter enforceOperations="query" expression="(nvl(t1.down_payment,0) + nvl(t1.deposit,0) + nvl(t1.lease_charge,0) + nvl(t1.consulting_service,0) + nvl(t1.first_rent,0)) != 0 and t1.lease_item_amount != 0 and t1.data_class = &apos;NORMAL&apos;"/>
        <bm:data-filter enforceOperations="query" expression=" not exists (select 1 from csh_offset where contract_id = t1.contract_id and reversed_flag = &apos;N&apos;)"/>
        <bm:data-filter enforceOperations="query" expression=" t1.contract_status in (&apos;SIGN&apos;,&apos;INCEPT&apos;)"/>
        <!-- <bm:data-filter enforceOperations="query" expression="exists (select 1 from con_contract s where s.contract_id = t1.contract_id and s.lease_channel != &apos;70&apos; and s.offset_flag = &apos;Y&apos;)"/> -->
    </bm:data-filters>
</bm:model>
