<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
                BEGIN
                    hn_job_pkg.hn_insert_payment_notice_batch;
                END;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
                BEGIN
                    hn_job_pkg.hn_csh_payment_send_email;
                END;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    *
                FROM
                    (SELECT
                        hd.batch_id,
                        ln.contract_id,
                        ln.cashflow_id,
                        (SELECT
                            cc.contract_number
                        FROM
                            con_contract cc
                        WHERE
                            cc.contract_id = ln.contract_id
                        ) contract_number,
                        (SELECT
                            ccc.times
                        FROM
                            con_contract_cashflow ccc
                        WHERE
                            ccc.cashflow_id = ln.cashflow_id
                        ) times
                    FROM
                        hn_payment_notice_hd hd,
                        hn_payment_notice_ln ln
                    WHERE
                        hd.batch_id     = ln.batch_id AND
                        hd.enabled_flag = 'Y' AND
                        ln.print_flag   ='N'
                    ORDER BY
                        ln.contract_id
                    ) t1
                WHERE
                    rownum = 1
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                BEGIN
                    hn_job_pkg.update_payment_notice_batch(p_contract_id=>${@contract_id},
                                                           p_cashflow_id=>${@cashflow_id});
                END;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
