<?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.contract_name,
                    t.project_name,
                    con_contract_change_req_pkg.get_con_bps_name(t.contract_id, 'TENANT') bp_name,
                    con_contract_change_req_pkg.get_con_bps_name(r.change_req_id, 'TENANT') bp_name_new,
                    con_contract_change_req_pkg.get_con_bps_name(t.contract_id, 'GUARANTOR') bp_guarantor,
                    con_contract_change_req_pkg.get_con_bps_name(r.change_req_id, 'GUARANTOR') bp_guarantor_new,
                    t.employee_name,
                    t.lease_organization_n,
                    t.business_type_n,
                    TO_CHAR(t.total_rental , 'fm99,999,999,990.00') total_rental,
                    (SELECT
                        TO_CHAR(c.total_rental, 'fm99,999,999,990.00')
                    FROM
                        con_contract c
                    WHERE
                        c.contract_id = r.change_req_id
                    ) total_rental_new,
                    t.lease_times,
                    TO_CHAR(ch.lease_charge, 'fm99,999,999,990.00') lease_charge,
                    ROUND(ch.irr * 100, 2)
                    || '%' irr_per,
                    (SELECT
                        ROUND(c.irr * 100, 2)
                        || '%'
                    FROM
                        con_contract c,
                        hls_fin_calculator_hd nh
                    WHERE
                        c.contract_id     = r.change_req_id AND
                        c.calc_session_id = nh.calc_session_id
                    ) irr_per_new,
                    (SELECT
                        e.description
                    FROM
                        HLS_FIN_CALC_TYPE e
                    WHERE
                        e.calc_type = ch.calc_type
                    ) calc_type_n,
                    TO_CHAR(r.req_date,'yyyy-mm-dd') req_date,
                    r.description,
                    DECODE(r.change_bp, 'Y', '变更商业伙伴 ', '')
                    || DECODE(r.change_lease_item, 'Y', '变更租赁物 ', '')
                    || DECODE(r.change_quotation, 'Y', '变更报价 ', '') change_things
                FROM
                    con_contract_v t,
                    con_contract_change_req r,
                    hls_fin_calculator_hd ch
                WHERE
                    r.change_req_id     = ${@document_id} AND
                    r.document_category = ${@document_category} AND
                    t.calc_session_id   = ch.calc_session_id AND
                    t.contract_id       = r.contract_id
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
