Beispiel #1
0
 public static System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.TurnoverStatistic> GetTurnoverStatisticsForSupplier(DSS5_SupplyChainFinancialsOptimisation.BO.Supplier supplier)
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("TurnoverStatistic", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "GetTurnoverStatisticsForSupplier")) {
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.TurnoverStatistic> stats        = new System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.TurnoverStatistic>();
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>       transactions = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>((a) => a.Supplier.UserName == supplier.UserName);
         System.Collections.Generic.List <int?> years = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().GetAsQueryable <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>((a) => a.Supplier.UserName == supplier.UserName)?.Select((a) => a.TransactionDateOccured.GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value).Year).Select(_n => _n as int?).ToList().Distinct().ToList().OrderBy((a) => a.GetValueOrDefault(0).ToString()).ToList();
         foreach (var year in years ?? Enumerable.Empty <int?>())
         {
             DSS5_SupplyChainFinancialsOptimisation.BO.TurnoverStatistic stat = new DSS5_SupplyChainFinancialsOptimisation.BO.TurnoverStatistic();
             stat.Supplier = supplier; stat.TotalAmount = (transactions?.Where((a) => a.TransactionDateOccured.GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value).Year == year).Sum((a) => a.TransactionValue) ?? 0); stat.Year = year; stat.TotalAmountFunded = (transactions?.Where((a) => a.TransactionDateOccured.GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value).Year == year).Sum((a) => a.FundedAmount) ?? 0); stats?.Add(stat);
         }
         return(stats);
     }
 }
