wip - admin print with orders

This commit is contained in:
Frede Hundewadt 2022-07-02 16:15:28 +02:00
parent 831959c258
commit f7675bec06
48 changed files with 459 additions and 253 deletions

View file

@ -17,7 +17,7 @@
@if (Enabled == 1)
{
<a type="button" class="btn btn-@ButtonType" href="@ActionLink">@ButtonText</a>
<a class="btn btn-@ButtonType" href="@ActionLink">@ButtonText</a>
}
else
{

View file

@ -5,5 +5,5 @@ namespace Wonky.Client.Components;
public partial class ActivityTableComponent
{
[Parameter] public List<ActivityListItemView> Activities { get; set; }
[Parameter] public List<ReportItemView> Activities { get; set; }
}

View file

@ -1,3 +1,5 @@
@using System.Globalization
@if (ReportList != null)
{
<div class="list-group list-group-flush">
@ -49,14 +51,14 @@
}
}
</div>
<div class="col">
<div class="col text-center">
@(report.DayTypeEnum == "Sales" ? report.FromDateTime.Split(" ")[1] : report.FromDateTime.Split(" ")[0])
</div>
<div class="col">
<div class="col text-center">
@(report.DayTypeEnum == "Sales" ? report.ToDateTime.Split(" ")[1] : report.ToDateTime.Split(" ")[0])
</div>
<div class="col text-end">
@report.Turnover
@report.Turnover.ToString(CultureInfo.CurrentUICulture)
</div>
</div>
</a>

View file

@ -8,9 +8,4 @@ public partial class AdminReportTableComponent
[Parameter] public List<NgSalesReportListView> ReportList { get; set; }
[Parameter] public string UserId { get; set; } = "";
[Parameter] public string CountryCode { get; set; } = "";
protected override void OnParametersSet()
{
base.OnParametersSet();
}
}

View file

