<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: WangYu  
    $Date: 2014-4-25 上午09:31:11  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="t1.document_category=&apos;CONTRACT&apos;" fetchAll="true" model="basic.hls_document_type_for_lov" rootPath="con501_document_type_path"/>
    </a:init-procedure>
    <a:view>
        <script type="text/javascript"><![CDATA[
        
        	function CON321_con_contract_query()
        	{
        	    $('con_contract_cashflow_balance_result_ds').query();
        	}
        	
        	function CON321_con_contract_reset()
        	{	
        	   $('con_contract_cashflow_balance_query_ds').reset();
        	}
        	
        	function CON321_render_contract_number(value, record, name)
        	{
        	    if(name=="contract_number")
        	    {
        	        if (record.get('overdue_max_days') >= 1) {
                        return '<u><a style="color:red" >' + value + '</a></u>';
                    } else {
                        return value ;
                    }
        	    }
        	    if(name=="penalty")
        	    {
        	        if (value > 0) {
                        return '<u><a style="color:red" >' + value + '</a></u>';
                    } else {
                        return '<a >' + value + '</a>';
                    }
        	    }
        	}
		]]></script>
        <a:dataSets>
            <a:dataSet id="con321_contract_status_ds" lookupCode="CON500_CONTRACT_STATUS"/>
            <a:dataSet id="over_status_flag_ds">
                <a:datas>
                    <a:record name="Y" value="是"/>
                    <a:record name="N" value="否"/>
                </a:datas>
            </a:dataSet>
            <a:dataSet id="con501_document_type_name_ds">
                <a:datas dataSource="/model/con501_document_type_path"/>
            </a:dataSet>
            <a:dataSet id="con_contract_cashflow_balance_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="document_type_desc" displayField="description" options="con501_document_type_name_ds" returnField="document_type" valueField="document_type"><![CDATA[
                	]]></a:field>
                    <a:field name="contract_number_from"/>
                    <a:field name="contract_number_to"/>
                    <a:field name="bp_id_tenant_n" lovGridHeight="350" lovHeight="500" lovLabelWidth="100" lovService="basic.hls_bp_master_v_for_lov?bp_category=TENANT" lovWidth="520" title="HLS.BP_TITLE">
                        <a:mapping>
                            <a:map from="bp_name" to="bp_id_tenant_n"/>
                            <a:map from="bp_id" to="bp_id_tenant"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="cf_item_desc" autoComplete="true" lovGridHeight="350" lovHeight="500" lovLabelWidth="100" lovService="cont.CON321.hls_cashflow_item_v_lov" lovWidth="520" title="现金流项目">
                        <a:mapping>
                            <a:map from="cf_item" to="cf_item"/>
                            <a:map from="cf_item_desc" to="cf_item_desc"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="price_list_name" autoComplete="true" fetchSingle="true" lovGridHeight="350" lovHeight="500" lovService="hls.HLS050.hls_price_list_for_lov" lovWidth="500" title="HLS.PRICE_LIST">
                        <a:mapping>
                            <a:map from="price_list" to="price_list"/>
                            <a:map from="description" to="price_list_name"/>
                            <a:map from="calc_method" to="calc_method"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="contract_status"/>
                    <a:field name="contract_status_desc" displayField="code_value_name" options="con321_contract_status_ds" returnField="contract_status" valueField="code_value"/>
                    <a:field name="overdue_status" defaultValue="Y"/>
                    <a:field name="write_off_flag_desc" displayField="value" options="over_status_flag_ds" returnField="write_off_flag" valueField="name"/>
                    <a:field name="over_status_flag_desc" defaultValue="是" displayField="value" options="over_status_flag_ds" returnField="overdue_status" valueField="name"/>
                    <a:field name="company_authority" defaultValue="${/session/@company_id}"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_contract_cashflow_balance_result_ds" model="cont.CON321.con_contract_cashflow_balance" pageSize="12" queryDataSet="con_contract_cashflow_balance_query_ds" selectable="true" selectionModel="single"/>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="CON321_con_contract_query" text="HLS.QUERY"/>
                <a:gridButton click="CON321_con_contract_reset" text="HLS.RESET"/>
            </a:screenTopToolbar>
            <a:form bindTarget="con_contract_cashflow_balance_query_ds" column="5" title="合同现金流余额查询" width="1200">
                <a:textField name="contract_number_from" bindTarget="con_contract_cashflow_balance_query_ds" prompt="合同编号从"/>
                <a:textField name="contract_number_to" bindTarget="con_contract_cashflow_balance_query_ds" prompt="合同编号到"/>
                <a:comboBox name="contract_status_desc" bindTarget="con_contract_cashflow_balance_query_ds" prompt="合同状态"/>
                <a:lov name="bp_id_tenant_n" bindTarget="con_contract_cashflow_balance_query_ds" prompt="承租人"/>
                <a:lov name="cf_item_desc" bindTarget="con_contract_cashflow_balance_query_ds" prompt="现金流项目"/>
                <a:comboBox name="over_status_flag_desc" bindTarget="con_contract_cashflow_balance_query_ds" prompt="逾期标志"/>
                <a:datePicker name="due_date_from" bindTarget="con_contract_cashflow_balance_query_ds" prompt="应收日从"/>
                <a:datePicker name="due_date_to" bindTarget="con_contract_cashflow_balance_query_ds" prompt="应收日到"/>
                <a:numberField name="due_amount_from" bindTarget="con_contract_cashflow_balance_query_ds" prompt="应收金额从"/>
                <a:numberField name="due_amount_to" bindTarget="con_contract_cashflow_balance_query_ds" prompt="应收金额到"/>
                <a:numberField name="received_amount_from" bindTarget="con_contract_cashflow_balance_query_ds" prompt="实收金额从"/>
                <a:numberField name="received_amount_to" bindTarget="con_contract_cashflow_balance_query_ds" prompt="实收金额到"/>
                <a:numberField name="unreceived_amount_from" bindTarget="con_contract_cashflow_balance_query_ds" prompt="未收金额从"/>
                <a:numberField name="unreceived_amount_to" bindTarget="con_contract_cashflow_balance_query_ds" prompt="未收金额到"/>
                <a:datePicker name="last_received_date" bindTarget="con_contract_cashflow_balance_query_ds" prompt="最后收款日"/>
                <a:lov name="price_list_name" bindTarget="con_contract_cashflow_balance_query_ds" prompt="价目表"/>
                <a:comboBox name="document_type_desc" bindTarget="con_contract_cashflow_balance_query_ds" prompt="HLS.CONTRACT_TYPE"/>
                <a:comboBox name="write_off_flag_desc" bindTarget="con_contract_cashflow_balance_query_ds" prompt="是否核销"/>
            </a:form>
            <a:grid bindTarget="con_contract_cashflow_balance_result_ds" height="380" navBar="true" width="1200">
                <a:toolBar>
                    <a:button type="excel"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="contract_number" lock="true" prompt="合同编号" renderer="CON321_render_contract_number" width="120"/>
                    <a:column name="contract_name" align="center" prompt="合同名称" width="150"/>
                    <a:column name="contract_status_n" align="center" prompt="合同状态" width="80"/>
                    <a:column name="document_type_n" align="center" prompt="HLS.CONTRACT_TYPE" width="90"/>
                    <a:column name="price_list_n" align="center" prompt="报价类型" width="150"/>
                    <a:column name="bp_id_tenant_n" align="center" prompt="承租人" width="150"/>
                    <a:column name="cf_item_desc" prompt="现金流项目"/>
                    <a:column name="times" align="center" prompt="期数" width="50"/>
                    <a:column name="due_date" align="center" prompt="应收日" renderer="Leaf.formatDate" width="80"/>
                    <a:column name="due_amount" align="right" prompt="应收金额" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="principal" align="right" prompt="应收本金" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="interest" align="right" prompt="应收利息" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="estimated_due_amount" align="right" prompt="预估金额" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="received_amount" align="right" prompt="实收金额" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="received_principal" align="right" prompt="实收本金" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="received_interest" align="right" prompt="实收利息" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="unreceived_amount" align="right" prompt="未收金额" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="unreceived_principal" align="right" prompt="未收本金" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="unreceived_interest" align="right" prompt="未收利息" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="last_received_date" align="center" prompt="最后收款日" renderer="Leaf.formatDate" width="80"/>
                    <a:column name="overdue_status" align="center" prompt="逾期标志" width="80"/>
                    <a:column name="overdue_max_days" align="center" prompt="逾期天数" width="80"/>
                    <a:column name="penalty" align="right" prompt="逾期罚金" renderer="Leaf.formatMoney" width="80"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>