|
|
@@ -75,11 +75,20 @@ module.exports = app => {
|
|
|
where: { stage_id: preStage.id },
|
|
|
columns: costFields.editQueryFields
|
|
|
});
|
|
|
+ if (stage.rela_stage) throw '财务账面关联的成本报审数据错误';
|
|
|
+ const relaStage = JSON.parse(stage.rela_stage);
|
|
|
+ const curLedger = await this.ctx.service.costStageLedger.getAllDataByCondition({
|
|
|
+ where: { stage_id: relaStage.id },
|
|
|
+ columns: ['id', 'cost_id'],
|
|
|
+ });
|
|
|
const insertData = [];
|
|
|
for (const b of preBooks) {
|
|
|
b.id = this.uuid.v4();
|
|
|
b.stage_id = stage.id;
|
|
|
delete b.postil;
|
|
|
+ const cl = curLedger.find(x => { return x.cost_id === b.cost_id });
|
|
|
+ if (!cl) throw '财务账面关联的成本报审数据错误';
|
|
|
+ b.ledger_id = cl.id;
|
|
|
for(const prop of costFields.curFields) {
|
|
|
b['pre_' + prop] = this.ctx.helper.add(b['pre_' + prop], b[prop]);
|
|
|
b[prop] = 0;
|