From adad250a1e557a71ae3c27d758d684e817e79bcb Mon Sep 17 00:00:00 2001 From: Frede Hundewadt <22748698+fhdk@users.noreply.github.com> Date: Fri, 10 Jun 2022 18:11:38 +0200 Subject: [PATCH] wip - sales report --- Wonky.Client/Components/Home.razor | 2 +- Wonky.Client/Components/Home.razor.cs | 2 +- .../HttpRepository/ActivityHttpRepository.cs | 6 +-- .../HttpRepository/IActivityHttpRepository.cs | 2 +- .../HttpRepository/IReportHttpRepository.cs | 9 +++++ .../HttpRepository/ReportHttpRepository.cs | 38 +++++++++++++++++++ Wonky.Client/Pages/CrmReport.razor | 6 --- Wonky.Client/Pages/SalesReport.razor | 2 +- Wonky.Client/Pages/SalesReport.razor.cs | 2 +- Wonky.Entity/DTO/NgSalesReportInitDto.cs | 10 +++++ .../ReportActivityDto.cs} | 15 ++------ Wonky.Entity/DTO/ReportFiguresDto.cs | 29 ++++++++++++++ Wonky.Entity/DTO/ReportVisitDto.cs | 11 ++++++ 13 files changed, 108 insertions(+), 26 deletions(-) create mode 100644 Wonky.Client/HttpRepository/IReportHttpRepository.cs create mode 100644 Wonky.Client/HttpRepository/ReportHttpRepository.cs delete mode 100644 Wonky.Client/Pages/CrmReport.razor create mode 100644 Wonky.Entity/DTO/NgSalesReportInitDto.cs rename Wonky.Entity/{Models/ReportActivity.cs => DTO/ReportActivityDto.cs} (51%) create mode 100644 Wonky.Entity/DTO/ReportFiguresDto.cs create mode 100644 Wonky.Entity/DTO/ReportVisitDto.cs diff --git a/Wonky.Client/Components/Home.razor b/Wonky.Client/Components/Home.razor index 8ddfeb12..2edf91c5 100644 --- a/Wonky.Client/Components/Home.razor +++ b/Wonky.Client/Components/Home.razor @@ -41,7 +41,7 @@ { - @activity.Company.Name + @activity.ReportVisitDto.Name @activity.Demo diff --git a/Wonky.Client/Components/Home.razor.cs b/Wonky.Client/Components/Home.razor.cs index 8c6d8e94..b2adf441 100644 --- a/Wonky.Client/Components/Home.razor.cs +++ b/Wonky.Client/Components/Home.razor.cs @@ -33,7 +33,7 @@ public partial class Home [Inject] public IActivityHttpRepository ActivityRepo { get; set; } private Preferences _prefs = new(); private string _workDate; - private List Activities { get; set; } + private List Activities { get; set; } protected override async Task OnInitializedAsync() diff --git a/Wonky.Client/HttpRepository/ActivityHttpRepository.cs b/Wonky.Client/HttpRepository/ActivityHttpRepository.cs index 7ca94f62..37b615a2 100644 --- a/Wonky.Client/HttpRepository/ActivityHttpRepository.cs +++ b/Wonky.Client/HttpRepository/ActivityHttpRepository.cs @@ -53,7 +53,7 @@ public class ActivityHttpRepository : IActivityHttpRepository _apiConfig = configuration.Value; } - public async Task?> GetActivities(string activityDate) + public async Task?> GetActivities(string activityDate) { var response = await _client .GetAsync($"{_apiConfig.ActivityEndpoint}/date/{activityDate}") @@ -61,8 +61,8 @@ public class ActivityHttpRepository : IActivityHttpRepository var content = await response.Content.ReadAsStringAsync(); //Console.WriteLine(content); return string.IsNullOrWhiteSpace(content) - ? new List() - : JsonSerializer.Deserialize>(content, _options); + ? new List() + : JsonSerializer.Deserialize>(content, _options); } public async Task> GetActivityPaged(ActivityPagingParams pagingParameters) { diff --git a/Wonky.Client/HttpRepository/IActivityHttpRepository.cs b/Wonky.Client/HttpRepository/IActivityHttpRepository.cs index fa7812d3..9ad1b604 100644 --- a/Wonky.Client/HttpRepository/IActivityHttpRepository.cs +++ b/Wonky.Client/HttpRepository/IActivityHttpRepository.cs @@ -28,5 +28,5 @@ public interface IActivityHttpRepository Task GetActivity(string id); Task CreateActivity(ActivityDto model); Task AcceptOffer(string id); - Task?> GetActivities(string activityDate); + Task?> GetActivities(string activityDate); } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/IReportHttpRepository.cs b/Wonky.Client/HttpRepository/IReportHttpRepository.cs new file mode 100644 index 00000000..45a41871 --- /dev/null +++ b/Wonky.Client/HttpRepository/IReportHttpRepository.cs @@ -0,0 +1,9 @@ +using Wonky.Client.Pages; +using Wonky.Entity.DTO; + +namespace Wonky.Client.HttpRepository; + +public interface IReportHttpRepository +{ + Task FetchReport(string workDate); +} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/ReportHttpRepository.cs b/Wonky.Client/HttpRepository/ReportHttpRepository.cs new file mode 100644 index 00000000..fa856ba8 --- /dev/null +++ b/Wonky.Client/HttpRepository/ReportHttpRepository.cs @@ -0,0 +1,38 @@ +using System.Net.Http.Json; +using System.Text.Json; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Options; +using Wonky.Entity.Configuration; +using Wonky.Entity.DTO; + +namespace Wonky.Client.HttpRepository; + +public class ReportHttpRepository :IReportHttpRepository +{ + private readonly JsonSerializerOptions _options = new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }; + + private readonly NavigationManager _navigation; + private ILogger _logger; + private readonly HttpClient _client; + private readonly ApiConfig _apiConfig; + + public ReportHttpRepository(HttpClient client, + ILogger logger, + NavigationManager navigation, IOptions configuration) + { + _client = client; + _logger = logger; + _navigation = navigation; + _apiConfig = configuration.Value; + } + + public async Task FetchReport(string workDate) + { + var initData = await _client + .GetFromJsonAsync($"{_apiConfig.ReportEndpoint}/init/{workDate}"); + return initData ?? new NgSalesReportInitDto(); + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/CrmReport.razor b/Wonky.Client/Pages/CrmReport.razor deleted file mode 100644 index 3783d6bd..00000000 --- a/Wonky.Client/Pages/CrmReport.razor +++ /dev/null @@ -1,6 +0,0 @@ -@page "/CrmReport" -

CrmReport

- -@code { - -} \ No newline at end of file diff --git a/Wonky.Client/Pages/SalesReport.razor b/Wonky.Client/Pages/SalesReport.razor index c3b6f322..cbc981aa 100644 --- a/Wonky.Client/Pages/SalesReport.razor +++ b/Wonky.Client/Pages/SalesReport.razor @@ -124,7 +124,7 @@ {
- @activity.Company.Name @activity.Company.ZipCity + @activity.ReportVisitDto.Name @activity.ReportVisitDto.ZipCity
diff --git a/Wonky.Client/Pages/SalesReport.razor.cs b/Wonky.Client/Pages/SalesReport.razor.cs index 90bfb76c..21b8fa3d 100644 --- a/Wonky.Client/Pages/SalesReport.razor.cs +++ b/Wonky.Client/Pages/SalesReport.razor.cs @@ -33,7 +33,7 @@ public partial class SalesReport private ReportDto _reportDto = new(); private Preferences _prefs { get; set; } = new(); private bool _formInvalid = true; - private List? Activities { get; set; } = new(); + private List? Activities { get; set; } = new(); private DateTime _workDate; protected override async Task OnInitializedAsync() { diff --git a/Wonky.Entity/DTO/NgSalesReportInitDto.cs b/Wonky.Entity/DTO/NgSalesReportInitDto.cs new file mode 100644 index 00000000..84448be7 --- /dev/null +++ b/Wonky.Entity/DTO/NgSalesReportInitDto.cs @@ -0,0 +1,10 @@ +using Wonky.Entity.Models; + +namespace Wonky.Entity.DTO; + +public class NgSalesReportInitDto +{ + public ReportFiguresDto ReportFigures { get; set; } = new(); + public List Activities { get; set; } = new(); + +} \ No newline at end of file diff --git a/Wonky.Entity/Models/ReportActivity.cs b/Wonky.Entity/DTO/ReportActivityDto.cs similarity index 51% rename from Wonky.Entity/Models/ReportActivity.cs rename to Wonky.Entity/DTO/ReportActivityDto.cs index 60c5f3ab..78358315 100644 --- a/Wonky.Entity/Models/ReportActivity.cs +++ b/Wonky.Entity/DTO/ReportActivityDto.cs @@ -1,8 +1,8 @@ -namespace Wonky.Entity.Models; +namespace Wonky.Entity.DTO; -public class ReportActivity +public class ReportActivityDto { - public VisitCompany Company { get; set; } + public ReportVisitDto ReportVisitDto { get; set; } = new(); public string SalesHeadId { get; set; } = ""; public bool Closed { get; set; } public string OrderDate { get; set; } = ""; @@ -14,12 +14,3 @@ public class ReportActivity public string SalesResume { get; set; } = ""; } -public class VisitCompany -{ - public string CompanyId { get; set; } = ""; - public string Account { get; set; } = ""; - public string Name { get; set; } = ""; - public string ZipCity { get; set; } = ""; - public string Phone { get; set; } = ""; - public string VatNumber { get; set; } = ""; -} \ No newline at end of file diff --git a/Wonky.Entity/DTO/ReportFiguresDto.cs b/Wonky.Entity/DTO/ReportFiguresDto.cs new file mode 100644 index 00000000..efac69f8 --- /dev/null +++ b/Wonky.Entity/DTO/ReportFiguresDto.cs @@ -0,0 +1,29 @@ +namespace Wonky.Entity.DTO; + +public class ReportFiguresDto +{ + public int SalesDayNumber { get; set; } + public int NewVisitCount { get; set; } + public int NewDemoCount { get; set; } + public int NewSaleCount { get; set; } + public int RecallVisitCount { get; set; } + public int RecallDemoCount { get; set; } + public int RecallSaleCount { get; set; } + public int SasCount { get; set; } + public int DistanceMonth { get; set; } + public int NewVisitCountMonth { get; set; } + public int NewDemoCountMonth { get; set; } + public int NewSaleCountMonth { get; set; } + public int RecallVisitCountMonth { get; set; } + public int RecallDemoCountMonth { get; set; } + public int RecallSaleCountMonth { get; set; } + public int SasCountMonth { get; set; } + public decimal NewTurnover { get; set; } + public decimal RecallTurnover { get; set; } + public decimal SasTurnover { get; set; } + public decimal TotalTurnover { get; set; } + public decimal NewTurnoverMonth { get; set; } + public decimal RecallTurnoverMonth { get; set; } + public decimal SasTurnoverMonth { get; set; } + public decimal TotalTurnoverMonth { get; set; } +} \ No newline at end of file diff --git a/Wonky.Entity/DTO/ReportVisitDto.cs b/Wonky.Entity/DTO/ReportVisitDto.cs new file mode 100644 index 00000000..d8133c24 --- /dev/null +++ b/Wonky.Entity/DTO/ReportVisitDto.cs @@ -0,0 +1,11 @@ +namespace Wonky.Entity.DTO; + +public class ReportVisitDto +{ + public string CompanyId { get; set; } = ""; + public string Account { get; set; } = ""; + public string Name { get; set; } = ""; + public string ZipCity { get; set; } = ""; + public string Phone { get; set; } = ""; + public string VatNumber { get; set; } = ""; +} \ No newline at end of file