internal static void AssertEqual(this ProductionBatch productionBatch, IProductionResultSummaryReturn summaryReturn) { if (productionBatch == null) { throw new ArgumentNullException("productionBatch"); } if (summaryReturn == null) { throw new ArgumentNullException("summaryReturn"); } var productionResult = productionBatch.Production.Results; var lotKeyValue = new LotKey(productionResult).KeyValue; Assert.AreEqual(lotKeyValue, summaryReturn.ProductionResultKey); Assert.AreEqual(lotKeyValue, summaryReturn.ProductionBatchKey); Assert.AreEqual(lotKeyValue, summaryReturn.OutputLotNumber); Assert.AreEqual(new LocationKey(productionResult).KeyValue, summaryReturn.ProductionLineKey); Assert.AreEqual(new ChileProductKey(productionResult.Production.ResultingChileLot).KeyValue, summaryReturn.ChileProductKey); Assert.AreEqual(productionResult.Production.ResultingChileLot.ChileProduct.Product.Name, summaryReturn.ChileProductName); Assert.AreEqual(productionBatch.TargetParameters.BatchTargetWeight, summaryReturn.TargetBatchWeight); Assert.AreEqual(productionResult.ShiftKey, summaryReturn.ProductionShiftKey); Assert.AreEqual(productionBatch.PackSchedule.WorkType.Description, summaryReturn.WorkType); if (productionBatch.ProductionHasBeenCompleted) { Assert.AreEqual("Completed", summaryReturn.BatchStatus); } else { Assert.AreEqual("NotCompleted", summaryReturn.BatchStatus); } }
public void SetIncomingItems(ProductionBatch productionBatch, tblLot lot) { var currentIncoming = lot.tblIncomings.Where(i => i.TTypeID == (int?)TransType.Production).ToList(); var newIncoming = productionBatch.Production.Results.ResultItems.Select(CreateIncoming).ToList(); //EF has issue with tracking entities with duplicate or no primary keys and considering them equal. Answer seems to be to disable entity tracking on the object set. //http://stackoverflow.com/questions/4994203/unbelievable-duplicate-in-an-entity-framework-query // -RI 2016/2/1 var mergeOption = OldContext.ViewAvailables.MergeOption; OldContext.ViewAvailables.MergeOption = MergeOption.NoTracking; var inventory = OldContext.ViewAvailables.Where(i => i.Lot == lot.Lot).ToList(); OldContext.ViewAvailables.MergeOption = mergeOption; foreach (var modification in GetModifications(currentIncoming, newIncoming)) { var item = inventory.SingleOrDefault(i => i.LocID == modification.LocID && i.PkgID == modification.PkgID && i.TrtmtID == modification.TrtmtID); if ((item != null ? item.Quantity : 0) + modification.ModifyQuantity < 0) { throw new Exception(string.Format("Inventory Lot[{0}] PkgID[{1}] LocID[{2}] TrtmtID[{3}] would have resulted in negative quantity.", modification.Lot, modification.PkgID, modification.LocID, modification.TrtmtID)); } } currentIncoming.ForEach(i => OldContext.tblIncomings.DeleteObject(i)); newIncoming.ForEach(i => OldContext.tblIncomings.AddObject(i)); }
private static void UpdateLot(tblLot lot, ProductionBatch productionBatch) { lot.TargetWgt = (decimal?)productionBatch.TargetParameters.BatchTargetWeight; lot.TgtAsta = (decimal?)productionBatch.TargetParameters.BatchTargetAsta; lot.TgtScan = (decimal?)productionBatch.TargetParameters.BatchTargetScan; lot.TgtScov = (decimal?)productionBatch.TargetParameters.BatchTargetScoville; lot.Notes = productionBatch.Production.ResultingChileLot.Lot.Notes; }
public void SetOutgoingItems(ProductionBatch productionBatch, tblLot lot) { var currentOutgoing = lot.tblOutgoingInputs.Where(i => i.TTypeID == (int?)TransType.Production).ToList(); var newOutgoing = lot.inputBatchItems.Select(b => CreateOutgoingFromBatchItem(b, productionBatch)).ToList(); currentOutgoing.ForEach(o => OldContext.tblOutgoings.DeleteObject(o)); newOutgoing.ForEach(o => OldContext.tblOutgoings.AddObject(o)); }
public ValidationData ValidateUpdateProductionBatch(ClaimsPrincipal principal, ProductionBatch entity, UpdateProductionBatchModel model) { var validationData = new ValidationData(); if (model.TotalAmount <= 0) { validationData.Fail("Invalid total amount", Constants.AppResultCode.FailValidation); } return(validationData); }
internal static void SetTargetParameters(this ProductionBatch productionBatch, double asta, double scan, double scoville, double weight) { if (productionBatch == null) { throw new ArgumentNullException("productionBatch"); } productionBatch.TargetParameters.BatchTargetAsta = asta; productionBatch.TargetParameters.BatchTargetScan = scan; productionBatch.TargetParameters.BatchTargetScoville = scoville; productionBatch.TargetParameters.BatchTargetWeight = weight; }
private IEnumerable<tblBatchItem> CreateBatchItems(ProductionBatch batch, IDictionary<int, tblBOM> daBOMs) { var lotNumber = LotNumberParser.BuildLotNumber(batch); foreach(var pickedItem in batch.Production.PickedInventory.Items) { var availableQuantity = pickedItem.Quantity; var inventory = _unitOfWork.InventoryRepository.FindByKey(new InventoryKey(pickedItem)); if(inventory != null) { availableQuantity += inventory.Quantity; } var weight = pickedItem.PackagingProduct.Weight; var avaiableWeight = availableQuantity * weight; int? astaCalc = null; var asta = pickedItem.Lot.Attributes.FirstOrDefault(a => a.AttributeShortName == StaticAttributeNames.Asta.ShortName); if(asta != null) { var productionDate = asta.AttributeDate; if(batch.Production.Results != null) { productionDate = batch.Production.Results.ProductionEnd; } astaCalc = AstaCalculator.CalculateAsta(asta.AttributeValue, asta.AttributeDate, productionDate, DateTime.UtcNow); } yield return new tblBatchItem { EntryDate = pickedItem.PickedInventory.TimeStamp.ConvertUTCToLocal(), Lot = LotNumberParser.BuildLotNumber(pickedItem), TTypeID = (int?)TransType.Batching, PkgID = int.Parse(pickedItem.Lot.LotTypeEnum == LotTypeEnum.Packaging ? pickedItem.Lot.PackagingLot.PackagingProduct.Product.ProductCode : pickedItem.PackagingProduct.Product.ProductCode), Tote = pickedItem.ToteKey, Quantity = pickedItem.Quantity, NetWgt = (decimal?)weight, TtlWgt = (decimal?)(pickedItem.Quantity * weight), LocID = pickedItem.FromLocation.LocID.Value, TrtmtID = pickedItem.TreatmentId, EmployeeID = pickedItem.PickedInventory.EmployeeId, NewLot = lotNumber, BatchLot = lotNumber, AstaCalc = astaCalc, AvgAsta = asta == null ? null : (decimal?)asta.AttributeValue, //ODetail = PackSchID = batch.PackSchedule.PackSchID, AQ = availableQuantity, AW = (decimal?)avaiableWeight, LoBac = batch.Production.ResultingChileLot.AllAttributesAreLoBac, tblBOM = GetDaBOM(daBOMs, pickedItem) }; } }
internal static ProductionBatch SetToNotCompleted(this ProductionBatch productionBatch) { if (productionBatch == null) { throw new ArgumentNullException("productionBatch"); } productionBatch.ProductionHasBeenCompleted = false; productionBatch.Production.Results = null; return(productionBatch); }
public AppEvent ChangeProductionBatchStatus(ProductionBatch entity, ClaimsPrincipal principal) { string username = principal.FindFirstValue(AppClaimType.UserName); var ev = new AppEvent { Data = null, Description = $"User {username} changed production batch status: {entity.Status.DisplayName()} - id: {entity.Id}", Type = Data.Constants.AppEventType.ChangeProductionBatchStatus, UserId = principal.Identity.Name }; PrepareCreate(ev); return(context.AppEvent.Add(ev).Entity); }
public AppEvent DeleteProductionBatch(ProductionBatch entity, ClaimsPrincipal principal) { string username = principal.FindFirstValue(AppClaimType.UserName); var ev = new AppEvent { Data = null, Description = $"User {username} deleted production batch id: {entity.Id}", Type = Data.Constants.AppEventType.DeleteProductionBatch, UserId = principal.Identity.Name }; PrepareCreate(ev); return(context.AppEvent.Add(ev).Entity); }
public void SetResults(ProductionBatch productionBatch, tblLot lot) { var productionStart = productionBatch.Production.Results.ProductionBegin.ConvertUTCToLocal().RoundMillisecondsForSQL(); lot.Shift = productionBatch.Production.Results.ShiftKey; lot.Produced = productionStart.Date; // this is how they are expecting to find lots for entry of production results. -VK 2/19/14 lot.ProductionDate = productionBatch.LotDateCreated.Date; lot.BatchBegTime = productionStart; lot.BatchEndTime = productionBatch.Production.Results.ProductionEnd.ConvertUTCToLocal().RoundMillisecondsForSQL(); lot.ProductionLine = ProductionLineParser.GetProductionLineNumber(productionBatch.Production.Results.ProductionLineLocation); lot.BatchStatID = (int?)BatchStatID.Produced; SetIncomingItems(productionBatch, lot); SetOutgoingItems(productionBatch, lot); }
internal static ProductionBatch ConstrainByKeys(this ProductionBatch productionBatch, IPackScheduleKey packScheduleKey) { if (productionBatch == null) { throw new ArgumentNullException("productionBatch"); } if (packScheduleKey == null) { throw new ArgumentNullException("packScheduleKey"); } productionBatch.PackSchedule = null; productionBatch.PackScheduleDateCreated = packScheduleKey.PackScheduleKey_DateCreated; productionBatch.PackScheduleSequence = packScheduleKey.PackScheduleKey_DateSequence; return(productionBatch); }
private IDictionary<int, tblBOM> CreateDaBOMs(ProductionBatch batch, int lotNumber) { var ingredients = batch.Production.ResultingChileLot.ChileProduct.Ingredients.ToDictionary(i => i.AdditiveType.Id, i => i); var fgPercentage = 1.0; var daBoms = new Dictionary<int, tblBOM>(); if(batch.PackSchedule.WorkType.Description.ToUpper().Contains("NEW")) { foreach(var ingredient in ingredients) { fgPercentage -= ingredient.Value.Percentage; daBoms.Add(ingredient.Key, CreateDaBOM(lotNumber, ingredient.Key, (decimal)ingredient.Value.Percentage, batch.Production.PickedInventory)); } } else { daBoms.Add((int)Ingredient.Dextrose, CreateDaBOM(lotNumber, (int)Ingredient.Dextrose, 0, batch.Production.PickedInventory)); } daBoms.Add((int)Ingredient.Fbase, CreateDaBOM(lotNumber, (int)Ingredient.Fbase, (decimal)fgPercentage, batch.Production.PickedInventory)); foreach(var item in batch.Production.PickedInventory.Items) { var lotTypeIngredient = ToLotTypeIngredient(item.LotTypeId.ToLotType().Value); if(lotTypeIngredient != null) { if(!daBoms.ContainsKey((int)lotTypeIngredient)) { daBoms.Add((int)lotTypeIngredient, CreateDaBOM(lotNumber, (int)lotTypeIngredient, 0, batch.Production.PickedInventory)); } } else { var additiveLot = _unitOfWork.AdditiveLotRepository.FilterByKey(new LotKey(item), a => a.AdditiveProduct).FirstOrDefault(); if(additiveLot != null) { if(!daBoms.ContainsKey(additiveLot.AdditiveProduct.AdditiveTypeId)) { daBoms.Add(additiveLot.AdditiveProduct.AdditiveTypeId, CreateDaBOM(lotNumber, additiveLot.AdditiveProduct.AdditiveTypeId, 0, batch.Production.PickedInventory)); } } } } return daBoms; }
internal static ProductionBatch SetOutputLot(this ProductionBatch productionBatch, ILotKey lotKey) { if (productionBatch == null) { throw new ArgumentNullException("productionBatch"); } if (lotKey == null) { throw new ArgumentNullException("lotKey"); } productionBatch.Production.ResultingChileLot = null; productionBatch.LotDateCreated = lotKey.LotKey_DateCreated; productionBatch.LotDateSequence = lotKey.LotKey_DateSequence; productionBatch.LotTypeId = lotKey.LotKey_LotTypeId; return(productionBatch); }
internal static ProductionBatch EmptyItems(this ProductionBatch productionBatch) { if (productionBatch == null) { throw new ArgumentNullException("productionBatch"); } if (productionBatch.Production.PickedInventory != null) { productionBatch.Production.PickedInventory.EmptyItems(); } if (productionBatch.Production.ResultingChileLot != null) { productionBatch.Production.ResultingChileLot.Lot.EmptyLot(); } return(productionBatch); }
public void ChangeProductionBatchStatus(ProductionBatch entity, ChangeProductionBatchStatusModel model) { if (model.Status == Data.Constants.BatchStatus.New) { throw new Exception("Invalid status change"); } switch (model.Status) { case Data.Constants.BatchStatus.Started: entity.StartedTime = DateTime.UtcNow; break; case Data.Constants.BatchStatus.Finished: entity.FinishedTime = DateTime.UtcNow; break; } entity.Status = model.Status; PrepareUpdate(entity); }
public void SetBOMBatchItems(ProductionBatch productionBatch, tblLot lot) { foreach(var item in lot.inputBatchItems.ToList()) { _oldContext.tblBatchItems.DeleteObject(item); } foreach(var bom in lot.tblBOMs.ToList()) { _oldContext.tblBOMs.DeleteObject(bom); } var newBOMs = CreateDaBOMs(productionBatch, lot.Lot); foreach(var newBOM in newBOMs) { _oldContext.tblBOMs.AddObject(newBOM.Value); } foreach(var batchItem in CreateBatchItems(productionBatch, newBOMs)) { _oldContext.tblBatchItems.AddObject(batchItem); } SetLotAttributes(productionBatch, lot); }
private tblLot CreateNewLot(LotNumberResult lotNumber, ProductionBatch productionBatch) { var chileProduct = OldContextHelper.GetProduct(productionBatch.PackSchedule.ChileProduct); var productionLine = OldContextHelper.GetProductionLine(productionBatch.PackSchedule.ProductionLineLocation); var batchTypeId = BatchTypeIDHelper.GetBatchTypeID(productionBatch.PackSchedule.WorkType.Description); return(new tblLot { Lot = lotNumber, EmployeeID = productionBatch.Production.ResultingChileLot.Lot.EmployeeId, EntryDate = productionBatch.Production.ResultingChileLot.Lot.TimeStamp.ConvertUTCToLocal().RoundMillisecondsForSQL(), Notes = productionBatch.Production.ResultingChileLot.Lot.Notes, PTypeID = productionBatch.LotTypeId, Julian = lotNumber.Julian, BatchNum = productionBatch.LotDateSequence, ProdID = chileProduct.ProdID, PackSchID = productionBatch.PackSchedule.PackSchID, BatchTypeID = (int?)batchTypeId, Company_IA = productionBatch.PackSchedule.Customer == null ? null : productionBatch.PackSchedule.Customer.Company.Name, ProductionDate = productionBatch.PackSchedule.ScheduledProductionDate, ProductionLine = productionLine, BatchProdctnOrder = 0, //Seems constant in old context - RI 2014/4/16 SetTrtmtID = 0, LotStat = 0, BatchStatID = (int?)BatchStatID.Scheduled, TargetWgt = (decimal?)productionBatch.TargetParameters.BatchTargetWeight, TgtAsta = (decimal?)productionBatch.TargetParameters.BatchTargetAsta, TgtScan = (decimal?)productionBatch.TargetParameters.BatchTargetScan, TgtScov = (decimal?)productionBatch.TargetParameters.BatchTargetScoville, }); }
private IResult UpdatePickedItems(Employee employee, DateTime timeStamp, ProductionBatch productionBatch, List <PickedInventoryParameters> pickedInventoryChanges, ref List <ModifyInventoryParameters> inventoryModifications) { if (!pickedInventoryChanges.Any()) { return(new SuccessResult()); } var setItems = productionBatch.Production.PickedInventory.Items.Select(i => new PickedInventoryParameters(i)).ToList(); foreach (var change in pickedInventoryChanges) { var existing = setItems.FirstOrDefault(i => i.Match(change)); if (existing != null) { existing.Quantity += change.Quantity; } else { setItems.Add(change); } } return(new ProductionBatchPickInventoryConductor(_productionUnitOfWork).UpdatePickedWithoutModifyingInventory(employee, timeStamp, productionBatch, setItems, ref inventoryModifications)); }
protected void PrepareUpdate(ProductionBatch entity) { entity.LastUpdated = DateTime.UtcNow; }
public IDictionary <string, object> GetProductionBatchDynamic( ProductionBatch row, ProductionBatchQueryProjection projection, ProductionBatchQueryOptions options) { var obj = new Dictionary <string, object>(); foreach (var f in projection.GetFieldsArr()) { switch (f) { case ProductionBatchQueryProjection.INFO: { var entity = row; obj["id"] = entity.Id; obj["code"] = entity.Code; obj["info"] = entity.Info; obj["total_amount"] = entity.TotalAmount; obj["production_line_id"] = entity.ProductionLineId; obj["product_model_id"] = entity.ProductModelId; var time = entity.CreatedTime .ToDefaultTimeZone(); var timeStr = time.ToString(options.date_format); obj["created_time"] = new { display = timeStr, iso = $"{time.ToUniversalTime():s}Z" }; time = entity.LastUpdated .ToDefaultTimeZone(); timeStr = time.ToString(options.date_format); obj["last_updated"] = new { display = timeStr, iso = $"{time.ToUniversalTime():s}Z" }; obj["status"] = entity.Status; obj["status_display"] = entity.Status.DisplayName(); } break; case ProductionBatchQueryProjection.P_LINE: { var entity = row.Line; if (entity != null) { obj["production_line"] = new { id = entity.Id, code = entity.Code, disabled = entity.Disabled } } ; } break; case ProductionBatchQueryProjection.P_MODEL: { var entity = row.Model; if (entity != null) { obj["product_model"] = new { id = entity.Id, code = entity.Code, name = entity.Name, } } ; } break; case ProductionBatchQueryProjection.SELECT: { var entity = row; obj["id"] = entity.Id; obj["code"] = entity.Code; } break; } } return(obj); }
public ValidationData ValidateDeleteProductionBatch(ClaimsPrincipal principal, ProductionBatch entity) { return(new ValidationData()); }
public ValidationData ValidateChangeProductionBatchStatus(ClaimsPrincipal principal, ProductionBatch entity, ChangeProductionBatchStatusModel model) { return(new ValidationData()); }
public ProductionBatch DeleteProductionBatch(ProductionBatch entity) { return(context.ProductionBatch.Remove(entity).Entity); }
public void UpdateProductionBatch(ProductionBatch entity, UpdateProductionBatchModel model) { model.CopyTo(entity); PrepareUpdate(entity); }
public IResult <ProductionBatch> Execute(DateTime timestamp, CreateProductionBatchCommandParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } var packSchedule = _productionUnitOfWork.PackScheduleRepository.FindByKey(parameters.PackScheduleKey, p => p.ChileProduct); if (packSchedule == null) { return(new InvalidResult <ProductionBatch>(null, string.Format(UserMessages.PackScheduleNotFound, parameters.PackScheduleKey.KeyValue))); } var employeeResult = new GetEmployeeCommand(_productionUnitOfWork).GetEmployee(parameters.Parameters); if (!employeeResult.Success) { return(employeeResult.ConvertTo <ProductionBatch>()); } var createChileLotCommand = new CreateNewChileLotCommand(_productionUnitOfWork); var createChileLotResult = createChileLotCommand.Execute(new CreateNewChileLotCommandParameters { EmployeeKey = employeeResult.ResultingObject, TimeStamp = timestamp, PackagingReceivedKey = packSchedule, ChileProductKey = new ChileProductKey(packSchedule), LotType = parameters.Parameters.LotType ?? packSchedule.ChileProduct.ChileState.ToLotType(), LotDate = parameters.Parameters.LotDateCreated?.Date ?? timestamp, LotSequence = parameters.Parameters.LotSequence, SetLotProductionStatus = LotProductionStatus.Batched, SetLotQualityStatus = LotQualityStatus.Pending }); if (!createChileLotResult.Success) { return(createChileLotResult.ConvertTo <ProductionBatch>()); } var chileLot = createChileLotResult.ResultingObject; chileLot.Lot.Notes = parameters.Parameters.Notes.TrimTruncate(Constants.StringLengths.LotNotes); var productionResult = new CreateChileLotProductionCommand(_productionUnitOfWork).Execute(new CreateChileLotProduction { TimeStamp = timestamp, EmployeeKey = employeeResult.ResultingObject, LotKey = chileLot, ProductionType = ProductionType.ProductionBatch }); if (!productionResult.Success) { return(productionResult.ConvertTo <ProductionBatch>()); } var production = productionResult.ResultingObject; var notebookResult = new CreateNotebookCommand(_productionUnitOfWork).Execute(timestamp, employeeResult.ResultingObject, parameters.Parameters.Instructions); if (!notebookResult.Success) { return(notebookResult.ConvertTo <ProductionBatch>()); } var notebook = notebookResult.ResultingObject; var productionBatch = new ProductionBatch { EmployeeId = employeeResult.ResultingObject.EmployeeId, TimeStamp = timestamp, LotDateCreated = chileLot.LotDateCreated, LotDateSequence = chileLot.LotDateSequence, LotTypeId = chileLot.LotTypeId, PackScheduleDateCreated = parameters.PackScheduleKey.PackScheduleKey_DateCreated, PackScheduleSequence = parameters.PackScheduleKey.PackScheduleKey_DateSequence, InstructionNotebook = notebook, InstructionNotebookDateCreated = notebook.Date, InstructionNotebookSequence = notebook.Sequence, ProductionHasBeenCompleted = false, TargetParameters = new ProductionBatchTargetParameters(parameters.Parameters), Production = production }; _productionUnitOfWork.ProductionBatchRepository.Add(productionBatch); return(new SuccessResult <ProductionBatch>(productionBatch)); }
protected void PrepareCreate(ProductionBatch entity) { entity.Status = Data.Constants.BatchStatus.New; entity.CreatedTime = DateTime.UtcNow; entity.LastUpdated = entity.CreatedTime; }
public IResult UpdatePickedWithoutModifyingInventory(Employee employee, DateTime timeStamp, ProductionBatch productionBatch, List <PickedInventoryParameters> setPickedInventoryItems, ref List <ModifyInventoryParameters> pendingInventoryModifications) { var updateResult = UpdatePickedInventory(PickedInventoryValidator.ForProductionBatch, employee, timeStamp, productionBatch.Production.PickedInventory, setPickedInventoryItems, ref pendingInventoryModifications); if (!updateResult.Success) { return(updateResult); } return(new SetLotWeightedAttributesConductor(UnitOfWork).Execute(productionBatch.Production.ResultingChileLot, productionBatch.Production.PickedInventory.Items.ToList(), timeStamp)); }
private static void SetLotAttributes(ProductionBatch productionBatch, tblLot lot) { var lotAttributes = productionBatch.Production.ResultingChileLot.Lot.Attributes.ToList(); LotSyncHelper.SetLotAttributes(lot, lotAttributes); SetLotBatchAttributes(lot, lotAttributes); }
public static bool DeserializeIntoPackSchedule(PackSchedule packSchedule, string serializedPackSchedule, out int?pkgID) { pkgID = null; var deserialized = Deserialize(serializedPackSchedule); if (deserialized == null) { return(false); } var employeeKeyParser = new EmployeeKey(); var lotKeyParser = new LotKey(); pkgID = deserialized.PkgID; IEmployeeKey employeeKey; if (employeeKeyParser.TryParse(deserialized.EmployeeKey, out employeeKey)) { packSchedule.EmployeeId = employeeKey.EmployeeKey_Id; } packSchedule.TimeStamp = deserialized.TimeStamp; packSchedule.DefaultBatchTargetParameters = new ProductionBatchTargetParameters(deserialized.TargetParameters); packSchedule.ProductionBatches = deserialized.Batches.Select(b => { var lotKey = lotKeyParser.Parse(b.LotKey); var batchEmployeeKey = employeeKeyParser.Parse(b.EmployeeKey); var pickedEmployeeKey = employeeKeyParser.Parse(b.PickedInventory.EmployeeKey); var productionBatch = new ProductionBatch { EmployeeId = batchEmployeeKey.EmployeeKey_Id, TimeStamp = b.TimeStamp, LotDateCreated = lotKey.LotKey_DateCreated, LotDateSequence = lotKey.LotKey_DateSequence, LotTypeId = lotKey.LotKey_LotTypeId, PackScheduleDateCreated = packSchedule.DateCreated, PackScheduleSequence = packSchedule.SequentialNumber, ProductionHasBeenCompleted = false, TargetParameters = new ProductionBatchTargetParameters(b.TargetParameters), Production = new ChileLotProduction { EmployeeId = batchEmployeeKey.EmployeeKey_Id, TimeStamp = b.TimeStamp, LotDateCreated = lotKey.LotKey_DateCreated, LotDateSequence = lotKey.LotKey_DateSequence, LotTypeId = lotKey.LotKey_LotTypeId, ProductionType = ProductionType.ProductionBatch, PickedInventory = new Models.PickedInventory { EmployeeId = pickedEmployeeKey.EmployeeKey_Id, TimeStamp = b.PickedInventory.TimeStamp, PickedReason = PickedReason.Production, Archived = false, Items = new List <PickedInventoryItem>() } } }; return(productionBatch); }).ToList(); return(true); }