<?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
                    c.contract_name,
                    c.employee_name,
                    c.lease_organization_n,
                    TO_CHAR(h.submit_date, 'yyyy-mm-dd') submit_date,
                    TO_CHAR(h.termination_date,'yyyy-mm-dd') termination_date,
                    (SELECT
                        cp.description
                    FROM
                        con_contract_et_profile cp
                    WHERE
                        cp.et_profile = h.et_profile
                    ) et_profile_desc,
                    TO_CHAR(h.overdue_amount, 'fm99,999,999,990.00') overdue_amount,
                    TO_CHAR(h.penalty, 'fm99,999,999,990.00') penalty,
                    TO_CHAR(h.rentals_payable, 'fm99,999,999,990.00') rentals_payable,
                    TO_CHAR(h.undue_principal, 'fm99,999,999,990.00') undue_principal,
                    TO_CHAR(h.et_interest, 'fm99,999,999,990.00') et_interest,
                    TO_CHAR(h.et_fee, 'fm99,999,999,990.00') et_fee,
                    TO_CHAR(h.residual_value, 'fm99,999,999,990.00') residual_value,
                    TO_CHAR(h.et_total_amount, 'fm99,999,999,990.00') et_total_amount
                FROM
                    con_contract_et_hd h,
                    con_contract_v c
                WHERE
                    h.contract_id       = c.contract_id AND
                    h.et_agreement_id   = ${@document_id} AND
                    h.document_category = ${@document_category}
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
