|
@@ -127,8 +127,7 @@ module.exports = app => {
|
|
try {
|
|
try {
|
|
if (preMaterial) {
|
|
if (preMaterial) {
|
|
newMaterial.rate = preMaterial.rate;
|
|
newMaterial.rate = preMaterial.rate;
|
|
- newMaterial.pre_tp = preMaterial.m_tp + preMaterial.pre_tp;
|
|
|
|
- // 计算新一期本期金额
|
|
|
|
|
|
+ newMaterial.pre_tp = this.ctx.helper.add(preMaterial.m_tp, preMaterial.pre_tp);
|
|
}
|
|
}
|
|
// 新增期记录
|
|
// 新增期记录
|
|
const result = await transaction.insert(this.tableName, newMaterial);
|
|
const result = await transaction.insert(this.tableName, newMaterial);
|
|
@@ -137,17 +136,20 @@ module.exports = app => {
|
|
} else {
|
|
} else {
|
|
throw '新增期数据失败';
|
|
throw '新增期数据失败';
|
|
}
|
|
}
|
|
- // 存在上一期时,复制上一期审批流程、不参与调差的清单
|
|
|
|
|
|
+ // 存在上一期时,复制上一期审批流程、不参与调差的清单、上期清单并算本期有效价差,本期应耗数量,并算本期总金额
|
|
if (preMaterial) {
|
|
if (preMaterial) {
|
|
const auditResult = await this.ctx.service.materialAudit.copyPreMaterialAuditors(transaction, preMaterial, newMaterial);
|
|
const auditResult = await this.ctx.service.materialAudit.copyPreMaterialAuditors(transaction, preMaterial, newMaterial);
|
|
if (!auditResult) {
|
|
if (!auditResult) {
|
|
throw '复制上一期审批流程失败';
|
|
throw '复制上一期审批流程失败';
|
|
}
|
|
}
|
|
|
|
+ // 复制不参与调差清单
|
|
const preNotJoinList = await this.ctx.service.materialListNotjoin.getAllDataByCondition({ where: { tid: this.ctx.tender.id, mid: preMaterial.id } });
|
|
const preNotJoinList = await this.ctx.service.materialListNotjoin.getAllDataByCondition({ where: { tid: this.ctx.tender.id, mid: preMaterial.id } });
|
|
- const materialResult = await this.ctx.service.materialListNotjoin.copyNewStageNotJoinList(transaction, preNotJoinList, newMaterial.id);
|
|
|
|
- if (materialResult.affectedRows === 0) {
|
|
|
|
- throw '新增不参与调差清单数据失败';
|
|
|
|
- }
|
|
|
|
|
|
+ await this.ctx.service.materialListNotjoin.copyNewStageNotJoinList(transaction, preNotJoinList, newMaterial.id);
|
|
|
|
+ // 复制调差清单工料关联表
|
|
|
|
+ await this.ctx.service.materialList.copyPreMaterialList(transaction, preMaterial, newMaterial);
|
|
|
|
+ // 修改本期应耗数量值和有效价差,需要剔除不参与调差的清单数据
|
|
|
|
+ await this.ctx.service.materialBills.updateNewMaterial(transaction, preNotJoinList);
|
|
|
|
+ // 计算得出本期总金额
|
|
}
|
|
}
|
|
|
|
|
|
await transaction.commit();
|
|
await transaction.commit();
|