<?xml version="1.0" encoding="UTF-8"?>

<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
           begin
           margin_check_req_pkg.margin_check_submit(
           p_user_id =>${/session/@user_id},
           p_margin_check_id => ${@margin_check_id}
           );
           end;
           ]]></bm:update-sql>
        </bm:operation>

        <bm:operation name="insert">
            <bm:parameters>
                <bm:parameter name="margin_check_id" dataType="java.lang.Long" input="false" output="true"/>
            </bm:parameters>
            <bm:update-sql><![CDATA[
        		begin
				  margin_check_req_pkg.margin_check_save(
				                 p_sql_type     => 'INSERT',
				                 p_user_id     =>${/session/@user_id},
                                 p_margin_check_id => ${@margin_check_id},
                                 p_mar_after_status => ${@mar_after_status},
                                 p_mar_before_status =>${@mar_before_status}
                                 );
				end;
]]></bm:update-sql>
        </bm:operation>

        <bm:operation name="query">
            <bm:query-sql><![CDATA[
select Mar_After_Status as Mar_Status, mar_after_status_n
  from (select t.mar_after_status,
               (SELECT Code_Value_Name
                  FROM Sys_Code_Values_v sv
                 where sv.code = 'MARGIN_CHECK_STATUS'
                   and sv.code_value = t.mar_after_status) mar_after_status_n
          from Csh_Margin_Check t
         where t.wfl_status = 'APPROVED'
         order by t.creation_date desc)
 where Rownum = 1
]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>

