| 
					
				 | 
			
			
				@@ -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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 |