<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: whumeister  
    $Date: 2015-10-13 上午10:35:39  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    rownum row_num,
                    c.contract_id,
                    c.bp_id_tenant,
                    p.bp_id,
                    c.contract_number,      --合同编号
                    c.bp_id_tenant_n,       --承租人名称
                    p.bp_name,              --推荐厂商
                    t.transaction_date,     --垫付日期
                    cf.write_off_due_amount,--垫付金额
                    cf.cashflow_id
                FROM
                    con_contract_lv c,
                    con_contract_cashflow cc,
                     con_contract_bp_lv p,
                    csh_write_off cf,
                    csh_transaction t
                WHERE
                    p.contract_id         = c.contract_id AND
                    cc.cashflow_id        =cf.cashflow_id AND
                    cc.cf_direction       ='INFLOW' AND
                    p.bp_category         = 'VENDER' AND
                    c.business_type      <>'LEASEBACK' AND
                    c.data_class          = 'NORMAL' AND
                    cf.contract_id        = c.contract_id AND
                    cf.csh_transaction_id =t.transaction_id AND
                    t.bp_id               = p.bp_id AND
                    cf.reversed_flag      = 'N' AND
                    t.reversed_flag       = 'N' AND
                    p.contract_id         =${/parameter/@contract_id} AND
                    p.bp_id               =${/parameter/@bp_id}
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="row_num" databaseType="NUMBER" datatype="java.lang.Long" physicalName="ROW_NUM"/>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" required="true"/>
        <bm:field name="bp_id_tenant" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID_TENANT" required="true"/>
        <bm:field name="bp_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NUMBER" required="true"/>
        <bm:field name="bp_id_tenant_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_ID_TENANT_N"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_NAME"/>
        <bm:field name="transaction_date" databaseType="DATE" datatype="java.util.Date" physicalName="TRANSACTION_DATE" required="true"/>
        <bm:field name="write_off_due_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="WRITE_OFF_DUE_AMOUNT"/>
        <bm:field name="cashflow_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CASHFLOW_ID"/>
    </bm:fields>
</bm:model>
