|
@@ -222,14 +222,12 @@ module.exports = app => {
|
|
|
const nd = { id: this.uuid.v4(), tender_id: this.ctx.tender.id };
|
|
|
nd.code = d.code;
|
|
|
nd.order = d.order;
|
|
|
- if (d.name) nd.name = d.name;
|
|
|
- if (d.unit) nd.unit = d.unit;
|
|
|
- if (d.unit_price) nd.unit_price = this.ctx.helper.round(d.unit_price, info.decimal.up);
|
|
|
+ nd.name = d.name || '';
|
|
|
+ nd.unit = d.unit || '';
|
|
|
+ nd.unit_price = d.unit_price ? this.ctx.helper.round(d.unit_price, info.decimal.up) : 0;
|
|
|
const precision = this.ctx.helper.findPrecision(info.precision, d.unit);
|
|
|
- if (d.quantity) {
|
|
|
- nd.quantity = this.ctx.helper.round(d.quantity, precision.value);
|
|
|
- nd.total_price = this.ctx.helper.mul(nd.unit_price, nd.quantity, info.decimal.tp);
|
|
|
- }
|
|
|
+ nd.quantity = d.quantity ? this.ctx.helper.round(d.quantity, precision.value) : 0;
|
|
|
+ nd.total_price = this.ctx.helper.mul(nd.unit_price, nd.quantity, info.decimal.tp);
|
|
|
insertData.push(nd);
|
|
|
}
|
|
|
const result = await this.db.insert(this.tableName, insertData);
|