From f731bc4b582df1b203be59da3c0bbd2e19c5094d Mon Sep 17 00:00:00 2001 From: Frede Hundewadt <22748698+fhdk@users.noreply.github.com> Date: Sun, 19 Jun 2022 13:55:29 +0200 Subject: [PATCH] wip - refactor and adding functionality --- Wonky.Client/Components/ActivityButton.razor | 19 +- .../Components/ActivityTableComponent.razor | 45 ++ .../ActivityTableComponent.razor.cs | 9 + Wonky.Client/Components/AppSpinner.razor | 5 +- Wonky.Client/Components/AppVersion.razor | 1 + Wonky.Client/Components/ColorCoding.razor | 17 + .../Components/CompanyTableComponent.razor | 62 ++- Wonky.Client/Components/Home.razor | 1 - .../Components/ReportSummaryComponent.razor | 135 ++++++ .../ReportSummaryComponent.razor.cs | 11 + .../Components/TopbarNavigation.razor | 4 +- .../HttpRepository/CompanyHttpRepository.cs | 10 +- .../HttpRepository/IReportHttpRepository.cs | 1 + .../HttpRepository/ReportHttpRepository.cs | 8 + .../Pages/ActivityCompanyCreate.razor | 374 +++++++++++++++++ ...azor.cs => ActivityCompanyCreate.razor.cs} | 138 ++++--- Wonky.Client/Pages/ActivityCreate.razor | 386 ------------------ Wonky.Client/Pages/ActivityList.razor | 19 + Wonky.Client/Pages/ActivityList.razor.cs | 14 + Wonky.Client/Pages/ActivityToday.razor | 57 +-- Wonky.Client/Pages/CompanyCreate.razor | 2 +- Wonky.Client/Pages/CompanyCreate.razor.cs | 3 +- Wonky.Client/Pages/CompanyList.razor | 2 +- .../{CompanyEdit.razor => CompanyView.razor} | 129 +++--- ...panyEdit.razor.cs => CompanyView.razor.cs} | 108 ++--- Wonky.Client/Pages/ReportCreate.razor | 3 +- Wonky.Client/Pages/ReportView.razor | 136 ++---- Wonky.Client/Pages/ReportView.razor.cs | 1 + Wonky.Client/Pages/SalesReportList.razor | 30 ++ Wonky.Client/Pages/SalesReportList.razor.cs | 19 + ...rrorReport.razor => SiteErrorReport.razor} | 0 ...port.razor.cs => SiteErrorReport.razor.cs} | 2 +- Wonky.Client/Shared/NavMenu.razor | 4 +- Wonky.Client/wwwroot/appsettings.json | 4 +- Wonky.Client/wwwroot/css/app.css | 4 +- Wonky.Entity/DTO/CompanyDto.cs | 53 ++- Wonky.Entity/DTO/ReportDto.cs | 13 +- Wonky.Entity/Requests/ReportPagingParams.cs | 30 ++ 38 files changed, 1076 insertions(+), 783 deletions(-) create mode 100644 Wonky.Client/Components/ActivityTableComponent.razor create mode 100644 Wonky.Client/Components/ActivityTableComponent.razor.cs create mode 100644 Wonky.Client/Components/ReportSummaryComponent.razor create mode 100644 Wonky.Client/Components/ReportSummaryComponent.razor.cs create mode 100644 Wonky.Client/Pages/ActivityCompanyCreate.razor rename Wonky.Client/Pages/{ActivityCreate.razor.cs => ActivityCompanyCreate.razor.cs} (70%) delete mode 100644 Wonky.Client/Pages/ActivityCreate.razor create mode 100644 Wonky.Client/Pages/ActivityList.razor create mode 100644 Wonky.Client/Pages/ActivityList.razor.cs rename Wonky.Client/Pages/{CompanyEdit.razor => CompanyView.razor} (68%) rename Wonky.Client/Pages/{CompanyEdit.razor.cs => CompanyView.razor.cs} (63%) create mode 100644 Wonky.Client/Pages/SalesReportList.razor create mode 100644 Wonky.Client/Pages/SalesReportList.razor.cs rename Wonky.Client/Pages/{ErrorReport.razor => SiteErrorReport.razor} (100%) rename Wonky.Client/Pages/{ErrorReport.razor.cs => SiteErrorReport.razor.cs} (96%) create mode 100644 Wonky.Entity/Requests/ReportPagingParams.cs diff --git a/Wonky.Client/Components/ActivityButton.razor b/Wonky.Client/Components/ActivityButton.razor index 4fc2aabb..2cfa8948 100644 --- a/Wonky.Client/Components/ActivityButton.razor +++ b/Wonky.Client/Components/ActivityButton.razor @@ -1,6 +1,23 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + @if (Enabled == 1) { - Besøg + Besøg } else { diff --git a/Wonky.Client/Components/ActivityTableComponent.razor b/Wonky.Client/Components/ActivityTableComponent.razor new file mode 100644 index 00000000..8ff5d17e --- /dev/null +++ b/Wonky.Client/Components/ActivityTableComponent.razor @@ -0,0 +1,45 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +@if (Activities.Any()) +{ + + + + + + + + + + + @foreach (var activity in Activities) + { + + + + + + + } + +
BesøgDemoSalgBeløb
@activity.Company.Name, @activity.Company.ZipCity@activity.Demo@activity.SalesResume@activity.OrderAmount
+} +else +{ + +} \ No newline at end of file diff --git a/Wonky.Client/Components/ActivityTableComponent.razor.cs b/Wonky.Client/Components/ActivityTableComponent.razor.cs new file mode 100644 index 00000000..07f51127 --- /dev/null +++ b/Wonky.Client/Components/ActivityTableComponent.razor.cs @@ -0,0 +1,9 @@ +using Microsoft.AspNetCore.Components; +using Wonky.Entity.Views; + +namespace Wonky.Client.Components; + +public partial class ActivityTableComponent +{ + [Parameter] public List Activities { get; set; } +} \ No newline at end of file diff --git a/Wonky.Client/Components/AppSpinner.razor b/Wonky.Client/Components/AppSpinner.razor index 53db76d4..facd837f 100644 --- a/Wonky.Client/Components/AppSpinner.razor +++ b/Wonky.Client/Components/AppSpinner.razor @@ -13,6 +13,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // -*@
- Afventer svar fra netværk ... Venter ... +*@ +
+ Venter på svar ... Afventer server ...
diff --git a/Wonky.Client/Components/AppVersion.razor b/Wonky.Client/Components/AppVersion.razor index 7f420d6d..d734daed 100644 --- a/Wonky.Client/Components/AppVersion.razor +++ b/Wonky.Client/Components/AppVersion.razor @@ -16,6 +16,7 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // *@ + @_app?.Version@if(_app!.IsBeta){-beta} @code { diff --git a/Wonky.Client/Components/ColorCoding.razor b/Wonky.Client/Components/ColorCoding.razor index 34abd06d..171d9167 100644 --- a/Wonky.Client/Components/ColorCoding.razor +++ b/Wonky.Client/Components/ColorCoding.razor @@ -1,3 +1,20 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + diff --git a/Wonky.Client/Components/CompanyTableComponent.razor b/Wonky.Client/Components/CompanyTableComponent.razor index 225d8792..d043c168 100644 --- a/Wonky.Client/Components/CompanyTableComponent.razor +++ b/Wonky.Client/Components/CompanyTableComponent.razor @@ -20,42 +20,32 @@ @if (Companies.Any()) { -
- - - - - - - - - - - @foreach (var company in Companies) - { - - - - - - - - } - -
NavnKontoBynavn
- - - - @company.Name - - @company.Account - - @company.City - - Rediger - -
+ } else { diff --git a/Wonky.Client/Components/Home.razor b/Wonky.Client/Components/Home.razor index 5e8f9b06..7110ef08 100644 --- a/Wonky.Client/Components/Home.razor +++ b/Wonky.Client/Components/Home.razor @@ -28,6 +28,5 @@
- \ No newline at end of file diff --git a/Wonky.Client/Components/ReportSummaryComponent.razor b/Wonky.Client/Components/ReportSummaryComponent.razor new file mode 100644 index 00000000..20963cc3 --- /dev/null +++ b/Wonky.Client/Components/ReportSummaryComponent.razor @@ -0,0 +1,135 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Dagens Demo @(Report.NewDemoCount + Report.RecallDemoCount)Dagens ResultatMåneds Resultat
BesøgDemoSalgBeløbBesøgDemoSalgBeløb
N@Report.NewVisitCount@Report.NewDemoCount@Report.NewSaleCount@Report.NewTurnover@Report.NewVisitCountMonth@Report.NewDemoCountMonth@Report.NewSaleCountMonth@Report.NewTurnoverMonth
R@Report.RecallVisitCount@Report.RecallDemoCount@Report.RecallSaleCount@Report.RecallTurnover@Report.RecallVisitCountMonth@Report.RecallDemoCountMonth@Report.RecallSaleCountMonth@Report.RecallTurnoverMonth
SAS@Report.SasCount@Report.SasTurnover@Report.SasCountMonth@Report.SasTurnoverMonth
TOTAL@Report.TotalVisitCount@Report.TotalDemoCount@Report.TotalSaleCount@Report.TotalTurnover@Report.TotalVisitCountMonth@Report.TotalDemoCountMonth@Report.TotalSaleCountMonth@Report.TotalTurnoverMonth
+ + + + + + + + + + + + + + + + + + + + + +
+ Km Aften + + Km Morgen + + Km Kørt Dag + + Km Kørt Md. + + Km Privat + + Km Privat Md. +
@Report.KmEvening@Report.KmMorning@Report.Distance@Report.DistanceMonth@Report.DistancePrivate@Report.DistancePrivateMonth
+@if (!string.IsNullOrWhiteSpace(Report.Description) || !string.IsNullOrWhiteSpace(Report.SupervisedBy)) +{ + + + + + + + + + + + + + +
TekstMedkørende Supervisor
@Report.Description@Report.SupervisedBy
+} diff --git a/Wonky.Client/Components/ReportSummaryComponent.razor.cs b/Wonky.Client/Components/ReportSummaryComponent.razor.cs new file mode 100644 index 00000000..bf196367 --- /dev/null +++ b/Wonky.Client/Components/ReportSummaryComponent.razor.cs @@ -0,0 +1,11 @@ +using Wonky.Entity.Views; +using Microsoft.AspNetCore.Components; + +namespace Wonky.Client.Components; + +public partial class ReportSummaryComponent +{ + [Parameter] + public NgSalesReport Report { get; set; } + +} \ No newline at end of file diff --git a/Wonky.Client/Components/TopbarNavigation.razor b/Wonky.Client/Components/TopbarNavigation.razor index 554403a3..995c5f35 100644 --- a/Wonky.Client/Components/TopbarNavigation.razor +++ b/Wonky.Client/Components/TopbarNavigation.razor @@ -18,7 +18,7 @@ @using System.Security.Claims - Log af - INFO + LOG AF + HJÆLP \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CompanyHttpRepository.cs b/Wonky.Client/HttpRepository/CompanyHttpRepository.cs index 1d063fd1..b3f294bf 100644 --- a/Wonky.Client/HttpRepository/CompanyHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CompanyHttpRepository.cs @@ -91,13 +91,17 @@ public class CompanyHttpRepository : ICompanyHttpRepository return company ?? new CompanyDto(); } + /// + /// Create company from model + /// + /// + /// company id public async Task CreateCompany(CompanyDto model) { var response = await _client.PostAsJsonAsync($"{_apiConfig.CustomerEndpoint}", model); var content = await response.Content.ReadAsStringAsync(); - Console.WriteLine(content); - var result = JsonSerializer.Deserialize(content); - return result == null ? "" : result.CompanyId; + var result = JsonSerializer.Deserialize(content, _options); + return result.CompanyId; } public async Task UpdateCompany(string companyId, CompanyDto model) diff --git a/Wonky.Client/HttpRepository/IReportHttpRepository.cs b/Wonky.Client/HttpRepository/IReportHttpRepository.cs index bb75ba06..f936fd56 100644 --- a/Wonky.Client/HttpRepository/IReportHttpRepository.cs +++ b/Wonky.Client/HttpRepository/IReportHttpRepository.cs @@ -7,6 +7,7 @@ namespace Wonky.Client.HttpRepository; public interface IReportHttpRepository { Task ReportExist(string workDate); + Task> GetReports(); Task GetReport(string workDate); Task InitializeReportData(string workDate); Task PostReport(string workDate, ReportDto reportDto); diff --git a/Wonky.Client/HttpRepository/ReportHttpRepository.cs b/Wonky.Client/HttpRepository/ReportHttpRepository.cs index 174916e1..5520a631 100644 --- a/Wonky.Client/HttpRepository/ReportHttpRepository.cs +++ b/Wonky.Client/HttpRepository/ReportHttpRepository.cs @@ -30,6 +30,14 @@ public class ReportHttpRepository :IReportHttpRepository _apiConfig = configuration.Value; } + public async Task> GetReports() + { + var response = await _client.GetStringAsync($"{_apiConfig.ReportEndpoint}"); + Console.WriteLine(response); + + return new List(); + + } public async Task ReportExist(string workDate) { var result = diff --git a/Wonky.Client/Pages/ActivityCompanyCreate.razor b/Wonky.Client/Pages/ActivityCompanyCreate.razor new file mode 100644 index 00000000..058cac3f --- /dev/null +++ b/Wonky.Client/Pages/ActivityCompanyCreate.razor @@ -0,0 +1,374 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +@page "/companies/{companyId}/activities/new" +@using Microsoft.AspNetCore.Authorization +@attribute [Authorize(Roles = "Adviser")] +@using Wonky.Client.Components + +
+
+
+
+

