WIP: office create order - minor cosmetics

This commit is contained in:
Frede Hundewadt 2023-02-21 07:38:34 +01:00
parent e4a4ea62f6
commit 308876896f
11 changed files with 108 additions and 77 deletions

View file

@ -61,7 +61,7 @@
<button class="btn btn-success" @onclick="() => ShowInventory(company.CompanyId)">Produkt</button> <button class="btn btn-success" @onclick="() => ShowInventory(company.CompanyId)">Produkt</button>
</div> </div>
<div class="col"> <div class="col">
@* <a class="btn btn-primary" href="/office/customers/@company.CountryCode.ToLower()/@company.CompanyId/order" >Bestilling</a> *@ <a class="btn btn-primary" href="/office/customers/@company.CountryCode.ToLower()/@company.CompanyId/order" >Bestilling</a>
</div> </div>
</div> </div>
</div> </div>

View file

@ -76,7 +76,7 @@ namespace Wonky.Client.Components
// check for console manipulation // check for console manipulation
if (!Utils.Validate(VType.Id, companyId)) return; if (!Utils.Validate(VType.Id, companyId)) return;
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
ActivityList = await ActivityRepo.RequestActitivityList(companyId); ActivityList = await ActivityRepo.RequestActivityList(companyId);
ActivityListOverlay.Show(); ActivityListOverlay.Show();
} }

View file

@ -0,0 +1,21 @@
using Wonky.Entity.DTO;
namespace Wonky.Client.Helpers;
internal interface IValidator<in T>
{
bool Validate(T t);
}
public class CustomerValidator : IValidator<CompanyDto>
{
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);
}
}

View file

@ -36,5 +36,5 @@ public interface ICountryActivityRepository
/// </summary> /// </summary>
/// <param name="customerId"></param> /// <param name="customerId"></param>
/// <returns></returns> /// <returns></returns>
Task<List<ReportItemView>> RequestActitivityList(string customerId); Task<List<ReportItemView>> RequestActivityList(string customerId);
} }

View file

