<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: qwm  
    $Date: 2013-7-24 下午7:36:34  
    $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.first_fiscal_year || '年' || t.first_fiscal_month || '月' fiscal_year,
       'first_year' as year,
       (select l.audit_inf from rsc_fin_statement_prj_lns l
         where l.fin_statement_id = t.first_fin_statement_id
           and l.fin_statement_type = ${/model/fin_statement_type/record/@code_value}
           and l.fin_statement_item = 'AUDIT_INF') audit_inf,
       'Y' as  flag  
       
  from rsc_fin_statement_prj_output t
 where t.fin_statement_templet_id = ${/model/datasource/record/@fin_statement_templet_id}
   and t.bp_id = ${/parameter/@bp_id}
   and t.first_fiscal_year is not null
   and t.fin_statement_type = ${/model/fin_statement_type/record/@code_value}
 group by t.first_fiscal_year, t.first_fiscal_month,t.first_fin_statement_id
 
 union all
select t.second_fiscal_year || '年' || t.second_fiscal_month || '月' fiscal_year,
       'second_year' as year,
       (select l.audit_inf from rsc_fin_statement_prj_lns l
         where l.fin_statement_id = t.second_fin_statement_id
           and l.fin_statement_type = ${/model/fin_statement_type/record/@code_value}
           and l.fin_statement_item = 'AUDIT_INF') audit_inf,
       'N' as  flag  
       
  from rsc_fin_statement_prj_output t
 where t.fin_statement_templet_id = ${/model/datasource/record/@fin_statement_templet_id}
   and t.bp_id = ${/parameter/@bp_id}
   and t.second_fiscal_year is not null
   and t.fin_statement_type = ${/model/fin_statement_type/record/@code_value}
 group by t.second_fiscal_year, t.second_fiscal_month,t.second_fin_statement_id
 
 union all
 select t.third_fiscal_year || '年' || t.third_fiscal_month || '月' fiscal_year,
       'third_year' as year,
       (select l.audit_inf from rsc_fin_statement_prj_lns l
         where l.fin_statement_id = t.third_fin_statement_id
           and l.fin_statement_type = ${/model/fin_statement_type/record/@code_value}
           and l.fin_statement_item = 'AUDIT_INF') audit_inf,
       'N' as  flag  
       
  from rsc_fin_statement_prj_output t
 where t.fin_statement_templet_id = ${/model/datasource/record/@fin_statement_templet_id}
   and t.bp_id = ${/parameter/@bp_id}
   and t.third_fiscal_year is not null
   and t.fin_statement_type = ${/model/fin_statement_type/record/@code_value}
 group by t.third_fiscal_year, t.third_fiscal_month,t.third_fin_statement_id
 
 union all
 
 select t.fourth_fiscal_year || '年' || t.fourth_fiscal_month || '月' fiscal_year,
       'fourth_year' as year,
       (select l.audit_inf from rsc_fin_statement_prj_lns l
         where l.fin_statement_id = t.fourth_fin_statement_id
           and l.fin_statement_type = ${/model/fin_statement_type/record/@code_value}
           and l.fin_statement_item = 'AUDIT_INF') audit_inf,
       'N' as  flag  
       
  from rsc_fin_statement_prj_output t
 where t.fin_statement_templet_id = ${/model/datasource/record/@fin_statement_templet_id}
   and t.bp_id = ${/parameter/@bp_id}
   and t.fourth_fiscal_year is not null
   and t.fin_statement_type = ${/model/fin_statement_type/record/@code_value}
 group by t.fourth_fiscal_year, t.fourth_fiscal_month,t.fourth_fin_statement_id
               
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <!-- <bm:fields>
        <bm:field name="column_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COLUMN_NAME"/>
        <bm:field name="field_description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FIELD_DESCRIPTION"/>
        <bm:field name="field_width" databaseType="NUMBER" datatype="java.lang.Long" physicalName="FIELD_WIDTH"/>
        <bm:field name="column_align" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COLUMN_ALIGN"/>
    </bm:fields> -->
</bm:model>
