| | |
| | | index++; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (int i = 0; i < stockInfos.Count; i++) |
| | | { |
| | | Dt_ProStockInfo stockInfo = stockInfos[i]; |
| | | float useableStockQuantity = stockInfo.proStockInfoDetails |
| | | .Where(x => x.SaleOrder == mesRworkOutboundOrder.SaleOrder |
| | | && x.ProductCode == mesRworkOutboundOrder.ProductCode |
| | | && x.ProductVersion == mesRworkOutboundOrder.ProductVersion |
| | | && (isCanDate ? isCanDate : x.DateCode == mesRworkOutboundOrder.DateCode)) |
| | | .Sum(x => x.StockPcsQty - x.OutboundQuantity); |
| | | if (useableStockQuantity < needQuantity) |
| | | { |
| | | stockInfo.proStockInfoDetails.ForEach(x => x.OutboundQuantity = x.StockPcsQty); |
| | | needQuantity -= useableStockQuantity; |
| | | } |
| | | else |
| | | { |
| | | stockInfo.proStockInfoDetails.ForEach(x => |
| | | { |
| | | if (x.StockPcsQty > x.OutboundQuantity && x.SaleOrder == mesRworkOutboundOrder.SaleOrder |
| | | && x.ProductCode == mesRworkOutboundOrder.ProductCode |
| | | && x.ProductVersion == mesRworkOutboundOrder.ProductVersion |
| | | && (isCanDate ? isCanDate : x.DateCode == mesRworkOutboundOrder.DateCode)) |
| | | { |
| | | if (x.StockPcsQty - x.OutboundQuantity >= needQuantity) |
| | | { |
| | | x.OutboundQuantity += needQuantity; |
| | | needQuantity = 0; |
| | | } |
| | | else |
| | | { |
| | | needQuantity -= (x.StockPcsQty - x.OutboundQuantity); |
| | | x.OutboundQuantity = x.StockPcsQty; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | assignOutStocks.Add(stockInfo); |
| | | } |
| | | } |
| | | residueQuantity = needQuantity; |
| | | return assignOutStocks; |
| | | } |