acr_invoice_penalty_invoice.lview 12.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
<?xml version="1.0" encoding="UTF-8"?>
<!--
	&author:DJ
	$date:2013/05/08
	$purpose:发票创建
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query model="basic.sys_session_info" rootPath="default_value_record"/>
        <a:model-query model="acr.ACR510.acr_invoice_group_penalty_billing_method" rootPath="group_billing_method_list"/>
11
		<a:model-query model="basic.sys_invoice_kind_type_v" rootPath="acr512_invoice_kind_type"/>
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
    </a:init-procedure>
    <a:view>
        <a:link id="svcLink_create_invoice" url="${/request/@context_path}/modules/acr/ACR510/acr_invoice_penalty_create.lsc"/>
        <a:screen-include screen="modules/hls/hls_common_javascript.lview"/>
        <script><![CDATA[
        function createScreen_close()
        {
            var win = $('acr_invoice_penalty_invoice');
            win.close();
        }
        function colum_caculateTotal(data, name) {
            var total = 0;
            var length = data.length;
            var value = 0;
            for (var i = 0;i < length;i++) {
                if (Ext.isEmpty(data[i].get(name))) {
                    value = 0;
                } else {
                    value = data[i].get(name);
                }
                total = plus(total, value);
            }
            return '<font color=red>' + Leaf.formatMoney(total) + '</font>';
        }

        function sum_foot(data, name) {
            if (name == 'billing_amount') {
                return colum_caculateTotal(data, name);
            }

        }

        function createScreen_create()
        {
            var win = $('acr_invoice_create_invoice');
            var ds=$('headDs');
48 49
            var message_flag =false;
            debugger
50 51 52 53 54
            if(!ds.validate(true))
            {
                Leaf.Masker.unmask(Ext.getBody());
                return;
            }
niminmin's avatar
niminmin committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
            //判断本次开票金额是否大于(已收金额减去已开票金额)
            var selectedDs=$('selectedDs').getAll();
            for(var i=0;i<selectedDs.length;i++){
                var billing_amount=selectedDs[i].get('billing_amount');
                var received_amount=selectedDs[i].get('received_amount');
                var cf_billing_amount=selectedDs[i].get('cf_billing_amount')||0;
                var temp_billing_amount=minus(received_amount,cf_billing_amount);


                // if(billing_amount!=due_amount &&billing_amount!=principal &&billing_amount!=interest){
                //    $L.showErrorMessage("提示","本次开票金额需与应收金额,应收本金,应收利息中的某一金额一致!");
                //    return;
                // }
                if(billing_amount>temp_billing_amount){
                    $L.showErrorMessage("提示","开票金额填写有误!");
                    return;
                }
72 73 74 75 76 77 78 79 80 81 82
                //add by gzj 售后回租只能开普票
                var business_type= selectedDs[i].get('business_type');
                var kind_type=selectedDs[i].get('invoice_kind_type');
                if(business_type=='LEASEBACK'&&(kind_type!='PAPER_GENERAL'&&kind_type!='ELECTRONIC_GENERAL'&&kind_type!='RECEIPT')){
                    Leaf.showMessage("提示","售后回租只能开普通发票!");
                    return;
                }
                if(business_type=='LEASEBACK'&&(kind_type!='ELECTRONIC_GENERAL'&&kind_type!='RECEIPT')){
                    message_flag =true;
                    // Leaf.showMessage("提示","回租建议选择增值税电子普票!");
                }
niminmin's avatar
niminmin committed
83 84 85 86



            }
87 88

            var datas = ds.getJsonData();
89 90 91 92 93 94 95
            var message_info;
            if(message_flag==false){
                message_info= '是否确认开票?';
            }else {
                message_info= "回租建议选择增值税电子普票!是否确认开票?";
            }
            Leaf.showConfirm('${l:HLS.PROMPT}',message_info,function()
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
            {

                Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
                Leaf.request({
                    url: $('svcLink_create_invoice').getUrl(),
                    para: datas,
                    success: function(res) {
                        Leaf.Masker.unmask(Ext.getBody());
                        createScreen_close();
                        contractDs_grid_query();
                    },
                    failure: function() {
                        Leaf.Masker.unmask(Ext.getBody());

                    },
                    error: function() {
                        Leaf.Masker.unmask(Ext.getBody());

                    },
                    scope: this
                });
            },function (){
                Leaf.Masker.unmask(Ext.getBody());

            });

        }

        function unSelect_selectedDs(ds,record){
            record.dirty = false;
        }

        function onSelect_selectedDs(ds,record){
            record.dirty = true;
        }

        function onLoad_selectedDs(ds)
        {
            ds.selectAll.defer(5,ds);
            var records=ds.getAll();
            for (var i=0;i<records.length;i++) {
                if (records[i].get('invoice_kind') && records[i].get('invoice_kind')=='RECEIPT' && records[i].get('cf_item') && records[i].get('cf_item')=='51') {
                    records[i].set('product_name','保证金');
                }
            }
        }
142
		window['acr510_get_object_for_invoice'] = function(object) {
143 144 145 146 147 148 149 150 151 152 153 154 155
            debugger;
            var record = object.record;
            var name = object.binder.name;
            var url = '${/request/@context_path}/autocrud/basic.sys_invoice_kind_type_v/query';
            if(name=='invoice_kind_type_n'){
                var combobox_ds =$('invoiceKindDs');
                combobox_ds.setQueryUrl(url);
                combobox_ds.setQueryParameter('record_id', record.get('record_id'));
                combobox_ds.query();
            }


        };
156 157
        ]]></script>
        <a:dataSets>
158
             <!--<a:dataSet id="invoiceKindDs" lookupCode="ACR510_INVOICE_KIND"/>-->
