فهرست منبع

大司空数据四舍五入

ellisran 1 سال پیش
والد
کامیت
9d726e9004
1فایلهای تغییر یافته به همراه7 افزوده شده و 0 حذف شده
  1. 7 0
      app/controller/change_controller.js

+ 7 - 0
app/controller/change_controller.js

@@ -1658,6 +1658,13 @@ module.exports = app => {
         async _addDeal(ctx, data) {
             if (!data.type || !data.dealBills) throw '数据错误';
             data.dealBills.unit_price = this.ctx.helper.round(data.dealBills.unit_price, ctx.tender.info.decimal.up);
+            if (data.dealBills.quantity && data.dealBills.unit) {
+                const precision = ctx.helper.findPrecision(ctx.tender.info.precision, data.dealBills.unit);
+                data.dealBills.quantity = ctx.helper.round(data.dealBills.quantity, precision.value);
+                data.dealBills.sgfh_qty = data.dealBills.quantity;
+                data.dealBills.total_price = ctx.helper.mul(data.dealBills.quantity, data.dealBills.unit_price, ctx.tender.info.decimal.tp);
+                data.dealBills.sgfh_tp = data.dealBills.total_price;
+            }
             if (data.type === 'child') {
                 return await ctx.service.changeLedger.addChild(ctx.tender.id, data.id, data.dealBills, ctx.change.cid);
             } else if (data.type === 'next') {