Bladeren bron

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

TonyKang 3 jaren geleden
bovenliggende
commit
1a56dcc51f
3 gewijzigde bestanden met toevoegingen van 10 en 4 verwijderingen
  1. 7 1
      app/service/material.js
  2. 2 2
      app/service/material_bills.js
  3. 1 1
      app/view/material/info.ejs

+ 7 - 1
app/service/material.js

@@ -130,7 +130,7 @@ module.exports = app => {
                     newMaterial.rate = preMaterial.rate;
                     newMaterial.pre_tp = this.ctx.helper.add(preMaterial.m_tp, preMaterial.pre_tp);
                     newMaterial.ex_pre_tp = this.ctx.helper.add(preMaterial.ex_tp, preMaterial.ex_pre_tp);
-                    newMaterial.tax_pre_tp = this.ctx.helper.add(preMaterial.m_tax_tp, preMaterial.tax_pre_tp);
+                    newMaterial.m_tax_pre_tp = this.ctx.helper.add(preMaterial.m_tax_tp, preMaterial.m_tax_pre_tp);
                 }
                 // 新增期记录
                 const result = await transaction.insert(this.tableName, newMaterial);
@@ -335,6 +335,12 @@ module.exports = app => {
             const info = await this.getDataById(id);
             return info.m_tax_tp;
         }
+
+        async getSumMaterial(tid) {
+            const sql = 'Select sum(m_tp + ex_tp) as tp From ' + this.tableName + ' where tid = ?';
+            const result = await this.db.queryOne(sql, [tid]);
+            return result ? result.tp : 0;
+        }
     }
 
     return Material;

+ 2 - 2
app/service/material_bills.js

@@ -263,7 +263,7 @@ module.exports = app => {
                     m_tp: newTp,
                     pre_tp: mb.m_tp !== null ? this.ctx.helper.round(this.ctx.helper.add(mb.pre_tp, mb.m_tp), 2) : mb.pre_tp,
                     m_tax_tp: this.ctx.helper.round(this.ctx.helper.mul(newTp, (1 + this.ctx.helper.div(mb.m_tax, 100))), 2),
-                    m_tax_pre_tp: mb.m_tax_tp !== null ? this.ctx.helper.round(this.ctx.helper.add(mb.m_tax_pre_tp, mb.m_tax_tp), 2) : mb.m_tax_pre_tp,
+                    tax_pre_tp: mb.m_tax_tp !== null ? this.ctx.helper.round(this.ctx.helper.add(mb.tax_pre_tp, mb.m_tax_tp), 2) : mb.tax_pre_tp,
                 };
                 await transaction.update(this.tableName, updateData);
                 const m_tp = mb.is_summary === 1 ? await this.ctx.helper.round(this.ctx.helper.mul(mb_quantity.quantity, newm_spread), 2) : 0;
@@ -283,7 +283,7 @@ module.exports = app => {
                     m_tp: newTp,
                     pre_tp: mb.m_tp !== null ? this.ctx.helper.round(this.ctx.helper.add(mb.pre_tp, mb.m_tp), 2) : mb.pre_tp,
                     m_tax_tp: this.ctx.helper.round(this.ctx.helper.mul(newTp, (1 + this.ctx.helper.div(mb.m_tax, 100))), 2),
-                    m_tax_pre_tp: mb.m_tax_tp !== null ? this.ctx.helper.round(this.ctx.helper.add(mb.m_tax_pre_tp, mb.m_tax_tp), 2) : mb.m_tax_pre_tp,
+                    tax_pre_tp: mb.m_tax_tp !== null ? this.ctx.helper.round(this.ctx.helper.add(mb.tax_pre_tp, mb.m_tax_tp), 2) : mb.tax_pre_tp,
                 };
                 await transaction.update(this.tableName, updateData);
                 const m_tp = mb.is_summary === 1 ? await this.ctx.helper.round(this.ctx.helper.mul(quantity, newm_spread), 2) : 0;

+ 1 - 1
app/view/material/info.ejs

@@ -95,7 +95,7 @@
                                 </tr>
                                 <tr id="rate_set"><td>材料价差费用(含材料税)</td>
                                     <td class="text-center"><%= material.m_tax_tp !== null ? material.m_tax_tp : null %></td>
-                                    <td class="text-center"><%= material.m_tax_tp !== null || material.tax_pre_tp !== null ? ctx.helper.round(ctx.helper.add(material.tax_pre_tp, material.m_tax_tp), 2) : null %></td>
+                                    <td class="text-center"><%= material.m_tax_tp !== null || material.m_tax_pre_tp !== null ? ctx.helper.round(ctx.helper.add(material.m_tax_pre_tp, material.m_tax_tp), 2) : null %></td>
                                     <td class="text-center">-</td>
                                     <td class="text-center">-</td>
                                 </tr>