public static System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.Stats> ItemWaste(string sku)
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("Stats", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "ItemWaste")) {
         System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.Stats> stats = new System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.Stats>();
         decimal?result = new decimal?();
         System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.Item> items = new System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.Item>();
         DSS1_RetailerDriverStockOptimisation.BO.Item foundItem = new DSS1_RetailerDriverStockOptimisation.BO.Item();
         if ((sku == null || sku == ""))
         {
         }
         else
         {
             try {
                 foundItem = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().GetById <DSS1_RetailerDriverStockOptimisation.BO.Item>(sku);
             }
             catch (System.Exception x) {
             }
             if (foundItem != null)
             {
             }
         }
         System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.WasteOld> wastes = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().Get <DSS1_RetailerDriverStockOptimisation.BO.WasteOld>((a) => a.Item.SKU == foundItem.SKU);
         foreach (var waste in wastes ?? Enumerable.Empty <DSS1_RetailerDriverStockOptimisation.BO.WasteOld>())
         {
             DSS1_RetailerDriverStockOptimisation.BO.Stats stat = new DSS1_RetailerDriverStockOptimisation.BO.Stats();
             stat.Item = foundItem; stat.Percentage = (waste?.WastePercentage ?? 0); stat.DateFormatted = (waste?.DateFormatted ?? ""); stats?.Add(stat);
         }
         stats = stats?.OrderBy((a) => a.Date).ToList().ToList(); return(stats);
     }
 }
 public static System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.Stats> itemSLALeadTime(string sku)
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("Stats", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "itemSLALeadTime")) {
         decimal?result = new decimal?();
         System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.Stats> stats = new System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.Stats>();
         System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.Item>  items = new System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.Item>();
         DSS1_RetailerDriverStockOptimisation.BO.Item foundItem = new DSS1_RetailerDriverStockOptimisation.BO.Item();
         if ((sku == null || sku == ""))
         {
         }
         else
         {
             try {
                 foundItem = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().GetById <DSS1_RetailerDriverStockOptimisation.BO.Item>(sku);
             }
             catch (System.Exception x) {
             }
             if (foundItem != null)
             {
             }
         }
         foreach (var slaLead in foundItem?.SLALeadTimes?.Take(10).ToList() ?? Enumerable.Empty <DSS1_RetailerDriverStockOptimisation.BO.SLALeadTime>())
         {
             DSS1_RetailerDriverStockOptimisation.BO.Stats stat = new DSS1_RetailerDriverStockOptimisation.BO.Stats();
             stat.Item = foundItem; stat.Percentage = (slaLead?.Percentage ?? 0); stat.DateFormatted = (slaLead?.SLALeadDate?.ToString("MMMM dd, yyyy") ?? ""); stat.Threshold = (slaLead?.Threshold ?? 0); stat.Date = (slaLead?.SLALeadDate ?? System.Data.SqlTypes.SqlDateTime.MinValue.Value); stats?.Add(stat);
         }
         stats = stats?.OrderBy((a) => a.Date).ToList().ToList(); return(stats);
     }
 }
 public static System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.InventoryDaysKPI> InventoryDaysKPI(string sku, int?warehouseId, DateTime?fromDate, DateTime?toDate)
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("InventoryDaysKPI", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "InventoryDaysKPI")) {
         System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.InventoryDaysKPI> kpis = new System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.InventoryDaysKPI>();
         DSS1_RetailerDriverStockOptimisation.BO.Item item = new DSS1_RetailerDriverStockOptimisation.BO.Item();
         try {
             item = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().GetById <DSS1_RetailerDriverStockOptimisation.BO.Item>(sku);
         }
         catch (System.Exception x) {
         }
         if ((item == null))
         {
             return(kpis);
         }
         DSS1_RetailerDriverStockOptimisation.BO.Warehouse            warehouse = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().GetAsQueryable <DSS1_RetailerDriverStockOptimisation.BO.Warehouse>((a) => a.Id == warehouseId)?.FirstOrDefault();
         DSS1_RetailerDriverStockOptimisation.BO.SalesForecastDetails sale      = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().GetAsQueryable <DSS1_RetailerDriverStockOptimisation.BO.SalesForecastDetails>((s) => s.Item.SKU == item.SKU && s.Warehouse.Id == warehouse.Id)?.FirstOrDefault();
         decimal?inventoryDays = 0;
         var     _var4 = (fromDate?.Date ?? System.Data.SqlTypes.SqlDateTime.MinValue.Value); var _var5 = (toDate?.Date ?? System.Data.SqlTypes.SqlDateTime.MinValue.Value); foreach (var stock in item?.StocksOnHand?.Where((s) => s.StockOnHandDate.GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value).Date >= _var4 && s.StockOnHandDate.GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value).Date <= _var5 && s.Warehouse == warehouse).ToList() ?? Enumerable.Empty <DSS1_RetailerDriverStockOptimisation.BO.StockOnHand>())
         {
             DSS1_RetailerDriverStockOptimisation.BO.InventoryDaysKPI kpi = new DSS1_RetailerDriverStockOptimisation.BO.InventoryDaysKPI();
             kpi.SalesForecastDate = (stock?.StockOnHandDate ?? System.Data.SqlTypes.SqlDateTime.MinValue.Value); kpi.SalesForecastDateFormatted = (stock?.StockOnHandDate?.ToString("yyyy/MM/dd") ?? ""); if (sale == null)
             {
                 kpi.InventoryDays = 0;
             }
             else
             {
                 kpi.InventoryDays = (stock?.Units ?? 0) / (sale?.AvgDailyDemandForecast ?? 0);
             }
             kpi.ItemDescription = (item?.Description?.Substring(0, 15) ?? ""); kpis?.Add(kpi);
         }
         kpis = kpis?.OrderBy((a) => a.SalesForecastDate).ToList().ToList(); zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Info, "InventoryDaysKPI", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "stats length: " + (kpis?.Count() ?? 0));
         return(kpis);
     }
 }
