<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            SELECT * FROM (
                SELECT ccc.contract_id,
				       ccc.cashflow_id,
				       ccc.times,
				       TO_CHAR(ccc.due_date, 'YYYY-MM-DD') due_date,
				       TO_CHAR(ccc.outstanding_prin_tax_incld, 'FM999,999,999,990.00') rental_incld, --当期剩余本金(含税)
				       TO_CHAR(ccc.principal, 'FM999,999,999,990.00') principal,
				       TO_CHAR(ccc.interest, 'FM999,999,999,990.00') interest,
				       TO_CHAR(ccc.due_amount, 'FM999,999,999,990.00') rental,
				       nvl((select to_char(nvl(t.due_amount, 0), 'FM999,999,999,990.00')
				             from con_contract_cashflow t
				            where t.contract_id = ccc.contract_id
				              and t.times = ccc.times
				              and t.cf_item = 3),
				           0) lease_charge,	--手续费
				       to_char(nvl(ccc.principal, 0) + nvl(ccc.interest, 0) +
				               nvl((select t.due_amount
				                     from con_contract_cashflow t
				                    where t.contract_id = ccc.contract_id
				                      and t.times = ccc.times
				                      and t.cf_item = 3),
				                   0),
				               'FM999,999,999,990.00') sum_due_amount	--合计
				  FROM con_contract_cashflow ccc
				 WHERE ccc.cf_item = 1
				   AND ccc.cf_direction = 'INFLOW'
				   AND ccc.cf_status = 'RELEASE'
                    ) t1
                    #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
