<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zjw  
    $Date: 2011-9-7 上午10:06:32  
    $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 t.*,
        t.period_set_code,
        to_char(t.start_date, 'yyyy-mm-dd') start_date_c,
        to_char(t.end_date, 'yyyy-mm-dd') end_date_c
   from gld_periods t
  where t.period_set_code = ${@period_set_code}
    and t.internal_period_num > nvl((select max(s.internal_period_num) internal_period_num                                 
                                      from fnd_sob_period_status s
                                     where s.period_set_code = ${@period_set_code}
                                       and s.set_of_books_id =
                                           (select f.set_of_books_id
                                              from fnd_companies f
                                             where f.company_id = ${/session/@company_id})
                                     group by period_set_code),
                                    0)
  order by t.period_year asc,t.period_num asc
 ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="period_year" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PERIOD_YEAR" required="true"/>
        <bm:field name="period_num" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PERIOD_NUM" required="true"/>
        <bm:field name="period_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PERIOD_NAME" required="true"/>
        <bm:field name="start_date_c" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="START_DATE_C"/>
        <bm:field name="end_date_c" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="END_DATE_C"/>
        <bm:field name="quarter_num" databaseType="NUMBER" datatype="java.lang.Long" physicalName="QUARTER_NUM" required="true"/>
        <bm:field name="period_set_code" databaseType="VARCHAR2" datatype="java.lang.String" required="true"/>
        <bm:field name="adjustment_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ADJUSTMENT_FLAG" required="true"/>
    </bm:fields>
</bm:model>
