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>
</div>
<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>

View file

@ -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();
}

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>
/// <param name="customerId"></param>
/// <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>
/// <param name="customerId"></param>
/// <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 content = await response.Content.ReadAsStringAsync();

View file

@ -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();
}

View file

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

View file

@ -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<VirkRegInfo> 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<UserInfoView>("_xu");
Dk = ux.CountryCode.ToLower() == "dk";
var xu = await Storage.GetItemAsync<UserInfoView>("_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.");

View file

@ -24,8 +24,8 @@
<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="col">
<WorkDateComponent OnChangedCallback="@WorkDateComponentCallback"/>
<div class="col text-center">
@DateTime.Now.ToLongDateString()
</div>
</div>
@ -61,15 +61,11 @@
<div class="col-sm-10 col-md-4">
<InputText id="phone" class="form-control" @bind-Value="Activity.Phone"/>
<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">
<InputCheckbox id="express" class="form-check-input" @bind-Value="@Activity.Express"/>
<label class="form-check-label" for="express">Express</label>
</div>
</div>
</div>
<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
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()

View file

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