<?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 cbail.batch_hd_id,
			       cbail.batch_ln_id,
			       ccv.contract_id,
			       ccc.times,--期数
			       ccc.due_date,
			       TO_CHAR(ccc.principal, 'FM999,999,999,990.00') principal,
			       TO_CHAR(ccc.interest, 'FM999,999,999,990.00') interest,
			       NVL((SELECT TO_CHAR(cct.due_amount, 'FM999,999,999,990.00')
			             FROM con_contract_cashflow cct
			            WHERE cct.contract_id = ccc.contract_id
			              AND cct.cf_item = 3
			              AND cct.times = ccc.times),
			           0) lease_charge,
			       TO_CHAR(ccc.principal + ccc.interest +
			               nvl((SELECT cct.due_amount
			                     FROM con_contract_cashflow cct
			                    WHERE cct.contract_id = ccc.contract_id
			                      AND cct.cf_item = 3
			                      AND cct.times = ccc.times),
			                   0),
			               'FM999,999,999,990.00') sum_amount
			  FROM con_batch_adjust_interest_ln cbail, con_contract_v ccv,con_contract_cashflow ccc
			 WHERE cbail.contract_id = ccv.contract_id and ccc.contract_id = ccv.contract_id AND ccc.cf_item = 1 
			 	   and cbail.batch_hd_id = ${@batch_hd_id} order by ccc.times
			 	]]></bm:query-sql>
            <bm:parameters>
                <bm:parameter name="batch_hd_id"/>
            </bm:parameters>
        </bm:operation>
    </bm:operations>
</bm:model>
