<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang 
    $Date: 2015-1-27 下午03:46:43  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                DECLARE
                    v_payment_req_number VARCHAR2(200);
                BEGIN
                    IF ${@payment_req_number} IS NULL THEN
                        v_payment_req_number  :=csh_payment_req_pkg.get_payment_req_number( p_document_type =>${@document_type}, p_transaction_date =>${@req_date}, p_company_id =>NVL(${@company_id},${/session/@company_id}), p_user_id =>${/session/@user_id}, p_document_category =>${@document_category});
                        csh_payment_req_pkg.update_payment_req_number(p_payment_req_id=>${@payment_req_id},p_payment_req_number=>v_payment_req_number);
                        csh_payment_req_pkg.create_cdd(p_payment_req_id      =>${@payment_req_id},
						                               p_user_id          =>${/session/@user_id},
						                               p_cdd_list_id      =>${@cdd_list_id});
                        ${@payment_req_number}:= v_payment_req_number;
                    END IF;
                     aut_document_authority_pkg.insert_trx_user_authority
				       (p_company_id    => nvl(${@company_id},${/session/@company_id}),
				        p_owner_user_id => nvl(${@owner_user_id},${/session/@user_id}),
				        p_trx_category  => 'PAYMENT_REQ',
				        p_trx_id        => ${@payment_req_id},
				        p_start_date    => trunc(sysdate),
				        p_end_date      => to_date('30000101','yyyymmdd'),
				        p_user_id       => ${/session/@user_id});
                END;
            ]]></bm:update-sql>
            <bm:parameters>
                <bm:parameter name="payment_req_number" dataType="java.lang.String" input="true" output="true"
                              outputPath="@payment_req_number"/>
                <bm:parameter name="cdd_list_id" dataType="java.lang.Long" input="true" output="true" outputPath="@cdd_list_id"/>
            </bm:parameters>
        </bm:operation>
    </bm:operations>
</bm:model>
