Просмотр исходного кода

财务账面,上期数据逻辑调整

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

+ 9 - 0
app/service/cost_stage_book.js

@@ -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;