<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-3-26 下午03:11:36  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:e="leaf.service.exception" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="HLS_SALESMAN_ASSIGN" defaultOrderBy="t1.lease_organization,employee_code">
    <bm:fields>
        <bm:field name="employee_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="EMPLOYEE_ID" prompt="HLS_SALESMAN_ASSIGN.EMPLOYEE_ID"/>
        <bm:field name="lease_organization" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_ORGANIZATION" prompt="HLS_SALESMAN_ASSIGN.LEASE_ORGANIZATION"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG" prompt="HLS_SALESMAN_ASSIGN.ENABLED_FLAG"/>
        <bm:field name="ref_v01" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V01" prompt="HLS_SALESMAN_ASSIGN.REF_V01"/>
        <bm:field name="ref_v02" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V02" prompt="HLS_SALESMAN_ASSIGN.REF_V02"/>
        <bm:field name="ref_v03" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V03" prompt="HLS_SALESMAN_ASSIGN.REF_V03"/>
        <bm:field name="ref_v04" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V04" prompt="HLS_SALESMAN_ASSIGN.REF_V04"/>
        <bm:field name="ref_v05" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V05" prompt="HLS_SALESMAN_ASSIGN.REF_V05"/>
        <bm:field name="ref_n01" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N01" prompt="HLS_SALESMAN_ASSIGN.REF_N01"/>
        <bm:field name="ref_n02" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N02" prompt="HLS_SALESMAN_ASSIGN.REF_N02"/>
        <bm:field name="ref_n03" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N03" prompt="HLS_SALESMAN_ASSIGN.REF_N03"/>
        <bm:field name="ref_n04" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N04" prompt="HLS_SALESMAN_ASSIGN.REF_N04"/>
        <bm:field name="ref_n05" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N05" prompt="HLS_SALESMAN_ASSIGN.REF_N05"/>
        <bm:field name="ref_d01" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D01" prompt="HLS_SALESMAN_ASSIGN.REF_D01"/>
        <bm:field name="ref_d02" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D02" prompt="HLS_SALESMAN_ASSIGN.REF_D02"/>
        <bm:field name="ref_d03" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D03" prompt="HLS_SALESMAN_ASSIGN.REF_D03"/>
        <bm:field name="ref_d04" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D04" prompt="HLS_SALESMAN_ASSIGN.REF_D04"/>
        <bm:field name="ref_d05" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D05" prompt="HLS_SALESMAN_ASSIGN.REF_D05"/>
        <bm:field name="lease_organization_name" expression="(select lo.description from hls_lease_organization lo where lo.lease_organization=t1.lease_organization)" forInsert="false" forUpdate="false"/>
        <bm:field name="employee_name" expression="(select ee.name from exp_employees ee where ee.employee_id=t1.employee_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="employee_code" expression="(select ee.employee_code from exp_employees ee where ee.employee_id=t1.employee_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="employee_primary_position" expression="(select eop.description   from exp_employee_assigns   eea,        hls_lease_organization hlo,        exp_org_position_vl    eop  where eea.employee_id = t1.employee_id    and hlo.lease_organization = t1.lease_organization and eea.primary_position_flag = &apos;Y&apos;    and eea.position_id = eop.position_id)" forInsert="false" forUpdate="false"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="employee_id"/>
        <bm:pk-field name="lease_organization"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field field="employee_id" queryOperator="="/>
        <bm:query-field field="lease_organization" queryOperator="="/>
        <bm:query-field field="enabled_flag" queryOperator="="/>
    </bm:query-fields>
    <e:exception-descriptor-config>
        <e:exception-descriptor exception="java.sql.SQLException" handleClass="leaf.database.SQLExceptionDescriptor">
            <e:error-message code="1" message="HLS.SALESMAN_ASSIGN_DUPLICATE"/>
        </e:exception-descriptor>
    </e:exception-descriptor-config>
</bm:model>
