|
@@ -71,6 +71,10 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
async _addDatas(data) {
|
|
|
+ const tpDecimal = this.ctx.tender.info.decimal.extra
|
|
|
+ ? this.ctx.tender.info.decimal.extraTp
|
|
|
+ : this.ctx.tender.info.decimal.tp;
|
|
|
+
|
|
|
const datas = data instanceof Array ? data : [data];
|
|
|
const insertData = [];
|
|
|
for (const d of datas) {
|
|
@@ -88,11 +92,11 @@ module.exports = app => {
|
|
|
const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, d.unit_price);
|
|
|
if (d.arrive_qty) {
|
|
|
nd.arrive_qty = this.ctx.helper.round(d.arrive_qty, precision.value);
|
|
|
- nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, nd.arrive_qty, this.ctx.tender.info.decimal.tp);
|
|
|
+ nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, nd.arrive_qty, tpDecimal);
|
|
|
}
|
|
|
if (d.deduct_qty) {
|
|
|
nd.deduct_qty = this.ctx.helper.round(d.deduct_qty, precision.value);
|
|
|
- nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, nd.deduct_qty, this.ctx.tender.info.decimal.tp);
|
|
|
+ nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, nd.deduct_qty, tpDecimal);
|
|
|
}
|
|
|
if (d.source) nd.source = d.source;
|
|
|
if (d.bills_code) nd.bills_code = d.bills_code;
|
|
@@ -117,6 +121,10 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
async _updateDatas (data) {
|
|
|
+ const tpDecimal = this.ctx.tender.info.decimal.extra
|
|
|
+ ? this.ctx.tender.info.decimal.extraTp
|
|
|
+ : this.ctx.tender.info.decimal.tp;
|
|
|
+
|
|
|
const datas = data instanceof Array ? data : [data];
|
|
|
const orgDatas = await this.getAllDataByCondition({sid: this.ctx.stage.id, id: this.ctx.helper._.map(datas, 'id')});
|
|
|
const info = this.ctx.tender.info;
|
|
@@ -137,15 +145,15 @@ module.exports = app => {
|
|
|
const precision = this.ctx.helper.findPrecision(info.precision, d.unit_price);
|
|
|
if (d.arrive_qty !== undefined) {
|
|
|
nd.arrive_qty = this.ctx.helper.round(d.arrive_qty, precision.value);
|
|
|
- nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, nd.arrive_qty, info.decimal.tp);
|
|
|
+ nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, nd.arrive_qty, tpDecimal);
|
|
|
} else if (d.unit_price !== undefined) {
|
|
|
- nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, od.arrive_qty, info.decimal.tp);
|
|
|
+ nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, od.arrive_qty, tpDecimal);
|
|
|
}
|
|
|
if (d.deduct_qty !== undefined) {
|
|
|
nd.deduct_qty = this.ctx.helper.round(d.deduct_qty, precision.value);
|
|
|
- nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, nd.deduct_qty, info.decimal.tp);
|
|
|
+ nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, nd.deduct_qty, tpDecimal);
|
|
|
} else if (d.unit_price !== undefined) {
|
|
|
- nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, od.deduct_qty, info.decimal.tp);
|
|
|
+ nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, od.deduct_qty, tpDecimal);
|
|
|
}
|
|
|
if (d.source !== undefined) nd.source = d.source;
|
|
|
if (d.bills_code !== undefined) nd.bills_code = d.bills_code;
|