<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: ZLF  
    $Date: 2014-11-13 下午3:54:06  
    $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 * from (
            	select t1.contract_id,
       t2.contract_number,
       t1.times,
       t1.due_date,
       t1.due_amount,
       nvl(t1.received_amount,0) received_amount,
       (t1.due_amount - nvl(t1.received_amount,0)) balance_due_amount
  from con_contract_cashflow t1, con_contract t2
 where t1.contract_id = t2.contract_id
   and t2.data_class = 'NORMAL'
   and t1.cf_item=1
   and t1.cf_type=1
   and t1.write_off_flag not in ('FULL')
   and t1.cf_direction='INFLOW') t #WHERE_CLAUSE#
   
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <!-- <bm:fields >
    	<bm:field name="contract_id"  />
    	<bm:field name="contract_number"  />
    	<bm:field name="times"  />
    	<bm:field name="due_date"  />
    	<bm:field name="due_amount"  />
    	<bm:field name="received_amount"  />
    	<bm:field name="balance_due_amount"  />
    </bm:fields> -->
    <bm:fields>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="times" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="due_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="due_amount" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="received_amount" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="balance_due_amount" databaseType="NUMBER" datatype="java.lang.Long"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="contract_id" queryExpression="t.contract_id = ${@contract_id}"/>
    </bm:query-fields>
</bm:model>
