This commit is contained in:
FH 2022-04-13 12:48:50 +02:00
parent c13d484d65
commit 5c52f97ce9
7 changed files with 30 additions and 37 deletions

View file

@ -20,7 +20,7 @@ using Wonky.Client.Models;
namespace Wonky.Client.Components;
public partial class VatAddressInputComponent : IDisposable
{
private VatAddress Address { get; set; } = new();
[Parameter] public VatAddress Address { get; set; } = new();
private EditContext? _editAddress;
private bool _formInvalid = true;
[Parameter] public EventCallback<VatAddress> OnValidSubmit { get; set; }

View file

@ -20,7 +20,7 @@ using Wonky.Client.Models;
namespace Wonky.Client.Components;
public partial class VatNumberInputComponent : IDisposable
{
private string VatNumber { get; set; } = "";
[Parameter] public string VatNumber { get; set; } = "";
private EditContext? _editVatNumber;
private bool _formInvalid = true;

View file

@ -27,10 +27,10 @@
<div class="h2">@_company.Account - @_company.Name</div>
</div>
<div class="card-body">
<VatNumberInputComponent OnValidSubmit="GetInfoFromVat"/>
<VatNumberInputComponent VatNumber="@_company.VatNumber" OnValidSubmit="GetInfoFromVat"/>
</div>
<div class="card-body">
<VatAddressInputComponent OnValidSubmit="GetInfoFromAddress"/>
<VatAddressInputComponent Address="@_address" OnValidSubmit="GetInfoFromAddress"/>
</div>
@if (VInfos.Any())
{

View file

@ -45,6 +45,7 @@ public partial class CompanyUpdate : IDisposable
private VirkRegInfo _virkRegInfo { get; set; } = new();
private DateTime LastVisit { get; set; }
private DateTime NextVisit { get; set; }
private VatAddress _address { get; set; } = new();
private string _vatState { get; set; } = "the-ugly";
protected override async Task OnInitializedAsync()
@ -66,12 +67,14 @@ public partial class CompanyUpdate : IDisposable
else
{
_vatState = VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber) ? "the-good" : "the-draw";
}
}
_address.ZipCode = _company.ZipCode;
}
private async Task Update()
{
if (!VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber))
if (!string.IsNullOrWhiteSpace(_company.VatNumber) && !VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber))
{
ToastService.ShowError($"CVR/VAT/ORG nummer er ugyldig.");
StateHasChanged();

View file

@ -33,6 +33,7 @@ public partial class CompanyView : IDisposable
[Inject] public VatOwnerLookupService VatOwnerLookup { get; set; }
[Inject] public ILogger<CompanyView> Logger { get; set; }
[Inject] public IToastService ToastService { get; set; }
[Inject] public NavigationManager NavManager { get; set; }
[Parameter] public string CompanyId { get; set; } = "";
private CompanyDto _company { get; set; } = new ();
private string _vatState { get; set; } = "the-dead";
@ -51,18 +52,6 @@ public partial class CompanyView : IDisposable
else
{
_vatState = VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber) ? "the-good" : "the-draw";
if (string.IsNullOrWhiteSpace(_company.VatNumber))
{
ToastService.ShowInfo("CVR / ORG nummer mangler.");
}
else
{
if(_vatState == "the-draw")
ToastService.ShowInfo("CVR / ORG nummer er ugyldigt.");
}
}
}

View file

@ -38,14 +38,19 @@
aria-labelledby="activityHeader" data-bs-parent="#crmActivity">
<div class="accordion-body">
<div class="row mb-1">
<label for="activityType" class="col-md-2 col-form-label" >Aktivitet</label>
<label for="activityDate" class="col-form-label col-md-2">Næste besøg</label>
<div class="col-md-3">
<InputDate id="activityDate" class="form-control" @bind-Value="@(ActivityDate)"/>
</div>
<label for="activityType" class="col-md-2 col-form-label">Aktivitet</label>
<div class="col-md-2">
<select id="activityType" class="form-select" @bind-value="@_purchaseOrder.ActivityType" @bind-value:event="oninput">
<option value="" selected></option>
<option value="onSite">Besøg</option>
<option value="phone">Telefon</option>
<option value="canvas">Kanvas</option>
</select>
</select>
</div>
<label for="account" class="col-md-2 col-form-label">Konto</label>
<div class="col-md-2">

View file

@ -33,16 +33,6 @@ namespace Wonky.Client.Pages;
public partial class CrmActivityCreate : IDisposable
{
private PurchaseOrder _purchaseOrder = new ();
private CompanyDto _company = new();
private EditContext _editContext;
private bool _poFormInvalid = true;
private MetaData? MetaData { get; set; } = new();
private CatalogPagingParams _paging = new();
private bool ShowItem;
private bool ShowSearchView;
private string Quantity = "1";
private string Price = "0";
private SalesItemDto _selectedItem { get; set; } = new();
private List<SalesItemDto> SalesItems { get; set; } = new();
private MetaData _meta { get; set; } = new();
@ -57,13 +47,23 @@ public partial class CrmActivityCreate : IDisposable
[Inject] public NavigationManager NavigationManager { get; set; }
[Inject] public ILocalStorageService StorageService { get; set; }
[Inject] public ISalesItemHttpRepository SalesItemRepo { get; set; }
public List<CrmSalesLines> Lines { get; set; } = new();
private PurchaseOrder _purchaseOrder = new ();
private CompanyDto _company = new();
private EditContext _editContext;
private bool _poFormInvalid = true;
private MetaData? MetaData { get; set; } = new();
private CatalogPagingParams _paging = new();
private bool ShowItem;
private bool ShowSearchView;
private string Quantity = "1";
private string Price = "0";
private DateTime ActivityDate { get; set; }
protected override async Task OnInitializedAsync()
{
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
_prefs = await UserPrefs.GetPreferences();
_paging.SearchColumn = _prefs.ItemSearch;
await GetSalesItems();
@ -94,7 +94,6 @@ public partial class CrmActivityCreate : IDisposable
_purchaseOrder.DlvAddress2 = _company.Address2;
_purchaseOrder.DlvZipCode = _company.ZipCode;
_purchaseOrder.DlvCity = _company.City;
}
private async Task DeleteDraft()
@ -120,10 +119,8 @@ public partial class CrmActivityCreate : IDisposable
Quantity = Convert.ToInt32(Quantity),
Price = Convert.ToDecimal(Price)
};
// add it to the cart
DraftStateProvider.Draft.Items.Add(item);
// save the item using the CartStateProvider's save method
await DraftStateProvider.SaveChangesAsync();
}
@ -178,7 +175,6 @@ public partial class CrmActivityCreate : IDisposable
_purchaseOrder.Lines.Add(line);
}
await StorageService.SetItemAsync(CompanyId, _purchaseOrder);
//ToastService.ShowSuccess($"Aktivitet oprettet.");
}