<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: lgc5900  
    $Date: 2015年12月29日 上午9:25:20  
    $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
                    TO_CHAR(SUM(NVL(cw.principal, 0)), 'FM999,999,999,990.00') sum_principal,
                    TO_CHAR(SUM(NVL(cw.interest, 0)), 'FM999,999,999,990.00') sum_interest,
                    --不含税租金
                    TO_CHAR(SUM(NVL(cw.net_due_amount, 0)), 'FM999,999,999,990.00') sum_net_rental,
                    TO_CHAR(SUM(NVL(cw.vat_due_amount, 0)), 'FM999,999,999,990.00') sum_vat_rental,
                    --租金总和
                    TO_CHAR(SUM(NVL(cw.due_amount, 0)), 'FM999,999,999,990.00') sum_rental,
                    --本金余额总和
                    TO_CHAR(SUM(NVL(cw.outstanding_rental_tax_incld, 0)), 'FM999,999,999,990.00') sum_tax_incld,
                    --增值税总和
                    TO_CHAR(SUM(NVL(cw.ln_user_col_n02, 0)), 'FM999,999,999,990.00') sum_ln_n02
                FROM
                    con_contract_cashflow cw
                WHERE
                    cw.times       > 0 AND
                    cw.cf_item     = 1 AND
                    cw.contract_id = ${@contract_id}
                ORDER BY
                    cw.times
            ]]></bm:query-sql>
            <bm:parameters>
                <bm:parameter name="contract_id"/>
            </bm:parameters>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="sum_principal" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SUM_PRINCIPAL"/>
        <bm:field name="sum_interest" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SUM_INTEREST"/>
        <bm:field name="sum_net_rental" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SUM_NET_RENTAL"/>
        <bm:field name="sum_vat_rental" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SUM_VAT_RENTAL"/>
        <bm:field name="sum_rental" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SUM_RENTAL"/>
        <bm:field name="sum_tax_incld" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SUM_TAX_INCLD"/>
        <bm:field name="sum_ln_n02" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SUM_LN_N02"/>
    </bm:fields>
</bm:model>
