<?xml version="1.0" encoding="UTF-8"?>
<!--
    @Author: xsh 35973  
    @Date: 2022/3/28 10:16
    @Revision: 1.0  
    @Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1">
    <bm:fields/>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select *
                  from (select
                        hd.fin_statement_id,
                        hd.bp_id,
                       (hd.fiscal_year || lpad(hd.fiscal_month, 2, 0)) report_num,
                       (select bp_name from hls_bp_master where bp_id = hd.bp_id) bp_name,
                       hd.month_check_result,
                       (hd.fiscal_year || '-' || lpad(hd.fiscal_month, 2, 0)) report_month,
                       (select nvl(ln.indicator_value, 0)
                          from rsc_fin_indicator_lns ln
                         where hd.fin_indicator_id = ln.fin_indicator_id
                           and ln.line_number = 1) index_name1,
                       (select nvl(ln.indicator_value, 0)
                          from rsc_fin_indicator_lns ln
                         where hd.fin_indicator_id = ln.fin_indicator_id
                           and ln.line_number = 2) index_name2,
                       (select nvl(ln.indicator_value, 0)
                          from rsc_fin_indicator_lns ln
                         where hd.fin_indicator_id = ln.fin_indicator_id
                           and ln.line_number = 3) index_name3,
                       (select nvl(ln.indicator_value, 0)
                          from rsc_fin_indicator_lns ln
                         where hd.fin_indicator_id = ln.fin_indicator_id
                           and ln.line_number = 4) index_name4,
                       (select nvl(ln.indicator_value, 0)
                          from rsc_fin_indicator_lns ln
                         where hd.fin_indicator_id = ln.fin_indicator_id
                           and ln.line_number = 5) index_name5,
                       (select nvl(ln.indicator_value, 0)
                          from rsc_fin_indicator_lns ln
                         where hd.fin_indicator_id = ln.fin_indicator_id
                           and ln.line_number = 6) index_name6,
                       (select nvl(ln.indicator_value, 0)
                          from rsc_fin_indicator_lns ln
                         where hd.fin_indicator_id = ln.fin_indicator_id
                           and ln.line_number = 7) index_name7,
                       (select nvl(ln.indicator_value, 0)
                          from rsc_fin_indicator_lns ln
                         where hd.fin_indicator_id = ln.fin_indicator_id
                           and ln.line_number = 8) index_name8,
                       (select nvl(ln.indicator_value, 0)
                          from rsc_fin_indicator_lns ln
                         where hd.fin_indicator_id = ln.fin_indicator_id
                           and ln.line_number = 9) index_name9,
                       (select nvl(ln.indicator_value, 0)
                          from rsc_fin_indicator_lns ln
                         where hd.fin_indicator_id = ln.fin_indicator_id
                           and ln.line_number = 10) index_name10,
                       (select nvl(ln.indicator_value, 0)
                          from rsc_fin_indicator_lns ln
                         where hd.fin_indicator_id = ln.fin_indicator_id
                           and ln.line_number = 11) index_name11,
                       (select nvl(ln.indicator_value, 0)
                          from rsc_fin_indicator_lns ln
                         where hd.fin_indicator_id = ln.fin_indicator_id
                           and ln.line_number = 12) index_name12,
                       (select nvl(ln.indicator_value, 0)
                          from rsc_fin_indicator_lns ln
                         where hd.fin_indicator_id = ln.fin_indicator_id
                           and ln.line_number = 13) index_name13,
                       (select nvl(ln.indicator_value, 0)
                          from rsc_fin_indicator_lns ln
                         where hd.fin_indicator_id = ln.fin_indicator_id
                           and ln.line_number = 14) index_name14,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 1
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'BALANCE_SHEET'
                           and phd.project_id is null) index_name15,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 3
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'BALANCE_SHEET'
                           and phd.project_id is null) index_name16,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 4
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'BALANCE_SHEET'
                           and phd.project_id is null) index_name17,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 5
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'BALANCE_SHEET'
                           and phd.project_id is null) index_name18,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 6
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'BALANCE_SHEET'
                           and phd.project_id is null) index_name19,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 8
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'BALANCE_SHEET'
                           and phd.project_id is null) index_name20,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 10
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'BALANCE_SHEET'
                           and phd.project_id is null) index_name21,
                       (select round(sum(nvl(amount,0)),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number in (12,13,14,15)
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'BALANCE_SHEET'
                           and phd.project_id is null) index_name22,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 32
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'BALANCE_SHEET'
                           and phd.project_id is null) index_name23,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 1
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'INCOME_STATEMENT'
                           and phd.project_id is null) index_name24,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 2
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'INCOME_STATEMENT'
                           and phd.project_id is null) index_name25,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 5
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'INCOME_STATEMENT'
                           and phd.project_id is null) index_name26,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 6
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'INCOME_STATEMENT'
                           and phd.project_id is null) index_name27,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 18
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'INCOME_STATEMENT'
                           and phd.project_id is null) index_name28,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 11
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'CASHFLOW_STATEMENT'
                           and phd.project_id is null) index_name29,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 24
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'CASHFLOW_STATEMENT'
                           and phd.project_id is null) index_name30,
                       (select round(nvl(amount,0),2)
                          from rsc_fin_statement_prj_hds phd, rsc_fin_statement_prj_lns pln
                         where phd.fin_statement_id = pln.fin_statement_id
                           and phd.bp_id = hd.bp_id
                           and phd.fiscal_year = hd.fiscal_year
                           and phd.fiscal_month = hd.fiscal_month
                           and pln.line_number = 34
                           and phd.fin_statement_templet_id = hd.fin_statement_templet_id
                           and pln.fin_statement_type = 'CASHFLOW_STATEMENT'
                           and phd.project_id is null) index_name31
                  from rsc_fin_indicator_hds hd
                 where hd.fin_statement_templet_id = 206
                 and project_id is null) t1
                   #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="bp_id" queryExpression="t1.bp_id in (${:@bp_id})"/>
        <bm:query-field name="report_num" queryExpression="t1.report_num in (${:@report_num})"/>
    </bm:query-fields>
</bm:model>