|
|
@ -6,6 +6,7 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
{ |
|
|
|
public partial class Dashboard |
|
|
|
{ |
|
|
|
#region Declarations
|
|
|
|
private TradeSummary m_tradeSummary { get; set; } = new TradeSummary(); |
|
|
|
private List<WeeklySaleItem> m_weeklySaleItems { get; set; } = new List<WeeklySaleItem> { }; |
|
|
|
private List<CancelledSales> m_weeklyCancelledSales { get; set; } = new List<CancelledSales> { }; |
|
|
@ -17,10 +18,18 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
private double m_cancelledPercentage { get; set; } = 0; |
|
|
|
private double m_totalDebt { get; set; } = 0; |
|
|
|
private string m_username { get; set; } = string.Empty; |
|
|
|
private bool loadWeeklySales = true; |
|
|
|
private bool loadingPriceHistory = true; |
|
|
|
#region Loading Variables
|
|
|
|
private bool m_loadingWeeklySales = true; |
|
|
|
private bool m_loadingPriceHistory = true; |
|
|
|
private bool m_loadingMostPurchased { get; set; } = true; |
|
|
|
|
|
|
|
private bool m_loadingTradeSummary { get; set; } = true; |
|
|
|
private bool m_loadingDebtSummary { get; set; } = true; |
|
|
|
private bool m_loadingLowStockSummary { get; set; } = true; |
|
|
|
private bool m_loadingRecentTransactionsSummary { get; set; } = true; |
|
|
|
private bool m_loadingCancelledSummary { get; set; } = true; |
|
|
|
private bool m_loadingCreditSummary { get; set; } = true; |
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
protected override async Task OnInitializedAsync() |
|
|
|
{ |
|
|
|
m_username = m_tokenService.GetUserNameFromToken(await m_tokenService.GetToken())!; |
|
|
@ -48,9 +57,6 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
productPriceChangeHistoryTask |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
// Rest of the code...
|
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@ -62,6 +68,8 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
m_loadingTradeSummary = true; |
|
|
|
StateHasChanged(); |
|
|
|
var response = await m_http.GetAsync("api/analytics/tradesummary"); |
|
|
|
if (response.IsSuccessStatusCode) |
|
|
|
{ |
|
|
@ -69,6 +77,7 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; |
|
|
|
var tradeSummary = JsonSerializer.Deserialize<TradeSummary>(jsonContent, options); |
|
|
|
m_tradeSummary = tradeSummary; |
|
|
|
m_loadingTradeSummary = false; |
|
|
|
StateHasChanged(); |
|
|
|
} |
|
|
|
} |
|
|
@ -85,6 +94,8 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
m_loadingDebtSummary = true; |
|
|
|
StateHasChanged(); |
|
|
|
var response = await m_http.GetAsync("api/analytics/debtors"); |
|
|
|
if (response.IsSuccessStatusCode) |
|
|
|
{ |
|
|
@ -92,6 +103,7 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; |
|
|
|
var debt = JsonSerializer.Deserialize<List<InDebtCustomers>>(jsonContent, options); |
|
|
|
m_totalDebt = (double)debt.Sum(c => c.Debt); |
|
|
|
m_loadingDebtSummary = false; |
|
|
|
StateHasChanged(); |
|
|
|
} |
|
|
|
} |
|
|
@ -108,6 +120,8 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
m_loadingWeeklySales = true; |
|
|
|
StateHasChanged(); |
|
|
|
var response = await m_http.GetAsync("api/analytics/sales/weekly"); |
|
|
|
if (response.IsSuccessStatusCode) |
|
|
|
{ |
|
|
@ -115,7 +129,7 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; |
|
|
|
var sales = JsonSerializer.Deserialize<List<WeeklySaleItem>>(jsonContent, options); |
|
|
|
m_weeklySaleItems = sales; |
|
|
|
loadWeeklySales = false; |
|
|
|
m_loadingWeeklySales = false; |
|
|
|
StateHasChanged(); |
|
|
|
} |
|
|
|
} |
|
|
@ -132,8 +146,10 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
DateTime start = DateTime.Now.AddDays(-7).Date; |
|
|
|
DateTime end = DateTime.Now.Date; |
|
|
|
m_loadingCancelledSummary = true; |
|
|
|
StateHasChanged(); |
|
|
|
string start = m_tradeSummary.CurrentTradeDate.Date.AddDays(-7).ToString("yyyy-MM-dd"); |
|
|
|
string end = m_tradeSummary.CurrentTradeDate.ToString("yyyy-MM-dd"); |
|
|
|
var response = await m_http.GetAsync($"api/analytics/cancelledsales/{start}/{end}"); |
|
|
|
if (response.IsSuccessStatusCode) |
|
|
|
{ |
|
|
@ -143,24 +159,21 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
m_weeklyCancelledSales = weekly; |
|
|
|
|
|
|
|
var loadCancelledSales = m_weeklyCancelledSales.OrderByDescending(t => t.CancelledTransaction.DateCancelled); |
|
|
|
if (loadCancelledSales.Count() > 1) |
|
|
|
if (loadCancelledSales.Count() >= 1) |
|
|
|
{ |
|
|
|
m_cancelledWeeklySale = (double)loadCancelledSales.ToList()[0].Value; |
|
|
|
m_cancelledPercentage = (((double)loadCancelledSales.ToList()[0].Value - (double)loadCancelledSales.ToList()[1].Value) / (double)loadCancelledSales.ToList()[0].Value) * 100; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
m_cancelledWeeklySale = (double)loadCancelledSales.FirstOrDefault().Value; |
|
|
|
m_cancelledWeeklySale = 0; |
|
|
|
m_cancelledPercentage = 0; |
|
|
|
} |
|
|
|
|
|
|
|
m_loadingCancelledSummary = false; |
|
|
|
StateHasChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
Console.WriteLine(ex.Message); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// Gets the recent transaction
|
|
|
@ -170,6 +183,8 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
m_loadingRecentTransactionsSummary = true; |
|
|
|
StateHasChanged(); |
|
|
|
var response = await m_http.GetAsync($"api/analytics/sales/recent/{50}"); |
|
|
|
if (response.IsSuccessStatusCode) |
|
|
|
{ |
|
|
@ -177,6 +192,7 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; |
|
|
|
var recent = JsonSerializer.Deserialize<List<SaleItem>>(jsonContent, options); |
|
|
|
m_recentTransaction = recent; |
|
|
|
m_loadingRecentTransactionsSummary = false; |
|
|
|
StateHasChanged(); |
|
|
|
} |
|
|
|
} |
|
|
@ -191,6 +207,7 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
try |
|
|
|
{ |
|
|
|
m_loadingMostPurchased = true; |
|
|
|
StateHasChanged(); |
|
|
|
string start = m_tradeSummary.LastTradeDate.ToString("yyyy-MM-dd"); |
|
|
|
string end = m_tradeSummary.CurrentTradeDate.ToString("yyyy-MM-dd"); |
|
|
|
var response = await m_http.GetAsync($"api/analytics/mostpurchaseditem/" + start + "/" + end); |
|
|
@ -214,6 +231,8 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
m_loadingLowStockSummary = true; |
|
|
|
StateHasChanged(); |
|
|
|
var response = await m_http.GetAsync($"api/analytics/lowonstock"); |
|
|
|
if (response.IsSuccessStatusCode) |
|
|
|
{ |
|
|
@ -221,12 +240,11 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; |
|
|
|
var recent = JsonSerializer.Deserialize<List<ProductItem>>(jsonContent, options); |
|
|
|
m_lowstock = recent; |
|
|
|
m_loadingLowStockSummary = false; |
|
|
|
StateHasChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// Gets a collection of items that are low on stock
|
|
|
@ -236,6 +254,8 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
m_loadingPriceHistory = true; |
|
|
|
StateHasChanged(); |
|
|
|
var response = await m_http.GetAsync($"api/analytics/pricechanges/product/history/{5}"); |
|
|
|
if (response.IsSuccessStatusCode) |
|
|
|
{ |
|
|
@ -243,13 +263,11 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard |
|
|
|
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; |
|
|
|
var recent = JsonSerializer.Deserialize<List<ProductPriceChange>>(jsonContent, options); |
|
|
|
m_ProductPriceChanges = recent; |
|
|
|
loadingPriceHistory = false; |
|
|
|
m_loadingPriceHistory = false; |
|
|
|
StateHasChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|