<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: 38823
    $Date: 2023-12-25
    $Revision: 1
    $Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="insert">
            <bm:parameters>
                <bm:parameter name="payment_batch_id" output="true" outputPath="@payment_batch_id"/>
            </bm:parameters>
            <bm:update-sql><![CDATA[
        declare
        v_payment_batch_id  hl_cm_payment_journal_batch.payment_batch_id%TYPE := hl_cm_payment_journal_batch_s.nextval;
        begin
         ${@payment_batch_id} := v_payment_batch_id;
         insert into hl_cm_payment_journal_batch
                         (payment_batch_id,
                          instance_id,
                          wfl_status,
                          created_by,
                          creation_date,
                          last_updated_by,
                          last_update_date)
                          values
                          (v_payment_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 hl_cm_payment_journal hc
   set hc.payment_batch_id =${/parameter/@payment_batch_id},
   hc.last_updated_by = ${/session/@user_id},
   hc.last_update_date = sysdate
   where hc.payment_journal_id = ${@payment_journal_id}
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
            begin
              HL_CM_PAYMENT_JOURNAL_PKG.payment_wfl_start(p_payment_batch_id =>${/parameter/@payment_batch_id},
                                                          p_user_id =>${/session/@user_id});
            end;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
