checking - HTTP repositories

This commit is contained in:
Frede Hundewadt 2023-11-16 18:28:42 +01:00
parent e13c08937e
commit 6776b3ca6d
10 changed files with 205 additions and 172 deletions

View file

@ -53,7 +53,7 @@
</div>
<div class="col-sm-3">
<button type="button" class="btn btn-outline-dark me-2" @onclick="@(() => SetQuote(quote.ESalesNumber, QuoteStatus.Lose))">
<i class="bi-trash-fill"></i>
<i class="bi-trash-2-fill"></i>
</button>
<button type="button" class="btn btn-outline-dark me-2" @onclick="@(() => SetQuote(quote.ESalesNumber, QuoteStatus.Archive))">
<i class="bi-archive-fill"></i>
@ -75,7 +75,9 @@
<i class="bi-question-circle-fill" style="font-size: 1.2rem"></i>
break;
case "Lose":
<i class="bi-trash-fill" style="font-size: 1.2rem"></i>
<button type="button" class="btn btn-outline-danger me-2" @onclick="@(() => SetQuote(quote.ESalesNumber, QuoteStatus.Trash))">
<i class="bi-trash-fill" style="font-size: 1.2rem"></i>
</button>
break;
case "Note":
<i class="bi-tag-fill" style="font-size: 1.2rem"></i>

View file

@ -21,8 +21,20 @@ public enum QuoteStatus
None,
Order,
Lose,
Archive,
Note,
Archive,
Trash,
All,
NoteOpen
}
// public enum QuoteStatus
// {
// None,
// Order,
// Lose,
// Archive,
// Note,
// All,
// NoteOpen
// }

View file