Beispiel #2
0
 public static System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.TurnoverStatistic> GetTurnoverStatisticsPerMonth(DSS5_SupplyChainFinancialsOptimisation.BO.Supplier supplier, int?year)
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("TurnoverStatistic", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "GetTurnoverStatisticsPerMonth")) {
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.TurnoverStatistic> stats        = new System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.TurnoverStatistic>();
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>       transactions = new System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>();
         System.Collections.Generic.List <int?> months = new System.Collections.Generic.List <int?>();
         try {
             transactions = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>((a) => a.Supplier.UserName == supplier.UserName && a.TransactionDateOccured.GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value).Year == year).ToList(); months = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().GetAsQueryable <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>((a) => a.Supplier.UserName == supplier.UserName)?.Select((a) => a.TransactionDateOccured.GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value).Month).Select(_n => _n as int?).ToList().Distinct().ToList().ToList(); months = months.OrderBy((a) => a).ToList().ToList(); foreach (var month in months ?? Enumerable.Empty <int?>())
             {
                 DSS5_SupplyChainFinancialsOptimisation.BO.TurnoverStatistic stat = new DSS5_SupplyChainFinancialsOptimisation.BO.TurnoverStatistic();
                 stat.Supplier = supplier; stat.TotalAmount = (transactions?.Where((a) => a.TransactionDateOccured.GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value).Month == month).Sum((a) => a.TransactionValue) ?? 0); stat.TotalAmountFunded = (transactions?.Where((a) => a.TransactionDateOccured.GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value).Month == month).Sum((a) => a.FundedAmount) ?? 0); stat.Month = month; stats?.Add(stat);
             }
         }
         catch (System.Exception e) {
             zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Error, "TurnoverStatistic", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Error" + e.Message);
             zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Error, "TurnoverStatistic", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "OH-OH!!!!" + transactions?.Count((a) => a != null) + "--------------" + months.Count((a) => a != null));
         }
         return(stats);
     }
 }
 public static int?DataAvailability(string UserName)
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("DataAvailability", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "DataAvailability")) {
         int?count = 0;
         DSS5_SupplyChainFinancialsOptimisation.BO.Supplier supplier = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().GetById <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier>(UserName);
         if ((supplier?.DataAvailability?.Orders ?? false))
         {
             count = count.GetValueOrDefault(0) + 1;
         }
         if ((supplier?.DataAvailability?.DeliveryNotes ?? false))
         {
             count = count.GetValueOrDefault(0) + 1;
         }
         if ((supplier?.DataAvailability?.CustomsDocuments ?? false))
         {
             count = count.GetValueOrDefault(0) + 1;
         }
         if ((supplier?.DataAvailability?.IntermediaryLogistics ?? false))
         {
             count = count.GetValueOrDefault(0) + 1;
         }
         if ((supplier?.DataAvailability?.Invoices ?? false))
         {
             count = count.GetValueOrDefault(0) + 1;
         }
         if ((supplier?.DataAvailability?.PoDs ?? false))
         {
             count = count.GetValueOrDefault(0) + 1;
         }
         if ((supplier?.DataAvailability?.PaymentData ?? false))
         {
             count = count.GetValueOrDefault(0) + 1;
         }
         zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "DataAvailability", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "count " + (count?.ToString() ?? ""));
         return(count);
     }
 }
 public static System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.CreditNote> FindCreditNote()
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("CreditNote", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "FindCreditNote")) {
         string userName = "";
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Agreement>  agreements = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <DSS5_SupplyChainFinancialsOptimisation.BO.Agreement>((a) => a.Investor.UserName == zAppDev.DotNet.Framework.Identity.IdentityHelper.GetCurrentApplicationUser().UserName);
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.CreditNote> foundNotes = new System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.CreditNote>();
         foreach (var agr in agreements ?? Enumerable.Empty <DSS5_SupplyChainFinancialsOptimisation.BO.Agreement>())
         {
             zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "CreditNote", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "-------2-------");
             userName = (agr?.Supplier?.UserName ?? ""); foreach (var creditNote in new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <DSS5_SupplyChainFinancialsOptimisation.BO.CreditNote>((o) => o.Transaction.Supplier.UserName == userName) ?? Enumerable.Empty <DSS5_SupplyChainFinancialsOptimisation.BO.CreditNote>())
             {
                 foundNotes?.Add(creditNote);
                 zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "CreditNote", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "length foundOrders: " + (foundNotes?.Count().ToString() ?? ""));
             }
         }
         return(foundNotes);
     }
 }
 public static System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Order> FindAgreement()
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("Order", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "FindAgreement")) {
         string userName = "";
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Agreement> agreements  = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <DSS5_SupplyChainFinancialsOptimisation.BO.Agreement>((a) => a.Investor.UserName == zAppDev.DotNet.Framework.Identity.IdentityHelper.GetCurrentApplicationUser().UserName);
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Order>     foundOrders = new System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Order>();
         foreach (var agr in agreements ?? Enumerable.Empty <DSS5_SupplyChainFinancialsOptimisation.BO.Agreement>())
         {
             userName = (agr?.Supplier?.UserName ?? ""); foreach (var order in new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <DSS5_SupplyChainFinancialsOptimisation.BO.Order>((o) => o.Transaction.Supplier.UserName == userName) ?? Enumerable.Empty <DSS5_SupplyChainFinancialsOptimisation.BO.Order>())
             {
                 foundOrders?.Add(order);
             }
         }
         return(foundOrders?.Distinct().ToList());
     }
 }
Beispiel #6
0
 public static System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.ImportedBuyer> FindSupplierBuyers()
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("CommercialAgreement", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "FindSupplierBuyers")) {
         string supUsername = "";
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.CommercialAgreement> supplierAgreements = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <DSS5_SupplyChainFinancialsOptimisation.BO.CommercialAgreement>((a) => a.Supplier.UserName == zAppDev.DotNet.Framework.Identity.IdentityHelper.GetCurrentApplicationUser().UserName);
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.ImportedBuyer>       foundBuyers        = new System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.ImportedBuyer>();
         foreach (var supAgreement in supplierAgreements ?? Enumerable.Empty <DSS5_SupplyChainFinancialsOptimisation.BO.CommercialAgreement>())
         {
             zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "CommercialAgreement", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "buyer: " + (supAgreement?.ImportedBuyer?.Code ?? "") + "c.a. " + (supAgreement?.Id?.ToString() ?? ""));
             foundBuyers?.Add(supAgreement?.ImportedBuyer);
         }
         return(foundBuyers?.Distinct().ToList());
     }
 }
