<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hand  
    $Date: 2016-4-25 下午5:20:00  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:o="leaf.database.local.oracle" xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="CON_EXPRESS_HD" defaultOrderBy="t1.express_date desc">
    <bm:fields>
        <bm:field name="express_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="EXPRESS_ID" prompt="CON_EXPRESS_HD.EXPRESS_ID"/>
        <bm:field name="express_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXPRESS_NUMBER" prompt="CON_EXPRESS_HD.EXPRESS_NUMBER"/>
        <bm:field name="express_company" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXPRESS_COMPANY" prompt="CON_EXPRESS_HD.EXPRESS_COMPANY"/>
        <bm:field name="express_province" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXPRESS_PROVINCE" prompt="CON_EXPRESS_HD.EXPRESS_PROVINCE"/>
        <bm:field name="express_city" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXPRESS_CITY" prompt="CON_EXPRESS_HD.EXPRESS_CITY"/>
        <bm:field name="express_address" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXPRESS_ADDRESS" prompt="CON_EXPRESS_HD.EXPRESS_ADDRESS"/>
        <bm:field name="express_date" databaseType="DATE" datatype="java.util.Date" physicalName="EXPRESS_DATE" prompt="CON_EXPRESS_HD.EXPRESS_DATE"/>
        <bm:field name="express_person" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXPRESS_PERSON" prompt="CON_EXPRESS_HD.EXPRESS_PERSON"/>
        <bm:field name="express_tel" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXPRESS_TEL" prompt="CON_EXPRESS_HD.EXPRESS_TEL"/>
        <bm:field name="express_note" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXPRESS_NOTE" prompt="CON_EXPRESS_HD.EXPRESS_NOTE"/>
        <bm:field name="express_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXPRESS_TYPE" prompt="CON_EXPRESS_HD.EXPRESS_TYPE"/>
        <bm:field name="invoice_agent" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INVOICE_AGENT" prompt="CON_EXPRESS_HD.INVOICE_AGENT"/>
        <bm:field name="invoice_agent_desc" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select bpv.bp_name from hls_bp_master_v bpv where bpv.bp_id = t1.invoice_agent)" forInsert="false" forUpdate="false"/>
        <bm:field name="express_person_n" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select description from sys_user s where to_char(s.user_id)=t1.express_person)" forInsert="false" forUpdate="false"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="express_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field name="express_type" queryExpression="t1.express_type=${@express_type}"/>
        <bm:query-field name="express_number" queryExpression="t1.express_number like upper(&apos;%&apos;||${@express_number}||&apos;%&apos;)"/>
        <!--  <bm:query-field name="express_date" queryExpression="t1.express_date=to_date(${@express_date},&apos;yyyy-mm-dd&apos;)"/> -->
        <bm:query-field name="contract_number" queryExpression="t1.express_id in( select cel.express_id   from CON_EXPRESS_LN cel   where cel.contract_id in   (select c.contract_id  from con_contract c  where c.contract_number like &apos;%&apos;||${@contract_number}||&apos;%&apos;))"/>
        <bm:query-field name="reg_status" queryExpression="t1.express_id in( select cel.express_id   from CON_EXPRESS_LN cel   where cel.contract_id in   (select c.contract_id  from con_contract c  where c.ARCHIVE_STATUS=${@reg_status}))"/>
        <bm:query-field name="archive_status" queryExpression="t1.express_id in( select cel.express_id   from CON_EXPRESS_LN cel   where cel.contract_id in   (select c.contract_id  from con_contract c  where c.ARCHIVE_STATUS=${@archive_status}))"/>
        <bm:query-field name="express_date_from" queryExpression="t1.express_date &gt;= to_date(${@express_date_from},&apos;yyyy-mm-dd&apos;) "/>
        <bm:query-field name="express_date_to" queryExpression="t1.express_date &lt;= to_date(${@express_date_to},&apos;yyyy-mm-dd&apos;)"/>
        <!--  <bm:query-field name="borrow_date_from" queryExpression="t1.borrower_date &gt;= to_date(${@borrow_date_from},&apos;yyyy-mm-dd&apos;) "/>
        <bm:query-field name="borrow_date_to" queryExpression="t1.borrower_date &lt;= to_date(${@borrow_date_to},&apos;yyyy-mm-dd&apos;)"/> -->
        <bm:query-field name="invoice_agent" queryExpression="t1.invoice_agent=${@invoice_agent}"/>
    </bm:query-fields>
    <bm:data-filters>
        <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:model>