private void UpdateItem(InventoryKey key) { if (key != itemKey) { return; } WeaponSlot slot; if (_inventory.RetrieveSlot(itemKey, out slot)) { if (_item != slot.Item) { if (_item != null) { _item.Item.OnUnequip(_unit, itemKey); } _item = slot.Item; _item.Item.OnEquip(_unit, itemKey); } } else { _item = null; _ui.ChangeState(ItemSlotUiController.State.Disabled); } }
public static IQueryable <Inventory> FilterByInventoryKeys(this IQueryable <Inventory> inventoryQuery, IEnumerable <IInventoryKey> inventoryKeys) { if (inventoryQuery == null) { throw new ArgumentNullException("inventoryQuery"); } if (inventoryKeys == null) { throw new ArgumentNullException("inventoryKeys"); } if (inventoryQuery as DbQuery <Inventory> != null) { var stringBuilder = new InventoryKey(); var lotNumberStrings = inventoryKeys.ToList().Select(stringBuilder.BuildKeyValue).ToList(); return(inventoryQuery.Where(c => lotNumberStrings.Contains( SqlFunctions.StringConvert((double?)c.LotDateCreated.Year).Trim() + "-" + SqlFunctions.StringConvert((double?)c.LotDateCreated.Month).Trim() + "-" + SqlFunctions.StringConvert((double?)c.LotDateCreated.Day).Trim() + "-" + SqlFunctions.StringConvert((double?)c.LotDateSequence).Trim() + "-" + SqlFunctions.StringConvert((double?)c.LotTypeId).Trim() + "-" + SqlFunctions.StringConvert((double?)c.LocationId).Trim() + "-" + SqlFunctions.StringConvert((double?)c.PackagingProductId).Trim()))); } return(inventoryQuery.Where(c => inventoryKeys.Any(n => n.LotKey_DateCreated == c.LotKey_DateCreated && n.LotKey_DateSequence == c.LotKey_DateSequence && n.LotKey_LotTypeId == c.LotKey_LotTypeId && n.LocationKey_Id == c.LocationId && n.PackagingProductKey_ProductId == c.PackagingProductId))); }
public void Creates_PickedInventory_with_Archived_set_to_true() { //Arrange var inventory = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Lot.SetAdditiveLot(), i => i.Quantity = 100); var inventoryKey = new InventoryKey(inventory); var destinationLocationKey = new LocationKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Location>(l => l.ConstrainByKeys(inventory.Location.Facility))); //Act var result = Service.CreateIntraWarehouseOrder(new CreateIntraWarehouseOrderParameters { UserToken = TestUser.UserName, TrackingSheetNumber = 123.1m, OperatorName = "Manny", MovementDate = new DateTime(2020, 1, 1), PickedItems = new List <IIntraWarehouseOrderPickedItemParameters> { new IntraWarehouseOrderPickedItemParameters { InventoryKey = inventoryKey.KeyValue, DestinationLocationKey = destinationLocationKey, Quantity = 10 } } }); //Assert result.AssertSuccess(); var pickedInventory = RVCUnitOfWork.PickedInventoryRepository.All().Single(); Assert.IsTrue(pickedInventory.Archived); }
public void Reducing_PickedInventoryItem_quantity_will_create_Inventory_record_with_expected_quantity_if_it_doesnt_exist() { //Arrange const int pickedQuantity = 10; const int newPickedQuantity = 6; const int expectedInventoryQuantity = 4; var order = TestHelper.CreateObjectGraphAndInsertIntoDatabase <TOrder>(InitializeOrder, o => o.PickedInventory.Items = null); var orderKey = CreateKeyFromOrder(order); var pickedInventoryItem = TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => InitializeValidPickedInventoryItem(i, order, pickedQuantity)); var inventoryKey = new InventoryKey(pickedInventoryItem, pickedInventoryItem, pickedInventoryItem, pickedInventoryItem, pickedInventoryItem.ToteKey); Assert.IsNull(RVCUnitOfWork.InventoryRepository.FindByKey(inventoryKey)); //Act var result = GetResult(orderKey.KeyValue, new SetPickedInventoryParameters { UserToken = TestUser.UserName, PickedInventoryItems = new List <IPickedInventoryItemParameters> { new SetPickedInventoryItemParameters { InventoryKey = inventoryKey, Quantity = newPickedQuantity } } }); //Assert result.AssertSuccess(); Assert.AreEqual(expectedInventoryQuantity, RVCUnitOfWork.InventoryRepository.FindByKey(inventoryKey).Quantity); }
public void Will_successfuly_set_PickedInventoryItem_and_Inventory_records_as_expected_in_database() { //Arrange const int pickedItemToLeaveAlone_quantity = 10; const int pickedItemToUpdate_quantity = 12; const int pickedItemToUpdate_expectedQuantity = 7; const int inventoryItemToUpdate_quantity = 1; const int inventoryItemToUpdate_expectedQuantity = 6; const int pickedItemToCreate_expectedQuantity = 5; const int inventoryItemToRemove_quantity = 5; const int pickedItemToRemove_quantity = 22; const int inventoryItemToCreate_expectedQuantity = 22; var order = TestHelper.CreateObjectGraphAndInsertIntoDatabase <TOrder>(InitializeOrder, o => o.PickedInventory.Items = null); var orderKey = CreateKeyFromOrder(order); var pickedItemToLeaveAlone = TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => InitializeValidPickedInventoryItem(i, order, pickedItemToLeaveAlone_quantity)); var pickedItemToUpdate = TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => InitializeValidPickedInventoryItem(i, order, pickedItemToUpdate_quantity), i => i.FromLocation.Locked = false); var inventoryItemToUpdate = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => SetInventoryToPickedInventory(i, pickedItemToUpdate), i => i.Quantity = inventoryItemToUpdate_quantity); var inventoryItemToRemove = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Lot.SetValidToPick(), i => i.Quantity = inventoryItemToRemove_quantity, i => SetupInventoryToPick(i).Location.Locked = false); var pickedItemToRemove = TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => InitializeValidPickedInventoryItem(i, order, pickedItemToRemove_quantity)); //Act var result = GetResult(orderKey.KeyValue, new SetPickedInventoryParameters { UserToken = TestUser.UserName, PickedInventoryItems = new List <IPickedInventoryItemParameters> { new SetPickedInventoryItemParameters { InventoryKey = new InventoryKey(pickedItemToLeaveAlone), Quantity = pickedItemToLeaveAlone_quantity }, new SetPickedInventoryItemParameters { InventoryKey = new InventoryKey(inventoryItemToUpdate), Quantity = pickedItemToUpdate_expectedQuantity }, new SetPickedInventoryItemParameters { InventoryKey = new InventoryKey(inventoryItemToRemove), Quantity = pickedItemToCreate_expectedQuantity } } }); //Assert result.AssertSuccess(); Assert.AreEqual(pickedItemToLeaveAlone_quantity, RVCUnitOfWork.PickedInventoryItemRepository.FindByKey(new PickedInventoryItemKey(pickedItemToLeaveAlone)).Quantity); Assert.AreEqual(pickedItemToUpdate_expectedQuantity, RVCUnitOfWork.PickedInventoryItemRepository.FindByKey(new PickedInventoryItemKey(pickedItemToUpdate)).Quantity); Assert.AreEqual(inventoryItemToUpdate_expectedQuantity, RVCUnitOfWork.InventoryRepository.FindByKey(new InventoryKey(inventoryItemToUpdate)).Quantity); var inventoryToRemoveKey = new InventoryKey(inventoryItemToRemove); Assert.AreEqual(pickedItemToCreate_expectedQuantity, RVCUnitOfWork.PickedInventoryItemRepository.All().ToList().Single(p => inventoryToRemoveKey.Equals(new InventoryKey(p))).Quantity); Assert.IsNull(RVCUnitOfWork.InventoryRepository.FindByKey(inventoryToRemoveKey)); Assert.IsNull(RVCUnitOfWork.PickedInventoryItemRepository.FindByKey(new PickedInventoryItemKey(pickedItemToRemove))); Assert.AreEqual(inventoryItemToCreate_expectedQuantity, RVCUnitOfWork.InventoryRepository.FindByKey(new InventoryKey(pickedItemToRemove)).Quantity); }
public ModifyInventoryParameters(ILotKey lotKey, IPackagingProductKey packagingProductKey, ILocationKey locationKey, IInventoryTreatmentKey inventoryTreatmentKey, string toteKey, int adjustQuantity) { if (lotKey == null) { throw new ArgumentNullException("lotKey"); } if (packagingProductKey == null) { throw new ArgumentNullException("packagingProductKey"); } if (locationKey == null) { throw new ArgumentNullException("locationKey"); } if (inventoryTreatmentKey == null) { throw new ArgumentNullException("inventoryTreatmentKey"); } InventoryKey = new InventoryKey(lotKey, packagingProductKey, locationKey, inventoryTreatmentKey, toteKey); LotKey = lotKey.ToLotKey(); PackagingProductKey = packagingProductKey.ToPackagingProductKey(); LocationKey = locationKey.ToLocationKey(); InventoryTreatmentKey = inventoryTreatmentKey.ToInventoryTreatmentKey(); ModifyQuantity = adjustQuantity; }
public void Successfuly_picking_an_Inventory_item_adjusts_Inventory_record_quantity_as_expected() { //Arrange const int inventoryQuantity = 10; const int pickedQuantity = 7; const int expectedQuantity = inventoryQuantity - pickedQuantity; var order = TestHelper.CreateObjectGraphAndInsertIntoDatabase <TOrder>(InitializeOrder, o => o.PickedInventory.Items = null); var orderKey = CreateKeyFromOrder(order); var inventory = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Lot.SetValidToPick(), i => i.Quantity = inventoryQuantity, i => SetupInventoryToPick(i).Location.Locked = false); var inventoryKey = new InventoryKey(inventory); //Act var result = GetResult(orderKey.KeyValue, new SetPickedInventoryParameters { UserToken = TestUser.UserName, PickedInventoryItems = new List <IPickedInventoryItemParameters> { new SetPickedInventoryItemParameters { InventoryKey = inventoryKey.KeyValue, Quantity = pickedQuantity } } }); //Assert result.AssertSuccess(); Assert.AreEqual(expectedQuantity, RVCUnitOfWork.InventoryRepository.FindByKey(inventoryKey).Quantity); }
public void Creates_new_Inventory_record_as_expected_if_Adjustment_quantity_is_positive_and_Inventory_record_does_not_previously_exist() { //Arrange const int adjustmentQuantity = 12; const string toteKey = ""; var userToken = TestUser.UserName; var lotKey = new LotKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Lot>(l => l.EmptyLot())); var packagingProductKey = new PackagingProductKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <PackagingProduct>()); var warehouseLocationKey = new LocationKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Location>()); var treatmentKey = new InventoryTreatmentKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <InventoryTreatment>()); var inventoryKey = new InventoryKey(lotKey, packagingProductKey, warehouseLocationKey, treatmentKey, toteKey); //Act var result = Service.CreateInventoryAdjustment(new Params { UserToken = userToken, InventoryAdjustments = new List <IInventoryAdjustmentParameters> { new Params.ParamsItem(inventoryKey) { Adjustment = adjustmentQuantity } } }); //Assert result.AssertSuccess(); Assert.AreEqual(adjustmentQuantity, RVCUnitOfWork.InventoryRepository.FindByKey(inventoryKey).Quantity); }
internal PickedInventoryParameters(IInventoryKey inventoryKey, int quantity, string customerLotCode, string customerProductCode) { InventoryKey = new InventoryKey(inventoryKey); CurrentLocationKey = new LocationKey(InventoryKey); Quantity = quantity; CustomerLotCode = customerLotCode; CustomerProductCode = customerProductCode; }
internal IResult Execute(LotProductionResults productionResults, IEnumerable <IProductionResultItemParameters> resultItems, ref List <ModifyInventoryParameters> inventoryModifications) { var nextSequence = productionResults.ResultItems.Select(i => i.ResultItemSequence).DefaultIfEmpty(0).Max() + 1; var existingItems = productionResults.ResultItems.ToDictionary(i => new InventoryKey(i)); inventoryModifications = inventoryModifications ?? new List <ModifyInventoryParameters>(); foreach (var item in resultItems) { if (item.Quantity <= 0) { return(new InvalidResult(UserMessages.QuantityNotGreaterThanZero)); } var inventoryKey = new InventoryKey(productionResults, item.PackagingProductKey, item.LocationKey, item.InventoryTreatmentKey, ""); if (inventoryModifications.Any(m => m.InventoryKey.Equals(inventoryKey) && m.ModifyQuantity > 0)) { return(new InvalidResult(string.Format(UserMessages.ProductionResultAlreadyPendingAddition, inventoryKey))); } LotProductionResultItem resultItem; if (existingItems.TryGetValue(inventoryKey, out resultItem)) { existingItems.Remove(inventoryKey); } else { resultItem = _productionUnitOfWork.LotProductionResultItemsRepository.Add(new LotProductionResultItem { LotDateCreated = inventoryKey.LotKey_DateCreated, LotDateSequence = inventoryKey.LotKey_DateSequence, LotTypeId = inventoryKey.LotKey_LotTypeId, ResultItemSequence = nextSequence++, Quantity = 0 }); } var deltaQuantity = item.Quantity - resultItem.Quantity; if (deltaQuantity != 0) { inventoryModifications.Add(new ModifyInventoryParameters(inventoryKey, deltaQuantity)); } resultItem.PackagingProductId = inventoryKey.PackagingProductKey_ProductId; resultItem.LocationId = inventoryKey.LocationKey_Id; resultItem.TreatmentId = inventoryKey.InventoryTreatmentKey_Id; resultItem.Quantity = item.Quantity; } foreach (var item in existingItems.Values) { _productionUnitOfWork.LotProductionResultItemsRepository.Remove(item); inventoryModifications.Add(new ModifyInventoryParameters(item, -item.Quantity)); } return(new SuccessResult()); }
public void Creates_PickedInventoryItem_records_as_expected() { //Arrange const int quantityPicked0 = 50; const int quantityPicked1 = 75; var inventory = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Quantity = 100); var inventoryKey0 = new InventoryKey(inventory); var inventoryKey1 = new InventoryKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Location.ConstrainByKeys(inventory.Location), i => i.Quantity = 100)); var destinationLocationKey = new LocationKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Location>(l => l.ConstrainByKeys(inventory.Location.Facility))); //Act var result = Service.CreateIntraWarehouseOrder(new CreateIntraWarehouseOrderParameters { UserToken = TestUser.UserName, TrackingSheetNumber = 123.1m, OperatorName = "Oh operator", MovementDate = new DateTime(2012, 3, 29), PickedItems = new List <IIntraWarehouseOrderPickedItemParameters> { new IntraWarehouseOrderPickedItemParameters { InventoryKey = inventoryKey0.KeyValue, DestinationLocationKey = destinationLocationKey, Quantity = quantityPicked0 }, new IntraWarehouseOrderPickedItemParameters { InventoryKey = inventoryKey1.KeyValue, DestinationLocationKey = destinationLocationKey, Quantity = quantityPicked1 } } }); //Assert result.AssertSuccess(); var orderKey = new IntraWarehouseOrderKey(KeyParserHelper.ParseResult <IIntraWarehouseOrderKey>(result.ResultingObject).ResultingObject); var items = RVCUnitOfWork.IntraWarehouseOrderRepository.FindByKey(orderKey, i => i.PickedInventory.Items.Select(t => t.FromLocation), i => i.PickedInventory.Items.Select(t => t.CurrentLocation)) .PickedInventory.Items.ToList(); Assert.AreEqual(2, items.Count); var item0 = items.Single(i => inventoryKey0.Equals(new InventoryKey(i, i, i.FromLocation, i, i.ToteKey))); Assert.AreEqual(quantityPicked0, item0.Quantity); var item1 = items.Single(i => inventoryKey1.Equals(new InventoryKey(i, i, i.FromLocation, i, i.ToteKey))); Assert.AreEqual(quantityPicked1, item1.Quantity); }
public override void OnEquip(Unit.Unit unit, InventoryKey weaponKey) { base.OnEquip(unit, weaponKey); _weaponKey = weaponKey; if (initialAmmunition != null) { var inventory = unit.GetComponent <IProvider <Inventory> >()?.Get(); if (inventory != null) { initialAmmunition.AddToInventory(inventory); } } }
public MoveInventoryCommandParameters(IInventoryKey sourceInventoryKey, ILocationKey destinationWarehouseLocationKey, int moveQuantity) { if (sourceInventoryKey == null) { throw new ArgumentNullException("sourceInventoryKey"); } if (destinationWarehouseLocationKey == null) { throw new ArgumentNullException("destinationWarehouseLocationKey"); } SourceInventoryKey = new InventoryKey(sourceInventoryKey); DestinationLocationKey = new LocationKey(destinationWarehouseLocationKey); MoveQuantity = moveQuantity; }
public ModifyPickedInventoryItemParameters(PickedInventoryItem pickedItem) { if (pickedItem.CurrentLocation == null) { throw new ArgumentNullException("Expected pickedItem.CurrentLocation but was null, verify navigational property is being included in selection."); } PickedInventoryItemKey = new PickedInventoryItemKey(pickedItem); InventoryKey = new InventoryKey(pickedItem, pickedItem, pickedItem, pickedItem, pickedItem.ToteKey); CurrentLocationKey = new LocationKey(pickedItem.CurrentLocation); OriginalQuantity = pickedItem.Quantity; CustomerLotCode = pickedItem.CustomerLotCode; CustomerProductCode = pickedItem.CustomerProductCode; NewQuantity = 0; }
public void Creates_InventoryAdjustmentItem_records_as_expected_on_success() { //Arrange const int expectedResults = 3; const int adjustmentQuantity0 = 10; const int adjustmentQuantity1 = 11; const int adjustmentQuantity2 = -12; var userToken = TestUser.UserName; var inventory0 = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(); var inventory1 = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Quantity = 20); //Act var result = Service.CreateInventoryAdjustment(new Params { UserToken = userToken, InventoryAdjustments = new List <IInventoryAdjustmentParameters> { new Params.ParamsItem(inventory0) { Adjustment = adjustmentQuantity0 }, new Params.ParamsItem(inventory0) { Adjustment = adjustmentQuantity1 }, new Params.ParamsItem(inventory1) { Adjustment = adjustmentQuantity2 } } }); //Assert result.AssertSuccess(); var adjustments = RVCUnitOfWork.InventoryAdjustmentItemRepository.All().ToList(); Assert.AreEqual(expectedResults, adjustments.Count); var inventoryKey0 = new InventoryKey(inventory0); var inventoryKey1 = new InventoryKey(inventory1); Assert.IsNotNull(adjustments.Single(a => inventoryKey0.KeyValue == new InventoryKey(a).KeyValue&& adjustmentQuantity0 == a.QuantityAdjustment)); Assert.IsNotNull(adjustments.Single(a => inventoryKey0.KeyValue == new InventoryKey(a).KeyValue&& adjustmentQuantity1 == a.QuantityAdjustment)); Assert.IsNotNull(adjustments.Single(a => inventoryKey1.KeyValue == new InventoryKey(a).KeyValue&& adjustmentQuantity2 == a.QuantityAdjustment)); }
public void Creates_Inventory_records_as_expected() { //Arrange const int quantityPicked0 = 50; const int quantityPicked1 = 75; const int quantity0 = 100; const int quantity1 = 200; var inventory = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Quantity = quantity0); var inventoryKey0 = new InventoryKey(inventory); var inventoryKey1 = new InventoryKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Location.ConstrainByKeys(inventory.Location), i => i.Quantity = quantity1)); var destinationKey0 = new LocationKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Location>(l => l.ConstrainByKeys(inventory.Location))); var destinationKey1 = new LocationKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Location>(l => l.ConstrainByKeys(inventory.Location))); var expectedInventoryKey0 = new InventoryKey(inventoryKey0, inventoryKey0, destinationKey0, inventoryKey0, inventoryKey0.InventoryKey_ToteKey); var expectedInventoryKey1 = new InventoryKey(inventoryKey1, inventoryKey1, destinationKey1, inventoryKey1, inventoryKey1.InventoryKey_ToteKey); //Act var result = Service.CreateIntraWarehouseOrder(new CreateIntraWarehouseOrderParameters { UserToken = TestUser.UserName, TrackingSheetNumber = 123.1m, OperatorName = "Oh operator", MovementDate = new DateTime(2012, 3, 29), PickedItems = new List <IIntraWarehouseOrderPickedItemParameters> { new IntraWarehouseOrderPickedItemParameters { InventoryKey = inventoryKey0.KeyValue, DestinationLocationKey = destinationKey0, Quantity = quantityPicked0 }, new IntraWarehouseOrderPickedItemParameters { InventoryKey = inventoryKey1.KeyValue, DestinationLocationKey = destinationKey1, Quantity = quantityPicked1 } } }); //Assert result.AssertSuccess(); Assert.AreEqual(quantityPicked0, RVCUnitOfWork.InventoryRepository.FindByKey(expectedInventoryKey0).Quantity); Assert.AreEqual(quantityPicked1, RVCUnitOfWork.InventoryRepository.FindByKey(expectedInventoryKey1).Quantity); }
public void Picking_into_the_same_existing_Inventory_record_will_modify_that_record_by_total_quantity_picked() { //Arrange const int quantityPicked0 = 23; const int quantityPicked1 = 54; const int existingQuantity = 100; const int expectedQuantity = existingQuantity + quantityPicked0 + quantityPicked1; var existingInventory = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Quantity = existingQuantity); var existingInventoryKey = new InventoryKey(existingInventory); var inventoryKey0 = new InventoryKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Quantity = 200, i => i.ConstrainByKeys(existingInventoryKey, existingInventoryKey, null, existingInventoryKey, existingInventory.Location, existingInventoryKey.InventoryKey_ToteKey))); var inventoryKey1 = new InventoryKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Quantity = 200, i => i.ConstrainByKeys(existingInventoryKey, existingInventoryKey, null, existingInventoryKey, existingInventory.Location, existingInventoryKey.InventoryKey_ToteKey))); var destinationLocationKey = new LocationKey(existingInventory); //Act var result = Service.CreateIntraWarehouseOrder(new CreateIntraWarehouseOrderParameters { UserToken = TestUser.UserName, TrackingSheetNumber = 123.1m, OperatorName = "Oh operator", MovementDate = new DateTime(2012, 3, 29), PickedItems = new List <IIntraWarehouseOrderPickedItemParameters> { new IntraWarehouseOrderPickedItemParameters { InventoryKey = inventoryKey0.KeyValue, DestinationLocationKey = destinationLocationKey, Quantity = quantityPicked0 }, new IntraWarehouseOrderPickedItemParameters { InventoryKey = inventoryKey1.KeyValue, DestinationLocationKey = destinationLocationKey, Quantity = quantityPicked1 } } }); //Assert result.AssertSuccess(); Assert.AreEqual(expectedQuantity, RVCUnitOfWork.InventoryRepository.FindByKey(existingInventoryKey).Quantity); }
public void Returns_non_successful_result_if_moving_Inventory_from_different_Warehouses() { //Arrange const int existingQuantity = 100; const int quantityPicked0 = 67; const int quantityPicked1 = 34; var inventory0 = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Quantity = existingQuantity); var inventoryKey0 = new InventoryKey(inventory0); var inventory1 = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Quantity = existingQuantity); var inventoryKey1 = new InventoryKey(inventory1); var destinationLocationKey = new LocationKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Location>(l => l.ConstrainByKeys(inventory0.Location.Facility))); //Act var result = Service.CreateIntraWarehouseOrder(new CreateIntraWarehouseOrderParameters { UserToken = TestUser.UserName, TrackingSheetNumber = 123.1m, OperatorName = "Oh operator", MovementDate = new DateTime(2012, 3, 29), PickedItems = new List <IIntraWarehouseOrderPickedItemParameters> { new IntraWarehouseOrderPickedItemParameters { InventoryKey = inventoryKey0.KeyValue, DestinationLocationKey = destinationLocationKey, Quantity = quantityPicked0 }, new IntraWarehouseOrderPickedItemParameters { InventoryKey = inventoryKey1.KeyValue, DestinationLocationKey = destinationLocationKey, Quantity = quantityPicked1 } } }); //Assert result.AssertNotSuccess(UserMessages.IntraWarehouseOrderDifferentWarehouses); }
public void Creates_IntraWarehouseOrder_record_as_expected() { //Arrange const int expectedSequence = 1; var expectedUser = TestUser.UserName; const decimal expectedSheetNumber = 123.1m; const string expectedOperatorName = "Little Jimmy"; var expectedMovementDate = new DateTime(2012, 3, 29); var inventory = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Quantity = 100); var inventoryKey = new InventoryKey(inventory); var destinationLocationKey = new LocationKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Location>(l => l.ConstrainByKeys(inventory.Location.Facility))); //Act var result = Service.CreateIntraWarehouseOrder(new CreateIntraWarehouseOrderParameters { UserToken = expectedUser, TrackingSheetNumber = expectedSheetNumber, OperatorName = expectedOperatorName, MovementDate = expectedMovementDate, PickedItems = new List <IIntraWarehouseOrderPickedItemParameters> { new IntraWarehouseOrderPickedItemParameters { InventoryKey = inventoryKey.KeyValue, DestinationLocationKey = destinationLocationKey, Quantity = 10 } } }); //Assert result.AssertSuccess(); var order = RVCUnitOfWork.IntraWarehouseOrderRepository.Filter(o => true, o => o.Employee).Single(); Assert.AreEqual(expectedSequence, order.Sequence); Assert.AreEqual(expectedUser, order.Employee.UserName); Assert.AreEqual(expectedSheetNumber, order.TrackingSheetNumber); Assert.AreEqual(expectedOperatorName, order.OperatorName); Assert.AreEqual(expectedMovementDate, order.MovementDate); }
public void Removes_Inventory_record_if_total_picked_quantity_equals_existing_quantity() { //Arrange const int existingQuantity = 100; const int quantityPicked0 = 67; const int quantityPicked1 = 33; var inventory = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Quantity = existingQuantity); var inventoryKey = new InventoryKey(inventory); var destinationLocationKey = new LocationKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Location>(l => l.ConstrainByKeys(inventory.Location.Facility))); //Act var result = Service.CreateIntraWarehouseOrder(new CreateIntraWarehouseOrderParameters { UserToken = TestUser.UserName, TrackingSheetNumber = 123.00010005m, OperatorName = "Oh operator", MovementDate = new DateTime(2012, 3, 29), PickedItems = new List <IIntraWarehouseOrderPickedItemParameters> { new IntraWarehouseOrderPickedItemParameters { InventoryKey = inventoryKey.KeyValue, DestinationLocationKey = destinationLocationKey, Quantity = quantityPicked0 }, new IntraWarehouseOrderPickedItemParameters { InventoryKey = inventoryKey.KeyValue, DestinationLocationKey = destinationLocationKey, Quantity = quantityPicked1 } } }); //Assert result.AssertSuccess(); Assert.IsNull(RVCUnitOfWork.InventoryRepository.FindByKey(inventoryKey)); }
public virtual void OnUnequip(Unit.Unit unit, InventoryKey weaponKey) { }
public NewPickedInventory(IInventoryKey inventoryKey, int quantity, ILocationKey currentLocationKey) { InventoryKey = new InventoryKey(inventoryKey); QuantityPicked = quantity; CurrentLocationKey = new LocationKey(currentLocationKey); }
internal bool Match(PickedInventoryParameters b) { return(InventoryKey.Equals(b.InventoryKey) && CurrentLocationKey.Equals(b.CurrentLocationKey) && CustomerLotCode == b.CustomerLotCode && CustomerProductCode == b.CustomerProductCode && (OrderItemKey == null ? b.OrderItemKey == null : OrderItemKey.Equals(b.OrderItemKey))); }