Beispiel #7
0
 public static System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic> GetSupplierDataStatistics2()
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("SupplierStatistic", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "GetSupplierDataStatistics2")) {
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic> stats2    = new System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic>();
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier>          suppliers = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().GetAll <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier>();
         string  test  = "";
         decimal?test2 = new decimal?();
         foreach (var s in suppliers ?? Enumerable.Empty <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier>())
         {
             DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic stat = new DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic();
             stat.Supplier = s; decimal?count = 0;
             int?countAvailability = 0;
             if ((s?.DataQuality?.Orders ?? false))
             {
                 count = count.GetValueOrDefault(0) + 1;
             }
             if ((s?.DataQuality?.DeliveryNotes ?? false))
             {
                 count = count.GetValueOrDefault(0) + 1;
             }
             if ((s?.DataQuality?.CustomsDocuments ?? false))
             {
                 count = count.GetValueOrDefault(0) + 1;
             }
             if ((s?.DataQuality?.IntermediaryLogistics ?? false))
             {
                 count = count.GetValueOrDefault(0) + 1;
             }
             if ((s?.DataQuality?.Invoices ?? false))
             {
                 count = count.GetValueOrDefault(0) + 1;
             }
             if ((s?.DataQuality?.PoDs ?? false))
             {
                 count = count.GetValueOrDefault(0) + 1;
             }
             if ((s?.DataQuality?.PaymentData ?? false))
             {
                 count = count.GetValueOrDefault(0) + 1;
             }
             test2 = (count.GetValueOrDefault(0) / 7.0m) * 100; stat.DataQuality = Math.Round((test2).GetValueOrDefault(0), 2); zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Info, "SupplierStatistic", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Rounded data quality: " + (stat?.DataQuality ?? 0) + " for supplier " + (s?.UserName ?? "") + " with status: " + (s?.SupplierStatus ?? ""));
             if (s?.DataAvailability == null)
             {
                 DSS5_SupplyChainFinancialsOptimisation.BO.DataAvailability supDataAvailability = new DSS5_SupplyChainFinancialsOptimisation.BO.DataAvailability();
                 supDataAvailability.Supplier = s;
             }
             if ((s?.Transactions?.Any((a) => a.Orders.Count() > 0) ?? false))
             {
                 s.DataAvailability.Orders = true;
             }
             else
             {
                 s.DataAvailability.Orders = false;
             }
             if ((s?.Transactions?.Any((b) => b.DeliveryNotes.Count() > 0) ?? false))
             {
                 s.DataAvailability.DeliveryNotes = true;
             }
             else
             {
             }
             if ((s?.Transactions?.Any((c) => c.Invoices.Count() > 0) ?? false))
             {
                 s.DataAvailability.Invoices = true;
             }
             else
             {
             }
             if ((s?.Transactions?.Any((a) => a.ProofOfDeliveries.Count() > 0) ?? false))
             {
                 s.DataAvailability.PoDs = true;
             }
             else
             {
             }
             if ((s?.Transactions?.Any((a) => a.Intermediaries.Count() > 0) ?? false))
             {
                 s.DataAvailability.IntermediaryLogistics = true;
             }
             else
             {
             }
             if ((s?.Transactions?.Where((a) => a.PaymentStatus != null).Count() ?? 0) > 0)
             {
                 s.DataAvailability.PaymentData = true;
             }
             else
             {
             }
             if ((s?.DataAvailability?.Orders ?? false))
             {
                 countAvailability = countAvailability.GetValueOrDefault(0) + 1;
             }
             if ((s?.DataAvailability?.DeliveryNotes ?? false))
             {
                 countAvailability = countAvailability.GetValueOrDefault(0) + 1;
             }
             if ((s?.DataAvailability?.CustomsDocuments ?? false))
             {
                 countAvailability = countAvailability.GetValueOrDefault(0) + 1;
             }
             if ((s?.DataAvailability?.IntermediaryLogistics ?? false))
             {
                 countAvailability = countAvailability.GetValueOrDefault(0) + 1;
             }
             if ((s?.DataAvailability?.Invoices ?? false))
             {
                 countAvailability = countAvailability.GetValueOrDefault(0) + 1;
             }
             if ((s?.DataAvailability?.PoDs ?? false))
             {
                 countAvailability = countAvailability.GetValueOrDefault(0) + 1;
             }
             if ((s?.DataAvailability?.PaymentData ?? false))
             {
                 countAvailability = countAvailability.GetValueOrDefault(0) + 1;
             }
             stat.DataAvailability = countAvailability; new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Save <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier>(s);
             stats2?.Add(stat);
         }
         return(stats2);
     }
 }
