void GetCurrentInventoryAmount() { InventoryBatch batch = inventorySource.FindInventoryBatchByBatchNumber(BatchNumber); AmountInInventory = batch.Quantity.ToString(); NotifyPropertyChanged("AmountInInventory"); }
bool QuantityIsAvialableToDeleteFromInInventory() { string batchNumber = ReceivedBatches[ReceivedBatchesSelectedIndex].BatchNumber; InventoryBatch inventoryBatch = inventorySource.FindInventoryBatchByBatchNumber(batchNumber); return(inventoryBatch.Quantity >= originalQuantity); }
void MergeCommonBatches(ITransaction finder) { List <InventoryBatch> merged = new List <InventoryBatch>(); foreach (IEntity result in finder.Results) { Entity <InventoryBatch> currentEntity = result as Entity <InventoryBatch>; InventoryBatch currentBatch = currentEntity.NativeModel; bool batchNotFound = true; for (int i = 0; i < merged.Count; i++) { if (merged[i].BatchNumber == currentBatch.BatchNumber) { merged[i].AddQuantity(currentBatch.Quantity); batchNotFound = false; continue; } } if (batchNotFound) { merged.Add(currentBatch); } } foreach (InventoryBatch batch in merged) { ITransaction deleter = new DeleteFromActiveInventoryAtBatchNumberTransaction(batch.BatchNumber, sqliteStore); deleter.Execute(); ITransaction adder = new AddReceivedBatchToInventoryTransaction(new Entity <InventoryBatch>(batch), sqliteStore); adder.Execute(); } }
public void SavingReceivedBatchAlsoUpdatesActiveInventoryWithNewRecord() { ReceivedBatch batch = helper.GetUniqueBatch1(); string batchNumber = batch.BatchNumber; receivedBatchSource.SaveReceivedBatch(batch); InventoryBatch stored = inventorySource.FindInventoryBatchByBatchNumber(batchNumber); Assert.AreEqual(batchNumber, stored.BatchNumber); }
void UpdateInventoryBatches(Entity <ReceivedBatch> original, Entity <ReceivedBatch> updated) { ITransaction deleter = null; ProcessColorAndBatchNumberUpdates(original, updated); if (BatchDoesNotExistInInventory(updated.NativeModel.BatchNumber)) { InventoryBatch inventoryBatch = new InventoryBatch( updated.NativeModel.ColorName, updated.NativeModel.BatchNumber, updated.NativeModel.ActivityDate, updated.NativeModel.Quantity ); ITransaction adder = new AddReceivedBatchToInventoryTransaction(new Entity <InventoryBatch>(inventoryBatch), sqliteStore); adder.Execute(); } ITransaction finder = new ListCurrentInventoryTransaction(sqliteStore); finder.Execute(); foreach (IEntity entity in finder.Results) { Entity <InventoryBatch> inventoryEntity = entity as Entity <InventoryBatch>; if (inventoryEntity.NativeModel.BatchNumber == original.NativeModel.BatchNumber) { inventoryEntity.NativeModel.Quantity = GetAdjustedInventoryQuantity( inventoryEntity.NativeModel.BatchNumber, original.NativeModel.Quantity, updated.NativeModel.Quantity ); ITransaction updater = new EditBatchInCurrentInventoryTransaction(inventoryEntity, sqliteStore); updater.Execute(); if (inventoryEntity.NativeModel.Quantity == 0) { deleter = new DeleteDepletedInventoryBatchAtId(inventoryEntity, sqliteStore); } } } if (deleter != null) { deleter.Execute(); } finder.Execute(); MergeCommonBatches(finder); }
public void FindSpecificBatchFromMultipleBatchesInActiveInventory() { ReceivedBatch paddingBatch = SetupReceivedBatch(); ReceivedBatch targetBatch = SetupReceivedBatch(); targetBatch.BatchNumber = "872894501202"; inventorySource.AddReceivedBatchToInventory(paddingBatch); inventorySource.AddReceivedBatchToInventory(targetBatch); InventoryBatch found = inventorySource.FindInventoryBatchByBatchNumber(targetBatch.BatchNumber); Assert.AreEqual(targetBatch.BatchNumber, found.BatchNumber); }
public void DeductImplementedBatchFromActiveInventory() { int expectedQty = 1; ReceivedBatch batch = SetupReceivedBatch(); batch.Quantity = 2; inventorySource.AddReceivedBatchToInventory(batch); inventorySource.DeductBatchFromInventory(batch.BatchNumber); InventoryBatch found = inventorySource.FindInventoryBatchByBatchNumber(batch.BatchNumber); Assert.AreEqual(expectedQty, found.Quantity); }
public void AddReceivedBatchToInventory(ReceivedBatch batch) { InventoryBatch inventoryBatch = new InventoryBatch( batch.ColorName, batch.BatchNumber, batch.ActivityDate, batch.Quantity ); ITransaction adder = new AddReceivedBatchToInventoryTransaction(new Entity <InventoryBatch>(inventoryBatch), sqliteStore); adder.Execute(); UpdateActiveInventory(); }
public void MergedInventoryRecordsHaveCorrectQuantity() { int expectedQty = 5; ReceivedBatch batch = SetupReceivedBatch(); batch.Quantity = 3; inventorySource.AddReceivedBatchToInventory(batch); batch.Quantity = 2; inventorySource.AddReceivedBatchToInventory(batch); InventoryBatch found = inventorySource.FindInventoryBatchByBatchNumber(batch.BatchNumber); Assert.AreEqual(expectedQty, found.Quantity); }
public void CorrectBatchIsDeductedWhenSendingToImplementationLedger() { int expectedQuantity = 2; string targetBatch = string.Empty; receivedBatch.Quantity = expectedQuantity + 1; inventorySource.AddReceivedBatchToInventory(receivedBatch); receivedBatch.BatchNumber = receivedBatchHelper.GetUniqueBatch2().BatchNumber; targetBatch = receivedBatch.BatchNumber; inventorySource.AddReceivedBatchToInventory(receivedBatch); implementedBatchSource.AddBatchToImplementationLedger(targetBatch, date, batchOperator); InventoryBatch found = inventorySource.FindInventoryBatchByBatchNumber(targetBatch); Assert.AreEqual(expectedQuantity, found.Quantity); }
public void ExecutedCommandWillAddBatchToImplementationLedgerAndRemoveFromInventory() { ReceivedBatch receivedBatch = SetupReceivedBatchWithQuantityOfTwo(); BatchOperator implementingOperator = operatorHelper.GetJaneDoeOperator(); int expectedQuantity = 1; int expectedLedgerCount = 1; int expectedInventoryCount = 1; SetupInventoryStateToImplementBatch(); SetupViewModelStateToImplementBatch(); command.Execute(null); InventoryBatch inventoryBatch = viewModel.CurrentInventory[0]; Assert.AreEqual(expectedQuantity, inventoryBatch.Quantity); Assert.AreEqual(expectedLedgerCount, viewModel.ImplementedBatchLedger.Count); Assert.AreEqual(expectedInventoryCount, viewModel.TotalInventoryCount); }
public InventoryBatch FindInventoryBatchByBatchNumber(string batchNumber) { InventoryBatch batch = new InventoryBatch(); ITransaction finder = new ListCurrentInventoryTransaction(sqliteStore); finder.Execute(); foreach (IEntity result in finder.Results) { Entity <InventoryBatch> entity = result as Entity <InventoryBatch>; if (entity.NativeModel.BatchNumber == batchNumber) { batch = entity.NativeModel; break; } } return(batch); }
public void AddBatchToImplementationLedger(string batchNumber, DateTime date, BatchOperator batchOperator) { InventoryBatch inventoryBatch = inventorySource.FindInventoryBatchByBatchNumber(batchNumber); date = CreateDateTimeWithPrecisionToMinutes(date); if (inventoryBatch.BatchNumber == batchNumber) { LoggedBatch implemented = new LoggedBatch( inventoryBatch.ColorName, inventoryBatch.BatchNumber, date, batchOperator ); Entity <LoggedBatch> entity = new Entity <LoggedBatch>(implemented); ITransaction adder = new TransferInventoryBatchToImplementedBatchLedgerTransaction(entity, sqliteStore); adder.Execute(); inventorySource.DeductBatchFromInventory(batchNumber); UpdateImplementationLedger(); } }
List <IEntity> ProcessInventoryBatches(SQLiteDataReader reader) { List <IEntity> entities = new List <IEntity>(); if (reader.HasRows) { while (reader.Read()) { InventoryBatch inventoryBatch = new InventoryBatch( reader.GetString(1), reader.GetString(2), DateTime.ParseExact(reader.GetString(3), "yyyy-MM-dd HH:mm:ss", null), reader.GetInt32(4) ); Entity <InventoryBatch> entity = new Entity <InventoryBatch>(reader.GetInt32(0), inventoryBatch); entities.Add(entity); } } return(entities); }
public void Setup() { batch = new InventoryBatch(colorName, batchNumber, inventoryDate, quantity); }