@ -17,35 +17,37 @@
@if (UserList.Any())
{
<table class="table table-striped">
<thead>
<tr>
<th scope="col">
Land
</th>
<th scope="col">
Navn
</th>
<th scope="col">
Telefon
</th>
<th scope="col">
Email
</th>
</tr>
</thead>
<tbody>
<div class="list-group list-group-flush">
<div class="list-group-item">
<div class="row">
<div class="col fw-bold">
Navn
</div>
<div class="col fw-bold">
Telefon
</div>
<div class="col fw-bold">
Email
</div>
</div>
</div>
@foreach (var user in UserList)
{
<tr class="align-middle">
<td class="align-content-center">@user.CountryCode</td>
<td><a href="/admin/users/office/@user.CountryCode.ToLower()/@user.UserId/view">@user.FullName</a></td>
<td>@user.PhoneNumber</td>
<td>@user.Email</td>
</tr>
<a class="list-group-item list-group-item-action" href="/admin/users/office/@user.CountryCode.ToLower()/@user.UserId/view">
<div class="row">
<div class="col">
@user.FullName
</div>
<div class="col">
@user.PhoneNumber
</div>
<div class="col">
@user.Email
</div>
</div>
</a>
}
</tbody>
</table>
</div>
}
else
{

View file

@ -6,5 +6,5 @@ namespace Wonky.Client.Components;
public partial class ReportActivityLedgerComponent
{
[Parameter]
public SalesReportDataViewModel ReportData { get; set; }
public ReportData ReportData { get; set; }
}

View file

@ -15,7 +15,7 @@
//
*@
<table class="table table-bordered table-striped d-print-table">
<table class="table table-sm table-bordered table-striped d-print-table">
<thead>
<tr class="bg-dark text-white opacity-75 border-bottom">
<th colspan="2">
@ -25,28 +25,28 @@
</thead>
<tbody>
<tr>
<th scope="row">Km Aften</th>
<td>@ReportData.KmEvening</td>
<th scope="row">Aften</th>
<td class="text-end">@ReportData.KmEvening</td>
</tr>
<tr>
<th scope="row">Km Morgen</th>
<td>@ReportData.KmMorning</td>
<th scope="row">Morgen</th>
<td class="text-end">@ReportData.KmMorning</td>
</tr>
<tr>
<th scope="row">Km Kørt Dag</th>
<td>@ReportData.Distance</td>
<th scope="row">Kørt Dag</th>
<td class="text-end">@ReportData.Distance</td>
</tr>
<tr>
<th scope="row">Km Kørt Md.</th>
<td>@ReportData.DistanceMonth</td>
<th scope="row">Kørt Md.</th>
<td class="text-end">@ReportData.DistanceMonth</td>
</tr>
<tr>
<th scope="row">Km Privat</th>
<td>@ReportData.DistancePrivate</td>
<th scope="row">Privat</th>
<td class="text-end">@ReportData.DistancePrivate</td>
</tr>
<tr>
<th scope="row">Km Privat Md.</th>
<td>@ReportData.DistancePrivateMonth</td>
<th scope="row">Privat Md.</th>
<td class="text-end">@ReportData.DistancePrivateMonth</td>
</tr>
</tbody>
</table>

View file

@ -6,6 +6,6 @@ namespace Wonky.Client.Components;
public partial class ReportDistanceLedgerComponent
{
[Parameter]
public SalesReportDataViewModel ReportData { get; set; }
public ReportData ReportData { get; set; }
}

View file

@ -18,7 +18,7 @@
<table class="table table-bordered table-striped d-print-table">
<thead>
<tr class="bg-dark text-white opacity-75 border-bottom">
<th colspan="2">
<th colspan="3">
Rapport
</th>
</tr>
@ -26,23 +26,26 @@
<tbody>
<tr>
<th scope="row">Beskrivelse</th>
<td>@ReportData.Description</td>
<td colspan="2">@ReportData.Description</td>
</tr>
<tr>
<th scope="row">Supervisor</th>
<td>@ReportData.SupervisedBy</td>
<td colspan="2">@ReportData.SupervisedBy</td>
</tr>
<tr>
<th scope="row">Dagtype</th>
<td>
<th scope="row">Indhold</th>
<td colspan="2">
@{
switch (ReportData.DayTypeEnum)
{
case "Sales":
<span>Salgsdag: @ReportData.SalesDayNumber</span>
<span>Salgsdag @ReportData.SalesDayNumber</span>
break;
case "SickLeave":
<span>Sygdom</span>
<span>Sygefravær</span>
break;
case "Leave":
<span>Aftalt frihed</span>
break;
case "Office":
<span>Kontordag</span>
@ -50,13 +53,65 @@
case "Meeting":
<span>Salgsmøde</span>
break;
case "Leave":
<span>Ferie</span>
default:
<span></span>
break;
}
}
</td>
</tr>
<tr>
<th scope="row">Fra/Til</th>
<td>
@{
switch (ReportData.DayTypeEnum)
{
case "Sales":
<span>@(ReportData.FromDateTime.Split(" ")[1])</span>
break;
case "SickLeave":
<span>@(ReportData.FromDateTime.Split(" ")[0])</span>
break;
case "Leave":
<span>@(ReportData.FromDateTime.Split(" ")[0])</span>
break;
case "Office":
<span></span>
break;
case "Meeting":
<span></span>
break;
default:
<span></span>
break;
}
}
</td>
<td>
@{
switch (ReportData.DayTypeEnum)
{
case "Sales":
<span>@(ReportData.ToDateTime.Split(" ")[1])</span>
break;
case "SickLeave":
<span>@(ReportData.ToDateTime.Split(" ")[0])</span>
break;
case "Leave":
<span>@(ReportData.ToDateTime.Split(" ")[0])</span>
break;
case "Office":
<span></span>
break;
case "Meeting":
<span></span>
break;
default:
<span></span>
break;
}
}
</td>
</tr>
</tbody>
</table>

View file

@ -6,6 +6,6 @@ namespace Wonky.Client.Components;
public partial class ReportSummaryComponent
{
[Parameter]
public SalesReportDataViewModel ReportData { get; set; }
public ReportData ReportData { get; set; }
}

View file

@ -0,0 +1,12 @@
@using Wonky.Entity.Views
<div class="report-item">
</div>
@code{
[Parameter]
public ReportItemView ReportItem { get; set; } = new();
}

View file

@ -54,14 +54,14 @@ public class ActivityHttpRepository : IActivityHttpRepository
_apiConfig = configuration.Value;
}
public async Task<ActivityListReportView> GetActivities(string activityDate)
public async Task<ReportItemListView> GetActivities(string activityDate)
{
var response = await _client
.GetAsync($"{_apiConfig.ActivityUri}/date/{activityDate}");
var content = await response.Content.ReadAsStringAsync();
return string.IsNullOrWhiteSpace(content)
? new ActivityListReportView()
: JsonSerializer.Deserialize<ActivityListReportView>(content, _options);
? new ReportItemListView()
: JsonSerializer.Deserialize<ReportItemListView>(content, _options);
}
public async Task<ApiResponseView> CreateActivity(ActivityDto model)

View file

@ -35,9 +35,9 @@ public class AdminReportHttpRepository : IAdminReportHttpRepository
return await _client.GetFromJsonAsync<List<NgSalesReportListView>>($"{_apiConfig.AdminAdviserUri}/{userId}/reports");
}
public async Task<SalesReportViewModel> GetReport(string userId, string workDate)
public async Task<ReportView> GetReport(string userId, string workDate)
{
return await _client.GetFromJsonAsync<SalesReportViewModel>($"{_apiConfig.AdminAdviserUri}/{userId}/reports/{workDate}");
return await _client.GetFromJsonAsync<ReportView>($"{_apiConfig.AdminAdviserUri}/{userId}/reports/{workDate}");
}
}

View file

@ -27,5 +27,5 @@ public interface IActivityHttpRepository
Task<ActivityDto> GetActivity(string id);
Task<ApiResponseView> CreateActivity(ActivityDto model);
Task<ApiResponseView> AcceptOffer(string id);
Task<ActivityListReportView> GetActivities(string activityDate);
Task<ReportItemListView> GetActivities(string activityDate);
}

View file

