done - customer invoice overlay

This commit is contained in:
Frede Hundewadt 2023-01-20 14:06:57 +01:00
parent 8216659360
commit 2f91e10f32
11 changed files with 117 additions and 50 deletions

View file

@ -37,7 +37,7 @@
{
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-1"><i class="bi-pencil"></i></div>
<div class="col-md-1"><i class="bi-card-text"></i></div>
<div class="col-md-10 fw-bold">@invoice.OrderNote</div>
</div>
}
@ -47,5 +47,5 @@
}
else
{
<div>Ingen data</div>
<div>Venter ...</div>
}

View file

@ -11,11 +11,15 @@
</tr>
<tr>
<td><i class="bi-search" style="font-size:1.3rem"></i></td>
<td>Søg data</td>
<td>Søg</td>
</tr>
<tr>
<td><i class="bi-plus" style="font-size:1.3rem"></i></td>
<td>Opret ny</td>
<td>Opret</td>
</tr>
<tr>
<td><i class="bi-card-text" style="font-size:1.3rem"></i></td>
<td>Notat</td>
</tr>
<tr>
<td><i class="bi-printer" style="font-size:1.3rem"></i></td>

View file

@ -13,11 +13,5 @@
</td>
<td>Brugere</td>
</tr>
<tr>
<td>
<i class="bi-box" style="font-size:1.3rem"></i>
</td>
<td>Pakning / Forsendelse</td>
</tr>
</tbody>
</table>

View file

@ -1,5 +1,5 @@
<h3>Aktivitet Oversigt</h3>
<h3>Bestilling Status</h3>
<table class="table">
<thead>
<tr>

View file

@ -68,16 +68,16 @@
</div>
@if (!string.IsNullOrWhiteSpace(quote.OfficeNote))
{
<div class="col-sm-2 text-end">Note</div>
<div class="col-sm-2 text-end">Kontor <i class="bi-card-text"></i></div>
<div class="col-sm-10">
<i class="bi-pencil"></i> @quote.OfficeNote
@quote.OfficeNote
</div>
}
@if (!string.IsNullOrWhiteSpace(quote.CrmNote))
{
<div class="col-sm-2 text-end">CRM note</div>
<div class="col-sm-2 text-end">CRM <i class="bi-card-text"></i></div>
<div class="col-sm-10">
<i class="bi-pencil"></i> @quote.CrmNote
@quote.CrmNote
</div>
}
</div>

View file

@ -106,7 +106,7 @@ namespace Wonky.Client.HttpInterceptors
_logger.LogDebug("{}", message);
_authenticationService.Logout();
_navigation.NavigateTo($"/login/{currDoc}");
_toast.ShowInfo(message);
_toast.ShowInfo("Venligst Login. Tak.");
break;
case HttpStatusCode.Conflict:
_logger.LogDebug("Conflict <= {}", currDoc);
@ -117,7 +117,7 @@ namespace Wonky.Client.HttpInterceptors
_logger.LogDebug("{}", message);
break;
default:
_toast.ShowError(message);
_logger.LogDebug("{}", message);
break;
}
// throw new HttpResponseException(message);

View file

@ -158,7 +158,7 @@ else
<div class="row g-2">
<div class="col-sm-4 d-grid mx-auto">
<button class="btn btn-danger" disabled>Faktura</button>
<button class="btn btn-danger" disabled="@string.IsNullOrWhiteSpace(Activity.ActivityTypeEnum)" @onclick="ShowInvoiceOverlay">Faktura</button>
</div>
<div class="col-sm-4 d-grid mx-auto">
<button class="btn btn-warning" disabled>Tidl. besøg</button>
@ -340,4 +340,5 @@ else
<PriceCatalogModal CountryCode="@Company.CountryCode.ToLower()" OnSelected="PriceListCallback" @ref="PriceCatalogModal"/>
<ProductHistoryModal CompanyId="@CompanyId" ItemSku="@SelectedItem.Sku" @ref="HistoryModal"/>
<ProductPriceHistoryModal OnSelected="PriceHistoryCallback" CompanyId="@CompanyId" Sku="@SelectedItem.Sku" @ref="PriceHistoryModal"/>
<ConfirmProductCheckModal BodyMessage="" CompanyId="@CompanyId" Products="CheckList" OnOkClicked="ConfirmProductCheckCallback" @ref="ConfirmProductCheckModal" />
<ConfirmProductCheckModal BodyMessage="" CompanyId="@CompanyId" Products="CheckList" OnOkClicked="ConfirmProductCheckCallback" @ref="ConfirmProductCheckModal" />
<CustomerInvoiceOverlay CustomerInvoices="CompanyInvoices" @ref="InvoiceOverlay" />

