Przeglądaj źródła

Merge branch 'master' of http://192.168.1.41:3000/maixinrong/Calculation

MaiXinRong 5 lat temu
rodzic
commit
6d55cb5317

+ 4 - 0
app/controller/material_controller.js

@@ -260,6 +260,10 @@ module.exports = app => {
                 renderData.calcBase = await ctx.service.stage.getMaterialCalcBase(stage_list, ctx.tender.info);
                 // }
 
+                // 取当前期截止上期含税金额
+                renderData.pre_tp_hs = await ctx.service.material.getPreTpHs(ctx.tender.id, ctx.material.order);
+                console.log(renderData.pre_tp_hs);
+
                 renderData.materialType = JSON.stringify(materialConst);
                 renderData.jsFiles = this.app.jsFiles.common.concat(this.app.jsFiles.material.info);
                 await this.layout('material/info.ejs', renderData, 'material/info_modal.ejs');

+ 1 - 3
app/public/js/material.js

@@ -74,7 +74,7 @@ DatePickerCellType.prototype.updateEditor = function (editorContext, cellStyle,
 function resetTpTable() {
     const rate = $('#changeRate').val();
     const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), 2);
-    const jzbqhs = ZhCalc.round(ZhCalc.mul(ZhCalc.add(pre_tp, m_tp), 1+rate/100), 2);
+    const jzbqhs = ZhCalc.round(ZhCalc.add(pre_tp_hs, bqhs), 2);
     $('#tp_set').find('td').eq(1).text(ZhCalc.round(m_tp, 2));
     $('#tp_set').find('td').eq(2).text(ZhCalc.round(ZhCalc.add(pre_tp, m_tp), 2));
     $('#rate_set').find('td').eq(1).text(bqhs !== 0 ? bqhs : '');
@@ -334,8 +334,6 @@ $(document).ready(() => {
                 select.m_spread = materialCol.getValue.m_spread(select);
                 select.m_tp = materialCol.getValue.m_tp(select);
 
-                console.log(select);
-
                 // 更新至服务器
                 postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
                     m_tp = result.m_tp;

+ 13 - 0
app/service/material.js

@@ -230,6 +230,19 @@ module.exports = app => {
             };
             return await this.db.update(this.tableName, updateData);
         }
+
+        /**
+         * 修改增税税率
+         * @param {int} tid 标段id
+         * @param {int} order 调差期数
+         * @returns {Promise<*>}
+         */
+        async getPreTpHs(tid, order) {
+            const sql = 'SELECT SUM(ROUND(`m_tp`*(1+ `rate`/100),2)) AS `pre_tp_hs` FROM ?? WHERE `tid` = ? AND `order` < ?';
+            const sqlParam = [this.tableName, tid, order];
+            const result = await this.db.queryOne(sql, sqlParam);
+            return result.pre_tp_hs;
+        }
     }
 
     return Material;

+ 3 - 2
app/view/material/info.ejs

@@ -48,8 +48,8 @@
                         <div class="col-4 p-0">
                             <table class="table table-sm table-bordered">
                                 <tr><th></th><th>本期金额</th><th>截止本期金额</th></tr>
-                                <tr id="tp_set"><td>材料价差费用</td><td><%= material.m_tp !== null ? ctx.helper.round(material.m_tp, 2) : null %></td><td><%= material.m_tp !== null ? ctx.helper.round(ctx.helper.add(material.pre_tp, material.m_tp), 2) : null %></td></tr>
-                                <tr id="rate_set"><td>材料价差费用(含税)</td><td><%= material.m_tp !== null ? ctx.helper.round(ctx.helper.mul(material.m_tp, 1+material.rate/100), 2) : null %></td><td><%= material.m_tp !== null ? ctx.helper.round(ctx.helper.mul(ctx.helper.add(material.pre_tp, material.m_tp), 1+material.rate/100), 2) : null %></td></tr>
+                                <tr id="tp_set"><td>材料价差费用</td><td><%= material.m_tp !== null ? ctx.helper.round(material.m_tp, 2) : null %></td><td><%= material.m_tp !== null && material.pre_tp !== null ? ctx.helper.round(ctx.helper.add(material.pre_tp, material.m_tp), 2) : null %></td></tr>
+                                <tr id="rate_set"><td>材料价差费用(含税)</td><td><%= material.m_tp !== null ? ctx.helper.round(ctx.helper.mul(material.m_tp, 1+material.rate/100), 2) : null %></td><td><%= material.m_tp !== null && pre_tp_hs !== null ? ctx.helper.round(ctx.helper.add(pre_tp_hs, ctx.helper.round(ctx.helper.mul(material.m_tp, 1+material.rate/100), 2)), 2) : null %></td></tr>
                             </table>
                         </div>
                     </div>
@@ -78,5 +78,6 @@
     const materialID = <%- material.id %>;
     let m_tp = <%= material.m_tp !== null ? material.m_tp : 0 %>;
     const pre_tp = <%= material.pre_tp !== null ? material.pre_tp : 0 %>;
+    const pre_tp_hs = <%= pre_tp_hs !== null ? pre_tp_hs : 0 %>;
     const calcBase = JSON.parse('<%- JSON.stringify(calcBase) %>');
 </script>