private void setList(SearchResult i_Result) { ItemsList = new List <Item>(); foreach (SearchItem item in i_Result.item) { Item itemToAddToList = new Models.Item { ItemID = item.itemId, ItemPictureURL = item.galleryURL, ItemPrice = item.sellingStatus.convertedCurrentPrice.Value.ToString(), ItemTitle = item.title, ItemCondition = item.condition.ToString(), ItemLink = item.viewItemURL, ItemProfitableLink = item.viewItemURL, ItemShipingPrice = item.shippingInfo.shippingServiceCost.Value.ToString(), ItemShipingToCountry = item.shippingInfo.shipToLocations, ItemSourceCountry = item.location, ItemComments = item.subtitle, ItemPriceCorency = item.sellingStatus.currentPrice.currencyId, ItemSourceWebSite = eSourceSites.eBay }; ItemsList.Add(itemToAddToList); } }
/// <summary> /// Renders the panel. /// </summary> /// <param name="output">The output writer.</param> /// <param name="ribbon">The ribbon.</param> /// <param name="button">The button.</param> /// <param name="context">The context.</param> public override void Render(HtmlTextWriter output, Ribbon ribbon, Item button, CommandContext context) { this.CatalogView = context.CustomData as ICatalogView; this.Initilize(); Order currentOrder = this.Presenter.CurrentOrder(); if (currentOrder != null) { RenderText(output, this.GetText(currentOrder)); IEnumerable<OrderStatusCommand> commands = this.Presenter.GetOrderStatusesCommands(currentOrder.Status); Sitecore.Context.ClientPage.ClientResponse.DisableOutput(); foreach (OrderStatusCommand command in commands) { this.RenderSmallButton(output, ribbon, string.Empty, command.Title, command.Icon, command.Title, new OrderStatusCommandBuilder(currentOrder, command).ToString(), this.Enabled, false); } Sitecore.Context.ClientPage.ClientResponse.EnableOutput(); } }
public InventoryReportLineVM(Item item) { _item = item; }
/// <summary> /// Creates a product view model based on an Item and Rendering /// </summary> /// <param name="productItem">The product item to based the model on</param> /// <param name="rendering">The rendering to initialize the model with</param> /// <returns>A Product View Model</returns> protected ProductViewModel GetProductViewModel(Item productItem, Rendering rendering) { if (this.CurrentSiteContext.Items[CurrentProductViewModelKeyName] != null) { return (ProductViewModel) this.CurrentSiteContext.Items[CurrentProductViewModelKeyName]; } var variants = new List<VariantViewModel>(); if (productItem != null && productItem.HasChildren) { foreach (Item item in productItem.Children) { var v = new VariantViewModel(item); variants.Add(v); } } var productViewModel = new ProductViewModel(); productViewModel.Initialize(rendering, variants); PopulateStockInformation(productViewModel); this.CurrentSiteContext.Items[CurrentProductViewModelKeyName] = productViewModel; return (ProductViewModel)this.CurrentSiteContext.Items[CurrentProductViewModelKeyName]; }
/// <summary> /// This method returns child products for this category /// </summary> /// <param name="searchOptions">The options to perform the search with</param> /// <param name="categoryItem">The category item whose children to retrieve</param> /// <returns>A list of child products</returns> protected SearchResults GetChildProducts(CommerceSearchOptions searchOptions, Item categoryItem) { IEnumerable<CommerceQueryFacet> facets = null; var returnList = new List<Item>(); var totalPageCount = 0; var totalProductCount = 0; if (Item != null) { SearchResponse searchResponse = null; if (CatalogUtility.IsItemDerivedFromCommerceTemplate(categoryItem, CommerceConstants.KnownTemplateIds.CommerceDynamicCategoryTemplate)) { var defaultBucketQuery = categoryItem[CommerceConstants.KnownSitecoreFieldNames.DefaultBucketQuery]; var persistendBucketFilter = categoryItem[CommerceConstants.KnownSitecoreFieldNames.PersistentBucketFilter]; persistendBucketFilter = CleanLanguageFromFilter(persistendBucketFilter); searchResponse = SearchNavigation.SearchCatalogItems(defaultBucketQuery, persistendBucketFilter, searchOptions); } else { searchResponse = SearchNavigation.GetCategoryProducts(categoryItem.ID, searchOptions); } if (searchResponse != null) { returnList.AddRange(searchResponse.ResponseItems); totalProductCount = searchResponse.TotalItemCount; totalPageCount = searchResponse.TotalPageCount; facets = searchResponse.Facets; } } var results = new SearchResults(returnList, totalProductCount, totalPageCount, searchOptions.StartPageIndex, facets); return results; }
/// <summary> /// Builds a category view model or retrieves it if it already exists /// </summary> /// <param name="productSearchOptions">The product options class for finding child products</param> /// <param name="categorySearchOptions">The category options classf or finding child categories</param> /// <param name="sortFields">The fields to sort he results on</param> /// <param name="item">The item.</param> /// <param name="rendering">The rendering to initialize the model with</param> /// <returns> /// A category view model /// </returns> protected virtual LandingPageViewModel GetLandingPageViewModel(CommerceSearchOptions productSearchOptions, CommerceSearchOptions categorySearchOptions, IEnumerable<CommerceQuerySort> sortFields, Item item, Rendering rendering) { if (this.CurrentSiteContext.Items[CurrentCategoryViewModelKeyName] == null) { var categoryViewModel = new LandingPageViewModel(item); this.CurrentSiteContext.Items[CurrentCategoryViewModelKeyName] = categoryViewModel; } var viewModel = (LandingPageViewModel)this.CurrentSiteContext.Items[CurrentCategoryViewModelKeyName]; return viewModel; }
/// <summary> /// This method returns child categories for this category /// </summary> /// <param name="searchOptions">The options to perform the search with</param> /// <param name="categoryItem">The category item whose children to retrieve</param> /// <returns>A list of child categories</returns> protected CategorySearchResults GetChildCategories(CommerceSearchOptions searchOptions, Item categoryItem) { var returnList = new List<Item>(); var totalPageCount = 0; var totalCategoryCount = 0; if (Item != null) { var searchResponse = SearchNavigation.GetCategoryChildCategories(categoryItem.ID, searchOptions); returnList.AddRange(searchResponse.ResponseItems); totalCategoryCount = searchResponse.TotalItemCount; totalPageCount = searchResponse.TotalPageCount; } var results = new CategorySearchResults(returnList, totalCategoryCount, totalPageCount, searchOptions.StartPageIndex, new List<FacetCategory>()); return results; }
private static decimal CalculateCOGS(ERPContext context, Item item, int quantity) { var purchases = context.PurchaseTransactionLines .Include("PurchaseTransaction") .Where(e => e.ItemID.Equals(item.ID) && e.SoldOrReturned < e.Quantity) .OrderBy(purchaseTransactionLine => purchaseTransactionLine.PurchaseTransactionID) .ThenByDescending(purchaseTransactionLine => purchaseTransactionLine.Quantity - purchaseTransactionLine.SoldOrReturned) .ThenByDescending(purchaseTransactionLine => purchaseTransactionLine.PurchasePrice) .ThenByDescending(purchaseTransactionLine => purchaseTransactionLine.Discount) .ThenByDescending(purchaseTransactionLine => purchaseTransactionLine.WarehouseID) .ToList(); var totalCOGS = 0m; var tracker = quantity; foreach (var purchase in purchases) { var availableQuantity = purchase.Quantity - purchase.SoldOrReturned; var purchaseLineNetTotal = purchase.PurchasePrice - purchase.Discount; if (tracker <= availableQuantity) { if (purchaseLineNetTotal == 0) break; var fractionOfTransactionDiscount = tracker * purchaseLineNetTotal / purchase.PurchaseTransaction.GrossTotal * purchase.PurchaseTransaction.Discount; var fractionOfTransactionTax = tracker * purchaseLineNetTotal / purchase.PurchaseTransaction.GrossTotal * purchase.PurchaseTransaction.Tax; totalCOGS += tracker * purchaseLineNetTotal - fractionOfTransactionDiscount + fractionOfTransactionTax; break; } if (tracker > availableQuantity) { tracker -= availableQuantity; if (purchaseLineNetTotal == 0) continue; var fractionOfTransactionDiscount = availableQuantity * purchaseLineNetTotal / purchase.PurchaseTransaction.GrossTotal * purchase.PurchaseTransaction.Discount; var fractionOfTransactionTax = availableQuantity * purchaseLineNetTotal / purchase.PurchaseTransaction.GrossTotal * purchase.PurchaseTransaction.Tax; totalCOGS += availableQuantity * purchaseLineNetTotal - fractionOfTransactionDiscount + fractionOfTransactionTax; } } return totalCOGS; }
private static void DecreaseStock(ERPContext context, Warehouse warehouse, Item item, int quantity) { var stock = context.Stocks.Single(e => e.ItemID.Equals(item.ID) && e.WarehouseID.Equals(warehouse.ID)); stock.Pieces += quantity; if (stock.Pieces == 0) context.Stocks.Remove(stock); }
private static void IncreaseStock(ERPContext context, Warehouse warehouse, Item item, int quantity) { var stockFromDatabase = context.Stocks.SingleOrDefault( stock => stock.ItemID.Equals(item.ID) && stock.WarehouseID.Equals(warehouse.ID)); if (stockFromDatabase == null) { var newStock = new Stock { Item = item, Warehouse = warehouse, Pieces = quantity }; context.Stocks.Add(newStock); } else stockFromDatabase.Pieces += quantity; }
private static void IncreaseSoldOrReturned(ERPContext context, Item item, int quantity) { var purchases = context.PurchaseTransactionLines .Include("PurchaseTransaction") .Where(e => e.ItemID.Equals(item.ID) && e.SoldOrReturned < e.Quantity) .OrderBy(purchaseTransactionLine => purchaseTransactionLine.PurchaseTransactionID) .ThenByDescending(purchaseTransactionLine => purchaseTransactionLine.Quantity - purchaseTransactionLine.SoldOrReturned) .ThenByDescending(purchaseTransactionLine => purchaseTransactionLine.PurchasePrice) .ThenByDescending(purchaseTransactionLine => purchaseTransactionLine.Discount) .ThenByDescending(purchaseTransactionLine => purchaseTransactionLine.WarehouseID) .ToList(); var tracker = quantity; foreach (var purchase in purchases) { var availableQuantity = purchase.Quantity - purchase.SoldOrReturned; if (tracker <= availableQuantity) { purchase.SoldOrReturned += tracker; break; } if (tracker > availableQuantity) { purchase.SoldOrReturned += availableQuantity; tracker -= availableQuantity; } } }