<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" xmlns:dr="leaf.plugin.excelreport"  trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="contract_id=${/parameter/@contract_id}" fetchAll="true" model="cont.CON1300.get_contract_print_info" rootPath="/model/head_info"/>
        <a:model-query  fetchAll="true" model="cont.CON1300.get_contract_print_grid_info" rootPath="/model/grid_data"/>
        <s:server-script><![CDATA[
            function getdate() {
            var now = new Date()
            y = now.getFullYear()
            m = now.getMonth() + 1
            d = now.getDate()
            m = m < 10 ? "0" + m : m
            d = d < 10 ? "0" + d : d
            return y + "" + m + "" + d
            }

            $ctx.parameter.file_name   = $ctx.parameter.file_name+getdate()+'.xlsx';
            ]]></s:server-script>
        <dr:excel-report enableTask="false" fileName="${/parameter/@file_name}">
            <styles>
                <dr:cell-style name="title" align="ALIGN_CENTER">
                    <dr:font fontName="黑体" height="12" italic="false"/>
                </dr:cell-style>
                <dr:cell-style name="left" align="ALIGN_LEFT">
                    <dr:font fontName="黑体" height="10" italic="false"/>
                </dr:cell-style>
                <dr:cell-style name="right" align="ALIGN_RIGHT">
                    <dr:font fontName="黑体" height="10" italic="false"/>
                </dr:cell-style>
                <dr:cell-style name="grid_title"  align="ALIGN_CENTER" borderbottom="BORDER_THIN" borderleft="BORDER_THIN" borderTop="BORDER_THIN" borderRight="BORDER_THIN">
                    <dr:font fontName="黑体" height="9" italic="false"/>

                </dr:cell-style>
                <dr:cell-style name="grid_cell" align="ALIGN_CENTER" borderbottom="BORDER_THIN" borderleft="BORDER_THIN" borderTop="BORDER_THIN" borderRight="BORDER_THIN">
                    <dr:font fontName="黑体" height="9" italic="false"/>

                </dr:cell-style>
                <dr:cell-style name="header" align="ALIGN_CENTER">
                    <dr:font bold="false" fontName="宋体" height="12"/>
                </dr:cell-style>
                <dr:cell-style name="foot">
                    <dr:font bold="false" fontName="宋体" height="12"/>
                </dr:cell-style>
                <dr:cell-style name="footNumber" dataFormat="#,##0.000">
                    <dr:font bold="false" fontName="宋体" height="12"/>
                </dr:cell-style>
                <dr:cell-style name="dateFormat" dataFormat="YYYY-MM-DD">
                    <dr:font bold="false" fontName="宋体" height="12"/>
                </dr:cell-style>
                <dr:cell-style name="group">
                    <dr:font bold="false" fontName="宋体" height="12"/>
                </dr:cell-style>
            </styles>
            <sheets>
                <dr:sheet name="第一页" autoSizeColumns="0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20" displayGridlines="true">
                    <dr:static-content>
                        <dr:cell-data cell="A"    row="1" stylename="title" type="content" value="合同应收明细表"/>
                        <dr:cell-data cell="A"    row="3" stylename="right" type="content" value="代理店："/>
                        <dr:cell-data cell="B"   row="3" stylename="left" type="content" value="${/model/head_info/record/@bp_name}"/>
                        <dr:cell-data cell="J"   row="3" stylename="right" type="content" value="业务伙伴号："/>
                        <dr:cell-data cell="k"   row="3" stylename="left" type="content" value="${/model/head_info/record/@client_bp_code}"/>
                        <dr:cell-data cell="A"   row="4" stylename="right" type="content" value="合同编号："/>
                        <dr:cell-data cell="B"   row="4" stylename="left" type="content" value="${/model/head_info/record/@contract_number}"/>
                        <dr:cell-data cell="J"   row="4" stylename="right" type="content" value="客户名称："/>
                        <dr:cell-data cell="k"   row="4" stylename="left" type="content" value="${/model/head_info/record/@client_bp_name}"/>

                        <dr:cell-data cell="A"   row="5" stylename="right" type="content" value="机型："/>
                        <dr:cell-data cell="B"   row="5" stylename="left" type="content" value="${/model/head_info/record/@pattern}"/>
                        <dr:cell-data cell="J"   row="5" stylename="right" type="content" value="机号："/>
                        <dr:cell-data cell="k"   row="5" stylename="left" type="content" value="${/model/head_info/record/@machine_number}"/>

                        <dr:cell-data cell="A"   row="6" stylename="right" type="content" value="合同签订日："/>
                        <dr:cell-data cell="B"   row="6" stylename="left" type="content" value="${/model/head_info/record/@inception_of_lease}"/>
                        <dr:cell-data cell="J"   row="6" stylename="right" type="content" value="租赁开始日："/>
                        <dr:cell-data cell="k"   row="6" stylename="left" type="content" value="${/model/head_info/record/@lease_start_date}"/>

                        <dr:cell-data cell="A"   row="7" stylename="right" type="content" value="利率："/>
                        <dr:cell-data cell="B"   row="7" stylename="left" type="content" value="${/model/head_info/record/@int_rate_display}"/>
                        <dr:cell-data cell="J"   row="7" stylename="right" type="content" value="租赁期间："/>
                        <dr:cell-data cell="k"   row="7" stylename="left" type="content" value="${/model/head_info/record/@lease_times}"/>
                    </dr:static-content>
                    <dr:dynamic-content cell="A" datamodel="/model/grid_data" row="8">
                        <dr:columns>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="439" field="times" title="期数"  type="content"/>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="440" field="due_date" title="预定收款日"  type="content" groupDesc="计数" />
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="441" field="due_amount" title="预定收款金额"  type="content"/>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="441" field="vat_due_amount" title="租金增值税"  type="content"/>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="441" field="principal" title="本金"  type="content"/>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="441" field="vat_principal" title="本金增值税"  type="content"/>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="448" field="total_interest" title="利息合计"  type="content"/>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="442" field="up_interest" title="利息上段"  type="content"/>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="443" field="down_interest" title="利息下段"  type="content"/>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="444" field="total_net_interest" title="利息（不含税）合计"  type="content" />
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="445" field="up_net_interest" title="利息（不含税）上段"  type="content"/>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="446" field="down_net_interest" title="利息（不含税）下段"  type="content"/>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="447" field="total_vat_interest" title="利息（增值税）合计"  type="content"/>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="447" field="up_vat_interest" title="利息（增值税）上段"  type="content"/>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="447" field="down_vat_interest" title="利息（增值税）下段"  type="content"/>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="447" field="total_weight_factor" title="本期天数合计"  type="content"/>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="447" field="up_weight_factor" title="本期天数上段"  type="content"/>
                            <dr:table-column cellStyle="grid_cell" titleStyle="grid_title" column_id="447" field="down_weight_factor" title="本期天数下段"  type="content"/>
                        </dr:columns>
                    </dr:dynamic-content>
                </dr:sheet>
            </sheets>
        </dr:excel-report>
    </a:init-procedure>
</a:service>
