|
@@ -146,61 +146,86 @@ module.exports = app => {
|
|
|
* @private
|
|
|
*/
|
|
|
async _addStagePosData(data) {
|
|
|
- let bills , precision;
|
|
|
+ let bills , precision, updateBills = null;
|
|
|
const result = {pos: [], ledger: []};
|
|
|
- const datas = data instanceof Array ? data : [data], calcBills = [], calcStageBills = [];
|
|
|
+ const datas = data instanceof Array ? data : [data], calcStageBills = [];
|
|
|
+ if (datas[0].sgfh_qty !== undefined || datas[0].sjcl_qty !== undefined || datas[0].qtcl_qty !== undefined
|
|
|
+ || datas[0].contract_qty !== undefined || datas[0].qc_qty !== undefined) {
|
|
|
+ bills = await this.ctx.service.ledger.getDataById(datas[0].lid);
|
|
|
+ precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, bills.unit);
|
|
|
+ result.ledger.push(bills.id);
|
|
|
+ }
|
|
|
+ if (datas[0].contract_qty !== undefined || datas[0].qc_qty !== undefined || datas[0].postil !== undefined) {
|
|
|
+ result.stageUpdate = true;
|
|
|
+ }
|
|
|
|
|
|
- const transaction = await this.db.beginTransaction();
|
|
|
- try {
|
|
|
- for (const d of datas) {
|
|
|
- if (d.sgfh_qty !== undefined || d.sjcl_qty !== undefined || d.qtcl_qty !== undefined) {
|
|
|
- if (!bills || bills.id !== data.lid) {
|
|
|
- bills = await this.ctx.service.ledger.getDataById(d.lid);
|
|
|
- precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, bills.unit);
|
|
|
- }
|
|
|
- }
|
|
|
- // 在主表pos中新增数据
|
|
|
- const p = {
|
|
|
- id: this.uuid.v4(), tid: this.ctx.tender.id, lid: d.lid, name: d.name, porder: d.porder, position: d.position,
|
|
|
- add_stage: this.ctx.stage.id,
|
|
|
- add_times: this.ctx.stage.curTimes,
|
|
|
- add_user: this.ctx.session.sessionUser.accountId,
|
|
|
- };
|
|
|
- if (d.sgfh_qty) p.sgfh_qty = this.round(d.sgfh_qty, precision.value);
|
|
|
- if (d.sjcl_qty) p.sjcl_qty = this.round(d.sjcl_qty, precision.value);
|
|
|
- if (d.qtcl_qty) p.qtcl_qty = this.round(d.qtcl_qty, precision.value);
|
|
|
+ const insertPos = [], insertPosStage = [];
|
|
|
+ for (const d of datas) {
|
|
|
+ const p = {
|
|
|
+ id: this.uuid.v4(), tid: this.ctx.tender.id, lid: d.lid, name: d.name, porder: d.porder, position: d.position,
|
|
|
+ add_stage: this.ctx.stage.id,
|
|
|
+ add_times: this.ctx.stage.curTimes,
|
|
|
+ add_user: this.ctx.session.sessionUser.accountId,
|
|
|
+ };
|
|
|
+ if (d.sgfh_qty !== undefined || d.sjcl_qty !== undefined || d.qtcl_qty !== undefined) {
|
|
|
+ if (d.sgfh_qty!== undefined) p.sgfh_qty = this.round(d.sgfh_qty, precision.value);
|
|
|
+ if (d.sjcl_qty!== undefined) p.sjcl_qty = this.round(d.sjcl_qty, precision.value);
|
|
|
+ if (d.qtcl_qty!== undefined) p.qtcl_qty = this.round(d.qtcl_qty, precision.value);
|
|
|
p.quantity = this.ctx.helper.sum([p.sgfh_qty, p.sjcl_qty, p.qtcl_qty]);
|
|
|
- const addRst = await transaction.insert(this.ctx.service.pos.tableName, p);
|
|
|
- result.pos.push(p.id);
|
|
|
- // 如果存在复核数据,更新计算主表清单
|
|
|
- if (p.sgfh_qty || p.sjcl_qty || p.qtcl_qty) {
|
|
|
- calcBills.push(p.lid);
|
|
|
- result.ledger.push(p.lid);
|
|
|
- }
|
|
|
- // 如果存在本期计算数据,更新计算清单本期计量数据
|
|
|
- if (d.contract_qty || d.qc_qty || d.postil) {
|
|
|
- const ps = {
|
|
|
- pid: p.id,
|
|
|
- lid: d.lid,
|
|
|
- tid: this.ctx.tender.id,
|
|
|
- sid: this.ctx.stage.id,
|
|
|
- said: this.ctx.session.sessionUser.accountId,
|
|
|
- times: this.ctx.stage.curTimes,
|
|
|
- order: this.ctx.stage.curOrder,
|
|
|
- };
|
|
|
- if (d.contract_qty) ps.contract_qty = this.round(d.contract_qty, precision.value);
|
|
|
- if (d.qc_qty) ps.qc_qty = this.round(d.qc_qty, precision.value);
|
|
|
- if (d.postil) ps.postil = d.postil;
|
|
|
- await transaction.insert(this.tableName, ps);
|
|
|
- if ((d.contract_qty || d.qc_qty) && calcStageBills.indexOf(ps.lid) === -1) {
|
|
|
- calcStageBills.push(ps.lid);
|
|
|
- }
|
|
|
- result.stageUpdate = true;
|
|
|
+ if (!updateBills) updateBills = {id: bills.id, sgfh_qty: bills.sgfh_qty, sjcl_qty: bills.sjcl_qty, qtcl_qty: bills.qtcl_qty};
|
|
|
+ }
|
|
|
+ insertPos.push(p);
|
|
|
+ result.pos.push(p.id);
|
|
|
+
|
|
|
+ if (d.contract_qty!== undefined || d.qc_qty!== undefined || d.postil!== undefined) {
|
|
|
+ const ps = {
|
|
|
+ pid: p.id,
|
|
|
+ lid: d.lid,
|
|
|
+ tid: this.ctx.tender.id,
|
|
|
+ sid: this.ctx.stage.id,
|
|
|
+ said: this.ctx.session.sessionUser.accountId,
|
|
|
+ times: this.ctx.stage.curTimes,
|
|
|
+ order: this.ctx.stage.curOrder,
|
|
|
+ };
|
|
|
+ if (d.contract_qty !== undefined) ps.contract_qty = this.round(d.contract_qty, precision.value);
|
|
|
+ if (d.qc_qty!== undefined) ps.qc_qty = this.round(d.qc_qty, precision.value);
|
|
|
+ if (d.postil!== undefined) ps.postil = d.postil;
|
|
|
+ insertPosStage.push(ps);
|
|
|
+ if ((d.contract_qty || d.qc_qty) && calcStageBills.indexOf(ps.lid) === -1) {
|
|
|
+ calcStageBills.push(ps.lid);
|
|
|
}
|
|
|
}
|
|
|
- for (const lid of calcBills) {
|
|
|
- await this.ctx.service.ledger.calc(this.ctx.tender.id, lid, transaction);
|
|
|
+ }
|
|
|
+ if (updateBills) {
|
|
|
+ for (const d of insertPos) {
|
|
|
+ if (d.sgfh_qty) {
|
|
|
+ d.sgfh_qty = this.ctx.helper.round(d.sgfh_qty, precision.value);
|
|
|
+ updateBills.sgfh_qty = this.ctx.helper.add(updateBills.sgfh_qty, d.sgfh_qty);
|
|
|
+ }
|
|
|
+ if (d.sjcl_qty) {
|
|
|
+ d.sjcl_qty = this.ctx.helper.round(d.sjcl_qty, precision.value);
|
|
|
+ updateBills.sjcl_qty = this.ctx.helper.add(updateBills.sjcl_qty, d.sjcl_qty);
|
|
|
+ }
|
|
|
+ if (d.qtcl_qty) {
|
|
|
+ d.qtcl_qty = this.ctx.helper.round(d.qtcl_qty, precision.value);
|
|
|
+ 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.sum([updateBills.sgfh_qty, updateBills.qtcl_qty, updateBills.sjcl_qty]);
|
|
|
+ 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 {
|
|
|
+ if (insertPos.length > 0) await transaction.insert(this.ctx.service.pos.tableName, insertPos);
|
|
|
+ if (updateBills) await transaction.update(this.ctx.service.ledger.tableName, updateBills);
|
|
|
+ if (insertPosStage.length > 0) await transaction.insert(this.tableName, insertPosStage);
|
|
|
+
|
|
|
for (const lid of calcStageBills) {
|
|
|
await this.ctx.service.stageBills.calc(this.ctx.tender.id, this.ctx.stage.id, lid, transaction);
|
|
|
}
|
|
@@ -221,89 +246,110 @@ module.exports = app => {
|
|
|
* @private
|
|
|
*/
|
|
|
async _updateStagePosData(data) {
|
|
|
- let bills, precision;
|
|
|
- const result = {ledger: [], pos: [], stageUpdate: true}, ledgerCalc = [];
|
|
|
+ let bills, precision, updateBills = null;
|
|
|
const datas = data instanceof Array ? data : [data];
|
|
|
const orgPos = await this.ctx.service.pos.getPosDataByIds(this._.map(datas, 'pid'));
|
|
|
+ const result = {ledger: [], pos: [], stageUpdate: true};
|
|
|
const orgStagePos = await this.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id,
|
|
|
{pid: this._.map(datas, 'pid')});
|
|
|
|
|
|
- const transaction = await this.db.beginTransaction();
|
|
|
- try {
|
|
|
- for (const d of datas) {
|
|
|
- if (d.sgfh_qty !== undefined || d.qtcl_qty !== undefined || d.sjcl_qty !== undefined
|
|
|
- || d.contract_qty !== undefined || d.qc_qty !== undefined) {
|
|
|
- if (!bills || bills.id !== data.lid) {
|
|
|
- bills = await this.ctx.service.ledger.getDataById(d.lid);
|
|
|
- precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, bills.unit);
|
|
|
- }
|
|
|
- }
|
|
|
- if (d.name !== undefined || d.drawing_code !== undefined || d.position !== undefined
|
|
|
- || d.sgfh_qty !== undefined || d.qtcl_qty !== undefined || d.sjcl_qty !== undefined) {
|
|
|
- const op = this._.find(orgPos, {id: d.pid});
|
|
|
- if (op.add_stage !== this.ctx.stage.id) throw '不可修改数据';
|
|
|
- const p = {id: d.pid};
|
|
|
- if (d.name !== undefined) p.name = d.name;
|
|
|
- if (d.position !== undefined) p.position = d.position;
|
|
|
- if (d.sgfh_qty !== undefined || d.qtcl_qty !== undefined || d.sjcl_qty !== undefined) {
|
|
|
- p.sgfh_qty = d.sgfh_qty !== undefined ? d.sgfh_qty : op.sgfh_qty;
|
|
|
- p.sjcl_qty = d.sjcl_qty !== undefined ? d.sjcl_qty : op.sjcl_qty;
|
|
|
- p.qtcl_qty = d.qtcl_qty !== undefined ? d.qtcl_qty : op.qtcl_qty;
|
|
|
- p.quantity = this.ctx.helper.sum([p.sgfh_qty, p.sjcl_qty, p.qtcl_qty]);
|
|
|
- if (ledgerCalc.indexOf(op.lid) === -1) {
|
|
|
- ledgerCalc.push(op.lid);
|
|
|
- }
|
|
|
- }
|
|
|
- if (d.drawing_code !== undefined) p.drawing_code = d.drawing_code;
|
|
|
- await transaction.update(this.ctx.service.pos.tableName, p);
|
|
|
+ if (datas[0].sgfh_qty !== undefined || datas[0].qtcl_qty !== undefined || datas[0].sjcl_qty !== undefined
|
|
|
+ || datas[0].contract_qty !== undefined || datas[0].qc_qty !== undefined) {
|
|
|
+ bills = await this.ctx.service.ledger.getDataById(datas[0].lid);
|
|
|
+ precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, bills.unit);
|
|
|
+ result.ledger.push(bills.id);
|
|
|
+ }
|
|
|
+ const updatePos = [], updatePosStage = [], insertPosStage = [];
|
|
|
+ for (const d of datas) {
|
|
|
+ if (d.name !== undefined || d.drawing_code !== undefined || d.position !== undefined
|
|
|
+ || d.sgfh_qty !== undefined || d.qtcl_qty !== undefined || d.sjcl_qty !== undefined) {
|
|
|
+
|
|
|
+ const op = this._.find(orgPos, {id: d.pid});
|
|
|
+ if (op.add_stage !== this.ctx.stage.id) throw '不可修改数据';
|
|
|
+
|
|
|
+ const p = {id: op.id};
|
|
|
+ if (d.name !== undefined) p.name = d.name;
|
|
|
+ if (d.position !== undefined) p.position = d.position;
|
|
|
+ if (d.sgfh_qty !== undefined || d.qtcl_qty !== undefined || d.sjcl_qty !== undefined) {
|
|
|
+ p.sgfh_qty = d.sgfh_qty !== undefined ? d.sgfh_qty : op.sgfh_qty;
|
|
|
+ p.sjcl_qty = d.sjcl_qty !== undefined ? d.sjcl_qty : op.sjcl_qty;
|
|
|
+ p.qtcl_qty = d.qtcl_qty !== undefined ? d.qtcl_qty : op.qtcl_qty;
|
|
|
+ p.quantity = this.ctx.helper.sum([p.sgfh_qty, p.sjcl_qty, p.qtcl_qty]);
|
|
|
+ if (!updateBills) updateBills = {id: bills.id};
|
|
|
}
|
|
|
+ if (d.drawing_code !== undefined) p.drawing_code = d.drawing_code;
|
|
|
+ updatePos.push(p);
|
|
|
+ }
|
|
|
|
|
|
- if (d.contract_qty !== undefined || d.qc_qty !== undefined || d.postil !== undefined) {
|
|
|
- const osp = this._.find(orgStagePos, function (p) { return p.pid === d.pid; });
|
|
|
- if (osp && osp.times === this.ctx.stage.curTimes && osp.order === this.ctx.stage.curOrder) {
|
|
|
- const sp = {};
|
|
|
- if (d.contract_qty !== undefined) {
|
|
|
- sp.contract_qty = this.ctx.helper.round(d.contract_qty, precision.value);
|
|
|
- }
|
|
|
- if (d.qc_qty !== undefined) {
|
|
|
- sp.qc_qty = this.ctx.helper.round(d.qc_qty, precision.value);
|
|
|
- }
|
|
|
- if (d.postil !== undefined) {
|
|
|
- sp.postil = d.postil;
|
|
|
- }
|
|
|
- await transaction.update(this.tableName, sp, {where: {id: osp.id}});
|
|
|
- } else {
|
|
|
- const sp = {
|
|
|
- pid: d.pid, lid: d.lid,
|
|
|
- tid: this.ctx.tender.id, sid: this.ctx.stage.id,
|
|
|
- said: this.ctx.session.sessionUser.accountId,
|
|
|
- times: this.ctx.stage.curTimes, order: this.ctx.stage.curOrder
|
|
|
- };
|
|
|
- if (d.contract_qty !== undefined || osp) {
|
|
|
- sp.contract_qty = d.contract_qty === undefined && osp
|
|
|
- ? osp.contract_qty
|
|
|
- : this.ctx.helper.round(d.contract_qty, precision.value);
|
|
|
- }
|
|
|
- if (d.qc_qty || osp) {
|
|
|
- sp.qc_qty = d.qc_qty === undefined && osp
|
|
|
- ? osp.qc_qty
|
|
|
- : this.ctx.helper.round(d.qc_qty, precision.value);
|
|
|
- }
|
|
|
- if (d.postil || osp) {
|
|
|
- sp.postil = d.postil === undefined && osp ? osp.postil : d.postil;
|
|
|
- }
|
|
|
- await transaction.insert(this.tableName, sp);
|
|
|
+ if (d.contract_qty !== undefined || d.qc_qty !== undefined || d.postil !== undefined) {
|
|
|
+ const osp = this._.find(orgStagePos, function (p) { return p.pid === d.pid; });
|
|
|
+ if (osp && osp.times === this.ctx.stage.curTimes && osp.order === this.ctx.stage.curOrder) {
|
|
|
+ const sp = {id: osp.id};
|
|
|
+ if (d.contract_qty !== undefined) {
|
|
|
+ sp.contract_qty = this.ctx.helper.round(d.contract_qty, precision.value);
|
|
|
}
|
|
|
- }
|
|
|
- result.pos.push(d.pid);
|
|
|
- if ((d.sgfh_qty !== undefined || d.qtcl_qty !== undefined || d.sjcl_qty !== undefined ||
|
|
|
- d.contract_qty === undefined || d.qc_qty === undefined)
|
|
|
- && (result.ledger.indexOf(d.lid) === -1)) {
|
|
|
- result.ledger.push(d.lid);
|
|
|
+ if (d.qc_qty !== undefined) {
|
|
|
+ sp.qc_qty = this.ctx.helper.round(d.qc_qty, precision.value);
|
|
|
+ }
|
|
|
+ if (d.postil !== undefined) {
|
|
|
+ sp.postil = d.postil;
|
|
|
+ }
|
|
|
+ updatePosStage.push(sp);
|
|
|
+ } else {
|
|
|
+ const sp = {
|
|
|
+ pid: d.pid, lid: d.lid,
|
|
|
+ tid: this.ctx.tender.id, sid: this.ctx.stage.id,
|
|
|
+ said: this.ctx.session.sessionUser.accountId,
|
|
|
+ times: this.ctx.stage.curTimes, order: this.ctx.stage.curOrder
|
|
|
+ };
|
|
|
+ if (d.contract_qty !== undefined || osp) {
|
|
|
+ sp.contract_qty = d.contract_qty === undefined && osp
|
|
|
+ ? osp.contract_qty
|
|
|
+ : this.ctx.helper.round(d.contract_qty, precision.value);
|
|
|
+ }
|
|
|
+ if (d.qc_qty || osp) {
|
|
|
+ sp.qc_qty = d.qc_qty === undefined && osp
|
|
|
+ ? osp.qc_qty
|
|
|
+ : this.ctx.helper.round(d.qc_qty, precision.value);
|
|
|
+ }
|
|
|
+ if (d.postil || osp) {
|
|
|
+ sp.postil = d.postil === undefined && osp ? osp.postil : d.postil;
|
|
|
+ }
|
|
|
+ insertPosStage.push(sp);
|
|
|
}
|
|
|
}
|
|
|
- for (const lid of ledgerCalc) {
|
|
|
- await this.ctx.service.ledger.calc(this.ctx.tender.id, lid, transaction);
|
|
|
+ result.pos.push(d.pid);
|
|
|
+ }
|
|
|
+ if (updateBills) {
|
|
|
+ const billsPos = await this.ctx.service.pos.getAllDataByCondition({where: {tid: bills.tender_id, lid: bills.id} });
|
|
|
+ for (const bp of billsPos) {
|
|
|
+ const newPos = updatePos.find(function (x) { return x.id === bp.id });
|
|
|
+ const calcData = newPos ? newPos : bp;
|
|
|
+ updateBills.sgfh_qty = this.ctx.helper.add(updateBills.sgfh_qty, calcData.sgfh_qty);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ 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 {
|
|
|
+ if (updatePos.length > 0) {
|
|
|
+ await transaction.updateRows(this.ctx.service.pos.tableName, updatePos);
|
|
|
+ }
|
|
|
+ if (updateBills) {
|
|
|
+ await transaction.update(this.ctx.service.ledger.tableName, updateBills);
|
|
|
+ }
|
|
|
+ if (updatePosStage.length > 0) {
|
|
|
+ await transaction.updateRows(this.tableName, updatePosStage);
|
|
|
+ }
|
|
|
+ if (insertPosStage.length > 0) {
|
|
|
+ await transaction.insert(this.tableName, insertPosStage);
|
|
|
}
|
|
|
for (const lid of result.ledger) {
|
|
|
await this.ctx.service.stageBills.calc(this.ctx.tender.id, this.ctx.stage.id, lid, transaction);
|
|
@@ -332,27 +378,40 @@ module.exports = app => {
|
|
|
if (p.add_stage !== this.ctx.stage.id /*|| p.add_times !== this.ctx.stage.curTimes || p.add_user !== this.ctx.session.sessionUser.accountId*/) {
|
|
|
throw '不可删除该数据';
|
|
|
}
|
|
|
+ if (p.lid !== pos[0].lid) {
|
|
|
+ throw '提交数据错误';
|
|
|
+ }
|
|
|
}
|
|
|
} 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 ledgerIds = this._.map(pos, 'lid');
|
|
|
+ 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});
|
|
|
- for (const lid of ledgerIds) {
|
|
|
- await this.ctx.service.ledger.calc(this.ctx.tender.id, lid, transaction);
|
|
|
- }
|
|
|
+ await transaction.update(this.ctx.service.ledger.tableName, updateBills);
|
|
|
// 删除部位明细计量数据
|
|
|
await transaction.delete(this.tableName, {tid: this.ctx.tender.id, lid: data});
|
|
|
- for (const lid of ledgerIds) {
|
|
|
- await this.ctx.service.stageBills.calc(this.ctx.tender.id, this.ctx.stage.id, lid, transaction);
|
|
|
- }
|
|
|
+ await this.ctx.service.stageBills.calc(this.ctx.tender.id, this.ctx.stage.id, bills.id, transaction);
|
|
|
await transaction.commit();
|
|
|
// 获取需要更新的数据
|
|
|
- result.ledger = ledgerIds;
|
|
|
+ result.ledger = [bills.id];
|
|
|
result.stageUpdate = true;
|
|
|
return result;
|
|
|
} catch (err) {
|