New source control repo for Biskilog POS - secure hub to store & manage source code. Streamlines dev process, tracks changes, & improves collaboration. Ensures reliable software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

61 lines
2.5 KiB

using Biskilog_Accounting.Shared.CustomModels;
using Microsoft.AspNetCore.Components;
namespace Biskilog_Accounting.Client.Pages.Dashboard.Elements
{
public partial class WelcomeCard
{
[Parameter]
public string Username { get; set; } = string.Empty;
[Parameter]
public TradeSummary TradeSummary { get; set; } = new TradeSummary();
[Parameter]
public bool IsLoading { get; set; } = true;
private string m_remarks { get; set; } = "";
private string m_currentTrade { get; set; } = string.Empty;
private string m_previousTrade { get; set; } = string.Empty;
protected override void OnParametersSet()
{
CalculateStatistic();
}
private void CalculateStatistic()
{
if (TradeSummary.CurrentTradeDate != DateTime.Today)
{
m_currentTrade = $"most recent trade date ({TradeSummary.CurrentTradeDate.ToString("dd MMM,yyy")})";
}
else
{
m_currentTrade = "current trade";
}
if (TradeSummary.LastTradeDate != DateTime.Today.AddDays(-1))
{
m_previousTrade = $"previous trade date ({TradeSummary.LastTradeDate.ToString("dd MMM,yyy")})";
}
else
{
m_previousTrade = "previous trade";
}
double change = ((TradeSummary.CurrentTradeSales - TradeSummary.LastTradeSales) / TradeSummary.LastTradeSales) * 100;
if (TradeSummary.CurrentTradeSales > TradeSummary.LastTradeSales)
{
string changePercent = change.ToString("0.00") + "%";
m_remarks = $"You made a total of {m_calculator.FormatMoneyWithCurrency(TradeSummary.CurrentTradeSales)} in the {m_currentTrade}, {changePercent} more than the sales in the {m_previousTrade}";
}
else if (TradeSummary.LastTradeSales > TradeSummary.CurrentTradeSales)
{
string changePercent = (change * -1).ToString("0.00") + "%";
m_remarks = $"You made a total of {m_calculator.FormatMoneyWithCurrency(TradeSummary.CurrentTradeSales)} in the {m_currentTrade}, {changePercent} less than the sales in the {m_previousTrade}";
}
else
{
m_remarks = $"You made a total of {m_calculator.FormatMoneyWithCurrency(TradeSummary.CurrentTradeSales)} in the {m_currentTrade}, same as the sales in the {m_previousTrade}";
}
StateHasChanged();
}
}
}