<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    *
                FROM
                    (SELECT
                        cc.contract_id,
                        cc.hn_industry_classification,
                        cc.contract_number,
                        cc.contract_name,
                        cc.bp_id_tenant,
                        hbm.bp_name,
                        NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '01'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '01'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '01')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'01'
                        ),0) month_1,
                        NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '02'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '02'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '02')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'02'
                        ),0) month_2,
                        NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '03'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '03'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '03')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'03'
                        ),0) month_3,
                        NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '04'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '04'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '04')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'04'
                        ),0) month_4,
                        NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '05'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '05'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '05')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'05'
                        ),0) month_5,
                        NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '06'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '06'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '06')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'06'
                        ),0) month_6,
                        NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '07'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '07'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '07')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'07'
                        ),0) month_7,
                        NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '08'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '08'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '08')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'08'
                        ),0) month_8,
                        NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '09'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '09'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '09')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'09'
                        ),0) month_9,
                        NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '10'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '10'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '10')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'10'
                        ),0) month_10,
                        NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '11'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '11'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '11')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'11'
                        ),0) month_11,
                        NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '12'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '12'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '12')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'12'
                        ),0) month_12,
                        NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '01'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '01'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '01')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'01'
                        ),0) + NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '02'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '02'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '02')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'02'
                        ),0) + NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '03'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '03'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '03')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'03'
                        ),0) + NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '04'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '04'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '04')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'04'
                        ),0) + NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '05'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '05'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '05')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'05'
                        ),0) + NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '06'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '06'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '06')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'06'
                        ),0) + NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '07'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '07'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '07')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'07'
                        ),0) + NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '08'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '08'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '08')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'08'
                        ),0) + NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '09'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '09'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '09')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'09'
                        ),0) + NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '10'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '10'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '10')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'10'
                        ),0) + NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '11'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '11'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '11')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'11'
                        ),0) + NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '12'
                        ), 0) - sdic_report_pkg.get_sum_vat_finance_income(p_contract_id => cc.contract_id, p_finance_income => NVL(
                        (SELECT
                            SUM(NVL(cufi.unearned_finance_income, 0))
                        FROM
                            con_unearned_finance_income cufi
                        WHERE
                            cufi.contract_id         = cc.contract_id AND
                            cufi.cf_item             = 1 AND
                            cufi.internal_period_num = ${@calc_year}
                            || '12'
                        ), 0), p_internal_period_num => ${@calc_year}
                        || '12')+ NVL(
                        (SELECT
                            sum(ccc.net_due_amount)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     IN (3,15) AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') =${@calc_year}
                            ||'12'
                        ),0) sum_amount
                    FROM
                        con_contract cc,
                        hls_bp_master hbm
                    WHERE
                        cc.data_class                      = 'NORMAL' AND
                        NVL(cc.hn_adjust_review_flag, 'N') = 'Y' AND
                        cc.bp_id_tenant                    = hbm.bp_id AND
                        ${@data_type}                      ='OPERATING_RECEIPT'
                    UNION
                    SELECT
                        cc.contract_id,
                        cc.hn_industry_classification,
                        cc.contract_number,
                        cc.contract_name,
                        cc.bp_id_tenant,
                        hbm.bp_name,
                        NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '01'
                        ), 0) month_1,
                        NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '02'
                        ), 0) month_2,
                        NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '03'
                        ), 0) month_3,
                        NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '04'
                        ), 0) month_4,
                        NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '05'
                        ), 0) month_5,
                        NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '06'
                        ), 0) month_6,
                        NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '07'
                        ), 0) month_7,
                        NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '08'
                        ), 0) month_8,
                        NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '09'
                        ), 0) month_9,
                        NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '10'
                        ), 0) month_10,
                        NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '11'
                        ), 0) month_11,
                        NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '12'
                        ), 0) month_12,
                        NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '01'
                        ), 0) + NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '02'
                        ), 0) + NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '03'
                        ), 0) + NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '04'
                        ), 0) + NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '05'
                        ), 0) + NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '06'
                        ), 0) + NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '07'
                        ), 0) + NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '08'
                        ), 0) + NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '09'
                        ), 0) + NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '10'
                        ), 0) + NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '11'
                        ), 0) + NVL(
                        (SELECT
                            sum(ccc.principal)
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.contract_id                 = cc.contract_id AND
                            ccc.cf_item                     = 1 AND
                            ccc.cf_direction                = 'INFLOW' AND
                            TO_CHAR(ccc.due_date, 'YYYYMM') = ${@calc_year}
                            || '12'
                        ), 0) sum_amount
                    FROM
                        con_contract cc,
                        hls_bp_master hbm
                    WHERE
                        cc.data_class                      = 'NORMAL' AND
                        NVL(cc.hn_adjust_review_flag, 'N') = 'Y' AND
                        cc.bp_id_tenant                    = hbm.bp_id AND
                        ${@data_type}                      ='RECOVERY_PRINCIPAL'
                    UNION
                    SELECT
                        cc.contract_id,
                        cc.hn_industry_classification,
                        cc.contract_number,
                        cc.contract_name,
                        cc.bp_id_tenant,
                        hbm.bp_name,
                        NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '01'),0) month_1,
                        NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '02'),0) month_2,
                        NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '03'),0) month_3,
                        NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '04'),0) month_4,
                        NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '05'),0) month_5,
                        NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '06'),0) month_6,
                        NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '07'),0) month_7,
                        NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '08'),0) month_8,
                        NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '09'),0) month_9,
                        NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '10'),0) month_10,
                        NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '11'),0) month_11,
                        NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '12'),0) month_12,
                        NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '01'),0) + NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '02'),0) + NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '03'),0) + NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '04'),0) + NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '05'),0) + NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '06'),0) + NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '07'),0) + NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '08'),0) + NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '09'),0) + NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '10'),0) + NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '11'),0) + NVL(sdic_report_pkg.get_long_term_receivables(p_contract_id => cc.contract_id, p_calc_date => ${@calc_year}
                        || '12'),0) sum_amount
                    FROM
                        con_contract cc,
                        hls_bp_master hbm
                    WHERE
                        cc.data_class                      = 'NORMAL' AND
                        NVL(cc.hn_adjust_review_flag, 'N') = 'Y' AND
                        cc.bp_id_tenant                    = hbm.bp_id AND
                        ${@data_type}                      ='LONG_TERM_RECEIVABLES'
                    ) t1 #WHERE_CLAUSE#
                ORDER BY
                    t1.contract_number
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="contract_number" queryExpression="t1.contract_number like &apos;%&apos;||${@contract_number}||&apos;%&apos;"/>
        <bm:query-field name="contract_name" queryExpression="t1.contract_name like &apos;%&apos;||${@contract_name}||&apos;%&apos;"/>
        <bm:query-field name="bp_name" queryExpression="t1.bp_name like &apos;%&apos;||${@bp_name}||&apos;%&apos;"/>
        <bm:query-field name="hn_industry_classification_desc" queryExpression="t1.hn_industry_classification=${@hn_industry_classification}"/>
    </bm:query-fields>
</bm:model>
