<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: WangYu  
    $Date: 2014-11-14 上午10:31:57  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[select (select to_char(ccc.due_amount - nvl(ccc.received_amount, 0))||'('||ccc.cf_direction||')'
          from con_contract_cashflow ccc
         where ccc.contract_id = t.contract_id
           and ccc.cf_type = 905 and ccc.cf_status = 'RELEASE') zero_due_amount,
        (select to_char(ccc.due_amount - nvl(ccc.received_amount, 0))
          from con_contract_cashflow ccc
         where ccc.contract_id = t.contract_id
           and ccc.cf_item = 8 and ccc.cf_status = 'RELEASE') leave_due_amount,
        (select sum(ccc.due_amount-nvl(ccc.received_amount,0)) from con_contract_cashflow ccc where ccc.contract_id=t.contract_id and ccc.cf_direction = 'INFLOW' and ccc.write_off_flag!='FULL' and ccc.cf_status = 'RELEASE')
         -(select sum(ccc.due_amount-nvl(ccc.received_amount,0)) from con_contract_cashflow ccc where ccc.contract_id=t.contract_id and ccc.cf_direction = 'OUTFLOW' and ccc.write_off_flag!='FULL' and ccc.cf_status = 'RELEASE')
        unreceived_amount,
        '承租人自行支付至车管部门'  other_fee
  from con_contract t where t.contract_id = ${/parameter/@contract_id}]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
