MaiXinRong 2 дней назад
Родитель
Сommit
c08553a29a
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      app/service/cost_stage_analysis.js

+ 3 - 2
app/service/cost_stage_analysis.js

@@ -275,7 +275,6 @@ module.exports = app => {
                     for (const prop of costFields.selfCalcFields) {
                         ln[prop] = preSource ? preSource[prop] : 0;
                     }
-                    this.ctx.service.calcTmpl.calcByTemplate(ln, ln, ln, stage.calcTemplate.calc_expr);
                 } else {
                     for (const prop of costFields.sumFields) {
                         ln[prop] = 0;
@@ -298,13 +297,15 @@ module.exports = app => {
                             ld[prop] = preDetailSource ? preDetailSource[prop] || 0 : 0;
                         }
                         this.ctx.service.calcTmpl.calcByTemplate(ld, ld, ld, stage.calcTemplate.calc_expr);
+                        ld.sf_percent = ld.yf_excl_tax_tp ? this.ctx.helper.mul(this.ctx.helper.div(ld.sf_excl_tax_tp, ld.yf_excl_tax_tp), 100, 2) : 0;
                         for (const prop of costFields.sumFields) {
                             ln[prop] = this.ctx.helper.add(ln[prop], ld[prop]);
                         }
                         insertDetailData.push(ld);
                     }
-                    this.ctx.service.calcTmpl.calcByTemplate(ln, ln, ln, stage.calcTemplate.calc_expr);
                 }
+                this.ctx.service.calcTmpl.calcByTemplate(ln, ln, ln, stage.calcTemplate.calc_expr);
+                ln.sf_percent = ln.yf_excl_tax_tp ? this.ctx.helper.mul(this.ctx.helper.div(ln.sf_excl_tax_tp, ln.yf_excl_tax_tp), 100, 2) : 0;
             }
 
             await transaction.insert(this.tableName, insertData);