<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: LR  
    $Date: 2013-8-12 上午10:08:35  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:e="leaf.service.exception" xmlns:ns2="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="fc" baseTable="fnd_companies" defaultOrderBy="company_code">
    <bm:fields>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" forInsert="true" physicalName="COMPANY_ID" prompt="FND_COMPANIES.COMPANY_ID"/>
        <bm:field name="company_code" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="234" forDisplay="true" forInsert="true" forQuery="true" fordisplay="true" physicalName="COMPANY_CODE" prompt="FND_COMPANIES.COMPANY_CODE"/>
        <bm:field name="company_type" databaseType="VARCHAR" datatype="java.lang.String" lookupCode="COMPANY_TYPE" lookupField="company_type_display"/>
        <bm:field name="company_type_display" forInsert="false" forUpdate="false" prompt="FND_COMPANIES.COMPANY_TYPE"/>
        <bm:field name="set_of_books_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SET_OF_BOOKS_ID" prompt="FND_COMPANIES.SET_OF_BOOKS_ID"/>
        <bm:field name="set_of_books_id_display" databaseType="VARCHAR" datatype="java.lang.String" expression="(select v.set_of_books_code||&apos;-&apos;||v.set_of_books_name from  gld_set_of_books v where v.set_of_books_id=fc.set_of_books_id)" forInsert="false" forUpdate="false" prompt="FND_COMPANIES.SET_OF_BOOKS"/>
        <bm:field name="address" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ADDRESS" prompt="FND_COMPANIES.ADDRESS"/>
        <bm:field name="company_level_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_LEVEL_ID" prompt="FND_COMPANIES.COMPANY_LEVEL_ID"/>
        <bm:field name="company_level_id_display" databaseType="VARCHAR" datatype="java.lang.String" expression="(select fclv.company_level_code||&apos;-&apos;||fclv.description from fnd_company_levels_vl fclv where fclv.company_level_id=fc.company_level_id)" forInsert="false" forUpdate="false" prompt="FND_COMPANIES.COMPANY_LEVEL_ID"/>
        <bm:field name="parent_company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PARENT_COMPANY_ID" prompt="FND_COMPANIES.PARENT_COMPANY_ID"/>
        <bm:field name="chief_position_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CHIEF_POSITION_ID" prompt="FND_COMPANIES.CHIEF_POSITION_ID"/>
        <bm:field name="chief_position_id_display" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select eopv.POSITION_CODE||&apos;-&apos;||eopv.DESCRIPTION from exp_org_position_vl eopv where eopv.company_id= fc.company_id AND eopv.position_id =fc.chief_position_id)" forInsert="false" forUpdate="false" prompt="FND_COMPANIES.CHIEF_POSITION_ID"/>
        <bm:field name="start_date_active" databaseType="DATE" datatype="java.util.Date" physicalName="START_DATE_ACTIVE" prompt="FND_COMPANIES.START_DATE_ACTIVE"/>
        <bm:field name="end_date_active" databaseType="DATE" datatype="java.util.Date" physicalName="END_DATE_ACTIVE" prompt="FND_COMPANIES.END_DATE_ACTIVE"/>
        <bm:field name="enable_role_authority" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLE_ROLE_AUTHORITY" prompt="FND_COMPANIES.ENABLE_ROLE_AUTHORITY"/>
        <bm:field name="enable_user_authority" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLE_USER_AUTHORITY" prompt="FND_COMPANIES.ENABLE_USER_AUTHORITY"/>
        <bm:field name="invoice_title" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INVOICE_TITLE" prompt="FND_COMPANIES.INVOICE_TITLE"/>
        <bm:field name="tax_registry_num" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TAX_REGISTRY_NUM" prompt="FND_COMPANIES.TAX_REGISTRY_NUM"/>
        <bm:field name="invoice_bp_address_phone_num" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INVOICE_BP_ADDRESS_PHONE_NUM" prompt="FND_COMPANIES.INVOICE_BP_ADDRESS_PHONE_NUM"/>
        <bm:field name="invoice_bp_bank_account" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INVOICE_BP_BANK_ACCOUNT" prompt="FND_COMPANIES.INVOICE_BP_BANK_ACCOUNT"/>
        <bm:field name="vat_invoice_limit" databaseType="NUMBER" datatype="java.lang.Double" physicalName="VAT_INVOICE_LIMIT" prompt="FND_COMPANIES.VAT_INVOICE_LIMIT"/>
        <bm:field name="invoice_limit" databaseType="NUMBER" datatype="java.lang.Double" physicalName="INVOICE_LIMIT" prompt="FND_COMPANIES.INVOICE_LIMIT"/>
        <bm:field name="company_short_name" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="234" forDisplay="true" forInsert="true" forQuery="true" fordisplay="true" physicalName="COMPANY_SHORT_NAME" prompt="FND_COMPANIES.COMPANY_SHORT_NAME"/>
        <bm:field name="company_full_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COMPANY_FULL_NAME" prompt="FND_COMPANIES.COMPANY_FULL_NAME"/>
        <bm:field name="parent_biz_company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PARENT_BIZ_COMPANY_ID" prompt="FND_COMPANIES.PARENT_BIZ_COMPANY_ID"/>
        <bm:field name="spv_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SPV_FLAG" prompt="FND_COMPANIES.SPV_FLAG"/>
        <bm:field name="parent_biz_company_code" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select fc1.company_code from fnd_companies fc1 where fc1.company_id=fc.parent_biz_company_id)" forInsert="false" forUpdate="false" prompt="FND_COMPANIES.PARENT_BIZ_COMPANY_CODE"/>
        <bm:field name="parent_biz_company_display" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select fc1.company_short_name from fnd_companies fc1 where fc1.company_id=fc.parent_biz_company_id)" forInsert="false" forUpdate="false" prompt="FND_COMPANIES.PARENT_BIZ_COMPANY_DISPLAY"/>
        <bm:field name="sales_tax_invoice_limit" databaseType="NUMBER" datatype="java.lang.Double" physicalName="SALES_TAX_INVOICE_LIMIT" prompt="FND_COMPANIES.SALES_TAX_INVOICE_LIMIT"/>
        <bm:field name="phone" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PHONE" prompt="FND_COMPANIES.PHONE"/>
        <bm:field name="bank_account_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BANK_ACCOUNT_ID" prompt="FND_COMPANIES.BANK_ACCOUNT_ID"/>
        <bm:field name="bank_info" expression="(select a.bank_branch_name||&apos;-&apos;||a.bank_account_num from CSH_BANK_ACCOUNT_V a where a.bank_account_id=fc.bank_account_id)" forInsert="false" forUpdate="false"/>
    </bm:fields>
    <bm:primary-key>
        <bm:pk-field name="company_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field field="company_id" queryOperator="="/>
        <bm:query-field field="company_code" queryOperator="like"/>
        <bm:query-field field="set_of_books_id" queryOperator="="/>
        <bm:query-field field="company_short_name" queryOperator="like"/>
        <bm:query-field name="valid_date" queryExpression="(sysdate between fc.start_date_active and nvl(fc.end_date_active,sysdate))"/>
        <bm:query-field field="company_type" queryOperator="="/>
        <bm:query-field name="not_company_id" queryExpression="fc.company_id != ${@not_company_id}"/>
        <bm:query-field name="include_disabled_flag" queryExpression="(${@include_disabled_flag}=&apos;Y&apos; or( sysdate between start_date_active and nvl(end_date_active,sysdate)))"/>
    </bm:query-fields>
    <bm:features>
        <ns2:sequence-pk/>
        <f:standard-who/>
        <f:multi-language-storage/>
    </bm:features>
    <bm:ref-fields/>
    <e:exception-descriptor-config>
        <e:exception-descriptor exception="java.sql.SQLException" handleClass="leaf.database.SQLExceptionDescriptor">
            <e:error-message code="1" message="FND_COMPANIES.COMPANY_CODE_DISTINCT"/>
        </e:exception-descriptor>
    </e:exception-descriptor-config>
</bm:model>
