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.

41 lines
1.7 KiB

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 double CurrentTradeSales { get; set; } = 0;
[Parameter]
public double PreviousTradeSales { get; set; } = 0;
private string m_remarks { get; set; } = "";
protected override void OnInitialized()
{
CalculateStatistic();
base.OnInitialized();
}
private void CalculateStatistic()
{
if (CurrentTradeSales > PreviousTradeSales)
{
double change = (CurrentTradeSales / (CurrentTradeSales + PreviousTradeSales)) * 100;
string changePercent = change.ToString("0.00") + "%";
m_remarks = $"You made a total of {m_calculator.FormatMoneyWithCurrency(CurrentTradeSales)} in the current trade, {changePercent} more than the previous trade sales";
}
else if (PreviousTradeSales > CurrentTradeSales) {
double change = (CurrentTradeSales / (CurrentTradeSales + PreviousTradeSales)) * -100;
string changePercent = change.ToString("0.00") + "%";
m_remarks = $"You made a total of {m_calculator.FormatMoneyWithCurrency(CurrentTradeSales)} in the current trade, {changePercent} less than the previous trade sales";
} else {
m_remarks = $"You made a total of {m_calculator.FormatMoneyWithCurrency(CurrentTradeSales)} in the current trade, same as the previous trade sales";
}
}
}
}