|
@@ -429,12 +429,12 @@ module.exports = app => {
|
|
|
if (d.id) {
|
|
|
const changePosNum = await transaction.count(this.ctx.service.changePos.tableName, { lid: d.id });
|
|
|
const updateCol = {};
|
|
|
- if (column === 'gcl_id' && d.b_code !== undefined) updateCol.code = d.b_code;
|
|
|
- if (column === 'gcl_id' && d.sgfh_qty !== undefined && changePosNum === 0) updateCol.oamount = d.sgfh_qty ? d.sgfh_qty : 0;
|
|
|
+ if (column === 'gcl_id' && d.b_code) updateCol.code = d.b_code;
|
|
|
+ if (column === 'gcl_id' && d.quantity !== undefined && changePosNum === 0) updateCol.oamount = d.quantity ? d.quantity : 0;
|
|
|
if (column === 'gcl_id' && d.unit_price !== undefined) updateCol.unit_price = d.unit_price ? d.unit_price : 0;
|
|
|
if (column === 'gcl_id' && d.unit !== undefined) updateCol.unit = d.unit;
|
|
|
if (column === 'gcl_id' && d.name !== undefined) updateCol.name = d.name;
|
|
|
- if (d.code !== undefined && d.b_code === null) {
|
|
|
+ if (d.b_code !== undefined && d.b_code === null) {
|
|
|
// 清单升级成了项目节,故删除变更已有的此清单,并找出需要重新计算的变更令
|
|
|
const sql = 'SELECT `cid` FROM ?? WHERE `tid` = ? AND ' + column + ' = ? GROUP BY `cid`';
|
|
|
const params = [this.tableName, tid, d.id];
|
|
@@ -670,8 +670,9 @@ module.exports = app => {
|
|
|
if (d.id) {
|
|
|
const updateCol = {};
|
|
|
if (column === 'mx_id' && d.name !== undefined) updateCol.bwmx = d.name;
|
|
|
- if (column === 'mx_id' && d.sgfh_qty !== undefined) updateCol.oamount = d.sgfh_qty ? d.sgfh_qty : 0;
|
|
|
- if (column === 'mx_id' && d.sgfh_qty === undefined && d.sgfh_expr === '') updateCol.oamount = 0;
|
|
|
+ if (column === 'mx_id' && d.quantity !== undefined) updateCol.oamount = d.quantity ? d.quantity : 0;
|
|
|
+ if (column === 'mx_id' && d.quantity === undefined &&
|
|
|
+ ((d.sgfh_expr && d.sgfh_expr === '') || (d.sjcl_expr && d.sjcl_expr === '') || (d.qtcl_expr && d.qtcl_expr === ''))) updateCol.oamount = 0;
|
|
|
const options = {
|
|
|
row: {},
|
|
|
where: {},
|
|
@@ -682,7 +683,6 @@ module.exports = app => {
|
|
|
if (!this._.isEmpty(options.row)) updateArr.push(options);
|
|
|
}
|
|
|
}
|
|
|
- console.log(updateArr);
|
|
|
if (updateArr.length > 0) await transaction.updateRows(this.tableName, updateArr);
|
|
|
}
|
|
|
}
|
|
@@ -745,16 +745,22 @@ module.exports = app => {
|
|
|
if (this._.indexOf(changeLedgerGclIdList, data.lid) === -1) {
|
|
|
const info = this._.find(needUpdateLedgerList, { id: data.lid });
|
|
|
if (info) {
|
|
|
+ info.sgfh_qty = this.ctx.helper.add(info.sgfh_qty, data.sgfh_qty);
|
|
|
+ info.sjcl_qty = this.ctx.helper.add(info.sjcl_qty, data.sjcl_qty);
|
|
|
+ info.qtcl_qty = this.ctx.helper.add(info.qtcl_qty, data.qtcl_qty);
|
|
|
info.quantity = this.ctx.helper.add(info.quantity, data.quantity);
|
|
|
} else {
|
|
|
- needUpdateLedgerList.push({ id: data.lid, quantity: data.quantity });
|
|
|
+ needUpdateLedgerList.push({ id: data.lid, sgfh_qty: data.sgfh_qty, sjcl_qty: data.sjcl_qty, qtcl_qty: data.qtcl_qty, quantity: data.quantity });
|
|
|
}
|
|
|
} else {
|
|
|
const info = this._.find(needUpdateChangeLedgerList, { id: data.lid });
|
|
|
if (info) {
|
|
|
+ info.sgfh_qty = this.ctx.helper.add(info.sgfh_qty, data.sgfh_qty);
|
|
|
+ info.sjcl_qty = this.ctx.helper.add(info.sjcl_qty, data.sjcl_qty);
|
|
|
+ info.qtcl_qty = this.ctx.helper.add(info.qtcl_qty, data.qtcl_qty);
|
|
|
info.quantity = this.ctx.helper.add(info.quantity, data.quantity);
|
|
|
} else {
|
|
|
- needUpdateChangeLedgerList.push({ id: data.lid, quantity: data.quantity });
|
|
|
+ needUpdateChangeLedgerList.push({ id: data.lid, sgfh_qty: data.sgfh_qty, sjcl_qty: data.sjcl_qty, qtcl_qty: data.qtcl_qty, quantity: data.quantity });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -762,9 +768,13 @@ module.exports = app => {
|
|
|
if (needUpdateChangeLedgerList.length > 0) {
|
|
|
for (const nucl of needUpdateChangeLedgerList) {
|
|
|
const now = this._.find(result, { id: nucl.id });
|
|
|
+ now.sgfh_qty = nucl.sgfh_qty;
|
|
|
+ now.sjcl_qty = nucl.sjcl_qty;
|
|
|
+ now.qtcl_qty = nucl.qtcl_qty;
|
|
|
now.quantity = nucl.quantity;
|
|
|
- now.sgfh_qty = nucl.quantity;
|
|
|
now.sgfh_tp = this.ctx.helper.mul(now.sgfh_qty, now.unit_price, tpDecimal);
|
|
|
+ now.sjcl_tp = this.ctx.helper.mul(now.sjcl_qty, now.unit_price, tpDecimal);
|
|
|
+ now.qtcl_tp = this.ctx.helper.mul(now.qtcl_qty, now.unit_price, tpDecimal);
|
|
|
now.total_price = this.ctx.helper.mul(now.quantity, now.unit_price, tpDecimal);
|
|
|
}
|
|
|
}
|
|
@@ -772,9 +782,13 @@ module.exports = app => {
|
|
|
if (needUpdateLedgerList.length > 0) {
|
|
|
for (const nul of needUpdateLedgerList) {
|
|
|
const ledgerInfo = await this.ctx.service.ledger.getDataById(nul.id);
|
|
|
+ ledgerInfo.sgfh_qty = this.ctx.helper.add(ledgerInfo.sgfh_qty, nul.sgfh_qty);
|
|
|
+ ledgerInfo.sjcl_qty = this.ctx.helper.add(ledgerInfo.sjcl_qty, nul.sjcl_qty);
|
|
|
+ ledgerInfo.qtcl_qty = this.ctx.helper.add(ledgerInfo.qtcl_qty, nul.qtcl_qty);
|
|
|
ledgerInfo.quantity = this.ctx.helper.add(ledgerInfo.quantity, nul.quantity);
|
|
|
- ledgerInfo.sgfh_qty = this.ctx.helper.add(ledgerInfo.sgfh_qty, nul.quantity);
|
|
|
ledgerInfo.sgfh_tp = this.ctx.helper.mul(ledgerInfo.sgfh_qty, ledgerInfo.unit_price, tpDecimal);
|
|
|
+ ledgerInfo.sjcl_tp = this.ctx.helper.mul(ledgerInfo.sjcl_qty, ledgerInfo.unit_price, tpDecimal);
|
|
|
+ ledgerInfo.qtcl_tp = this.ctx.helper.mul(ledgerInfo.qtcl_qty, ledgerInfo.unit_price, tpDecimal);
|
|
|
ledgerInfo.total_price = this.ctx.helper.mul(ledgerInfo.quantity, ledgerInfo.unit_price, tpDecimal);
|
|
|
await transaction.update(this.ctx.service.ledger.tableName, ledgerInfo);
|
|
|
}
|