@ -1,5 +1,3 @@
using Wonky.Client.Pages;
using Wonky.Entity.DTO;
using Wonky.Entity.Views;
namespace Wonky.Client.HttpRepository;
@ -7,5 +5,5 @@ namespace Wonky.Client.HttpRepository;
public interface IAdminReportHttpRepository
{
Task<List<NgSalesReportListView>> GetReports(string userId);
Task<SalesReportViewModel> GetReport(string userId, string workDate);
Task<ReportView> GetReport(string userId, string workDate);
}

View file

@ -8,7 +8,7 @@ public interface IReportHttpRepository
{
Task<bool> ReportExist(string workDate);
Task<List<NgSalesReportListView>> GetReports();
Task<SalesReportViewModel> GetReport(string workDate);
Task<ReportView> GetReport(string workDate);
Task<ReportInitDto> InitializeReportData(string workDate);
Task<ApiResponseView> PostReport(string workDate, ReportDto reportDto);
}

View file

@ -42,9 +42,9 @@ public class ReportHttpRepository :IReportHttpRepository
return result.ReportClosed;
}
public async Task<SalesReportViewModel> GetReport(string workDate)
public async Task<ReportView> GetReport(string workDate)
{
return await _client.GetFromJsonAsync<SalesReportViewModel>($"{_apiConfig.ReportUri}/{workDate}");
return await _client.GetFromJsonAsync<ReportView>($"{_apiConfig.ReportUri}/{workDate}");
}
public async Task<ReportInitDto> InitializeReportData(string workDate)

View file