示例#4
0
 public static System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.SLAStatistics> ItemLeadTimePercentage(string sku)
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("SLALeadTime", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "ItemLeadTimePercentage")) {
         DSS1_RetailerDriverStockOptimisation.BO.Item item = new DSS1_RetailerDriverStockOptimisation.BO.Item();
         System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.SLAStatistics> stats = new System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.SLAStatistics>();
         if ((sku == null || sku == ""))
         {
             return(stats);
         }
         else
         {
             try {
                 item = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().GetById <DSS1_RetailerDriverStockOptimisation.BO.Item>(sku);
             }
             catch (System.Exception x) {
             }
         }
         foreach (var leadTime in item?.SLALeadTimes ?? Enumerable.Empty <DSS1_RetailerDriverStockOptimisation.BO.SLALeadTime>())
         {
             DSS1_RetailerDriverStockOptimisation.BO.SLAStatistics stat = new DSS1_RetailerDriverStockOptimisation.BO.SLAStatistics();
             stat.Item = item; stat.Percentage = (leadTime?.MonthlyPercentage ?? 0); stat.Month = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName((leadTime?.Month ?? 0)); stat.Threshold = 80; stats?.Add(stat);
         }
         return(stats);
     }
 }
 public static void CreateNotifications(DSS1_RetailerDriverStockOptimisation.BO.OrderForecast orderForecast)
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("Notification", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "CreateNotifications")) {
         zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Info, "Notification", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Creating Alerts for Order Forecast: " + (orderForecast?.Id ?? 0));
         System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.OrderForecastDetails> forecastOrderDetails = orderForecast?.OrderForecastDetails;
         foreach (var order in forecastOrderDetails ?? Enumerable.Empty <DSS1_RetailerDriverStockOptimisation.BO.OrderForecastDetails>())
         {
             if ((order?.Notification != null))
             {
                 zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Info, "Notification", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "---- Deleting " + (order?.Notification?.Id ?? 0) + "----");
                 new DSS1_RetailerDriverStockOptimisation.DAL.Repository().DeleteNotification(order?.Notification);
             }
             DSS1_RetailerDriverStockOptimisation.BO.Item currItem = order?.Item;
             var _var0 = currItem?.SKU; var _var1 = order?.RecommendedOrderDate?.Date; DSS1_RetailerDriverStockOptimisation.BO.SupplierCapacity supplierCapacity = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().GetAsQueryable <DSS1_RetailerDriverStockOptimisation.BO.SupplierCapacity>((a) => a.Item.SKU == _var0 && a.DateOfStockUpdate.GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value).Date == _var1)?.FirstOrDefault();
             if ((supplierCapacity == null || supplierCapacity?.Stock == 0))
             {
                 zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "Notification", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Don't have supplier capacity for item : " + (currItem?.SKU ?? ""));
                 continue;
             }
             int?totalStock    = (supplierCapacity?.Stock ?? 0);
             int?orderQuantity = (int)((order?.Quantity ?? 0));
             zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "Notification", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "totalStock " + (totalStock?.ToString() ?? "") + " : orderQuantity" + (orderQuantity?.ToString() ?? ""));
             if ((totalStock < orderQuantity))
             {
                 DSS1_RetailerDriverStockOptimisation.BO.Notification notification = new DSS1_RetailerDriverStockOptimisation.BO.Notification();
                 notification.Message = "Low Stock"; notification.Item = currItem; notification.Warehouse = order?.Warehouse; notification.TotalSupplierStock = totalStock; notification.SalesForecastDate = (order?.RecommendedOrderDate ?? System.Data.SqlTypes.SqlDateTime.MinValue.Value); notification.OrderForecastQuantity = orderQuantity; notification.Diff = orderQuantity.GetValueOrDefault(0) - totalStock.GetValueOrDefault(0); notification.OrderForecastDetails = order; notification.CreatedBy = "System"; new DSS1_RetailerDriverStockOptimisation.DAL.Repository().Save <DSS1_RetailerDriverStockOptimisation.BO.Notification>(notification);
                 zAppDev.DotNet.Framework.Utilities.EMailMessage em = new zAppDev.DotNet.Framework.Utilities.EMailMessage();
                 em.To = new List <string> {
                     "*****@*****.**"
                 }.ToList(); em.Subject = "New Alert"; em.IsBodyHtml = true; em.Body = "A new alert is created due to low stock " + "for the Item: " + (notification?.Item?.SKU ?? ""); zAppDev.DotNet.Framework.Utilities.Email.SendMail(em, true);
             }
             string recommendationThresholdPercentString = zAppDev.DotNet.Framework.Identity.Model.ApplicationSetting.GetValue("RecommendationThresholdPercent");
             if (((recommendationThresholdPercentString == null || recommendationThresholdPercentString.Trim() == "")))
             {
                 continue;
             }
             int?recommendationThresholdPercent = int.Parse(recommendationThresholdPercentString);
             if ((100 * (totalStock.GetValueOrDefault(0) - orderQuantity.GetValueOrDefault(0)) / totalStock.GetValueOrDefault(0) >= recommendationThresholdPercent))
             {
                 DSS1_RetailerDriverStockOptimisation.BO.Notification notification = new DSS1_RetailerDriverStockOptimisation.BO.Notification();
                 notification.Message = "Excess of Stock"; notification.Item = currItem; notification.Warehouse = order?.Warehouse; notification.TotalSupplierStock = totalStock; notification.SalesForecastDate = (order?.RecommendedOrderDate ?? System.Data.SqlTypes.SqlDateTime.MinValue.Value); notification.OrderForecastQuantity = orderQuantity; notification.Diff = totalStock.GetValueOrDefault(0) - orderQuantity.GetValueOrDefault(0); notification.OrderForecastDetails = order; notification.CreatedBy = "System"; new DSS1_RetailerDriverStockOptimisation.DAL.Repository().Save <DSS1_RetailerDriverStockOptimisation.BO.Notification>(notification);
             }
         }
     }
 }
 public static System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.UnitsKPI> UnitsKPI(string sku, int?warehouseId, DateTime?fromDate, DateTime?toDate)
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("UnitsKPI", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "UnitsKPI")) {
         System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.UnitsKPI> kpis = new System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.UnitsKPI>();
         DSS1_RetailerDriverStockOptimisation.BO.Item item = new DSS1_RetailerDriverStockOptimisation.BO.Item();
         try {
             item = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().GetById <DSS1_RetailerDriverStockOptimisation.BO.Item>(sku);
         }
         catch (System.Exception x) {
         }
         if ((item == null))
         {
             return(kpis);
         }
         DSS1_RetailerDriverStockOptimisation.BO.Warehouse warehouse = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().GetAsQueryable <DSS1_RetailerDriverStockOptimisation.BO.Warehouse>((a) => a.Id == warehouseId)?.FirstOrDefault();
         var _var2 = (fromDate?.Date ?? System.Data.SqlTypes.SqlDateTime.MinValue.Value); var _var3 = (toDate?.Date ?? System.Data.SqlTypes.SqlDateTime.MinValue.Value); foreach (var stock in item?.StocksOnHand?.Where((s) => s.Warehouse == warehouse && s.StockOnHandDate.GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value).Date >= _var2 && s.StockOnHandDate.GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value).Date <= _var3).ToList() ?? Enumerable.Empty <DSS1_RetailerDriverStockOptimisation.BO.StockOnHand>())
         {
             DSS1_RetailerDriverStockOptimisation.BO.UnitsKPI kpi = new DSS1_RetailerDriverStockOptimisation.BO.UnitsKPI();
             kpi.SalesForecastDate = (stock?.StockOnHandDate ?? System.Data.SqlTypes.SqlDateTime.MinValue.Value); kpi.SalesForecastDateFormatted = (stock?.StockOnHandDate?.ToString("yyyy/MM/dd") ?? ""); kpi.Units = (stock?.Units ?? 0); kpis?.Add(kpi);
         }
         kpis = kpis?.OrderBy((a) => a.SalesForecastDate).ToList().ToList(); return(kpis);
     }
 }
