<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: chenlingfeng
    $Date: 2018-12-31 18:17:30
    $Revision: 1.0
    $Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:s="leaf.plugin.script" defaultOrderBy="t1.due_date desc">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
	    	  select header_number,
to_char(due_date ,'yyyy-mm-dd hh24:mi:ss') due_date,
contract_id,
contract_number,
bp_id_tenant,
bp_name,
bp_id_agent_level1,
bp_agent,
bank_account_num,
bank_account_name,
apply_amount,
actual_amount,
real_amount,
status_desc,
res_msg,
to_char(res_date ,'yyyy-mm-dd hh24:mi:ss') res_date,
withhold_method,
withhold_method_desc
 from ds_Bank_withholding_info_v t1
#WHERE_CLAUSE#
#ORDER_BY_CLAUSE#

	    	]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="header_number"/>
        <bm:field name="due_date"  />
        <bm:field name="contract_id"/>
        <bm:field name="contract_number"/>
        <bm:field name="bp_id_tenant"/>
        <bm:field name="bp_name"/>
        <bm:field name="bp_id_agent_level1"/>
        <bm:field name="bp_agent"/>
        <bm:field name="bank_account_num"/>
        <bm:field name="bank_account_name"/>
        <bm:field name="apply_amount" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="actual_amount" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="real_amount" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="status_desc"/>
        <bm:field name="res_msg"/>
        <bm:field name="withhold_method"/>
        <bm:field name="withhold_method_desc"/>
        <bm:field name="res_date"  />
    </bm:fields>
    <s:bm-script><![CDATA[
            var cx = Packages.leaf.javascript.Context.getCurrentContext();
            Packages.leaf.plugin.script.engine.ScriptImportor.defineExternScript(cx, this, $ctx.getData(), "aut_authority_bm_validate.js");
        ]]></s:bm-script>
    <bm:query-fields>
        <bm:query-field name="contract_number"  queryExpression="t1.contract_number like '%'||${@contract_number}||'%'"/>
        <bm:query-field name="bp_name"  queryExpression="t1.bp_name like '%'||${@bp_name}||'%'"/>
        <bm:query-field  name="bp_agent"  queryExpression="t1.bp_agent like '%'||${@bp_agent}||'%'"/>
        <bm:query-field name="bank_account_num"  queryExpression="t1.bank_account_num like '%'||${@bank_account_num}||'%'"/>
        <bm:query-field name="bank_account_name"  queryExpression="t1.bank_account_name like '%'||${@bank_account_name}||'%'"/>
        <bm:query-field name="due_date_from"  queryExpression="trunc(t1.due_date) &gt;= to_date(${@due_date_from},'yyyy-mm-dd')"/>
        <bm:query-field name="due_date_to"  queryExpression="trunc(t1.due_date) &lt;= to_date(${@due_date_to},'yyyy-mm-dd')"/>
        <bm:query-field name="withhold_method"  queryExpression="t1.withhold_method = ${@withhold_method}"/>
        <bm:query-field name="status_desc"  queryExpression="t1.status_desc like ${@status_desc}"/>
    </bm:query-fields>
</bm:model>
