<?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
                    t1.*
                FROM
                    (SELECT
                        ha.record_id,
                        ha.session_id,
                        ha.contract_id,
                        t.contract_number,
                        t.bp_id_tenant,
                        (SELECT bp.bp_name FROM hls_bp_master bp WHERE bp.bp_id = t.bp_id_tenant
                        ) bp_name,
                        ha.cashflow_id,
                        ccc.times,
                        ccc.cf_item,
                        (SELECT i.description FROM hls_cashflow_item i WHERE i.cf_item = ccc.cf_item
                        ) cf_item_n,
                        ha.due_amount,   --当期应收金额
                        ha.withhold_amount,  --本次扣款金额（人工干预修改）
                        TO_CHAR(ccc.due_date, 'yyyy-mm-dd') due_date,
                        ha.currency_code,
                        ha.bank_account_id,
                        ha.bank_account_num,
                        ha.bank_account_name,
                        ha.error_message
                    FROM
                        ds_abc_interface_temp ha,
                        con_contract t,
                        con_contract_cashflow ccc
                    WHERE
                        ha.contract_id = t.contract_id AND
                        ha.cashflow_id = ccc.cashflow_id AND
                        ha.session_id  = ${/session/@session_id}                        
                    ) t1 #WHERE_CLAUSE#
                ORDER BY
                    DECODE(t1.error_message, NULL, 2, 1),
                    t1.contract_number,
                    t1.times
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
                 BEGIN
                     hls_ebank_abc_pub_pkg.init_abc_inteface_temp(p_session_id =>${/session/@session_id},
                     											  p_create_date => sysdate, 
                     											  p_create_date_to => sysdate, 
                     											  p_user_id => ${/session/@user_id});
                 END;
             ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                 BEGIN
                     hls_ebank_abc_pub_pkg.init_abc_inteface_temp(p_session_id =>${/session/@session_id},
                     											  p_create_date => null,
                     											  p_create_date_to =>to_date(${@create_date_to},'yyyy-mm-dd'),
                     											  p_user_id => ${/session/@user_id});
                 END;
             ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
                 BEGIN
                     hls_ebank_abc_pub_pkg.delete_abc_inteface_temp(p_record_id =>${@record_id});
                 END;
             ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
