<?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 a.contract_id,a.cashflow_id,b.description as cf_item,
       a.due_date,
       a.times,
       a.due_amount - nvl(a.received_amount,0) - (select nvl(sum(ld.amount),0) from CSH_PAYMENT_REQ_LN_DDCT ld where ld.ref_doc_line_id = a.cashflow_id) as un_due_amount,
       a.principal - nvl(a.received_principal,0)-(select nvl(sum(ld.principal),0) from CSH_PAYMENT_REQ_LN_DDCT ld where ld.ref_doc_line_id = a.cashflow_id) as un_principal,
       a.interest - nvl(a.received_interest,0) - (select nvl(sum(ld.interest),0) from CSH_PAYMENT_REQ_LN_DDCT ld where ld.ref_doc_line_id = a.cashflow_id) as un_interest
  from con_contract_cashflow a,
       hls_cashflow_item b
       #WHERE_CLAUSE#
       #ORDER_BY_CLAUSE#
       ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="a.contract_id = ${@contract_id}    and (a.times = 0 or (a.times = 1 and a.cf_item = 1))    and a.cf_direction = &apos;INFLOW&apos;    and a.cf_status = &apos;RELEASE&apos;    and a.due_amount &gt; nvl(a.received_amount,0)    and a.cf_item = b.cf_item"/>
    </bm:data-filters>
    <bm:fields>
        <bm:field name="contract_id"/>
        <bm:field name="cashflow_id"/>
        <bm:field name="cf_item" forDisplay="true" forQuery="true" prompt="HLS.CF_ITEM_DESC"/>
        <bm:field name="times" forDisplay="true" forQuery="true" prompt="HLS.TIMES"/>
        <bm:field name="due_date" databaseType="DATE" datatype="java.util.Date" forDisplay="true" prompt="CSH710.DUE_DATE"/>
        <bm:field name="un_due_amount" forDisplay="true" prompt="CSH513.UNRECEIVED_AMOUNT"/>
        <bm:field name="un_principal" forDisplay="true" prompt="CSH513.UNRECEIVED_PRINCIPAL"/>
        <bm:field name="un_interest" forDisplay="true" prompt="CSH513.UNRECEIVED_INTEREST"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="cf_item" queryExpression="b.description like ${@cf_item}"/>
        <bm:query-field name="times" queryExpression="a.time=${@times}"/>
    </bm:query-fields>
</bm:model>