@_workDate.ToLongDateString()

+
+
+ +
+
+
+
+ + +
+
+

+ +

+
+
+
+ +
+ + + + + + +
+ +
+ + + + + + +
+
+ +
+ +
+ + +
+ +
+ + +
+
+
+ +
+ + +
+ +
+ + +
+
+
+ +
+ + +
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+
+@* Order lines *@ +
+

+ +

+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+ @if (_caltalog.Any()) + { + + + + + + + + + + + @foreach (var item in _caltalog) + { + + + + + + + } + +
NavnVarenrForkStk / Pris
@item.Name@item.Sku@item.ShortName +
    + @foreach (var rate in item.Rates) + { +
  • +
    @rate.Quantity
    +
    @rate.Rate
    + +
  • + } +
+
+ } + else + { + + } + @if (_selectedItem != null && ShowItem) + { +
+
Kladdelinje
+
+
+
+ Varenavn +
+
+ Varenr +
+
+ Antal +
+
+ Pris +
+
+ Rabat +
+
+ SAS +
+
+ +
+
+
+
+ @_selectedItem.Name +
+
+ @_selectedItem.Sku +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ } + @* Order draft lines *@ +
+
+ Kladdelinjer Global kladde (udløber efter @(DraftStateProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet) +
+
+ + + + + + + + + + + + + @if (DraftStateProvider != null && DraftStateProvider.Draft.Items.Count > 0) + { + @foreach (var cItem in DraftStateProvider.Draft.Items) + { + + + + + + + + + + } + + + + + + + + + } + +
NavnVarenrAntalEnhedsprisLinjesum 
@cItem.Item.Name@cItem.Item.Sku@cItem.Quantity@cItem.Price@cItem.LineTotal + + + +
Total@DraftStateProvider.Draft.Total
+
+ +
+
+
+@* Delivery address *@ +
+

+ +

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ Tilbage +
+
+ @* *@ + +
+
+
+
+
\ No newline at end of file diff --git a/Wonky.Client/Pages/ActivityCreate.razor.cs b/Wonky.Client/Pages/ActivityCompanyCreate.razor.cs similarity index 70% rename from Wonky.Client/Pages/ActivityCreate.razor.cs rename to Wonky.Client/Pages/ActivityCompanyCreate.razor.cs index 7034e5da..6a3f1caa 100644 --- a/Wonky.Client/Pages/ActivityCreate.razor.cs +++ b/Wonky.Client/Pages/ActivityCompanyCreate.razor.cs @@ -30,10 +30,10 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class ActivityCreate : IDisposable +public partial class ActivityCompanyCreate : IDisposable { // todo: prevent creating activity for workDate with closed report - [Inject] private ILogger _logger { get; set; } + [Inject] private ILogger _logger { get; set; } [Inject] private IToastService _toast { get; set; } [Inject] private NavigationManager _navigator { get; set; } [Inject] private ILocalStorageService _storage { get; set; } @@ -50,13 +50,13 @@ public partial class ActivityCreate : IDisposable PropertyNameCaseInsensitive = true }; private NgSalesItemView _selectedItem { get; set; } = new(); - private List SalesItems { get; set; } = new(); - private MetaData MetaData { get; set; } = new(); + private List _caltalog { get; set; } = new(); + private MetaData _metaData { get; set; } = new(); private Preferences _prefs { get; set; } = new(); - private ActivityDto _poDraft { get; set; } = new(); - private CompanyDto NgCompany = new(); + private ActivityDto _draft { get; set; } = new(); + private CompanyDto _company = new(); private CatalogPagingParams _paging = new(); - private EditContext DraftContext { get; set; } + private EditContext _editContext { get; set; } private bool _poFormInvalid { get; set; } = true; private bool ShowItem { get; set; } private bool HideButtons { get; set; } @@ -72,61 +72,67 @@ public partial class ActivityCreate : IDisposable private UserInfoView Ux { get; set; } = new(); private DateTime _workDate { get; set; } = DateTime.Now; - protected override async Task OnInitializedAsync() + protected override async Task OnParametersSetAsync() { - _interceptor.RegisterEvent(); - _interceptor.RegisterBeforeSendEvent(); - _prefs = await _userPrefs.GetPreferences(); if (!string.IsNullOrWhiteSpace(_prefs.WorkDate)) _workDate = DateTime.Parse(_prefs.WorkDate); - _poDraft.ActivityDate = $"{_workDate:yyyy-MM-dd}" ; + // raise flag if report is closed + _reportClosdd = await _reportRepo.ReportExist($"{_workDate:yyyy-MM-dd}"); + if(_reportClosdd) + _navigator.NavigateTo($"/sales-reports/view/{_workDate:yyyy-MM-dd}"); - // check if report is closed + } + + protected override async Task OnInitializedAsync() + { + _editContext = new EditContext(_draft); + _editContext.OnFieldChanged += HandleFieldChanged; + _editContext.OnValidationStateChanged += ValidationChanged; - _reportClosdd = await _reportRepo.ReportExist(_poDraft.ActivityDate); + _interceptor.RegisterEvent(); + _interceptor.RegisterBeforeSendEvent(); + _draft.ActivityDate = $"{_workDate:yyyy-MM-dd}" ; + + // todo - does it make sense to continue if _reportClosed is true? _paging.SearchColumn = _prefs.ItemSearch ?? "name"; _paging.PageSize = Convert.ToInt32(_prefs.PageSize); await GetSalesItems(); Ux = await _storage.GetItemAsync("_xu"); - NgCompany = await _companyRepo.GetCompanyById(CompanyId); - - DraftContext = new EditContext(_poDraft); - DraftContext.OnFieldChanged += HandleFieldChanged; - DraftContext.OnValidationStateChanged += ValidationChanged; + _company = await _companyRepo.GetCompanyById(CompanyId); // set up identification - _poDraft.CompanyId = NgCompany.CompanyId; - _poDraft.BcId = NgCompany.BcId; - _poDraft.SalesRepId = Ux.Id; + _draft.CompanyId = _company.CompanyId; + _draft.BcId = _company.BcId; + _draft.SalesRepId = Ux.Id; - _poDraft.ActivityStatusEnum = "noSale"; - _poDraft.VisitTypeEnum = NgCompany.Account is "" or "NY" ? "new" : "recall"; + _draft.ActivityStatusEnum = "noSale"; + _draft.VisitTypeEnum = _company.Account is "" or "NY" ? "new" : "recall"; // permanent identifications - _poDraft.SalesRep = Ux.Adviser; - _poDraft.Account = NgCompany.Account; - _poDraft.VatNumber = NgCompany.VatNumber; - _poDraft.EMail = NgCompany.Email; - _poDraft.Phone = NgCompany.Phone; - _poDraft.Mobile = NgCompany.Mobile; + _draft.SalesRep = Ux.Adviser; + _draft.Account = _company.Account; + _draft.VatNumber = _company.VatNumber; + _draft.EMail = _company.Email; + _draft.Phone = _company.Phone; + _draft.Mobile = _company.Mobile; - _poDraft.Name = NgCompany.Name; - _poDraft.Address1 = NgCompany.Address1; - _poDraft.Address2 = NgCompany.Address2; - _poDraft.ZipCode = NgCompany.ZipCode; - _poDraft.City = NgCompany.City; + _draft.Name = _company.Name; + _draft.Address1 = _company.Address1; + _draft.Address2 = _company.Address2; + _draft.ZipCode = _company.ZipCode; + _draft.City = _company.City; - _poDraft.DlvName = NgCompany.Name; - _poDraft.DlvAddress1 = NgCompany.Address1; - _poDraft.DlvAddress2 = NgCompany.Address2; - _poDraft.DlvZipCode = NgCompany.ZipCode; - _poDraft.DlvCity = NgCompany.City; + _draft.DlvName = _company.Name; + _draft.DlvAddress1 = _company.Address1; + _draft.DlvAddress2 = _company.Address2; + _draft.DlvZipCode = _company.ZipCode; + _draft.DlvCity = _company.City; } @@ -134,21 +140,21 @@ public partial class ActivityCreate : IDisposable { _logger.LogInformation("WorkDateComponent.OnChanged(SetWorkDate(workDate)) => {workDate}", workDate); _workDate = DateTime.Parse(workDate); - _poDraft.ActivityDate = workDate; + _draft.ActivityDate = workDate; } private async Task CreateActivity() { HideButtons = true; - _poDraft.ActivityDate = _prefs.WorkDate; + _draft.ActivityDate = _prefs.WorkDate; - var activityType = _poDraft.ActivityTypeEnum switch + var activityType = _draft.ActivityTypeEnum switch { "phone" => "T", "onSite" => "B", _ => "" }; - _poDraft.OurRef = $"{activityType}:{Ux.FullName.Split(" ")[0]}"; + _draft.OurRef = $"{activityType}:{Ux.FullName.Split(" ")[0]}"; var ln = 0; // post to create activity endpoint @@ -168,18 +174,18 @@ public partial class ActivityCreate : IDisposable }; lines.Add(line); } - _poDraft.Lines = lines; + _draft.Lines = lines; - await _storage.SetItemAsync(CompanyId, _poDraft); - Console.WriteLine(JsonSerializer.Serialize(_poDraft)); - var result = await _activityRepo.CreateActivity(_poDraft); + await _storage.SetItemAsync(CompanyId, _draft); + Console.WriteLine(JsonSerializer.Serialize(_draft)); + var result = await _activityRepo.CreateActivity(_draft); _toast.ShowSuccess($"{result.Message}."); _navigator.NavigateTo($"/companies"); } private void CheckActivity() { - InvalidActivityType = string.IsNullOrWhiteSpace(_poDraft.ActivityTypeEnum); + InvalidActivityType = string.IsNullOrWhiteSpace(_draft.ActivityTypeEnum); } private async Task DeleteDraft() { @@ -189,7 +195,7 @@ public partial class ActivityCreate : IDisposable private void SelectItem(string itemId, string quantity, string price) { ShowItem = true; - _selectedItem = (from x in SalesItems where x.ItemId == itemId select x).First(); + _selectedItem = (from x in _caltalog where x.ItemId == itemId select x).First(); Price = price; Quantity = quantity; } @@ -225,14 +231,14 @@ public partial class ActivityCreate : IDisposable } private async Task SetItemGroup(string groupFilter) { - SalesItems = new List(); + _caltalog = new List(); _paging.PageNumber = 1; _paging.SelectGroup = groupFilter; await GetSalesItems(); } private async Task SetSearchCol(string columnName) { - SalesItems = new List(); + _caltalog = new List(); _paging.PageNumber = 1; _paging.SearchTerm = ""; _paging.SearchColumn = columnName; @@ -240,27 +246,27 @@ public partial class ActivityCreate : IDisposable } private async Task SetSortCol(string orderBy) { - SalesItems = new List(); + _caltalog = new List(); _paging.OrderBy = orderBy; await GetSalesItems(); } private async Task SetSearchPhrase(string searchTerm) { - SalesItems = new List(); + _caltalog = new List(); _paging.PageNumber = 1; _paging.SearchTerm = searchTerm; await GetSalesItems(); } private async Task SelectedPage(int page) { - SalesItems = new List(); + _caltalog = new List(); _paging.PageNumber = page; await GetSalesItems(); } private async Task SetPageSize(string pageSize) { - SalesItems = new List(); + _caltalog = new List(); _paging.PageSize = Convert.ToInt32(pageSize); _paging.PageNumber = 1; await GetSalesItems(); @@ -269,8 +275,8 @@ public partial class ActivityCreate : IDisposable private async Task GetSalesItems() { var response = await _itemRepo.GetSalesItemsPaged(_paging); - SalesItems = response.Items!; - MetaData = response.MetaData; + _caltalog = response.Items!; + _metaData = response.MetaData; } private void HandleFieldChanged(object sender, FieldChangedEventArgs e) @@ -287,27 +293,27 @@ public partial class ActivityCreate : IDisposable // return; // } - _poFormInvalid = !DraftContext.Validate(); + _poFormInvalid = !_editContext.Validate(); StateHasChanged(); } private void ValidationChanged(object sender, ValidationStateChangedEventArgs e) { - if (string.IsNullOrEmpty(_poDraft.ActivityTypeEnum)) + if (string.IsNullOrEmpty(_draft.ActivityTypeEnum)) _toast.ShowWarning("Aktivitet type kan ikke være tom"); _poFormInvalid = false; - DraftContext.OnFieldChanged -= HandleFieldChanged; - DraftContext = new EditContext(_poDraft); - DraftContext.OnFieldChanged += HandleFieldChanged; - DraftContext.OnValidationStateChanged -= ValidationChanged; + _editContext.OnFieldChanged -= HandleFieldChanged; + _editContext = new EditContext(_draft); + _editContext.OnFieldChanged += HandleFieldChanged; + _editContext.OnValidationStateChanged -= ValidationChanged; } public void Dispose() { _interceptor.DisposeEvent(); - DraftContext.OnFieldChanged -= HandleFieldChanged; - DraftContext.OnValidationStateChanged -= ValidationChanged; + _editContext.OnFieldChanged -= HandleFieldChanged; + _editContext.OnValidationStateChanged -= ValidationChanged; } } \ No newline at end of file diff --git a/Wonky.Client/Pages/ActivityCreate.razor b/Wonky.Client/Pages/ActivityCreate.razor deleted file mode 100644 index f426dc8e..00000000 --- a/Wonky.Client/Pages/ActivityCreate.razor +++ /dev/null @@ -1,386 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@page "/company/{companyId}/activity" -@using Microsoft.AspNetCore.Authorization -@attribute [Authorize(Roles = "Adviser")] -@using Wonky.Client.Components - -
-
-
@_workDate.ToLongDateString()
-
-
- -
-
- -@if (_reportClosdd) -{ -
-
-
Rapport for @($"{_workDate:yyyy-MM-dd}") er fundet.
-
- -
-} -else -{ -@if (DraftContext != null) -{ - - -
-
-

- -

-
-
-
- -
- - - - - - -
- -
- - - - - - -
-
- -
- -
- - -
- -
- - -
-
-
- -
- - -
- -
- - -
-
-
- -
- - -
- -
- - -
-
-
- -
- - -
-
-
-
-
- @* Order lines *@ -
-

- -

-
-
-
-
- -
-
- -
-
- -
-
- -
-
- -
-
-
-
-
- -
-
- @if (SalesItems.Any()) - { - - - - - - - - - - - @foreach (var item in SalesItems) - { - - - - - - - } - -
NavnVarenrForkStk / Pris
@item.Name@item.Sku@item.ShortName -
    - @foreach (var rate in item.Rates) - { -
  • -
    @rate.Quantity
    -
    @rate.Rate
    - -
  • - } -
-
- } - else - { - - } - @if (_selectedItem != null && ShowItem) - { -
-
Kladdelinje
-
-
-
- Varenavn -
-
- Varenr -
-
- Antal -
-
- Pris -
-
- Rabat -
-
- SAS -
-
- -
-
-
-
- @_selectedItem.Name -
-
- @_selectedItem.Sku -
-
- -
-
- -
-
- -
-
- -
-
- -
-
-
-
- } - @* Order draft lines *@ -
-
- Kladdelinjer Global kladde (udløber efter @(DraftStateProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet) -
-
- - - - - - - - - - - - - @if (DraftStateProvider != null && DraftStateProvider.Draft.Items.Count > 0) - { - @foreach (var cItem in DraftStateProvider.Draft.Items) - { - - - - - - - - - - } - - - - - - - - - } - -
NavnVarenrAntalEnhedsprisLinjesum 
@cItem.Item.Name@cItem.Item.Sku@cItem.Quantity@cItem.Price@cItem.LineTotal - - - -
Total@DraftStateProvider.Draft.Total
-
- -
-
-
- @* Delivery address *@ -
-

- -

-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
-
-
- -
- Tilbage -
-
- @* *@ - -
-
-
-} -} \ No newline at end of file diff --git a/Wonky.Client/Pages/ActivityList.razor b/Wonky.Client/Pages/ActivityList.razor new file mode 100644 index 00000000..209bc374 --- /dev/null +++ b/Wonky.Client/Pages/ActivityList.razor @@ -0,0 +1,19 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +@page "/ActivityList" +

ActivityList

diff --git a/Wonky.Client/Pages/ActivityList.razor.cs b/Wonky.Client/Pages/ActivityList.razor.cs new file mode 100644 index 00000000..9f9596c7 --- /dev/null +++ b/Wonky.Client/Pages/ActivityList.razor.cs @@ -0,0 +1,14 @@ +using Microsoft.AspNetCore.Components; +using Toolbelt.Blazor; +using Wonky.Client.HttpRepository; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages; + +public partial class ActivityList +{ + [Inject] public IActivityHttpRepository ActivityRepo { get; set; } + [Inject] public IHttpClientInterceptor Interceptor { get; set; } + + +} \ No newline at end of file diff --git a/Wonky.Client/Pages/ActivityToday.razor b/Wonky.Client/Pages/ActivityToday.razor index 69c8bc8a..f7ad98e5 100644 --- a/Wonky.Client/Pages/ActivityToday.razor +++ b/Wonky.Client/Pages/ActivityToday.razor @@ -14,53 +14,24 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // *@ + @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components @attribute [Authorize(Roles = "Adviser")] @page "/activity-today" -
-
- @(string.IsNullOrWhiteSpace(_workDate) ? "" : $"{DateTime.Parse(_workDate).ToLongDateString()}") -
-
- -
-
+
+
+
+
+

@(string.IsNullOrWhiteSpace(_workDate) ? "" : $"{DateTime.Parse(_workDate).ToLongDateString()}")

+
+
+ +
+
- -
-
Dagens aktivitet
- - - - - - - - - - - @if (_view != null) - { - foreach (var activity in _view.Activities) - { - - - - - - - } - } - -
KundeDemoSalgSum
- @activity.Company.Name - - @activity.Demo - - @activity.SalesResume - - @activity.OrderAmount -
\ No newline at end of file +
+ +
diff --git a/Wonky.Client/Pages/CompanyCreate.razor b/Wonky.Client/Pages/CompanyCreate.razor index 3b63bd4c..093e9453 100644 --- a/Wonky.Client/Pages/CompanyCreate.razor +++ b/Wonky.Client/Pages/CompanyCreate.razor @@ -15,7 +15,7 @@ // *@ -@page "/company/create" +@page "/companies/new" @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components @using System.Xml diff --git a/Wonky.Client/Pages/CompanyCreate.razor.cs b/Wonky.Client/Pages/CompanyCreate.razor.cs index 4ae0fe72..d232b438 100644 --- a/Wonky.Client/Pages/CompanyCreate.razor.cs +++ b/Wonky.Client/Pages/CompanyCreate.razor.cs @@ -124,10 +124,11 @@ namespace Wonky.Client.Pages private async Task SubmitCompanyForm() { var newId = await CompanyRepo.CreateCompany(_companyObject); + if (!string.IsNullOrWhiteSpace(newId)) { ToastService.ShowSuccess($"'{_companyObject.Name}' er oprettet i CRM."); - Navigation.NavigateTo($"/company/id/{newId}"); + Navigation.NavigateTo($"/companies/{newId}"); } else { diff --git a/Wonky.Client/Pages/CompanyList.razor b/Wonky.Client/Pages/CompanyList.razor index c274ef75..139cd258 100644 --- a/Wonky.Client/Pages/CompanyList.razor +++ b/Wonky.Client/Pages/CompanyList.razor @@ -44,7 +44,7 @@
diff --git a/Wonky.Client/Pages/CompanyEdit.razor b/Wonky.Client/Pages/CompanyView.razor similarity index 68% rename from Wonky.Client/Pages/CompanyEdit.razor rename to Wonky.Client/Pages/CompanyView.razor index c2602ca9..a8356719 100644 --- a/Wonky.Client/Pages/CompanyEdit.razor +++ b/Wonky.Client/Pages/CompanyView.razor @@ -14,53 +14,57 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // *@ + @using Microsoft.AspNetCore.Authorization @using Microsoft.AspNetCore.Components @using Wonky.Client.Components @using Wonky.Client.Helpers @attribute [Authorize(Roles = "Adviser")] -@page "/company/{CompanyId}/update" +@page "/companies/{CompanyId}" -@if (!string.IsNullOrWhiteSpace(_companyView.Name)) +@if (!string.IsNullOrWhiteSpace(_company.Name)) {
-
@_companyView.Account - @_companyView.Name
+

@_company.Account - @_company.Name

-
- -
- @if (_vInfos.Any()) + @if (countryCode == "dk" && _company.ValidVat == 0) { - - - - - - - - - - - - @foreach (var info in _vInfos) - { +
+ +
+ @if (_vInfos.Any()) + { +
CVR ORGNavnStatus
+ - - - - - + + + + + - } - -
@info.VatNumber@info.Name@info.States[^1].State - - - - CVR ORGNavnStatus
+ + + @foreach (var info in _vInfos) + { + + @info.VatNumber + @info.Name + @info.States[^1].State + + + + + + + + } + + + } } - +
@@ -73,15 +77,15 @@ @@ -90,15 +94,15 @@ @@ -107,15 +111,15 @@ @@ -124,15 +128,15 @@ @@ -141,15 +145,15 @@ @@ -157,11 +161,12 @@ Næste besøg
- - + + Telefon - - + +
- - + + Attention - - + +
- - + + Adresse2 - - + +
- - + + Bynavn - - + +
- - + + Mobil - - + +
- + + - Dato kan ikke vær før sidste besøg + Dato kan ikke vær før sidste besøg Besøgt @@ -176,8 +181,8 @@ - - + + @@ -191,14 +196,6 @@ diff --git a/Wonky.Client/Pages/CompanyEdit.razor.cs b/Wonky.Client/Pages/CompanyView.razor.cs similarity index 63% rename from Wonky.Client/Pages/CompanyEdit.razor.cs rename to Wonky.Client/Pages/CompanyView.razor.cs index b847be56..261c5a46 100644 --- a/Wonky.Client/Pages/CompanyEdit.razor.cs +++ b/Wonky.Client/Pages/CompanyView.razor.cs @@ -32,19 +32,18 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class CompanyEdit : IDisposable +public partial class CompanyView : IDisposable { [Inject] public IToastService ToastService { get; set; } - [Inject] public ILogger Logger { get; set; } + [Inject] public ILogger Logger { get; set; } [Inject] public NavigationManager Navigation { get; set; } [Inject] public ICompanyHttpRepository CompanyRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public VatInfoLookupService VatInfoLookupService { get; set; } [Inject] public ILocalStorageService StorageService { get; set; } - [Parameter] public string Account { get; set; } = ""; [Parameter] public string CompanyId { get; set; } = ""; - private CompanyDto _companyView { get; set; } = new(); - private EditContext _updateCompany { get; set; } + private CompanyDto _company { get; set; } = new(); + private EditContext _editContext { get; set; } private List _vInfos { get; set; } = new(); private VirkRegInfo _virkRegInfo { get; set; } = new(); private DateTime _lastVisit { get; set; } @@ -55,6 +54,8 @@ public partial class CompanyEdit : IDisposable private bool _hasFolded; private bool _formInvalid = true; private string _orgVat; + private string countryCode = "dk"; + private string _visitState = "the-ugly"; private readonly JsonSerializerOptions _options = new () { @@ -64,93 +65,94 @@ public partial class CompanyEdit : IDisposable protected override async Task OnInitializedAsync() { var ux = await StorageService.GetItemAsync("_xu"); - + countryCode = ux.CountryCode; Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); - _companyView = await CompanyRepo.GetCompanyById(CompanyId); - _orgVat = _companyView.VatNumber; - _companyView.CountryCode = ux.CountryCode.ToLower(); + _company = await CompanyRepo.GetCompanyById(CompanyId); + _orgVat = _company.VatNumber; + _company.CountryCode = ux.CountryCode.ToLower(); - vatAddress = PrepareVatAddress(_companyView); + vatAddress = PrepareVatAddress(_company); - if (_companyView.Interval == 0) - _companyView.Interval = 8; + if (_company.Interval == 0) + _company.Interval = 8; - _lastVisit = DateTime.Parse(_companyView.LastVisit); - _nextVisit = DateTime.Parse(_companyView.NextVisit); + _lastVisit = DateTime.Parse(_company.LastVisit); + _nextVisit = DateTime.Parse(_company.NextVisit); - if (!_companyView.ValidDateSpan()) - _nextVisit = _lastVisit.AddDays(_companyView.Interval * 7); - - if(_companyView.HasFolded == 1) + if (!_company.ValidDateSpan()) + _nextVisit = _lastVisit.AddDays(_company.Interval * 7); + if(_company.HasFolded == 1) { _hasFolded = true; _vatState = "the-dead"; + _visitState = "the-dead"; } else { - if (_companyView.ValidVat == 0 && !string.IsNullOrWhiteSpace(_companyView.VatNumber)) - _companyView.ValidVat = VatUtils.ValidateFormat(_companyView.CountryCode, _companyView.VatNumber) ? 1 : 0; - _validVat = _companyView.ValidVat == 1; - _vatState = _companyView.ValidVat == 1 ? "the-good" : "the-draw"; + if (_company.ValidVat == 0 && !string.IsNullOrWhiteSpace(_company.VatNumber)) + _company.ValidVat = VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber) ? 1 : 0; + _validVat = _company.ValidVat == 1; + _vatState = _company.ValidVat == 1 ? "the-good" : "the-draw"; + _visitState = Utils.GetVisitState($"{_nextVisit:yyyy-HH-mm}"); } - _updateCompany = new EditContext(_companyView); - _updateCompany.OnFieldChanged += HandleFieldChanged; - _updateCompany.OnValidationStateChanged += ValidationChanged; + _editContext = new EditContext(_company); + _editContext.OnFieldChanged += HandleFieldChanged; + _editContext.OnValidationStateChanged += ValidationChanged; } private void HandleFieldChanged(object sender, FieldChangedEventArgs e) { - _nextVisit = _lastVisit.AddDays(_companyView.Interval * 7); + _nextVisit = _lastVisit.AddDays(_company.Interval * 7); - _companyView.LastVisit = $"{_lastVisit:yyyy-MM-dd}"; - _companyView.NextVisit = $"{_nextVisit:yyyy-MM-dd}"; + _company.LastVisit = $"{_lastVisit:yyyy-MM-dd}"; + _company.NextVisit = $"{_nextVisit:yyyy-MM-dd}"; - if (!VatUtils.ValidateFormat(_companyView.CountryCode, _companyView.VatNumber) || - !_companyView.ValidDateSpan()) + if (!VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber) || + !_company.ValidDateSpan()) { _formInvalid = true; } else { - _formInvalid = !_updateCompany.Validate(); + _formInvalid = !_editContext.Validate(); } StateHasChanged(); } private void ValidationChanged(object sender, ValidationStateChangedEventArgs e) { _formInvalid = true; - _updateCompany.OnFieldChanged -= HandleFieldChanged; + _editContext.OnFieldChanged -= HandleFieldChanged; - _updateCompany = new EditContext(_companyView); + _editContext = new EditContext(_company); - _updateCompany.OnFieldChanged += HandleFieldChanged; - _updateCompany.OnValidationStateChanged -= ValidationChanged; + _editContext.OnFieldChanged += HandleFieldChanged; + _editContext.OnValidationStateChanged -= ValidationChanged; } private async Task SubmitUpdate() { - if (!VatUtils.ValidateFormat(_companyView.CountryCode, _companyView.VatNumber)) + if (!VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber)) { ToastService.ShowError($"CVR/VAT/ORG nummer er ugyldig."); StateHasChanged(); return; } - _companyView.LastVisit = $"{_lastVisit:yyyy-MM-dd}"; - _companyView.NextVisit = $"{_nextVisit:yyyy-MM-dd}"; - _companyView.IsHidden = 0; - if (_companyView.VatNumber != _orgVat) - _companyView.UpdateErpVat = 1; + _company.LastVisit = $"{_lastVisit:yyyy-MM-dd}"; + _company.NextVisit = $"{_nextVisit:yyyy-MM-dd}"; + _company.IsHidden = 0; + if (_company.VatNumber != _orgVat) + _company.UpdateErpVat = 1; - var x = JsonSerializer.Serialize(_companyView, _options); + var x = JsonSerializer.Serialize(_company, _options); Logger.LogInformation(x); - var success = await CompanyRepo.UpdateCompany(CompanyId, _companyView ); + var success = await CompanyRepo.UpdateCompany(CompanyId, _company ); if (success) { ToastService.ShowSuccess("Check"); - Navigation.NavigateTo($"/company/{CompanyId}"); + Navigation.NavigateTo($"/companies/{CompanyId}"); } } @@ -173,16 +175,16 @@ public partial class CompanyEdit : IDisposable _virkRegInfo = (from x in _vInfos where x.VatNumber == vatNumber select x).First(); if (syncAll) { - _companyView.VatNumber = _virkRegInfo.VatNumber; - _companyView.Name = _virkRegInfo.Name; - _companyView.Address1 = _virkRegInfo.Address; - _companyView.Address2 = _virkRegInfo.CoName; - _companyView.ZipCode = _virkRegInfo.ZipCode; - _companyView.City = _virkRegInfo.City; + _company.VatNumber = _virkRegInfo.VatNumber; + _company.Name = _virkRegInfo.Name; + _company.Address1 = _virkRegInfo.Address; + _company.Address2 = _virkRegInfo.CoName; + _company.ZipCode = _virkRegInfo.ZipCode; + _company.City = _virkRegInfo.City; } else { - _companyView.VatNumber = _virkRegInfo.VatNumber; + _company.VatNumber = _virkRegInfo.VatNumber; } _vInfos = new List(); @@ -192,8 +194,8 @@ public partial class CompanyEdit : IDisposable public void Dispose() { Interceptor.DisposeEvent(); - _updateCompany.OnFieldChanged -= HandleFieldChanged; - _updateCompany.OnValidationStateChanged -= ValidationChanged; + _editContext.OnFieldChanged -= HandleFieldChanged; + _editContext.OnValidationStateChanged -= ValidationChanged; } private static VatAddress PrepareVatAddress(CompanyDto model) { diff --git a/Wonky.Client/Pages/ReportCreate.razor b/Wonky.Client/Pages/ReportCreate.razor index 15ea71a9..d301c1ea 100644 --- a/Wonky.Client/Pages/ReportCreate.razor +++ b/Wonky.Client/Pages/ReportCreate.razor @@ -14,10 +14,11 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // *@ + @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components @attribute [Authorize(Roles = "Adviser")] -@page "/sales-report" +@page "/sales-reports/new"
diff --git a/Wonky.Client/Pages/ReportView.razor b/Wonky.Client/Pages/ReportView.razor index 5e6e6e9e..0b9aa170 100644 --- a/Wonky.Client/Pages/ReportView.razor +++ b/Wonky.Client/Pages/ReportView.razor @@ -1,105 +1,41 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + @using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization -@page "/sales-report/view/{reportDate}" +@page "/sales-reports/view/{ReportDate}" @attribute [Authorize(Roles = "Adviser,Admin,Supervisor")] - -
- @if (_report.Activities.Any()) - { - - - - - - - - - - - @foreach (var activity in _report.Activities) - { - - - - - - - } - - - - - - - -
BesøgDemoSalgBeløb
@activity.Company.Name - @activity.Company.ZipCity@activity.Demo@activity.SalesResume@activity.OrderAmount
Total@_report.Report.TotalTurnover
- } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Demo @(_report.Report.NewDemoCount + _report.Report.RecallDemoCount)ResultatResultat Måned
BesøgDemoSalgBeløbBesøgDemoSalgBeløb
N@_report.Report.NewVisitCount@_report.Report.NewDemoCount@_report.Report.NewSaleCount@_report.Report.NewTurnover@_report.Report.NewVisitCountMonth@_report.Report.NewDemoCountMonth@_report.Report.NewSaleCountMonth@_report.Report.NewTurnoverMonth
R@_report.Report.RecallVisitCount@_report.Report.RecallDemoCount@_report.Report.RecallSaleCount@_report.Report.RecallTurnover@_report.Report.RecallVisitCountMonth@_report.Report.RecallDemoCountMonth@_report.Report.RecallSaleCountMonth@_report.Report.RecallTurnoverMonth
SAS@_report.Report.SasCount@_report.Report.SasTurnover@_report.Report.SasCountMonth@_report.Report.SasTurnoverMonth
TOTAL@(_report.Report.TotalVisitCount)@(_report.Report.TotalDemoCount)@(_report.Report.TotalSaleCount)@(_report.Report.TotalTurnover)@(_report.Report.TotalVisitCountMonth)@(_report.Report.TotalDemoCountMonth)@(_report.Report.TotalSaleCountMonth)@(_report.Report.TotalTurnoverMonth)
+
+
+
+
+ @if (!string.IsNullOrWhiteSpace(ReportDate)) + { +

Dagsrapport @DateTime.Parse(ReportDate).ToLongDateString()

+ } +
+
+ +
+
+
+
+ + +
\ No newline at end of file diff --git a/Wonky.Client/Pages/ReportView.razor.cs b/Wonky.Client/Pages/ReportView.razor.cs index 16177fb0..75c3b730 100644 --- a/Wonky.Client/Pages/ReportView.razor.cs +++ b/Wonky.Client/Pages/ReportView.razor.cs @@ -21,6 +21,7 @@ public partial class ReportView private async Task GetReport(string workDate) { + _report = new NgSalesReportView(); _report = await ReportRepo.GetReport(workDate); } } \ No newline at end of file diff --git a/Wonky.Client/Pages/SalesReportList.razor b/Wonky.Client/Pages/SalesReportList.razor new file mode 100644 index 00000000..2816827d --- /dev/null +++ b/Wonky.Client/Pages/SalesReportList.razor @@ -0,0 +1,30 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +@page "/sales-reports" +

SalesReportList

+@if (_reports != null) +{ + foreach (var report in _reports) + { + @report.Name + } +} +else +{ + +} diff --git a/Wonky.Client/Pages/SalesReportList.razor.cs b/Wonky.Client/Pages/SalesReportList.razor.cs new file mode 100644 index 00000000..7ee85589 --- /dev/null +++ b/Wonky.Client/Pages/SalesReportList.razor.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Components; +using Toolbelt.Blazor; +using Wonky.Client.HttpRepository; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages; + +public partial class SalesReportList +{ + [Inject] public IReportHttpRepository ReportRepo { get; set; } + [Inject] public IHttpClientInterceptor Interceport { get; set; } + + private List _reports { get; set; } + + protected override async Task OnInitializedAsync() + { + _reports = await ReportRepo.GetReports(); + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/ErrorReport.razor b/Wonky.Client/Pages/SiteErrorReport.razor similarity index 100% rename from Wonky.Client/Pages/ErrorReport.razor rename to Wonky.Client/Pages/SiteErrorReport.razor diff --git a/Wonky.Client/Pages/ErrorReport.razor.cs b/Wonky.Client/Pages/SiteErrorReport.razor.cs similarity index 96% rename from Wonky.Client/Pages/ErrorReport.razor.cs rename to Wonky.Client/Pages/SiteErrorReport.razor.cs index 4f84d389..ee6104c5 100644 --- a/Wonky.Client/Pages/ErrorReport.razor.cs +++ b/Wonky.Client/Pages/SiteErrorReport.razor.cs @@ -17,7 +17,7 @@ using Microsoft.AspNetCore.Components; namespace Wonky.Client.Pages { - public partial class ErrorReport + public partial class SiteErrorReport { [Parameter] public int ErrorCode { get; set; } diff --git a/Wonky.Client/Shared/NavMenu.razor b/Wonky.Client/Shared/NavMenu.razor index e461763d..769198d9 100644 --- a/Wonky.Client/Shared/NavMenu.razor +++ b/Wonky.Client/Shared/NavMenu.razor @@ -63,8 +63,8 @@
diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 71707855..b13007ce 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -18,12 +18,12 @@ }, "appInfo": { "name": "Wonky Client", - "version": "0.8.7", + "version": "0.8.10", "isBeta": true, "image": "grumpy-coder.png" }, "apiConfig": { - "baseAddress": "https://staging.innotec.dk", + "baseAddress": "https://dev.innotec.dk", "tokenPath": "token", "userInfo": "api/auth/userinfo", "customerEndpoint": "api/v2/crm/companies", diff --git a/Wonky.Client/wwwroot/css/app.css b/Wonky.Client/wwwroot/css/app.css index c7068748..31605ce2 100644 --- a/Wonky.Client/wwwroot/css/app.css +++ b/Wonky.Client/wwwroot/css/app.css @@ -6,7 +6,9 @@ .spinner { height: 48px; } - +.workDate { + font-variant: small-caps; +} /* visit / vat state classes */ .state { width: 16px; diff --git a/Wonky.Entity/DTO/CompanyDto.cs b/Wonky.Entity/DTO/CompanyDto.cs index 5cc80e47..95c13851 100644 --- a/Wonky.Entity/DTO/CompanyDto.cs +++ b/Wonky.Entity/DTO/CompanyDto.cs @@ -21,34 +21,65 @@ namespace Wonky.Entity.DTO; public class CompanyDto { - [Required(ErrorMessage = "Navn skal udfyldes")] [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] + [Required(ErrorMessage = "Navn skal udfyldes")] + [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string Name { get; set; } - [Required(ErrorMessage = "Postnummer skal udfyldes")] [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] + + [Required(ErrorMessage = "Postnummer skal udfyldes")] + [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string ZipCode { get; set; } - [Required(ErrorMessage = "Bynavn skal udfyldes")] [MaxLength(30, ErrorMessage = "Du kan højst bruge 30 tegn")] + + [Required(ErrorMessage = "Bynavn skal udfyldes")] + [MaxLength(30, ErrorMessage = "Du kan højst bruge 30 tegn")] public string City { get; set; } + [Required(ErrorMessage = "ORG/VAT/CVR er ikke et gyldigt nummer")] public string VatNumber { get; set; } = ""; + public string CompanyId { get; set; } = ""; + public string SalesRepId { get; set; } = ""; + public string BcId { get; set; } = ""; - [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string Address1 { get; set; } = ""; - [MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")] public string Address2 { get; set; } = ""; - [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string Account { get; set; } = ""; - [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string Phone { get; set; } = ""; - [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string Mobile { get; set; } = ""; - [MaxLength(80, ErrorMessage = "Du kan højst bruge 80 tegn")] public string Email { get; set; } = ""; - [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string Attention { get; set; } = ""; + [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] + public string Address1 { get; set; } = ""; + + [MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")] + public string Address2 { get; set; } = ""; + + [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] + public string Account { get; set; } = ""; + + [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] + public string Phone { get; set; } = ""; + + [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] + public string Mobile { get; set; } = ""; + + [MaxLength(80, ErrorMessage = "Du kan højst bruge 80 tegn")] + public string Email { get; set; } = ""; + + [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] + public string Attention { get; set; } = ""; + public string CountryCode { get; set; } = ""; + public string LastVisit { get; set; } = ""; + public string NextVisit { get; set; } = ""; + [Range(1, 52, ErrorMessage = "Angiv interval mellem 1 og 52 uger")] public int Interval { get; set; } = 8; + public int HasFolded { get; set; } + public int IsHidden { get; set; } + public int ValidVat { get; set; } + public int UpdateErpVat { get; set; } - public bool ValidDateSpan() + + public virtual bool ValidDateSpan() { var notAllowed = new List {"1970-01-01", "0001-01-01"}; if (notAllowed.Contains(LastVisit) || notAllowed.Contains(NextVisit)) diff --git a/Wonky.Entity/DTO/ReportDto.cs b/Wonky.Entity/DTO/ReportDto.cs index 26dc56e1..f96a481a 100644 --- a/Wonky.Entity/DTO/ReportDto.cs +++ b/Wonky.Entity/DTO/ReportDto.cs @@ -5,9 +5,16 @@ namespace Wonky.Entity.DTO; public class ReportDto { public string Name { get; set; } = ""; - [MaxLength(1000, ErrorMessage = "Du kan højst bruge 1000 tegn")] public string Description { get; set; } = ""; - [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string SupervisedBy { get; set; } = ""; - [Required(ErrorMessage = "Dagtype skal angives")] public string DayTypeEnum { get; set; } = ""; + + [MaxLength(1000, ErrorMessage = "Du kan højst bruge 1000 tegn")] + public string Description { get; set; } = ""; + + [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] + public string SupervisedBy { get; set; } = ""; + + [Required(ErrorMessage = "Dagtype skal angives")] + public string DayTypeEnum { get; set; } = ""; + // Date interval (used for leave, sickLeave and work hours public string FromDateTime { get; set; } = ""; public string ToDateTime { get; set; } = ""; diff --git a/Wonky.Entity/Requests/ReportPagingParams.cs b/Wonky.Entity/Requests/ReportPagingParams.cs new file mode 100644 index 00000000..14fa749b --- /dev/null +++ b/Wonky.Entity/Requests/ReportPagingParams.cs @@ -0,0 +1,30 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +namespace Wonky.Entity.Requests; + +public class ReportPagingParams +{ + private int _pageSize = 5; + private const int MaxPageSize = 50; + public int PageNumber { get; set; } = 1; + public int PageSize + { + get => _pageSize; + set => _pageSize = (value > MaxPageSize) ? MaxPageSize : value; + } + public string SearchTerm { get; set; } = ""; + public string SearchColumn { get; set; } = "name"; + public string OrderBy { get; set; } = "name"; +} \ No newline at end of file