<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhuxianfei 
    $Date: 2018/7/26 14:11
    $Revision: 1.0 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    l.invoice_line_id,
                    l.invoice_code,
                    l.invoice_number,
                    l.invoice_date,
                    l.total_amount,
                    l.invoice_status,
                    (SELECT
                        v.code_value_name
                    FROM
                        sys_code_values_v v
                    WHERE
                        v.code       = 'ACP517_INVOICE_STATUS' AND
                        v.code_value = l.invoice_status
                    ) invoice_status_n,
                    l.invoice_date,
                    l.reversed_date,
                    l.reversed_amount,
                    l.contract_id,
                    l.contract_id_n,
                    l.agent_name
                FROM
                    acp_invoice_ln_lv l
                WHERE
                    l.invoice_line_id = ${@invoice_line_id}
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
            begin
                acp_invoice_pkg.invoice_reversed(p_invoice_line_id   => ${@invoice_line_id},
                                                 p_reversed_amount => ${@reversed_amount},
                                                 p_reversed_date   => to_date(substr(${@reversed_date}, 1, 10), 'yyyy-mm-dd'),
                                                 p_user_id         => ${/session/@user_id});
             end;
         ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
