<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangwei  
    $Date: 2014-12-19 上午10:15:43  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
           select * from (select * from con_contract_all_v union select * from prj_project_union_con_v) 
           t1  #WHERE_CLAUSE# 
           order by nvl(t1.SUBMIT_DATE,to_date('2000-01-01','yyyy-mm-dd')) desc
           ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="car_user_name"/>
        <bm:field name="spv_company"/>
        <bm:field name="tenant_sec_name"/>
        <bm:field name="project_id"/>
        <bm:field name="document_status"/>
        <bm:field name="document_status_des"/>
        <bm:field name="lease_end_date"/>
        <bm:field name="return_reason"/>
        <bm:field name="bp_class"/>
        <bm:field name="bp_class_des"/>
        <bm:field name="inception_of_lease" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="invoice_agent_id"/>
        <bm:field name="invoice_agent_name"/>
        <bm:field name="company_id"/>
        <bm:field name="company_short_name"/>
        <bm:field name="document_category_name"/>
        <bm:field name="document_category"/>
        <bm:field name="employee_id_des"/>
        <bm:field name="employee_id"/>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" prompt="CON_CONTRACT_ALL_V.CONTRACT_ID"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NUMBER" prompt="CON_CONTRACT_ALL_V.CONTRACT_NUMBER"/>
        <bm:field name="contract_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_STATUS" prompt="CON_CONTRACT_ALL_V.CONTRACT_STATUS"/>
        <bm:field name="contract_status_des" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_STATUS_DES" prompt="CON_CONTRACT_ALL_V.CONTRACT_STATUS_DES"/>
        <bm:field name="district" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DISTRICT" prompt="CON_CONTRACT_ALL_V.DISTRICT"/>
        <bm:field name="lease_channel" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_CHANNEL" prompt="CON_CONTRACT_ALL_V.LEASE_CHANNEL"/>
        <bm:field name="lease_channel_des" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_CHANNEL_DES" prompt="CON_CONTRACT_ALL_V.LEASE_CHANNEL_DES"/>
        <bm:field name="district_des" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DISTRICT_DES" prompt="CON_CONTRACT_ALL_V.DISTRICT_DES"/>
        <bm:field name="unit_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="UNIT_ID" prompt="CON_CONTRACT_ALL_V.UNIT_ID"/>
        <bm:field name="unit_id_des" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="UNIT_ID_DES" prompt="CON_CONTRACT_ALL_V.UNIT_ID_DES"/>
        <bm:field name="organization_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="ORGANIZATION_ID" prompt="CON_CONTRACT_ALL_V.ORGANIZATION_ID"/>
        <bm:field name="organization_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ORGANIZATION_NAME" prompt="CON_CONTRACT_ALL_V.ORGANIZATION_NAME"/>
        <bm:field name="business_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BUSINESS_TYPE" prompt="CON_CONTRACT_ALL_V.BUSINESS_TYPE"/>
        <bm:field name="business_type_des" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BUSINESS_TYPE_DES" prompt="CON_CONTRACT_ALL_V.BUSINESS_TYPE_DES"/>
        <bm:field name="price_list" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PRICE_LIST" prompt="CON_CONTRACT_ALL_V.PRICE_LIST"/>
        <bm:field name="price_list_des" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PRICE_LIST_DES" prompt="CON_CONTRACT_ALL_V.PRICE_LIST_DES"/>
        <bm:field name="plate_resource_des" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PLATE_RESOURCE_DES" prompt="CON_CONTRACT_ALL_V.PLATE_RESOURCE_DES"/>
        <bm:field name="brand_id_des" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BRAND_ID_DES" prompt="CON_CONTRACT_ALL_V.BRAND_ID_DES"/>
        <bm:field name="brand_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BRAND_ID" prompt="CON_CONTRACT_ALL_V.BRAND_ID"/>
        <bm:field name="series_id_des" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SERIES_ID_DES" prompt="CON_CONTRACT_ALL_V.SERIES_ID_DES"/>
        <bm:field name="series_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SERIES_ID" prompt="CON_CONTRACT_ALL_V.SERIES_ID"/>
        <bm:field name="model_id_des" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MODEL_ID_DES" prompt="CON_CONTRACT_ALL_V.MODEL_ID_DES"/>
        <bm:field name="model_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="MODEL_ID" prompt="CON_CONTRACT_ALL_V.MODEL_ID"/>
        <bm:field name="tenant_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TENANT_NAME" prompt="CON_CONTRACT_ALL_V.TENANT_NAME"/>
        <bm:field name="guarantor_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="GUARANTOR_NAME" prompt="CON_CONTRACT_ALL_V.GUARANTOR_NAME"/>
        <bm:field name="owner_user_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OWNER_USER_ID" prompt="CON_CONTRACT_ALL_V.OWNER_USER_ID"/>
        <bm:field name="owner_user_id_des" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OWNER_USER_ID_DES" prompt="CON_CONTRACT_ALL_V.OWNER_USER_ID_DES"/>
        <bm:field name="sale_consultant" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SALE_CONSULTANT" prompt="CON_CONTRACT_ALL_V.SALE_CONSULTANT"/>
        <bm:field name="submit_date" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SUBMIT_DATE" prompt="CON_CONTRACT_ALL_V.SUBMIT_DATE"/>
        <bm:field name="create_date_fmt" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CREATE_DATE_FMT" prompt="CON_CONTRACT_ALL_V.CREATE_DATE_FMT"/>
        <bm:field name="action_type_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ACTION_TYPE_DESC" prompt="CON_CONTRACT_ALL_V.ACTION_TYPE_DESC"/>
        <bm:field name="signing_date" databaseType="DATE" datatype="java.util.Date" physicalName="SIGNING_DATE" prompt="CON_CONTRACT_ALL_V.SIGNING_DATE"/>
        <bm:field name="item_frame_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ITEM_FRAME_NUMBER" prompt="CON_CONTRACT_ALL_V.ITEM_FRAME_NUMBER"/>
        <bm:field name="hd_user_col_n06" databaseType="NUMBER" datatype="java.lang.Long" physicalName="HD_USER_COL_N06" prompt="CON_CONTRACT_ALL_V.HD_USER_COL_N06"/>
        <bm:field name="irr" databaseType="NUMBER" datatype="java.lang.Long" physicalName="IRR" prompt="CON_CONTRACT_ALL_V.IRR"/>
        <bm:field name="finance_income" databaseType="NUMBER" datatype="java.lang.Long" physicalName="FINANCE_INCOME" prompt="CON_CONTRACT_ALL_V.FINANCE_INCOME"/>
        <bm:field name="lease_item_amount" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LEASE_ITEM_AMOUNT" prompt="CON_CONTRACT_ALL_V.LEASE_ITEM_AMOUNT"/>
        <bm:field name="down_payment" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DOWN_PAYMENT" prompt="CON_CONTRACT_ALL_V.DOWN_PAYMENT"/>
        <bm:field name="down_payment_ratio" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DOWN_PAYMENT_RATIO" prompt="CON_CONTRACT_ALL_V.DOWN_PAYMENT_RATIO"/>
        <bm:field name="finance_amount" databaseType="NUMBER" datatype="java.lang.Long" physicalName="FINANCE_AMOUNT" prompt="CON_CONTRACT_ALL_V.FINANCE_AMOUNT"/>
        <bm:field name="lease_term" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LEASE_TERM" prompt="CON_CONTRACT_ALL_V.LEASE_TERM"/>
        <bm:field name="lease_charge" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LEASE_CHARGE" prompt="CON_CONTRACT_ALL_V.LEASE_CHARGE"/>
        <bm:field name="pmt" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PMT" prompt="CON_CONTRACT_ALL_V.PMT"/>
        <bm:field name="annual_pay_times" databaseType="NUMBER" datatype="java.lang.Long" physicalName="ANNUAL_PAY_TIMES" prompt="CON_CONTRACT_ALL_V.ANNUAL_PAY_TIMES"/>
        <bm:field name="annual_pay_times_des" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ANNUAL_PAY_TIMES_DES" prompt="CON_CONTRACT_ALL_V.ANNUAL_PAY_TIMES_DES"/>
        <bm:field name="pay_type" databaseType="CHAR" datatype="java.lang.String" physicalName="PAY_TYPE" prompt="CON_CONTRACT_ALL_V.PAY_TYPE"/>
        <bm:field name="residual_value" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RESIDUAL_VALUE" prompt="CON_CONTRACT_ALL_V.RESIDUAL_VALUE"/>
        <bm:field name="deposit" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DEPOSIT" prompt="CON_CONTRACT_ALL_V.DEPOSIT"/>
        <bm:field name="deposit_ratio" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DEPOSIT_RATIO" prompt="CON_CONTRACT_ALL_V.DEPOSIT_RATIO"/>
        <bm:field name="deposit_deduction_des" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DEPOSIT_DEDUCTION_DES" prompt="CON_CONTRACT_ALL_V.DEPOSIT_DEDUCTION_DES"/>
        <bm:field name="hd_user_col_n03" databaseType="NUMBER" datatype="java.lang.Long" physicalName="HD_USER_COL_N03" prompt="CON_CONTRACT_ALL_V.HD_USER_COL_N03"/>
        <bm:field name="hd_user_col_n12" databaseType="NUMBER" datatype="java.lang.Long" physicalName="HD_USER_COL_N12" prompt="CON_CONTRACT_ALL_V.HD_USER_COL_N12"/>
        <bm:field name="other_fee" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OTHER_FEE" prompt="CON_CONTRACT_ALL_V.OTHER_FEE"/>
        <bm:field name="other_fee3" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OTHER_FEE3" prompt="CON_CONTRACT_ALL_V.OTHER_FEE3"/>
        <bm:field name="insurance_fee" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INSURANCE_FEE" prompt="CON_CONTRACT_ALL_V.INSURANCE_FEE"/>
        <bm:field name="hd_user_col_n05" databaseType="NUMBER" datatype="java.lang.Long" physicalName="HD_USER_COL_N05" prompt="CON_CONTRACT_ALL_V.HD_USER_COL_N05"/>
        <bm:field name="full_write_off_date" databaseType="DATE" datatype="java.util.Date" physicalName="FULL_WRITE_OFF_DATE" prompt="CON_CONTRACT_ALL_V.FULL_WRITE_OFF_DATE"/>
        <bm:field name="car_invoice_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CAR_INVOICE_NUMBER" prompt="CON_CONTRACT_ALL_V.CAR_INVOICE_NUMBER"/>
        <bm:field name="car_invoice_date" databaseType="DATE" datatype="java.util.Date" physicalName="CAR_INVOICE_DATE" prompt="CON_CONTRACT_ALL_V.CAR_INVOICE_DATE"/>
        <bm:field name="car_invoice_total_amount" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CAR_INVOICE_TOTAL_AMOUNT" prompt="CON_CONTRACT_ALL_V.CAR_INVOICE_TOTAL_AMOUNT"/>
        <bm:field name="car_accounting_date" databaseType="DATE" datatype="java.util.Date" physicalName="CAR_ACCOUNTING_DATE" prompt="CON_CONTRACT_ALL_V.CAR_ACCOUNTING_DATE"/>
        <bm:field name="car_payment_completed_date" databaseType="DATE" datatype="java.util.Date" physicalName="CAR_PAYMENT_COMPLETED_DATE" prompt="CON_CONTRACT_ALL_V.CAR_PAYMENT_COMPLETED_DATE"/>
        <bm:field name="fee_invoice_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FEE_INVOICE_NUMBER" prompt="CON_CONTRACT_ALL_V.FEE_INVOICE_NUMBER"/>
        <bm:field name="fee_invoice_date" databaseType="DATE" datatype="java.util.Date" physicalName="FEE_INVOICE_DATE" prompt="CON_CONTRACT_ALL_V.FEE_INVOICE_DATE"/>
        <bm:field name="fee_invoice_total_amount" databaseType="NUMBER" datatype="java.lang.Long" physicalName="FEE_INVOICE_TOTAL_AMOUNT" prompt="CON_CONTRACT_ALL_V.FEE_INVOICE_TOTAL_AMOUNT"/>
        <bm:field name="fee_accounting_date" databaseType="DATE" datatype="java.util.Date" physicalName="FEE_ACCOUNTING_DATE" prompt="CON_CONTRACT_ALL_V.FEE_ACCOUNTING_DATE"/>
        <bm:field name="fee_payment_completed_date" databaseType="DATE" datatype="java.util.Date" physicalName="FEE_PAYMENT_COMPLETED_DATE" prompt="CON_CONTRACT_ALL_V.FEE_PAYMENT_COMPLETED_DATE"/>
        <bm:field name="insurance_invoice_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INSURANCE_INVOICE_NUMBER" prompt="CON_CONTRACT_ALL_V.INSURANCE_INVOICE_NUMBER"/>
        <bm:field name="insurance_invoice_date" databaseType="DATE" datatype="java.util.Date" physicalName="INSURANCE_INVOICE_DATE" prompt="CON_CONTRACT_ALL_V.INSURANCE_INVOICE_DATE"/>
        <bm:field name="insurance_invoice_total_amount" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INSURANCE_INVOICE_TOTAL_AMOUNT" prompt="CON_CONTRACT_ALL_V.INSURANCE_INVOICE_TOTAL_AMOUNT"/>
        <bm:field name="insurance_accounting_date" databaseType="DATE" datatype="java.util.Date" physicalName="INSURANCE_ACCOUNTING_DATE" prompt="CON_CONTRACT_ALL_V.INSURANCE_ACCOUNTING_DATE"/>
        <bm:field name="insurance_payment_date" databaseType="DATE" datatype="java.util.Date" physicalName="INSURANCE_PAYMENT_DATE" prompt="CON_CONTRACT_ALL_V.INSURANCE_PAYMENT_DATE"/>
        <bm:field name="hd_user_col_n02" databaseType="NUMBER" datatype="java.lang.Long" physicalName="HD_USER_COL_N02" prompt="CON_CONTRACT_ALL_V.HD_USER_COL_N02"/>
        <bm:field name="hd_user_col_n06_v"/>
        <bm:field name="irr_v"/>
        <bm:field name="down_payment_ratio_v"/>
        <bm:field name="deposit_ratio_v"/>
        <bm:field name="bp_property_des"/>
    </bm:fields>
    <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:data-filters>
        <bm:data-filter name="user_id" enforceOperations="query" expression=" exists (select 1 from aut_trx_user_authorize a1,aut_owner_user_authorize a2 where a1.trx_category = &apos;PROJECT&apos; and a1.trx_id = t1.project_id  and trunc(sysdate) between a1.start_date and nvl(a1.end_date,trunc(sysdate)) and a1.user_id = a2.owner_user_id and a1.trx_category = a2.trx_category  and a2.authorized_user_id = ${/session/@user_id} and trunc(sysdate) between a2.start_date and nvl(a2.end_date,trunc(sysdate)))"/>
    </bm:data-filters>
    <bm:query-fields>
        <bm:query-field field="document_status" queryOperator="="/>
        <bm:query-field field="contract_number" queryOperator="like"/>
        <bm:query-field field="contract_status" queryOperator="="/>
        <bm:query-field field="district" queryOperator="="/>
        <bm:query-field field="lease_channel" queryOperator="="/>
        <bm:query-field field="unit_id" queryOperator="="/>
        <bm:query-field field="organization_id" queryOperator="="/>
        <bm:query-field field="business_type" queryOperator="="/>
        <bm:query-field field="price_list" queryOperator="="/>
        <bm:query-field field="document_category" queryOperator="="/>
        <bm:query-field field="company_id" queryOperator="="/>
        <bm:query-field field="unit_id" queryOperator="="/>
        <bm:query-field field="employee_id" queryOperator="="/>
        <bm:query-field field="bp_class" queryOperator="="/>
        <bm:query-field field="lease_term" queryOperator="="/>
        <bm:query-field name="submit_start_date" queryExpression="t1.submit_date&gt;=trunc(to_date(${@submit_start_date},&apos;yyyy-mm-dd&apos;))"/>
        <bm:query-field name="submit_end_date" queryExpression="trunc(t1.submit_date)&lt;=to_date(${@submit_end_date},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="create_date_fmt_start" queryExpression="to_date(t1.create_date_fmt,&apos;yyyy-mm-dd hh24:mi:ss&apos;)&gt;=trunc(to_date(${@create_date_fmt_start},&apos;yyyy-mm-dd&apos;))"/>
        <bm:query-field name="create_date_fmt_end" queryExpression="trunc(to_date(t1.create_date_fmt,&apos;yyyy-mm-dd hh24:mi:ss&apos;))&lt;=to_date(${@create_date_fmt_end},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="inception_of_lease_start" queryExpression="t1.inception_of_lease&gt;=trunc(to_date(${@inception_of_lease_start},&apos;yyyy-mm-dd&apos;))"/>
        <bm:query-field name="inception_of_lease_end" queryExpression="trunc(t1.inception_of_lease)&lt;=to_date(${@inception_of_lease_end},&apos;yyyy-mm-dd&apos;)"/>
    </bm:query-fields>
</bm:model>
