| 
					
				 | 
			
			
				@@ -244,6 +244,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         const nps = { tid: stage.tid, sid: stage.id, said, lid: b.id, pid: p.id, times: 1, order: 0 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         nps.contract_qty = this.ctx.helper.round(bp.contract_qty, decimal.qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         nps.qc_qty = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        nps.qc_minus_qty = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         nps.positive_qc_qty = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         nps.negative_qc_qty = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         insertPosData.push(nps); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -254,7 +255,11 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 const validQty = await this.ctx.service.stageChangeFinal.getChangeBillsValidQty(c.cbid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 ncs.qty = ncs.minus ? Math.max(validQty, c.qty) : Math.min(validQty, c.qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 insertChangeData.push(ncs); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                if (!ncs.no_value) nps.qc_qty = await this.ctx.helper.add(nps.qc_qty, ncs.qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if (!ncs.no_value) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    nps.qc_qty = this.ctx.helper.add(nps.qc_qty, ncs.qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    nps.qc_minus_qty = this.ctx.helper.add(nps.qc_minus_qty, ncs.qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 if (ncs.minus) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     nps.negative_qc_qty = this.ctx.helper.add(nps.negative_qc_qty, ncs.qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 } else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -264,8 +269,9 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         nbs.contract_qty = this.ctx.helper.add(nbs.contract_qty, nps.contract_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         nbs.qc_qty = this.ctx.helper.add(nbs.qc_qty, nps.qc_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        nbs.positive_qc_qty = this.ctx.helper.add(nbs.positive_qc_qty, nps.qc_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        nbs.negative_qc_qty = this.ctx.helper.add(nbs.negative_qc_qty, nps.qc_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        nbs.qc_minus_qty = this.ctx.helper.add(nbs.qc_minus_qty, nps.qc_minus_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        nbs.positive_qc_qty = this.ctx.helper.add(nbs.positive_qc_qty, nps.positive_qc_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        nbs.negative_qc_qty = this.ctx.helper.add(nbs.negative_qc_qty, nps.negative_qc_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     nbs.contract_tp = this.ctx.helper.mul(nbs.contract_qty, b.unit_price, decimal.tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     nbs.qc_tp = this.ctx.helper.mul(nbs.qc_qty, b.unit_price, decimal.tp); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -281,6 +287,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         nbs.contract_qty = this.ctx.helper.round(d.contract_qty, decimal.qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         nbs.contract_tp = this.ctx.helper.mul(nbs.contract_qty, b.unit_price, decimal.tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         nbs.qc_qty = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        nbs.qc_minus_qty = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         nbs.positive_qc_qty = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         nbs.negative_qc_qty = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         if (d.change) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -290,7 +297,11 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 const validQty = await this.ctx.service.stageChangeFinal.getChangeBillsValidQty(c.cbid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 ncs.qty = ncs.minus ? Math.max(validQty, c.qty) : Math.min(validQty, c.qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 insertChangeData.push(ncs); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                if (!ncs.no_value) nbs.qc_qty = this.ctx.helper.add(nbs.qc_qty, ncs.qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if (!ncs.no_value) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    nbs.qc_qty = this.ctx.helper.add(nbs.qc_qty, ncs.qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    nbs.qc_minus_qty = this.ctx.helper.add(nbs.qc_minus_qty, ncs.qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 if (ncs.minus) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     nbs.negative_qc_qty = this.ctx.helper.add(nbs.negative_qc_qty, ncs.qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 } else { 
			 |