@ -67,7 +67,7 @@ public class CountryActivityRepository : ICountryActivityRepository
/// </summary> /// </summary>
/// <param name="customerId"></param> /// <param name="customerId"></param>
/// <returns></returns> /// <returns></returns>
public async Task<List<ReportItemView>> RequestActitivityList(string customerId) public async Task<List<ReportItemView>> RequestActivityList(string customerId)
{ {
var response = await _client.GetAsync($"{_api.CrmActivities}/company/{customerId}"); var response = await _client.GetAsync($"{_api.CrmActivities}/company/{customerId}");
var content = await response.Content.ReadAsStringAsync(); var content = await response.Content.ReadAsStringAsync();

View file

@ -321,6 +321,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
private async Task WorkDateConfirmCallback() private async Task WorkDateConfirmCallback()
{ {
await ProfileService.SetDateConfirmed(true); await ProfileService.SetDateConfirmed(true);
Activity.ActivityDate = $"{SelectedDate:yyyy-MM-dd}";
ConfirmWorkDate.Hide(); ConfirmWorkDate.Hide();
StateHasChanged(); StateHasChanged();
} }

View file

@ -26,6 +26,8 @@
<EditForm EditContext="CompanyContext" OnValidSubmit="SubmitCompanyForm"> <EditForm EditContext="CompanyContext" OnValidSubmit="SubmitCompanyForm">
<DataAnnotationsValidator/> <DataAnnotationsValidator/>
<InputText type="hidden" id="salesRepId" @bind-Value="Company.SalesRepId"/> <InputText type="hidden" id="salesRepId" @bind-Value="Company.SalesRepId"/>
<VatLookupDkModal VatAddress="CompanyVatAddress" EntityName="@Company.Name" VatNumber="@Company.VatNumber"
@ref="VatLookupPopup" OnSelectedCompany="SelectCompanyCallback"/>
<div class="row g-2"> <div class="row g-2">
@* vat lookup *@ @* vat lookup *@
@ -124,11 +126,11 @@
</div> </div>
<label for="nextVisit" class="col-sm-1 col-form-label-sm">Næste besøg</label> <label for="nextVisit" class="col-sm-1 col-form-label-sm">Næste besøg</label>
<div class="col-sm-3"> <div class="col-sm-3">
<InputDate id="nextVisit" class="form-control" @bind-Value="@(NextVisit)" /> <InputDate id="nextVisit" class="form-control" @bind-Value="@(NextVisit)"/>
</div> </div>
<label for="lastVisit" class="col-sm-1 col-form-label-sm">Sidste besøg</label> <label for="lastVisit" class="col-sm-1 col-form-label-sm">Sidste besøg</label>
<div class="col-sm-3"> <div class="col-sm-3">
<InputDate id="lastVisit" class="form-control" @bind-Value="@LastVisit"/> <InputDate id="lastVisit" class="form-control" @bind-Value="@LastVisit"/>
</div> </div>
<label for="interval" class="col-sm-1 col-form-label-sm">Uge interval</label> <label for="interval" class="col-sm-1 col-form-label-sm">Uge interval</label>
<div class="col-sm-3"> <div class="col-sm-3">
@ -145,11 +147,5 @@
@if (Working) @if (Working)
{ {
<WorkingThreeDots /> <WorkingThreeDots/>
} }
<VatLookupDkModal VatAddress="CompanyVatAddress" EntityName="@Company.Name" VatNumber="@Company.VatNumber"
@ref="VatLookupPopup" OnSelectedCompany="SelectCompanyCallback"/>

View file

@ -14,10 +14,12 @@
// //
using System.Text.Json; using System.Text.Json;
using System.Xml;
using Blazored.LocalStorage; using Blazored.LocalStorage;
using Blazored.Toast.Services; using Blazored.Toast.Services;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms; using Microsoft.AspNetCore.Components.Forms;
using Wonky.Client.Helpers;
using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpInterfaces; using Wonky.Client.HttpInterfaces;
using Wonky.Client.Models; using Wonky.Client.Models;
@ -43,8 +45,6 @@ namespace Wonky.Client.Pages
private EditContext CompanyContext { get; set; } private EditContext CompanyContext { get; set; }
private CompanyDto Company { get; set; } = new(); private CompanyDto Company { get; set; } = new();
private VirkRegInfo CompanyRegInfo { get; set; } = new();
private List<VirkRegInfo> VatInfos { get; set; } = new();
private VatAddress CompanyVatAddress { get; set; } = new(); private VatAddress CompanyVatAddress { get; set; } = new();
private VatLookupDkModal VatLookupPopup { get; set; } = new(); private VatLookupDkModal VatLookupPopup { get; set; } = new();
@ -62,11 +62,11 @@ namespace Wonky.Client.Pages
CompanyContext.OnFieldChanged += HandleFieldChanged; CompanyContext.OnFieldChanged += HandleFieldChanged;
CompanyContext.OnValidationStateChanged += ValidationChanged; CompanyContext.OnValidationStateChanged += ValidationChanged;
var ux = await Storage.GetItemAsync<UserInfoView>("_xu"); var xu = await Storage.GetItemAsync<UserInfoView>("_xu");
Dk = ux.CountryCode.ToLower() == "dk"; Dk = xu.CountryCode.ToLower() == "dk";
Company.SalesRepId = ux.Id; Company.SalesRepId = xu.Id;
Company.CountryCode = ux.CountryCode.ToLower(); Company.CountryCode = xu.CountryCode.ToLower();
LastVisit = DateTime.Now; LastVisit = DateTime.Now;
NextVisit = DateTime.Now.AddDays(Company.Interval * 7); NextVisit = DateTime.Now.AddDays(Company.Interval * 7);
@ -105,6 +105,8 @@ namespace Wonky.Client.Pages
} }
Company.VatNumber = regInfo.VatNumber; Company.VatNumber = regInfo.VatNumber;
Company.ValidVat = 1;
FormInvalid = false;
} }
private async Task SubmitCompanyForm() private async Task SubmitCompanyForm()
@ -115,7 +117,7 @@ namespace Wonky.Client.Pages
Company.NextVisit = $"{NextVisit:yyyy-MM-dd}"; Company.NextVisit = $"{NextVisit:yyyy-MM-dd}";
var newId = await CompanyRepo.CreateCompany(Company); var newId = await CompanyRepo.CreateCompany(Company);
if (!string.IsNullOrWhiteSpace(newId)) if (!string.IsNullOrWhiteSpace(newId))
{ {
Toaster.ShowSuccess($"'{Company.Name}' er oprettet i CRM."); Toaster.ShowSuccess($"'{Company.Name}' er oprettet i CRM.");
@ -123,7 +125,7 @@ namespace Wonky.Client.Pages
} }
else else
{ {
Toaster.ShowWarning($"'{Company.Name}' IKKE oprettet."); Toaster.ShowWarning($"'{Company.Name}' IKKE oprettet.");
FormInvalid = false; FormInvalid = false;
} }
@ -133,7 +135,22 @@ namespace Wonky.Client.Pages
private void HandleFieldChanged(object sender, FieldChangedEventArgs e) private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
{ {
NextVisit = LastVisit.AddDays(7 * Company.Interval); 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()) if (!Company.ValidDateSpan())
{ {
Toaster.ShowError("Dato for næste besøg skal ligge efter sidste besøg."); Toaster.ShowError("Dato for næste besøg skal ligge efter sidste besøg.");

View file

@ -24,8 +24,8 @@
<PageTitle>Telefon Ordre - @Customer.Name - @Customer.Account</PageTitle> <PageTitle>Telefon Ordre - @Customer.Name - @Customer.Account</PageTitle>
<div class="row bg-dark text-white rounded-2 mb-2 py-2 align-items-center"> <div class="row bg-dark text-white rounded-2 mb-2 py-2 align-items-center">
<div class="col"> <div class="col text-center">
<WorkDateComponent OnChangedCallback="@WorkDateComponentCallback"/> @DateTime.Now.ToLongDateString()
</div> </div>
</div> </div>
@ -61,15 +61,11 @@
<div class="col-sm-10 col-md-4"> <div class="col-sm-10 col-md-4">
<InputText id="phone" class="form-control" @bind-Value="Activity.Phone"/> <InputText id="phone" class="form-control" @bind-Value="Activity.Phone"/>
<ValidationMessage For="@(() => Activity.Phone)"></ValidationMessage> <ValidationMessage For="@(() => Activity.Phone)"></ValidationMessage>
</div>
<div class="col-sm-2 col-md-2"></div>
<div class="col-sm-10 col-md-10">
<div class="form-check"> <div class="form-check">
<InputCheckbox id="express" class="form-check-input" @bind-Value="@Activity.Express"/> <InputCheckbox id="express" class="form-check-input" @bind-Value="@Activity.Express"/>
<label class="form-check-label" for="express">Express</label> <label class="form-check-label" for="express">Express</label>
</div> </div>
</div> </div>
</div> </div>
<div id="this-draft" style="@(Activity.ActivityStatusEnum is "order" or "quote" ? "display: block" : "display:none")"> <div id="this-draft" style="@(Activity.ActivityStatusEnum is "order" or "quote" ? "display: block" : "display:none")">

View file

@ -77,53 +77,53 @@ public partial class OfficeOrderCreatePage : IDisposable
// fetch customer // fetch customer
Customer = await CustomerRepo.GetByCustomerId(CountryCode, CompanyId); Customer = await CustomerRepo.GetByCustomerId(CountryCode, CompanyId);
Logger.LogDebug("Customer => {}", JsonSerializer.Serialize(Customer)); Logger.LogDebug("Customer => {}", JsonSerializer.Serialize(Customer));
//
// var today = $"{DateTime.Now:yyyy-MM-dd}"; var today = $"{DateTime.Now:yyyy-MM-dd}";
//
// // initiate a sync to ensure up-to-date product history // initiate a sync to ensure up-to-date product history
// if (Customer.HistorySync != today) if (Customer.HistorySync != today)
// Customer.HistorySync = await InventoryRepo.InvoiceErpToCrmRpc(CountryCode, CompanyId, Customer.HistorySync); Customer.HistorySync = await InventoryRepo.RequestErpToCrmSync(CountryCode, CompanyId, Customer.HistorySync);
//
// // fetch customer inventory // fetch customer inventory
// CustomerInventory = await InventoryRepo.FetchInventory(CountryCode, CompanyId); CustomerInventory = await InventoryRepo.RequestInventory(CountryCode, CompanyId);
// Logger.LogDebug("Inventory => {}", JsonSerializer.Serialize(CustomerInventory)); Logger.LogDebug("Inventory => {}", JsonSerializer.Serialize(CustomerInventory));
//
// // get sales rep info // get sales rep info
// SalesRep = await UserRepo.GetAdvisorInfo(Customer.SalesRepId); SalesRep = await UserRepo.GetAdvisorInfo(Customer.SalesRepId);
// Logger.LogDebug("SalesRep => {}", JsonSerializer.Serialize(SalesRep)); Logger.LogDebug("SalesRep => {}", JsonSerializer.Serialize(SalesRep));
//
// // set activity salesRep and countryCode // set activity salesRep and countryCode
// Activity.SalesRep = SalesRep.Advisor; Activity.SalesRep = SalesRep.Advisor;
// Activity.CountryCode = SalesRep.CountryCode; Activity.CountryCode = SalesRep.CountryCode;
//
// // add customer info into activity properties // add customer info into activity properties
// Activity.Account = Customer.Account; Activity.Account = Customer.Account;
// Activity.VatNumber = Customer.VatNumber; Activity.VatNumber = Customer.VatNumber;
// Activity.Email = Customer.Email; Activity.Email = Customer.Email;
// Activity.Phone = Customer.Phone; Activity.Phone = Customer.Phone;
// Activity.Mobile = Customer.Mobile; Activity.Mobile = Customer.Mobile;
// Activity.Name = Customer.Name; Activity.Name = Customer.Name;
// Activity.Address1 = Customer.Address1; Activity.Address1 = Customer.Address1;
// Activity.Address2 = Customer.Address2; Activity.Address2 = Customer.Address2;
// Activity.ZipCode = Customer.ZipCode; Activity.ZipCode = Customer.ZipCode;
// Activity.City = Customer.City; Activity.City = Customer.City;
// Activity.DlvName = Customer.Name; Activity.DlvName = Customer.Name;
// Activity.DlvAddress1 = Customer.Address1; Activity.DlvAddress1 = Customer.Address1;
// Activity.DlvAddress2 = Customer.Address2; Activity.DlvAddress2 = Customer.Address2;
// Activity.DlvZipCode = Customer.ZipCode; Activity.DlvZipCode = Customer.ZipCode;
// Activity.DlvCity = Customer.City; Activity.DlvCity = Customer.City;
// Activity.BcId = Customer.BcId; Activity.BcId = Customer.BcId;
// Activity.CompanyId = Customer.CompanyId; Activity.CompanyId = Customer.CompanyId;
// Activity.SalesRepId = Customer.SalesRepId; Activity.SalesRepId = Customer.SalesRepId;
//
// // setting up activity properties // setting up activity properties
// Activity.ActivityStatusEnum = "noSale"; Activity.ActivityStatusEnum = "noSale";
// Activity.VisitTypeEnum = "recall"; Activity.VisitTypeEnum = "recall";
// Activity.ActivityTypeEnum = "phone"; Activity.ActivityTypeEnum = "phone";
// Activity.ActivityStatusEnum = "order"; Activity.ActivityStatusEnum = "order";
//
// // Initialize date variable // Initialize date variable
// SelectedDate = DateTime.Now; SelectedDate = DateTime.Now;
} }
private void CallPriceListModal() private void CallPriceListModal()

View file

@ -1,7 +1,7 @@
{ {
"appInfo": { "appInfo": {
"name": "Wonky Online", "name": "Wonky Online",
"version": "0.116.2", "version": "0.117.0",
"rc": true, "rc": true,
"sandBox": false, "sandBox": false,
"image": "grumpy-coder.png" "image": "grumpy-coder.png"