Co-authored-by: Claudio Schaad <c.schaad@pog.ch> Co-committed-by: Claudio Schaad <c.schaad@pog.ch>
33 lines
No EOL
1.1 KiB
C#
33 lines
No EOL
1.1 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Schaad.Accounting.Datasets;
|
|
using Schaad.Accounting.Interfaces;
|
|
|
|
namespace Schaad.Accounting.UI.Components.Pages.Reports;
|
|
|
|
public partial class ProfitLossReport : ComponentBase
|
|
{
|
|
[Inject]
|
|
private IViewService viewService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private ISettingsService settingsService { get; set; } = null!;
|
|
|
|
private IReadOnlyList<AccountDataset>? accounts;
|
|
private decimal profit;
|
|
private decimal loss;
|
|
private decimal win;
|
|
private string header = "";
|
|
private string footer = "";
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
accounts = await viewService.GetAccountViewListAsync();
|
|
profit = Math.Abs(accounts.Where(m => m.Class == ClassIds.Income).Sum(m => m.Balance));
|
|
loss = Math.Abs(accounts.Where(m => m.Class == ClassIds.Expenses).Sum(m => m.Balance));
|
|
win = profit - loss;
|
|
|
|
(header, footer) = Report.GetViewDataTitleAndFooter("Erfolgsrechnung", settingsService);
|
|
|
|
await base.OnInitializedAsync();
|
|
}
|
|
} |