<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2013-9-9 上午10:28:05  
    $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 c.contract_number,
       cf.times,
       cf.due_date,
       nvl(cf.due_amount,0) due_amount,
       nvl(cf.received_amount,0) received_amount,
       nvl((select sum(nvl(cf2.received_amount,0))
             from con_contract_cashflow cf2
            where cf2.cf_item = 9
              and cf2.cf_type = 9
              and cf2.times = cf.times),
           0) received_fine
  from con_contract_cashflow cf, con_contract c
 where cf.cashflow_id =${@cashflow_id}
   and c.contract_id = cf.contract_id
   and c.company_id=${/session/@company_id}
   ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="contract_number"/>
        <bm:field name="times"/>
        <bm:field name="due_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="due_amount"/>
        <bm:field name="received_amount"/>
        <bm:field name="received_fine"/>
    </bm:fields>
</bm:model>
