rebuilt v310.0

This commit is contained in:
Frede Hundewadt 2023-11-28 14:54:50 +01:00
parent e75453e025
commit 03af77e0f0
13 changed files with 52 additions and 81 deletions

View file

@ -91,10 +91,10 @@
<button class="btn btn-sm btn-success" @onclick="@(() => ShowInventory(company.CompanyId))">Produkter</button> <button class="btn btn-sm btn-success" @onclick="@(() => ShowInventory(company.CompanyId))">Produkter</button>
</div> </div>
<div class="col"> <div class="col">
<a class="btn btn-sm btn-primary" href="/office/customers/@company.CountryCode.ToLower()/@company.CompanyId/order">Bestilling</a> <a class="btn btn-sm btn-primary" href="/office/customers/@CountryCode/@company.CompanyId/order">Bestilling</a>
</div> </div>
<div class="col"> <div class="col">
<button class="btn btn-sm btn-secondary" @onclick="() => RequestBusinessCentralData(company.CompanyId, true)">BC<i class="bi-database-down"></i></button> <button class="btn btn-sm btn-secondary" @onclick="() => RequestBusinessCentralData(company.CompanyId, true)">BC <i class="bi-database-down"></i></button>
</div> </div>
</div> </div>
</div> </div>

View file

@ -47,8 +47,7 @@ public partial class OfficeCountryCustomerListComponent : IDisposable
[Parameter] public List<CompanyDto> CompanyList { get; set; } = new(); [Parameter] public List<CompanyDto> CompanyList { get; set; } = new();
// [Parameter] public EventCallback<DraftItem> OnOrderItem { get; set; } // [Parameter] public EventCallback<DraftItem> OnOrderItem { get; set; }
[CascadingParameter] public DraftStateProvider DraftProvider { get; set; } [CascadingParameter] public DraftStateProvider DraftProvider { get; set; }
[Parameter] public EventCallback<bool> SetWorking { get; set; }
[Parameter] public EventCallback<bool> SetWorking { get; set; }
// ****************************************************** // ******************************************************
// overlays // overlays
@ -70,62 +69,49 @@ public partial class OfficeCountryCustomerListComponent : IDisposable
Interceptor.RegisterEvent(); Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent(); Interceptor.RegisterBeforeSendEvent();
} }
private async Task RequestBusinessCentralData(string companyId, bool force)
{
await SetWorking.InvokeAsync(true);
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
// call erp to crm sync before requesting invoices
await Task.Delay(500);
var newSyncDate = await HistoryRepo.RequestErpToCrmSync(companyId, SelectedCompany.HistorySync, force);
while (string.IsNullOrWhiteSpace(newSyncDate))
{
await Task.Delay(500);
}
await SetWorking.InvokeAsync(false);
}
private async Task ShowInvoiceList(string companyId) private async Task ShowInvoiceList(string companyId)
{ {
await SetWorking.InvokeAsync(true);
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
// call erp to crm sync before requesting invoices Logger.LogDebug("SelectedCompany => {}", SelectedCompany);
await Task.Delay(500); await SetWorking.InvokeAsync(true);
await RequestBusinessCentralData(companyId, false);
await RequestBusinessCentralData(companyId, true);
InvoiceList = await HistoryRepo.GetInvoiceList(CountryCode, companyId); InvoiceList = await HistoryRepo.GetInvoiceList(CountryCode, companyId);
InvoiceListOverlay.Show(); InvoiceListOverlay.Show();
await SetWorking.InvokeAsync(false); await SetWorking.InvokeAsync(false);
} }
private async Task ShowActivityList(string companyId) private async Task ShowActivityList(string companyId)
{ {
await SetWorking.InvokeAsync(true);
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
await Task.Delay(500);
await SetWorking.InvokeAsync(true);
ActivityList = await ActivityRepo.GetActivityList(companyId); ActivityList = await ActivityRepo.GetActivityList(companyId);
await Task.Delay(500);
ActivityListOverlay.Show(); ActivityListOverlay.Show();
await SetWorking.InvokeAsync(false); await SetWorking.InvokeAsync(false);
} }
private async Task ShowInventory(string companyId) private async Task ShowInventory(string companyId)
{ {
await SetWorking.InvokeAsync(true);
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
Logger.LogDebug("SelectedCompany => {}", JsonSerializer.Serialize(SelectedCompany));
await Task.Delay(500); await SetWorking.InvokeAsync(true);
await RequestBusinessCentralData(companyId, false); await RequestBusinessCentralData(companyId, false);
// request inventory
await Task.Delay(500); ProductInventory = await HistoryRepo.GetInventory(CountryCode, companyId);
ProductInventory = await HistoryRepo.GetInventory(SelectedCompany.CountryCode, SelectedCompany.CompanyId);
await Task.Delay(500);
Logger.LogDebug("ProductInventory => {}", JsonSerializer.Serialize(ProductInventory));
// show the overlay
InventoryListOverlay.Show(); InventoryListOverlay.Show();
await SetWorking.InvokeAsync(false); await SetWorking.InvokeAsync(false);
} }
@ -136,6 +122,18 @@ public partial class OfficeCountryCustomerListComponent : IDisposable
} }
private async Task RequestBusinessCentralData(string companyId, bool force)
{
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
await SetWorking.InvokeAsync(true);
SelectedCompany.HistorySync = await HistoryRepo.RequestErpToCrmSync(companyId, SelectedCompany.HistorySync, force);
await SetWorking.InvokeAsync(false);
}
public void Dispose() public void Dispose()
{ {
Interceptor.DisposeEvent(); Interceptor.DisposeEvent();

View file

@ -41,6 +41,7 @@ public partial class OfficeCustomerActivityListOverlay
{ {
_modalDisplay = "none;"; _modalDisplay = "none;";
_showBackdrop = false; _showBackdrop = false;
ActivityList = new List<ReportItemView>();
StateHasChanged(); StateHasChanged();
} }
} }

