diff --git a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor index bfc296c5..b77d6ce4 100644 --- a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor +++ b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor @@ -61,7 +61,7 @@
- @* Bestilling *@ + Bestilling
diff --git a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs index a3df3331..122c2dcf 100644 --- a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs +++ b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs @@ -76,7 +76,7 @@ namespace Wonky.Client.Components // check for console manipulation if (!Utils.Validate(VType.Id, companyId)) return; SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); - ActivityList = await ActivityRepo.RequestActitivityList(companyId); + ActivityList = await ActivityRepo.RequestActivityList(companyId); ActivityListOverlay.Show(); } diff --git a/Wonky.Client/Helpers/CustomerValidator.cs b/Wonky.Client/Helpers/CustomerValidator.cs new file mode 100644 index 00000000..fe4e6eee --- /dev/null +++ b/Wonky.Client/Helpers/CustomerValidator.cs @@ -0,0 +1,21 @@ +using Wonky.Entity.DTO; + +namespace Wonky.Client.Helpers; + +internal interface IValidator +{ + bool Validate(T t); +} + +public class CustomerValidator : IValidator +{ + public bool Validate(CompanyDto t) + { + if (string.IsNullOrWhiteSpace(t.Name) + || string.IsNullOrWhiteSpace(t.ZipCode) + || string.IsNullOrWhiteSpace(t.City) + || string.IsNullOrWhiteSpace(t.CountryCode)) return false; + + return string.IsNullOrWhiteSpace(t.VatNumber) || VatUtils.ValidateFormat(t.CountryCode, t.VatNumber); + } +} diff --git a/Wonky.Client/HttpInterfaces/ICountryActivityRepository.cs b/Wonky.Client/HttpInterfaces/ICountryActivityRepository.cs index 3361b764..e66cc945 100644 --- a/Wonky.Client/HttpInterfaces/ICountryActivityRepository.cs +++ b/Wonky.Client/HttpInterfaces/ICountryActivityRepository.cs @@ -36,5 +36,5 @@ public interface ICountryActivityRepository /// /// /// - Task> RequestActitivityList(string customerId); + Task> RequestActivityList(string customerId); } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CountryActivityRepository.cs b/Wonky.Client/HttpRepository/CountryActivityRepository.cs index 1442f3fd..f7a3a922 100644 --- a/Wonky.Client/HttpRepository/CountryActivityRepository.cs +++ b/Wonky.Client/HttpRepository/CountryActivityRepository.cs @@ -67,7 +67,7 @@ public class CountryActivityRepository : ICountryActivityRepository /// /// /// - public async Task> RequestActitivityList(string customerId) + public async Task> RequestActivityList(string customerId) { var response = await _client.GetAsync($"{_api.CrmActivities}/company/{customerId}"); var content = await response.Content.ReadAsStringAsync(); diff --git a/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs b/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs index 90119069..89df3651 100644 --- a/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs +++ b/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs @@ -321,6 +321,7 @@ public partial class AdvisorActivityCreatePage : IDisposable private async Task WorkDateConfirmCallback() { await ProfileService.SetDateConfirmed(true); + Activity.ActivityDate = $"{SelectedDate:yyyy-MM-dd}"; ConfirmWorkDate.Hide(); StateHasChanged(); } diff --git a/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor b/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor index 88303dd6..26b57d8b 100644 --- a/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor +++ b/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor @@ -26,6 +26,8 @@ +
@* vat lookup *@ @@ -124,11 +126,11 @@
- +
- +
@@ -145,11 +147,5 @@ @if (Working) { - -} - - - - - \ No newline at end of file + +} \ No newline at end of file diff --git a/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor.cs index c39c04f8..d6fab633 100644 --- a/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor.cs @@ -14,10 +14,12 @@ // using System.Text.Json; +using System.Xml; using Blazored.LocalStorage; using Blazored.Toast.Services; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; +using Wonky.Client.Helpers; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpInterfaces; using Wonky.Client.Models; @@ -43,8 +45,6 @@ namespace Wonky.Client.Pages private EditContext CompanyContext { get; set; } private CompanyDto Company { get; set; } = new(); - private VirkRegInfo CompanyRegInfo { get; set; } = new(); - private List VatInfos { get; set; } = new(); private VatAddress CompanyVatAddress { get; set; } = new(); private VatLookupDkModal VatLookupPopup { get; set; } = new(); @@ -62,11 +62,11 @@ namespace Wonky.Client.Pages CompanyContext.OnFieldChanged += HandleFieldChanged; CompanyContext.OnValidationStateChanged += ValidationChanged; - var ux = await Storage.GetItemAsync("_xu"); - Dk = ux.CountryCode.ToLower() == "dk"; + var xu = await Storage.GetItemAsync("_xu"); + Dk = xu.CountryCode.ToLower() == "dk"; - Company.SalesRepId = ux.Id; - Company.CountryCode = ux.CountryCode.ToLower(); + Company.SalesRepId = xu.Id; + Company.CountryCode = xu.CountryCode.ToLower(); LastVisit = DateTime.Now; NextVisit = DateTime.Now.AddDays(Company.Interval * 7); @@ -105,6 +105,8 @@ namespace Wonky.Client.Pages } Company.VatNumber = regInfo.VatNumber; + Company.ValidVat = 1; + FormInvalid = false; } private async Task SubmitCompanyForm() @@ -115,7 +117,7 @@ namespace Wonky.Client.Pages Company.NextVisit = $"{NextVisit:yyyy-MM-dd}"; var newId = await CompanyRepo.CreateCompany(Company); - + if (!string.IsNullOrWhiteSpace(newId)) { Toaster.ShowSuccess($"'{Company.Name}' er oprettet i CRM."); @@ -123,7 +125,7 @@ namespace Wonky.Client.Pages } else { - Toaster.ShowWarning($"'{Company.Name}' IKKE oprettet."); + Toaster.ShowWarning($"'{Company.Name}' IKKE oprettet."); FormInvalid = false; } @@ -133,7 +135,22 @@ namespace Wonky.Client.Pages private void HandleFieldChanged(object sender, FieldChangedEventArgs e) { NextVisit = LastVisit.AddDays(7 * Company.Interval); - + // invalid vat number id not accepted by the ERP system + // but is removed without warning + // it is necessary to validate if vat number has been added + // as the format should conform to country rule of generation + if (!string.IsNullOrWhiteSpace(Company.VatNumber)) + { + // validate vat number according to country + if (!VatUtils.ValidateFormat(Company.CountryCode, Company.VatNumber)) + { + Toaster.ShowError("Momsnummber er ikke korrekt."); + FormInvalid = true; + Company.ValidVat = 0; + RegState = "the-ugly"; + } + } + if (!Company.ValidDateSpan()) { Toaster.ShowError("Dato for næste besøg skal ligge efter sidste besøg."); diff --git a/Wonky.Client/Pages/OfficeOrderCreatePage.razor b/Wonky.Client/Pages/OfficeOrderCreatePage.razor index cf41ecc3..869e41e1 100644 --- a/Wonky.Client/Pages/OfficeOrderCreatePage.razor +++ b/Wonky.Client/Pages/OfficeOrderCreatePage.razor @@ -24,8 +24,8 @@ Telefon Ordre - @Customer.Name - @Customer.Account
-
- +
+ @DateTime.Now.ToLongDateString()
@@ -61,15 +61,11 @@
-
-
-
-
diff --git a/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs b/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs index 3acc69c1..03119474 100644 --- a/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs +++ b/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs @@ -77,53 +77,53 @@ public partial class OfficeOrderCreatePage : IDisposable // fetch customer Customer = await CustomerRepo.GetByCustomerId(CountryCode, CompanyId); Logger.LogDebug("Customer => {}", JsonSerializer.Serialize(Customer)); - // - // var today = $"{DateTime.Now:yyyy-MM-dd}"; - // - // // initiate a sync to ensure up-to-date product history - // if (Customer.HistorySync != today) - // Customer.HistorySync = await InventoryRepo.InvoiceErpToCrmRpc(CountryCode, CompanyId, Customer.HistorySync); - // - // // fetch customer inventory - // CustomerInventory = await InventoryRepo.FetchInventory(CountryCode, CompanyId); - // Logger.LogDebug("Inventory => {}", JsonSerializer.Serialize(CustomerInventory)); - // - // // get sales rep info - // SalesRep = await UserRepo.GetAdvisorInfo(Customer.SalesRepId); - // Logger.LogDebug("SalesRep => {}", JsonSerializer.Serialize(SalesRep)); - // - // // set activity salesRep and countryCode - // Activity.SalesRep = SalesRep.Advisor; - // Activity.CountryCode = SalesRep.CountryCode; - // - // // add customer info into activity properties - // Activity.Account = Customer.Account; - // Activity.VatNumber = Customer.VatNumber; - // Activity.Email = Customer.Email; - // Activity.Phone = Customer.Phone; - // Activity.Mobile = Customer.Mobile; - // Activity.Name = Customer.Name; - // Activity.Address1 = Customer.Address1; - // Activity.Address2 = Customer.Address2; - // Activity.ZipCode = Customer.ZipCode; - // Activity.City = Customer.City; - // Activity.DlvName = Customer.Name; - // Activity.DlvAddress1 = Customer.Address1; - // Activity.DlvAddress2 = Customer.Address2; - // Activity.DlvZipCode = Customer.ZipCode; - // Activity.DlvCity = Customer.City; - // Activity.BcId = Customer.BcId; - // Activity.CompanyId = Customer.CompanyId; - // Activity.SalesRepId = Customer.SalesRepId; - // - // // setting up activity properties - // Activity.ActivityStatusEnum = "noSale"; - // Activity.VisitTypeEnum = "recall"; - // Activity.ActivityTypeEnum = "phone"; - // Activity.ActivityStatusEnum = "order"; - // - // // Initialize date variable - // SelectedDate = DateTime.Now; + + var today = $"{DateTime.Now:yyyy-MM-dd}"; + + // initiate a sync to ensure up-to-date product history + if (Customer.HistorySync != today) + Customer.HistorySync = await InventoryRepo.RequestErpToCrmSync(CountryCode, CompanyId, Customer.HistorySync); + + // fetch customer inventory + CustomerInventory = await InventoryRepo.RequestInventory(CountryCode, CompanyId); + Logger.LogDebug("Inventory => {}", JsonSerializer.Serialize(CustomerInventory)); + + // get sales rep info + SalesRep = await UserRepo.GetAdvisorInfo(Customer.SalesRepId); + Logger.LogDebug("SalesRep => {}", JsonSerializer.Serialize(SalesRep)); + + // set activity salesRep and countryCode + Activity.SalesRep = SalesRep.Advisor; + Activity.CountryCode = SalesRep.CountryCode; + + // add customer info into activity properties + Activity.Account = Customer.Account; + Activity.VatNumber = Customer.VatNumber; + Activity.Email = Customer.Email; + Activity.Phone = Customer.Phone; + Activity.Mobile = Customer.Mobile; + Activity.Name = Customer.Name; + Activity.Address1 = Customer.Address1; + Activity.Address2 = Customer.Address2; + Activity.ZipCode = Customer.ZipCode; + Activity.City = Customer.City; + Activity.DlvName = Customer.Name; + Activity.DlvAddress1 = Customer.Address1; + Activity.DlvAddress2 = Customer.Address2; + Activity.DlvZipCode = Customer.ZipCode; + Activity.DlvCity = Customer.City; + Activity.BcId = Customer.BcId; + Activity.CompanyId = Customer.CompanyId; + Activity.SalesRepId = Customer.SalesRepId; + + // setting up activity properties + Activity.ActivityStatusEnum = "noSale"; + Activity.VisitTypeEnum = "recall"; + Activity.ActivityTypeEnum = "phone"; + Activity.ActivityStatusEnum = "order"; + + // Initialize date variable + SelectedDate = DateTime.Now; } private void CallPriceListModal() diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 7dad6bb7..b1d8cc89 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { "appInfo": { "name": "Wonky Online", - "version": "0.116.2", + "version": "0.117.0", "rc": true, "sandBox": false, "image": "grumpy-coder.png"