<?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
                    ln.contract_id,
                    ccc.times,
                    ccc.cf_item_name,
                    TO_CHAR(ccc.due_date,'yyyy-mm-dd') due_date,
                    ccc.cf_item_name,
                     TO_CHAR(ccc.due_amount-nvl(ccc.received_amount,0), 'FM999,999,999,990.00') due_amount,
                    TO_CHAR(ccc.principal, 'FM999,999,999,990.00') principal,
                    TO_CHAR(ccc.interest, 'FM999,999,999,990.00') interest
                FROM
                    con_contract_cashflow_v ccc,
                    hn_payment_notice_hd hd,
                    hn_payment_notice_ln ln
                WHERE
                    ccc.cf_status = 'RELEASE' and
                    ccc.due_amount >0 and
                    ccc.cf_item        IN (1,3,12, 15,8) AND
                    ccc.write_off_flag <> 'FULL' AND
                    ln.contract_id       = ccc.contract_id AND
                    hd.batch_id          = ln.batch_id AND
                    hd.enabled_flag      = 'Y' AND
                    ccc.contract_id      = ${@contract_id} AND
                    ccc.times            =
                    (SELECT
                        times
                    FROM
                        con_contract_cashflow ccc
                    WHERE
                        ccc.cashflow_id = ${@cashflow_id}
                    )
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
