<?xml version="1.0" encoding="UTF-8"?>
<ns1:model xmlns:ns2="leaf.database.local.oracle" xmlns:ns1="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="gber" baseTable="GLD_BOOKS_EXCHANGE_RATES">
    <ns1:fields>
        <ns1:field databaseType="NUMBER" datatype="java.lang.Long" name="exchange_rate_id"/>
        <ns1:field databaseType="VARCHAR2" datatype="java.lang.String" name="from_currency"/>
        <ns1:field databaseType="VARCHAR2" datatype="java.lang.String" name="to_currency"/>
        <ns1:field databaseType="VARCHAR2" datatype="java.lang.String" name="type_code"/>
        <ns1:field databaseType="NUMBER" datatype="java.lang.Long" name="set_of_books_id"/>
        <ns1:field databaseType="NUMBER" datatype="java.lang.Long" name="currency_volume"/>
        <ns1:field databaseType="NUMBER" datatype="java.lang.Long" name="conversion_rate"/>
        <ns1:field databaseType="DATE" datatype="java.util.Date" name="conversion_date"/>
        <ns1:field databaseType="VARCHAR2" datatype="java.lang.String" name="period_name"/>
        <ns1:field databaseType="NUMBER" datatype="java.lang.Long" name="internal_period_num"/>
        <ns1:field databaseType="VARCHAR2" datatype="java.lang.String" lookupCode="EXCHANGE_RATE_QUOTATION" lookupField="quotation_display" name="exchange_rate_quotation"/>
    </ns1:fields>
    <ns1:primary-key>
        <ns1:pk-field name="exchange_rate_id"/>
    </ns1:primary-key>
    <ns1:relations>
        <ns1:relation joinType="INNER" name="gc" refModel="gld.gld_currency">
            <ns1:reference foreignField="currency_code" localField="to_currency"/>
        </ns1:relation>
        <ns1:relation joinType="INNER" name="sob" refModel="gld.gld_set_of_books">
            <ns1:reference foreignField="set_of_books_id" localField="set_of_books_id"/>
        </ns1:relation>
    </ns1:relations>
    <ns1:query-fields>
        <ns1:query-field name="currency_code" queryExpression="gber.from_currency = ${/parameter/@currency_code}"/>
        <ns1:query-field field="type_code" queryOperator="="/>
        <ns1:query-field name="currency_code_frn" queryExpression="gber.to_currency =nvl(${/parameter/@currency_code_frn},gber.to_currency)"/>
        <ns1:query-field name="period_from" queryExpression="exists (             select 1 from gld_periods gp             where gp.period_set_code = sob.period_set_code             and gp.period_name = gber.period_name             and internal_period_num &gt;= gld_common_pkg.get_gld_internal_period_num(${/session/@company_id},${/parameter/@period_from})              )"/>
        <ns1:query-field name="period_to" queryExpression=" exists (             select 1 from gld_periods gp             where gp.period_set_code = sob.period_set_code             and gp.period_name = gber.period_name             and internal_period_num &lt;= gld_common_pkg.get_gld_internal_period_num(${/session/@company_id},${@period_from})              ) "/>
        <ns1:query-field name="date_from" queryExpression=" gber.conversion_date &gt;= ${@date_from}"/>
        <ns1:query-field name="date_to" queryExpression=" gber.conversion_date &lt;= ${@date_to} "/>
    </ns1:query-fields>
    <ns1:data-filters>
        <ns1:data-filter enforceOperations="query" expression="exists (select  fc.set_of_books_id             from  fnd_companies  fc             where  fc.set_of_books_id = gber.set_of_books_id              and    fc.company_id = ${/session/@company_id})"/>
    </ns1:data-filters>
    <ns1:features>
        <ns2:sequence-pk/>
        <f:standard-who/>
        <f:multi-language-display/>
    </ns1:features>
    <ns1:ref-fields>
        <ns1:ref-field name="period_set_code" relationName="sob" sourceField="period_set_code"/>
        <ns1:ref-field name="currency_name_id" relationName="gc" sourceField="currency_name_id"/>
    </ns1:ref-fields>
</ns1:model>
