<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: duanjian 
    $Date: 2012-2-8 下午01:39:46  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
          select * from
          (
          select fc.company_id,
                 fc.company_code,
                 fc.company_short_name,
                 fc.company_code ||' - '||fc.company_short_name code_name
            from fnd_companies_vl fc
            where fc.company_id not in
                (select ger.company_id 
                 from gld_books_exchange_rates gber,
                      gld_exchange_rates ger
              where ger.from_currency=gber.from_currency
                and ger.to_currency=gber.to_currency
                and ger.type_code=gber.type_code
                and ger.set_of_books_id=gber.set_of_books_id
                and nvl(ger.conversion_date,sysdate) = nvl(gber.conversion_date,sysdate)
                and nvl(ger.period_name,'1')=nvl(gber.period_name,'1')
                and gber.exchange_rate_id=${@exchange_rate_id}
                )
              and fc.set_of_books_id=${@set_of_books_id}
              ) fv
              #WHERE_CLAUSE#
			  order by fv.company_code
			]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID"/>
        <bm:field name="company_code" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" physicalName="COMPANY_CODE" prompt="FND_COMPANIES.COMPANY_CODE"/>
        <bm:field name="company_short_name" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="false" forQuery="false" physicalName="COMPANY_SHORT_NAME" prompt="FND_COMPANIES.COMPANY_SHORT_NAME"/>
        <bm:field name="code_name" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" prompt="FND_COMPANIES.COMPANY_SHORT_NAME"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="company_code" queryOperator="like"/>
        <bm:query-field field="company_short_name" queryOperator="like"/>
        <bm:query-field name="code_name" queryExpression="fv.company_code like ${@code_name} || &apos;%&apos;"/>
        <bm:query-field name="company_code_from" queryExpression="fv.company_code &gt;= ${@company_code_from}"/>
        <bm:query-field name="company_code_to" queryExpression="fv.company_code &lt;= ${@company_code_to}"/>
    </bm:query-fields>
</bm:model>
