//Read the lines from the input file // need some error handling in here; think about how to move error handling into constructor; and throw erros upwards //also make sure it adds null entries public void ReadStockItem(string item) { string stock_no, item_name, supplier, cost, level, min; if (item != null) { try { string [] parts = item.Split (','); stock_no = parts [0].Trim (); item_name = parts [1].Trim (); supplier = parts [2].Trim (); cost = parts [3].Trim (); level = parts [4].Trim (); min = parts [5].Trim (); StockItem s = new StockItem (stock_no, item_name, supplier, cost, level, min); stock_list.AddStockItem (stock_no, s); } catch (FormatException x) { if (x.Message.StartsWith ("Stock Code must begin with BMAC.")) { //do nothing (ie. skip line) } } catch (ArgumentException) { //do nothing (ie. skip line) } } }
public void WhenManagingStockShouldUpdate() { // Arrange var product = Client.GetProductBySku("100000").Result; var productId = product.Result.entity_id; var stockItem = new StockItem { qty = 10, min_qty = 15, is_in_stock = false, manage_stock = true }; var response1 = Client.UpdateStockItemForProduct(productId, stockItem).Result; var updatedStockItem = new StockItem { qty = 10, is_in_stock = true }; // Act var response2 = Client.UpdateStockItemForProduct(productId, updatedStockItem).Result; // Assert Assert.IsFalse(response2.HasErrors, response2.ErrorString); var updatedProduct = Client.GetProductById(productId).Result; Assert.IsTrue(updatedProduct.Result.stock_data.is_in_stock.Value); }
protected StockItemHistoryBase(DateTime dateTime, string user, StockItem stockItem, int level) { DateTime = dateTime; User = user; StockItem = stockItem; Level = level; }
/* View Methods */ public void BuildOrder(StockItem s) { String selected = s.StockCode; //Clear & populate list combobox2.Clear (); CellRendererText cell = new CellRendererText (); combobox2.PackStart (cell, false); combobox2.AddAttribute (cell, "text", 0); ListStore store = new ListStore (typeof(string)); combobox2.Model = store; foreach (KeyValuePair<String, StockItem> kv in stock_list) { store.AppendValues (kv.Value.StockCode); } //Make selected item active combobox2.Model = store; TreeIter iter; combobox2.Model.GetIterFirst (out iter); do { GLib.Value thisRow = new GLib.Value (); combobox2.Model.GetValue (iter, 0, ref thisRow); if ((thisRow.Val as string).Equals (selected)) { combobox2.SetActiveIter (iter); break; } } while (combobox2.Model.IterNext (ref iter)); //Refresh order information OrderData (); }
public void test_that_ADDITEM_adds_to_list() { int length = repo.GetAll().Count(); var input = new StockItem { Name = "Stock???", Price = 50 , Quantity = 50}; StockItemsDb.AddItem(input); int newLength = repo.GetAll().Count(); Assert.Greater(newLength, length); }
public StockItem Parse() { // Information as to how these standards are ACTUALLY parsed can be found here: // http://www.hibcc.org/publication/view/supplier-labeling-standard/ // That being said, I will be returning static data for the purposes of this // exercise as a PoC. var item = new StockItem(123, 456, null, new DateTime(2016, 12, 31)); return item; }
public ItemStocks(XElement xml) { this.Items = new List<StockItem>(); var items = xml.Elements("item").ToArray(); foreach (XElement item in items) { StockItem entry = new StockItem(item); this.Items.Add(entry); } }
public StockItemProductNameChanged(DateTime dateTime, string user, StockItem stockItem, int level, string oldProductName, string newProductName) : base(dateTime, user, stockItem, level) { if (oldProductName == null) { throw new ArgumentNullException("oldProductName"); } if (newProductName == null) { throw new ArgumentNullException("newProductName"); } OldProductName = oldProductName; NewProductName = newProductName; }
public void AnyModification_should_raise_domain_event() { IDomainEvent capturedDomainEvent = null; using (DomainEvent.TestWith(domainEvent => { capturedDomainEvent = domainEvent; })) { stockItem = StockItem.Create(productName, sizeName, dateCreated, user); capturedDomainEvent.ShouldBe<StockItemCreated>(); stockItem.ReceiveStock(10, dateCreated, user); capturedDomainEvent.ShouldBe<ReceivedStock>(); stockItem.Dispatch(5, 1, dateCreated, user); capturedDomainEvent.ShouldBe<DispatchedStock>(); } }
public void SwitchMenu(string[] parameter) { switch (parameter[0].ToUpper()) //MENU SWITCH { case "ADJUST": { view.ChangeQuantity(Convert.ToInt32(parameter[1])); break; } case "LIST": { view.ListStock(); Console.ReadLine(); // BA this is a view concern break; } case "ADD": { // BA if you're going to have wrapper classes over the repository, this is the sort of work that they should be doing. // Rather than creating a stockitem here, add a method to the StockItemsDb class which takes a string, a decimal, and an int, // and create your new StockItem in that method before giving it to the repo. StockItem item = new StockItem() { Name = parameter[1], Price = Convert.ToDecimal(parameter[2]), Quantity = Convert.ToInt32(parameter[3]) }; StockItemsDb.AddItem(item); break; } case "DELETE": { var item = StockItemsDb.GetItem(Convert.ToInt32(parameter[1])); // BA, again, delegate this work to the StockItemsDb class, since you have it StockItemsDb.RemoveItem(item); break; } default: { Console.WriteLine("Invalid command"); // BA this is a view concern break; } } Console.Clear(); // BA this is a view concern Start(); }
public ActionResult AddBasketOrder(string stokkod, int miktar) { var stok = _stoklarORM.GetList("select * from STOKLAR where sto_kod='" + stokkod + "'").FirstOrDefault(); StockItem item = new StockItem(); var fiyat = _stoksatisFiyatORM.GetList().FirstOrDefault(x => x.sfiyat_stokkod == stok.sto_kod); if (fiyat != null) { item.BirimFiyat = fiyat.sfiyat_fiyati ?? 0; } else { item.BirimFiyat = 0; } item.Quantity = miktar; item.stoklar = stok; OrderBasket.ActiveOrder.OrderAdd(item); var data = OrderBasket.ActiveOrder._Items; return(Json("1")); }
public void NoChangeWhenSellInIsGreaterThanFirstApplicableDay() { var testRule = new IncreasingDeprecationRule { FirstApplicableDay = 2, Amount = 2 }; var testStock = new StockItem { StockTypeId = "Stock 1", SellIn = 3, Quality = 5 }; var service = new IncreasingDeprecationRuleService(); var result = service.RunRule(testRule, testStock); Assert.False(result); Assert.Equal(5, testStock.Quality); }
public void IncreasesQualityWhenSellInIsEqualLastApplicableDay() { var testRule = new IncreasingDeprecationRule { FirstApplicableDay = 3, Amount = 2 }; var testStock = new StockItem { StockTypeId = "Stock 1", SellIn = 3, Quality = 5 }; var service = new IncreasingDeprecationRuleService(); var result = service.RunRule(testRule, testStock); Assert.True(result); Assert.Equal(7, testStock.Quality); }
public void ForceClosePurchaseOrder(int orderNumber, string reason) { using (var context = new eToolsContext()) { PurchaseOrder purchaseOrder = context.PurchaseOrders.Find(orderNumber); purchaseOrder.Notes = reason; context.Entry(purchaseOrder).Property("Notes").IsModified = true; purchaseOrder.Closed = true; context.Entry(purchaseOrder).Property("Closed").IsModified = true; StockItem stockItem = null; foreach (PurchaseOrderDetail item in purchaseOrder.PurchaseOrderDetails) { stockItem = context.StockItems.Find(item.StockItemID); //stockItem.QuantityOnOrder -= item.Quantity - item.ReceiveOrderDetails.Select(receive => receive.QuantityReceived).DefaultIfEmpty(0).Sum(); stockItem.QuantityOnOrder = 0; context.Entry(stockItem).Property("QuantityOnOrder").IsModified = true; } context.SaveChanges(); } }
public void ShouldIncreaseStockCountOnIncrement() { var stockId = 1; var stockLevel = 0; var stockItem = new StockItem() { Id = stockId, Stock = stockLevel }; var stock = InitializeWithStock(stockItem); _stockRepository .AddStock(stockId); stockItem = _stockRepository .GetStockItem(stockId); stockItem.Stock.ShouldBe(stockLevel + 1); }
public void RehydrateAggregateFailsIfEventAggregateIdMismatch() { var aggregateId = Guid.NewGuid().ToString(); var locationName = "location1"; var item = new StockItem("item1", "1"); var contextMap = new BoundedContextModel().WithAssemblyContaining <Location>(); var aggregateRoot = new Location(); var aggregateAdapter = AggregateAdapterFactory.Default.CreateAggregate(contextMap, aggregateRoot).WithId(aggregateId); var eventAdapterFactory = new EventFactory(); var aggregateEventHistory = new List <IEvent>(); aggregateEventHistory.Add(eventAdapterFactory.CreateEvent <Location, LocationCreated>(aggregateId, 1, string.Empty, string.Empty, new LocationCreated(locationName, string.Empty))); aggregateEventHistory.Add(eventAdapterFactory.CreateEvent <Location, AdjustedIn>(aggregateId, 2, string.Empty, string.Empty, new AdjustedIn($"adjustment_{Guid.NewGuid()}", locationName, item))); aggregateEventHistory.Add(eventAdapterFactory.CreateEvent <Location, MovedOut>(Guid.NewGuid().ToString(), 3, string.Empty, string.Empty, new MovedOut($"movement_{Guid.NewGuid()}", locationName, item, "toLocationName"))); Assert.ThrowsException <ArgumentException>(() => aggregateAdapter.Rehydrate(aggregateEventHistory)); }
public void SizeCreatedEvent_should_create_new_StockItem() { const string productName = "Widget"; const string sizeName = "Small"; var @event = new SizeCreatedEvent(productName, sizeName, true); StockItem stockItem = null; stockItemRepository.SaveOrUpdateDelegate = x => stockItem = x; createStockItemOnSizeCreatedEvent.Handle(@event); stockItem.ShouldNotBeNull(); stockItem.ProductName.ShouldEqual("Widget"); stockItem.SizeName.ShouldEqual("Small"); stockItem.IsActive.ShouldBeTrue(); stockItem.History[0].DateTime.ShouldEqual(now); stockItem.History[0].User.ShouldEqual(user); }
public async Task Get_product_should_return_expected_StockItem() { // Arrange var expectedStockItem = new StockItem() { Id = 1, ProductId = 1, Inventory = 4, }; var client = new WebApplicationFactoryWithWebHost <Startup>().CreateClient(); // Act var response = await client.GetAsync("/api/inventory/product/1"); var stockItem = await response.Content.As <StockItem>(); // Assert Assert.Equal(expectedStockItem.Id, stockItem.Id); Assert.Equal(expectedStockItem.Inventory, stockItem.Inventory); Assert.Equal(expectedStockItem.ProductId, stockItem.ProductId); }
//Click Add New on an order Item private void Button_Click(object sender, RoutedEventArgs e) { try { int quantity = int.Parse(uiQuantity.Text); //Targets quantity in the textbox StockItem selectedStockItem = (StockItem)dgStockItems.SelectedItem; //Targets the selected stock item OrderItem newOrderItem = new OrderItem(selectedStockItem.Name, _orderHeader.OrderID, selectedStockItem.Price, int.Parse(uiQuantity.Text), selectedStockItem.Id); // Instantiates a new order item from the selected stock item _orderController.UpsertOrderItem(newOrderItem.OrderHeaderId, newOrderItem.StockItemId, quantity); //Adds the new orderitem to the orderItems table in the db _orderHeader.Total = _orderHeader.Total + ( selectedStockItem.Price * quantity); // Update the orderHeader total NavigationService.Navigate(new AddOrder(_orderHeader)); // Navigates back to the AddOrder View } catch (Exception error) { MessageBox.Show($"Error Encountered: {error}"); } }
public void GetHistory_should_get_a_stockItems_history_between_the_given_dates() { var stockItem = StockItem.Create("widget", "small", new DateTime(2011, 1, 1), user); var history1 = stockItem.ReceiveStock(10, new DateTime(2011, 2, 1), user); var history2 = stockItem.Dispatch(2, 1, new DateTime(2011, 3, 1), user); var history3 = stockItem.Dispatch(2, 2, new DateTime(2011, 4, 1), user); stockItem.Dispatch(2, 3, new DateTime(2011, 5, 1), user); var start = new DateTime(2011, 2, 1); var end = new DateTime(2011, 4, 1); historyRepository.GetAllDelegate = () => stockItem.History.AsQueryable(); var history = stockItemService.GetHistory(stockItem, start, end); history.Count().ShouldEqual(3); history.ElementAt(0).ShouldBeTheSameAs(history1); history.ElementAt(1).ShouldBeTheSameAs(history2); history.ElementAt(2).ShouldBeTheSameAs(history3); }
public void DoubleChangeWhenSellInIsLessZero() { var testRule = new DecreasingDeprecationRule { FirstApplicableDay = int.MaxValue, Amount = 2 }; var testStock = new StockItem { StockTypeId = "Stock 1", SellIn = -1, Quality = 5 }; var service = new DecreasingDeprecationRuleService(); var result = service.RunRule(testRule, testStock); Assert.True(result); Assert.Equal(1, testStock.Quality); }
public IEnumerable <StockItem> GetStockItems() { var items = new List <StockItem>(); using (var connection = new SqlConnection(_connectionString)) using (var command = new SqlCommand("sp_SelectStockItems", connection)) { connection.Open(); var reader = command.ExecuteReader(); while (reader.Read()) { int id = reader.GetInt32(0); string name = reader.GetString(1); decimal price = reader.GetDecimal(2); int inStock = reader.GetInt32(3); var item = new StockItem(id, name, price, inStock); items.Add(item); } } return(items); }
public ChartItem FromTradeDetailData(TradeDetailData tdd, ChartItemType type) { ChartItem item = null; switch (type) { case ChartItemType.Linear: item = new ChartItem() { Value = tdd.current, Date = tdd.DateTime }; break; case ChartItemType.Candle: item = new StockItem() { Close = tdd.current, Date = tdd.DateTime, High = tdd.current, Low = tdd.current, Open = tdd.current }; break; case ChartItemType.Volumn: item = new VolumnItem() { Volumn = tdd.volume, Turnover = tdd.amount, Date = tdd.DateTime, }; break; default: break; } return(item); }
//Build the stock item to add / update public StockItem BuildItem() { StockItem s = null; string e1; string e2 = null; string e3 = null; string e4 = null; string e5 = null; string e6 = null; Entry ent; string message = "Invalid data entered, item has not been added\nError(s):\n "; //Get the text from the input boxes, if no value has been added, null value is used e1 = entry1.Text.Trim (); e2 = entry2.Text.Trim (); e3 = entry3.Text.Trim (); e4 = entry4.Text.Trim (); e5 = entry5.Text.Trim (); e6 = entry6.Text.Trim (); try { s = new StockItem (e1, e2, e3, e4, e5, e6); } //If the stock item code is blank of incorrectly formatted, catch the exception and show pop-up catch (FormatException x) { if (x.Message.StartsWith ("Stock Code must begin with BMAC.")) { ent = entry1; ent.HasFocus = true; message += x.Message; message += " (in "; message += label1.Text; message += ")\n"; DataErrorMsg (message); } } return s; }
public void ShouldReturnAvailableWhenProductIsInStock() { var userId = "userId"; var productId = 1; var productName = "name"; var stockItem = new StockItem() { Id = productId, Name = productName, Stock = 2 }; var basketItem = new BasketItem() { ProductId = productId, ItemCount = 1 }; var basket = new List <BasketItem>() { basketItem }; _basketRepository .GetBasket(userId) .Returns(basket); _stockRepository .GetStockItem(productId) .Returns(stockItem); _basketRepository .GetBasketItem(userId, productId) .Returns(basketItem); var check = _command .CanCheckoutBasketCheck(userId); check.Result.ShouldBe(AvailabilityCheckStatus.Ok); check.ProductsNotAvailable.ShouldBeEmpty(); check.ProductsNotFound.ShouldBeEmpty(); }
private StockVolumnList FromCompleteStock(CompleteShare s) { StockVolumnList svList = new StockVolumnList(); if (s.Dates != null) { svList.Prices = new List <StockItem>(s.Dates.Count); svList.Volumns = new List <VolumnItem>(s.Dates.Count); double preClose = calChangeByStart ? s.Closes[0] : 0; for (int i = 0; i < s.Dates.Count; i++) { var sItem = new StockItem() { Date = s.Dates[i], Value = s.Closes[i], ValueChange = i != 0 ? (s.Closes[i] - preClose) / preClose : 0, High = s.Highs[i], Low = s.Lows[i], Open = s.Opens[i] }; svList.Prices.Add(sItem); svList.Volumns.Add(new VolumnItem() { Date = s.Dates[i], Value = s.Volumns[i], Turnover = s.Turnovers[i], IsRaise = s.Closes[i] > s.Opens[i] || (s.Closes[i] == s.Opens[i] && sItem.CloseChange > 0) }); if (!calChangeByStart) { preClose = s.Closes[i]; } } } return(svList); }
private void InicializeComponent() { Resizable = false; HasSeparator = false; BorderWidth = 12; //Modal = true; label = new Label(); label.LineWrap = true; label.Selectable = true; label.UseMarkup = true; label.SetAlignment(0.0f, 0.0f); secondaryLabel = new Label(); secondaryLabel.LineWrap = true; secondaryLabel.Selectable = true; secondaryLabel.UseMarkup = true; secondaryLabel.SetAlignment(0.0f, 0.0f); icon = new Image(Stock.DialogInfo, IconSize.Dialog); icon.SetAlignment(0.5f, 0.0f); StockItem item = Stock.Lookup(icon.Stock); Title = item.Label; HBox hbox = new HBox(false, 12); VBox vbox = new VBox(false, 12); vbox.PackStart(label, false, false, 0); vbox.PackStart(secondaryLabel, true, true, 0); hbox.PackStart(icon, false, false, 0); hbox.PackStart(vbox, true, true, 0); VBox.PackStart(hbox, false, false, 0); hbox.ShowAll(); Buttons = MessageDialog.DialogButtonType.OkCancel; }
public void ShowObjectInfoScreen(Transform storeObjectTransform) { StockItem storedStockItem = storeObjectTransform.GetComponent <ItemStockContainer>().InventoryItem; //if (storedStockItem == null) //{ // ShowMessage("Object Info", storeObjectTransform.name + "\n" + "Empty"); //} //else //{ // ShowMessage("Object Info", storeObjectTransform.name + "\n" + storedStockItem.Name + " " + storedStockItem.Amount + " / " + storedStockItem.MaxAmount + "\n" + storedStockItem.Category); //} //Fill info about object into window //Text Transform objectInfoTransform = WindowObjectInfo.transform; objectInfoTransform.Find("Title/txtTitle").GetComponent <Text>().text = storeObjectTransform.name; objectInfoTransform.Find("Description/txtDescription").GetComponent <Text>().text = storeObjectTransform.GetComponent <PlaceableObject>().Description; //Item slot Transform itemSlotTransform = objectInfoTransform.Find("ItemSlots/ItemSlot"); if (storedStockItem != null) //Only if there's an item in the slot { itemSlotTransform.FindChild("TxtItemStatus").GetComponent <Text>().text = storedStockItem.Name + "\n" + storedStockItem.Amount + "/" + storedStockItem.MaxAmount; itemSlotTransform.FindChild("Image").GetComponent <Image>().enabled = true; itemSlotTransform.FindChild("Image").GetComponent <Image>().sprite = StockItemManager.Singleton.GetInventorySprite(storedStockItem.SpriteName); itemSlotTransform.FindChild("Radial").GetComponent <Image>().fillAmount = storedStockItem.Amount / (float)storedStockItem.MaxAmount; } else { itemSlotTransform.FindChild("TxtItemStatus").GetComponent <Text>().text = "Empty"; itemSlotTransform.FindChild("Image").GetComponent <Image>().enabled = false; itemSlotTransform.FindChild("Radial").GetComponent <Image>().fillAmount = 1f; } WindowObjectInfo.SetActive(true); }
public dynamic AddStocktake(string sess, [FromBody] StockTake AddObject) { { var admin = db.Users.Where(zz => zz.SessionID == sess).ToList(); if (admin == null) { dynamic toReturn = new ExpandoObject(); toReturn.Error = "Session is no longer available"; return(toReturn); } if (AddObject != null) { StockTake Takes = new StockTake(); Takes.AdminID = AddObject.AdminID; Takes.Description = AddObject.Description; Takes.Date = DateTime.Now; db.StockTakes.Add(Takes); db.SaveChanges(); int StockTakeID = db.StockTakes.Where(zz => zz.Description == AddObject.Description).Select(zz => zz.StockTakeID).FirstOrDefault(); foreach (StockTakeLine lines in AddObject.StockTakeLines) { StockTakeLine newObject = new StockTakeLine(); newObject.ItemID = lines.ItemID; newObject.StockTakeID = StockTakeID; newObject.Quantity = lines.Quantity; StockItem updateStock = db.StockItems.Where(zz => zz.ItemID == lines.ItemID).FirstOrDefault(); updateStock.QuantityInStock = lines.Quantity; db.StockTakeLines.Add(newObject); db.SaveChanges(); } return("success"); } else { return(null); } } }
} //eom public List <VendorStockItemsView> List_VendorStockItemsPOCO(int vendorID, List <CurrentActiveOrderView> orderDetailPOCOList) { //List<string> businessEXResons = new List<string>(); using (var context = new eToolsContext()) { StockItem theStockItems = (from x in context.StockItems where x.VendorID == vendorID select x).FirstOrDefault(); if (theStockItems == null) { return(null); } else { var theStockItemList = (from x in context.StockItems where x.VendorID == vendorID where x.Discontinued == false select new VendorStockItemsView { SID = x.StockItemID, ItemDescription = x.Description, QOH = x.QuantityOnHand, QOO = x.QuantityOnOrder, ROL = x.ReOrderLevel, Buffer = x.QuantityOnHand + x.QuantityOnOrder - x.ReOrderLevel, Price = x.PurchasePrice }).ToList(); if (orderDetailPOCOList == null) { return(theStockItemList); } else { var theVendorStockItemPOCOView = theStockItemList.Where(xSList => !orderDetailPOCOList.Any(xOList => xOList.SID == xSList.SID)).ToList(); return(theVendorStockItemPOCOView); } //eol } //eol } //eou } //eom
public void SimpleProcessUpdatesTwoAggregatesUsingDefaultHandlersTest() { var eventStore = new InMemoryEventStore(); var contextModel = new BoundedContextModel().WithAssemblyContaining <Location>(); var aggregateModel = new RuntimeModel(contextModel, eventStore); var engine = DomainFactory.CreateDomainExecutionEngine(contextModel, eventStore, DomainOptions.Defaults); var item = new StockItem("item", "123"); engine.Process(CommandFactory.Default.CreateCommand <CreateLocation>("c1", "c1", "ar1", new CreateLocation("ar1"))); engine.Process(CommandFactory.Default.CreateCommand <AdjustIn>("c2", "c1", "ar1", new AdjustIn($"adjustment_{Guid.NewGuid()}", "ar1", item))); engine.Process(CommandFactory.Default.CreateCommand <CreateLocation>("c3", "c3", "ar2", new CreateLocation("ar2"))); var results = engine.Process(CommandFactory.Default.CreateCommand <MoveOut>("c3", "c3", "ar1", new MoveOut($"movement_{Guid.NewGuid()}", "ar1", item, "ar2"))); var movedOutEvent = results.FirstOrDefault(e => e.EventBody is MovedOut); var movedInEvent = results.FirstOrDefault(e => e.EventBody is MovedIn); Assert.IsNotNull(movedOutEvent); Assert.IsNotNull(movedInEvent); }
public void StockItemBalance_should_be_UPDATED_if_it_exists_for_customer() { var tmpStockBalanceList = new StockBalanceList(Uow); var customer = new Customer(Uow); var stockItem1 = new StockItem(Uow) { ID = 1, Name = "Item1" }; var stockItem2 = new StockItem(Uow) { ID = 2, Name = "Item2" }; tmpStockBalanceList.AddNewBalance(customer, stockItem1, 100); tmpStockBalanceList.AddNewBalance(customer, stockItem1, 10); tmpStockBalanceList.AddNewBalance(customer, stockItem2, 120); tmpStockBalanceList.AddNewBalance(customer, stockItem2, 1); tmpStockBalanceList.Count.ShouldBe(2); }
public StockItemDetailsViewModel(StockItem stockItem) { Supplier ItemSupplier = db.Suppliers.Find(stockItem.SupplierID); Person SupplierContact = db.People.Find(ItemSupplier.PrimaryContactPersonID); IEnumerable <InvoiceLine> ItemInvoiceLines = db.InvoiceLines.Where(x => x.StockItemID == stockItem.StockItemID).ToList(); IEnumerable <Customer> ItemCustomers = new List <Customer>(); foreach (var invoice in ItemInvoiceLines) { Customer cust = db.Customers.Find(invoice.Invoice.CustomerID); ItemCustomers.Append(cust); } ItemID = stockItem.StockItemID; Name = stockItem.StockItemName; Size = stockItem.Size; Price = stockItem.UnitPrice; Weight = stockItem.TypicalWeightPerUnit; LeadTime = stockItem.LeadTimeDays; ValidSince = stockItem.ValidFrom; Origin = stockItem.CustomFields; //parse Origin Tags = stockItem.Tags; SupplierName = ItemSupplier.SupplierName; SupplierPhone = ItemSupplier.PhoneNumber; SupplierFax = ItemSupplier.FaxNumber; SupplierWebsite = ItemSupplier.WebsiteURL; SupplierContactName = SupplierContact.FullName; foreach (var invoice in ItemInvoiceLines) { Orders += 1; GrossSales += invoice.ExtendedPrice; GrossProfits += invoice.LineProfit; } TopPurchasers = ItemCustomers.Take(10); }
public void RemoveStockItem() { int id = ValidationService.InputValidInt("Please enter stock item ID to remove it from stock:"); StockItem item = _stockItem.Where(i => i.ID == id).FirstOrDefault(); if (item != null) { int count = ValidationService.InputValidInt("Please enter stock item portion's count to remove from stock:"); if ((item.PortionCount - count) >= 0) { item.PortionCount = item.PortionCount - count; } else { Console.WriteLine("Not enough portion in stock to perform request"); } } else { Console.WriteLine("No such item in stock"); } }
public StockItem GetStockItem(int id) { StockItem item = null; using (var conn = new SqlConnection(OMDB.ConnectionString)) using (var command = new SqlCommand("sp_SelectStockItemById", conn)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@id", id); conn.Open(); var reader = command.ExecuteReader(CommandBehavior.SingleRow); reader.Read(); item = new StockItem( id, reader.GetString(1), reader.GetDecimal(2), reader.GetInt32(3) ); conn.Close(); } return(item); }
public static void ShowAndReloadStickers(long stickerId, string referrer) { StickersPackView.ShowWithLoader(referrer, (Action <Action <BackendResult <StockItem, ResultCode> >, CancellationToken>)((callback, cancellationToken) => StoreService.Instance.GetStockItemByStickerId(stickerId, (Action <BackendResult <StockItem, ResultCode> >)(result => { if (result.ResultCode == ResultCode.Succeeded) { StockItem resultData = result.ResultData; StoreProduct storeProduct = resultData != null ? resultData.product : null; if (storeProduct != null && storeProduct.purchased == 1 && storeProduct.active == 1) { EventAggregator.Current.Publish(new StickersUpdatedEvent(new StockItemHeader(resultData, false, 0, false))); } } Action <BackendResult <StockItem, ResultCode> > action = callback; if (action == null) { return; } BackendResult <StockItem, ResultCode> backendResult = result; action(backendResult); }), new CancellationToken?(cancellationToken))), 0, false); }
public void WhenUpdatingStockItemByIdShouldBeCorrect() { // Arrange var product = Client.GetProductBySku("100000").Result; var productId = product.Result.entity_id; var quantity = Math.Ceiling(new Random().NextDouble() * 100); var isInStock = (quantity%2) == 1; var stockItem = new StockItem { qty = quantity, is_in_stock = isInStock }; // Act var response = Client.UpdateStockItemForProduct(productId, stockItem).Result; // Assert Assert.False(response.HasErrors, response.ErrorString); var updatedProduct = Client.GetProductById(productId).Result; Assert.Equal(quantity, updatedProduct.Result.stock_data.qty); Assert.Equal(isInStock, updatedProduct.Result.stock_data.is_in_stock); }
public ActionResult Remove(int?id) { if (id == null) { return(RedirectToAction("Index")); } StockItem item = SIDB.GetItem(id); if (item == null) { TempData["Message"] = "Item not found!"; return(RedirectToAction("Index")); } if (Request.IsAjaxRequest()) { return(PartialView("RemoveModal", item)); } return(View(item)); }
public async Task ValidateStockItem_GivenAStockItemWithAnEmptyWholesalerId_ShouldReturAValidationResultWithExpectedMessage() { //Arrange var guid = Guid.NewGuid(); var stockItem = new StockItem { WholesalerId = Guid.Empty, UnitPrice = 1.0f, Quantity = 10 }; var expectedMessage = "The wholesaler cannot be null or empty"; var wholesalerValidation = new WholesalerValidation(null); //Act var results = await wholesalerValidation.ValidateStockItem(stockItem); //Assert Assert.Contains(results, result => result != null && result.ErrorMessage.Equals(expectedMessage)); }
public void ShouldDecreaseStockCountOnReduceAndReturnTrue() { var stockId = 1; var stockLevel = 1; var stockItem = new StockItem() { Id = stockId, Stock = stockLevel }; var stock = InitializeWithStock(stockItem); _stockRepository .RemoveStock(stockId) .ShouldBeTrue(); stockItem = _stockRepository .GetStockItem(stockId); stockItem.Stock.ShouldBe(stockLevel - 1); }
public void ProcessEventToCommand() { var movement = "movementId"; var location = "location"; var item = new StockItem("item", "1"); var toLocation = "toLocation"; var eventHandlerId = $"{typeof(Movement).Name}\\{movement}"; var storedEventStreamId = eventHandlerId; var @event = EventFactory.Default.CreateEvent <Location, MovedOut>(location, 3, "commandId", "correlationId", new MovedOut(movement, location, item, toLocation)); var eventEngine = DomainFactory.CreateEventHandler(this.boundedContextModel, this.eventStore.Object); var commands = eventEngine.Handle(@event, eventHandlerId, typeof(Movement)); Assert.IsTrue(commands.Count() == 1); this.eventStore.Verify(x => x.Store(storedEventStreamId, It.Is <IEnumerable <IEvent> >(x => x.First().EventBody as MovedOut == @event.EventBody))); Assert.IsTrue(commands.Single().AggregateId == toLocation); Assert.IsTrue(commands.Single().CorrelationId == @event.CorrelationId); }
//Retrieving the files that are attached to a stock item public static void ExportStockItemFiles(DefaultSoapClient soapClient) { Console.WriteLine( "Retrieving the files that are attached to a stock item..."); //Parameters of filtering string inventoryID = "AAMACHINE1"; //Filter the items by inventory ID StockItem stockItemToBeFound = new StockItem { InventoryID = new StringSearch { Value = inventoryID }, ImageUrl = new StringReturn(), ReturnBehavior = ReturnBehavior.OnlySpecified }; //Get the stock item record StockItem stockItem = (StockItem)soapClient.Get(stockItemToBeFound); //Get the files that are attached to the stock item and //save them on a local disc if (stockItem != null && stockItem.ImageUrl != null) { //Get the attached files Default.File[] files = soapClient.GetFiles(stockItem); //Save the files on disc foreach (Default.File file in files) { //The file name obtained from Acumatica ERP has the following //format: Stock Items (<Inventory ID>)\<File Name> string fileName = Path.GetFileName(file.Name); System.IO.File.WriteAllBytes(fileName, file.Content); } } }
public IEnumerable<StockItemHistoryBase> GetHistory(StockItem stockItem, DateTime start, DateTime end) { return stockItem.History.Where(h => h.DateTime >= start && h.DateTime <= end); }
public static void RemoveItem(StockItem item) { repo.Delete(item); repo.SaveChanges(); }
public static void AddItem(StockItem item) { repo.Add(item); repo.SaveChanges(); }
public void SetUp() { stockItem = StockItem.Create("widget", "small", now, user); domainEventService = new DummyDomainEventService(); publishStockItemInStockChangedOnOutOfStock = new PublishStockItemInStockChangedOnOutOfStock(domainEventService); }
//Return the comma-delimited string for the specified stock item public string WriteStockItem(StockItem s) { return s.ToString (); }
public void TestLessThan0Cost() { si = new StockItem("1234", "Test", "Test", -1.0, 5, 5); }
public void TestLessThan0CurrentStock() { si = new StockItem("1234", "Test", "Test", 1.0, -1, 5); }
public void TestLessThan0RequiredStock() { si = new StockItem("1234", "Test", "Test", 1.0, 5, -1); }
public StockItem Parse() { // Information as to how these standards are ACTUALLY parsed can be found here: // http://www.hibcc.org/publication/view/supplier-labeling-standard/ // That being said, I will be returning static data for the purposes of this // exercise as a PoC. This will be different data than R1 to verify data is being parsed correctly. var item = new StockItem(555, 999, null, new DateTime(2016, 12, 30)); return item; }
private StockVolumnList FromCompleteStock(CompleteShare s) { StockVolumnList svList = new StockVolumnList(); if (s.Dates != null) { svList.Prices = new List<StockItem>(s.Dates.Count); svList.Volumns = new List<VolumnItem>(s.Dates.Count); double preClose = calChangeByStart ? s.Closes[0] : 0; for (int i = 0; i < s.Dates.Count; i++) { var sItem = new StockItem() { Date = s.Dates[i], Value = s.Closes[i], ValueChange = i != 0 ? (s.Closes[i] - preClose) / preClose : 0, High = s.Highs[i], Low = s.Lows[i], Open = s.Opens[i] }; svList.Prices.Add(sItem); svList.Volumns.Add(new VolumnItem() { Date = s.Dates[i], Value = s.Volumns[i], Turnover = s.Turnovers[i], IsRaise = s.Closes[i] > s.Opens[i] || (s.Closes[i] == s.Opens[i] && sItem.CloseChange > 0) }); if (!calChangeByStart) preClose = s.Closes[i]; } } return svList; }
public StockItem MergeChartItem(StockItem source, StockItem target) { source.Date = target.Date; source.Close = target.Close; if (source.High < target.High) { source.High = target.High; } if (source.Low > target.Low) { source.Low = target.Low; } return source; }
public IEnumerable<StockItemHistoryBase> GetHistory(StockItem stockItem, DateTime start, DateTime end) { return GetHistoryDelegate(stockItem, start, end); }
public void TestCreateStockItemInvalidCurrentStock() { int invalidStock = -1; StockItem si = new StockItem("0001", "", "", 0.0, 0, invalidStock); }
public StockItemDeactivated(DateTime dateTime, string user, StockItem stockItem, int level) : base(dateTime, user, stockItem, level) { }
public void TestCreateStockItemInvalidStockCode() { String invalidStockCode = "00001"; StockItem si = new StockItem(invalidStockCode, "", "", 0.0, 0, 0); }
public void SetUp() { stockItem = StockItem.Create(productName, sizeName, dateCreated, user); }
public void TestCreateStockItemInvalidRequiredStock() { int invalidStock = -1; StockItem si = new StockItem("0001", "", "", 0.0, invalidStock, 0); }
public ReceivedStock(int numberOfItemsRecieved, DateTime dateTime, string user, StockItem stockItem, int level) : base(dateTime, user, stockItem, level) { NumberOfItemsRecieved = numberOfItemsRecieved; }