Bläddra i källkod

1. 暂存计量,计量上限相关
2. 自动调用变更令,计量上限相关,不计价相关

MaiXinRong 1 år sedan
förälder
incheckning
3d48b882b0
2 ändrade filer med 11 tillägg och 4 borttagningar
  1. 2 1
      app/service/stage_change.js
  2. 9 3
      app/service/stage_change_final.js

+ 2 - 1
app/service/stage_change.js

@@ -89,9 +89,10 @@ class autoUseChange {
         this.changeDetail.push({
             tid: this.default.tid, sid: this.default.sid,
             lid: billsPos.lid, pid: billsPos.pid + '', cid: bills.cid, cbid: bills.id,
-            qty: bills.valid_qty, stimes: 1, sorder: 0, unit_price: bills.unit_price, minus, no_value: false,
+            qty: bills.valid_qty, stimes: 1, sorder: 0, unit_price: bills.unit_price, minus, no_value: !bills.is_valuation,
         });
 
+        if (!bills.is_valuation) return;
         if (billsPos.pid !== '-1') {
             let cp = this.changePos[billsPos.pid];
             if (!cp) {

+ 9 - 3
app/service/stage_change_final.js

@@ -85,8 +85,10 @@ module.exports = app => {
             if (!changeBills) return undefined;
 
             const qty = parseFloat(changeBills.samount);
+            const qtyDecimal = this.ctx.helper.findDecimal(changeBills.unit);
+            const limitQty = this.ctx.helper.mul(qty, this.ctx.helper.div(changeBills.delimit, 100, 2), qtyDecimal);
             const usedQty = await this.db.queryOne('Select SUM(qty) as qty FROM ' + this.tableName + ' WHERE cbid = ?', [cbid]);
-            return usedQty ? this.ctx.helper.sub(qty, usedQty.qty) : qty;
+            return usedQty ? this.ctx.helper.sub(limitQty, usedQty.qty) : limitQty;
         }
 
         async getListChangeBillsValidQty(tid, cbid) {
@@ -102,7 +104,9 @@ module.exports = app => {
 
             return changeBills.filter(cb => {
                 cb.qty = parseFloat(cb.samount);
-                cb.valid_qty = self.ctx.helper.sub(cb.qty, cb.used_qty);
+                const qtyDecimal = self.ctx.helper.findDecimal(changeBills.unit);
+                cb.limitQty = self.ctx.helper.mul(qty, self.ctx.helper.div(changeBills.delimit, 100, 2), qtyDecimal);
+                cb.valid_qty = self.ctx.helper.sub(cb.limitQty, cb.used_qty);
                 return cb.valid_qty;
             });
         }
@@ -120,7 +124,9 @@ module.exports = app => {
 
             return changeBills.filter(cb => {
                 cb.qty = parseFloat(cb.samount);
-                cb.valid_qty = self.ctx.helper.sub(cb.qty, cb.used_qty);
+                const qtyDecimal = self.ctx.helper.findDecimal(changeBills.unit);
+                cb.limitQty = self.ctx.helper.mul(qty, self.ctx.helper.div(changeBills.delimit, 100, 2), qtyDecimal);
+                cb.valid_qty = self.ctx.helper.sub(cb.limitQty, cb.used_qty);
                 return cb.valid_qty;
             });
         }