<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: feng  
    $Date: 2013-9-11 下午15:13:20  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
            	begin
                    con_contract_closed_pkg.contract_use_seal_save(p_con_finish_batch_id         => ${/parameter/@con_finish_batch_id},
                                                                   p_user_id             => ${/session/@user_id});

            		con_contract_closed_pkg.terminate_contract(
            			p_con_finish_batch_id  =>${/parameter/@con_finish_batch_id},
            			p_user_id       =>${/session/@user_id},
            			p_company_id => ${/session/@company_id}
            		);
            	end;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:parameters>
                <bm:parameter name="con_finish_batch_id" output="true" outputPath="@con_finish_batch_id"/>
            </bm:parameters>
            <bm:update-sql>
                <![CDATA[
        declare
        v_con_finish_batch_id  contract_finish_batch.con_finish_batch_id%TYPE := contract_finish_batch_s.nextval;
        begin
         ${@con_finish_batch_id} := v_con_finish_batch_id;
         insert into contract_finish_batch
                         (con_finish_batch_id,
                          instance_id,
                          wfl_status,
                          created_by,
                          creation_date,
                          last_updated_by,
                          last_update_date)
                          values
                          (v_con_finish_batch_id,
                           null,
                           null,
                           ${/session/@user_id},
                           sysdate,
                           ${/session/@user_id},
                           sysdate
                          );

        end;
            ]]>
            </bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql>
                <![CDATA[
        update con_contract cc
        set
        cc.con_finish_batch_id = ${/parameter/@con_finish_batch_id},
        cc.last_updated_by = ${/session/@user_id},
        cc.last_update_date = sysdate
        where cc.contract_id = ${@contract_id}
            ]]>
            </bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
