Browse Source

计量期,上报判断结算数据

MaiXinRong 1 year ago
parent
commit
22c9442a99
3 changed files with 69 additions and 0 deletions
  1. 1 0
      app/controller/stage_controller.js
  2. 67 0
      app/lib/ledger.js
  3. 1 0
      app/public/js/shares/cs_tools.js

+ 1 - 0
app/controller/stage_controller.js

@@ -436,6 +436,7 @@ module.exports = app => {
                         checkData.checkMinusChangeBills(change, changeBills, endStageChange);
                     }
                 }
+                checkData.checkSettle();
                 ctx.body = { err: 0, msg: '', data: checkData.checkResult };
             } catch (err) {
                 this.log(err);

+ 67 - 0
app/lib/ledger.js

@@ -1079,6 +1079,73 @@ class checkData {
             });
         });
     }
+
+    checkSettle() {
+        const settleStatus = this.ctx.service.settle.settleStatus;
+        for (const b of this.checkBills.nodes) {
+            if (b.children && b.children.length > 0) continue;
+            const pr = this.checkPos.getLedgerPos(b.id);
+            if (!pr || pr.length === 0) {
+                if (b.contract_qty || b.contract_tp || b.qc_qty || b.qc_minus_qty || b.positive_qc_qty || b.negative_qc_qty) {
+                    this.checkResult.error.push({
+                        ledger_id: b.ledger_id,
+                        b_code: b.b_code,
+                        name: b.name,
+                        errorType: 'settle',
+                    });
+                    if (!this.checkResult.source.bills.find(x => {return x.ledger_id === b.ledger_id})) {
+                        this.checkResult.source.bills.push(b);
+                        for (const p of pr) {
+                            this.checkResult.source.pos.push(p);
+                        }
+                    }
+                }
+            } else {
+                for (const p of pr) {
+                    if (p.settle_status !== settleStatus.finish)  continue;
+                    if (p.contract_qty || p.qc_qty || p.qc_minus_qty || p.positive_qc_qty || p.negative_qc_qty) {
+                        this.checkResult.error.push({
+                            ledger_id: b.ledger_id,
+                            b_code: b.b_code,
+                            name: b.name,
+                            errorType: 'settle',
+                        });
+                        if (!this.checkResult.source.bills.find(x => {return x.ledger_id === b.ledger_id})) {
+                            this.checkResult.source.bills.push(b);
+                            for (const p of pr) {
+                                this.checkResult.source.pos.push(p);
+                            }
+                        }
+                    }
+                }
+            }
+            const checkData = {},
+                calcData = {};
+            for (const field of fields) {
+                checkData[field] = b[field] ? b[field] : 0;
+            }
+            for (const p of pr) {
+                for (const field of fields) {
+                    calcData[field] = this.ctx.helper.add(calcData[field], p[field]);
+                }
+            }
+            if (!this.ctx.helper._.isMatch(checkData, calcData)) {
+                this.checkResult.error.push({
+                    ledger_id: b.ledger_id,
+                    b_code: b.b_code,
+                    name: b.name,
+                    errorType: 'qty',
+                    error: { checkData, calcData },
+                });
+                if (!this.checkResult.source.bills.find(x => {return x.ledger_id === b.ledger_id})) {
+                    this.checkResult.source.bills.push(b);
+                    for (const p of pr) {
+                        this.checkResult.source.pos.push(p);
+                    }
+                }
+            }
+        }
+    }
 }
 
 class reviseTree extends billsTree {

+ 1 - 0
app/public/js/shares/cs_tools.js

@@ -84,6 +84,7 @@ const showSelectTab = function(select, spread, afterShow) {
                                 case 's2b_lost_gxby': return '遗漏计量(工序报验)';
                                 case 's2b_lost_dagl': return '遗漏计量(档案管理)';
                                 case 'minus_cb': return '负变更清单漏计';
+                                case 'settle': return '结算清单';
                                 default: return '';
                             }
                         }