<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: duzhihong  
    $Date: 2015-1-14 下午3:29:31  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="CON_BATCH_ADJUST_INTEREST_HD" defaultOrderBy="batch_num">
    <bm:fields>
        <bm:field name="batch_hd_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BATCH_HD_ID" prompt="CON_BATCH_ADJUST_INTEREST_HD.BATCH_HD_ID"/>
        <bm:field name="batch_num" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BATCH_NUM" prompt="CON_BATCH_ADJUST_INTEREST_HD.BATCH_NUM"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="CON_BATCH_ADJUST_INTEREST_HD.DESCRIPTION"/>
        <bm:field name="approval_status" databaseType="VARCHAR2" datatype="java.lang.String" lookupCode="CON_WFL_STATUS" lookupField="approval_status_n" physicalName="APPROVAL_STATUS" prompt="CON_BATCH_ADJUST_INTEREST_HD.APPROVAL_STATUS"/>
        <bm:field name="approval_status_n" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false" prompt="CON_BATCH_ADJUST_INTEREST_HD.APPROVAL_STATUS"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="batch_hd_id"/>
    </bm:primary-key>
    <bm:data-filters>
        <bm:data-filter name="document_category" expression="t1.document_category !=&apos;LOAN_CONTRACT&apos; or t1.document_category is null"/>
    </bm:data-filters>
    <bm:query-fields>
        <bm:query-field field="batch_hd_id" queryExpression="t1.batch_hd_id=${@batch_hd_id}"/>
    </bm:query-fields>
    <bm:features>
        <s:bm-script><![CDATA[
            var cx = Packages.leaf.javascript.Context.getCurrentContext();
            Packages.leaf.plugin.script.engine.ScriptImportor.defineExternScript(cx, this, $ctx.getData(), "aut_authority_bm_validate.js");
        ]]></s:bm-script>
    </bm:features>
    <bm:operations>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
            begin
            	con_batch_adjust_interest_pkg.batch_adjust_interest_hd_save(p_batch_hd_id =>${@batch_hd_id},
								                                            p_description =>${@description},
								                                            p_company_id  =>${/session/@company_id},
								                                            p_user_id     =>${/session/@user_id});
            end;
]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
            begin
            	con_batch_adjust_interest_pkg.batch_adjust_interest_hd_save(p_batch_hd_id =>${@batch_hd_id},
								                                            p_description =>${@description},
								                                            p_company_id  =>${/session/@company_id},
								                                            p_user_id     =>${/session/@user_id});
            end;
]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
            begin
            	delete from con_batch_adjust_interest_ln t
                 where t.batch_hd_id = ${@batch_hd_id};
                delete from con_batch_adjust_interest_hd t
                 where t.batch_hd_id = ${@batch_hd_id};

            end;
]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
            begin
            	con_batch_adjust_interest_pkg.contract_floating_rate_adj(p_batch_hd_id =>${@batch_hd_id},
								                                         p_company_id  =>${/session/@company_id},
								                                         p_user_id     =>${/session/@user_id});
            end;
]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