View file

@ -46,7 +46,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
[Inject] private IAdvisorCustomerRepository Companies { get; set; }
[Inject] private IAdvisorActivityRepository Actitivites { get; set; }
[Inject] private IAdvisorReportRepository Reports { get; set; }
[Inject] private IAdvisorCustomerHistoryRepository CustomerHistory { get; set; }
[Inject] private IAdvisorCustomerHistoryRepository HistoryRepo { get; set; }
// variables
private readonly JsonSerializerOptions _options = new() {PropertyNameCaseInsensitive = true};
private SalesItemView SelectedItem { get; set; } = new();
@ -77,6 +77,8 @@ public partial class AdvisorActivityCreatePage : IDisposable
private List<ProductInventoryView> CheckList { get; set; } = new();
private string ButtonText { get; set; } = "Gem besøg";
private bool OrgWarning { get; set; }
private CustomerInvoiceOverlay InvoiceOverlay { get; set; }
private InvoiceListView CompanyInvoices { get; set; } = new();
/// <summary>
@ -154,6 +156,42 @@ public partial class AdvisorActivityCreatePage : IDisposable
Working = false;
}
private async Task ShowInvoiceOverlay()
{
Logger.LogDebug("ShowInvoiceOverlay - wait for invoices");
InvoiceOverlay.Show();
CompanyInvoices = await FetchCompanyInvoices();
await Task.Delay(500);
}
private async Task<InvoiceListView> FetchCompanyInvoices()
{
// fetch from storage
var storage = await Storage.GetItemAsStringAsync($"{CompanyId}-invoices");
await Task.Delay(500);
var iDate = await Storage.GetItemAsStringAsync($"{CompanyId}-iDate");
// if we have a list and iDate was today return the list
if (!string.IsNullOrWhiteSpace(storage) && (!string.IsNullOrWhiteSpace(iDate) && DateTime.Parse(iDate.Replace("\"", "")) >= DateTime.Now))
{
Logger.LogDebug("fetching invoices from storage");
Logger.LogDebug("storage contains <= {}", storage);
return JsonSerializer.Deserialize<InvoiceListView>(storage);
}
Logger.LogDebug("pulling invoices from backend");
// pull invoices
var companyInvoices = await HistoryRepo.FetchInvoiceList(CompanyId);
// send invoices to storage
await Storage.SetItemAsync($"{CompanyId}-invoices", companyInvoices);
await Storage.SetItemAsync($"{CompanyId}-iDate", $"{DateTime.Now:yyyy-MM-dd}");
Logger.LogDebug(" --> return invoices from backend");
Working = false;
Logger.LogDebug("backend contains <= {}", JsonSerializer.Serialize(companyInvoices));
return companyInvoices;
}
private void ShowOrgWarning()
{
if (OrgWarning)
@ -195,7 +233,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
// product inventory has not been updated
// send rpc call to sync ERP to CRM
Toaster.ShowInfo("Vent mens data synkroniseres ...", "ERP til CRM ...");
var ts = await CustomerHistory.InvoiceErpToCrmRpc(CompanyId, Company.HistorySync);
var ts = await HistoryRepo.InvoiceErpToCrmRpc(CompanyId, Company.HistorySync);
while (string.IsNullOrWhiteSpace(ts))
await Task.Delay(500);
// save pDate
@ -203,7 +241,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
// request products from backend
Toaster.ShowInfo("Vent mens produkt oversigt hentes", "CRM produkt liste");
CheckList = await CustomerHistory.FetchInventory(CompanyId);
CheckList = await HistoryRepo.FetchInventory(CompanyId);
if(CheckList.Any())
CheckList = CheckList.OrderBy(x => x.Description).ToList();

View file

@ -1,20 +1,27 @@
@using Wonky.Client.Components
<div class="modal" tabindex="-1" role="dialog" style="display:@_modalDisplay">
<div class="modal-dialog modal-dialog-scrollable modal-fullscreen-lg-down modal-xl modal-lg">
<div class="row pt-2 pb-1 rounded-2 bg-dark text-white">
<div class="col-sm-6">
<h4 class="pt-1">@Company.Name</h4>
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Faktura</h5>
<button type="button" class="btn-close" @onclick="Hide" data-bs-dismiss="modal" aria-label="Luk"></button>
</div>
<div class="col-sm-3 align-content-end">
<a class="btn btn-primary d-block" href="/advisor/customers/@Company.CompanyId"><i class="bi-arrow-right"></i> Kundekort</a>
</div>
<div class="col-sm-3 align-content-end">
<a class="btn btn-primary d-block" href="/advisor/customers/@Company.CompanyId/activities/new"><i class="bi-arrow-right"></i> Besøg</a>
<div class="modal-body">
<div class="row pt-2 pb-1 rounded-2 bg-dark text-white">
<div class="col-sm-6">
<h4 class="pt-1">@Company.Name</h4>
</div>
</div>
<CustomerInvoiceListComponent OnShowInvoice="@CallInvoiceModal" CompanyId="@Company.CompanyId" InvoiceList="@Invoices"/>
<InvoiceViewModal CompanyId="@Company.CompanyId" InvoiceId="@InvoiceId" @ref="InvoiceView" />
</div>
</div>
<CustomerInvoiceListComponent OnShowInvoice="CallInvoiceModal" CompanyId="@Company.CompanyId" InvoiceList="@CompanyInvoices.Invoices"/>
<InvoiceViewModal CompanyId="@Company.CompanyId" InvoiceId="@InvoiceId" @ref="InvoiceView" />
</div>
</div>
@if (_showBackdrop)
{
<div class="modal-backdrop fade show"></div>
}

View file

@ -1,3 +1,4 @@
using System.Text.Json;
using Microsoft.AspNetCore.Components;
using Wonky.Entity.DTO;
using Wonky.Entity.Views;
@ -7,13 +8,35 @@ namespace Wonky.Client.Shared;
public partial class CustomerInvoiceOverlay
{
[Parameter] public InvoiceListView CompanyInvoices { get; set; } = new();
[Parameter] public CompanyDto Company { get; set; } = new();
[Parameter] public InvoiceViewModal InvoiceView { get; set; } = new();
[Parameter] public InvoiceListView CustomerInvoices { get; set; } = new();
[Inject] private ILogger<CustomerInvoiceOverlay> Logger { get; set; }
private InvoiceViewModal InvoiceView { get; set; } = new();
private string InvoiceId { get; set; } = "";
private string _modalDisplay = "";
private bool _showBackdrop;
private List<InvoiceListItemView> Invoices { get; set; } = new();
private InvoiceCompanyView Company { get; set; } = new();
protected override void OnParametersSet()
{
Company = CustomerInvoices.Company;
Logger.LogDebug("company => {}", JsonSerializer.Serialize(Company));
Invoices = CustomerInvoices.Invoices;
Logger.LogDebug("invoices => {}", JsonSerializer.Serialize(Invoices));
}
protected override void OnInitialized()
{
StateHasChanged();
}
private void CallInvoiceModal(string invoiceId)
{
InvoiceId = invoiceId;
InvoiceView.Show();
}
public void Show()
{
_modalDisplay = "block;";

View file

@ -1,11 +1,23 @@
{
"appInfo": {
"name": "Wonky Online",
"version": "0.103.9",
"version": "0.105.1",
"rc": true,
"sandBox": false,
"image": "grumpy-coder.png"
},
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
},
"Debug": {
"LogLevel": {
"Default": "Critical"
}
}
},
"apiConfig": {
"baseUrl": "https://zeta.innotec.dk",
"catalog": "api/v2/catalog/country",
@ -34,16 +46,4 @@
"userInfo": "api/auth/userinfo",
"warehouse": "api/v2/warehouse/packages"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"System": "Information",
"Microsoft": "Information"
},
"Debug": {
"LogLevel": {
"Default": "Critical"
}
}
}
}