<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129 $
    $Date: 2013/08/28 10:12:58 $
    $Revision: 1.1 $
    $Purpose: “会计期间控制”中，用于查询没有打开的期间信息
-->
<ns1:model xmlns:ns1="http://www.leaf-framework.org/schema/bm">
	<ns1:operations>
		<ns1:operation name="query">
			<ns1:query-sql><![CDATA[

				select p.*,
				to_char(p.start_date, 'yyyy-mm-dd') start_date_c,
				to_char(p.end_date, 'yyyy-mm-dd') end_date_c,
				(select max(s.internal_period_num)
				from gld_period_status s
				where s.period_set_code = p.period_set_code
				and s.company_id = ${/session/@company_id}) as internal_period_num_max,
				nvl((select s.period_status_code
				from gld_period_status s
				where s.company_id = ${/session/@company_id}
				and s.period_set_code = p.period_set_code
				and s.internal_period_num = p.internal_period_num),
				'U') as period_status_code
				from gld_periods p
				where p.period_set_code = ${@period_set_code}
				and p.internal_period_num >= ${@internal_period_num}
				and rownum <= 3
				order by p.period_set_code,internal_period_num

				]]></ns1:query-sql>
		</ns1:operation>
	</ns1:operations>
</ns1:model>
