Преглед изворни кода

变更台账,计量单元,计算1相关

MaiXinRong пре 2 месеци
родитељ
комит
13a692ed42
1 измењених фајлова са 31 додато и 5 уклоњено
  1. 31 5
      app/service/change_pos.js

+ 31 - 5
app/service/change_pos.js

@@ -30,7 +30,7 @@ module.exports = app => {
                 columns: ['id', 'tid', 'lid', 'name', 'quantity', 'position', 'drawing_code', 'sgfh_qty', 'sjcl_qty',
                     'qtcl_qty', 'in_time', 'porder', 'add_stage', 'sgfh_expr', 'sjcl_expr', 'qtcl_expr', 'real_qty',
                     'dagl_status', 'dagl_url', 'gxby_status', 'gxby_limit', 'dagl_limit', 'dagl_status',
-                    'ex_memo1', 'ex_memo2', 'ex_memo3', 'ccid', 'formc'],
+                    'ex_memo1', 'ex_memo2', 'ex_memo3', 'ccid', 'formc', 'ex_qty1'],
                 order: [['porder', 'ASC']],
             });
         }
@@ -77,7 +77,7 @@ module.exports = app => {
         }
 
         async updatePos(tid, data) {
-            if (data.sgfh_qty !== undefined || data.sjcl_qty !== undefined || data.qtcl_qty !== undefined) {
+            if (data.sgfh_qty !== undefined || data.sjcl_qty !== undefined || data.qtcl_qty !== undefined || data.ex_qty1 !== undefined) {
                 const op = await this.getDataById(data.id);
                 let bills = await this.ctx.service.changeLedger.getDataById(op.lid);
                 let newBills = false;
@@ -107,6 +107,11 @@ module.exports = app => {
                     data.qtcl_qty = op.qtcl_qty;
                 }
                 data.quantity = this.ctx.helper.sum([data.sgfh_qty, data.qtcl_qty, data.sjcl_qty]);
+                if (data.ex_qty1 !== undefined) {
+                    data.ex_qty1 = this.round(data.ex_qty1, precision.value);
+                } else if (op) {
+                    data.ex_qty1 = op.ex_qty1;
+                }
 
                 const updateBills = { id: bills.id };
                 for (const bp of billsPos) {
@@ -115,12 +120,14 @@ module.exports = app => {
                     updateBills.sjcl_qty = this.ctx.helper.add(updateBills.sjcl_qty, calcData.sjcl_qty);
                     updateBills.qtcl_qty = this.ctx.helper.add(updateBills.qtcl_qty, calcData.qtcl_qty);
                     updateBills.quantity = this.ctx.helper.add(updateBills.quantity, calcData.quantity);
+                    updateBills.ex_qty1 = this.ctx.helper.add(updateBills.ex_qty1, calcData.ex_qty1);
                 }
                 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);
+                updateBills.ex_tp1 = this.ctx.helper.mul(updateBills.ex_qty1, bills.unit_price, info.decimal.tp);
                 const transaction = await this.db.beginTransaction();
                 try {
                     await transaction.update(this.tableName, data);
@@ -167,7 +174,7 @@ module.exports = app => {
             const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, bills.unit);
             let needUpdateBills;
             for (const d of data) {
-                if (d.sgfh_qty !== undefined || d.sjcl_qty !== undefined || d.qtcl_qty !== undefined) {
+                if (d.sgfh_qty !== undefined || d.sjcl_qty !== undefined || d.qtcl_qty !== undefined || d.ex_qty1 !== undefined) {
                     if (d.sgfh_qty !== undefined) {
                         d.sgfh_qty = this.round(d.sgfh_qty, precision.value);
                     } else if (op) {
@@ -184,6 +191,11 @@ module.exports = app => {
                         d.qtcl_qty = op.qtcl_qty;
                     }
                     d.quantity = this.ctx.helper.sum([d.sgfh_qty, d.qtcl_qty, d.sjcl_qty]);
+                    if (d.ex_qty1 !== undefined) {
+                        d.ex_qty1 = this.round(d.ex_qty1, precision.value);
+                    } else if (op) {
+                        d.ex_qty1 = op.ex_qty1;
+                    }
                     needUpdateBills = true;
                 }
             }
@@ -203,12 +215,16 @@ module.exports = app => {
                     updateBills.quantity = newPos && newPos.quantity !== undefined
                         ? this.ctx.helper.add(updateBills.quantity, newPos.quantity)
                         : this.ctx.helper.add(updateBills.quantity, bp.quantity);
+                    updateBills.ex_qty1 = newPos && newPos.ex_qty1 !== undefined
+                        ? this.ctx.helper.add(updateBills.ex_qty1, newPos.ex_qty1)
+                        : this.ctx.helper.add(updateBills.ex_qty1, bp.ex_qty1);
                 }
                 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);
+                updateBills.ex_tp1 = this.ctx.helper.mul(updateBills.ex_qty1, bills.unit_price, info.decimal.tp);
             }
 
             const transaction = await this.db.beginTransaction();
@@ -254,19 +270,21 @@ module.exports = app => {
             }
             // const bills = await this.ctx.service.reviseBills.getDataById(pos[0].lid);
             // const billsPos = await this.getAllDataByCondition({ where: {tid: tid, lid: bills.id} });
-            const updateBills = {id: bills.id, sgfh_qty: null, sjcl_qty: null, qtcl_qty: null, quantity: null};
+            const updateBills = {id: bills.id, sgfh_qty: 0, sjcl_qty: 0, qtcl_qty: 0, quantity: 0, ex_qty1: 0};
             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);
+                updateBills.ex_qty1 = this.ctx.helper.add(updateBills.ex_qty1, bp.ex_qty1);
             }
             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);
+            updateBills.ex_tp1 = this.ctx.helper.mul(updateBills.ex_qty1, bills.unit_price, info.decimal.tp);
 
             const transaction = await this.db.beginTransaction();
             try {
@@ -332,12 +350,13 @@ module.exports = app => {
                 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);
+                updateBills.ex_qty1 = this.ctx.helper.add(updateBills.ex_qty1, bp.ex_qty1);
             }
 
             try {
                 for (const d of data) {
                     const op = d.id ? this._.find(orgPos, { id: d.id }) : null;
-                    if (d.sgfh_qty !== undefined || d.sjcl_qty !== undefined || d.qtcl_qty !== undefined) {
+                    if (d.sgfh_qty !== undefined || d.sjcl_qty !== undefined || d.qtcl_qty !== undefined || d.ex_qty1 !== undefined) {
                         if (d.sgfh_qty !== undefined) {
                             d.sgfh_qty = this.round(d.sgfh_qty, precision.value);
                         } else if (op) {
@@ -358,6 +377,12 @@ module.exports = app => {
                         updateBills.qtcl_qty = this.ctx.helper.add(updateBills.qtcl_qty, d.qtcl_qty);
                         d.quantity = this.ctx.helper.sum([d.sgfh_qty, d.qtcl_qty, d.sjcl_qty]);
                         updateBills.quantity = this.ctx.helper.add(updateBills.quantity, d.quantity);
+                        if (d.ex_qty1) {
+                            d.ex_qty1 = this.round(d.ex_qty1, precision.value);
+                        } else if (op) {
+                            d.ex_qty1 = op.ex_qty1;
+                        }
+                        updateBills.ex_qty1 = this.ctx.helper.add(updateBills.ex_qty1, d.ex_qty1);
                         needUpdateBills = true;
                     }
                     if (d.id) {
@@ -373,6 +398,7 @@ module.exports = app => {
                     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);
+                    updateBills.ex_tp1 = this.ctx.helper.mul(updateBills.ex_qty1, bills.unit_price, info.decimal.tp);
                     if (newBills) {
                         const newUpdateBills = this._.cloneDeep(updateBills);
                         delete newUpdateBills.cid;