@ -62,7 +62,6 @@ public class AdvisorActivityRepository : IAdvisorActivityRepository
{
return new List<ReportItemView>();
}
return JsonSerializer.Deserialize<List<ReportItemView>>(content, _options) ?? new List<ReportItemView>();
}
@ -73,7 +72,7 @@ public class AdvisorActivityRepository : IAdvisorActivityRepository
/// <returns></returns>
public async Task<ApiResponseView> UpdateQuoteStatus(ReportItemView activity)
{
var resp = new ApiResponseView
var responseView = new ApiResponseView
{
Code = 404,
IsSuccess = false,
@ -85,11 +84,10 @@ public class AdvisorActivityRepository : IAdvisorActivityRepository
var content = await response.Content.ReadAsStringAsync();
if (string.IsNullOrWhiteSpace(content))
{
return resp;
return responseView;
}
_logger.LogDebug("UpdateQuote Response Content <= {}", content);
return JsonSerializer.Deserialize<ApiResponseView>(content, _options) ?? resp;
return JsonSerializer.Deserialize<ApiResponseView>(content, _options) ?? responseView;
}
/// <summary>
@ -124,12 +122,10 @@ public class AdvisorActivityRepository : IAdvisorActivityRepository
{
var response = await _client
.GetAsync($"{_api.CrmActivities}/date/{activityDate}");
if (!response.IsSuccessStatusCode)
return new ReportStatusView();
var content = await response.Content.ReadAsStringAsync();
return string.IsNullOrWhiteSpace(content)
? new ReportStatusView()
: JsonSerializer.Deserialize<ReportStatusView>(content, _options);
if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
return new ReportStatusView();
return JsonSerializer.Deserialize<ReportStatusView>(content, _options) ?? new ReportStatusView();
}
/// <summary>
@ -153,11 +149,9 @@ public class AdvisorActivityRepository : IAdvisorActivityRepository
{
var response = await _client.GetAsync($"{_api.CrmActivities}/company/{customerId}");
var content = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
return new List<ReportItemView>();
return string.IsNullOrWhiteSpace(content)
? new List<ReportItemView>()
: JsonSerializer.Deserialize<List<ReportItemView>>(content, _options);
return JsonSerializer.Deserialize<List<ReportItemView>>(content, _options) ?? new List<ReportItemView>();
}
/// <summary>

View file

@ -60,7 +60,7 @@ public class AdvisorCustomerHistoryRepository : IAdvisorCustomerHistoryRepositor
public async Task<InvoiceListView> GetInvoiceListHeader(string companyId)
{
var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/invoices");
var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/invoices/head");
var content = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
{

View file

@ -36,12 +36,12 @@ public class CabinetDrawerService : ICabinetDrawerService
}
public async Task<ActivityDrawer> GetActivityDrawerAsync(string companyId, bool force = false)
public async Task<ActivityDrawer> GetActivityDrawerAsync(string companyId, bool forceBackend = false)
{
var drawer = await _asyncStorageService
.GetItemAsync<ActivityDrawer>($"{companyId}.{ActivityDrawer.Label}");
if (drawer == null) force = true;
if (!force) return drawer ?? new ActivityDrawer();
if (drawer == null) forceBackend = true;
if (!forceBackend) return drawer ?? new ActivityDrawer();
var result = await _activityRepo.GetCustomerActivities(companyId);
drawer = new ActivityDrawer
{
@ -53,13 +53,13 @@ public class CabinetDrawerService : ICabinetDrawerService
}
public async Task<CatalogDrawer> GetCatalogDrawerAsync(string countryCode, bool force = false)
public async Task<CatalogDrawer> GetCatalogDrawerAsync(string countryCode, bool forceBackend = false)
{
var drawer = await _asyncStorageService
.GetItemAsync<CatalogDrawer>($"{countryCode}.{CatalogDrawer.Label}");
if (drawer == null) force = true;
if (!force) return drawer ?? new CatalogDrawer();
if (drawer == null) forceBackend = true;
if (!forceBackend) return drawer ?? new CatalogDrawer();
var result = await _priceCatalogRepo.GetPriceList(countryCode);
drawer = new CatalogDrawer
{
@ -71,13 +71,13 @@ public class CabinetDrawerService : ICabinetDrawerService
}
public async Task<InfoDrawer> GetInfoDrawerAsync(string companyId, bool force = false)
public async Task<InfoDrawer> GetInfoDrawerAsync(string companyId, bool forceBackend = false)
{
var drawer = await _asyncStorageService
.GetItemAsync<InfoDrawer>($"{companyId}.{InfoDrawer.Label}");
if (drawer == null) force = true;
if (!force) return drawer ?? new InfoDrawer();
if (drawer == null) forceBackend = true;
if (!forceBackend) return drawer ?? new InfoDrawer();
var result = await _customerRepo.GetCompanyById(companyId);
drawer = new InfoDrawer
{
@ -85,17 +85,17 @@ public class CabinetDrawerService : ICabinetDrawerService
Content = result
};
await StoreInfoDrawerAsync(companyId, drawer);
return drawer ?? new InfoDrawer();
return drawer;
}
public async Task<InventoryDrawer> GetInventoryDrawerAsync(string companyId, bool force = false)
public async Task<InventoryDrawer> GetInventoryDrawerAsync(string companyId, bool forceBackend = false)
{
var drawer = await _asyncStorageService
.GetItemAsync<InventoryDrawer>($"{companyId}.{InventoryDrawer.Label}");
if (drawer == null) force = true;
if (!force) return drawer ?? new InventoryDrawer();
if (drawer == null) forceBackend = true;
if (!forceBackend) return drawer ?? new InventoryDrawer();
var result = await _historyRepo.GetInventory(companyId);
drawer = new InventoryDrawer
{
@ -107,12 +107,12 @@ public class CabinetDrawerService : ICabinetDrawerService
}
public async Task<InvoiceDrawer> GetInvoiceDrawerAsync(string companyId, bool force = false)
public async Task<InvoiceDrawer> GetInvoiceDrawerAsync(string companyId, bool forceBackend = false)
{
var drawer = await _asyncStorageService
.GetItemAsync<InvoiceDrawer>($"{companyId}.{InvoiceDrawer.Label}");
if (drawer == null) force = true;
if (!force) return drawer ?? new InvoiceDrawer();
if (drawer == null) forceBackend = true;
if (!forceBackend) return drawer ?? new InvoiceDrawer();
var result = await _historyRepo.GetInvoiceList(companyId);
drawer = new InvoiceDrawer
{
@ -120,17 +120,17 @@ public class CabinetDrawerService : ICabinetDrawerService
Content = result
};
await StoreInvoiceDrawerAsync(companyId, drawer);
return drawer ?? new InvoiceDrawer();
return drawer;
}
public async Task<StatisticDrawer> GetStatisticDrawerAsync(string companyId, bool force = false)
public async Task<StatisticDrawer> GetStatisticDrawerAsync(string companyId, bool forceBackend = false)
{
var drawer = await _asyncStorageService
.GetItemAsync<StatisticDrawer>($"{companyId}.{StatisticDrawer.Label}");
if (drawer == null) force = true;
if (!force) return drawer ?? new StatisticDrawer();
if (drawer == null) forceBackend = true;
if (!forceBackend) return drawer ?? new StatisticDrawer();
var result = await _historyRepo.GetProductInvoiceLines(companyId);
var content = result.Select(x => new InventoryItem
{
@ -153,7 +153,7 @@ public class CabinetDrawerService : ICabinetDrawerService
public async Task StoreActivityDrawerAsync(string companyId, ActivityDrawer drawer)
{
if (drawer.Content.Any())
if (drawer.Content.Count != 0)
{
drawer.Content = drawer.Content.OrderByDescending(x => x.OrderDate).ToList();
}
@ -176,7 +176,7 @@ public class CabinetDrawerService : ICabinetDrawerService
public async Task StoreInventoryDrawerAsync(string companyId, InventoryDrawer drawer)
{
if (drawer.Content.Any())
if (drawer.Content.Count != 0)
{
drawer.Content = drawer.Content.OrderByDescending(x => x.LastInvoiceDate).ToList();
}
@ -187,7 +187,7 @@ public class CabinetDrawerService : ICabinetDrawerService
public async Task StoreInvoiceDrawerAsync(string companyId, InvoiceDrawer drawer)
{
if (drawer.Content.Any())
if (drawer.Content.Count != 0)
{
drawer.Content = drawer.Content.OrderByDescending(x => x.DocumentDate).ToList();
}
@ -198,7 +198,7 @@ public class CabinetDrawerService : ICabinetDrawerService
public async Task StoreStatisticDrawerAsync(string companyId, StatisticDrawer drawer)
{
if (drawer.Content.Any())
if (drawer.Content.Count != 0)
{
drawer.Content = drawer.Content.OrderByDescending(x => x.DeliveryDate).ToList();
}

View file

@ -6,12 +6,12 @@ namespace Wonky.Client.Local.Services;
public interface ICabinetDrawerService
{
Task<ActivityDrawer> GetActivityDrawerAsync(string companyId, bool force = false);
Task<CatalogDrawer> GetCatalogDrawerAsync(string countryCode, bool force = false);
Task<InfoDrawer> GetInfoDrawerAsync(string companyId, bool force = false);
Task<InventoryDrawer> GetInventoryDrawerAsync(string companyId, bool force = false);
Task<InvoiceDrawer> GetInvoiceDrawerAsync(string companyId, bool force = false);
Task<StatisticDrawer> GetStatisticDrawerAsync(string companyId, bool force = false);
Task<ActivityDrawer> GetActivityDrawerAsync(string companyId, bool forceBackend = false);
Task<CatalogDrawer> GetCatalogDrawerAsync(string countryCode, bool forceBackend = false);
Task<InfoDrawer> GetInfoDrawerAsync(string companyId, bool forceBackend = false);
Task<InventoryDrawer> GetInventoryDrawerAsync(string companyId, bool forceBackend = false);
Task<InvoiceDrawer> GetInvoiceDrawerAsync(string companyId, bool forceBackend = false);
Task<StatisticDrawer> GetStatisticDrawerAsync(string companyId, bool forceBackend = false);
Task StoreActivityDrawerAsync(string companyId, ActivityDrawer drawer);
Task StoreCatalogDrawerAsync(string countryCode, CatalogDrawer drawer);

View file

@ -64,7 +64,7 @@ public partial class AdvisorCustomerCreatePage : IDisposable
CompanyContext.OnValidationStateChanged += ValidationChanged;
UserInfo = await UserInfoService.GetUserInfo();
Dk = UserInfo.CountryCode.ToLower() == "dk";
Dk = UserInfo.CountryCode.Equals("dk", StringComparison.CurrentCultureIgnoreCase);
Company.SalesRepId = UserInfo.UserId;
Company.CountryCode = UserInfo.CountryCode.ToLower();
@ -95,7 +95,7 @@ public partial class AdvisorCustomerCreatePage : IDisposable
Logger.LogDebug("CrmCompanyView => SelectCompanyCallback => {}", JsonSerializer.Serialize(regInfo));
// this can be removed in favor of the new data returned from updating the VatNumber
RegState = regInfo.States[0].State.ToLower() == "normal" ? "the-good" : "the-dead";
RegState = regInfo.States[0].State.Equals("normal", StringComparison.CurrentCultureIgnoreCase) ? "the-good" : "the-dead";
if (regInfo.SyncAll)
{
Company.Name = regInfo.Name;

View file

@ -55,7 +55,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
// ###########################################################################
[Parameter] public string CompanyId { get; set; } = "";
// ###########################################################################
private EditContext _erpFormContext;
private DateTime _lastVisit;
@ -67,7 +67,9 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
private VatLookupDkModal _vatLookupPopup = new();
private List<ContactDto> _contacts = new();
private string VatState { get; set; } = "the-ugly";
private bool _validVat;
// private bool _hasFolded;
// private string _currentVat = "";
private string _countryCode = "dk";
@ -82,7 +84,9 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
private string _activitiesLink = "";
private string _invoiceLink = "";
private string _newActivityLink = "";
private int _enableLink = 1;
// private ActivityDrawer _activityDrawer = new();
// private InventoryDrawer _inventoryDrawer = new();
// private InvoiceDrawer _invoiceDrawer = new();
@ -92,7 +96,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
private CompanyDto _company = new();
// private string _companyId = "";
protected override async Task OnInitializedAsync()
{
/*
@ -128,15 +132,15 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
{
Navigator.NavigateTo($"/advisor/customers/{CompanyId}/activities/new");
}
/*
* fetch user info from local storage
*/
_userInfo = await UserInfoService.GetUserInfo();
_countryCode = _userInfo.CountryCode.ToLower();
_countryIsDk = _countryCode == "dk";
_infoDrawer = await DrawerService.GetInfoDrawerAsync(CompanyId);
_infoDrawer.Content = _company;
await DrawerService.StoreInfoDrawerAsync(CompanyId, _infoDrawer);
_infoDrawer = await DrawerService.GetInfoDrawerAsync(CompanyId, forceBackend: true);
/*
* internal _enableActivity flag
*/
@ -149,86 +153,91 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
{
_enableActivity = 1;
}
/*
* only execute if the InfoDrawer.Company is not KANVAS
*/
Logger.LogDebug("_company => {}", JsonSerializer.Serialize(_company));
/*
* toggle view button text
*/
_toggleButtonText = _company.IsHidden == 0 ? "Udelad kunde i oversigt" : "Brug Normal Visning";
// _currentVat = _company.VatNumber;
_company.CountryCode = _userInfo.CountryCode.ToLower();
/*
* visit interval init
*/
if (_company.Interval == 0)
{
_company.Interval = 8;
}
/*
* visit date init
*/
_lastVisit = DateTime.Parse(_company.LastVisit);
_nextVisit = DateTime.Parse(_company.NextVisit);
/*
* if no previous visit is registered - force last visit date to 2020
*/
if (_lastVisit.Year < 2020)
{
_lastVisit = DateTime.Parse("2020-01-01");
}
/*
* set next visit according to last visit and interval
*/
if (!_company.ValidDateSpan())
{
_nextVisit = _lastVisit.AddDays(_company.Interval * 7);
}
/*
* display urgency of next visit
*/
_visitStateCss = Mapper.MapVisitState($"{_nextVisit:yyyy-MM-dd}");
/*
* handle InfoDrawer.Company out of business case
*/
if (_company.HasFolded == 1)
{
/*
* this is only used if user has selected to show closed companies
*/
// _hasFolded = true;
VatState = "the-dead";
_visitStateCss = "the-dead";
}
else
{
/*
* vat validation flags
*/
_company.ValidVat = VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber) ? 1 : 0;
_validVat = _company.ValidVat == 1; // true/false flag set if InfoDrawer.Company has a valid vatNumber
VatState = _company.ValidVat == 1 ? "the-good" : "no-vat"; // assign css class
}
Logger.LogDebug("_company => {}", JsonSerializer.Serialize(_company));
/*
* toggle view button text
*/
_toggleButtonText = _company.IsHidden == 0 ? "Udelad kunde i oversigt" : "Brug Normal Visning";
// _currentVat = _company.VatNumber;
_company.CountryCode = _userInfo.CountryCode.ToLower();
/*
* visit interval init
*/
if (_company.Interval == 0)
{
_company.Interval = 8;
}
if (_countryIsDk)
{
_companyVatAddress = PrepareVatAddress(_company);
}
// await GetContacts(CompanyId);
/*
* visit date init
*/
_lastVisit = DateTime.Parse(_company.LastVisit);
_nextVisit = DateTime.Parse(_company.NextVisit);
/*
* if no previous visit is registered - force last visit date to 2020
*/
if (_lastVisit.Year < 2020)
{
_lastVisit = DateTime.Parse("2020-01-01");
}
/*
* set next visit according to last visit and interval
*/
if (!_company.ValidDateSpan())
{
_nextVisit = _lastVisit.AddDays(_company.Interval * 7);
}
/*
* display urgency of next visit
*/
_visitStateCss = Mapper.MapVisitState($"{_nextVisit:yyyy-MM-dd}");
/*
* handle InfoDrawer.Company out of business case
*/
if (_company.HasFolded == 1)
{
/*
* this is only used if user has selected to show closed companies
*/
// _hasFolded = true;
VatState = "the-dead";
_visitStateCss = "the-dead";
}
else
{
/*
* vat validation flags
*/
_company.ValidVat = VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber) ? 1 : 0;
_validVat = _company.ValidVat == 1; // true/false flag set if InfoDrawer.Company has a valid vatNumber
VatState = _company.ValidVat == 1 ? "the-good" : "no-vat"; // assign css class
}
if (_countryIsDk)
{
_companyVatAddress = PrepareVatAddress(_company);
}
// await GetContacts(CompanyId);
/*
* remove loading image
*/
_working = false;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await GetContacts(CompanyId);
_ = await DrawerService.GetActivityDrawerAsync(CompanyId, force:true);
await DrawerService.GetActivityDrawerAsync(CompanyId, forceBackend: true);
if (!_company.Account.StartsWith("NY"))
{
await ReloadHistory();
@ -236,45 +245,50 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
}
}
private async Task ReloadHistory(bool force = false)
private async Task ReloadHistory(bool forceBackend = false)
{
if (force)
if (forceBackend)
{
Toaster.ShowInfo("Afventer svar fra tjenester ...");
Toaster.ShowInfo("Afventer svar fra tjenester ...");
}
_enableLink = 0;
_enableActivity = 0;
var newSync = await CustomerHistoryRepo.RequestErpSync(CompanyId, _company.HistorySync, force);
var newSync = await CustomerHistoryRepo.RequestErpSync(CompanyId, _company.HistorySync, forceBackend);
await Task.Delay(500);
if (!string.IsNullOrWhiteSpace(newSync))
{
Toaster.ShowSuccess($"{forceBackend} {newSync} ERP hitorik synkroniseret til CRM.");
_company.HistorySync = newSync;
if (!_company.Account.StartsWith("NY"))
{
_ = await DrawerService.GetInvoiceDrawerAsync(CompanyId, force);
_ = await DrawerService.GetInventoryDrawerAsync(CompanyId, force);
_ = await DrawerService.GetStatisticDrawerAsync(CompanyId, force);
await DrawerService.GetInvoiceDrawerAsync(CompanyId, forceBackend);
await DrawerService.GetInventoryDrawerAsync(CompanyId, forceBackend);
await DrawerService.GetStatisticDrawerAsync(CompanyId, forceBackend);
}
_ = await DrawerService.GetActivityDrawerAsync(CompanyId, force);
await DrawerService.GetActivityDrawerAsync(CompanyId, forceBackend);
}
_enableLink = 1;
_enableActivity = _company.ValidVat;
StateHasChanged();
if (force)
if (forceBackend)
{
Toaster.ShowSuccess("Alle tjenester har svaret.");
Toaster.ShowSuccess("Alle tjenester har svaret.");
}
}
private void ToggleErpEdit()
{
_erpEditDisabled = !_erpEditDisabled;
}
private void ToggleVatEdit()
{
_vatEditDisabled = !_vatEditDisabled;
@ -294,7 +308,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
await AdvisorCustomerRepo.UpdateCrmData(CompanyId, _company);
}
/*
* Request contacts for company
*/
@ -319,7 +333,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
_vatLookupPopup.Show();
}
/*
* Callback from vat lookup overlay with registration infomration
*/
@ -340,6 +354,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
_company.ZipCode = regInfo.ZipCode;
_company.City = regInfo.City;
}
_company.VatNumber = regInfo.VatNumber;
}
@ -386,6 +401,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
*/
await ContactRepo.PutContact(contact);
}
/*
* reset default contact
*/
@ -400,7 +416,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
/*
* Delete contact callback
*/
*/
private async Task DeleteContactCallback(string contactId)
{
if (_working)
@ -408,7 +424,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
_working = true;
/*
* send delete request to backend
*/
*/
await ContactRepo.DeleteContact(CompanyId, contactId);
/*
* reset default contact
@ -421,7 +437,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
_working = false;
}
/*
* Execute post requset - updating CRM data (non ERP related)
*/
@ -440,6 +456,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
_infoDrawer = await DrawerService.GetInfoDrawerAsync(CompanyId, true);
_company = _infoDrawer.Content;
}
StateHasChanged();
_working = false;
Toaster.ShowSuccess("Dine CRM data er opdateret.");
@ -462,6 +479,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
_infoDrawer = await DrawerService.GetInfoDrawerAsync(CompanyId, true);
_company = _infoDrawer.Content;
}
StateHasChanged();
_working = false;
Toaster.ShowSuccess(_company.Account.StartsWith("NY")
@ -484,12 +502,13 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
return;
/*
* VAT format validation
*/
*/
if (!VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber))
{
Toaster.ShowError($"Moms Nummer ugyldigt");
return;
}
_working = true;
_vatEditDisabled = true;
Toaster.ShowInfo("Vent venligst ...");
@ -499,6 +518,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
_infoDrawer = await DrawerService.GetInfoDrawerAsync(CompanyId, true);
_company = _infoDrawer.Content;
}
StateHasChanged();
_working = false;
// if (_company.HasFolded == 1)
@ -508,7 +528,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
Toaster.ShowSuccess("Moms Nr. er opdateret.");
}
/*
* Prepare vat address
* used to lookup danish company
@ -529,6 +549,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
HouseNumber = company.Address1.Split(' ')[1].Split('-')[0]
};
}
/*
* process address2
*/
@ -542,13 +563,14 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
HouseNumber = company.Address2.Split(' ')[1].Split('-')[0]
};
}
/*
* return empty model
*/
return new VatAddress();
}
/*
* Force enable activioty - even if company has turned keys and shut down
*/
@ -563,7 +585,6 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
*/
private void HandleFieldChanged(object? sender, FieldChangedEventArgs? e)
{
_nextVisit = _lastVisit.AddDays(_company.Interval * 7);
/*
* avoid nesting if by assuming _validVat is false
@ -571,7 +592,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
_validVat = false;
/*
* set _validVat true if validation succeed
*/
*/
if (VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber))
{
_validVat = true;

View file

@ -26,33 +26,31 @@
</div>
<div class="col-sm-4 text-end">
<div class="btn-group btn-group" role="group" aria-label="Filter tilbud">
<input type="radio" class="btn-check" name="btn-filter" id="btn-filter4" autocomplete="off" @onchange="() => FilterQuotes(QuoteStatus.All)"/>
<label class="btn btn-dark" for="btn-filter4"><i class="bi-list"style="font-size: 1.3rem"></i></label>
<input type="radio" class="btn-check" name="btn-filter" id="btn-filter1" autocomplete="off" @onchange="() => FilterQuotes(QuoteStatus.Lose)"/>
<label class="btn btn-dark" for="btn-filter1"><i class="bi-trash-fill"style="font-size: 1.3rem"></i></label>
<input type="radio" class="btn-check" name="btn-filter" id="btn-filter2" autocomplete="off" @onchange="() => FilterQuotes(QuoteStatus.Archive)"/>
<label class="btn btn-dark" for="btn-filter2"><i class="bi-archive-fill"style="font-size: 1.3rem"></i></label>
<input type="radio" class="btn-check" name="btn-filter" id="btn-filter5" autocomplete="off" @onchange="() => FilterQuotes(QuoteStatus.None)"/>
<label class="btn btn-dark" for="btn-filter5"><i class="bi-question-circle-fill"style="font-size: 1.3rem"></i></label>
<input type="radio" class="btn-check" name="btn-filter" id="btn-filter3" autocomplete="off" @onchange="() => FilterQuotes(QuoteStatus.Note)"/>
<label class="btn btn-dark" for="btn-filter3"><i class="bi-tag-fill"style="font-size: 1.3rem"></i></label>
<input type="radio" class="btn-check" name="btn-filter" id="btn-filter6" autocomplete="off" @onchange="() => FilterQuotes(QuoteStatus.NoteOpen)" checked/>
<label class="btn btn-dark" for="btn-filter6"><i class="bi-activity"style="font-size: 1.3rem"></i></label>
@* all quotes (list) *@
<input type="radio" class="btn-check" name="btn-filter" id="btn-filter4" autocomplete="off"
@onchange="() => FilterQuotes(QuoteStatus.All)"/>
<label class="btn btn-dark" for="btn-filter4"><i class="bi-list" style="font-size: 1.3rem"></i></label>
@* lost quotes (trash) *@
<input type="radio" class="btn-check" name="btn-filter" id="btn-filter1" autocomplete="off"
@onchange="() => FilterQuotes(QuoteStatus.Lose)"/>
<label class="btn btn-dark" for="btn-filter1"><i class="bi-trash-2" style="font-size: 1.3rem"></i></label>
@* archived quotes (archive) *@
<input type="radio" class="btn-check" name="btn-filter" id="btn-filter2" autocomplete="off"
@onchange="() => FilterQuotes(QuoteStatus.Archive)"/>
<label class="btn btn-dark" for="btn-filter2"><i class="bi-archive-fill" style="font-size: 1.3rem"></i></label>
@* open/undecided quotes (question) *@
<input type="radio" class="btn-check" name="btn-filter" id="btn-filter5" autocomplete="off"
@onchange="() => FilterQuotes(QuoteStatus.None)"/>
<label class="btn btn-dark" for="btn-filter5"><i class="bi-question-circle-fill" style="font-size: 1.3rem"></i></label>
@* quotes tagged as notes (tag) *@
<input type="radio" class="btn-check" name="btn-filter" id="btn-filter3" autocomplete="off"
@onchange="() => FilterQuotes(QuoteStatus.Note)"/>
<label class="btn btn-dark" for="btn-filter3"><i class="bi-tag-fill" style="font-size: 1.3rem"></i></label>
@* quotes - either tagged or open (activity) *@
<input type="radio" class="btn-check" name="btn-filter" id="btn-filter6" autocomplete="off"
@onchange="() => FilterQuotes(QuoteStatus.NoteOpen)" checked/>
<label class="btn btn-dark" for="btn-filter6"><i class="bi-activity" style="font-size: 1.3rem"></i></label>
</div>
@*
<div class="form-check">
<input class="form-check-input" type="checkbox" id="showAll"
@bind-Value="Filtered" @bind-Value:event="onchange" @onclick="@FilterQuotes" disabled="@(!Quotes.Any())"/>
<label for="showAll" class="form-check-label">Vis alle</label>
</div>
*@
</div>
</div>

View file

@ -48,7 +48,7 @@ public partial class AdvisorQuoteListPage : IDisposable
await Storage.SetItemAsync("quotes", QuoteList.OrderBy(x => x.Company.Name));
Working = false;
// filter quotes - if any - default to QStatus.NoteOpen
if (QuoteList.Any())
if (QuoteList.Count != 0)
await FilterQuotes(QuoteFilter);
}
@ -62,6 +62,7 @@ public partial class AdvisorQuoteListPage : IDisposable
QuoteStatus.Lose => QuoteList.Where(x => x.QuoteStatusEnum is "Lose").ToList(),
QuoteStatus.Archive => QuoteList.Where(x => x.QuoteStatusEnum is "Archive").ToList(),
QuoteStatus.Note => QuoteList.Where(x => x.QuoteStatusEnum is "Note").ToList(),
QuoteStatus.Trash => QuoteList.Where(x => x.QuoteStatusEnum is "Trash").ToList(),
QuoteStatus.NoteOpen => QuoteList.Where(x => x.QuoteStatusEnum is "Note" or "None").ToList(),
_ => QuoteList.ToList()
};
@ -75,19 +76,24 @@ public partial class AdvisorQuoteListPage : IDisposable
if (args.Status == QuoteStatus.Order)
quote.OrderDate = $"{DateTime.Now:yyyy-MM-dd}";
quote.QuoteStatusEnum = Utils.EnumToString(args.Status);
// send update request to backend
var response = await AdvisorActivityRepo.UpdateQuoteStatus(quote);
Toaster.ShowInfo($"{response.Message}");
// clear and reload quotes
QuoteList = new List<ReportItemView>();
await Storage.RemoveItemAsync("quotes");
QuoteList = await AdvisorActivityRepo.GetQuotes();
// store quotes in local storage
await Storage.SetItemAsync("quotes", QuoteList.OrderBy(x => x.Company.Name));
// filter quotes - if any - based on active filter
if(QuoteList.Count != 0)
await FilterQuotes(QuoteFilter);
Working = false;
// signal page state changed
StateHasChanged();
}