<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2013-9-9 下午01:40: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 cf.overdue_book_date,
       wo.write_off_date,
       trunc(sysdate - to_date(cf.overdue_book_date, 'yyyymmdd')) overdur_days,
       cf.overdue_amount,
       wo.write_off_due_amount,
       cf.due_amount,
       (select con.penalty_rate
          from con_contract con
         where con.contract_id = cf.contract_id) penalty_rate
  from csh_write_off wo,
       (select cf2.*
          from con_contract_cashflow cf2, con_contract_cashflow cf3
         where cf3.cashflow_id = ${@cashflow_id}
           and cf3.contract_id = cf2.contract_id
           and cf2.times = cf3.times
           and cf2.cf_item = 9
           and cf2.cf_type = 9) cf
 where wo.cashflow_id = cf.cashflow_id
   and wo.reversed_flag = 'N'
   and wo.cf_item = 9
   and wo.cf_type = 9

   ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="overdue_book_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="write_off_date"/>
        <bm:field name="overdur_days"/>
        <bm:field name="overdue_amount"/>
        <bm:field name="write_off_due_amount"/>
        <bm:field name="due_amount"/>
        <bm:field name="penalty_rate"/>
    </bm:fields>
</bm:model>