Beispiel #8
0
 public static System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic> GetSupplierTurnover()
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("SupplierStatistic", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "GetSupplierTurnover")) {
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic> stats     = new System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic>();
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier>          suppliers = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier>((s) => s.SupplierStatus == "ActiveSupplier");
         int?i = 0;
         foreach (var sup in suppliers ?? Enumerable.Empty <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier>())
         {
             DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic stat = new DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic();
             stat.Supplier = sup; stat.TotalCommercialAgreements = (sup?.CommercialAgreements?.Count() ?? 0); stat.CurrentTurnover = (sup?.SupplierTurnover?.PlannedCurrentYear ?? 0); stat.NextTurnover = (sup?.SupplierTurnover?.PlannedNextYear ?? 0); stat.PreviousTurnover = (sup?.SupplierTurnover?.ActualPreviousYear ?? 0); i = i.GetValueOrDefault(0) + 1; stats?.Add(stat);
         }
         return(stats);
     }
 }
Beispiel #9
0
 public static System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic> GetSupplierStatistics()
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("SupplierStatistic", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "GetSupplierStatistics")) {
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic> stats     = new System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic>();
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier>          suppliers = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier>((s) => s.SupplierStatus == "ActiveSupplier");
         int?i = 0;
         foreach (var sup in suppliers ?? Enumerable.Empty <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier>())
         {
             DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic stat = new DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic();
             stat.Supplier = sup; stat.TotalCommercialAgreements = (sup?.CommercialAgreements?.Count() ?? 0); stat.OnTimeDeliveries = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().GetCount <DSS5_SupplyChainFinancialsOptimisation.BO.ProofOfDelivery>((a) => a.Transaction.Supplier.UserName == sup.UserName && a.DeliveryStatus == "OnTime"); stat.AsOrderedDeliveries = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().GetCount <DSS5_SupplyChainFinancialsOptimisation.BO.ProofOfDelivery>((a) => a.Transaction.Supplier.UserName == sup.UserName && a.QualityStatus == "Asordered"); stat.InFullDeliveries = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().GetCount <DSS5_SupplyChainFinancialsOptimisation.BO.ProofOfDelivery>((a) => a.Transaction.Supplier.UserName == sup.UserName && a.QuantityStatus == "Infull"); stat.TotalImpeachments = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().GetCount <DSS5_SupplyChainFinancialsOptimisation.BO.ProofOfDelivery>((a) => a.Transaction.Supplier.UserName == sup.UserName && (a.DeliveryStatus != "OnTime" || a.QualityStatus != "Asordered" || a.QuantityStatus != "Infull")); stat.TotalTransactions = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().GetCount <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>((t) => t.Supplier.UserName == sup.UserName); stat.CurrentTurnover = (sup?.SupplierTurnover?.PlannedCurrentYear ?? 0); i = i.GetValueOrDefault(0) + 1; stats?.Add(stat);
         }
         return(stats);
     }
 }