<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: LR  
    $Date: 2013-8-23 下午04:18:57  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
                update  hls_fin_calculator_hd  hd set hd.other_payment2=${@other_payment2} where hd.calc_session_id=${@calc_session_id}
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    pqv.contract_seq,
                    pqv.version,
                    hdv.ref_document_type contract_type,
                    hdv.ref_document_type_desc contract_type_desc,
                    pbv.bp_id,
                    pbv.contract_seq bp_contract_seq,
                    pbv.bp_code,
                    pbv.bp_name,
                    pqv.document_id project_id,
                    hfh.billing_method
                FROM
                    prj_quotation_v pqv,  
                    hls_fin_calculator_hd hfh,
                    prj_project_bp_v pbv,
                    hls_document_type_v hdv,
                    prj_project p #WHERE_CLAUSE#
                ORDER BY
                    pqv.contract_seq
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
        		begin
				  con_contract_pkg.save_contract_from_project(p_project_id        => ${@project_id},
				                                              p_contract_seq      => ${@contract_seq},
				                                              p_bp_contract_seq   => ${@bp_contract_seq},
				                                              p_con_document_type => ${@contract_type},
				                                              p_con_contract_name => ${@contract_name},
				                                              p_billing_method    => ${@billing_method},
				                                              p_contract_id       => ${@contract_id},
				                                              p_contract_number   => ${@contract_number},
				                                              p_user_id           => ${/session/@user_id});

				  prj_project_pkg.update_prj_project_status(p_project_id =>${@project_id}, p_user_id =>${/session/@user_id});
				end;
        	]]></bm:update-sql>
            <bm:parameters>
                <bm:parameter name="contract_id" output="true" outputPath="@contract_id"/>
                <bm:parameter name="contract_number" output="true" outputPath="@contract_number"/>
            </bm:parameters>
        </bm:operation>
    </bm:operations>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query"
                        expression="pqv.document_category = &apos;PROJECT&apos; AND hfh.calc_session_id   = pqv.calc_session_id AND pbv.project_id(+)=pqv.document_id AND  pbv.bp_category(+) =&apos;TENANT&apos; AND pbv.contract_seq(+)=pqv.contract_seq and pqv.document_id = ${@project_id} and pqv.internal_confirm=&apos;Y&apos; and pqv.external_confirm=&apos;Y&apos; and pqv.enabled_flag=&apos;Y&apos; AND p.project_id = pqv.document_id and hdv.document_type(+) = p.document_type and nvl(pqv.create_contract_flag,&apos;N&apos;)=&apos;N&apos;"/>
    </bm:data-filters>
</bm:model>
