<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                Select t1.*
                From (Select al.head_id,
                al.line_id,
                al.contract_id,
                t.contract_number,
                t.bp_id_tenant,
                bp.bp_name,
                  (Select nvl(b.extra_nam, b.bp_name)
                  From hls_bp_master b
                 Where b.bp_id = t.bp_id_agent_level1) agent_name,
                al.currency_code,
                al.bank_account_id,
                al.bank_account_num,
                al.bank_account_name,
                al.due_amount,
                al.received_amount,
                al.write_off_amount,
                al.write_off_error,
                al.withhold_status,
                al.withhold_note,
                (Select v.code_value_name
                From sys_code_values_v v
                Where v.code = 'DS_ABC_BACK_STATUS'
                And v.code_enabled_flag = 'Y'
                And v.code_value_enabled_flag = 'Y'
                And v.code_value = al.withhold_status) withhold_status_desc,
                al.deal_flag,
                decode(al.deal_flag,'Y','已处理','N','未处理') deal_flag_n,
                al.deal_msg
                From ds_abc_interface_ln   al,
                con_contract          t,
                hls_bp_master         bp
                Where al.contract_id = t.contract_id
                And t.bp_id_tenant = bp.bp_id(+)
                And al.head_id = ${/parameter/@head_id}
               ) t1
                #WHERE_CLAUSE#
                Order By decode(t1.deal_flag, 'N', 1, 2), t1.contract_number

            ]]></bm:query-sql>
        </bm:operation>

        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                 BEGIN
                         update ds_abc_interface_temp
                          set  withhold_amount = ${@withhold_amount}
                        where  record_id = ${@record_id};
                 END;
             ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="head_id"/>
        <bm:field name="line_id"/>
        <bm:field name="contract_id"/>
        <bm:field name="contract_number"/>
        <bm:field name="due_amount"/>
        <bm:field name="bp_id_tenant"/>
        <bm:field name="bp_name"/>
        <bm:field name="currency_code"/>
        <bm:field name="bank_account_id"/>
        <bm:field name="bank_account_num"/>
        <bm:field name="bank_account_name"/>
        <bm:field name="write_off_amount"/>
        <bm:field name="write_off_error"/>
        <bm:field name="withhold_status"/>
        <bm:field name="withhold_status_desc"/>
        <bm:field name="withhold_note"/>
        <bm:field name="received_amount"/>
        <bm:field name="deal_flag"/>
        <bm:field name="deal_flag_n"/>
        <bm:field name="deal_msg"/>
        <bm:field name="agent_name"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="contract_number"
                        queryExpression="t1.contract_number like upper(&apos;%&apos;||${@contract_number}||&apos;%&apos;)"/>
        <bm:query-field field="bp_id_tenant" queryOperator="="/>
        <bm:query-field field="withhold_status" queryOperator="="/>
        <bm:query-field field="deal_flag" queryOperator="="/>
    </bm:query-fields>
</bm:model>