@ -23,13 +23,13 @@
<div class="card">
<div class="card-header">
<div class="row mb-1 align-items-center">
<div class="col">
<div class="col-md-6">
<h2 class="workDate">@(string.IsNullOrWhiteSpace(_workDate) ? "" : $"{DateTime.Parse(_workDate).ToLongDateString()}")</h2>
</div>
<div class="col">
<div class="col-md-4">
<WorkDateComponent OnChanged="GetActivities"></WorkDateComponent>
</div>
<div class="col">
<div class="col-md-2">
@if (_reportExist)
{
<a class="btn btn-primary" href="/sales-reports/view/@_workDate">RAPPORT</a>
@ -44,5 +44,5 @@
</div>
</div>
<div class="card-body">
<ActivityTableComponent Activities="ReportView.Activities"></ActivityTableComponent>
<ActivityTableComponent Activities="ReportItemListView.ReportItems"></ActivityTableComponent>
</div>

View file

@ -17,7 +17,7 @@ public partial class ActivityToday
[Inject] private IActivityHttpRepository _activityRepo { get; set; }
[Inject] private IReportHttpRepository _reportRepo { get; set; }
[Inject] private IToastService _toast { get; set; }
private ActivityListReportView ReportView { get; set; } = new();
private ReportItemListView ReportItemListView { get; set; } = new();
private Preferences _prefs { get; set; } = new();
private string _workDate { get; set; } = $"{DateTime.Now:yyyy-MM-dd}";
private bool _reportExist = false;
@ -38,8 +38,8 @@ public partial class ActivityToday
{
_toast.ShowInfo("Vent nogle sekunder for data");
_workDate = workDate;
ReportView = new ActivityListReportView();
ReportView = await _activityRepo.GetActivities(workDate);
ReportItemListView = new ReportItemListView();
ReportItemListView = await _activityRepo.GetActivities(workDate);
}
public void Dispose()

View file

@ -27,7 +27,7 @@
<h3 class="workDate">@_workDate.ToLongDateString()</h3>
</div>
<div class="col">
<WorkDateComponent OnChanged="SetWorkDate"></WorkDateComponent>
<WorkDateComponent SelectedDate="@_selectedDate" OnChanged="SetWorkDate"></WorkDateComponent>
</div>
</div>
</div>
@ -187,7 +187,7 @@
<th scope="col">Antal</th>
<th scope="col">Pris</th>
<th scope="col">Rabat</th>
<th scope="col">SAS</th>
<th class="align-content-center justify-content-center" scope="col">SAS</th>
<th scope="col">Varenr.</th>
<th scope="col"></th>
</tr>
@ -203,12 +203,12 @@
<td>
<input type="number" class="form-control" @bind-value="@Discount"/>
</td>
<td>
<td class="align-content-center justify-content-center">
<input type="checkbox" class="form-check" @bind-value="@Sas"/>
</td>
<td>@_selectedItem.Sku</td>
<td>
<button type="button" class="btn btn-warning text-nowrap d-block" @onclick="@(() => AddItem(_selectedItem))">@_selectedItem.Name</button>
<button type="button" class="btn btn-warning text-nowrap d-block" @onclick="@(() => AddItem(_selectedItem))">BESTIL @Quantity @_selectedItem.Name</button>
</td>
</tr>
</tbody>
@ -268,7 +268,7 @@
<li class="list-group-item d-flex justify-content-between align-items-end">
<div class="text-sm-start px-2">@rate.Quantity</div>
<div class="text-sm-end">@rate.Rate</div>
<a class="btn btn-primary" href="#draft-line" @onclick="@(() => SelectItem(item.ItemId, rate.Quantity, rate.Rate))">
<a class="btn btn-primary" @onclick="@(() => SelectItem(item.ItemId, rate.Quantity, rate.Rate))">
Vælg
</a>
</li>

View file

@ -71,6 +71,7 @@ public partial class ActivityVisitNew : IDisposable
private bool _reportClosdd { get; set; } = false;
private UserInfoView _ux { get; set; } = new();
private DateTime _workDate { get; set; } = DateTime.Now;
private string _selectedDate { get; set; } = "";
protected override async Task OnParametersSetAsync()
{
@ -78,11 +79,12 @@ public partial class ActivityVisitNew : IDisposable
if (!string.IsNullOrWhiteSpace(_prefs.WorkDate))
_workDate = DateTime.Parse(_prefs.WorkDate);
_selectedDate = $"{_workDate:yyyy-MM-dd}";
// raise flag if report is closed
_reportClosdd = await _reportRepo.ReportExist($"{_workDate:yyyy-MM-dd}");
_reportClosdd = await _reportRepo.ReportExist(_selectedDate);
if(_reportClosdd)
_navigator.NavigateTo($"/sales-reports/view/{_workDate:yyyy-MM-dd}");
_navigator.NavigateTo($"/sales-reports/view/{_selectedDate}");
}
@ -138,10 +140,9 @@ public partial class ActivityVisitNew : IDisposable
private void SetWorkDate(string workDate)
{
Console.WriteLine($"SetWorkDate => {workDate}");
_logger.LogInformation("WorkDateComponent.OnChanged(SetWorkDate(workDate)) => {workDate}", workDate);
_workDate = DateTime.Parse(workDate);
_draft.ActivityDate = workDate;
_selectedDate = workDate;
_workDate = DateTime.Parse(_selectedDate);
_draft.ActivityDate = _selectedDate;
}
private async Task CreateActivity()

View file

@ -18,6 +18,7 @@
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Admin")]
@page "/admin/users/advisers/{CountryCode}/{UserId}/reports"
<div class="card">
<div class="card-header bg-dark text-white">
<div class="row">
@ -27,6 +28,6 @@
</div>
</div>
<div class="card-body">
<AdminReportTableComponent CountryCode="@CountryCode" UserId="@UserId" ReportList="_reports"></AdminReportTableComponent>
<AdminReportTableComponent CountryCode="@CountryCode" UserId="@UserId" ReportList="@_reports" />
</div>
</div>

View file

@ -12,7 +12,6 @@ public partial class AdminSalesReportList : IDisposable
[Parameter] public string CountryCode { get; set; } = "";
[Inject] private IAdminReportHttpRepository _reportRepo { get; set; }
[Inject] private HttpInterceptorService _interceptor { get; set; }
private List<NgSalesReportListView> _reports { get; set; }
protected override async Task OnInitializedAsync()

View file

@ -20,43 +20,50 @@
@page "/admin/users/advisers/{CountryCode}/{UserId}/reports/{ReportDate}"
@attribute [Authorize(Roles = "Admin")]
<PageTitle>@_report.ReportData.Name</PageTitle>
<div class="card">
<div class="card-header bg-dark text-white">
@if (SalesReport != null)
{
<PageTitle>@SalesReport.ReportData.Name</PageTitle>
<div class="alert alert-dark">
<div class="row">
<div class="col w-75 d-print-none justify-content-center">
<div class="col-md-6 d-print-none align-content-center">
@if (!string.IsNullOrWhiteSpace(ReportDate))
{
<h2 class="workDate">@DateTime.Parse(ReportDate).ToLongDateString()</h2>
}
</div>
<div class="col col-sm-1 d-print-none">
<div class="col col-md-4 d-print-none align-content-center">
<WorkDateComponent SelectedDate="@ReportDate" OnChanged="GetReport"></WorkDateComponent>
</div>
<div class="col col-md-1 d-print-none align-content-center">
<button class="btn btn-warning" type="button" onclick="window.print();">Print</button>
</div>
<div class="col d-none d-print-block text-end">
<h3>@_report.ReportData.Name</h3>
<div class="col d-none d-print-block text-end align-content-center">
<h2>@SalesReport.ReportData.Name</h2>
</div>
</div>
</div>
<div class="card-body">
<div class="row">
<div class="col w-75">
<ReportSummaryComponent ReportData="_report.ReportData"></ReportSummaryComponent>
</div>
<div class="col w-25">
<ReportDistanceLedgerComponent ReportData="_report.ReportData"></ReportDistanceLedgerComponent>
</div>
<div class="row">
<div class="w-75">
<ReportSummaryComponent ReportData="SalesReport.ReportData"></ReportSummaryComponent>
</div>
<div class="row">
<div class="col">
<ActivityTableComponent Activities="_report.Activities"></ActivityTableComponent>
</div>
</div>
<div class="row">
<div class="col">
<ReportActivityLedgerComponent ReportData="_report.ReportData"></ReportActivityLedgerComponent>
</div>
<div class="w-25">
<ReportDistanceLedgerComponent ReportData="SalesReport.ReportData"></ReportDistanceLedgerComponent>
</div>
</div>
</div>
<div class="row">
<div class="col">
<ActivityTableComponent Activities="SalesReport.ReportItems"></ActivityTableComponent>
</div>
</div>
<div class="row">
<div class="col">
<ReportActivityLedgerComponent ReportData="SalesReport.ReportData"></ReportActivityLedgerComponent>
</div>
</div>
}
else
{
<AppSpinner/>
}

View file

@ -1,32 +1,74 @@
using System.Text.Json;
using Microsoft.AspNetCore.Components;
using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository;
using Wonky.Entity.DTO;
using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
public partial class AdminSalesReportView
public partial class AdminSalesReportView : IDisposable
{
[Parameter] public string ReportDate { get; set; } = "";
[Parameter] public string UserId { get; set; } = "";
/// <summary>
/// Country code from url parameter
/// </summary>
[Parameter] public string CountryCode { get; set; } = "";
/// <summary>
/// Report date from url parameter
/// </summary>
[Parameter] public string ReportDate { get; set; } = "";
/// <summary>
/// User entity Id from url parameter
/// </summary>
[Parameter] public string UserId { get; set; } = "";
/// <summary>
/// Injected interceptor service
/// </summary>
[Inject] private HttpInterceptorService _interceptor { get; set; }
/// <summary>
/// Injected administrative report http repo
/// </summary>
[Inject] private IAdminReportHttpRepository _reportRepo { get; set; }
private SalesReportViewModel _report { get; set; } = new();
/// <summary>
/// Navigation Manager
/// </summary>
[Inject] private NavigationManager _navigator { get; set; }
/// <summary>
/// Report to render
/// </summary>
private ReportView SalesReport { get; set; }
protected override async Task OnParametersSetAsync()
{
_interceptor.RegisterEvent();
_interceptor.RegisterBeforeSendEvent();
await GetReport(ReportDate);
}
/// <summary>
/// Work date component event handler
/// </summary>
/// <param name="workDate"></param>
private async Task GetReport(string workDate)
{
ReportDate = workDate;
_report = new SalesReportViewModel();
_report = await GetUserReport(UserId, workDate);
if(workDate != ReportDate)
_navigator.NavigateTo($"/admin/users/advisers/{CountryCode}/{UserId}/reports/{workDate}");
SalesReport = new ReportView();
SalesReport = await GetUserReport(UserId, workDate);
}
/// <summary>
/// Get report for user with entity Id for work date
/// </summary>
/// <param name="userId"></param>
/// <param name="workDate"></param>
/// <returns></returns>
private async Task<ReportView> GetUserReport(string userId, string workDate)
{
return SalesReport = await _reportRepo.GetReport(userId, workDate);
}
private async Task<SalesReportViewModel> GetUserReport(string userId, string workDate)
public void Dispose()
{
return _report = await _reportRepo.GetReport(userId, workDate);
_interceptor.DisposeEvent();
}
}
}

