From eba3a2bdc85f6bcdcd2b239b9c171a831f71070d Mon Sep 17 00:00:00 2001 From: Frede Hundewadt <22748698+fhdk@users.noreply.github.com> Date: Sun, 15 May 2022 18:27:54 +0200 Subject: [PATCH] create activity --- Wonky.Client/Components/AppVersion.razor | 2 +- Wonky.Client/Helpers/VatUtils.cs | 18 +- .../HttpRepository/ActivityHttpRepository.cs | 101 +++ .../HttpRepository/CompanyHttpRepository.cs | 12 +- .../HttpRepository/IActivityHttpRepository.cs | 29 + .../HttpRepository/SalesItemHttpRepository.cs | 4 +- Wonky.Client/Pages/CompanyCreate.razor.cs | 4 +- Wonky.Client/Pages/CompanyUpdate.razor.cs | 16 +- Wonky.Client/Pages/CompanyView.razor.cs | 4 +- Wonky.Client/Pages/CrmActivityCreate.razor | 599 +++++++++--------- Wonky.Client/Pages/CrmActivityCreate.razor.cs | 14 +- Wonky.Entity/Configuration/ApiConfig.cs | 9 +- Wonky.Entity/DTO/ActivityResponse.cs | 27 + Wonky.Entity/DTO/DtoNgActivity.cs | 4 +- Wonky.Entity/Requests/ActivityPagingParams.cs | 30 + 15 files changed, 554 insertions(+), 319 deletions(-) create mode 100644 Wonky.Client/HttpRepository/ActivityHttpRepository.cs create mode 100644 Wonky.Client/HttpRepository/IActivityHttpRepository.cs create mode 100644 Wonky.Entity/DTO/ActivityResponse.cs create mode 100644 Wonky.Entity/Requests/ActivityPagingParams.cs diff --git a/Wonky.Client/Components/AppVersion.razor b/Wonky.Client/Components/AppVersion.razor index 45ec5e89..dd347ab2 100644 --- a/Wonky.Client/Components/AppVersion.razor +++ b/Wonky.Client/Components/AppVersion.razor @@ -17,7 +17,7 @@ @Name @Version@if(IsBeta){-beta} @code { - private const string Version = "0.2.31"; + private const string Version = "0.2.33"; private const string Name = "wwo"; private const bool IsBeta = true; } diff --git a/Wonky.Client/Helpers/VatUtils.cs b/Wonky.Client/Helpers/VatUtils.cs index 7af27c1c..3bab8d26 100644 --- a/Wonky.Client/Helpers/VatUtils.cs +++ b/Wonky.Client/Helpers/VatUtils.cs @@ -1,12 +1,15 @@ namespace Wonky.Client.Helpers; -public static class VatUtils +public class VatUtils { // https://ec.europa.eu/taxation_customs/vies/faqvies.do#item_11 // https://ec.europa.eu/taxation_customs/vies/ - public static bool ValidateFormat(string countryCode, string vatNumber) + public bool ValidateFormat(string countryCode, string vatNumber) { + if (string.IsNullOrWhiteSpace(vatNumber) || string.IsNullOrWhiteSpace(countryCode)) + return false; + return countryCode.ToUpperInvariant() switch { "DK" => ValidateFormatDk(vatNumber), @@ -16,7 +19,7 @@ public static class VatUtils }; } - private static bool ValidateFormatDk(string vatNumber) + private bool ValidateFormatDk(string vatNumber) { // https://wiki.scn.sap.com/wiki/display/CRM/Denmark // 8 digits 0 to 9 @@ -32,7 +35,7 @@ public static class VatUtils return ValidateMod11(vatToCheck); } - private static bool ValidateFormatNo(string vatNumber) + private bool ValidateFormatNo(string vatNumber) { // https://wiki.scn.sap.com/wiki/display/CRM/Norway // 12 digits @@ -45,7 +48,7 @@ public static class VatUtils return long.Parse(vatToCheck) != 0 && ValidateMod11(vatNumber); } - private static bool ValidateFormatSe(string vatNumber) + private bool ValidateFormatSe(string vatNumber) { // https://wiki.scn.sap.com/wiki/display/CRM/Sweden // 12 digits 0 to 9 @@ -70,7 +73,7 @@ public static class VatUtils return $"{vatToCheck[..9]}{c10}01" == vatNumber; } - private static bool ValidateMod11(string number) + private bool ValidateMod11(string number) { if (long.Parse(number) == 0) return false; @@ -84,7 +87,7 @@ public static class VatUtils return sum % 11 == 0; } - private static string SanitizeVatNumber(string vatNumber) + private string SanitizeVatNumber(string vatNumber) { vatNumber = vatNumber.ToUpperInvariant(); return vatNumber @@ -94,6 +97,5 @@ public static class VatUtils .Replace("NO", "") .Replace("SE","") .Replace("MVA", ""); - } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/ActivityHttpRepository.cs b/Wonky.Client/HttpRepository/ActivityHttpRepository.cs new file mode 100644 index 00000000..992e073b --- /dev/null +++ b/Wonky.Client/HttpRepository/ActivityHttpRepository.cs @@ -0,0 +1,101 @@ +// 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 Affero GNU 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 +// Affero GNU General Public License for more details. +// +// You should have received a copy of the Affero GNU General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Net.Http.Json; +using System.Text.Json; +using System.Threading.Tasks; +using Wonky.Client.Features; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.WebUtilities; +using Microsoft.Extensions.Options; +using Wonky.Entity.Configuration; +using Wonky.Entity.DTO; +using Wonky.Entity.Requests; + +namespace Wonky.Client.HttpRepository; + +public class ActivityHttpRepository : IActivityHttpRepository +{ + private readonly JsonSerializerOptions _options = new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }; + + private readonly NavigationManager _navigation; + private ILogger _logger; + private readonly HttpClient _client; + private readonly ApiConfig _apiConfig; + + public ActivityHttpRepository(HttpClient client, + ILogger logger, + NavigationManager navigation, IOptions configuration) + { + _client = client; + _logger = logger; + _navigation = navigation; + _apiConfig = configuration.Value; + } + + public async Task> GetActivityPaged(ActivityPagingParams pagingParameters) + { + var queryString = new Dictionary + { + ["pageNumber"] = pagingParameters.PageNumber.ToString(), + ["pageSize"] = pagingParameters.PageSize.ToString(), + ["orderBy"] = pagingParameters.OrderBy, + ["searchColumn"] = pagingParameters.SearchColumn, + ["searchTerm"] = pagingParameters.SearchTerm, + }; + var response = await _client + .GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.ActivityEndpoint}/page", queryString)); + + var content = await response.Content.ReadAsStringAsync(); + + var pagingResponse = new PagingResponse + { + Items = JsonSerializer.Deserialize>(content, _options), + MetaData = JsonSerializer.Deserialize( + response.Headers.GetValues("X-Pagination").First(), _options) + }; + return pagingResponse; + } + + public async Task CreateActivity(DtoNgActivity model) + { + var response = await _client.PostAsJsonAsync($"{_apiConfig.ActivityEndpoint}", model).ConfigureAwait(true); + var content = await response.Content.ReadAsStringAsync(); + var result = JsonSerializer.Deserialize(content); + return result!; + } + + public async Task GetActivity(string id) + { + var salesItem = await _client + .GetFromJsonAsync($"{_apiConfig.ActivityEndpoint}/{id}").ConfigureAwait(true); + return salesItem ?? new DtoNgActivity(); + } + + public async Task AcceptOffer(string id) + { + var response = await _client.PostAsJsonAsync($"{_apiConfig.ActivityEndpoint}/{id}/accept", id) + .ConfigureAwait(true); + var content = await response.Content.ReadAsStringAsync(); + var result = JsonSerializer.Deserialize(content); + return result!; + } +} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CompanyHttpRepository.cs b/Wonky.Client/HttpRepository/CompanyHttpRepository.cs index d1874c44..5e544306 100644 --- a/Wonky.Client/HttpRepository/CompanyHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CompanyHttpRepository.cs @@ -66,7 +66,7 @@ public class CompanyHttpRepository : ICompanyHttpRepository ["isHidden"] = pagingParameters.IsHidden.ToString(), ["hasFolded"] = pagingParameters.HasFolded.ToString() }; - var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.CrmCompanies}/page", queryString)); + var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.CustomerEndpoint}/page", queryString)); var content = await response.Content.ReadAsStringAsync(); @@ -80,19 +80,19 @@ public class CompanyHttpRepository : ICompanyHttpRepository public async Task GetCompanyByAccount(string accountNumber) { - var company = await _client.GetFromJsonAsync($"{_apiConfig.CrmCompanies}/account/{accountNumber}"); + var company = await _client.GetFromJsonAsync($"{_apiConfig.CustomerEndpoint}/account/{accountNumber}"); return company ?? new DtoNgCompany(); } public async Task GetCompanyById(string companyId) { - var company = await _client.GetFromJsonAsync($"{_apiConfig.CrmCompanies}/{companyId}"); + var company = await _client.GetFromJsonAsync($"{_apiConfig.CustomerEndpoint}/{companyId}"); return company ?? new DtoNgCompany(); } public async Task CreateCompany(DtoNgCompany dtoNgCompany) { - var response = await _client.PostAsJsonAsync($"{_apiConfig.CrmCompanies}", dtoNgCompany); + var response = await _client.PostAsJsonAsync($"{_apiConfig.CustomerEndpoint}", dtoNgCompany); var content = await response.Content.ReadAsStringAsync(); var result = JsonSerializer.Deserialize(content); Console.WriteLine(content); @@ -101,11 +101,11 @@ public class CompanyHttpRepository : ICompanyHttpRepository public async Task UpdateCompany(DtoNgCompany dtoNgCompany) { - await _client.PutAsJsonAsync($"{_apiConfig.CrmCompanies}/{dtoNgCompany.CompanyId}", dtoNgCompany); + await _client.PutAsJsonAsync($"{_apiConfig.CustomerEndpoint}/{dtoNgCompany.CompanyId}", dtoNgCompany); } public async Task DeleteCompany(string companyId) { - await _client.DeleteAsync($"{_apiConfig.CrmCompanies}/{companyId}"); + await _client.DeleteAsync($"{_apiConfig.CustomerEndpoint}/{companyId}"); } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/IActivityHttpRepository.cs b/Wonky.Client/HttpRepository/IActivityHttpRepository.cs new file mode 100644 index 00000000..233423b9 --- /dev/null +++ b/Wonky.Client/HttpRepository/IActivityHttpRepository.cs @@ -0,0 +1,29 @@ +// 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 Affero GNU 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 +// Affero GNU General Public License for more details. +// +// You should have received a copy of the Affero GNU General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using System.Threading.Tasks; +using Wonky.Client.Features; +using Wonky.Entity.DTO; +using Wonky.Entity.Requests; + +namespace Wonky.Client.HttpRepository; + +public interface IActivityHttpRepository +{ + Task> GetActivityPaged(ActivityPagingParams pagingParameters); + Task GetActivity(string id); + Task CreateActivity(DtoNgActivity model); + Task AcceptOffer(string id); +} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/SalesItemHttpRepository.cs b/Wonky.Client/HttpRepository/SalesItemHttpRepository.cs index 48b6e1e1..36394954 100644 --- a/Wonky.Client/HttpRepository/SalesItemHttpRepository.cs +++ b/Wonky.Client/HttpRepository/SalesItemHttpRepository.cs @@ -63,7 +63,7 @@ public class SalesItemHttpRepository : ISalesItemHttpRepository ["selectGroup"] = pagingParameters.SelectGroup == "0" ? "" : pagingParameters.SelectGroup, }; var response = await _client - .GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.PriceCatalog}/page", queryString)); + .GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.CatalogEndpoint}/page", queryString)); var content = await response.Content.ReadAsStringAsync(); @@ -79,7 +79,7 @@ public class SalesItemHttpRepository : ISalesItemHttpRepository public async Task GetSalesItem(string id) { var salesItem = await _client - .GetFromJsonAsync($"{_apiConfig.PriceCatalog}/{id}"); + .GetFromJsonAsync($"{_apiConfig.CatalogEndpoint}/{id}"); return salesItem ?? new NgSalesItemView(); } } \ No newline at end of file diff --git a/Wonky.Client/Pages/CompanyCreate.razor.cs b/Wonky.Client/Pages/CompanyCreate.razor.cs index 62b969ab..d9f991b7 100644 --- a/Wonky.Client/Pages/CompanyCreate.razor.cs +++ b/Wonky.Client/Pages/CompanyCreate.razor.cs @@ -47,10 +47,12 @@ namespace Wonky.Client.Pages private VirkRegInfo _virkRegInfo = new(); private EditContext _createCompany; private bool _formInvalid = true; + private VatUtils _vatUtils { get; set; } private string RegState { get; set; } = ""; protected override async Task OnInitializedAsync() { + _vatUtils = new VatUtils(); _createCompany = new EditContext(_dtoNgCompany); _createCompany.OnFieldChanged += HandleFieldChanged; @@ -108,7 +110,7 @@ namespace Wonky.Client.Pages private void HandleFieldChanged(object sender, FieldChangedEventArgs e) { - if (!VatUtils.ValidateFormat(_dtoNgCompany.CountryCode, _dtoNgCompany.VatNumber)) + if (!_vatUtils.ValidateFormat(_dtoNgCompany.CountryCode, _dtoNgCompany.VatNumber)) { _formInvalid = false; } diff --git a/Wonky.Client/Pages/CompanyUpdate.razor.cs b/Wonky.Client/Pages/CompanyUpdate.razor.cs index a07f9865..cd4fc287 100644 --- a/Wonky.Client/Pages/CompanyUpdate.razor.cs +++ b/Wonky.Client/Pages/CompanyUpdate.razor.cs @@ -15,6 +15,7 @@ using System.Text.Json; using System.Text.Json.Serialization; +using Blazored.LocalStorage; using Blazored.Toast.Services; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpRepository; @@ -37,6 +38,7 @@ public partial class CompanyUpdate : IDisposable [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 DtoNgCompany DtoNgCompany { get; set; } @@ -46,9 +48,11 @@ public partial class CompanyUpdate : IDisposable private DateTime LastVisit { get; set; } private DateTime NextVisit { get; set; } private string _vatState { get; set; } = "the-ugly"; + private VatUtils _vatUtils { get; set; } protected override async Task OnInitializedAsync() { + _vatUtils = new VatUtils(); Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); DtoNgCompany = await CompanyRepo.GetCompanyById(CompanyId); @@ -56,6 +60,12 @@ public partial class CompanyUpdate : IDisposable LastVisit = DateTime.Parse(DtoNgCompany.LastVisit); NextVisit = DateTime.Parse(DtoNgCompany.NextVisit); _updateCompany = new EditContext(DtoNgCompany); + var ux = await StorageService.GetItemAsync("_xu"); + + if (string.IsNullOrWhiteSpace(DtoNgCompany.CountryCode)) + { + DtoNgCompany.CountryCode = ux.CountryCode; + } if(DtoNgCompany.HasFolded == 1) { @@ -63,13 +73,13 @@ public partial class CompanyUpdate : IDisposable } else { - _vatState = VatUtils.ValidateFormat(DtoNgCompany.CountryCode, DtoNgCompany.VatNumber) ? "the-good" : "the-draw"; + _vatState = _vatUtils.ValidateFormat(DtoNgCompany.CountryCode, DtoNgCompany.VatNumber) ? "the-good" : "the-draw"; } } private async Task Update() { - if (!string.IsNullOrWhiteSpace(DtoNgCompany.VatNumber) && !VatUtils.ValidateFormat(DtoNgCompany.CountryCode, DtoNgCompany.VatNumber)) + if (!string.IsNullOrWhiteSpace(DtoNgCompany.VatNumber) && !_vatUtils.ValidateFormat(DtoNgCompany.CountryCode, DtoNgCompany.VatNumber)) { ToastService.ShowError($"CVR/VAT/ORG nummer er ugyldig."); StateHasChanged(); @@ -85,7 +95,7 @@ public partial class CompanyUpdate : IDisposable } private async Task GetInfoFromVat(string vatNumber) { - if (string.IsNullOrWhiteSpace(vatNumber) || !VatUtils.ValidateFormat(DtoNgCompany.CountryCode, DtoNgCompany.VatNumber)) + if (string.IsNullOrWhiteSpace(vatNumber) || !_vatUtils.ValidateFormat(DtoNgCompany.CountryCode, DtoNgCompany.VatNumber)) { ToastService.ShowError($"CVR er ugyldigt eller mangler"); return; diff --git a/Wonky.Client/Pages/CompanyView.razor.cs b/Wonky.Client/Pages/CompanyView.razor.cs index 72db02d2..1d81aed8 100644 --- a/Wonky.Client/Pages/CompanyView.razor.cs +++ b/Wonky.Client/Pages/CompanyView.razor.cs @@ -38,9 +38,11 @@ public partial class CompanyView : IDisposable private DtoNgCompany DtoNgCompany { get; set; } = new (); private string _vatState { get; set; } = "the-dead"; private bool _hasFolded { get; set; } + private VatUtils _vatUtils { get; set; } protected override async Task OnInitializedAsync() { + _vatUtils = new VatUtils(); Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); DtoNgCompany = await CompanyRepo.GetCompanyById(CompanyId); @@ -51,7 +53,7 @@ public partial class CompanyView : IDisposable } else { - _vatState = VatUtils.ValidateFormat(DtoNgCompany.CountryCode, DtoNgCompany.VatNumber) ? "the-good" : "the-draw"; + _vatState = _vatUtils.ValidateFormat(DtoNgCompany.CountryCode, DtoNgCompany.VatNumber) ? "the-good" : "the-draw"; } } diff --git a/Wonky.Client/Pages/CrmActivityCreate.razor b/Wonky.Client/Pages/CrmActivityCreate.razor index c642e5d0..27170c5a 100644 --- a/Wonky.Client/Pages/CrmActivityCreate.razor +++ b/Wonky.Client/Pages/CrmActivityCreate.razor @@ -24,329 +24,354 @@

@_poDraft.Name

- -
-
-

- -

-
-
-
- -
- - -
- -
- - -
+ +
+
+

+ +

+
+
+
+ +
+ +
- -
- -
- -
- -
- -
+ +
+ +
-
- -
- -
- -
- -
+
+ +
+ +
+
-
- -
- -
+ +
+
-
- -
- - -
+
+ +
+ +
+ +
-
- -
- - -
+ +
+ +
-
- -
- - -
+
+
+ +
+
-
- -
- -
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ +
- - -
-

- -

-
-
-
-
- -
-
- -
-
- -
-
+
+ + @* Leverings adresse *@ +
+

+ +

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ + @* Ordder 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 +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
- @if (SalesItems.Any()) - { + } + @* Ordrekladde *@ +
+
+ Kladdelinjer Global kladde (udløber efter @(DraftStateProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet) +
+
- + + + + - @foreach (var item in SalesItems) + @if (DraftStateProvider != null && DraftStateProvider.Draft.Items.Count > 0) { + @foreach (var cItem in DraftStateProvider.Draft.Items) + { + + + + + + + + + + } - - - + + + + + + }
Navn VarenrStk / PrisAntalEnhedsprisLinjesum 
@cItem.Item.Name@cItem.Item.Sku@cItem.Quantity@cItem.Price@cItem.LineTotal + + + +
@item.Name@item.Sku -
    - @foreach (var rate in item.Rates) - { -
  • -
    @rate.Quantity
    -
    @rate.Rate
    - -
  • - } -
-
Total@DraftStateProvider.Draft.Total
- } - else - { - - } - @if (_selectedItem != null && ShowItem) - { -
-
Kladdelinje
-
-
-
- Varenavn -
-
- Varenr -
-
- Antal -
-
- Pris -
-
- Rabat -
-
- SAS -
-
- -
-
-
-
- @_selectedItem.Name -
-
- @_selectedItem.Sku -
-
- -
-
- -
-
- -
-
- -
-
- -
-
+
+ -
-
- - - @* Leverings adresse *@ -
-

- -

-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
+
-
-
- Tilbage -
-
- @* *@ - -
+
+ +
+ @* *@ + +
+
} \ No newline at end of file diff --git a/Wonky.Client/Pages/CrmActivityCreate.razor.cs b/Wonky.Client/Pages/CrmActivityCreate.razor.cs index 0ba110cb..7f93e683 100644 --- a/Wonky.Client/Pages/CrmActivityCreate.razor.cs +++ b/Wonky.Client/Pages/CrmActivityCreate.razor.cs @@ -43,7 +43,7 @@ public partial class CrmActivityCreate : IDisposable private List SalesItems { get; set; } = new(); // private MetaData _meta { get; set; } = new(); private Preferences _prefs { get; set; } = new(); - private DtoNgSalesRepActivity _poDraft { get; set; } = new(); + private DtoNgActivity _poDraft { get; set; } = new(); private DtoNgCompany NgCompany = new(); private CatalogPagingParams _paging = new(); private EditContext DraftContext { get; set; } @@ -60,6 +60,7 @@ public partial class CrmActivityCreate : IDisposable private bool InvalidCanvas { get; set; } = true; private bool InvalidDate { get; set; } = true; private UserInfoView Ux { get; set; } = new(); + private VatUtils _vatUtils { get; set; } protected override void OnParametersSet() { @@ -68,6 +69,7 @@ public partial class CrmActivityCreate : IDisposable protected override async Task OnInitializedAsync() { + _vatUtils = new VatUtils(); Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); _prefs = await UserPrefs.GetPreferences(); @@ -100,7 +102,7 @@ public partial class CrmActivityCreate : IDisposable _poDraft.City = NgCompany.City; _poDraft.DlvName = NgCompany.Name; - _poDraft.DlvAddress1 = NgCompany.Address1; + _poDraft.DlvAddress = NgCompany.Address1; _poDraft.DlvAddress2 = NgCompany.Address2; _poDraft.DlvZipCode = NgCompany.ZipCode; _poDraft.DlvCity = NgCompany.City; @@ -232,14 +234,18 @@ public partial class CrmActivityCreate : IDisposable { _poFormInvalid = !DraftContext.Validate(); InvalidCanvas = InvalidActivityType || InvalidDate; - InvalidActivity = InvalidActivityType || _poFormInvalid || DraftStateProvider.Draft.Items.Count == 0 || InvalidDate; + InvalidActivity = InvalidActivityType + || _poFormInvalid + || DraftStateProvider.Draft.Items.Count == 0 + || InvalidDate + || (_poDraft.ActivityStatusEnum == "offer" && string.IsNullOrWhiteSpace(_poDraft.EMail)); StateHasChanged(); } private void ValidationChanged(object sender, ValidationStateChangedEventArgs e) { if (!string.IsNullOrEmpty(_poDraft.VatNumber)) { - if(!VatUtils.ValidateFormat(NgCompany.CountryCode, _poDraft.VatNumber)) + if(!_vatUtils.ValidateFormat(NgCompany.CountryCode, _poDraft.VatNumber)) ToastService.ShowWarning("CVR / ORG nummer er ikke et gyldigt registreringsnummer"); } if (string.IsNullOrEmpty(_poDraft.ActivityTypeEnum)) diff --git a/Wonky.Entity/Configuration/ApiConfig.cs b/Wonky.Entity/Configuration/ApiConfig.cs index 6d3a8f91..f30c79dc 100644 --- a/Wonky.Entity/Configuration/ApiConfig.cs +++ b/Wonky.Entity/Configuration/ApiConfig.cs @@ -17,10 +17,10 @@ namespace Wonky.Entity.Configuration; public class ApiConfig { public string BaseAddress { get; set; } = ""; - public string CrmCompanies { get; set; } = ""; - public string PriceCatalog { get; set; } = ""; - public string KrvVariants { get; set; } = ""; - public string KrvProducts { get; set; } = ""; + public string CustomerEndpoint { get; set; } = ""; + public string CatalogEndpoint { get; set; } = ""; + public string KrvVariantEndpoint { get; set; } = ""; + public string KrvProductEndpoint { get; set; } = ""; public string ImageUpload { get; set; } = ""; public string UserRegistration { get; set; } = ""; public string UserInfo { get; set; } = ""; @@ -28,4 +28,5 @@ public class ApiConfig public string TokenPath { get; set; } = ""; public string GlsTrackUrl { get; set; } = ""; public string GlsId { get; set; } = ""; + public string ActivityEndpoint { get; set; } = ""; } \ No newline at end of file diff --git a/Wonky.Entity/DTO/ActivityResponse.cs b/Wonky.Entity/DTO/ActivityResponse.cs new file mode 100644 index 00000000..6550e82c --- /dev/null +++ b/Wonky.Entity/DTO/ActivityResponse.cs @@ -0,0 +1,27 @@ +// 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 Affero GNU 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 +// Affero GNU General Public License for more details. +// +// You should have received a copy of the Affero GNU General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using System.Collections.Generic; +using System.Net; + +namespace Wonky.Entity.DTO; + +public class ActivityResponseView +{ + public bool IsSuccessStatusCode { get; set; } + public HttpStatusCode Code { get; set; } + public string Message { get; set; } = ""; + public string Id { get; set; } = ""; +} \ No newline at end of file diff --git a/Wonky.Entity/DTO/DtoNgActivity.cs b/Wonky.Entity/DTO/DtoNgActivity.cs index 713b8a27..68a9b817 100644 --- a/Wonky.Entity/DTO/DtoNgActivity.cs +++ b/Wonky.Entity/DTO/DtoNgActivity.cs @@ -17,7 +17,7 @@ using System.ComponentModel.DataAnnotations; namespace Wonky.Entity.DTO { - public class DtoNgSalesRepActivity + public class DtoNgActivity { public string SalesHeadId { get; set; } = ""; public string CompanyId { get; set; } = ""; @@ -45,7 +45,7 @@ namespace Wonky.Entity.DTO [MaxLength(255, ErrorMessage = "Du kan højst bruge 255 tegn")] public string CrmNote { get; set; } = ""; // Delivery address form entries [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string DlvName { get; set; } = ""; - [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string DlvAddress1 { get; set; } = ""; + [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string DlvAddress { get; set; } = ""; [MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")] public string DlvAddress2 { get; set; } = ""; [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string DlvZipCode { get; set; } = ""; [MaxLength(30, ErrorMessage = "Du kan højst bruge 30 tegn")] public string DlvCity { get; set; } = ""; diff --git a/Wonky.Entity/Requests/ActivityPagingParams.cs b/Wonky.Entity/Requests/ActivityPagingParams.cs new file mode 100644 index 00000000..02798f85 --- /dev/null +++ b/Wonky.Entity/Requests/ActivityPagingParams.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 Affero GNU 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 +// Affero GNU General Public License for more details. +// +// You should have received a copy of the Affero GNU 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 ActivityPagingParams +{ + 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