This commit is contained in:
Frede Hundewadt 2022-04-18 11:02:03 +02:00
parent 8ea978668d
commit 6724c2b6b7
43 changed files with 244 additions and 390 deletions

View file

@ -22,7 +22,7 @@ namespace Wonky.Client.Components
{ {
public partial class CompanyTable public partial class CompanyTable
{ {
[Parameter] public List<CompanyDto> Companies { get; set; } = new(); [Parameter] public List<DtoNgCrmCompany> Companies { get; set; } = new();
[Parameter] public EventCallback<string> OnDelete { get; set; } [Parameter] public EventCallback<string> OnDelete { get; set; }
[Parameter] public EventCallback<string> OnSelect { get; set; } [Parameter] public EventCallback<string> OnSelect { get; set; }
[Inject] public NavigationManager NavManager { get; set; } [Inject] public NavigationManager NavManager { get; set; }

View file

@ -22,7 +22,7 @@ namespace Wonky.Client.Components;
public partial class ItemTable public partial class ItemTable
{ {
[Parameter] public List<SalesItemDto> SalesItems { get; set; } = new(); [Parameter] public List<NgSalesItemView> SalesItems { get; set; } = new();
[Inject] private IToastService ToastService { get; set; } [Inject] private IToastService ToastService { get; set; }
private void AddToDraft() private void AddToDraft()
{ {

View file

@ -54,7 +54,7 @@ public class CompanyHttpRepository : ICompanyHttpRepository
_apiConfig = apiConfig.Value; _apiConfig = apiConfig.Value;
} }
public async Task<PagingResponse<CompanyDto>> GetCompaniesPaged(CompanyPagingParams pagingParameters) public async Task<PagingResponse<DtoNgCrmCompany>> GetCompaniesPaged(CompanyPagingParams pagingParameters)
{ {
var queryString = new Dictionary<string, string> var queryString = new Dictionary<string, string>
{ {
@ -70,37 +70,37 @@ public class CompanyHttpRepository : ICompanyHttpRepository
var content = await response.Content.ReadAsStringAsync(); var content = await response.Content.ReadAsStringAsync();
var pagingResponse = new PagingResponse<CompanyDto> var pagingResponse = new PagingResponse<DtoNgCrmCompany>
{ {
Items = JsonSerializer.Deserialize<List<CompanyDto>>(content, _options), Items = JsonSerializer.Deserialize<List<DtoNgCrmCompany>>(content, _options),
MetaData = JsonSerializer.Deserialize<MetaData>(response.Headers.GetValues("X-Pagination").First(), _options) MetaData = JsonSerializer.Deserialize<MetaData>(response.Headers.GetValues("X-Pagination").First(), _options)
}; };
return pagingResponse; return pagingResponse;
} }
public async Task<CompanyDto> GetCompanyByAccount(string accountNumber) public async Task<DtoNgCrmCompany> GetCompanyByAccount(string accountNumber)
{ {
var company = await _client.GetFromJsonAsync<CompanyDto>($"{_apiConfig.CrmCompanies}/account/{accountNumber}"); var company = await _client.GetFromJsonAsync<DtoNgCrmCompany>($"{_apiConfig.CrmCompanies}/account/{accountNumber}");
return company ?? new CompanyDto(); return company ?? new DtoNgCrmCompany();
} }
public async Task<CompanyDto> GetCompanyById(string companyId) public async Task<DtoNgCrmCompany> GetCompanyById(string companyId)
{ {
var company = await _client.GetFromJsonAsync<CompanyDto>($"{_apiConfig.CrmCompanies}/{companyId}"); var company = await _client.GetFromJsonAsync<DtoNgCrmCompany>($"{_apiConfig.CrmCompanies}/{companyId}");
return company ?? new CompanyDto(); return company ?? new DtoNgCrmCompany();
} }
public async Task<string> CreateCompany(CompanyDto companyDto) public async Task<string> CreateCompany(DtoNgCrmCompany dtoNgCrmCompany)
{ {
var response = await _client.PostAsJsonAsync($"{_apiConfig.CrmCompanies}", companyDto); var response = await _client.PostAsJsonAsync($"{_apiConfig.CrmCompanies}", dtoNgCrmCompany);
var content = await response.Content.ReadAsStringAsync(); var content = await response.Content.ReadAsStringAsync();
var result = JsonSerializer.Deserialize<CompanyDto>(content); var result = JsonSerializer.Deserialize<DtoNgCrmCompany>(content);
return result.CompanyId; return result.CompanyId;
} }
public async Task UpdateCompany(CompanyDto companyDto) public async Task UpdateCompany(DtoNgCrmCompany dtoNgCrmCompany)
{ {
await _client.PutAsJsonAsync($"{_apiConfig.CrmCompanies}/{companyDto.CompanyId}", companyDto); await _client.PutAsJsonAsync($"{_apiConfig.CrmCompanies}/{dtoNgCrmCompany.CompanyId}", dtoNgCrmCompany);
} }
public async Task DeleteCompany(string companyId) public async Task DeleteCompany(string companyId)

View file

@ -22,10 +22,10 @@ namespace Wonky.Client.HttpRepository;
public interface ICompanyHttpRepository public interface ICompanyHttpRepository
{ {
Task<PagingResponse<CompanyDto>> GetCompaniesPaged(CompanyPagingParams pagingParameters); Task<PagingResponse<DtoNgCrmCompany>> GetCompaniesPaged(CompanyPagingParams pagingParameters);
Task<CompanyDto> GetCompanyByAccount(string accountNumber); Task<DtoNgCrmCompany> GetCompanyByAccount(string accountNumber);
Task<CompanyDto> GetCompanyById(string companyId); Task<DtoNgCrmCompany> GetCompanyById(string companyId);
Task<string> CreateCompany(CompanyDto companyDto); Task<string> CreateCompany(DtoNgCrmCompany dtoNgCrmCompany);
Task UpdateCompany(CompanyDto companyDto); Task UpdateCompany(DtoNgCrmCompany dtoNgCrmCompany);
Task DeleteCompany(string companyId); Task DeleteCompany(string companyId);
} }

View file

@ -22,6 +22,6 @@ namespace Wonky.Client.HttpRepository;
public interface ISalesItemHttpRepository public interface ISalesItemHttpRepository
{ {
Task<PagingResponse<SalesItemDto>> GetSalesItemsPaged(CatalogPagingParams pagingParameters); Task<PagingResponse<NgSalesItemView>> GetSalesItemsPaged(CatalogPagingParams pagingParameters);
Task<SalesItemDto> GetSalesItem(string id); Task<NgSalesItemView> GetSalesItem(string id);
} }

View file

@ -51,7 +51,7 @@ public class SalesItemHttpRepository : ISalesItemHttpRepository
_apiConfig = configuration.Value; _apiConfig = configuration.Value;
} }
public async Task<PagingResponse<SalesItemDto>> GetSalesItemsPaged(CatalogPagingParams pagingParameters) public async Task<PagingResponse<NgSalesItemView>> GetSalesItemsPaged(CatalogPagingParams pagingParameters)
{ {
var queryString = new Dictionary<string, string> var queryString = new Dictionary<string, string>
{ {
@ -67,19 +67,19 @@ public class SalesItemHttpRepository : ISalesItemHttpRepository
var content = await response.Content.ReadAsStringAsync(); var content = await response.Content.ReadAsStringAsync();
var pagingResponse = new PagingResponse<SalesItemDto> var pagingResponse = new PagingResponse<NgSalesItemView>
{ {
Items = JsonSerializer.Deserialize<List<SalesItemDto>>(content, _options), Items = JsonSerializer.Deserialize<List<NgSalesItemView>>(content, _options),
MetaData = JsonSerializer.Deserialize<MetaData>( MetaData = JsonSerializer.Deserialize<MetaData>(
response.Headers.GetValues("X-Pagination").First(), _options) response.Headers.GetValues("X-Pagination").First(), _options)
}; };
return pagingResponse; return pagingResponse;
} }
public async Task<SalesItemDto> GetSalesItem(string id) public async Task<NgSalesItemView> GetSalesItem(string id)
{ {
var salesItem = await _client var salesItem = await _client
.GetFromJsonAsync<SalesItemDto>($"{_apiConfig.PriceCatalog}/{id}"); .GetFromJsonAsync<NgSalesItemView>($"{_apiConfig.PriceCatalog}/{id}");
return salesItem ?? new SalesItemDto(); return salesItem ?? new NgSalesItemView();
} }
} }

View file

@ -5,31 +5,20 @@ namespace Wonky.Client.Models;
public class DraftItem public class DraftItem
{ {
public int Quantity { get; set; } public int Quantity { get; set; }
public SalesItemDto Item { get; set; } public NgSalesItemView Item { get; set; }
public decimal Price { get; set; } public decimal Price { get; set; }
public decimal Discount { get; set; } public decimal Discount { get; set; }
public decimal LineTotal => (Price - Price * Discount / 100) * Quantity;
public decimal Total
{
get
{
var price = (from x in Item.Rates where x.Quantity == Quantity.ToString() select x.Rate).First();
if (string.IsNullOrWhiteSpace(price))
price = Item.Rates[0].Rate;
Price = Convert.ToDecimal(price);
return (Price - Price * Discount / 100) * Quantity;
}
}
} }
public class Draft public class Draft
{ {
public List<DraftItem> Items { get; set; } = new List<DraftItem>(); public List<DraftItem> Items { get; set; } = new ();
public decimal Total public decimal Total
{ {
get get
{ {
return Items.Sum(item => item.Total); return Items.Sum(item => item.LineTotal);
} }
} }
public DateTime LastAccessed { get; set; } public DateTime LastAccessed { get; set; }

View file

@ -1,28 +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 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;
namespace Wonky.Client.Models
{
public class Quote
{
public int QuoteId { get; set; }
public string CompanyId { get; set; } = "";
public string Name { get; set; } = "";
public string EMail { get; set; } = "";
public List<QuoteItem> Items { get; set; } = new();
}
}

View file

@ -1,24 +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 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.Client.Models;
public class QuoteItem
{
public string Sku { get; set; } = "";
public string Text { get; set; } = "";
public int Qty { get; set; }
public decimal Price { get; set; }
}

View file

@ -57,7 +57,7 @@
<div class="card bg-light"> <div class="card bg-light">
<EditForm EditContext="_createCompany" OnValidSubmit="Create" class="card-body"> <EditForm EditContext="_createCompany" OnValidSubmit="Create" class="card-body">
<DataAnnotationsValidator /> <DataAnnotationsValidator />
<InputText type="hidden" id="salesRepId" @bind-Value="_companyDto.SalesRepId"/> <InputText type="hidden" id="salesRepId" @bind-Value="_dtoNgCrmCompany.SalesRepId"/>
<table class="table"> <table class="table">
<thead> <thead>
@ -67,73 +67,73 @@
<th scope="row">Reg.nr.</th> <th scope="row">Reg.nr.</th>
<td class="state"><DisplayStateComponent StateClass="@RegState"></DisplayStateComponent></td> <td class="state"><DisplayStateComponent StateClass="@RegState"></DisplayStateComponent></td>
<td> <td>
<InputText id="vatNumber" class="form-control" @bind-Value="_companyDto.VatNumber"/> <InputText id="vatNumber" class="form-control" @bind-Value="_dtoNgCrmCompany.VatNumber"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Firmanavn</th> <th scope="row">Firmanavn</th>
<td></td> <td></td>
<td> <td>
<InputText id="name" class="form-control" @bind-Value="_companyDto.Name"/> <InputText id="name" class="form-control" @bind-Value="_dtoNgCrmCompany.Name"/>
<ValidationMessage For="@(() => _companyDto.Name)"></ValidationMessage> <ValidationMessage For="@(() => _dtoNgCrmCompany.Name)"></ValidationMessage>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Conavn</th> <th scope="row">Conavn</th>
<td></td> <td></td>
<td> <td>
<InputText id="address1" class="form-control" @bind-Value="_companyDto.Address1"/> <InputText id="address1" class="form-control" @bind-Value="_dtoNgCrmCompany.Address1"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Adresse</th> <th scope="row">Adresse</th>
<td></td> <td></td>
<td> <td>
<InputText id="address2" class="form-control" @bind-Value="_companyDto.Address2"/> <InputText id="address2" class="form-control" @bind-Value="_dtoNgCrmCompany.Address2"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Postnr</th> <th scope="row">Postnr</th>
<td></td> <td></td>
<td> <td>
<InputText id="zipCode" class="form-control" @bind-Value="_companyDto.ZipCode"/> <InputText id="zipCode" class="form-control" @bind-Value="_dtoNgCrmCompany.ZipCode"/>
<ValidationMessage For="@(() => _companyDto.ZipCode)"></ValidationMessage> <ValidationMessage For="@(() => _dtoNgCrmCompany.ZipCode)"></ValidationMessage>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Bynavn</th> <th scope="row">Bynavn</th>
<td></td> <td></td>
<td> <td>
<InputText id="city" class="form-control" @bind-Value="_companyDto.City"/> <InputText id="city" class="form-control" @bind-Value="_dtoNgCrmCompany.City"/>
<ValidationMessage For="@(() => _companyDto.City)"></ValidationMessage> <ValidationMessage For="@(() => _dtoNgCrmCompany.City)"></ValidationMessage>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Telefon</th> <th scope="row">Telefon</th>
<td></td> <td></td>
<td> <td>
<InputText id="phone" class="form-control" @bind-Value="_companyDto.Phone"/> <InputText id="phone" class="form-control" @bind-Value="_dtoNgCrmCompany.Phone"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Mobil</th> <th scope="row">Mobil</th>
<td></td> <td></td>
<td> <td>
<InputText id="mobile" class="form-control" @bind-Value="_companyDto.Mobile"/> <InputText id="mobile" class="form-control" @bind-Value="_dtoNgCrmCompany.Mobile"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Email</th> <th scope="row">Email</th>
<td></td> <td></td>
<td> <td>
<InputText id="email" class="form-control" @bind-Value="_companyDto.Email"/> <InputText id="email" class="form-control" @bind-Value="_dtoNgCrmCompany.Email"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Attention</th> <th scope="row">Attention</th>
<td></td> <td></td>
<td> <td>
<InputText id="attention" class="form-control" @bind-Value="_companyDto.Attention"/> <InputText id="attention" class="form-control" @bind-Value="_dtoNgCrmCompany.Attention"/>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View file

@ -43,7 +43,7 @@ namespace Wonky.Client.Pages
[Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public VatInfoLookupService VatInfoLookupService { get; set; } [Inject] public VatInfoLookupService VatInfoLookupService { get; set; }
private List<VirkRegInfo> VInfos { get; set; } = new(); private List<VirkRegInfo> VInfos { get; set; } = new();
private CompanyDto _companyDto = new(); private DtoNgCrmCompany _dtoNgCrmCompany = new();
private VirkRegInfo _virkRegInfo = new(); private VirkRegInfo _virkRegInfo = new();
private EditContext _createCompany; private EditContext _createCompany;
private bool _formInvalid = true; private bool _formInvalid = true;
@ -51,12 +51,12 @@ namespace Wonky.Client.Pages
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
_createCompany = new EditContext(_companyDto); _createCompany = new EditContext(_dtoNgCrmCompany);
_createCompany.OnFieldChanged += HandleFieldChanged; _createCompany.OnFieldChanged += HandleFieldChanged;
var ux = await StorageService.GetItemAsync<UserInfo>("_ux"); var ux = await StorageService.GetItemAsync<UserInfoView>("_ux");
_companyDto.SalesRepId = ux.Id; _dtoNgCrmCompany.SalesRepId = ux.Id;
_companyDto.CountryCode = ux.CountryCode; _dtoNgCrmCompany.CountryCode = ux.CountryCode;
Interceptor.RegisterEvent(); Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent(); Interceptor.RegisterBeforeSendEvent();
} }
@ -91,23 +91,23 @@ namespace Wonky.Client.Pages
{ {
_virkRegInfo = (from x in VInfos where x.VatNumber == vatNumber select x).First(); _virkRegInfo = (from x in VInfos where x.VatNumber == vatNumber select x).First();
RegState = _virkRegInfo.States[^1].State == "NORMAL" ? "the-good" : "the-ugly"; RegState = _virkRegInfo.States[^1].State == "NORMAL" ? "the-good" : "the-ugly";
_companyDto.Name = _virkRegInfo.Name; _dtoNgCrmCompany.Name = _virkRegInfo.Name;
_companyDto.Address1 = _virkRegInfo.CoName; _dtoNgCrmCompany.Address1 = _virkRegInfo.CoName;
_companyDto.Address2 = _virkRegInfo.Address; _dtoNgCrmCompany.Address2 = _virkRegInfo.Address;
_companyDto.ZipCode = _virkRegInfo.ZipCode; _dtoNgCrmCompany.ZipCode = _virkRegInfo.ZipCode;
_companyDto.City = _virkRegInfo.City; _dtoNgCrmCompany.City = _virkRegInfo.City;
_companyDto.VatNumber = _virkRegInfo.VatNumber; _dtoNgCrmCompany.VatNumber = _virkRegInfo.VatNumber;
} }
private async Task Create() private async Task Create()
{ {
var newId = await CompanyRepo.CreateCompany(_companyDto); var newId = await CompanyRepo.CreateCompany(_dtoNgCrmCompany);
ToastService.ShowSuccess($"Godt så! '{_companyDto.Name}' er oprettet i CRM."); ToastService.ShowSuccess($"Godt så! '{_dtoNgCrmCompany.Name}' er oprettet i CRM.");
Navigation.NavigateTo($"/company/{newId}"); Navigation.NavigateTo($"/company/{newId}");
} }
private void HandleFieldChanged(object sender, FieldChangedEventArgs e) private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
{ {
if (!VatUtils.ValidateFormat(_companyDto.CountryCode, _companyDto.VatNumber)) if (!VatUtils.ValidateFormat(_dtoNgCrmCompany.CountryCode, _dtoNgCrmCompany.VatNumber))
{ {
_formInvalid = false; _formInvalid = false;
} }
@ -121,7 +121,7 @@ namespace Wonky.Client.Pages
{ {
_formInvalid = true; _formInvalid = true;
_createCompany.OnFieldChanged -= HandleFieldChanged; _createCompany.OnFieldChanged -= HandleFieldChanged;
_createCompany = new EditContext(_companyDto); _createCompany = new EditContext(_dtoNgCrmCompany);
_createCompany.OnFieldChanged += HandleFieldChanged; _createCompany.OnFieldChanged += HandleFieldChanged;
_createCompany.OnValidationStateChanged -= ValidationChanged; _createCompany.OnValidationStateChanged -= ValidationChanged;
} }

View file

@ -32,7 +32,7 @@ namespace Wonky.Client.Pages
[Inject] private UserPreferenceService UserPrefService { get; set; } [Inject] private UserPreferenceService UserPrefService { get; set; }
[Inject] public ICompanyHttpRepository CompanyRepo { get; set; } [Inject] public ICompanyHttpRepository CompanyRepo { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; }
public List<CompanyDto>? Companies { get; set; } = new(); public List<DtoNgCrmCompany>? Companies { get; set; } = new();
public MetaData? MetaData { get; set; } = new(); public MetaData? MetaData { get; set; } = new();
private CompanyPagingParams _paging = new(); private CompanyPagingParams _paging = new();
private Preferences _preferences { get; set; } = new(); private Preferences _preferences { get; set; } = new();
@ -54,21 +54,21 @@ namespace Wonky.Client.Pages
private async Task SelectedPage(int page) private async Task SelectedPage(int page)
{ {
Companies = new List<CompanyDto>(); Companies = new List<DtoNgCrmCompany>();
_paging.PageNumber = page; _paging.PageNumber = page;
await GetCompanies(); await GetCompanies();
} }
private async Task SetSearchCol(string searchColumn) private async Task SetSearchCol(string searchColumn)
{ {
Companies = new List<CompanyDto>(); Companies = new List<DtoNgCrmCompany>();
_paging.SearchColumn = searchColumn; _paging.SearchColumn = searchColumn;
_paging.PageNumber = 1; _paging.PageNumber = 1;
await GetCompanies(); await GetCompanies();
} }
private async Task SetPageSize(string pageSize) private async Task SetPageSize(string pageSize)
{ {
Companies = new List<CompanyDto>(); Companies = new List<DtoNgCrmCompany>();
_paging.PageSize = Convert.ToInt32(pageSize); _paging.PageSize = Convert.ToInt32(pageSize);
_paging.PageNumber = 1; _paging.PageNumber = 1;
await GetCompanies(); await GetCompanies();
@ -76,7 +76,7 @@ namespace Wonky.Client.Pages
private async Task SetSearchPhrase(string searchTerm) private async Task SetSearchPhrase(string searchTerm)
{ {
Companies = new List<CompanyDto>(); Companies = new List<DtoNgCrmCompany>();
_paging.PageNumber = 1; _paging.PageNumber = 1;
_paging.SearchTerm = searchTerm; _paging.SearchTerm = searchTerm;
await GetCompanies(); await GetCompanies();
@ -84,14 +84,14 @@ namespace Wonky.Client.Pages
private async Task SetSortCol(string orderBy) private async Task SetSortCol(string orderBy)
{ {
Companies = new List<CompanyDto>(); Companies = new List<DtoNgCrmCompany>();
_paging.OrderBy = orderBy; _paging.OrderBy = orderBy;
await GetCompanies(); await GetCompanies();
} }
private async Task DeleteCompany(string companyId) private async Task DeleteCompany(string companyId)
{ {
Companies = new List<CompanyDto>(); Companies = new List<DtoNgCrmCompany>();
await CompanyRepo.DeleteCompany(companyId); await CompanyRepo.DeleteCompany(companyId);
if (_paging.PageNumber > 1 && Companies.Count == 1) if (_paging.PageNumber > 1 && Companies.Count == 1)
_paging.PageNumber--; _paging.PageNumber--;

View file

@ -20,11 +20,11 @@
@attribute [Authorize(Roles = "Adviser")] @attribute [Authorize(Roles = "Adviser")]
@page "/company/{companyId}/update" @page "/company/{companyId}/update"
@if (_company != null) @if (DtoNgCrmCompany != null)
{ {
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<div class="h2">@_company.Account - @_company.Name</div> <div class="h2">@DtoNgCrmCompany.Account - @DtoNgCrmCompany.Name</div>
</div> </div>
<div class="card-body"> <div class="card-body">
<VatNumberInputComponent OnValidSubmit="GetInfoFromVat"/> <VatNumberInputComponent OnValidSubmit="GetInfoFromVat"/>
@ -60,65 +60,65 @@
<div class="form-group row mb-2"> <div class="form-group row mb-2">
<label for="vatNumber" class="col-md-2 col-form-label">CVR/ORG</label> <label for="vatNumber" class="col-md-2 col-form-label">CVR/ORG</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText id="vatNumber" class="form-control" @bind-Value="_company.VatNumber"/> <InputText id="vatNumber" class="form-control" @bind-Value="DtoNgCrmCompany.VatNumber"/>
<ValidationMessage For="@(() => _company.VatNumber)"></ValidationMessage> <ValidationMessage For="@(() => DtoNgCrmCompany.VatNumber)"></ValidationMessage>
</div> </div>
</div> </div>
<div class="form-group row mb-2"> <div class="form-group row mb-2">
<label for="name" class="col-md-2 col-form-label">Firmanavn</label> <label for="name" class="col-md-2 col-form-label">Firmanavn</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText id="name" class="form-control" @bind-Value="_company.Name"/> <InputText id="name" class="form-control" @bind-Value="DtoNgCrmCompany.Name"/>
<ValidationMessage For="@(() => _company.Name)"></ValidationMessage> <ValidationMessage For="@(() => DtoNgCrmCompany.Name)"></ValidationMessage>
</div> </div>
</div> </div>
<div class="form-group row mb-2"> <div class="form-group row mb-2">
<label for="address1" class="col-md-2 col-form-label">Conavn</label> <label for="address1" class="col-md-2 col-form-label">Conavn</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText id="address1" class="form-control" @bind-Value="_company.Address1"/> <InputText id="address1" class="form-control" @bind-Value="DtoNgCrmCompany.Address1"/>
</div> </div>
</div> </div>
<div class="form-group row mb-2"> <div class="form-group row mb-2">
<label for="address2" class="col-md-2 col-form-label">Adresse</label> <label for="address2" class="col-md-2 col-form-label">Adresse</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText id="address2" class="form-control" @bind-Value="_company.Address2"/> <InputText id="address2" class="form-control" @bind-Value="DtoNgCrmCompany.Address2"/>
</div> </div>
</div> </div>
<div class="form-group row mb-2"> <div class="form-group row mb-2">
<label for="zipCode" class="col-md-2 col-form-label">Postnr</label> <label for="zipCode" class="col-md-2 col-form-label">Postnr</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText id="zipCode" class="form-control" @bind-Value="_company.ZipCode"/> <InputText id="zipCode" class="form-control" @bind-Value="DtoNgCrmCompany.ZipCode"/>
<ValidationMessage For="@(() => _company.ZipCode)"></ValidationMessage> <ValidationMessage For="@(() => DtoNgCrmCompany.ZipCode)"></ValidationMessage>
</div> </div>
</div> </div>
<div class="form-group row mb-2"> <div class="form-group row mb-2">
<label for="city" class="col-md-2 col-form-label">Bynavn</label> <label for="city" class="col-md-2 col-form-label">Bynavn</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText id="city" class="form-control" @bind-Value="_company.City"/> <InputText id="city" class="form-control" @bind-Value="DtoNgCrmCompany.City"/>
<ValidationMessage For="@(() => _company.City)"></ValidationMessage> <ValidationMessage For="@(() => DtoNgCrmCompany.City)"></ValidationMessage>
</div> </div>
</div> </div>
<div class="form-group row mb-2"> <div class="form-group row mb-2">
<label for="phone" class="col-md-2 col-form-label">Telefon</label> <label for="phone" class="col-md-2 col-form-label">Telefon</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText id="phone" class="form-control" @bind-Value="_company.Phone"/> <InputText id="phone" class="form-control" @bind-Value="DtoNgCrmCompany.Phone"/>
</div> </div>
</div> </div>
<div class="form-group row mb-2"> <div class="form-group row mb-2">
<label for="mobile" class="col-md-2 col-form-label">Mobil</label> <label for="mobile" class="col-md-2 col-form-label">Mobil</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText id="mobile" class="form-control" @bind-Value="_company.Mobile"/> <InputText id="mobile" class="form-control" @bind-Value="DtoNgCrmCompany.Mobile"/>
</div> </div>
</div> </div>
<div class="form-group row mb-2"> <div class="form-group row mb-2">
<label for="email" class="col-md-2 col-form-label">Email</label> <label for="email" class="col-md-2 col-form-label">Email</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText id="email" class="form-control" @bind-Value="_company.Email"/> <InputText id="email" class="form-control" @bind-Value="DtoNgCrmCompany.Email"/>
</div> </div>
</div> </div>
<div class="form-group row mb-2"> <div class="form-group row mb-2">
<label for="attention" class="col-md-2 col-form-label">Attention</label> <label for="attention" class="col-md-2 col-form-label">Attention</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText id="attention" class="form-control" @bind-Value="_company.Attention"/> <InputText id="attention" class="form-control" @bind-Value="DtoNgCrmCompany.Attention"/>
</div> </div>
</div> </div>
<div class="form-group row mb-2"> <div class="form-group row mb-2">
@ -136,7 +136,7 @@
<div class="form-group row mb-2"> <div class="form-group row mb-2">
<label for="interval" class="col-form-label col-md-2">Interval (uger)</label> <label for="interval" class="col-form-label col-md-2">Interval (uger)</label>
<div class="col-md-3"> <div class="col-md-3">
<InputNumber id="interval" class="form-control" @bind-Value="_company.Interval"/> <InputNumber id="interval" class="form-control" @bind-Value="DtoNgCrmCompany.Interval"/>
</div> </div>
</div> </div>
<div class="row mb-2"> <div class="row mb-2">
@ -149,7 +149,7 @@
<div class="card-footer"> <div class="card-footer">
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<a class="btn btn-primary" href="/company/@_company.CompanyId">Tilbage</a> <a class="btn btn-primary" href="/company/@DtoNgCrmCompany.CompanyId">Tilbage</a>
</div> </div>
</div> </div>
</div> </div>

View file

@ -39,7 +39,7 @@ public partial class CompanyUpdate : IDisposable
[Inject] public VatInfoLookupService VatInfoLookupService { get; set; } [Inject] public VatInfoLookupService VatInfoLookupService { get; set; }
[Parameter] public string Account { get; set; } = ""; [Parameter] public string Account { get; set; } = "";
[Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string CompanyId { get; set; } = "";
private CompanyDto _company { get; set; } private DtoNgCrmCompany DtoNgCrmCompany { get; set; }
private EditContext _updateCompany { get; set; } private EditContext _updateCompany { get; set; }
private List<VirkRegInfo> VInfos { get; set; } = new(); private List<VirkRegInfo> VInfos { get; set; } = new();
private VirkRegInfo _virkRegInfo { get; set; } = new(); private VirkRegInfo _virkRegInfo { get; set; } = new();
@ -51,41 +51,41 @@ public partial class CompanyUpdate : IDisposable
{ {
Interceptor.RegisterEvent(); Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent(); Interceptor.RegisterBeforeSendEvent();
_company = await CompanyRepo.GetCompanyById(CompanyId); DtoNgCrmCompany = await CompanyRepo.GetCompanyById(CompanyId);
LastVisit = DateTime.Parse(_company.LastVisit); LastVisit = DateTime.Parse(DtoNgCrmCompany.LastVisit);
NextVisit = DateTime.Parse(_company.NextVisit); NextVisit = DateTime.Parse(DtoNgCrmCompany.NextVisit);
_updateCompany = new EditContext(_company); _updateCompany = new EditContext(DtoNgCrmCompany);
if(_company.HasFolded == 1) if(DtoNgCrmCompany.HasFolded == 1)
{ {
_vatState = "the-dead"; _vatState = "the-dead";
} }
else else
{ {
_vatState = VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber) ? "the-good" : "the-draw"; _vatState = VatUtils.ValidateFormat(DtoNgCrmCompany.CountryCode, DtoNgCrmCompany.VatNumber) ? "the-good" : "the-draw";
} }
} }
private async Task Update() private async Task Update()
{ {
if (!string.IsNullOrWhiteSpace(_company.VatNumber) && !VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber)) if (!string.IsNullOrWhiteSpace(DtoNgCrmCompany.VatNumber) && !VatUtils.ValidateFormat(DtoNgCrmCompany.CountryCode, DtoNgCrmCompany.VatNumber))
{ {
ToastService.ShowError($"CVR/VAT/ORG nummer er ugyldig."); ToastService.ShowError($"CVR/VAT/ORG nummer er ugyldig.");
StateHasChanged(); StateHasChanged();
return; return;
} }
_company.LastVisit = $"{LastVisit:yyyy-MM-dd}"; DtoNgCrmCompany.LastVisit = $"{LastVisit:yyyy-MM-dd}";
_company.NextVisit = $"{NextVisit:yyyy-MM-dd}"; DtoNgCrmCompany.NextVisit = $"{NextVisit:yyyy-MM-dd}";
Console.WriteLine(JsonSerializer.Serialize(_company)); Console.WriteLine(JsonSerializer.Serialize(DtoNgCrmCompany));
await CompanyRepo.UpdateCompany(_company); await CompanyRepo.UpdateCompany(DtoNgCrmCompany);
ToastService.ShowSuccess($"Godt så. Firma '{_company!.Name}' er opdateret."); ToastService.ShowSuccess($"Godt så. Firma '{DtoNgCrmCompany!.Name}' er opdateret.");
Navigation.NavigateTo($"/company/{_company.CompanyId}"); Navigation.NavigateTo($"/company/{DtoNgCrmCompany.CompanyId}");
} }
private async Task GetInfoFromVat(string vatNumber) private async Task GetInfoFromVat(string vatNumber)
{ {
if (string.IsNullOrWhiteSpace(vatNumber) || !VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber)) if (string.IsNullOrWhiteSpace(vatNumber) || !VatUtils.ValidateFormat(DtoNgCrmCompany.CountryCode, DtoNgCrmCompany.VatNumber))
{ {
ToastService.ShowError($"CVR er ugyldigt eller mangler"); ToastService.ShowError($"CVR er ugyldigt eller mangler");
return; return;
@ -120,12 +120,12 @@ public partial class CompanyUpdate : IDisposable
private void SelectCompany(string vatNumber) private void SelectCompany(string vatNumber)
{ {
_virkRegInfo = (from x in VInfos where x.VatNumber == vatNumber select x).First(); _virkRegInfo = (from x in VInfos where x.VatNumber == vatNumber select x).First();
_company.Name = _virkRegInfo.Name; DtoNgCrmCompany.Name = _virkRegInfo.Name;
_company.Address1 = _virkRegInfo.CoName; DtoNgCrmCompany.Address1 = _virkRegInfo.CoName;
_company.Address2 = _virkRegInfo.Address; DtoNgCrmCompany.Address2 = _virkRegInfo.Address;
_company.ZipCode = _virkRegInfo.ZipCode; DtoNgCrmCompany.ZipCode = _virkRegInfo.ZipCode;
_company.City = _virkRegInfo.City; DtoNgCrmCompany.City = _virkRegInfo.City;
_company.VatNumber = _virkRegInfo.VatNumber; DtoNgCrmCompany.VatNumber = _virkRegInfo.VatNumber;
} }
public void Dispose() public void Dispose()

View file

@ -21,56 +21,56 @@
@using Wonky.Client.Helpers @using Wonky.Client.Helpers
@attribute [Authorize(Roles = "Adviser")] @attribute [Authorize(Roles = "Adviser")]
@if (_company != null) @if (DtoNgCrmCompany != null)
{ {
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<div class="h2"><img src="gravestone.png" class="img-fluid" style="float:left;width:48px;height:48px;display:@(_hasFolded ? "block" : "none")" alt="tombstone"/> @_company.Name</div> <div class="h2"><img src="gravestone.png" class="img-fluid" style="float:left;width:48px;height:48px;display:@(_hasFolded ? "block" : "none")" alt="tombstone"/> @DtoNgCrmCompany.Name</div>
</div> </div>
<div class="card-body"> <div class="card-body">
<table class="table table-sm table-striped table-bordered"> <table class="table table-sm table-striped table-bordered">
<tbody> <tbody>
<tr> <tr>
<th scope="row">Konto</th> <th scope="row">Konto</th>
<td colspan="2">@_company.Account</td> <td colspan="2">@DtoNgCrmCompany.Account</td>
</tr> </tr>
<tr> <tr>
<th scope="row">Conavn</th> <th scope="row">Conavn</th>
<td colspan="2">@_company.Address1</td> <td colspan="2">@DtoNgCrmCompany.Address1</td>
</tr> </tr>
<tr> <tr>
<th scope="row">Adresse</th> <th scope="row">Adresse</th>
<td colspan="2">@_company.Address2</td> <td colspan="2">@DtoNgCrmCompany.Address2</td>
</tr> </tr>
<tr> <tr>
<th scope="row">Postnummer</th> <th scope="row">Postnummer</th>
<td colspan="2">@_company.ZipCode</td> <td colspan="2">@DtoNgCrmCompany.ZipCode</td>
</tr> </tr>
<tr> <tr>
<th scope="row">Bynavn</th> <th scope="row">Bynavn</th>
<td colspan="2">@_company.City</td> <td colspan="2">@DtoNgCrmCompany.City</td>
</tr> </tr>
<tr> <tr>
<th scope="row">CVR</th> <th scope="row">CVR</th>
<td class="state"><DisplayStateComponent StateClass="@_vatState"></DisplayStateComponent></td> <td class="state"><DisplayStateComponent StateClass="@_vatState"></DisplayStateComponent></td>
<td>@_company.VatNumber</td> <td>@DtoNgCrmCompany.VatNumber</td>
</tr> </tr>
<tr> <tr>
<th scope="row">Telefon</th> <th scope="row">Telefon</th>
<td colspan="2">@_company.Phone</td> <td colspan="2">@DtoNgCrmCompany.Phone</td>
</tr> </tr>
<tr> <tr>
<th scope="row">Email</th> <th scope="row">Email</th>
<td colspan="2">@_company.Email</td> <td colspan="2">@DtoNgCrmCompany.Email</td>
</tr> </tr>
<tr> <tr>
<th scope="row">Sidste besøg</th> <th scope="row">Sidste besøg</th>
<td colspan="2">@_company.LastVisit</td> <td colspan="2">@DtoNgCrmCompany.LastVisit</td>
</tr> </tr>
<tr> <tr>
<th scope="row">Næste besøg</th> <th scope="row">Næste besøg</th>
<td class="state"><DisplayStateComponent StateClass="@(_hasFolded ? "the-dead" : Utils.GetVisitState(_company.NextVisit))"></DisplayStateComponent></td> <td class="state"><DisplayStateComponent StateClass="@(_hasFolded ? "the-dead" : Utils.GetVisitState(DtoNgCrmCompany.NextVisit))"></DisplayStateComponent></td>
<td>@_company.NextVisit</td> <td>@DtoNgCrmCompany.NextVisit</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -78,8 +78,8 @@
<div class="card-footer"> <div class="card-footer">
<div class="d-flex align-items-end"> <div class="d-flex align-items-end">
<a class="btn btn-primary mx-2" href="/companies">Tilbage</a> <a class="btn btn-primary mx-2" href="/companies">Tilbage</a>
<a class="btn btn-primary mx-2" href="/company/@_company.CompanyId/update">Rediger</a> <a class="btn btn-primary mx-2" href="/company/@DtoNgCrmCompany.CompanyId/update">Rediger</a>
<a class="btn btn-primary mx-2" href="/company/@_company.CompanyId/activity">Aktivitet</a> <a class="btn btn-primary mx-2" href="/company/@DtoNgCrmCompany.CompanyId/activity">Aktivitet</a>
</div> </div>
</div> </div>
</div> </div>

View file

@ -35,7 +35,7 @@ public partial class CompanyView : IDisposable
[Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public VatInfoLookupService VatInfoLookup { get; set; } [Inject] public VatInfoLookupService VatInfoLookup { get; set; }
[Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string CompanyId { get; set; } = "";
private CompanyDto _company { get; set; } = new (); private DtoNgCrmCompany DtoNgCrmCompany { get; set; } = new ();
private string _vatState { get; set; } = "the-dead"; private string _vatState { get; set; } = "the-dead";
private bool _hasFolded { get; set; } private bool _hasFolded { get; set; }
@ -43,15 +43,15 @@ public partial class CompanyView : IDisposable
{ {
Interceptor.RegisterEvent(); Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent(); Interceptor.RegisterBeforeSendEvent();
_company = await CompanyRepo.GetCompanyById(CompanyId); DtoNgCrmCompany = await CompanyRepo.GetCompanyById(CompanyId);
if(_company.HasFolded == 1) if(DtoNgCrmCompany.HasFolded == 1)
{ {
_hasFolded = true; _hasFolded = true;
} }
else else
{ {
_vatState = VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber) ? "the-good" : "the-draw"; _vatState = VatUtils.ValidateFormat(DtoNgCrmCompany.CountryCode, DtoNgCrmCompany.VatNumber) ? "the-good" : "the-draw";
} }
} }

View file

@ -19,7 +19,7 @@
@using Microsoft.AspNetCore.Authorization @using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Adviser")] @attribute [Authorize(Roles = "Adviser")]
@using Wonky.Client.Components @using Wonky.Client.Components
@if (_company != null) @if (_dtoNgCrmCompany != null)
{ {
<h2>@_poDraft.Name</h2> <h2>@_poDraft.Name</h2>
<EditForm EditContext="_createActivity" OnValidSubmit="CreateActivity"> <EditForm EditContext="_createActivity" OnValidSubmit="CreateActivity">
@ -43,9 +43,9 @@
<div class="col-sm-3 col-md-3"> <div class="col-sm-3 col-md-3">
<select id="activityType" class="form-select" @bind-Value="@_poDraft.ActivityType" @bind-Value:event="oninput" @onchange="CheckActivity"> <select id="activityType" class="form-select" @bind-Value="@_poDraft.ActivityType" @bind-Value:event="oninput" @onchange="CheckActivity">
<option value="" selected>--type--</option> <option value="" selected>--type--</option>
<option value="onSite">Besøg</option> <option value="caOnSite">Besøg</option>
<option value="phone">Telefon</option> <option value="caPhone">Telefon</option>
<option value="canvas">Kanvas</option> <option value="caCanvas">Kanvas</option>
</select> </select>
</div> </div>
<div class="col-sm-3 col-md-3"> <div class="col-sm-3 col-md-3">
@ -254,7 +254,7 @@
<td>@cItem.Item.Sku</td> <td>@cItem.Item.Sku</td>
<td class="text-end">@cItem.Quantity</td> <td class="text-end">@cItem.Quantity</td>
<td class="text-end">@cItem.Price</td> <td class="text-end">@cItem.Price</td>
<td class="text-end">@cItem.Total</td> <td class="text-end">@cItem.LineTotal</td>
<td> <td>
<button class="btn btn-warning" @onclick="@(() => RemoveItem(@cItem))">Slet</button> <button class="btn btn-warning" @onclick="@(() => RemoveItem(@cItem))">Slet</button>
</td> </td>
@ -329,7 +329,7 @@
<div class="row mt-2 mb-2"> <div class="row mt-2 mb-2">
<div class="col"> <div class="col">
<a class="btn btn-primary" href="/company/@_company.CompanyId">Tilbage</a> <a class="btn btn-primary" href="/company/@_dtoNgCrmCompany.CompanyId">Tilbage</a>
</div> </div>
<div class="col"> <div class="col">
<button type="submit" class="btn btn-dark" disabled="@InvalidCanvas">Kanvas</button> <button type="submit" class="btn btn-dark" disabled="@InvalidCanvas">Kanvas</button>

View file

@ -39,12 +39,12 @@ public partial class CrmActivityCreate : IDisposable
[Inject] private UserPreferenceService UserPrefs { get; set; } [Inject] private UserPreferenceService UserPrefs { get; set; }
[CascadingParameter] DraftStateProvider DraftStateProvider { get; set; } [CascadingParameter] DraftStateProvider DraftStateProvider { get; set; }
[Parameter] public string CompanyId { get; set; } [Parameter] public string CompanyId { get; set; }
private SalesItemDto _selectedItem { get; set; } = new(); private NgSalesItemView _selectedItem { get; set; } = new();
private List<SalesItemDto> SalesItems { get; set; } = new(); private List<NgSalesItemView> SalesItems { get; set; } = new();
// private MetaData _meta { get; set; } = new(); // private MetaData _meta { get; set; } = new();
private Preferences _prefs { get; set; } = new(); private Preferences _prefs { get; set; } = new();
private ActivityHead _poDraft { get; set; } = new(); private DtoNgSalesHead _poDraft { get; set; } = new();
private CompanyDto _company = new(); private DtoNgCrmCompany _dtoNgCrmCompany = new();
private CatalogPagingParams _paging = new(); private CatalogPagingParams _paging = new();
private EditContext _createActivity { get; set; } private EditContext _createActivity { get; set; }
private bool _poFormInvalid { get; set; } = true; private bool _poFormInvalid { get; set; } = true;
@ -56,6 +56,7 @@ public partial class CrmActivityCreate : IDisposable
private bool InvalidActivity { get; set; } = true; private bool InvalidActivity { get; set; } = true;
private bool InvalidCanvas { get; set; } = true; private bool InvalidCanvas { get; set; } = true;
private bool InvalidDate { get; set; } = true; private bool InvalidDate { get; set; } = true;
private UserInfoView Ux { get; set; } = new();
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -64,32 +65,31 @@ public partial class CrmActivityCreate : IDisposable
_prefs = await UserPrefs.GetPreferences(); _prefs = await UserPrefs.GetPreferences();
_paging.SearchColumn = _prefs.ItemSearch; _paging.SearchColumn = _prefs.ItemSearch;
await GetSalesItems(); await GetSalesItems();
var ux = await StorageService.GetItemAsync<UserInfo>("_ux"); Ux = await StorageService.GetItemAsync<UserInfoView>("_ux");
_company = await CompanyRepo.GetCompanyById(CompanyId); _dtoNgCrmCompany = await CompanyRepo.GetCompanyById(CompanyId);
_createActivity = new EditContext(_poDraft); _createActivity = new EditContext(_poDraft);
_createActivity.OnFieldChanged += HandleFieldChanged; _createActivity.OnFieldChanged += HandleFieldChanged;
// set up indexdb identification // set up indexdb identification
_poDraft.ActivityId = CompanyId; _poDraft.SalesHeadId = Guid.NewGuid().ToString();
_poDraft.CrmCompanyKey = CompanyId; _poDraft.CompanyId = CompanyId;
_poDraft.ActivityDate = string.IsNullOrWhiteSpace(_prefs.WorkDate) _poDraft.ActivityDate = string.IsNullOrWhiteSpace(_prefs.WorkDate)
? DateTime.Now ? DateTime.Now
: DateTime.Parse(_prefs.WorkDate); : DateTime.Parse(_prefs.WorkDate);
// permanent identifications // permanent identifications
_poDraft.SalesRep = ux.Adviser; _poDraft.SalesRep = Ux.Adviser;
_poDraft.Account = _company.Account; _poDraft.Account = _dtoNgCrmCompany.Account;
_poDraft.VatNumber = _company.VatNumber; _poDraft.VatNumber = _dtoNgCrmCompany.VatNumber;
_poDraft.EMail = _company.Email; _poDraft.EMail = _dtoNgCrmCompany.Email;
_poDraft.Phone = _company.Phone; _poDraft.Phone = _dtoNgCrmCompany.Phone;
_poDraft.OurRef = ux.FullName.Split(" ")[0];
_poDraft.Name = _company.Name; _poDraft.Name = _dtoNgCrmCompany.Name;
_poDraft.Address = _company.Address1; _poDraft.Address = _dtoNgCrmCompany.Address1;
_poDraft.Address2 = _company.Address2; _poDraft.Address2 = _dtoNgCrmCompany.Address2;
_poDraft.ZipCode = _company.ZipCode; _poDraft.ZipCode = _dtoNgCrmCompany.ZipCode;
_poDraft.City = _company.City; _poDraft.City = _dtoNgCrmCompany.City;
_poDraft.DlvName = ""; _poDraft.DlvName = "";
_poDraft.DlvAddress1 = ""; _poDraft.DlvAddress1 = "";
@ -111,17 +111,24 @@ public partial class CrmActivityCreate : IDisposable
{ {
// write work date to preference // write work date to preference
await UserPrefs.SetWorkDate(_poDraft.ActivityDate); await UserPrefs.SetWorkDate(_poDraft.ActivityDate);
var activityType = _poDraft.ActivityType switch
{
"caPhone" => "Tlf. ",
"caOnSite" => "Bsg. ",
_ => ""
};
_poDraft.OurRef = $"{activityType}{Ux.FullName.Split(" ")[0]}";
var ln = 0; var ln = 0;
// post to create activity endpoint // post to create activity endpoint
foreach (var line in DraftStateProvider.Draft.Items.Select(item => new ActivityLine foreach (var line in DraftStateProvider.Draft.Items.Select(item => new DtoNgSalesLine
{ {
Price = item.Price, Price = item.Price,
Discount = item.Discount, Discount = item.Discount,
Qty = item.Quantity, Qty = item.Quantity,
Sku = item.Item.Sku, Sku = item.Item.Sku,
Text = item.Item.Name, Text = item.Item.Name,
LineAmount = item.Total, LineAmount = item.LineTotal,
LineNumber = ++ln LineNumber = ++ln
})) }))
{ {
@ -156,13 +163,13 @@ public partial class CrmActivityCreate : IDisposable
Quantity = quantity; Quantity = quantity;
} }
private async Task AddItem(SalesItemDto salesItem) private async Task AddItem(NgSalesItemView ngSalesItem)
{ {
ShowItem = false; ShowItem = false;
// create a new cart item // create a new cart item
var item = new DraftItem var item = new DraftItem
{ {
Item = salesItem, Item = ngSalesItem,
Quantity = Convert.ToInt32(Quantity), Quantity = Convert.ToInt32(Quantity),
Price = Convert.ToDecimal(Price) Price = Convert.ToDecimal(Price)
}; };
@ -180,14 +187,14 @@ public partial class CrmActivityCreate : IDisposable
} }
private async Task SetItemGroup(string groupFilter) private async Task SetItemGroup(string groupFilter)
{ {
SalesItems = new List<SalesItemDto>(); SalesItems = new List<NgSalesItemView>();
_paging.PageNumber = 1; _paging.PageNumber = 1;
_paging.SelectGroup = groupFilter; _paging.SelectGroup = groupFilter;
await GetSalesItems(); await GetSalesItems();
} }
private async Task SetSearchCol(string columnName) private async Task SetSearchCol(string columnName)
{ {
SalesItems = new List<SalesItemDto>(); SalesItems = new List<NgSalesItemView>();
_paging.PageNumber = 1; _paging.PageNumber = 1;
_paging.SearchTerm = ""; _paging.SearchTerm = "";
_paging.SearchColumn = columnName; _paging.SearchColumn = columnName;
@ -195,7 +202,7 @@ public partial class CrmActivityCreate : IDisposable
} }
private async Task SetSortCol(string searchTerm) private async Task SetSortCol(string searchTerm)
{ {
SalesItems = new List<SalesItemDto>(); SalesItems = new List<NgSalesItemView>();
_paging.PageNumber = 1; _paging.PageNumber = 1;
_paging.SearchTerm = searchTerm; _paging.SearchTerm = searchTerm;
await GetSalesItems(); await GetSalesItems();
@ -219,7 +226,7 @@ public partial class CrmActivityCreate : IDisposable
{ {
if (!string.IsNullOrEmpty(_poDraft.VatNumber)) if (!string.IsNullOrEmpty(_poDraft.VatNumber))
{ {
if(!VatUtils.ValidateFormat(_company.CountryCode, _poDraft.VatNumber)) if(!VatUtils.ValidateFormat(_dtoNgCrmCompany.CountryCode, _poDraft.VatNumber))
ToastService.ShowWarning("CVR / ORG nummer er ikke et gyldigt registreringsnummer"); ToastService.ShowWarning("CVR / ORG nummer er ikke et gyldigt registreringsnummer");
} }
if (string.IsNullOrEmpty(_poDraft.ActivityType)) if (string.IsNullOrEmpty(_poDraft.ActivityType))

View file

@ -28,22 +28,22 @@
} }
</div> </div>
} }
<EditForm Model="_userAuthenticationDto" OnValidSubmit="ExecuteLogin" class="card card-body bg-light mt-5"> <EditForm Model="_dtoUserAuthentication" OnValidSubmit="ExecuteLogin" class="card card-body bg-light mt-5">
<DataAnnotationsValidator /> <DataAnnotationsValidator />
<div class="form-group row"> <div class="form-group row">
<label for="email" class="col-md-2 col-form-label">Login</label> <label for="email" class="col-md-2 col-form-label">Login</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText type="email" id="email" class="form-control" <InputText type="email" id="email" class="form-control"
@bind-Value="_userAuthenticationDto.Email" autocomplete="username" /> @bind-Value="_dtoUserAuthentication.Email" autocomplete="username" />
<ValidationMessage For="@(() => _userAuthenticationDto.Email)" /> <ValidationMessage For="@(() => _dtoUserAuthentication.Email)" />
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="password" class="col-md-2 col-form-label">Kode</label> <label for="password" class="col-md-2 col-form-label">Kode</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText type="password" id="password" class="form-control" <InputText type="password" id="password" class="form-control"
@bind-Value="_userAuthenticationDto.Password" autocomplete="current-password" /> @bind-Value="_dtoUserAuthentication.Password" autocomplete="current-password" />
<ValidationMessage For="@(() => _userAuthenticationDto.Password)" /> <ValidationMessage For="@(() => _dtoUserAuthentication.Password)" />
</div> </div>
</div> </div>
<div class="row"> <div class="row">

View file

@ -25,7 +25,7 @@ public partial class Login
[Inject] public NavigationManager NavigationManager { get; set; } [Inject] public NavigationManager NavigationManager { get; set; }
[Inject] public IAuthenticationService AuthenticationService { get; set; } [Inject] public IAuthenticationService AuthenticationService { get; set; }
[Parameter] public string ReturnUrl { get; set; } = ""; [Parameter] public string ReturnUrl { get; set; } = "";
private UserAuthenticationDto _userAuthenticationDto = new (); private DtoUserAuthentication _dtoUserAuthentication = new ();
private bool ShowAuthError { get; set; } private bool ShowAuthError { get; set; }
private string? Error { get; set; } private string? Error { get; set; }
private bool execLogin = false; private bool execLogin = false;
@ -35,7 +35,7 @@ public partial class Login
ShowAuthError = false; ShowAuthError = false;
execLogin = true; execLogin = true;
var result = await AuthenticationService.Login(_userAuthenticationDto); var result = await AuthenticationService.Login(_dtoUserAuthentication);
if (!result.IsSuccess) if (!result.IsSuccess)
{ {
Error = result.ErrorMessage; Error = result.ErrorMessage;

View file

@ -33,7 +33,7 @@ public partial class SalesItemCatalog : IDisposable
[Inject] public ISalesItemHttpRepository SalesItemRepo { get; set; } [Inject] public ISalesItemHttpRepository SalesItemRepo { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] private UserPreferenceService UserPreferenceService { get; set; } [Inject] private UserPreferenceService UserPreferenceService { get; set; }
private List<SalesItemDto> SalesItems { get; set; } = new(); private List<NgSalesItemView> SalesItems { get; set; } = new();
private MetaData? MetaData { get; set; } = new(); private MetaData? MetaData { get; set; } = new();
private CatalogPagingParams _paging = new(); private CatalogPagingParams _paging = new();
private Preferences _preferences = new(); private Preferences _preferences = new();
@ -52,7 +52,7 @@ public partial class SalesItemCatalog : IDisposable
private async Task SelectedPage(int page) private async Task SelectedPage(int page)
{ {
SalesItems = new List<SalesItemDto>(); SalesItems = new List<NgSalesItemView>();
_paging.PageNumber = page; _paging.PageNumber = page;
await GetSalesItems(); await GetSalesItems();
} }
@ -66,7 +66,7 @@ public partial class SalesItemCatalog : IDisposable
private async Task SetPageSize(string pageSize) private async Task SetPageSize(string pageSize)
{ {
SalesItems = new List<SalesItemDto>(); SalesItems = new List<NgSalesItemView>();
_paging.PageSize = Convert.ToInt32(pageSize); _paging.PageSize = Convert.ToInt32(pageSize);
_paging.PageNumber = 1; _paging.PageNumber = 1;
await GetSalesItems(); await GetSalesItems();
@ -74,21 +74,21 @@ public partial class SalesItemCatalog : IDisposable
private async Task SetItemGroup(string groupFilter) private async Task SetItemGroup(string groupFilter)
{ {
SalesItems = new List<SalesItemDto>(); SalesItems = new List<NgSalesItemView>();
_paging.PageNumber = 1; _paging.PageNumber = 1;
_paging.SelectGroup = groupFilter; _paging.SelectGroup = groupFilter;
await GetSalesItems(); await GetSalesItems();
} }
private async Task SetSearchCol(string columnName) private async Task SetSearchCol(string columnName)
{ {
SalesItems = new List<SalesItemDto>(); SalesItems = new List<NgSalesItemView>();
_paging.PageNumber = 1; _paging.PageNumber = 1;
_paging.SearchColumn = columnName; _paging.SearchColumn = columnName;
await GetSalesItems(); await GetSalesItems();
} }
private async Task SetSearchPhrase(string searchTerm) private async Task SetSearchPhrase(string searchTerm)
{ {
SalesItems = new List<SalesItemDto>(); SalesItems = new List<NgSalesItemView>();
_paging.PageNumber = 1; _paging.PageNumber = 1;
_paging.SearchTerm = searchTerm; _paging.SearchTerm = searchTerm;
await GetSalesItems(); await GetSalesItems();
@ -96,7 +96,7 @@ public partial class SalesItemCatalog : IDisposable
private async Task SetSortCol(string orderBy) private async Task SetSortCol(string orderBy)
{ {
SalesItems = new List<SalesItemDto>(); SalesItems = new List<NgSalesItemView>();
_paging.OrderBy = orderBy; _paging.OrderBy = orderBy;
await GetSalesItems(); await GetSalesItems();
} }

View file

@ -24,7 +24,7 @@ namespace Wonky.Client.Pages;
public partial class SalesItemView : IDisposable public partial class SalesItemView : IDisposable
{ {
private SalesItemDto Item { get; set; } = new (); private NgSalesItemView Item { get; set; } = new ();
[Inject] [Inject]
public ISalesItemHttpRepository SalesItemRepo { get; set; } public ISalesItemHttpRepository SalesItemRepo { get; set; }

View file

@ -44,7 +44,7 @@ namespace Wonky.Client.Providers
return _anonymous; return _anonymous;
// create an authorized user // create an authorized user
var userInfo = await _storage.GetItemAsync<UserInfo>("_ux"); var userInfo = await _storage.GetItemAsync<UserInfoView>("_ux");
if (userInfo == null) if (userInfo == null)
return _anonymous; return _anonymous;
@ -79,7 +79,7 @@ namespace Wonky.Client.Providers
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", token); _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", token);
// create an authorized user // create an authorized user
var userInfo = await _storage.GetItemAsync<UserInfo>("_ux"); var userInfo = await _storage.GetItemAsync<UserInfoView>("_ux");
var exp = await _storage.GetItemAsync<string>("_ex"); var exp = await _storage.GetItemAsync<string>("_ex");
var roles = ExtractRoles(userInfo); var roles = ExtractRoles(userInfo);
var claims = new List<Claim> var claims = new List<Claim>
@ -105,18 +105,18 @@ namespace Wonky.Client.Providers
NotifyAuthenticationStateChanged(authState); NotifyAuthenticationStateChanged(authState);
} }
private static IEnumerable<string> ExtractRoles(UserInfo userInfo) private static IEnumerable<string> ExtractRoles(UserInfoView userInfoView)
{ {
var roles = new List<string>(); var roles = new List<string>();
if (userInfo.IsAdmin) if (userInfoView.IsAdmin)
roles.Add("Admin"); roles.Add("Admin");
if (userInfo.IsAdviser) if (userInfoView.IsAdviser)
roles.Add("Adviser"); roles.Add("Adviser");
if (userInfo.IsSupervisor) if (userInfoView.IsSupervisor)
roles.Add("Supervisor"); roles.Add("Supervisor");
if(userInfo.IsEDoc) if(userInfoView.IsEDoc)
roles.Add("EDoc"); roles.Add("EDoc");
if (userInfo.IsEShop) if (userInfoView.IsEShop)
roles.Add("EShop"); roles.Add("EShop");
return roles; return roles;
} }

View file

@ -43,29 +43,29 @@ namespace Wonky.Client.Services
_apiConfig = apiConfig; _apiConfig = apiConfig;
} }
public async Task<ResponseDto> RegisterUser(UserRegistrationDto userRegistrationDto) public async Task<ApiResponseView> RegisterUser(DtoNgUserRegistration dtoNgUserRegistration)
{ {
var response = await _client var response = await _client
.PostAsJsonAsync(_apiConfig.Value.UserRegistration, userRegistrationDto); .PostAsJsonAsync(_apiConfig.Value.UserRegistration, dtoNgUserRegistration);
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
return new ResponseDto {IsSuccess = true}; return new ApiResponseView {IsSuccess = true};
var content = await response.Content var content = await response.Content
.ReadAsStringAsync() .ReadAsStringAsync()
; ;
var result = JsonSerializer.Deserialize<ResponseDto>(content, _options); var result = JsonSerializer.Deserialize<ApiResponseView>(content, _options);
return result ?? new ResponseDto(); return result ?? new ApiResponseView();
} }
public async Task<AuthResponseDto> Login(UserAuthenticationDto userAuth) public async Task<AuthResponseView> Login(DtoUserAuthentication dtoUserAuth)
{ {
var credentials = new Dictionary<string, string> var credentials = new Dictionary<string, string>
{ {
["grant_type"] = "password", ["grant_type"] = "password",
["username"] = userAuth.Email, ["username"] = dtoUserAuth.Email,
["password"] = userAuth.Password ["password"] = dtoUserAuth.Password
}; };
var response = await _client var response = await _client
.PostAsync(_apiConfig.Value.TokenPath, new FormUrlEncodedContent(credentials)); .PostAsync(_apiConfig.Value.TokenPath, new FormUrlEncodedContent(credentials));
@ -74,10 +74,10 @@ namespace Wonky.Client.Services
// if not success - return error status // if not success - return error status
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
return new AuthResponseDto {IsSuccess = false, ErrorMessage = $"Kontroller indtastning"}; return new AuthResponseView {IsSuccess = false, ErrorMessage = $"Kontroller indtastning"};
// process response content // process response content
var data = JsonSerializer.Deserialize<AuthResponseDto>(resContent, _options); var data = JsonSerializer.Deserialize<AuthResponseView>(resContent, _options);
await _localStorage.SetItemAsync("_tx", data.AccessToken); await _localStorage.SetItemAsync("_tx", data.AccessToken);
await _localStorage.SetItemAsync("_rx", data.RefreshToken); await _localStorage.SetItemAsync("_rx", data.RefreshToken);
@ -112,7 +112,7 @@ namespace Wonky.Client.Services
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{ {
var resContent = await response.Content.ReadAsStringAsync(); var resContent = await response.Content.ReadAsStringAsync();
var data = JsonSerializer.Deserialize<AuthResponseDto>(resContent, _options); var data = JsonSerializer.Deserialize<AuthResponseView>(resContent, _options);
// set default request headers using access_token // set default request headers using access_token
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", data.AccessToken); _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", data.AccessToken);
@ -140,14 +140,14 @@ namespace Wonky.Client.Services
_client.DefaultRequestHeaders.Authorization = null; _client.DefaultRequestHeaders.Authorization = null;
} }
public async Task<UserInfo> UserInfo(bool write = false) public async Task<UserInfoView> UserInfo(bool write = false)
{ {
var infoResponse = await _client.GetAsync(_apiConfig.Value.UserInfo); var infoResponse = await _client.GetAsync(_apiConfig.Value.UserInfo);
var infoContent = await infoResponse.Content.ReadAsStringAsync(); var infoContent = await infoResponse.Content.ReadAsStringAsync();
var userInfo = JsonSerializer.Deserialize<UserInfo>(infoContent, _options); var userInfo = JsonSerializer.Deserialize<UserInfoView>(infoContent, _options);
if(write) if(write)
await _localStorage.SetItemAsync("_ux", userInfo); await _localStorage.SetItemAsync("_ux", userInfo);
return userInfo ?? new UserInfo(); return userInfo ?? new UserInfoView();
} }
} }

View file

@ -20,11 +20,11 @@ namespace Wonky.Client.Services
{ {
public interface IAuthenticationService public interface IAuthenticationService
{ {
Task<ResponseDto> RegisterUser(UserRegistrationDto userRegistrationDto); Task<ApiResponseView> RegisterUser(DtoNgUserRegistration dtoNgUserRegistration);
Task<AuthResponseDto> Login(UserAuthenticationDto userAuth); Task<AuthResponseView> Login(DtoUserAuthentication dtoUserAuth);
Task Logout(); Task Logout();
Task<string> RefreshToken(); Task<string> RefreshToken();
Task<UserInfo> UserInfo(bool write = false); Task<UserInfoView> UserInfo(bool write = false);
} }
} }

View file

@ -17,7 +17,7 @@ using System.Collections.Generic;
namespace Wonky.Entity.DTO; namespace Wonky.Entity.DTO;
public class ResponseDto public class ApiResponseView
{ {
public bool IsSuccess { get; set; } public bool IsSuccess { get; set; }
public IEnumerable<string>? Errors { get; set; } public IEnumerable<string>? Errors { get; set; }

View file

@ -17,9 +17,8 @@ using System.Text.Json.Serialization;
namespace Wonky.Entity.DTO; namespace Wonky.Entity.DTO;
public class AuthResponseDto public class AuthResponseView
{ {
public bool IsSuccess { get; set; } public bool IsSuccess { get; set; }
public string ErrorMessage { get; set; } = ""; public string ErrorMessage { get; set; } = "";
[JsonPropertyName("access_token")] public string? AccessToken { get; set; } = ""; [JsonPropertyName("access_token")] public string? AccessToken { get; set; } = "";
@ -28,12 +27,4 @@ public class AuthResponseDto
[JsonPropertyName("refresh_token")] public string RefreshToken { get; set; } = ""; [JsonPropertyName("refresh_token")] public string RefreshToken { get; set; } = "";
[JsonPropertyName(".issued")] public string Issued { get; set; } = ""; [JsonPropertyName(".issued")] public string Issued { get; set; } = "";
[JsonPropertyName(".expires")] public string Expires { get; set; } = ""; [JsonPropertyName(".expires")] public string Expires { get; set; } = "";
/*{
"access_token": "",
"token_type": "bearer",
"expires_in": 1209599,
"refresh_token": "",
".issued": "Fri, 14 Jan 2022 07:05:48 GMT",
".expires": "Fri, 28 Jan 2022 07:05:48 GMT"
}*/
} }

View file

@ -15,7 +15,7 @@
namespace Wonky.Entity.DTO; namespace Wonky.Entity.DTO;
public class CreateCompanyResponse public class CreateCompanyResponseView
{ {
} }

View file

@ -1,31 +0,0 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO;
public class CrmActivityHeadDto
{
// Base account info
public string CompanyId { get; set; } = "";
public string Account { get; set; } = "";
public string VatNumber { get; set; } = "";
public string Name { get; set; } = "";
public string Address { get; set; } = "";
public string Address2 { get; set; } = "";
public string City { get; set; }= "";
public string ZipCode { get; set; } = "";
public string SalesRep { get; set; } = "";
public string Phone { get; set; } = "";
public string EMail { get; set; } = "";
// Form entries
public string ReferenceNumber { get; set; } = "";
public string YourRef { get; set; } = "";
public string OurRef { get; set; } = "";
public string OrderMessage { get; set; } = "";
// From company or form entry
public string DlvName { get; set; } = "";
public string DlvAddress1 { get; set; } = "";
public string DlvAddress2 { get; set; } = "";
public string DlvZipCode { get; set; } = "";
public string DlvCity { get; set; } = "";
}

View file

@ -1,29 +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 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.DTO;
public class CrmSalesLines
{
public int ActivityLineId { get; set; }
public int ActivityId { get; set; }
public string Sku { get; set; } = "";
public string Text { get; set; } = "";
public int Qty { get; set; }
public decimal Price { get; set; }
public decimal Discount { get; set; }
public decimal LineAmount { get; set; }
public int LineNumber { get; set; }
}

View file

@ -19,7 +19,7 @@ using System.Text.Json.Serialization;
namespace Wonky.Entity.DTO; namespace Wonky.Entity.DTO;
public class CompanyDto public class DtoNgCrmCompany
{ {
[Required(ErrorMessage = "Navn skal udfyldes")] [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string Name { get; set; } [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")] public string ZipCode { get; set; } [Required(ErrorMessage = "Postnummer skal udfyldes")] [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string ZipCode { get; set; }

View file

@ -13,16 +13,14 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// //
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Wonky.Entity.DTO;
namespace Wonky.Client.Models namespace Wonky.Entity.DTO
{ {
public class ActivityHead public class DtoNgSalesHead
{ {
public string ActivityId { get; set; } = ""; public string SalesHeadId { get; set; } = "";
public string CrmCompanyKey { get; set; } = ""; public string CompanyId { get; set; } = "";
public string SalesRep { get; set; } = ""; public string SalesRep { 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 Account { get; set; } = "";
[MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string Name { get; set; } = ""; [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string Name { get; set; } = "";
@ -50,6 +48,6 @@ namespace Wonky.Client.Models
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string DlvZipCode { 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; } = ""; [MaxLength(30, ErrorMessage = "Du kan højst bruge 30 tegn")] public string DlvCity { get; set; } = "";
// Lines // Lines
public List<ActivityLine> Lines { get; set; } = new(); public List<DtoNgSalesLine> Lines { get; set; } = new();
} }
} }

View file

@ -12,9 +12,9 @@
// You should have received a copy of the Affero GNU General Public License // 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] // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// //
namespace Wonky.Client.Models; namespace Wonky.Entity.DTO;
public class ActivityLine public class DtoNgSalesLine
{ {
public string Sku { get; set; } = ""; public string Sku { get; set; } = "";
public string Text { get; set; } = ""; public string Text { get; set; } = "";
@ -23,4 +23,5 @@ public class ActivityLine
public decimal Discount { get; set; } public decimal Discount { get; set; }
public decimal LineAmount { get; set; } public decimal LineAmount { get; set; }
public int LineNumber { get; set; } public int LineNumber { get; set; }
public bool Sas { get; set; }
} }

View file

@ -17,7 +17,7 @@ using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO; namespace Wonky.Entity.DTO;
public class UpdateCompanyDto public class DtoNgUpdateCompany
{ {
[MaxLength(100)] public string Name { get; set; } = ""; [MaxLength(100)] public string Name { get; set; } = "";
[MaxLength(30)] public string City { get; set; } = ""; [MaxLength(30)] public string City { get; set; } = "";

View file

@ -17,17 +17,12 @@ using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO; namespace Wonky.Entity.DTO;
public class UserRegistrationDto public class DtoNgUserRegistration
{ {
[Required(ErrorMessage = "Login skal angives")] [Required(ErrorMessage = "Login skal angives")] public string? Email { get; set; }
public string? Email { get; set; } [Required(ErrorMessage = "Kode skal angives")] public string? Password { get; set; }
[Required(ErrorMessage = "Kode skal angives")]
public string? Password { get; set; }
[Compare(nameof(Password), ErrorMessage = "Adgangskoder skal være identiske")] [Compare(nameof(Password), ErrorMessage = "Adgangskoder skal være identiske")]
public string? ConfirmPassword { get; set; } public string? ConfirmPassword { get; set; }
public string FirstName { get; set; } = ""; public string FirstName { get; set; } = "";
public string LastName { get; set; } = ""; public string LastName { get; set; } = "";
public string CountryCode { get; set; } = "dk"; public string CountryCode { get; set; } = "dk";

View file

@ -17,11 +17,8 @@ using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO; namespace Wonky.Entity.DTO;
public class UserAuthenticationDto public class DtoUserAuthentication
{ {
[Required(ErrorMessage = "Email skal angives")] [Required(ErrorMessage = "Email skal angives")] public string Email { get; set; } = "";
public string Email { get; set; } = ""; [Required(ErrorMessage = "Password skal angives")] public string Password { get; set; } = "";
[Required(ErrorMessage = "Password skal angives")]
public string Password { get; set; } = "";
} }

View file

@ -19,12 +19,8 @@ namespace Wonky.Entity.DTO;
public class KrvProductDto public class KrvProductDto
{ {
[Required] [Required] public string ProductId { get; set; } = "";
public string ProductId { get; set; } = ""; [Required] public string TradingName { get; set; } = "";
[Required] [Required] public string PictureLink { get; set; } = "";
public string TradingName { get; set; } = ""; [Required] public string ProductCategoryEnum { get; set; } = "";
[Required]
public string PictureLink { get; set; } = "";
[Required]
public string ProductCategoryEnum { get; set; } = "";
} }

View file

@ -19,20 +19,12 @@ namespace Wonky.Entity.DTO;
public class KrvVariantDto public class KrvVariantDto
{ {
[Required] [Required] public string VariantId { get; set; } = "";
public string VariantId { get; set; } = ""; [Required] public string Name { get; set; } = "";
[Required] [Required] public string Sku { get; set; } = "";
public string Name { get; set; } = ""; [Required] public string ErpSku { get; set; } = "";
[Required] [Required] public string ErpName { get; set; } = "";
public string Sku { get; set; } = ""; [Required] public string ShortName { get; set; } = "";
[Required] [Required] public string SdsLink { get; set; } = "";
public string ErpSku { get; set; } = "";
[Required]
public string ErpName { get; set; } = "";
[Required]
public string ShortName { get; set; } = "";
[Required]
public string SdsLink { get; set; } = "";
// [Required]
public string PictureLink { get; set; } = ""; public string PictureLink { get; set; } = "";
} }

View file

@ -17,7 +17,7 @@ using System.Collections.Generic;
namespace Wonky.Entity.DTO; namespace Wonky.Entity.DTO;
public class SalesItemDto public class NgSalesItemView
{ {
public string ItemId { get; set; } = ""; public string ItemId { get; set; } = "";
public string Name { get; set; } = ""; public string Name { get; set; } = "";
@ -25,5 +25,5 @@ public class SalesItemDto
public string ShortName { get; set; } = ""; public string ShortName { get; set; } = "";
public string ProductGroup { get; set; } = ""; public string ProductGroup { get; set; } = "";
public string PictureLink { get; set; } = ""; public string PictureLink { get; set; } = "";
public List<SalesRateDto> Rates { get; set; } = new(); public List<NgSalesRateView> Rates { get; set; } = new();
} }

View file

@ -14,7 +14,7 @@
// //
namespace Wonky.Entity.DTO; namespace Wonky.Entity.DTO;
public class SalesRateDto public class NgSalesRateView
{ {
public string Quantity { get; set; } = ""; public string Quantity { get; set; } = "";
public string Rate { get; set; } = ""; public string Rate { get; set; } = "";

View file

@ -14,7 +14,7 @@
// //
namespace Wonky.Entity.DTO; namespace Wonky.Entity.DTO;
public class RefreshTokenDto public class RefreshTokenView
{ {
public string Token { get; set; } = ""; public string Token { get; set; } = "";
public string RefreshToken { get; set; } = ""; public string RefreshToken { get; set; } = "";

View file

@ -14,7 +14,7 @@
// //
namespace Wonky.Entity.DTO; namespace Wonky.Entity.DTO;
public class UploadResponse public class UploadResponseView
{ {
public string Message { get; set; } = ""; public string Message { get; set; } = "";
} }

View file

@ -17,7 +17,7 @@ using System.Text.Json.Serialization;
namespace Wonky.Entity.DTO; namespace Wonky.Entity.DTO;
public class UserInfo public class UserInfoView
{ {
[JsonPropertyName("Id")] public string Id { get; set; } = ""; [JsonPropertyName("Id")] public string Id { get; set; } = "";
[JsonPropertyName("adviser")] public string Adviser { get; set; } = ""; [JsonPropertyName("adviser")] public string Adviser { get; set; } = "";