View file

@ -39,6 +39,7 @@ public partial class OfficeCustomerActivityViewOverlay
{ {
_modalDisplay = "none;"; _modalDisplay = "none;";
_showBackdrop = false; _showBackdrop = false;
Activity = new ReportItemView();
StateHasChanged(); StateHasChanged();
} }

View file

@ -57,6 +57,7 @@ public partial class OfficeCustomerInventoryItemHistoryOverlay
{ {
_modalDisplay = "none;"; _modalDisplay = "none;";
_showBackdrop = false; _showBackdrop = false;
History = new List<ProductHistoryView>();
StateHasChanged(); StateHasChanged();
} }
} }

View file

@ -48,8 +48,6 @@ public partial class OfficeCustomerInventoryItemReorderOverlay
return; return;
History = await HistoryRepo.GetSkuHistory(Company.CountryCode, Company.CompanyId, SalesItem.Sku); History = await HistoryRepo.GetSkuHistory(Company.CountryCode, Company.CompanyId, SalesItem.Sku);
// if (!History.Any())
// await Task.Delay(500);
SelectedItem.Item = SalesItem; SelectedItem.Item = SalesItem;
SelectedItem.Discount = 0; SelectedItem.Discount = 0;
SelectedItem.Quantity = 1; SelectedItem.Quantity = 1;

View file

