<?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 * from (
                SELECT
                    ccc.contract_id contract_id,
                    ccc.times times,
                    TO_CHAR(ccc.fin_income_date,'yyyy-mm-dd') fin_income_date,
                    content_fun_pkg.due_amount_convert_money(ccc.outstanding_prin_tax_incld) outstanding_prin_tax_incld,
                    content_fun_pkg.due_amount_convert_money(ccc.net_principal) net_principal,
                    content_fun_pkg.NO2_LIXI(CCC.TIMES,cc.contract_id) INTEREST ,
                    content_fun_pkg.NO2_ZUJIN(CCC.TIMES,cc.contract_id) net_amount,
                    content_fun_pkg.NO2_ZENGZHISHUI(CCC.TIMES,cc.contract_id) vat_amount,
                    content_fun_pkg.due_amount_convert_money(ccc.due_amount) 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
                    ) t1 #WHERE_CLAUSE#
                ORDER BY
                    t1.TIMES ASC
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="contract_id"/>
        <bm:field name="times"/>
        <bm:field name="fin_income_date"/>
        <bm:field name="outstanding_prin_tax_incld"/>
        <bm:field name="net_principal"/>
        <bm:field name="interest"/>
        <bm:field name="net_amount"/>
        <bm:field name="vat_amount"/>
        <bm:field name="due_amount"/>
    </bm:fields>
    <bm:query-fields><![CDATA[
    ]]></bm:query-fields>
    <bm:data-filters><![CDATA[
    ]]></bm:data-filters>
    <bm:features>
        <s:bm-script><![CDATA[
        ]]></s:bm-script>
    </bm:features>
</bm:model>
