<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: 王建文  
    $Date: 2017-3-6 下午7:49:17  
    $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
                        ROUND(nvl(SUM(cc.due_amount),0),0)
                    FROM
                        con_contract_cashflow cc,
                        con_contract c
                    WHERE
                        cc.contract_id =c.contract_id AND
                        to_char(c.creation_date,'yyyy-mm')=to_char(sysdate,'yyyy-mm') 
                    ) rent_total,
                    (SELECT
                        ROUND(nvl(SUM(cc.received_amount),0),0)
                    FROM
                        con_contract_cashflow cc,
                        con_contract c
                    WHERE
                        cc.contract_id =c.contract_id AND
                        to_char(c.creation_date,'yyyy-mm')=to_char(sysdate,'yyyy-mm') 
                    ) received_rent_total,
                    ((SELECT
                        ROUND(nvl(SUM(cc.due_amount),0),0)
                    FROM
                        con_contract_cashflow cc,
                        con_contract c
                    WHERE
                        cc.contract_id =c.contract_id AND
                        to_char(c.creation_date,'yyyy-mm')=to_char(sysdate,'yyyy-mm') 
                    )-
                    (SELECT
                        ROUND(nvl(SUM(cc.received_amount),0),0)
                    FROM
                        con_contract_cashflow cc,
                        con_contract c
                    WHERE
                        cc.contract_id =c.contract_id AND
                        to_char(c.creation_date,'yyyy-mm')=to_char(sysdate,'yyyy-mm') 
                    )) unreceive_rent_total
                FROM
                    dual
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="rent_total" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RENT_TOTAL"/>
        <bm:field name="received_rent_total" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RECEIVED_RENT_TOTAL"/>
        <bm:field name="unreceive_rent_total" databaseType="NUMBER" datatype="java.lang.Long" physicalName="UNRECEIVE_RENT_TOTAL"/>
    </bm:fields>
</bm:model>
