refactor vat lookup
This commit is contained in:
parent
551c338fcb
commit
2e8deb6bb6
20 changed files with 357 additions and 156 deletions
|
@ -19,7 +19,7 @@ using Wonky.Entity.Views;
|
|||
|
||||
namespace Wonky.Client.Components;
|
||||
|
||||
public partial class OfficeAvisorTableComponent
|
||||
public partial class OfficeAdvisorTableComponent
|
||||
{
|
||||
[Parameter] public List<UserListAdminView> UserList { get; set; }
|
||||
}
|
|
@ -111,7 +111,7 @@
|
|||
</tr>
|
||||
}
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
<td colspan="5"></td>
|
||||
<td>Ordresum</td>
|
||||
<td class="text-end">@ReportItem.OrderAmount</td>
|
||||
</tr>
|
||||
|
@ -129,4 +129,11 @@
|
|||
|
||||
@code{
|
||||
[Parameter] public ReportItemView ReportItem { get; set; } = new();
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
var lines = ReportItem.Lines.OrderBy(x => x.Location).ToList();
|
||||
ReportItem.Lines = lines;
|
||||
}
|
||||
|
||||
}
|
30
Wonky.Client/Components/VatEntityNameInputComponent.razor
Normal file
30
Wonky.Client/Components/VatEntityNameInputComponent.razor
Normal file
|
@ -0,0 +1,30 @@
|
|||
@*
|
||||
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero 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
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||
//
|
||||
*@
|
||||
|
||||
<EditForm EditContext="_editName" OnValidSubmit="SubmitForm">
|
||||
<DataAnnotationsValidator/>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<InputText id="vatNumber" class="form-control" placeholder="26991765"
|
||||
@bind-Value="@EntityName"/>
|
||||
<ValidationMessage For="@(() => EntityName)"/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="btn btn-primary" type="submit" disabled="@_formInvalid">HENT</button>
|
||||
</div>
|
||||
</div>
|
||||
</EditForm>
|
47
Wonky.Client/Components/VatEntityNameInputComponent.razor.cs
Normal file
47
Wonky.Client/Components/VatEntityNameInputComponent.razor.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
// 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 GNU Affero 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
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||
//
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Wonky.Client.Models;
|
||||
|
||||
namespace Wonky.Client.Components;
|
||||
public partial class VatEntityNameInputComponent : IDisposable
|
||||
{
|
||||
[Parameter] public string EntityName { get; set; } = "";
|
||||
private EditContext _editName { get; set; }
|
||||
private bool _formInvalid = true;
|
||||
[Parameter] public EventCallback<string> OnValidSubmit { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_editName = new EditContext(EntityName);
|
||||
_editName.OnFieldChanged += HandleFieldChanged;
|
||||
}
|
||||
private async Task SubmitForm()
|
||||
{
|
||||
await OnValidSubmit.InvokeAsync(EntityName);
|
||||
}
|
||||
private void HandleFieldChanged(object? sender, FieldChangedEventArgs e)
|
||||
{
|
||||
_formInvalid = !_editName.Validate();
|
||||
StateHasChanged();
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_editName!.OnFieldChanged -= HandleFieldChanged;
|
||||
}
|
||||
}
|
|
@ -1,35 +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 GNU Affero 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
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||
//
|
||||
*@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<button class="btn btn-primary text-nowrap" @onclick="GetCvrData" disabled="@CvrInvalid">Vis CVR data</button>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div style="@(_hideMe ? "display:none" : "display:block")">
|
||||
<div class="alert @(_currentState == "NORMAL" ? "alert-success" : "alert-warning")">
|
||||
<strong>CVR status @_currentState</strong>
|
||||
</div>
|
||||
<ul class="list-group list-group-flush small">
|
||||
<li class="list-group-item">@VirkRegInfo.Name</li>
|
||||
<li class="list-group-item">@VirkRegInfo.CoName</li>
|
||||
<li class="list-group-item">@VirkRegInfo.Address</li>
|
||||
<li class="list-group-item">@VirkRegInfo.ZipCode @VirkRegInfo.City</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,45 +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 GNU Affero 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
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||
//
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Wonky.Client.Services;
|
||||
using Wonky.Entity.Models;
|
||||
using Wonky.Entity.Requests;
|
||||
|
||||
namespace Wonky.Client.Components;
|
||||
|
||||
public partial class VatInfoComponent
|
||||
{
|
||||
[Inject] public VatInfoLookupService VatInfoLookupService { get; set; } = null!;
|
||||
[Parameter] public string VatNumber { get; set; } = "";
|
||||
private VirkRegInfo VirkRegInfo { get; set; } = new();
|
||||
private bool _hideMe = true;
|
||||
private bool CvrInvalid => string.IsNullOrEmpty(VatNumber);
|
||||
private readonly VirkParams _virkParams = new();
|
||||
private string _currentState = "";
|
||||
private async Task GetCvrData()
|
||||
{
|
||||
_virkParams.VatNumber = VatNumber;
|
||||
if (string.IsNullOrWhiteSpace(VirkRegInfo.VatNumber))
|
||||
{
|
||||
var result = await VatInfoLookupService.QueryVirkRegistry(_virkParams);
|
||||
if (result.Any())
|
||||
{
|
||||
_currentState = VirkRegInfo.States[^1].State;
|
||||
}
|
||||
}
|
||||
_hideMe = !_hideMe;
|
||||
}
|
||||
}
|
|
@ -111,12 +111,7 @@ public partial class CrmNewActivityPage : IDisposable
|
|||
_company.Phone = _company.Account[..8];
|
||||
}
|
||||
|
||||
// set up identification
|
||||
_draft.CompanyId = _company.CompanyId;
|
||||
_draft.BcId = _company.BcId;
|
||||
_draft.SalesRepId = _ux.Id;
|
||||
_draft.SalesRep = _ux.Advisor;
|
||||
|
||||
_draft.ActivityStatusEnum = "noSale";
|
||||
_draft.VisitTypeEnum = _company.Account is "" or "NY" ? "new" : "recall";
|
||||
|
||||
|
@ -124,7 +119,11 @@ public partial class CrmNewActivityPage : IDisposable
|
|||
_draft.OrderMessage = "Virksomheden er ophørt.";
|
||||
|
||||
// permanent identifications
|
||||
_draft.SalesRep = _ux.Advisor;
|
||||
_draft.CompanyId = _company.CompanyId;
|
||||
_draft.SalesRepId = _company.SalesRepId;
|
||||
_draft.SalesRep = _company.SalesRep;
|
||||
_draft.CountryCode = _company.CountryCode;
|
||||
|
||||
_draft.Account = _company.Account;
|
||||
_draft.VatNumber = _company.VatNumber;
|
||||
_draft.Email = _company.Email;
|
||||
|
@ -142,7 +141,7 @@ public partial class CrmNewActivityPage : IDisposable
|
|||
_draft.DlvAddress2 = _company.Address2;
|
||||
_draft.DlvZipCode = _company.ZipCode;
|
||||
_draft.DlvCity = _company.City;
|
||||
|
||||
|
||||
}
|
||||
private void CallPriceListModal()
|
||||
{
|
||||
|
@ -244,8 +243,8 @@ public partial class CrmNewActivityPage : IDisposable
|
|||
if (_phone != _draft.Phone)
|
||||
{
|
||||
_company.Phone = _draft.Phone;
|
||||
// update company phone record
|
||||
await _companyRepo.UpdateCompany(_company.CompanyId, _company);
|
||||
// _toast.ShowInfo("Kunde telefon nummer er opdateret.");
|
||||
}
|
||||
// post to api
|
||||
var result = await CrmActivityRepo.CreateActivity(_draft);
|
||||
|
|
|
@ -27,10 +27,14 @@
|
|||
<div class="card-header bg-dark text-white">
|
||||
<h3>@_company.Account - @_company.Name</h3>
|
||||
</div>
|
||||
@*
|
||||
@if (_dk)
|
||||
{
|
||||
<div class="card-body">
|
||||
<VatAddressInputComponent Address="_vatAddress" OnValidSubmit="GetInfoFromAddress"/>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
</div>
|
||||
@if (_vInfos.Any())
|
||||
{
|
||||
|
@ -63,10 +67,11 @@
|
|||
</table>
|
||||
}
|
||||
}
|
||||
*@
|
||||
<EditForm EditContext="_editContext" OnValidSubmit="SubmitUpdate">
|
||||
<DataAnnotationsValidator/>
|
||||
<div class="card-body">
|
||||
<table class="table">
|
||||
<table class="table table-sm">
|
||||
<tbody>
|
||||
<tr class="align-middle">
|
||||
<th>
|
||||
|
@ -78,6 +83,7 @@
|
|||
<td>
|
||||
<InputText id="vatNumber" class="form-control" @bind-Value="_company.VatNumber"/>
|
||||
<ValidationMessage For="@(() => _company.VatNumber)"></ValidationMessage>
|
||||
<button class="btn btn-warning" type="button" @onclick="CallVatLookupModal">CVR opslag</button>
|
||||
</td>
|
||||
<th>
|
||||
Telefon
|
||||
|
@ -223,4 +229,6 @@
|
|||
else
|
||||
{
|
||||
<LoaderThreeDots />
|
||||
}
|
||||
}
|
||||
|
||||
<VatLookupDkModal VatAddress="_vatAddress" OnSelectedCompany="OnSelectedCompany" @ref="_vatLookupModal" />
|
|
@ -27,6 +27,7 @@ using Wonky.Client.Helpers;
|
|||
using Wonky.Client.HttpInterfaces;
|
||||
using Wonky.Client.Models;
|
||||
using Wonky.Client.Services;
|
||||
using Wonky.Client.Shared;
|
||||
using Wonky.Entity.DTO;
|
||||
using Wonky.Entity.Models;
|
||||
using Wonky.Entity.Requests;
|
||||
|
@ -67,6 +68,7 @@ public partial class CrmViewCompanyPage : IDisposable
|
|||
private bool _dk { get; set; } = true;
|
||||
private int _isDirty { get; set; }
|
||||
private int _vatUpdated { get; set; }
|
||||
private VatLookupDkModal _vatLookupModal { get; set; } = new();
|
||||
|
||||
private readonly JsonSerializerOptions _options = new ()
|
||||
{
|
||||
|
@ -200,55 +202,6 @@ public partial class CrmViewCompanyPage : IDisposable
|
|||
}
|
||||
_hideButtons = false;
|
||||
}
|
||||
|
||||
private async Task GetInfoFromAddress(VatAddress address)
|
||||
{
|
||||
_vInfos = await _vatService.QueryVirkRegistry(
|
||||
new VirkParams
|
||||
{
|
||||
StreetName = address.StreetName.Trim(),
|
||||
HouseNumber = address.HouseNumber.Trim(),
|
||||
ZipCode = address.ZipCode.Trim()
|
||||
});
|
||||
|
||||
if (!_vInfos.Any())
|
||||
_toast.ShowError($"Ingen virksomheder fundet.");
|
||||
}
|
||||
|
||||
private void SelectCompany(string vatNumber, bool syncAll)
|
||||
{
|
||||
_virkRegInfo = (from x in _vInfos where x.VatNumber == vatNumber select x).First();
|
||||
_validVat = _virkRegInfo.States[0].State.ToLower() == "normal";
|
||||
_company.HasFolded = _validVat ? 1 : 0;
|
||||
_enableActivity = _validVat ? 1 : 0;
|
||||
_vatState = _virkRegInfo.States[0].State.ToLower() == "normal" ? "the-good" : "the-dead";
|
||||
|
||||
if (syncAll)
|
||||
{
|
||||
_company.VatNumber = _virkRegInfo.VatNumber;
|
||||
_company.Name = _virkRegInfo.Name;
|
||||
_company.Address1 = _virkRegInfo.Address;
|
||||
_company.Address2 = _virkRegInfo.CoName;
|
||||
_company.ZipCode = _virkRegInfo.ZipCode;
|
||||
_company.City = _virkRegInfo.City;
|
||||
_isDirty = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_company.VatNumber = _virkRegInfo.VatNumber;
|
||||
_vatUpdated = 1;
|
||||
}
|
||||
// empty list
|
||||
_vInfos = new List<VirkRegInfo>();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_interceptor.DisposeEvent();
|
||||
_editContext.OnFieldChanged -= HandleFieldChanged;
|
||||
_editContext.OnValidationStateChanged -= ValidationChanged;
|
||||
}
|
||||
|
||||
private static VatAddress PrepareVatAddress(CompanyDto model)
|
||||
{
|
||||
|
@ -278,4 +231,68 @@ public partial class CrmViewCompanyPage : IDisposable
|
|||
// return empty model
|
||||
return new VatAddress();
|
||||
}
|
||||
|
||||
private void CallVatLookupModal()
|
||||
{
|
||||
_vatLookupModal.Show();
|
||||
}
|
||||
private void OnSelectedCompany(VirkRegInfo regInfo)
|
||||
{
|
||||
_validVat = regInfo.States[0].State.ToLower() == "normal";
|
||||
_company.HasFolded = _validVat ? 1 : 0;
|
||||
_enableActivity = _validVat ? 1 : 0;
|
||||
_vatState = regInfo.States[0].State.ToLower() == "normal" ? "the-good" : "the-dead";
|
||||
|
||||
if (regInfo.SyncAll)
|
||||
{
|
||||
_company.VatNumber = this._virkRegInfo.VatNumber;
|
||||
_company.Name = this._virkRegInfo.Name;
|
||||
_company.Address1 = this._virkRegInfo.Address;
|
||||
_company.Address2 = this._virkRegInfo.CoName;
|
||||
_company.ZipCode = this._virkRegInfo.ZipCode;
|
||||
_company.City = this._virkRegInfo.City;
|
||||
_isDirty = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_company.VatNumber = this._virkRegInfo.VatNumber;
|
||||
_vatUpdated = 1;
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
// private void SelectCompany(string vatNumber, bool syncAll)
|
||||
// {
|
||||
// _virkRegInfo = (from x in _vInfos where x.VatNumber == vatNumber select x).First();
|
||||
// _validVat = _virkRegInfo.States[0].State.ToLower() == "normal";
|
||||
// _company.HasFolded = _validVat ? 1 : 0;
|
||||
// _enableActivity = _validVat ? 1 : 0;
|
||||
// _vatState = _virkRegInfo.States[0].State.ToLower() == "normal" ? "the-good" : "the-dead";
|
||||
//
|
||||
// if (syncAll)
|
||||
// {
|
||||
// _company.VatNumber = _virkRegInfo.VatNumber;
|
||||
// _company.Name = _virkRegInfo.Name;
|
||||
// _company.Address1 = _virkRegInfo.Address;
|
||||
// _company.Address2 = _virkRegInfo.CoName;
|
||||
// _company.ZipCode = _virkRegInfo.ZipCode;
|
||||
// _company.City = _virkRegInfo.City;
|
||||
// _isDirty = 1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _company.VatNumber = _virkRegInfo.VatNumber;
|
||||
// _vatUpdated = 1;
|
||||
// }
|
||||
// // empty list
|
||||
// _vInfos = new List<VirkRegInfo>();
|
||||
// StateHasChanged();
|
||||
// }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_interceptor.DisposeEvent();
|
||||
_editContext.OnFieldChanged -= HandleFieldChanged;
|
||||
_editContext.OnValidationStateChanged -= ValidationChanged;
|
||||
}
|
||||
}
|
|
@ -25,6 +25,6 @@
|
|||
<h3>Sælgere</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<OfficeAvisorTableComponent UserList="_salesReps"></OfficeAvisorTableComponent>
|
||||
<OfficeAdvisorTableComponent UserList="_salesReps"></OfficeAdvisorTableComponent>
|
||||
</div>
|
||||
</div>
|
|
@ -24,6 +24,6 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<OfficeCustomerTableComponent Companies="_companyList"></OfficeCustomerTableComponent>
|
||||
<OfficeCustomerTableComponent Companies="_companyList" />
|
||||
</div>
|
||||
</div>
|
|
@ -72,13 +72,8 @@ public partial class OfficeNewOrderPage : IDisposable
|
|||
// set up identification
|
||||
_draft.CompanyId = _company.CompanyId;
|
||||
_draft.BcId = _company.BcId;
|
||||
_draft.SalesRepId = _userInfo.UserId;
|
||||
|
||||
_draft.ActivityStatusEnum = "noSale";
|
||||
_draft.VisitTypeEnum = _company.Account is "" or "NY" ? "new" : "recall";
|
||||
|
||||
// permanent identifications
|
||||
_draft.SalesRep = _userInfo.Advisor;
|
||||
_draft.SalesRepId = _company.SalesRepId;
|
||||
_draft.SalesRep = _company.SalesRep;
|
||||
_draft.Account = _company.Account;
|
||||
_draft.VatNumber = _company.VatNumber;
|
||||
_draft.Email = _company.Email;
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
}
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<a class="btn btn-outline-primary text-nowrap" href="/warehouse/orders/none">Oversigt</a>
|
||||
<a class="btn btn-outline-danger text-nowrap" href="/warehouse/orders/none">Ubehandlet</a>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
</div>
|
||||
|
|
67
Wonky.Client/Shared/VatLookupDkModal.razor
Normal file
67
Wonky.Client/Shared/VatLookupDkModal.razor
Normal file
|
@ -0,0 +1,67 @@
|
|||
@*
|
||||
// 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 GNU Affero 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
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||
//
|
||||
*@
|
||||
|
||||
@using Wonky.Client.Components
|
||||
<div class="modal" tabindex="-1" role="dialog" style="display:@_modalDisplay">
|
||||
<div class="modal-dialog modal-dialog-scrollable modal-lg modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">CVR opslag</h5>
|
||||
<button type="button" class="btn-close" @onclick="Hide" data-bs-dismiss="modal" aria-label="Luk"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<VatNumberInputComponent OnValidSubmit="GetInfoFromVat"/>
|
||||
<VatAddressInputComponent Address="VatAddress" OnValidSubmit="GetInfoFromAddress"/>
|
||||
<VatEntityNameInputComponent OnValidSubmit="GetInfoFromName"/>
|
||||
@if (_vInfos.Any())
|
||||
{
|
||||
<table class="table table-sm table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">CVR ORG</th>
|
||||
<th scope="col">Navn</th>
|
||||
<th scope="col">Status</th>
|
||||
<th scope="col"></th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var info in _vInfos)
|
||||
{
|
||||
<tr>
|
||||
<td class="align-middle">@info.VatNumber</td>
|
||||
<td class="align-middle">@info.Name</td>
|
||||
<td class="align-middle">@info.States[^1].State</td>
|
||||
<td class="align-middle">
|
||||
<button class="btn btn-primary" @onclick="@(() => SelectCompany(info.VatNumber, true))">OVERFØR</button>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<button class="btn btn-primary" @onclick="@(() => SelectCompany(info.VatNumber, false))">CVR/VAT</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@if (_showBackdrop)
|
||||
{
|
||||
<div class="modal-backdrop fade show"></div>
|
||||
}
|
98
Wonky.Client/Shared/VatLookupDkModal.razor.cs
Normal file
98
Wonky.Client/Shared/VatLookupDkModal.razor.cs
Normal file
|
@ -0,0 +1,98 @@
|
|||
// 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 GNU Affero 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
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||
//
|
||||
|
||||
using Blazored.Toast.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpInterfaces;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Client.Models;
|
||||
using Wonky.Client.Services;
|
||||
using Wonky.Entity.Models;
|
||||
using Wonky.Entity.Requests;
|
||||
using Wonky.Entity.Views;
|
||||
|
||||
namespace Wonky.Client.Shared;
|
||||
|
||||
public partial class VatLookupDkModal
|
||||
{
|
||||
private string _modalDisplay = "";
|
||||
private bool _showBackdrop;
|
||||
[Parameter] public VatAddress VatAddress { get; set; } = new();
|
||||
[Parameter] public EventCallback<VirkRegInfo> OnSelectedCompany { get; set; }
|
||||
[Inject] private VatInfoLookupService _vatService { get; set; }
|
||||
[Inject] private IToastService _toast { get; set; }
|
||||
private VirkRegInfo _virkRegInfo { get; set; } = new();
|
||||
private List<VirkRegInfo> _vInfos { get; set; } = new();
|
||||
|
||||
private async Task SelectCompany(string vatNumber, bool syncAll)
|
||||
{
|
||||
_virkRegInfo = _vInfos.First(x => x.VatNumber == vatNumber);
|
||||
_virkRegInfo.SyncAll = syncAll;
|
||||
await OnSelectedCompany.InvokeAsync(_virkRegInfo);
|
||||
}
|
||||
|
||||
private async Task GetInfoFromAddress(VatAddress address)
|
||||
{
|
||||
_toast.ShowInfo("Vent for adresse info ...");
|
||||
_vInfos = await _vatService.QueryVirkRegistry(
|
||||
new VirkParams
|
||||
{
|
||||
StreetName = address.StreetName,
|
||||
HouseNumber = address.HouseNumber,
|
||||
ZipCode = address.ZipCode
|
||||
});
|
||||
if (!_vInfos.Any())
|
||||
{
|
||||
_toast.ShowWarning($"Ingen data fundet ...");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task GetInfoFromVat(string vatNumber)
|
||||
{
|
||||
_toast.ShowInfo("Vent for firma info ...");
|
||||
_vInfos = await _vatService
|
||||
.QueryVirkRegistry(new VirkParams {VatNumber = vatNumber});
|
||||
if (!_vInfos.Any())
|
||||
{
|
||||
_toast.ShowError($"Firma med CVR '{vatNumber}' findes ikke.");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task GetInfoFromName(string entityName)
|
||||
{
|
||||
_toast.ShowInfo("Vent for firma info ...");
|
||||
_vInfos = await _vatService
|
||||
.QueryVirkRegistry(new VirkParams {EntityName = entityName});
|
||||
if (!_vInfos.Any())
|
||||
{
|
||||
_toast.ShowError($"Firma med nav '{entityName}' findes ikke.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
_modalDisplay = "block;";
|
||||
_showBackdrop = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void Hide()
|
||||
{
|
||||
_modalDisplay = "none;";
|
||||
_showBackdrop = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"appInfo": {
|
||||
"name": "Wonky Client",
|
||||
"version": "0.16.1",
|
||||
"version": "0.19.1",
|
||||
"rc": true,
|
||||
"sandBox": true,
|
||||
"image": "grumpy-coder.png"
|
||||
|
@ -29,7 +29,7 @@
|
|||
"officeUserPasswd": "api/v2/office/users/passwd",
|
||||
"officeCustomers": "api/v2/office/customers",
|
||||
"officeReports": "api/v2/office/reports",
|
||||
"warehouse": "api/v2/warehouse/orders"
|
||||
"warehouse": "api/v2/warehouse/packages"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
|
|
@ -23,18 +23,23 @@ public class ActivityDto
|
|||
/// Activity entity id
|
||||
/// </summary>
|
||||
public string ActivityId { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Sales representative identification
|
||||
/// </summary>
|
||||
public string SalesRep { get; set; } = "";
|
||||
[Required] public string SalesRep { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Sales representative entity Id
|
||||
/// </summary>
|
||||
public string SalesRepId { get; set; } = "";
|
||||
[Required] public string SalesRepId { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Company countryCode (ensure correct code when office create ordre)
|
||||
/// </summary>
|
||||
[Required] public string CountryCode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Company entity Id
|
||||
/// </summary>
|
||||
public string CompanyId { get; set; } = "";
|
||||
[Required] public string CompanyId { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Business Central entity Id
|
||||
/// </summary>
|
||||
|
|
|
@ -57,6 +57,12 @@ public class CompanyDto
|
|||
/// Sales representative entity Id
|
||||
/// </summary>
|
||||
public string SalesRepId { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// SalesRep ERP identifier
|
||||
/// </summary>
|
||||
public string SalesRep { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Business Central entity Id
|
||||
/// </summary>
|
||||
|
|
|
@ -60,4 +60,6 @@ public class VirkRegInfo
|
|||
/// Date for last request of entity VAT state
|
||||
/// </summary>
|
||||
public string RequestDate { get; set; } = "" ;
|
||||
|
||||
public bool SyncAll { get; set; }
|
||||
}
|
Loading…
Reference in a new issue