View file

@ -163,14 +163,14 @@
</DisplayStateComponent>
</td>
<td>
<InputDate id="nextVisit" class="form-control" @bind-Value="@(_nextVisit)"/>
<InputDate id="nextVisit" class="form-control" @bind-Value="@(_nextVisit)" />
<ValidationMessage For="@(() => _company.NextVisit)">Dato kan ikke vær før sidste besøg</ValidationMessage>
</td>
<th>
Besøgt
</th>
<td>
<InputDate id="lastVisit" class="form-control" @bind-Value="@_lastVisit"/>
<InputDate id="lastVisit" class="form-control" @bind-Value="@_lastVisit" />
</td>
</tr>
<tr class="align-middle">

View file

@ -58,7 +58,7 @@ public partial class CompanyView : IDisposable
private string _orgVat;
private string countryCode = "dk";
private string _visitState = "the-ugly";
private int _enableActivity = 0;
private int _enableActivity = 1;
private bool _hideButtons = false;
private string _actionLink = "";
@ -70,6 +70,7 @@ public partial class CompanyView : IDisposable
private async Task RefreshHistory()
{
_toast.ShowInfo("Vent mens data opdateres ...");
_toast.ShowInfo("Der kan gå nogle minuutter inden data er klar ...");
var ts = await _historyRepo.UpdateProductHistory(_company.CompanyId, $"{DateTime.Parse(_company.HistorySync):yyyy-MM-dd}");;
_company.HistorySync = ts.Replace("\"", "");
}
@ -81,6 +82,9 @@ public partial class CompanyView : IDisposable
_interceptor.RegisterBeforeSendEvent();
_company = await _companyRepo.GetCompanyById(CompanyId);
_logger.LogDebug("CompanyView => _company <= {_company}", JsonSerializer.Serialize(_company, _options));
_orgVat = _company.VatNumber;
_company.CountryCode = ux.CountryCode.ToLower();
@ -96,11 +100,18 @@ public partial class CompanyView : IDisposable
_lastVisit = DateTime.Parse(_company.LastVisit);
_nextVisit = DateTime.Parse(_company.NextVisit);
if (_lastVisit.Year < 2020)
{
_lastVisit = DateTime.Parse("2020-01-01");
}
if (!_company.ValidDateSpan())
_nextVisit = _lastVisit.AddDays(_company.Interval * 7);
_visitState = Utils.GetVisitState($"{_nextVisit:yyyy-MM-dd}");
_actionLink = $"/companies/{CompanyId}/activities/new";
if(_company.HasFolded == 1)
{
_hasFolded = true;
@ -127,7 +138,7 @@ public partial class CompanyView : IDisposable
_company.LastVisit = $"{_lastVisit:yyyy-MM-dd}";
_company.NextVisit = $"{_nextVisit:yyyy-MM-dd}";
if (!VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber) || !_company.ValidDateSpan())
if (!VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber))
{
_formInvalid = true;
}
@ -139,7 +150,7 @@ public partial class CompanyView : IDisposable
}
private void ValidationChanged(object sender, ValidationStateChangedEventArgs e)
{
_formInvalid = true;
_formInvalid = false;
_editContext.OnFieldChanged -= HandleFieldChanged;
_editContext.OnValidationStateChanged -= ValidationChanged;
@ -172,10 +183,13 @@ public partial class CompanyView : IDisposable
var success = await _companyRepo.UpdateCompany(CompanyId, _company );
if (success)
{
_toast.ShowSuccess("Kunde er opdateret");
_toast.ShowSuccess("Opdatering er afsendt. Der nogle minutter inden data er opdateret.");
_company = await _companyRepo.GetCompanyById(_company.CompanyId);
_company.ValidVat = 1;
StateHasChanged();
}
_hideButtons = false;
}

