|  | @@ -409,7 +409,7 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                  const osp = this._.find(orgStagePos, function (p) { return p.pid === d.pid; });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  if (osp && osp.times === this.ctx.stage.curTimes && osp.order === this.ctx.stage.curOrder) {
 | 
	
		
			
				|  |  | -                    const sp = {id: osp.id};
 | 
	
		
			
				|  |  | +                    const sp = {id: osp.id, pid: osp.pid};
 | 
	
		
			
				|  |  |                      if (d.contract_qty !== undefined) {
 | 
	
		
			
				|  |  |                          sp.contract_qty = this.ctx.helper.round(d.contract_qty, b.precision.value);
 | 
	
		
			
				|  |  |                      }
 | 
	
	
		
			
				|  | @@ -437,14 +437,16 @@ module.exports = app => {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  const posStage = await this.getLastestStageData2(b.tender_id, this.ctx.stage.id, {lid: b.id});
 | 
	
		
			
				|  |  |                  let contract_qty = 0;
 | 
	
		
			
				|  |  | -                const newPosRange = data.filter(x => {return x.lid = b.id});
 | 
	
		
			
				|  |  | +                const newPosRange = insertPosStage.filter(x => {return x.lid = b.id});
 | 
	
		
			
				|  |  |                  for (const nps of newPosRange) {
 | 
	
		
			
				|  |  |                      contract_qty = this.ctx.helper.add(contract_qty, nps.contract_qty);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  for (const ps of posStage) {
 | 
	
		
			
				|  |  | -                    const nps = this._.find(datas, {pid: ps.pid});
 | 
	
		
			
				|  |  | -                    if (nps) continue;
 | 
	
		
			
				|  |  | -                    contract_qty = this.ctx.helper.add(contract_qty, ps.contract_qty);
 | 
	
		
			
				|  |  | +                    const ips = this._.find(insertPosStage, {pid: ps.pid});
 | 
	
		
			
				|  |  | +                    if (!ips) {
 | 
	
		
			
				|  |  | +                        const ups = this._.find(updatePosStage, {id: ps.id});
 | 
	
		
			
				|  |  | +                        contract_qty = this.ctx.helper.add(contract_qty, ups ? ups.contract_qty : ps.contract_qty);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  if (stageBills && stageBills.times === this.ctx.stage.curTimes && stageBills.order === this.ctx.stage.curOrder) {
 | 
	
		
			
				|  |  |                      if (contract_qty === stageBills.contract_qty) continue;
 |