<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author:   copy from acr515 , modify file interface
    $Date: 
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="gld.gld_currency_vl" rootPath="acr515_currency_list"/>
        <a:model-query fetchAll="true" model="acr.ACR512.acr_invoice_business_type_list" rootPath="acr515_business_type_list"/>
    </a:init-procedure>
    <a:view>
        <!-- <a:link id="bmLink_vat_pause_or_submit" model="acr.ACR515.acr_invoice_vat" modelaction="batch_update"/> -->
        <!-- <a:link id="bmLink_vat_receive" model="acr.ACR515.acr_invoice_vat" modelaction="execute"/> -->
        <a:link id="acr_interface_file_import_id" url="${/request/@context_path}/modules/acr/ACR516/acr_vat_file_interface_import.lview"/>
        <a:screen-include screen="modules/hls/hls_common_javascript.lview"/>
        <script type="text/javascript"><![CDATA[
            function acr516_invoice_query() {
                $('acr515_invoiceVatDs').query();
            }
            
            function acr515_invoice_refresh()
            {
                var ds = $('acr515_invoiceVatDs');
                ds.query(ds.currentPage);
            }
            
            function acr516_invoice_reset() {
                $('acr515_invoiceVatParaDs').reset();
            }
            
            function onUpdate_acr515_invoiceVatParaDs(ds, record, name, value, oldVlaue) {
                if (name == 'document_number_f') {
                    if (Leaf.isEmpty(record.get('document_number_t'))) {
                        record.set('document_number_t', value);
                    }
                } else if (name == 'project_number_f') {
                    if (Leaf.isEmpty(record.get('project_number_t'))) {
                        record.set('project_number_t', value);
                    }
                } else if (name == 'invoice_number_f') {
                    if (Leaf.isEmpty(record.get('invoice_number_t'))) {
                        record.set('invoice_number_t', value);
                    }
                } else if (name == 'contract_number_f') {
                    if (Leaf.isEmpty(record.get('contract_number_t'))) {
                        record.set('contract_number_t', value);
                    }
                } else if (name == 'invoice_bp_code_f') {
                    if (Leaf.isEmpty(record.get('invoice_bp_code_t'))) {
                        record.set('invoice_bp_code_t', value);
                    }
                } else if (name == 'total_amount_f') {
                    if (Leaf.isEmpty(record.get('total_amount_t'))) {
                        record.set('total_amount_t', value);
                    }
                }
                
                if(Ext.isEmpty(record.get('project_number_f'))&&Ext.isEmpty(record.get('project_number_t')))
                {
                    record.set('query_project_number','');
                }
                else
                {
                    record.set('query_project_number','Y');
                }
                if(Ext.isEmpty(record.get('contract_number_f'))&&Ext.isEmpty(record.get('contract_number_t')))
                {
                    record.set('query_contract_number','');
                }
                else
                {
                    record.set('query_contract_number','Y');
                }
            }
            
            function onSubmitSuccess_acr515_invoiceVatDs(ds) {
                acr515_invoice_refresh();
            }
            function open_file_import_window(){
                var url=$('acr_interface_file_import_id').getUrl();
                new Leaf.Window({
		                id:'acr_file_import_id',
		                url:url,
		                title:'金穗接口文件数据导入',
		                fullScreen:true
				}).on('close',function(){
					    acr516_invoice_query();
				});
            }
            function file_export(){
                $('acr516_invoiceVatDs_grid')._export();
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="acr515_businessTypeDs">
                <a:datas dataSource="/model/acr515_business_type_list"/>
            </a:dataSet>
            <a:dataSet id="acr515_currencyDs">
                <a:datas dataSource="/model/acr515_currency_list"/>
            </a:dataSet>
            <a:dataSet id="acr515_invoiceKindDs" lookupCode="ACR510_INVOICE_KIND"/>
            <a:dataSet id="acr515_invoiceStatusDs" lookupCode="ACR510_AR_INVOICE_STATUS"/>
            <a:dataSet id="acr515_express_status_ds" lookupCode="ACR518_EXPRESS_STATUS"/>
            <a:dataSet id="acr515_vat_interface_status_ds" lookupCode="ACR515_VAT_INTERFACE_STATUS"/>
            <a:dataSet id="acr515_invoiceVatParaDs" autoCreate="true" model="acr.acr_invoice_hd_v">
                <a:fields>
                    <a:field name="currency_desc" displayField="currency_name" options="acr515_currencyDs" returnField="currency" valueField="currency_code"/>
                    <a:field name="invoice_kind_desc" displayField="code_value_name" options="acr515_invoiceKindDs" returnField="invoice_kind" valueField="code_value"/>
                    <a:field name="invoice_status_desc" displayField="code_value_name" options="acr515_invoiceStatusDs" returnField="invoice_status" valueField="code_value"/>
                    <a:field name="vat_interface_status_desc" displayField="code_value_name" options="acr515_vat_interface_status_ds" returnField="vat_interface_status" valueField="code_value"/>
                    <a:field name="business_type_desc" displayField="business_type_desc" options="acr515_businessTypeDs" returnField="business_type" valueField="business_type"/>
                    <a:field name="created_by_name" lovGridHeight="320" lovHeight="500" lovService="acr.ACR512.acr_invoice_sys_user_lov" lovWidth="500" title="ACR.CREATED_BY_NAME">
                        <a:mapping>
                            <a:map from="user_id" to="created_by"/>
                            <a:map from="description" to="created_by_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="confirmed_by_name" lovGridHeight="320" lovHeight="500" lovService="acr.ACR512.acr_invoice_sys_user_lov" lovWidth="500" title="ACR.CONFIRMED_BY_NAME">
                        <a:mapping>
                            <a:map from="user_id" to="confirmed_by"/>
                            <a:map from="description" to="confirmed_by_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="invoice_bp_code_f" lovGridHeight="320" lovHeight="480" lovService="acr.ACR512.acr_invoice_bp_master_list" lovWidth="500" title="ACR.INVOICE_BP_CODE">
                        <a:mapping>
                            <a:map from="bp_code" to="invoice_bp_code_f"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="invoice_bp_code_t" lovGridHeight="320" lovHeight="480" lovService="acr.ACR512.acr_invoice_bp_master_list" lovWidth="500" title="ACR.INVOICE_BP_CODE">
                        <a:mapping>
                            <a:map from="bp_code" to="invoice_bp_code_t"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="project_number_f" lovGridHeight="320" lovHeight="480" lovService="acr.ACR512.acr_invoice_project_list" lovWidth="500" title="HLS.PROJECT_NUMBER_FROM">
                        <a:mapping>
                            <a:map from="project_number" to="project_number_f"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="project_number_t" lovGridHeight="320" lovHeight="480" lovService="acr.ACR512.acr_invoice_project_list" lovWidth="500" title="HLS.PROJECT_NUMBER_FROM">
                        <a:mapping>
                            <a:map from="project_number" to="project_number_t"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="contract_number_f" lovGridHeight="320" lovHeight="480" lovService="acr.ACR512.acr_invoice_contract_list" lovWidth="500" title="HLS.CONTRACT_NUMBER_FROM">
                        <a:mapping>
                            <a:map from="contract_number" to="contract_number_f"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="contract_number_t" lovGridHeight="320" lovHeight="480" lovService="acr.ACR512.acr_invoice_contract_list" lovWidth="500" title="HLS.CONTRACT_NUMBER_FROM">
                        <a:mapping>
                            <a:map from="contract_number" to="contract_number_t"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="received_flag" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="express_status_name" displayField="code_value_name" options="acr515_express_status_ds" returnField="express_status" valueField="code_value"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="onUpdate_acr515_invoiceVatParaDs"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="acr515_invoiceVatDs" autoPageSize="true" model="acr.acr_invoice_hd_v" queryDataSet="acr515_invoiceVatParaDs" selectable="true">
                <a:events>
                    <a:event name="submitsuccess" handler="onSubmitSuccess_acr515_invoiceVatDs"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="acr516_invoice_query" text="HLS.QUERY"/>
                <a:gridButton click="acr516_invoice_reset" text="HLS.RESET"/>
                <a:gridButton click="file_export" text="发票导出"/>
                <a:gridButton click="open_file_import_window" text="发票导入"/>
            </a:screenTopToolbar>
            <a:form column="1" marginWidth="30" padding="0">
                <a:hBox labelSeparator=" ">
                    <a:textField name="document_number_f" bindTarget="acr515_invoiceVatParaDs" prompt="HLS.DOCUMENT_NUMBER_FROM" width="135"/>
                    <div><![CDATA[${l:HLS.DOCUMENT_NUMBER_TO}]]></div>
                    <a:textField name="document_number_t" bindTarget="acr515_invoiceVatParaDs" prompt="" width="135"/>
                    <a:lov name="project_number_f" bindTarget="acr515_invoiceVatParaDs" prompt="HLS.PROJECT_NUMBER_FROM" width="135"/>
                    <div><![CDATA[${l:HLS.DOCUMENT_NUMBER_TO}]]></div>
                    <a:lov name="project_number_t" bindTarget="acr515_invoiceVatParaDs" prompt="" width="135"/>
                    <a:comboBox name="business_type_desc" bindTarget="acr515_invoiceVatParaDs" width="135"/>
                    <a:comboBox name="currency_desc" bindTarget="acr515_invoiceVatParaDs" width="135"/>
                </a:hBox>
                <a:hBox labelSeparator=" ">
                    <a:textField name="invoice_number_f" bindTarget="acr515_invoiceVatParaDs" prompt="ACR.INVOICE_NUMBER_FROM" width="135"/>
                    <div><![CDATA[${l:ACR.INVOICE_NUMBER_TO}]]></div>
                    <a:textField name="invoice_number_t" bindTarget="acr515_invoiceVatParaDs" prompt="" width="135"/>
                    <a:lov name="contract_number_f" bindTarget="acr515_invoiceVatParaDs" prompt="HLS.CONTRACT_NUMBER_FROM" width="135"/>
                    <div><![CDATA[${l:HLS.CONTRACT_NUMBER_TO}]]></div>
                    <a:lov name="contract_number_t" bindTarget="acr515_invoiceVatParaDs" prompt="" width="135"/>
                    <a:comboBox name="invoice_kind_desc" bindTarget="acr515_invoiceVatParaDs" width="135"/>
                    <a:lov name="created_by_name" bindTarget="acr515_invoiceVatParaDs" width="135"/>
                </a:hBox>
                <a:hBox labelSeparator=" ">
                    <a:datePicker name="invoice_date_f" bindTarget="acr515_invoiceVatParaDs" prompt="ACR.INVOICE_DATE_FROM" width="135"/>
                    <div><![CDATA[${l:ACR.INVOICE_DATE_TO}]]></div>
                    <a:datePicker name="invoice_date_t" bindTarget="acr515_invoiceVatParaDs" prompt="" width="135"/>
                    <a:lov name="invoice_bp_code_f" bindTarget="acr515_invoiceVatParaDs" prompt="HLS.CUSTOMER_NUMBER_FROM" width="135"/>
                    <div><![CDATA[${l:HLS.CUSTOMER_NUMBER_TO}]]></div>
                    <a:lov name="invoice_bp_code_t" bindTarget="acr515_invoiceVatParaDs" prompt="" width="135"/>
                    <a:textField name="invoice_title" bindTarget="acr515_invoiceVatParaDs" width="135"/>
                    <a:lov name="confirmed_by_name" bindTarget="acr515_invoiceVatParaDs" width="135"/>
                </a:hBox>
                <a:hBox labelSeparator=" ">
                    <a:datePicker name="accounting_date_f" bindTarget="acr515_invoiceVatParaDs" prompt="HLS.ACCOUNT_DATE_FROM" width="135"/>
                    <div><![CDATA[${l:HLS.ACCOUNT_DATE_TO}]]></div>
                    <a:datePicker name="accounting_date_t" bindTarget="acr515_invoiceVatParaDs" prompt="" width="135"/>
                    <a:numberField name="total_amount_f" allowFormat="true" bindTarget="acr515_invoiceVatParaDs" prompt="ACR.TOTAL_AMOUNT_FROM" width="135"/>
                    <div><![CDATA[${l:ACR.TOTAL_AMOUNT_TO}]]></div>
                    <a:numberField name="total_amount_t" allowFormat="true" bindTarget="acr515_invoiceVatParaDs" prompt="" width="135"/>
                    <a:comboBox name="invoice_status_desc" bindTarget="acr515_invoiceVatParaDs" width="135"/>
                    <a:comboBox name="vat_interface_status_desc" bindTarget="acr515_invoiceVatParaDs" width="135"/>
                </a:hBox>
            </a:form>
            <a:grid id="acr516_invoiceVatDs_grid" bindTarget="acr515_invoiceVatDs" marginHeight="240" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="document_number" lock="true" width="120"/>
                    <a:column name="business_type_desc" width="80"/>
                    <a:column name="invoice_kind_desc" width="100"/>
                    <a:column name="invoice_number" width="120"/>
                    <a:column name="invoice_date" renderer="Leaf.formatDate" width="100"/>
                    <a:column name="invoice_bp_code" width="100"/>
                    <a:column name="invoice_bp_name" autoAdjust="false" width="150"/>
                    <a:column name="invoice_title" autoAdjust="false" width="150"/>
                    <a:column name="total_amount" align="right" renderer="Leaf.formatMoney" width="100"/>
                    <a:column name="currency" width="80"/>
                    <a:column name="created_by_name" autoAdjust="false" width="150"/>
                    <a:column name="confirmed_by_name" autoAdjust="false" width="150"/>
                    <a:column name="invoice_status_desc" width="100"/>
                    <a:column name="reversed_flag_desc" width="100"/>
                    <a:column name="vat_interface_status_desc" width="100"/>
                    <a:column name="vat_invoice_status_desc"/>
                    <a:column name="accounting_date" prompt="记账日期" renderer="Leaf.formatDate" width="100"/>
                    <a:column name="internal_period_num" prompt="期间序号" width="100"/>
                    <a:column name="create_je_flag" width="60"/>
                    <a:column name="project_number" width="120"/>
                    <a:column name="project_name" autoAdjust="false" width="150"/>
                    <a:column name="contract_number" width="120"/>
                    <a:column name="contract_name" autoAdjust="false" width="150"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
