public IResult <InventoryPickOrder> Execute(IPickedInventoryKey pickedInventoryKey) { if (pickedInventoryKey == null) { throw new ArgumentNullException("pickedInventoryKey"); } var pickOrder = new InventoryPickOrder { DateCreated = pickedInventoryKey.PickedInventoryKey_DateCreated, Sequence = pickedInventoryKey.PickedInventoryKey_Sequence }; _inventoryPickOrderUnitOfWork.InventoryPickOrderRepository.Add(pickOrder); return(new SuccessResult().ConvertTo(pickOrder)); }
private PickedInventory CreatePickedInventory(IPickedInventoryKey pickedInventoryKey, tblRinconDTO rincon) { _loadCount.AddRead(EntityTypes.PickedInventory); var identifiable = rincon.tblRinconDetails.Cast <IEmployeeIdentifiableDTO>().ToList(); identifiable.Add(rincon); int? employeeID; DateTime?timestamp; identifiable.GetLatest(out employeeID, out timestamp); if (timestamp == null) { Log(new CallbackParameters(CallbackReason.PickedInventoryUndeterminedTimestamp) { Rincon = rincon }); return(null); } employeeID = employeeID ?? _newContextHelper.DefaultEmployee.EmployeeId; if (employeeID == _newContextHelper.DefaultEmployee.EmployeeId) { Log(new CallbackParameters(CallbackReason.PickedInventoryUsedDefaultEmployee) { Rincon = rincon, DefaultEmployeeID = employeeID.Value }); } return(new PickedInventory { EmployeeId = employeeID.Value, TimeStamp = timestamp.Value, DateCreated = pickedInventoryKey.PickedInventoryKey_DateCreated, Sequence = pickedInventoryKey.PickedInventoryKey_Sequence, Archived = true, PickedReason = PickedReason.IntraWarehouseMovement, Items = CreatePickedInventoryItems(pickedInventoryKey, rincon).ToList() }); }
private IEnumerable <PickedInventoryItem> CreatePickedInventoryItems(IPickedInventoryKey pickedInventoryKey, IEnumerable <OutgoingDTO> outgoings) { var pickedItemSequence = 0; foreach (var outgoing in outgoings) { _loadCount.AddRead(EntityTypes.PickedInventoryItem); LotKey lotKey; if (!LotNumberParser.ParseLotNumber(outgoing.Lot, out lotKey)) { Log(new CallbackParameters(CallbackReason.OutgoingInvalidLotNumber) { Outgoing = outgoing }); continue; } if (!_newContextHelper.LotLoaded(lotKey)) { Log(new CallbackParameters(CallbackReason.OutgoingLotNotLoaded) { Outgoing = outgoing }); continue; } var packagingProduct = outgoing.PTypeID == (int?)LotTypeEnum.Packaging ? _newContextHelper.NoPackagingProduct : _newContextHelper.GetPackagingProduct(outgoing.PkgID); if (packagingProduct == null) { Log(new CallbackParameters(CallbackReason.OutgoingPackagingNotLoaded) { Outgoing = outgoing }); continue; } var warehouseLocation = _newContextHelper.GetLocation(outgoing.LocID); if (warehouseLocation == null) { Log(new CallbackParameters(CallbackReason.OutgoingWarehouseLocationNotLoaded) { Outgoing = outgoing }); continue; } var treatment = _newContextHelper.GetInventoryTreatment(outgoing.TrtmtID); if (treatment == null) { Log(new CallbackParameters(CallbackReason.OutgoingTreatmentNotLoaded) { Outgoing = outgoing }); continue; } yield return(new PickedInventoryItem { DateCreated = pickedInventoryKey.PickedInventoryKey_DateCreated, Sequence = pickedInventoryKey.PickedInventoryKey_Sequence, ItemSequence = ++pickedItemSequence, LotDateCreated = lotKey.LotKey_DateCreated, LotDateSequence = lotKey.LotKey_DateSequence, LotTypeId = lotKey.LotKey_LotTypeId, PackagingProductId = packagingProduct.Id, FromLocationId = warehouseLocation.Id, TreatmentId = treatment.Id, CurrentLocationId = warehouseLocation.Id, ToteKey = outgoing.Tote ?? "", Quantity = (int)(outgoing.Quantity ?? 0), CustomerProductCode = outgoing.CustProductCode }); } }
internal IResult <List <PickedInventoryItem> > Execute(IPickedInventoryKey pickedInventoryKey, IEnumerable <ModifyPickedInventoryItemParameters> items) { if (pickedInventoryKey == null) { throw new ArgumentNullException("pickedInventoryKey"); } if (items == null) { throw new ArgumentNullException("items"); } var newItems = new List <PickedInventoryItem>(); foreach (var item in items) { if (item.PickedInventoryItemKey != null) { var notPendingResult = _unitOfWorkHelper.EntityHasNoPendingChanges(item.PickedInventoryItemKey, item.PickedInventoryItemKey); if (!notPendingResult.Success) { return(notPendingResult.ConvertTo <List <PickedInventoryItem> >()); } var pickedItem = _pickedInventoryUnitOfWork.PickedInventoryItemRepository.FindByKey(item.PickedInventoryItemKey); if (pickedItem == null) { return(new InvalidResult <List <PickedInventoryItem> >(null, string.Format(UserMessages.PickedInventoryItemNotFound, item.PickedInventoryItemKey.KeyValue))); } if (pickedItem.CurrentLocationId != pickedItem.FromLocationId) { return(new InvalidResult <List <PickedInventoryItem> >(null, string.Format(UserMessages.PickedInventoryItemNotInOriginalLocation, new PickedInventoryItemKey(pickedItem).KeyValue))); } pickedItem.Quantity = item.NewQuantity; pickedItem.CurrentLocationId = item.CurrentLocationKey.LocationKey_Id; pickedItem.CustomerLotCode = item.CustomerLotCode; pickedItem.CustomerProductCode = item.CustomerProductCode; if (pickedItem.Quantity < 0) { return(new InvalidResult <List <PickedInventoryItem> >(null, string.Format(UserMessages.QuantityForPickedCannotBeNegative, item.PickedInventoryItemKey.KeyValue))); } if (pickedItem.Quantity == 0) { _pickedInventoryUnitOfWork.PickedInventoryItemRepository.Remove(pickedItem); } else { newItems.Add(pickedItem); } } else { if (item.NewQuantity <= 0) { return(new InvalidResult <List <PickedInventoryItem> >(null, string.Format(UserMessages.QuantityForPickingFromInventoryMustBeGreaterThanZero, item.InventoryKey.KeyValue))); } var newSequence = _unitOfWorkHelper.GetNextSequence(PickedInventoryItemPredicates.FilterByPickedInventoryKey(pickedInventoryKey), i => i.ItemSequence); var newPickedInventoryItem = new PickedInventoryItem { DateCreated = pickedInventoryKey.PickedInventoryKey_DateCreated, Sequence = pickedInventoryKey.PickedInventoryKey_Sequence, ItemSequence = newSequence, LotDateCreated = item.InventoryKey.LotKey_DateCreated, LotDateSequence = item.InventoryKey.LotKey_DateSequence, LotTypeId = item.InventoryKey.LotKey_LotTypeId, PackagingProductId = item.InventoryKey.PackagingProductKey_ProductId, TreatmentId = item.InventoryKey.InventoryTreatmentKey_Id, ToteKey = item.InventoryKey.InventoryKey_ToteKey, FromLocationId = item.InventoryKey.LocationKey_Id, CurrentLocationId = item.CurrentLocationKey.LocationKey_Id, CustomerLotCode = item.CustomerLotCode, CustomerProductCode = item.CustomerProductCode, Quantity = item.NewQuantity }; newItems.Add(_pickedInventoryUnitOfWork.PickedInventoryItemRepository.Add(newPickedInventoryItem)); } } return(new SuccessResult <List <PickedInventoryItem> >(newItems)); }
private IEnumerable <PickedInventoryItem> CreatePickedInventoryItems(IPickedInventoryKey pickedInventoryKey, tblRinconDTO rincon) { var sequence = 0; foreach (var detail in rincon.tblRinconDetails) { _loadCount.AddRead(EntityTypes.PickedInventoryItem); LotKey lotKey; if (!LotNumberParser.ParseLotNumber(detail.Lot, out lotKey)) { Log(new CallbackParameters(CallbackReason.InvalidLotKey) { Detail = detail }); continue; } if (!_newContextHelper.LotLoaded(lotKey)) { Log(new CallbackParameters(CallbackReason.LotNotLoaded) { Detail = detail }); continue; } var packagingProduct = detail.PTypeID == (int?)LotTypeEnum.Packaging ? _newContextHelper.NoPackagingProduct : _newContextHelper.GetPackagingProduct(detail.PkgID); if (packagingProduct == null) { Log(new CallbackParameters(CallbackReason.PackagingNotLoaded) { Detail = detail }); continue; } var fromWarehouseLocation = _newContextHelper.GetLocation(detail.CurrLocID); if (fromWarehouseLocation == null) { Log(new CallbackParameters(CallbackReason.FromWarehouseLocationNotLoaded) { Detail = detail }); continue; } var treatment = _newContextHelper.GetInventoryTreatment(detail.TrtmtID); if (treatment == null) { Log(new CallbackParameters(CallbackReason.TreatmentNotLoaded) { Detail = detail }); continue; } var destinationLocation = _newContextHelper.GetLocation(detail.DestLocID); if (destinationLocation == null) { Log(new CallbackParameters(CallbackReason.DestinationLocationNotLoaded) { Detail = detail }); continue; } if (detail.Quantity == null) { Log(new CallbackParameters(CallbackReason.MissingQuantity) { Detail = detail }); continue; } yield return(new PickedInventoryItem { DateCreated = pickedInventoryKey.PickedInventoryKey_DateCreated, Sequence = pickedInventoryKey.PickedInventoryKey_Sequence, ItemSequence = ++sequence, LotDateCreated = lotKey.LotKey_DateCreated, LotDateSequence = lotKey.LotKey_DateSequence, LotTypeId = lotKey.LotKey_LotTypeId, PackagingProductId = packagingProduct.Id, FromLocationId = fromWarehouseLocation.Id, TreatmentId = treatment.Id, CurrentLocationId = destinationLocation.Id, ToteKey = "", Quantity = (int)detail.Quantity }); } }
public SalesOrderKey(IPickedInventoryKey pickedInventoryKey) : base(pickedInventoryKey.PickedInventoryKey_DateCreated, pickedInventoryKey.PickedInventoryKey_Sequence) { }
internal static PickedInventoryItem ConstrainByKeys(this PickedInventoryItem item, IPickedInventoryKey pickedInventoryKey = null, ILotKey lotKey = null, IPackagingProductKey packagingProductKey = null, IInventoryTreatmentKey treatmentKey = null, ILocationKey sourceLocationKey = null, ILocationKey currentLocationKey = null, string toteKey = null) { if (item == null) { throw new ArgumentNullException("item"); } if (pickedInventoryKey != null) { item.PickedInventory = null; item.DateCreated = pickedInventoryKey.PickedInventoryKey_DateCreated; item.Sequence = pickedInventoryKey.PickedInventoryKey_Sequence; } if (lotKey != null) { item.Lot = null; item.LotDateCreated = lotKey.LotKey_DateCreated; item.LotDateSequence = lotKey.LotKey_DateSequence; item.LotTypeId = lotKey.LotKey_LotTypeId; } if (packagingProductKey != null) { item.PackagingProduct = null; item.PackagingProductId = packagingProductKey.PackagingProductKey_ProductId; } if (treatmentKey != null) { item.Treatment = null; item.TreatmentId = treatmentKey.InventoryTreatmentKey_Id; } if (sourceLocationKey != null) { item.FromLocation = null; item.FromLocationId = sourceLocationKey.LocationKey_Id; } if (currentLocationKey != null) { item.CurrentLocation = null; item.CurrentLocationId = currentLocationKey.LocationKey_Id; } if (toteKey != null) { item.ToteKey = toteKey; } return(item); }
public static Expression <Func <PickedInventoryItem, bool> > FilterByPickedInventoryKey(IPickedInventoryKey pickedInventoryKey) { return(i => i.DateCreated == pickedInventoryKey.PickedInventoryKey_DateCreated && i.Sequence == pickedInventoryKey.PickedInventoryKey_Sequence); }
protected PickedInventory CreatePickedInventory(IPickedInventoryKey pickedInventoryKey, MovementOrderDTO order, ShipmentStatus shipmentStatus) { LoadCount.AddRead(EntityTypes.PickedInventory); int? employeeId = null; DateTime? timestamp = null; var latestMoveDetail = order.tblMoveDetails.OrderByDescending(d => d.MDetail).FirstOrDefault(); if(latestMoveDetail != null) { employeeId = latestMoveDetail.EmployeeID; timestamp = latestMoveDetail.MDetail.ConvertLocalToUTC(); } if(employeeId == null) { employeeId = employeeId ?? order.EmployeeID; timestamp = timestamp ?? order.EntryDate.ConvertLocalToUTC(); if(employeeId == null || timestamp == null) { var latestOutgoing = order.tblOutgoings.OrderByDescending(d => d.EntryDate).FirstOrDefault(); if(latestOutgoing != null) { employeeId = employeeId ?? latestOutgoing.EmployeeID; timestamp = timestamp ?? latestOutgoing.EntryDate.ConvertLocalToUTC(); } } } if(timestamp == null) { Log(new CallbackParameters(CallbackReason.PickedInventoryNoTimestamp) { MovementOrder = order }); return null; } employeeId = employeeId ?? NewContextHelper.DefaultEmployee.EmployeeId; if(employeeId == NewContextHelper.DefaultEmployee.EmployeeId) { Log(new CallbackParameters(CallbackReason.PickedInventoryDefaultEmployee) { MovementOrder = order, DefaultEmployeeId = employeeId.Value }); } return new PickedInventory { EmployeeId = employeeId.Value, TimeStamp = timestamp.Value, DateCreated = pickedInventoryKey.PickedInventoryKey_DateCreated, Sequence = pickedInventoryKey.PickedInventoryKey_Sequence, PickedReason = ((TransType)order.TTypeID).ToPickedReason(), Archived = order.Status > (int)tblOrderStatus.Staged, Items = CreatePickedInventoryItemsFromMoveDetails(pickedInventoryKey, order, shipmentStatus).ToList() }; }
private IEnumerable<PickedInventoryItem> CreatePickedInventoryItemsFromMoveDetails(IPickedInventoryKey pickedInventoryKey, MovementOrderDTO order, ShipmentStatus shipmentStatus) { var sequence = 0; var moveDetails = order.tblMoveDetails.ToList(); foreach(var moveDetail in moveDetails) { LoadCount.AddRead(EntityTypes.PickedInventoryItem); var lotKey = LotNumberParser.ParseLotNumber(moveDetail.Lot); if(lotKey == null) { Log(new CallbackParameters(CallbackReason.MoveDetailInvalidLotNumber) { MoveDetail = moveDetail }); continue; } if(!NewContextHelper.LotLoaded(lotKey)) { Log(new CallbackParameters(CallbackReason.MoveDetailLotNotLoaded) { MoveDetail = moveDetail }); continue; } var packaging = moveDetail.PType == (int?)LotTypeEnum.Packaging ? NewContextHelper.NoPackagingProduct : NewContextHelper.GetPackagingProduct(moveDetail.PkgID); if(packaging == null) { Log(new CallbackParameters(CallbackReason.MoveDetailPackagingNotLoaded) { MoveDetail = moveDetail }); continue; } var pickedLocation = NewContextHelper.GetLocation(moveDetail.LocID); if(pickedLocation == null) { pickedLocation = NewContextHelper.UnknownFacilityLocation; if(pickedLocation == null) { Log(new CallbackParameters(CallbackReason.MoveDetailUnknownWarehouseLocationNotLoaded) { MoveDetail = moveDetail }); continue; } Log(new CallbackParameters(CallbackReason.MoveDetailDefaultUnknownWarehouseLocation) { MoveDetail = moveDetail, Location = pickedLocation }); } var currentLocation = shipmentStatus == ShipmentStatus.Shipped ? NewContextHelper.GetLocation(moveDetail.Move2) ?? pickedLocation : pickedLocation; var treatment = NewContextHelper.GetInventoryTreatment(moveDetail.TrtmtID); if(treatment == null) { Log(new CallbackParameters(CallbackReason.MoveDetailTreatmentNotLoaded) { MoveDetail = moveDetail }); continue; } const string tote = ""; yield return new PickedInventoryItem { DateCreated = pickedInventoryKey.PickedInventoryKey_DateCreated, Sequence = pickedInventoryKey.PickedInventoryKey_Sequence, ItemSequence = ++sequence, DetailID = moveDetail.MDetail, LotDateCreated = lotKey.LotKey_DateCreated, LotDateSequence = lotKey.LotKey_DateSequence, LotTypeId = lotKey.LotKey_LotTypeId, PackagingProductId = packaging.Id, TreatmentId = treatment.Id, ToteKey = tote, Quantity = (int)moveDetail.Quantity, FromLocationId = pickedLocation.Id, CurrentLocationId = currentLocation.Id, CustomerLotCode = moveDetail.CustLot, CustomerProductCode = moveDetail.CustProductCode }; } }