<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2013-9-5 下午05:04:37  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    t1.*
                FROM
                    (SELECT
                        cc.contract_id,
                        content_fun_pkg.DUE_AMOUNT_CONVERT_MONEY(SUM(ccc.outstanding_prin_tax_incld)) outstanding_prin_tax_incld,
                        content_fun_pkg.DUE_AMOUNT_CONVERT_MONEY(SUM(CCC.NET_PRINCIPAL)) SUM_NET_PRINCIPAL,
                        content_fun_pkg.DUE_AMOUNT_CONVERT_MONEY(SUM(CONTENT_FUN_PKG.NO2_LIXI_SUM(CCC.TIMES, CC.CONTRACT_ID))) SUM_INTEREST,
                        content_fun_pkg.DUE_AMOUNT_CONVERT_MONEY(SUM(CONTENT_FUN_PKG.NO2_ZUJIN_SUM(CCC.TIMES, CC.CONTRACT_ID))) SUM_NET_AMOUNT,
                        content_fun_pkg.DUE_AMOUNT_CONVERT_MONEY(SUM(CONTENT_FUN_PKG.NO2_ZENGZHISHUI_SUM(CCC.TIMES, CC.CONTRACT_ID))) SUM_VAT_AMOUNT,
                        content_fun_pkg.DUE_AMOUNT_CONVERT_MONEY(SUM(CCC.DUE_AMOUNT)) SUM_DUE_AMOUNT
                    FROM
                        con_contract cc,
                        con_contract_cashflow ccc
                    WHERE
                        CCC.CF_ITEM      = 1 AND
                        CCC.TIMES       <> 0 AND
                        CCC.CF_STATUS    = 'RELEASE' AND
                        CCC.CF_DIRECTION = 'INFLOW' AND
                        CCC.CF_TYPE      = 1 AND
                        cc.contract_id   = ccc.contract_id
                        group by cc.contract_id
                    ) t1 #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="outstanding_prin_tax_incld"/>
        <bm:field name="sum_net_principal"/>
        <bm:field name="sum_interest"/>
        <bm:field name="sum_net_amount"/>
        <bm:field name="sum_vat_amount"/>
        <bm:field name="sum_due_amount"/>
    </bm:fields>
    <bm:query-fields>
        <!-- <bm:query-field name="contract_id" queryExpression="t1.contract_id=${@contract_id}"/> -->
        <!-- <bm:query-field name="contract_id" queryExpression="cc.contract_id=11"/> --><![CDATA[
        
        
        
        
    ]]></bm:query-fields>
    <bm:data-filters>
        <!-- <bm:data-filter enforceOperations="query" expression="t1.contract_id=${@contract_id}"  /> --><![CDATA[
    	
]]></bm:data-filters>
    <bm:features>
        <s:bm-script><![CDATA[
        	
        
        	
        ]]></s:bm-script>
    </bm:features>
</bm:model>
