|
@@ -178,6 +178,22 @@ module.exports = app => {
|
|
|
return await this.db.queryOne(sql, sqlParam);
|
|
|
}
|
|
|
|
|
|
+ _calcStageBillsData(data, orgData, ledgerData) {
|
|
|
+ const info = this.ctx.tender.info;
|
|
|
+ const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, ledgerData.unit);
|
|
|
+ if (data.contract_qty !== undefined) {
|
|
|
+ data.contract_qty = this.round(data.contract_qty, precision.value);
|
|
|
+ data.contract_tp = this.ctx.helper.mul(data.contract_qty, ledgerData.unit_price, info.decimal.tp);
|
|
|
+ }
|
|
|
+ if (data.qc_qty !== undefined) {
|
|
|
+ data.qc_qty = this.round(data.qc_qty, precision.value);
|
|
|
+ data.qc_tp = this.ctx.helper.mul(data.qc_qty, ledgerData.unit_price, info.decimal.tp);
|
|
|
+ }
|
|
|
+ if (ledgerData.is_tp && data.contract_tp !== undefined) {
|
|
|
+ data.contract_tp = this.ctx.helper.round(data.contract_tp, info.decimal.tp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
async _insertStageBillsData(transaction, insertData, orgData, ledgerData) {
|
|
|
const info = this.ctx.tender.info;
|
|
|
const d = {
|
|
@@ -195,8 +211,8 @@ module.exports = app => {
|
|
|
d.qc_tp = orgData.qc_tp;
|
|
|
d.postil = orgData.postil;
|
|
|
}
|
|
|
-
|
|
|
const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, ledgerData.unit);
|
|
|
+
|
|
|
if (insertData.contract_qty !== undefined) {
|
|
|
d.contract_qty = this.round(insertData.contract_qty, precision.value);
|
|
|
d.contract_tp = this.ctx.helper.mul(d.contract_qty, ledgerData.unit_price, info.decimal.tp);
|
|
@@ -231,6 +247,7 @@ module.exports = app => {
|
|
|
await this._insertStageBillsData(transaction, d, stageBills, ledgerBills);
|
|
|
} else {
|
|
|
d.id = stageBills.id;
|
|
|
+ this._calcStageBillsData(d, stageBills, ledgerBills);
|
|
|
await transaction.update(this.tableName, d);
|
|
|
}
|
|
|
}
|
|
@@ -257,6 +274,7 @@ module.exports = app => {
|
|
|
(data.qc_qty === undefined || stageBills.qc_qty !== data.qc_qty)) {
|
|
|
if (stageBills.times === this.ctx.stage.curTimes && stageBills.order === this.ctx.stage.curOrder) {
|
|
|
data.id = stageBills.id;
|
|
|
+ this._calcStageBillsData(data, stageBills, ledgerBills);
|
|
|
await transaction.update(this.tableName, data);
|
|
|
} else {
|
|
|
await this._insertStageBillsData(transaction, data, stageBills, ledgerBills);
|