|
@@ -208,6 +208,10 @@ module.exports = app => {
|
|
|
if (insertData.postil) {
|
|
|
d.postil = insertData.postil;
|
|
|
}
|
|
|
+ if (ledgerData.is_tp && insertData.contract_tp !== undefined) {
|
|
|
+ d.contract_tp = this.ctx.helper.round(insertData.contract_tp, info.decimal.tp);
|
|
|
+ }
|
|
|
+ console.log(d);
|
|
|
await transaction.insert(this.tableName, d);
|
|
|
}
|
|
|
|
|
@@ -217,22 +221,12 @@ module.exports = app => {
|
|
|
* @returns {Promise<void>}
|
|
|
*/
|
|
|
async updateStageData(data) {
|
|
|
- const info = this.ctx.tender.info;
|
|
|
const datas = data instanceof Array ? data : [data];
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
|
for (const d of datas) {
|
|
|
const stageBills = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, d.lid);
|
|
|
const ledgerBills = await this.ctx.service.ledger.getDataById(d.lid);
|
|
|
- const precision = this.ctx.helper.findPrecision(info.precision, ledgerBills.unit);
|
|
|
- if (d.contract_qty !== undefined) {
|
|
|
- d.contract_qty = this.round(d.contract_qty, precision.value);
|
|
|
- d.contract_tp = this.ctx.helper.mul(d.contract_qty, ledgerBills.unit_price, info.decimal.tp);
|
|
|
- }
|
|
|
- if (d.qc_qty !== undefined) {
|
|
|
- d.qc_qty = this.round(d.qc_qty, precision.value);
|
|
|
- d.qc_tp = this.ctx.helper.mul(d.qc_qty, ledgerBills.unit_price, info.decimal.tp);
|
|
|
- }
|
|
|
if (!stageBills || stageBills.times !== this.ctx.stage.curTimes || stageBills.order !== this.ctx.stage.curOrder) {
|
|
|
await this._insertStageBillsData(transaction, d, stageBills, ledgerBills);
|
|
|
} else {
|
|
@@ -258,29 +252,18 @@ module.exports = app => {
|
|
|
* @private
|
|
|
*/
|
|
|
async updateStageBillsQty(transaction, ledgerBills, stageBills, data) {
|
|
|
- const info = this.ctx.tender.info;
|
|
|
- const precision = this.ctx.helper.findPrecision(info.precision, ledgerBills.unit);
|
|
|
- const updateData = {};
|
|
|
- if (data.contract_qty !== undefined) {
|
|
|
- updateData.contract_qty = this.round(data.contract_qty, precision.value);
|
|
|
- updateData.contract_tp = this.ctx.helper.mul(updateData.contract_qty, ledgerBills.unit_price, info.decimal.tp);
|
|
|
- }
|
|
|
- if (data.qc_qty !== undefined) {
|
|
|
- updateData.qc_qty = this.round(data.qc_qty, precision.value);
|
|
|
- updateData.qc_tp = this.ctx.helper.mul(updateData.qc_qty, ledgerBills.unit_price, info.decimal.tp);
|
|
|
- }
|
|
|
if (stageBills) {
|
|
|
if ((updateData.contract_qty === undefined || stageBills.contract_qty !== updateData.contract_qty) ||
|
|
|
(updateData.qc_qty === undefined || stageBills.qc_qty !== updateData.qc_qty)) {
|
|
|
if (stageBills.times === this.ctx.stage.curTimes && stageBills.order === this.ctx.stage.curOrder) {
|
|
|
- updateData.id = stageBills.id;
|
|
|
- await transaction.update(this.tableName, updateData);
|
|
|
+ data.id = stageBills.id;
|
|
|
+ await transaction.update(this.tableName, data);
|
|
|
} else {
|
|
|
- await this._insertStageBillsData(transaction, updateData, stageBills, ledgerBills);
|
|
|
+ await this._insertStageBillsData(transaction, data, stageBills, ledgerBills);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- await this._insertStageBillsData(transaction, updateData, stageBills, ledgerBills);
|
|
|
+ await this._insertStageBillsData(transaction, data, stageBills, ledgerBills);
|
|
|
}
|
|
|
};
|
|
|
/**
|