<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1"
          baseTable="con_contract_et_temp">
    <bm:fields>
        <bm:field name="record_id"/>
        <bm:field name="contract_number"/>
        <bm:field name="cert_recipient01"/>
        <bm:field name="cert_tracknum01"/>
        <bm:field name="cert_send_date01"/>
        <bm:field name="trans_recipient01"/>
        <bm:field name="trans_tracknum01"/>
        <bm:field name="trans_send_date01"/>
        <bm:field name="err_message"/>
        <bm:field name="note"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="record_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field name="batch_id" queryExpression="t1.batch_id=${@batch_id}"/>
    </bm:query-fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                Select t1.record_id,
                t1.contract_number,
                t1.cert_recipient01,
                t1.cert_tracknum01,
                to_char(t1.cert_send_date01, 'yyyy-mm-dd') cert_send_date01,
                t1.trans_recipient01,
                t1.trans_tracknum01,
                to_char(t1.trans_send_date01, 'yyyy-mm-dd') trans_send_date01,
                t1.note,
                t1.err_message
                From con_contract_et_temp t1
                Where t1.batch_id = ${@batch_id}
                Order By decode(t1.err_message, Null, 2, 1)
         ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
            begin
                contract_et_document_pkg.save_data
                    (
                        p_batch_id=>${@batch_id},
                        p_user_id=>${/session/@user_id},
                        p_company_id =>${/session/@company_id}
                    );
             end;
         ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