View file

@ -28,7 +28,7 @@
<h3 class="workDate">@(_workDate.ToLongDateString())</h3>
</div>
<div class="col-md-4 justify-content-center">
<WorkDateComponent OnChanged="SetWorkDate"></WorkDateComponent>
<WorkDateComponent SelectedDate="@($"{_workDate:yyyy-MM-dd}")" OnChanged="SetWorkDate"></WorkDateComponent>
</div>
<div class="col-md-2 justify-content-center">
@if (_working)

View file

@ -40,7 +40,7 @@ public partial class SalesReportNew : IDisposable
[Inject] private IToastService _toast { get; set; }
private EditContext _editContext { get; set; }
private ReportDto _report { get; set; } = new();
private List<ActivityListItemView> _activities { get; set; } = new();
private List<ReportItemView> _activities { get; set; } = new();
private ReportFiguresDto _init { get; set; }
private Preferences _prefs { get; set; } = new();
private bool _formInvalid = true;
@ -152,7 +152,7 @@ public partial class SalesReportNew : IDisposable
_noFigures = true;
_report.Figures = new ReportFiguresDto();
_init = new ReportFiguresDto();
_activities = new List<ActivityListItemView>();
_activities = new List<ReportItemView>();
_report.Figures.KmEvening = 0;
_report.Figures.KmMorning = 0;
_report.Figures.Distance = 0;
@ -167,12 +167,12 @@ public partial class SalesReportNew : IDisposable
{
_working = true;
var data = await _reportRepo.InitializeReportData($"{_workDate:yyyy-MM-dd}");
if(data.Closed)
if(data.ReportClosed)
_navigator.NavigateTo($"/sales-reports/view/{_workDate:yyyy-MM-dd}");
_noFigures = false;
_report.Figures = data.Figures;
_init = data.Figures;
_activities = data.Activities;
_report.Figures = data.ReportData;
_init = data.ReportData;
_activities = data.ReportItems;
_working = false;
}

View file

@ -22,36 +22,41 @@
<PageTitle>@_report.ReportData.Name</PageTitle>
<div class="card">
<div class="card-header bg-dark text-white">
<div class="row">
<div class="col w-75 d-print-none justify-content-center">
@if (!string.IsNullOrWhiteSpace(ReportDate))
{
<h2 class="workDate">@DateTime.Parse(ReportDate).ToLongDateString()</h2>
}
</div>
<div class="col d-print-none justify-content-center">
<WorkDateComponent OnChanged="GetReport"></WorkDateComponent>
</div>
<div class="col col-sm-1 d-print-none">
<button class="btn btn-warning" type="button" onclick="window.print();">Print</button>
</div>
<div class="col d-none d-print-block text-end">
<h3>@_report.ReportData.Name</h3>
</div>
<div class="alert alert-dark">
<div class="row">
<div class="col-md-6 d-print-none align-content-center">
@if (!string.IsNullOrWhiteSpace(ReportDate))
{
<h2 class="workDate">@DateTime.Parse(ReportDate).ToLongDateString()</h2>
}
</div>
<div class="col col-md-4 d-print-none align-content-center">
<WorkDateComponent SelectedDate="@ReportDate" OnChanged="GetReport"></WorkDateComponent>
</div>
<div class="col col-md-1 d-print-none align-content-center">
<button class="btn btn-warning" type="button" onclick="window.print();">Print</button>
</div>
<div class="col d-none d-print-block text-end align-content-center">
<h2>@_report.ReportData.Name</h2>
</div>
</div>
<div class="card-body">
<div class="row">
<div class="col w-75">
<ReportSummaryComponent ReportData="_report.ReportData"></ReportSummaryComponent>
</div>
<div class="col w-25">
<ReportDistanceLedgerComponent ReportData="_report.ReportData"></ReportDistanceLedgerComponent>
</div>
</div>
<ActivityTableComponent Activities="_report.Activities"></ActivityTableComponent>
<ReportActivityLedgerComponent ReportData="_report.ReportData"></ReportActivityLedgerComponent>
</div>
<div class="row">
<div class="w-75">
<ReportSummaryComponent ReportData="_report.ReportData"></ReportSummaryComponent>
</div>
</div>
<div class="w-25">
<ReportDistanceLedgerComponent ReportData="_report.ReportData"></ReportDistanceLedgerComponent>
</div>
</div>
<div class="row">
<div class="col">
<ActivityTableComponent Activities="_report.ReportItems"></ActivityTableComponent>
</div>
</div>
<div class="row">
<div class="col">
<ReportActivityLedgerComponent ReportData="_report.ReportData"></ReportActivityLedgerComponent>
</div>
</div>