@ -40,12 +40,7 @@ public partial class OfficeCustomerInvoiceListOverlay
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
// extract company from customer invoices Invoices = InvoiceList.Invoices.OrderByDescending(x => x.DocumentDate).ToList();
Logger.LogDebug("OfficeInvoiceListOverlay => company => {}", JsonSerializer.Serialize(Company));
// if there is invoices -> order by document date
if (InvoiceList.Invoices.Any())
Invoices = InvoiceList.Invoices.OrderByDescending(x => x.DocumentDate).ToList();
Logger.LogDebug("invoices => {}", JsonSerializer.Serialize(Invoices));
} }
protected override void OnInitialized() protected override void OnInitialized()
@ -68,6 +63,7 @@ public partial class OfficeCustomerInvoiceListOverlay
private void Hide() private void Hide()
{ {
InvoiceList = new InvoiceListView();
_modalDisplay = "none;"; _modalDisplay = "none;";
_showBackdrop = false; _showBackdrop = false;
StateHasChanged(); StateHasChanged();

View file

@ -38,44 +38,19 @@ public partial class OfficeCustomerInvoiceViewOverlay : IDisposable
private string _modalDisplay = ""; private string _modalDisplay = "";
private bool _showBackdrop; private bool _showBackdrop;
private InvoiceView Invoice { get; set; } = new(); private InvoiceView Invoice { get; set; } = new();
// private string SasAmount { get; set; } = "0.00";
// private string NormalAmount { get; set; } = "0.00";
// private string DiscountAmount { get; set; } = "0.00";
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
Interceptor.RegisterEvent(); Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent(); Interceptor.RegisterBeforeSendEvent();
if (!string.IsNullOrWhiteSpace(InvoiceId)) if (string.IsNullOrWhiteSpace(InvoiceId))
{ {
Invoice = await HistoryRepo.GetInvoice( CountryCode, CompanyId, InvoiceId); return;
// CalculateDisplaySums();
} }
Invoice = await HistoryRepo.GetInvoice(CountryCode, CompanyId, InvoiceId);
} }
// private void CalculateDisplaySums()
// {
// var invoiceAmount = decimal.Parse(Invoice.InvoiceAmount);
// var normalLines = Invoice.Lines.Where(x => !x.Sas && !x.Price.Contains("-"));
// var normalSale = (
// from line in normalLines
// let price = int.Parse(line.Qty) * decimal.Parse(line.Price)
// select decimal.Parse(line.Qty) == 0
// ? price : price + price * decimal.Parse(line.Qty) / 100).Sum();
// NormalAmount = $"{normalSale:N2}";
//
// var sasLines = Invoice.Lines.Where(x => x.Sas && !x.Price.Contains("-"));
// var sasSale = (
// from line in sasLines
// let price = int.Parse(line.Qty) * decimal.Parse(line.Price)
// select price).Sum();
// SasAmount = $"{sasSale:N2}";
//
// if (normalSale > invoiceAmount)
// DiscountAmount = $"{normalSale - invoiceAmount:N2}";
// }
public void Show() public void Show()
{ {
_modalDisplay = "block;"; _modalDisplay = "block;";

View file

@ -49,12 +49,9 @@ public partial class OfficeCustomerListInventoryOverlay
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
// sort the base Inventory if (Inventory.Count <= 0) return;
Inventory = Utils.SortInventory(Inventory, SortColumn, Descending); Inventory = Utils.SortInventory(Inventory, SortColumn, Descending);
// initialize FilteredList
ApplyInventoryFilter(DisplayFilter); ApplyInventoryFilter(DisplayFilter);
Logger.LogDebug("OfficeCustomerListInventoryOverlay {}", JsonSerializer.Serialize(DisplayList));
} }
@ -106,6 +103,7 @@ public partial class OfficeCustomerListInventoryOverlay
{ {
_modalDisplay = "none;"; _modalDisplay = "none;";
_showBackdrop = false; _showBackdrop = false;
Inventory = new List<ProductInventoryItemView>();
StateHasChanged(); StateHasChanged();
} }
} }

View file

@ -80,6 +80,7 @@ public partial class OfficeCustomerOrderInventoryListOverlay : IDisposable
{ {
_modalDisplay = "none;"; _modalDisplay = "none;";
_showBackdrop = false; _showBackdrop = false;
Inventory = new List<ProductInventoryItemView>();
StateHasChanged(); StateHasChanged();
} }

View file

@ -92,6 +92,7 @@ public partial class OfficeCustomerOrderInventoryReorderOverlay
SelectedItem = new DraftItem(); SelectedItem = new DraftItem();
_modalDisplay = "none;"; _modalDisplay = "none;";
_showBackdrop = false; _showBackdrop = false;
ProductHistory = new List<ProductHistoryView>();
StateHasChanged(); StateHasChanged();
} }
} }

View file

@ -1,8 +1,8 @@
{ {
"appInfo": { "appInfo": {
"name": "Wonky Online", "name": "Wonky Online",
"version": "309.0", "version": "310.0",
"rc": true, "rc": false,
"sandBox": true, "sandBox": true,
"image": "grumpy-coder.png", "image": "grumpy-coder.png",
"sdk": "dotnet 8.0" "sdk": "dotnet 8.0"

View file

@ -14,8 +14,9 @@ sed -i "s|\"version\":.*|\"version\": \"$1\",|g" "${FILE}"
sed -i 's|\"rc\":.*|\"rc\": true,|g' "${FILE}" sed -i 's|\"rc\":.*|\"rc\": true,|g' "${FILE}"
sed -i 's|\"sandBox\":.*|\"sandBox\": false,|g' "${FILE}" sed -i 's|\"sandBox\":.*|\"sandBox\": false,|g' "${FILE}"
sed -i 's|\"Default": \"Debug\",|\"Default": \"None\",|g' "${FILE}" # need debugging in next build
sed -i 's|\"System": \"Debug\",|\"System": \"None\",|g' "${FILE}" #sed -i 's|\"Default": \"Debug\",|\"Default": \"None\",|g' "${FILE}"
#sed -i 's|\"System": \"Debug\",|\"System": \"None\",|g' "${FILE}"
sed -i 's|\"Microsoft\": \"Information\",|\"Microsoft\": \"None\",|g' "${FILE}" sed -i 's|\"Microsoft\": \"Information\",|\"Microsoft\": \"None\",|g' "${FILE}"
sed -i 's|\"Microsoft\": \"Debug\",|\"Microsoft\": \"None\",|g' "${FILE}" sed -i 's|\"Microsoft\": \"Debug\",|\"Microsoft\": \"None\",|g' "${FILE}"