<?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
                    cc.contract_id,
                    (SELECT
                        pp.virtual_con_number
                    FROM
                        prj_project pp
                    WHERE
                        pp.project_id = cc.project_id
                    ) virtual_con_number,
                    cc.contract_number,
                    cc.contract_name,
                    cc.finance_amount,
                    cc.inception_of_lease,
                    hd.hd_id
                FROM
                    con_contract cc,
                    hn_con_payment_con_hd hd
                WHERE
                    cc.data_class  = 'NORMAL' AND
                    cc.contract_id = hd.contract_id(+) AND
                    nvl(hd.data_class,'NORMAL') = 'NORMAL' and
                    cc.project_id  =
                    (SELECT
                        cct.project_id
                    FROM
                        con_contract cct
                    WHERE
                        cct.contract_id = ${@contract_id}
                    ) AND
                    cc.contract_id <> ${@contract_id}
                    AND CC.CONTRACT_STATUS NOT IN ('CANCEL')
                    order by cc.contract_number
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
