<?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
                    t.project_name,
                    t.bp_name,
                    t.lease_item_short_name,
                    t.employee_id_of_manager_n,
                    t.lease_organization_n,
                    t.business_type_n,
                    t.price_list_n
                    || '·'
                    || t.annual_pay_times_n
                    || '·'
                    ||
                    (SELECT
                        sc.code_value_name
                    FROM
                        sys_code_values_v sc
                    WHERE
                        ch.pay_type = sc.code_value AND
                        sc.code     = 'HLS500_PAY_TYPE'
                    ) pay_type_n,
                    TO_CHAR(t.finance_amount, 'fm99,999,999,990.00') finance_amount,
                    t.lease_times,
                    ch.lease_term,
                    TO_CHAR(ch.lease_charge, 'fm99,999,999,990.00') lease_charge,
                    ROUND(ch.lease_charge_ratio*100,2)
                    ||'%' lease_charge_ratio_per,
                    ROUND(ch.down_payment_ratio*100,2)
                    ||'%' down_payment_ratio_per,
                    TO_CHAR(ch.deposit, 'fm99,999,999,990.00') deposit,
                    ROUND(ch.irr * 100,2)
                    || '%' irr_per,
                    (SELECT
                        e.description
                    FROM
                        HLS_FIN_CALC_TYPE e
                    WHERE
                        e.calc_type =ch.calc_type
                    ) calc_type_n,
                    ROUND(ch.int_rate_display * 100,2)
                    || '%' int_rate_display_per
                FROM
                    prj_project_v t,
                    prj_quotation pq,
                    hls_fin_calculator_hd ch
                WHERE
                    t.project_id         = ${@document_id} AND
                    t.document_category  = ${@document_category} AND
                    pq.document_id       = t.project_id AND
                    pq.document_category = t.document_category AND
                    pq.calc_session_id   = ch.calc_session_id AND
                    pq.enabled_flag      = 'Y'
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