159 160 161
            <a:dataSet id="invoiceKindDs">
                <a:datas dataSource="/model/acr512_invoice_kind_type"/>
            </a:dataSet>
162 163 164 165
            <a:dataSet id="headDs" autoCreate="true">
                <a:fields>
                    <a:field name="company_id" defaultValue="${/parameter/@company_id}"/>
                    <a:field name="group_billing_method" defaultValue="NO_GROUP"/>
166
                    <a:field name="accounting_date" defaultValue="${/model/default_value_record/record/@today}"/>
167 168 169 170 171 172
                    <a:field name="invoice_date" defaultValue="${/model/default_value_record/record/@today}" required="true"/>
                </a:fields>
            </a:dataSet>

            <a:dataSet id="selectedDs" autoQuery="true" bindName="line_info" bindTarget="headDs" fetchAll="true" model="acr.ACR510.acr_invoice_penalty_create" selectable="true">
                <a:fields>
niminmin's avatar
niminmin committed
173
                    <a:field name="billing_amount" required="true"/>
174
                    <a:field name="product_name" required="true"/>
175 176 177 178
                    <!--<a:field name="invoice_kind"/>
                   <a:field name="invoice_kind_desc" displayField="code_value_name" options="invoiceKindDs" required="true" returnField="invoice_kind" valueField="code_value"/>-->
                    <a:field name="invoice_kind_type"/>
                    <a:field name="invoice_kind_type_n" displayField="value_name" options="invoiceKindDs" required="true" returnField="invoice_kind_type" valueField="value_code"/>
179 180
                    <a:field name="billing_object"/>
                    <a:field name="billing_object_name" prompt="开票对象名称"/>
181
                   
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
                </a:fields>
                <a:events>
                    <a:event name="load" handler="onLoad_selectedDs"/>
                    <a:event name="select" handler="onSelect_selectedDs"/>
                    <a:event name="unselect" handler="unSelect_selectedDs"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="createScreen_close" text="HLS.CLOSE"/>
                <a:gridButton click="createScreen_create" text="HLS.CREATE"/>
            </a:screenTopToolbar>
            <a:form column="3" labelWidth="120">
                <a:datePicker name="invoice_date" bindTarget="headDs" prompt="开票申请日期"/>
                <a:datePicker name="accounting_date" bindTarget="headDs" prompt="HLS.ACCOUNT_DATE"/>
            </a:form>
            <a:tabPanel marginHeight="220" marginWidth="30">
                <a:tabs>
                    <a:tab prompt="ACR510.TAB.BILLING_INFO" width="100">
                        <a:grid id="selectedDs_grid" bindTarget="selectedDs" marginHeight="270" marginWidth="60">
                            <a:columns>
                                <a:column name="contract_number" width="150"/>
                                <a:column name="cf_item_desc"/>
                                <a:column name="product_name" editor="selectedDs_grid_editor_tf" width="150"/>
207 208
                                <!--<a:column name="invoice_kind_desc" editor="selectedDs_grid_editor_comb"/>-->
                                <a:column name="invoice_kind_type_n" editorFunction="" editor="selectedDs_grid_editor_comb" width="150"/>
209 210 211 212 213
                                <a:column name="billing_object_name" width="150"/>

                                <a:column name="currency_desc" align="center"/>
<!--                                <a:column name="due_amount" align="right" renderer="Leaf.formatMoney"/>-->
                                <a:column name="received_amount" align="right" renderer="Leaf.formatMoney"/>
niminmin's avatar
niminmin committed
214
                                <a:column name="cf_billing_amount" align="right" renderer="Leaf.formatMoney"/>
215
                                <a:column name="billing_amount" align="right" editor="selectedDs_grid_editor_nf" renderer="Leaf.formatMoney" footerRenderer="sum_foot"/>
216 217
                                 <a:column name="full_elec_invoice_flag_n" prompt="是否全电发票" align="center"/>
							</a:columns>
218
                            <a:editors>
219 220 221 222 223
                                <a:comboBox id="selectedDs_grid_editor_comb">
                                    <a:events>
                                        <a:event name="focus" handler="window[&apos;acr510_get_object_for_invoice&apos;]"/>
                                    </a:events>
                                </a:comboBox>
224 225 226 227 228 229 230 231 232 233 234 235
                                <a:textField id="selectedDs_grid_editor_tf"/>
                                <a:numberField id="selectedDs_grid_editor_nf"/>
                            </a:editors>
                        </a:grid>
                    </a:tab>
                    <a:tab prompt="ACR510.TAB.ASSIST_INFO" width="100">
                        <a:grid id="selectedDs_grid_2" bindTarget="selectedDs" marginHeight="270" marginWidth="60">
                            <a:columns>
                                <a:column name="contract_number" width="150"/>
                                <a:column name="cf_item_desc"/>
                                <a:column name="contract_name" width="200"/>
                                <a:column name="project_number" width="150" prompt="报单编号"/>
236
<!--                                <a:column name="project_name" width="200" prompt="报单名称"/>-->
237 238 239 240 241 242 243 244 245 246 247 248 249 250
                                <a:column name="transaction_date" renderer="Leaf.formatDate" width="80" prompt="收款日期"/>
                             <!--   <a:column name="exchange_rate" align="right"/>
                                <a:column name="exchange_rate_type_desc"/>-->
                            </a:columns>
                        </a:grid>
                    </a:tab>
                </a:tabs>
            </a:tabPanel>
            <a:fieldSet title="ACR.GROUP_BILLING_METHOD">
                <a:radio name="group_billing_method" bindTarget="headDs" labelField="code_value_name" options="/model/group_billing_method_list" prompt="" radioSeparator="" valueField="code_value" width="600"/>
            </a:fieldSet>
        </a:screenBody>
    </a:view>
</a:screen>