Browse Source

结算相关

MaiXinRong 1 year ago
parent
commit
5d47ae61d3

+ 4 - 0
app/controller/measure_controller.js

@@ -267,6 +267,10 @@ module.exports = app => {
                     tid: ctx.tender.id,
                 });
 
+                const readySettle = await ctx.service.settle.getReadySettle(stageInfo.tid);
+                if (readySettle && readySettle.final_sorder >= stageInfo.order) {
+                    throw '已结算,不可删除';
+                }
                 if (ctx.request.body.confirm !== undefined && ctx.request.body.confirm !== '确认删除本期') {
                     throw '请输入正确的文本信息';
                 }

+ 3 - 0
app/controller/stage_controller.js

@@ -1350,6 +1350,9 @@ module.exports = app => {
                 if (ctx.stage.revising) {
                     throw '台账修订中,请勿修改提交期数据';
                 }
+                if (ctx.stage.readySettle.final_sorder >= ctx.stage.order) {
+                    throw '已结算,不可重审';
+                }
 
                 if (ctx.query.confirm !== undefined && ctx.query.confirm !== '确认设置终审审批') {
                     throw '请输入正确的文本信息';

+ 3 - 2
app/lib/ledger.js

@@ -1101,6 +1101,7 @@ class reviseTree extends billsTree {
         });
     }
     checkRevisePrice(d) {
+        if (d.settle_status) return false;
         const helper = this.ctx.helper;
         const setting = this.setting;
         const pid = this.getAllParents(d).map(x => { return x[setting.id] + ''; });
@@ -1149,7 +1150,7 @@ class reviseTree extends billsTree {
             if (x.children && x.children.length > 0) {
                 return {
                     id: x.id, tender_id: x.tender_id, crid: x.crid,
-                    ledger_id: x.ledger_id, ledger_pid: x.ledger_pid, full_path: x.full_path, order: x.order, level: x.level, is_leaf: x.is_leaf,
+                    ledger_id: x.ledger_id, ledger_pid: x.ledger_pid, full_path: x.full_path, order: x.order, level: x.level, is_leaf: 0,
                     node_type: x.node_type, check_calc: x.check_calc,
                     code: x.code, b_code: x.b_code, name: x.name, unit: x.unit, position: x.position,
                     drawing_code: x.drawing_code, memo: x.memo, add_user: x.add_user, in_time: x.in_time,
@@ -1163,7 +1164,7 @@ class reviseTree extends billsTree {
             } else {
                 return {
                     id: x.id, tender_id: x.tender_id, crid: x.crid,
-                    ledger_id: x.ledger_id, ledger_pid: x.ledger_pid, full_path: x.full_path, order: x.order, level: x.level, is_leaf: x.is_leaf,
+                    ledger_id: x.ledger_id, ledger_pid: x.ledger_pid, full_path: x.full_path, order: x.order, level: x.level, is_leaf: 1,
                     node_type: x.node_type, check_calc: x.check_calc,
                     code: x.code, b_code: x.b_code, name: x.name, unit: x.unit, position: x.position,
                     drawing_code: x.drawing_code, memo: x.memo, add_user: x.add_user, in_time: x.in_time,

+ 6 - 1
app/lib/revise_price.js

@@ -211,8 +211,10 @@ class revisePriceCalc {
         let total_price = 0, positive_tp = 0, negative_tp = 0;
         for (const b of changeBills) {
             const p = this.findChangeBillsPrice(b.code, b.name, b.unit, b.unit_price, change.cid);
+            const settleGcl = p.gcl_id ? this.settleBills.find(x => { return x.lid === p.gcl_id; }) : null;
+            const settlePos = p.mx_id ? this.settlePos.find(x => { return x.pid === p.mx_id; }): null;
             let bills_tp;
-            if (p) {
+            if (p && !settleGcl && !settlePos) {
                 bills_tp = this.ctx.helper.mul(p.new_price, b.spamount, change.tp_decimal || decimal.tp);
                 updateBills.push({ id: b.id, unit_price: p.new_price, checked_price: bills_tp });
                 if (!p.rela_cid) p.his_rela_cid.push(change.cid);
@@ -376,6 +378,9 @@ class revisePriceCalc {
         if (revise.tid !== this.ctx.tender.id) throw '数据错误';
 
         this.price = await this.ctx.service.revisePrice.getAllDataByCondition({ where: { rid: revise.id } });
+        this.settleStatus = this.ctx.service.settle.settleStatus;
+        this.settleBills = await this.ctx.service.settleBills.getAllDataByCondition({ where: { settle_id: revise.readySettle.id, settle_status: settleStatus.finish } });
+        this.settlePos = await this.ctx.service.settlePos.getAllDataByCondition({ where: { settle_id: revise.readySettle.id }});
         const pcTp = await this.calcReviseLedger(revise, transaction);
         // 引用到所有工程变更
         await this.calcAllChanges(revise.tid, transaction);

+ 0 - 1
app/public/js/path_tree.js

@@ -1257,7 +1257,6 @@ const createNewPathTree = function (type, setting) {
             });
         }
         checkRevisePrice(d) {
-            if (d.b_code === '203-3-2') console.log(d);
             if (d.settle_status) return false;
             if (!this.price || this.price.length === 0) return false;
             const setting = this.setting;

+ 4 - 0
app/service/ledger_history.js

@@ -124,6 +124,10 @@ module.exports = app => {
                 await this.ctx.hisOss.put(this.ctx.hisOssPath + billsHis, Buffer.from(JSON.stringify(bills), 'utf8'));
                 await this.ctx.hisOss.put(this.ctx.hisOssPath + posHis, Buffer.from(JSON.stringify(pos), 'utf8'));
             } else {
+                const settleStatusBills = revise.readySettle ? await ctx.service.settleBills.getAllDataByCondition({ where: { settle_id: revise.readySettle.id }}): [];
+                this.ctx.helper.assignRelaData(bills, [
+                    { data: settleStatusBills, fields: ['settle_status'], prefix: '', relaId: 'lid' },
+                ]);
                 const reviseTree = new Ledger.reviseTree(this.ctx, { id: 'ledger_id', pid: 'ledger_pid', order: 'order', level: 'level', rootId: -1 });
                 reviseTree.loadRevisePrice(price, this.ctx.tender.info.decimal);
                 reviseTree.loadDatas(bills);