<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-5-6 下午3:15:48  
    $Revision: 1.0  
    $Purpose: 
-->
<ns1:model xmlns:ns1="http://www.leaf-framework.org/schema/bm" alias="t" >
    <ns1:operations>
        <ns1:operation name="query">
            <ns1:query-sql><![CDATA[
           select * from ( select
            bank_account_number , bank_account_name , bank_name
                from csh_receipt_bank_account t1
               where (t1.status = '01' or （ exists
                      (select 1
                         from con_contract cc
                        where cc.bp_id_agent_level1 = t1.vender_bp_id
                          and cc.contract_id = ${@contract_id}
                          ) and  t1.status = '02'）or exists
                      (select 1
                         from con_contract cc2, hls_bp_master hbm
                        where cc2.bp_id_tenant = hbm.bp_id
                          and cc2.contract_id = ${@contract_id}
                          and hbm.bp_class = 'NP'
                          and hbm.id_card_no = t1.id_card_number)

                          or exists
                      (select 1
                         from con_contract cc2, hls_bp_master hbm
                        where cc2.bp_id_tenant = hbm.bp_id
                          and cc2.contract_id = ${@contract_id}
                          and hbm.bp_class = 'ORG'
                          and hbm.social_code = t1.id_card_number)
                          )) t
                          #WHERE_CLAUSE#
        ]]></ns1:query-sql>
        </ns1:operation>
    </ns1:operations>
    <ns1:fields>

        <ns1:field name="bank_account_number" displayWidth="210" forDisplay="true" forQuery="true" prompt="银行账号"/>
        <ns1:field name="bank_account_name" displayWidth="210" forDisplay="true" forQuery="true" prompt="账户名"/>
    </ns1:fields>

    <ns1:query-fields>
        <ns1:query-field name="bank_account_number" queryExpression="t.bank_account_number = ${@bank_account_number}"/>
        <ns1:query-field name="bank_account_name" queryExpression="t.bank_account_name like ${@bank_account_name}"/>
    </ns1:query-fields>
</ns1:model>
