public int GetBatchNumber(IProductEntryDto tpoCProductRollDto) { int batchNumber = 0; if (tpoCProductRollDto.MasterRollID.HasValue) { TPOCProductRollDto masterRoll = Get(tpoCProductRollDto.MasterRollID.Value); return(masterRoll.BatchNumber); } else { bool newBatch = false; TPOBatchService batchService = new TPOBatchService(); List <TPOBatchDto> batch = batchService.GetByLineID(tpoCProductRollDto.LineID); if (batch == null || batch.Count == 0) { newBatch = true; } else { batchNumber = batch[0].BatchNumber; } TPOFormulationLineProductDto formulationLineProduct = GetFormulationLineProduct(tpoCProductRollDto); newBatch = CheckNewBatchRequirements(tpoCProductRollDto, newBatch, batchService, batch, formulationLineProduct); if (newBatch) { return(GetNewBatch(tpoCProductRollDto, ++batchNumber, formulationLineProduct.TPOFormulationID)); } else { return(batch[0].BatchNumber); } } }
private int GetScrimCountForBatch(TPOBatchService batchService, List <TPOBatchDto> batch) { return(batch.Count(s => s.IsScrim == true)); }
private int GetRawMaterialCountForBatch(TPOBatchService batchService, List <TPOBatchDto> batch) { return(batch.Count(s => s.IsScrim == false)); }
private bool CheckScrimRollCountsForBatch(IProductEntryDto tpoCProductRollDto, bool newBatch, TPOBatchService batchService, List <TPOBatchDto> batch) { int oldScrimCount = GetScrimCountForBatch(batchService, batch); int newScrimCount = GetTPOCurrentScrimCount(tpoCProductRollDto); if (oldScrimCount != newScrimCount) { newBatch = true; } return(newBatch); }
private bool CheckNewBatchRequirements(IProductEntryDto tpoCProductRollDto, bool newBatch, TPOBatchService batchService, List <TPOBatchDto> batch, TPOFormulationLineProductDto formulationLineProduct) { if (!newBatch) { newBatch = CheckFormulationForBatch(newBatch, batch, formulationLineProduct); } if (!newBatch) { newBatch = CheckScrimRollCountsForBatch(tpoCProductRollDto, newBatch, batchService, batch); } if (!newBatch) { newBatch = CheckScrimRollsForBatch(tpoCProductRollDto, newBatch); } if (!newBatch) { newBatch = CheckRawMaterialCountsForBatch(tpoCProductRollDto, newBatch, batchService, batch); } if (!newBatch) { newBatch = CheckRawMaterialsForBatch(tpoCProductRollDto, newBatch); } return(newBatch); }