Browse Source

计量台账,删除计量单元,不重算台账

MaiXinRong 3 years ago
parent
commit
564b600776
1 changed files with 3 additions and 19 deletions
  1. 3 19
      app/service/stage_pos.js

+ 3 - 19
app/service/stage_pos.js

@@ -463,7 +463,7 @@ module.exports = app => {
          */
         async _deleteStagePosData(data) {
             const pos = await this.ctx.service.pos.getPosData({tid: this.ctx.tender.id, id: data});
-            const result = { pos: data, isDeletePos: true};
+            const result = { pos: data, isDeletePos: true };
             if (pos instanceof Array) {
                 for (const p of pos) {
                     if (p.add_stage !== this.ctx.stage.id /*|| p.add_times !== this.ctx.stage.curTimes || p.add_user !== this.ctx.session.sessionUser.accountId*/) {
@@ -476,33 +476,17 @@ module.exports = app => {
             } else if (pos.add_stage !== this.ctx.stage.id /*|| pos.add_times !== this.ctx.stage.curTimes || pos.add_user !== this.ctx.session.sessionUser.accountId*/) {
                 throw '不可删除该数据';
             }
-            const bills = await this.ctx.service.ledger.getDataById(pos[0].lid);
-            const billsPos = await this.ctx.service.pos.getAllDataByCondition({ where: {tid: bills.tender_id, lid: bills.id} });
-            const updateBills = {id: bills.id, sgfh_qty: null, sjcl_qty: null, qtcl_qty: null, quantity: null};
-            for (const bp of billsPos) {
-                if (data.indexOf(bp.id) >= 0) continue;
-                updateBills.sgfh_qty = this.ctx.helper.add(updateBills.sgfh_qty, bp.sgfh_qty);
-                updateBills.sjcl_qty = this.ctx.helper.add(updateBills.sjcl_qty, bp.sjcl_qty);
-                updateBills.qtcl_qty = this.ctx.helper.add(updateBills.qtcl_qty, bp.qtcl_qty);
-                updateBills.quantity = this.ctx.helper.add(updateBills.quantity, bp.quantity);
-            }
-            const info = this.ctx.tender.info;
-            updateBills.sgfh_tp = this.ctx.helper.mul(updateBills.sgfh_qty, bills.unit_price, info.decimal.tp);
-            updateBills.sjcl_tp = this.ctx.helper.mul(updateBills.sjcl_qty, bills.unit_price, info.decimal.tp);
-            updateBills.qtcl_tp = this.ctx.helper.mul(updateBills.qtcl_qty, bills.unit_price, info.decimal.tp);
-            updateBills.total_price = this.ctx.helper.mul(updateBills.quantity, bills.unit_price, info.decimal.tp);
 
             const transaction = await this.db.beginTransaction();
             try {
                 // 删除部位明细
                 await transaction.delete(this.ctx.service.pos.tableName, {tid: this.ctx.tender.id, id: data});
-                await transaction.update(this.ctx.service.ledger.tableName, updateBills);
                 // 删除部位明细计量数据
                 await transaction.delete(this.tableName, {tid: this.ctx.tender.id, lid: data});
-                await this.ctx.service.stageBills.calc(this.ctx.tender.id, this.ctx.stage.id, bills.id, transaction);
+                await this.ctx.service.stageBills.calc(this.ctx.tender.id, this.ctx.stage.id, pos[0].lid, transaction);
                 await transaction.commit();
                 // 获取需要更新的数据
-                result.ledger = [bills.id];
+                result.ledger = [pos[0].lid];
                 result.stageUpdate = true;
                 return result;
             } catch (err) {