| 
					
				 | 
			
			
				@@ -102,6 +102,17 @@ class BillsPosConvert { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    _calcPreContractTp(node, data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const info = this.ctx.tender.info; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const org_price = node.org_price || node.unit_price; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (info.calc_type === 'tp') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const activeQty = this.ctx.helper.add(data.quantity, data.pre_qc_minus_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const orgTotalPrice = this.ctx.helper.mul(data.quantity, org_price, info.decimal.tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return this.ctx.helper.mul(this.ctx.helper.div(data.pre_contract_qty, activeQty), orgTotalPrice, info.decimal.tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else if (info.calc_type === 'up') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return this.ctx.helper.mul(org_price, data.pre_contract_qty, info.decimal.tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // v2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     _loadPosCalcFields(node, data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         const tpDecimal = this.ctx.tender.info.decimal.tp; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -116,8 +127,9 @@ class BillsPosConvert { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         node.qc_tp = this.ctx.helper.add(node.qc_tp, this.ctx.helper.mul(node.unit_price, data.qc_qty, tpDecimal)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         node.gather_qty = this.ctx.helper.add(node.gather_qty, data.gather_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        data.pre_contract_tp = this._calcPreContractTp(node, data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         node.pre_contract_qty = this.ctx.helper.add(node.pre_contract_qty, data.pre_contract_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        node.pre_contract_tp = this.ctx.helper.add(node.pre_contract_tp, this.ctx.helper.mul(org_price, data.pre_contract_qty, tpDecimal)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        node.pre_contract_tp = this.ctx.helper.add(node.pre_contract_tp, data.pre_contract_tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         node.pre_qc_qty = this.ctx.helper.add(node.pre_qc_qty, data.pre_qc_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         node.pre_qc_tp = this.ctx.helper.add(node.pre_qc_tp, this.ctx.helper.mul(org_price, data.pre_qc_qty, tpDecimal)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         node.pre_gather_qty = this.ctx.helper.add(node.pre_gather_qty, data.pre_gather_qty); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -279,7 +291,7 @@ class BillsPosConvert { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         const priceDiff = child.org_price ? this.ctx.helper.sub(child.unit_price, child.org_price) : 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (priceDiff && (child.pre_contract_qty || child.pre_qc_qty)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            child.contract_pc_tp = this.ctx.helper.sub(this.ctx.helper.mul(child.unit_price, child.pre_contract_qty, this.ctx.tender.info.decimal.tp), child.pre_contract_tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (this.ctx.tender.info.calc_type === 'up') child.contract_pc_tp = this.ctx.helper.sub(this.ctx.helper.mul(child.unit_price, child.pre_contract_qty, this.ctx.tender.info.decimal.tp), child.pre_contract_tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             child.qc_pc_tp = this.ctx.helper.sub(this.ctx.helper.mul(child.unit_price, child.pre_qc_qty, this.ctx.tender.info.decimal.tp), child.pre_qc_tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             child.pc_tp = this.ctx.helper.add(child.contract_pc_tp, child.qc_pc_tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             child.gather_tp = this.ctx.helper.add(child.gather_tp, child.pc_tp); 
			 |