<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: niujiaqing1265 $
    $Date: 2010/12/09 05:48:38 $
    $Revision: 1.2 $
    $Purpose: “会计期间控制”中，用于查询已经打开的期间信息
-->
<ns1:model xmlns:ns1="http://www.leaf-framework.org/schema/bm" alias="gps" baseTable="GLD_PERIOD_STATUS" defaultOrderBy="period_year asc,period_num asc">
    <ns1:fields>
        <ns1:field name="period_set_code" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <ns1:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <ns1:field name="period_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <ns1:field name="internal_period_num" databaseType="NUMBER" datatype="java.lang.Long"/>
        <ns1:field name="period_status_code" databaseType="VARCHAR2" datatype="java.lang.String" expression="decode(gps.period_status_code,null,&apos;u&apos;,gps.period_status_code)"/>
        <ns1:field name="start_date_c" databaseType="VARCHAR2" datatype="java.lang.String" expression="to_char(gp.start_date, &apos;yyyy-mm-dd&apos;)"/>
        <ns1:field name="end_date_c" databaseType="VARCHAR2" datatype="java.lang.String" expression="to_char(gp.end_date, &apos;yyyy-mm-dd&apos;)"/>
    </ns1:fields>
    <ns1:primary-key>
        <ns1:pk-field name="company_id"/>
        <ns1:pk-field name="internal_period_num"/>
        <ns1:pk-field name="period_set_code"/>
    </ns1:primary-key>
    <ns1:relations>
        <ns1:relation name="gp" joinType="inner" refModel="gld.gld_periods">
            <ns1:reference foreignField="internal_period_num" localField="internal_period_num"/>
            <ns1:reference foreignField="period_set_code" localField="period_set_code"/>
        </ns1:relation>
    </ns1:relations>
    <ns1:data-filters>
        <ns1:data-filter enforceOperations="query" expression="gps.period_set_code = ${@period_set_code}"/>
        <ns1:data-filter enforceOperations="query" expression="gps.company_id = ${/session/@company_id}"/>
    </ns1:data-filters>
    <ns1:ref-fields>
        <ns1:ref-field name="period_year" relationName="gp" sourceField="period_year"/>
        <ns1:ref-field name="period_num" relationName="gp" sourceField="period_num"/>
        <ns1:ref-field name="start_date" relationName="gp" sourceField="start_date"/>
        <ns1:ref-field name="end_date" relationName="gp" sourceField="end_date"/>
        <ns1:ref-field name="quarter_num" relationName="gp" sourceField="quarter_num"/>
        <ns1:ref-field name="adjustment_flag" relationName="gp" sourceField="adjustment_flag"/>
    </ns1:ref-fields>
</ns1:model>
