This commit is contained in:
Frede Hundewadt 2022-04-13 18:18:01 +02:00
parent be1b81382e
commit 62fe86c403
6 changed files with 94 additions and 95 deletions

View file

@ -24,31 +24,31 @@ namespace Wonky.Client.Models
public string ActivityId { get; set; } = "";
public string CrmCompanyKey { get; set; } = "";
public string SalesRep { get; set; } = "";
public string Account { get; set; } = "";
public string Name { get; set; } = "";
public string City { get; set; }= "";
public string ZipCode { 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(30, ErrorMessage = "Du kan højst bruge 30 tegn")] public string City { get; set; }= "";
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string ZipCode { get; set; } = "";
[Required(ErrorMessage = "Vælg aktivitet")] public string ActivityType { get; set; } = "";
public string OurRef { get; set; } = "";
public string Address { get; set; } = "";
public string Address2 { get; set; } = "";
public string Phone { get; set; } = "";
public string EMail { get; set; } = "";
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string OurRef { get; set; } = "";
[MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string Address { get; set; } = "";
[MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")] public string Address2 { get; set; } = "";
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string Phone { get; set; } = "";
[MaxLength(80, ErrorMessage = "Du kan højst bruge 80 tegn")] public string EMail { get; set; } = "";
// Form entries
public bool CheckDate { get; set; }
public DateTime ActivityDate { get; set; }
public string Demo { get; set; } = "";
public string VatNumber { get; set; } = "";
public string ReferenceNumber { get; set; } = "";
[MaxLength(255, ErrorMessage = "Du kan højst bruge 255 tegn")]public string YourRef { get; set; } = "";
[MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")] public string Demo { get; set; } = "";
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string VatNumber { get; set; } = "";
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string ReferenceNumber { get; set; } = "";
[MaxLength(35, ErrorMessage = "Du kan højst bruge 35 tegn")] public string YourRef { get; set; } = "";
[MaxLength(255, ErrorMessage = "Du kan højst bruge 255 tegn")] public string OrderMessage { get; set; } = "";
public string CrmNote { get; set; } = "";
[MaxLength(255, ErrorMessage = "Du kan højst bruge 255 tegn")] public string CrmNote { get; set; } = "";
// Delivery address form entries
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; } = "";
[MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string DlvName { get; set; } = "";
[MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string DlvAddress1 { get; set; } = "";
[MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")] public string DlvAddress2 { 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; } = "";
// Lines
public List<CrmSalesLines> Lines { get; set; } = new();
}

View file

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

View file

@ -45,7 +45,6 @@ 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()
@ -58,8 +57,6 @@ public partial class CompanyUpdate : IDisposable
NextVisit = DateTime.Parse(_company.NextVisit);
_editContext = new EditContext(_company);
Console.WriteLine(JsonSerializer.Serialize(_company));
if(_company.HasFolded == 1)
{
_vatState = "the-dead";
@ -68,8 +65,6 @@ public partial class CompanyUpdate : IDisposable
{
_vatState = VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber) ? "the-good" : "the-draw";
}
_address.ZipCode = _company.ZipCode;
}
private async Task Update()

View file

@ -40,16 +40,16 @@
<div class="row mb-1">
<label for="activityDate" class="col-sm-2 col-md-2 col-form-label">Aktivitet</label>
<div class="col-sm-3 col-md-3">
<InputDate id="activityDate" class="form-control" @bind-Value="@(_purchaseOrder.ActivityDate)"/>
</div>
<div class="col-sm-3 col-md-3">
<select id="activityType" class="form-select" @bind-value="@_purchaseOrder.ActivityType" @bind-value:event="oninput">
<option value="" selected>vælg</option>
<select id="activityType" class="form-select" @bind-Value="@_purchaseOrder.ActivityType" @bind-Value:event="oninput" required>
<option value="" selected>--type--</option>
<option value="onSite">Besøg</option>
<option value="phone">Telefon</option>
<option value="canvas">Kanvas</option>
</select>
</div>
<div class="col-sm-3 col-md-3">
<InputDate id="activityDate" class="form-control" @bind-Value="@(_purchaseOrder.ActivityDate)"/>
</div>
<div class="col-sm-2 col-md-2">
<InputCheckbox id="checkDate" class="form-check-input" @bind-Value="@_purchaseOrder.CheckDate"></InputCheckbox>
<label for="checkDate" class="form-check-label">Godkendt</label>
@ -104,51 +104,6 @@
</div>
</div>
</div>
@* Section for delivery address *@
<div class="accordion-item">
<h2 class="accordion-header" id="deliveryHeader">
<button class="accordion-button collapsed bg-light" type="button"
data-bs-toggle="collapse" data-bs-target="#deliveryBody"
aria-expanded="false" aria-controls="deliveryBody">
Leveringsadresse
</button>
</h2>
<div id="deliveryBody" class="accordion-collapse collapse"
aria-labelledby="deliveryHeader" data-bs-parent="#crmActivity">
<div class="accordion-body">
<div class="row mb-1">
<label for="dlvName" class="col-md-2 col-form-label">Lev. Navn</label>
<div class="col-md-10">
<InputText id="dlvName" class="form-control" @bind-Value="_purchaseOrder.DlvName"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvAddress1" class="col-md-2 col-form-label">Lev. Adresse</label>
<div class="col-md-10">
<InputText id="dlvAddress1" class="form-control" @bind-Value="_purchaseOrder.DlvAddress1"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvAddress2" class="col-md-2 col-form-label">Lev. Adresse</label>
<div class="col-md-10">
<InputText id="dlvAddress2" class="form-control" @bind-Value="_purchaseOrder.DlvAddress2"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvZipCode" class="col-md-2 col-form-label">Lev. Postnr</label>
<div class="col-md-10">
<InputText id="dlvZipCode" class="form-control" @bind-Value="_purchaseOrder.DlvZipCode"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvCity" class="col-md-2 col-form-label">Lev. Bynavn</label>
<div class="col-md-10">
<InputText id="dlvCity" class="form-control" @bind-Value="_purchaseOrder.DlvCity"/>
</div>
</div>
</div>
</div>
</div>
@* Catalog selection for draft *@
<div class="accordion-item">
<h2 class="accordion-header" id="catalogHeader">
@ -274,7 +229,7 @@
@* Draft lines *@
<div class="accordion-item">
<h2 class="accordion-header" id="draftHeader">
<button class="accordion-button bg-light" type="button"
<button class="accordion-button collapsed bg-light" type="button"
data-bs-toggle="collapse" data-bs-target="#draftBody"
aria-expanded="false" aria-controls="draftBody">
Kladdelinjer <span class="mx-2 draft-expires-msg">Global kladde (udløber efter @(DraftStateProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet)</span>
@ -331,15 +286,60 @@
</div>
</div>
</div>
@* Section for delivery address *@
<div class="accordion-item">
<h2 class="accordion-header" id="deliveryHeader">
<button class="accordion-button collapsed bg-light" type="button"
data-bs-toggle="collapse" data-bs-target="#deliveryBody"
aria-expanded="false" aria-controls="deliveryBody">
Leveringsadresse
</button>
</h2>
<div id="deliveryBody" class="accordion-collapse collapse"
aria-labelledby="deliveryHeader" data-bs-parent="#crmActivity">
<div class="accordion-body">
<div class="row mb-1">
<label for="dlvName" class="col-md-2 col-form-label">Lev. Navn</label>
<div class="col-md-10">
<InputText id="dlvName" class="form-control" @bind-Value="_purchaseOrder.DlvName"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvAddress1" class="col-md-2 col-form-label">Lev. Adresse</label>
<div class="col-md-10">
<InputText id="dlvAddress1" class="form-control" @bind-Value="_purchaseOrder.DlvAddress1"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvAddress2" class="col-md-2 col-form-label">Lev. Adresse</label>
<div class="col-md-10">
<InputText id="dlvAddress2" class="form-control" @bind-Value="_purchaseOrder.DlvAddress2"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvZipCode" class="col-md-2 col-form-label">Lev. Postnr</label>
<div class="col-md-10">
<InputText id="dlvZipCode" class="form-control" @bind-Value="_purchaseOrder.DlvZipCode"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvCity" class="col-md-2 col-form-label">Lev. Bynavn</label>
<div class="col-md-10">
<InputText id="dlvCity" class="form-control" @bind-Value="_purchaseOrder.DlvCity"/>
</div>
</div>
</div>
</div>
</div>
</div>
@* ---------------------------------------------- *@
@* Display action buttons *@
<div class="row mt-2 mb-2">
<div class="col">
<a class="btn btn-primary" href="/company/@_company.CompanyId">Tilbage</a>
<button type="button" class="btn btn-dark" @onclick="CreateActivity" disabled="@(_poFormInvalid || !_purchaseOrder.CheckDate)">Kanvas</button>
<button type="button" class="btn btn-warning" @onclick="CreateActivityOffer" disabled="@(_poFormInvalid || DraftStateProvider.Draft.Items.Count == 0 || !_purchaseOrder.CheckDate)">Tilbud</button>
<button type="button" class="btn btn-success" @onclick="CreateActivityOrder" disabled="@(_poFormInvalid || DraftStateProvider.Draft.Items.Count == 0 || !_purchaseOrder.CheckDate)">Bestilling</button>
<button type="button" class="btn btn-dark" @onclick="CreateActivity" disabled="@InvalidCanvas">Kanvas</button>
<button type="button" class="btn btn-warning" @onclick="CreateActivityOffer" disabled="@InvalidActivity">Tilbud</button>
<button type="button" class="btn btn-success" @onclick="CreateActivityOrder" disabled="@InvalidActivity">Bestilling</button>
</div>
</div>
</EditForm>

View file

@ -46,15 +46,17 @@ public partial class CrmActivityCreate : IDisposable
private Preferences _prefs { get; set; } = new();
private PurchaseOrder _purchaseOrder = new ();
private CompanyDto _company = new();
private EditContext _editContext;
private bool _poFormInvalid = true;
private EditContext _editContext { get; set; }
private MetaData? MetaData { get; set; } = new();
private CatalogPagingParams _paging = new();
private bool ShowItem;
private bool ShowSearchView;
private bool _poFormInvalid { get; set; } = true;
private bool ShowItem { get; set; }
private bool ShowSearchView { get; set; }
private string Quantity = "1";
private string Price = "0";
private string Discount = "0";
private bool InvalidActivity { get; set; } = true;
private bool InvalidCanvas { get; set; } = true;
protected override async Task OnInitializedAsync()
{
@ -71,7 +73,7 @@ public partial class CrmActivityCreate : IDisposable
// set up indexdb identification
_purchaseOrder.ActivityId = CompanyId;
_purchaseOrder.CrmCompanyKey = CompanyId;
_purchaseOrder.ActivityDate = DateTime.Now;
// permanent identifications
_purchaseOrder.SalesRep = ux.Adviser;
_purchaseOrder.Account = _company.Account;
@ -192,6 +194,8 @@ public partial class CrmActivityCreate : IDisposable
private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
{
_poFormInvalid = !_editContext.Validate();
InvalidActivity = string.IsNullOrWhiteSpace(_purchaseOrder.ActivityType) || _poFormInvalid || DraftStateProvider.Draft.Items.Count == 0 || !_purchaseOrder.CheckDate;
InvalidCanvas = string.IsNullOrWhiteSpace(_purchaseOrder.ActivityType) || _poFormInvalid || !_purchaseOrder.CheckDate;
StateHasChanged();
}
private void ValidationChanged(object sender, ValidationStateChangedEventArgs e)

View file

@ -21,20 +21,20 @@ namespace Wonky.Entity.DTO;
public class CompanyDto
{
[Required(ErrorMessage = "Navn skal udyldes")] public string Name { get; set; }
[Required(ErrorMessage = "Postnummer skal udfyldes")] public string ZipCode { get; set; }
[Required(ErrorMessage = "Bynavn skal udfyldes")] public string City { get; set; }
[Required(ErrorMessage = "Navn skal udyldes")] [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 = "Bynavn skal udfyldes")] [MaxLength(30, ErrorMessage = "Du kan højst bruge 30 tegn")] public string City { get; set; }
[Required(ErrorMessage = "ORG/VAT/CVR er ikke et gyldigt nummer")] public string VatNumber { get; set; }
public string CompanyId { get; set; } = "";
public string SalesRepId { get; set; } = "";
public string BcId { get; set; } = "";
public string Address1 { get; set; } = "";
public string Address2 { get; set; } = "";
public string Account { get; set; } = "";
public string Phone { get; set; } = "";
public string Mobile { get; set; } = "";
public string Email { get; set; } = "";
public string Attention { get; set; } = "";
[MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string Address1 { get; set; } = "";
[MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")] public string Address2 { 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 Phone { get; set; } = "";
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string Mobile { get; set; } = "";
[MaxLength(80, ErrorMessage = "Du kan højst bruge 80 tegn")] public string Email { get; set; } = "";
[MaxLength(30, ErrorMessage = "Du kan højst bruge 30 tegn")] public string Attention { get; set; } = "";
public string LastVisit { get; set; } = "";
public string NextVisit { get; set; } = "";
public int Interval { get; set; } = 8;