<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2014-2-13 下午2:42:08  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
  select t1.* from (select to_number(to_char(sysdate, 'YYYYMM')) internal_period_num,
         to_char(sysdate, 'YYYY') || '-' || to_char(sysdate, 'MM') period_name,
         trunc(last_day(sysdate))end_date
  from dual
  union
  select to_number(to_char(add_months(sysdate, -1), 'YYYYMM')) internal_period_num,
         to_char(add_months(sysdate, -1), 'YYYY') || '-' ||
         to_char(add_months(sysdate, -1), 'MM')  period_name,
         trunc(last_day(add_months(sysdate,-1)))end_date
  from dual
  order by internal_period_num desc) t1 #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>

        <bm:field name="period_name" displayWidth="120" forDisplay="true" forQuery="true" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PERIOD_NAME" prompt="GLD_PERIODS.PERIOD_NAME"/>
        <bm:field name="internal_period_num"  displayWidth="120" forDisplay="true" forQuery="true"  physicalName="INTERNAL_PERIOD_NUM" prompt="期间号"/>
        <bm:field name="end_date"  databaseType="DATE" datatype="java.util.Date" physicalName="END_DATE" prompt="截止日期"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="internal_period_num" queryExpression="t1.internal_period_num=${@internal_period_num}"/>
        <bm:query-field name="period_name" queryExpression="t1.period_name=${@period_name}"/>
    </bm:query-fields>
</bm:model>
