<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangwei  
    $Date: 2016-2-26 上午10:22:54  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="tre.TRE1001.sdic_fin_plan_year_query" rootPath="plan_year_path"/>
        <a:model-query fetchAll="true" model="tre.TRE1001.sdic_fin_plan_month_query" rootPath="plan_month_path"/>
    </a:init-procedure>
    <a:view>
        <script type="text/javascript"><![CDATA[
            function sdic130_query() {
                $('month_end_unearned_income_ds').query();
            }
            
            function sdic130_export() {
                $('month_end_unearned_income_ds_id')._export();
            }
            
            function sum_unearned_finance_income(datas, name) {
                var sum = 0;
                for (var i = 0;i < datas.length;i++) {
                    var r = datas[i];
                    var d = r.get(name);
                    var n = parseFloat(d);
                    if (!isNaN(n)) {
                        sum += n;
                    }
                }
                return '<font color="red">' + Leaf.formatNumber(sum, 2) + '</font>';
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="contract_type_ds">
                <a:datas>
                    <a:record name="租赁" value="LEASE"/>
                    <a:record name="融资" value="LOAN"/>
                </a:datas>
            </a:dataSet>
            <a:dataSet id="plan_year_ds" loadData="true">
                <a:datas dataSource="/model/plan_year_path"/>
            </a:dataSet>
            <a:dataSet id="plan_month_ds" loadData="true">
                <a:datas dataSource="/model/plan_month_path"/>
            </a:dataSet>
            <a:dataSet id="for_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="contract_type_desc" displayField="name" options="contract_type_ds" required="true" returnField="contract_type" valueField="value"/>
                    <a:field name="contract_type"/>
                    <a:field name="document_number"/>
                    <a:field name="document_name"/>
                    <a:field name="bp_name"/>
                    <!--     <a:field name="period_name" lovGridHeight="330" lovHeight="500" lovService="sdic.SDIC130.gld_periods_for_lov" lovWidth="500">
                        <a:mapping>
                            <a:map from="internal_period_num" to="internal_period_num"/>
                            <a:map from="period_name" to="period_name"/>
                        </a:mapping>
                    </a:field> -->
                    <a:field name="plan_year_n" displayField="code_value_name" options="plan_year_ds" returnField="plan_year" valueField="code_value"/>
                    <a:field name="plan_month_n" displayField="code_value_name" options="plan_month_ds" returnField="plan_month" valueField="code_value"/>
                    <a:field name="internal_period_num"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="month_end_unearned_income_ds" autoPageSize="true" model="sdic.SDIC130.month_end_unearned_income" queryDataSet="for_query_ds">
                <a:fields>
                    <a:field name="finance_income_recognized" checkedValue="Y" readOnly="true" uncheckedValue="N"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="sdic130_query" text="查询"/>
                <a:gridButton click="sdic130_export" text="导出"/>
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="120" marginWidth="50" title="查询条件">
                <a:comboBox name="contract_type_desc" bindTarget="for_query_ds" prompt="单据类型"/>
                <a:textField name="document_number" bindTarget="for_query_ds" prompt="单据编号"/>
                <a:textField name="document_name" bindTarget="for_query_ds" prompt="单据名称"/>
                <a:textField name="bp_name" bindTarget="for_query_ds" prompt="商业伙伴名称"/>
                <!--  <a:lov name="period_name" bindTarget="for_query_ds" prompt="期间月份"/> -->
                <a:comboBox name="plan_year_n" bindTarget="for_query_ds" prompt="年份"/>
                <a:comboBox name="plan_month_n" bindTarget="for_query_ds" prompt="月份"/>
            </a:form>
            <a:grid id="month_end_unearned_income_ds_id" bindTarget="month_end_unearned_income_ds" marginHeight="200" marginWidth="50" navBar="true">
                <a:columns>
                    <a:column name="contract_type_desc" align="center" prompt="单据类型" width="80"/>
                    <a:column name="document_number" prompt="单据编号" width="210"/>
                    <a:column name="original_con_number" prompt="原始合同号" width="150"/>
                    <a:column name="document_name" prompt="单据名称" width="210"/>
                    <a:column name="bp_name" prompt="商业伙伴名称" width="210"/>
                    <a:column name="lease_item_amount" prompt="合同金额" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="month_end_principal" align="right" prompt="月末剩余本金" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="provision_days" align="right" prompt="月末计提天数" width="120"/>
                    <a:column name="rate_desc" prompt="利率" width="90"/>
                    <a:column name="lease_term" align="center" prompt="期限" width="60"/>
                    <a:column name="period_name" align="center" prompt="期间月份" width="80"/>
                    <a:column name="finance_income" align="right" footerRenderer="sum_unearned_finance_income" prompt="计提金额" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="net_finance_income" align="right" footerRenderer="sum_unearned_finance_income" prompt="不含税计提金额" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="vat_finance_income" align="right" footerRenderer="sum_unearned_finance_income" prompt="计提金额税额" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="finance_income_recognized" align="center" editor="check_box_id" prompt="收入确认"/>
                </a:columns>
                <a:editors>
                    <a:checkBox id="check_box_id"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
