瀏覽代碼

调差上报判断

laiguoran 4 年之前
父節點
當前提交
4f839443cb
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      app/service/material_audit.js

+ 2 - 2
app/service/material_audit.js

@@ -213,8 +213,7 @@ module.exports = app => {
                 });
                 // 本期一些必要数据(如应耗数量和上期调差金额)插入到material_bills_history表里
                 const materialBillsData = await this.ctx.service.materialBills.getAllDataByCondition({ where: { tid: this.ctx.tender.id } });
-                const materialExponentData = await this.ctx.service.materialExponent.getAllDataByCondition({ where: { tid: this.ctx.tender.id } });
-                if (materialBillsData.length === 0 && materialExponentData.length === 0) {
+                if (materialBillsData.length === 0 && this.ctx.material.ex_expr === null) {
                     throw '请至少使用一种调差方式';
                 }
                 const mbhList = [];
@@ -243,6 +242,7 @@ module.exports = app => {
                 }
                 await transaction.insert(this.ctx.service.materialBillsHistory.tableName, mbhList);
 
+                const materialExponentData = await this.ctx.service.materialExponent.getAllDataByCondition({ where: { tid: this.ctx.tender.id } });
                 const mehList = [];
                 for (const me of materialExponentData) {
                     const newMeh = {