<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hp  
    $Date: 2014-7-16 下午2:55:07  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    t1.batch_id,
                    t1.batch_line_id, t1.contract_number,
                    t1.bp_code,
                    t1.cf_item,
                    t1.payment_method_code,
                    t1.bank_account,
                    t1.times,
                    (SELECT m.description
        FROM csh_payment_method m
       WHERE m.payment_method_code = t1.payment_method_code
         AND m.enabled_flag = 'Y'
         AND m.ebanking_flag = 'Y') AS payment_method,
                    t1.receipt_date,
                    t1.receipt_amount,
                    t1.write_off_date,
                    t1.write_off_principal,
       t1.write_off_interest,
       t1.bank_slip_num,
                    t1.status,
                    DECODE(t1.status,'E','错误','S','成功') status_n,
                    t1.error_msg
                FROM
                    csh_transaction_interface_tmp t1
                 #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
        
                 begin
				  csh_transaction_interface_pkg.delete_interface(p_batch_id => ${@batch_id});
				end; 
               ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
        
                 begin
				  hls_transaction_interface_pkg.insert_transaction_interface(p_batch_id => ${@batch_id},p_user_id => ${/session/@user_id});
				end; 
               ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:parameters>
                <bm:parameter name="err_count" output="true" outputPath="/parameter/@err_count"/>
            </bm:parameters>
            <bm:update-sql><![CDATA[
                declare
                err_count number;
                begin
                csh_transaction_interface_pkg.import_interface(p_batch_id  => ${@batch_id},
                												p_header_id  => ${@header_id},
									                            p_user_id => ${/session/@user_id},
									                             p_err_count => ${@err_count});
			end;  
               ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
        
                 begin
				  csh_transaction_interface_pkg.auto_write_off(p_interface_id => ${@interface_id}, p_user_id => ${/session/@user_id});
				end; 
               ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="batch_id"/>
        <bm:field name="batch_line_id"/>
        <bm:field name="contract_number"/>
        <bm:field name="bp_code"/>
        <bm:field name="cf_item"/>
        <bm:field name="payment_method_code"/>
        <bm:field name="payment_method"/>
        <bm:field name="bank_account"/>
        <bm:field name="times"/>
        <bm:field name="receipt_date"/>
        <bm:field name="receipt_amount"/>
        <bm:field name="write_off_date"/>
        <bm:field name="write_off_principal"/>
        <bm:field name="write_off_interest"/>
        <bm:field name="bank_slip_num"/>
        <bm:field name="status"/>
        <bm:field name="status_n"/>
        <bm:field name="error_msg"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="bank_slip_num" queryOperator="like"/>
        <bm:query-field field="status_n" queryOperator="="/>
        <bm:query-field field="batch_id" queryOperator="="/>
    </bm:query-fields>
</bm:model>