示例#7
0
 public static System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.OrderForecastStatistic> OrderForecastForSKU(DSS1_RetailerDriverStockOptimisation.BO.Item item)
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("OrderForecastStatistic", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "OrderForecastForSKU")) {
         System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.OrderForecastStatistic> orderStats     = new System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.OrderForecastStatistic>();
         System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.OrderForecastDetails>   orderProposals = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().Get <DSS1_RetailerDriverStockOptimisation.BO.OrderForecastDetails>((a) => a.Item.SKU == item.SKU);
         if ((orderProposals?.Count() ?? 0) >= 10)
         {
         }
         foreach (var orderProposal in orderProposals ?? Enumerable.Empty <DSS1_RetailerDriverStockOptimisation.BO.OrderForecastDetails>())
         {
             DSS1_RetailerDriverStockOptimisation.BO.OrderForecastStatistic stat = new DSS1_RetailerDriverStockOptimisation.BO.OrderForecastStatistic();
             stat.Quantity = (orderProposal?.Quantity ?? 0); stat.RoundQuantity = (orderProposal?.RoundQuantity ?? 0); stat.OrderDate = (orderProposal?.RecommendedOrderDate ?? System.Data.SqlTypes.SqlDateTime.MinValue.Value); stat.OrderDateFormatted = (orderProposal?.RecommendedOrderDate?.ToString("MMMM dd, yyyy") ?? ""); stat.Item = item; stat.Warehouse = orderProposal?.Warehouse; orderStats?.Add(stat);
         }
         return(orderStats);
     }
 }