View file

@ -9,7 +9,8 @@ public partial class SalesReportView
{
[Parameter] public string ReportDate { get; set; }
[Inject] private IReportHttpRepository _reportRepo { get; set; }
private SalesReportViewModel _report { get; set; } = new();
[Inject] private NavigationManager _navigator { get; set; }
private ReportView _report { get; set; } = new();
protected override async Task OnInitializedAsync()
{
@ -21,8 +22,8 @@ public partial class SalesReportView
private async Task GetReport(string workDate)
{
ReportDate = workDate;
_report = new SalesReportViewModel();
if(workDate != ReportDate)
_navigator.NavigateTo($"/sales-reports/view/{workDate}");
_report = await _reportRepo.GetReport(workDate);
}
}

View file

@ -1,3 +1,4 @@
@using Wonky.Client.Components
@page "/task-items"
<div class="card">
@ -7,7 +8,7 @@
<h3 class="workDate">@(string.IsNullOrWhiteSpace(_workDate) ? "" : $"{DateTime.Parse(_workDate).ToLongDateString()}")</h3>
</div>
<div class="col">
<WorkDateComponent OnChanged="GetTaskItems"></WorkDateComponent>
<WorkDateComponent SelectedDate="_workDate" OnChanged="GetTaskItems"></WorkDateComponent>
</div>
<div class="col">
<a class="btn btn-primary" href="/task-items/new">NY OPGAVE</a>

View file

@ -28,10 +28,10 @@ public partial class TaskItemList : IDisposable
_interceptor.RegisterEvent();
_interceptor.RegisterBeforeSendEvent();
await GetActivities(_workDate);
await GetTaskItems(_workDate);
}
private async Task GetActivities(string workDate)
private async Task GetTaskItems(string workDate)
{
_toast.ShowInfo("Vent nogle sekunder for data");
_workDate = workDate;

View file

@ -1,12 +1,12 @@
{
"appInfo": {
"name": "Wonky Client",
"version": "0.8.83",
"version": "0.8.101",
"isBeta": true,
"image": "grumpy-coder.png"
},
"apiConfig": {
"innoBaseUrl": "https://dev.innotec.dk",
"innoBaseUrl": "https://staging.innotec.dk",
"glsTrackUrl": "https://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/DK01/DA/5004.htm?txtAction=71000&txtRefNo=",
"glsId": "",
"virkUrl": "api/v2/services/virk",

View file

@ -16,7 +16,18 @@
}
.page {
font-size: 10px;
border: initial;
border-radius: initial;
box-shadow: initial;
margin: 0;
min-height: initial;
page-break-after: always;
width: initial;
-webkit-print-color-adjust: exact;
color-adjust: exact;
}
.report-item {
font-size: 10px;
border: initial;
border-radius: initial;
box-shadow: initial;

View file

@ -0,0 +1,2 @@
User-agent: *
Disallow: /

View file

@ -8,16 +8,16 @@ public class ReportInitDto
/// <summary>
/// Flag to prevent activity to be added to report
/// </summary>
public bool Closed { get; set; }
public bool ReportClosed { get; set; }
/// <summary>
/// Report figures
/// </summary>
public ReportFiguresDto Figures { get; set; }
public ReportFiguresDto ReportData { get; set; }
/// <summary>
/// List of activities for report
/// </summary>
public List<ActivityListItemView> Activities { get; set; }
public List<ReportItemView> ReportItems { get; set; }
}

View file

@ -1,7 +0,0 @@
namespace Wonky.Entity.Views;
public class ActivityCompanyView
{
public string Name { get; set; } = "";
public string City { get; set; } = "";
}

View file

@ -1,7 +0,0 @@
namespace Wonky.Entity.Views;
public class ActivityListReportView
{
public bool ReportClosed { get; set; }
public List<ActivityListItemView> Activities { get; set; } = new();
}

View file

@ -0,0 +1,7 @@
namespace Wonky.Entity.Views;
public class ReportActivityInfoView
{
public bool ReportClosed { get; set; }
public List<ReportItemView> ReportItems { get; set; } = new();
}

View file

@ -1,6 +1,6 @@
namespace Wonky.Entity.Views;
public class SalesReportDataViewModel
public class ReportData
{
public string ReportId { get; set; } = "";
public string ErpUserId { get; set; } = "";

View file

@ -0,0 +1,37 @@
namespace Wonky.Entity.Views;
public class ReportItemCustomer
{
/// <summary>
/// Company name
/// </summary>
public string Name { get; set; } = "";
/// <summary>
/// Company account
/// </summary>
public string Account { get; set; } = "";
/// <summary>
/// Company office phone
/// </summary>
public string Phone { get; set; } = "";
/// <summary>
/// Company VAT registration number
/// </summary>
public string VatNumber { get; set; } = "";
/// <summary>
/// Company address city name
/// </summary>
public string City { get; set; } = "";
/// <summary>
/// Company address postal coce
/// </summary>
public string ZipCode { get; set; } = "";
/// <summary>
/// Company address line 1
/// </summary>
public string Address1 { get; set; } = "";
/// <summary>
/// Company address address line 2
/// </summary>
public string Address2 { get; set; } = "";
}

View file

@ -0,0 +1,29 @@
namespace Wonky.Entity.Views;
public class ReportItemLine
{
/// <summary>
/// Line description
/// </summary>
public string Description { get; set; } = "";
/// <summary>
/// Line item SKU
/// </summary>
public string Sku { get; set; } = "";
/// <summary>
/// Line item quantity
/// </summary>
public int Quantity { get; set; }
/// <summary>
/// Line item discount
/// </summary>
public decimal Discount { get; set; }
/// <summary>
/// Line item price
/// </summary>
public decimal Price { get; set; }
/// <summary>
/// Line sum
/// </summary>
public decimal LineSum { get; set; }
}

View file

@ -0,0 +1,7 @@
namespace Wonky.Entity.Views;
public class ReportItemListView
{
public bool ReportClosed { get; set; }
public List<ReportItemView> ReportItems { get; set; } = new();
}

View file

@ -1,70 +1,62 @@
namespace Wonky.Entity.Views;
public class ActivityListItemView
public class ReportItemView
{
/// <summary>
/// Company Info in listing
/// Customer company info
/// </summary>
public ActivityCompanyView Company { get; set; } = new();
public ReportItemCustomer Company { get; set; } = new();
/// <summary>
/// Processing note to office
/// Lines
/// </summary>
public string OfficeNote { get; set; } = "";
public List<ReportItemView> Lines { get; set; } = new();
/// <summary>
/// Total amount
/// </summary>
public decimal OrderAmount { get; set; }
/// <summary>
/// Sas amount
/// </summary>
public decimal SasAmount { get; set; }
/// <summary>
/// Sales head entity Id
/// </summary>
public string SalesHeadId { get; set; } = "";
/// <summary>
/// Flag indicating if activity is a sale or a quote
/// Closed sale
/// </summary>
public bool Closed { get; set; }
/// <summary>
/// Document date
/// Order amount
/// </summary>
public decimal OrderAmount { get; set; }
/// <summary>
/// Order safe seal amount
/// </summary>
public decimal SasAmount { get; set; }
/// <summary>
/// Order date
/// </summary>
public string OrderDate { get; set; } = "";
/// <summary>
/// Client reference number
/// Office note
/// </summary>
public string ReferenceNumber { get; set; } = "";
public string OfficeNote { get; set; } = "";
/// <summary>
/// Client reference name
/// Product demo
/// </summary>
public string Demo { get; set; } = "";
/// <summary>
/// Product sale resume
/// </summary>
public string Sales { get; set; } = "";
/// <summary>
/// Our reference
/// </summary>
public string OurRef { get; set; } = "";
/// <summary>
/// Customer reference
/// </summary>
public string YourRef { get; set; } = "";
/// <summary>
/// Customer reference number
/// </summary>
public string ReferenceNumber { get; set; } = "";
/// <summary>
/// Visit type enum as string
/// </summary>
public string VisitTypeEnum { get; set; } = "";
/// <summary>
/// Status type enum as string
/// Status type enum as string
/// </summary>
public string StatusTypeEnum { get; set; } = "";
/// <summary>
/// Demonstration
/// </summary>
public string Demo { get; set; } = "";
/// <summary>
/// Sales resume
/// </summary>
public string Sales { get; set; } = "";
}
}

View file

@ -0,0 +1,7 @@
namespace Wonky.Entity.Views;
public class ReportView
{
public ReportData ReportData { get; set; } = new();
public List<ReportItemView> ReportItems { get; set; } = new();
}

View file

@ -1,7 +0,0 @@
namespace Wonky.Entity.Views;
public class SalesReportViewModel
{
public SalesReportDataViewModel ReportData { get; set; } = new();
public List<ActivityListItemView> Activities { get; set; } = new ();
}