wip - sales report

This commit is contained in:
Frede Hundewadt 2022-06-10 18:11:38 +02:00
parent 40f9334e2d
commit adad250a1e
13 changed files with 108 additions and 26 deletions

View file

@ -41,7 +41,7 @@
{
<tr>
<td>
@activity.Company.Name
@activity.ReportVisitDto.Name
</td>
<td>
@activity.Demo

View file

@ -33,7 +33,7 @@ public partial class Home
[Inject] public IActivityHttpRepository ActivityRepo { get; set; }
private Preferences _prefs = new();
private string _workDate;
private List<ReportActivity> Activities { get; set; }
private List<ReportActivityDto> Activities { get; set; }
protected override async Task OnInitializedAsync()

View file

@ -53,7 +53,7 @@ public class ActivityHttpRepository : IActivityHttpRepository
_apiConfig = configuration.Value;
}
public async Task<List<ReportActivity>?> GetActivities(string activityDate)
public async Task<List<ReportActivityDto>?> 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<ReportActivity>()
: JsonSerializer.Deserialize<List<ReportActivity>>(content, _options);
? new List<ReportActivityDto>()
: JsonSerializer.Deserialize<List<ReportActivityDto>>(content, _options);
}
public async Task<PagingResponse<ActivityDto>> GetActivityPaged(ActivityPagingParams pagingParameters)
{

View file

@ -28,5 +28,5 @@ public interface IActivityHttpRepository
Task<ActivityDto> GetActivity(string id);
Task<ActivityResponseView> CreateActivity(ActivityDto model);
Task<ActivityResponseView> AcceptOffer(string id);
Task<List<ReportActivity>?> GetActivities(string activityDate);
Task<List<ReportActivityDto>?> GetActivities(string activityDate);
}

View file

@ -0,0 +1,9 @@
using Wonky.Client.Pages;
using Wonky.Entity.DTO;
namespace Wonky.Client.HttpRepository;
public interface IReportHttpRepository
{
Task<NgSalesReportInitDto> FetchReport(string workDate);
}

View file

@ -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<SalesItemHttpRepository> _logger;
private readonly HttpClient _client;
private readonly ApiConfig _apiConfig;
public ReportHttpRepository(HttpClient client,
ILogger<SalesItemHttpRepository> logger,
NavigationManager navigation, IOptions<ApiConfig> configuration)
{
_client = client;
_logger = logger;
_navigation = navigation;
_apiConfig = configuration.Value;
}
public async Task<NgSalesReportInitDto> FetchReport(string workDate)
{
var initData = await _client
.GetFromJsonAsync<NgSalesReportInitDto>($"{_apiConfig.ReportEndpoint}/init/{workDate}");
return initData ?? new NgSalesReportInitDto();
}
}

View file

@ -1,6 +0,0 @@
@page "/CrmReport"
<h3>CrmReport</h3>
@code {
}

View file

@ -124,7 +124,7 @@
{
<div class="card">
<div class="card-header">
@activity.Company.Name @activity.Company.ZipCity
@activity.ReportVisitDto.Name @activity.ReportVisitDto.ZipCity
</div>
<div class="card-body">
<div class="row">

View file

@ -33,7 +33,7 @@ public partial class SalesReport
private ReportDto _reportDto = new();
private Preferences _prefs { get; set; } = new();
private bool _formInvalid = true;
private List<ReportActivity>? Activities { get; set; } = new();
private List<ReportActivityDto>? Activities { get; set; } = new();
private DateTime _workDate;
protected override async Task OnInitializedAsync()
{

View file

@ -0,0 +1,10 @@
using Wonky.Entity.Models;
namespace Wonky.Entity.DTO;
public class NgSalesReportInitDto
{
public ReportFiguresDto ReportFigures { get; set; } = new();
public List<ReportActivityDto> Activities { get; set; } = new();
}

View file

@ -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; } = "";
}

View file

@ -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; }
}

View file

@ -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; } = "";
}