<?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
                    ccc.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_batch pnb
                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
                    ccc.contract_id     = pnb.contract_id AND
                    ccc.times           =
                    (SELECT
                        times
                    FROM
                        con_contract_cashflow ccc
                    WHERE
                        ccc.cashflow_id = pnb.cashflow_id
                    ) AND
                    pnb.session_id=${/session/@session_id}
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
