Compare commits

..

6 commits

Author SHA1 Message Date
ca4a67f20a Remove Akonto and Saldo from the electricity bills
Drop the advance payment (AdvanceChf) and the computed Balance from
ElectricityBill, the Strom list, the edit dialog and the help image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 19:33:52 +01:00
df52237420 Show the Strom charts per half-year
Each bill's values are spread evenly over the months of its period and
summed per calendar half-year, so a yearly July-June bill contributes
half to each of its two halves. Half-years without a bill appear as gaps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 19:28:29 +01:00
52870bb089 Show charts above the bill list on the Strom page
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 19:25:34 +01:00
034bc4e0f0 Add a total-costs-per-period line chart to the Strom page
A third chart below the existing pair, plotting ElectricityBill.TotalChf
per period.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-26 16:29:32 +01:00
ec0bf7d602 Split the CHF/kWh chart by Netz/PV and fix its axis scale
The price-per-kWh line only showed the blended total; add GridChfPerKwh
and PvChfPerKwh (null when there was no draw/consumption of that kind,
so the chart shows a gap instead of a misleading 0) and plot Netz, PV
and Total as separate lines.

Also fixes the y-axis: ticks used a fixed 0-decimal formatter, so
CHF/kWh values (well under 1) all rounded to "0". charts.js now takes
an optional data.axisDecimals (defaults to 0, so the Analyse page is
unaffected); the Strom page passes 2 for its CHF/kWh chart.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-26 16:27:17 +01:00
7d7bd6073c Add "Strom" page for the yearly NeoVac electricity bill
A new page (/electricity) to record one electricity bill per billing
period (1 July-30 June) with a grid, add/edit dialog, and two Chart.js
charts (kWh split grid/PV per period, CHF/kWh as a line).

- ElectricityBill (Common): Grid/PV kWh and CHF, side costs, advance
  payment; computed TotalKwh, PvShare, TotalChf, Balance, ChfPerKwh.
- Stored once per mandator at {DataPath}/{mandator}/electricity.json
  instead of per year, since the billing period doesn't align with
  calendar years (new ISettingsService.GetMandatorPath(),
  BaseRepository gets a directory-aware SaveAsync overload).
- electricity.json is also editable through the JSON editor
  (RawDataRepository).
- charts.js: stackedBar/line charts can now show a unit other than
  CHF (defaults to CHF, so the Analyse page is unaffected).
- The add/edit dialog links to an annotated example (SVG, placeholder
  data) showing which value on the real NeoVac bill goes into which
  field; opens in its own dialog since the main dialog has a fixed
  height.
- Tests for the computed properties and the new repositories.

Also bumps the TargetFramework to net10.0 and updates the local
DataPath in appsettings.Development.json.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-25 20:30:40 +01:00
121 changed files with 60387 additions and 2610 deletions

View file

@ -47,27 +47,24 @@ Data is multi-mandator and multi-year. The layout below `DataPath` (configured i
```
{DataPath}/{mandator}/{year}/*.json data files
{DataPath}/{mandator}/electricity.json electricity bills (not per year, see below)
{DataPath}/{mandator}/water.json water bills (not per year, see below)
{DataPath}/{mandator}/water-heating.json NeoVac water and heating bills (not per year, see below)
{DataPath}/uploads/{mandator}/{year}/ imported bank statements (+ creditCard/)
{DataPath}/backup/{mandator}/{year}/ backup zips
```
When a new year is opened, the previous year's data is copied as the starting point.
`electricity.json`, `water.json` and `water-heating.json` are the data files kept per mandator instead of per year (`ISettingsService.GetMandatorPath()`), because the NeoVac billing period runs 1 July–30 June and doesn't align with calendar years.
`electricity.json` is the one data file kept per mandator instead of per year (`ISettingsService.GetMandatorPath()`), because the NeoVac billing period runs 1 July–30 June and doesn't align with calendar years.
### Key services
- **ViewService** — aggregates account balances, applies FX rates, builds datasets for the UI
- **FileService** — imports bank statements (MT940, CAMT053 via external `Schaad.Finance.dll`; uploads go to temp files only), manages backups
- **FileService** — imports bank statements (MT940, CAMT053 via external `Schaad.Finance.dll`), parses PDFs, manages backups
- **ChartService** — produces data for the Plotly booking-text charts on the transactions page
- **SettingsService** — manages the active year, mandator, and file paths
- **RawDataRepository** — plain-text load/save of the data files for the JSON editor page; validates (strict JSON, unique Ids, account references), refuses if the file changed since loading, and backs up the old version to `backup/{mandator}/{year}/json-{timestamp}/`; for `electricity.json`, `water.json` and `water-heating.json` it reads/writes the mandator folder instead of the year folder
- **RawDataRepository** — plain-text load/save of the data files for the JSON editor page; validates (strict JSON, unique Ids, account references), refuses if the file changed since loading, and backs up the old version to `backup/{mandator}/{year}/json-{timestamp}/`; for `electricity.json` it reads/writes the mandator folder instead of the year folder
- **Texte bereinigen** page (`TextCleanup`) — edits only the `Text` of one account's bookings in the selected year (inline, search/replace via `TextReplacement`, bulk set); saves through `RawDataRepository.SaveTransactionTextsAsync`
- **AnalyticsService** — loads all years of the current mandator (via `MultiYearRepository`) into an `AccountingAnalysis` (expenses, income, net, assets) for the Analyse page; queries run in memory
- **Strom** page (`Electricity`, `/electricity`, under "Charts" in the menu) — grid and dialog (FluentDataGrid/`ElectricityBillDialog`) over `IElectricityBillRepository`'s `ElectricityBill` records (one yearly NeoVac bill each: kWh/CHF for grid and PV, side costs; `TotalKwh`, `PvShare`, `TotalChf`, `ChfPerKwh` are computed); three Chart.js charts via `ChartJsChart` (stacked kWh, CHF/kWh lines, total CHF), filtered by the shared `BillChartToolbar` (`BillChartFilter`): grouped per bill, calendar year (default) or half-year (`BillPeriod<T>.FromBills` over `IPeriodBill<T>`; a bill reaching over several periods is spread evenly over its months and the page shows a note) and limited to a from/to year range (periods overlapping it are kept whole)
- **Wasser** page (`Water`, `/water`, under "Charts" in the menu) — same layout as Strom over `IWaterBillRepository`'s `WaterBill` records (warm/cold water m³ and CHF, base costs; `TotalM3`, `WarmWaterShare`, `TotalChf` are computed); two charts (stacked m³, total CHF) with the same `BillChartToolbar`
- **Wasser & Heizung** page (`WaterHeating`, `/water-heating`, under "Charts" in the menu) — same layout for NeoVac bills where only per-mille shares are known, over `IWaterHeatingBillRepository`'s `WaterHeatingBill` records: consumption (warm/cold m³, heat MWh) and ‰ shares from NeoVac, own water/heating costs in CHF from the property manager's statement; `WaterHeatingBillDialog` calls `CalculateCosts`, which stores the CHF parts (water split into base/consumption by ‰, consumption split by m³, warm water part of the heating), so `AddShare` can sum them per period; `RoomHeatingChf` is the rest of the heating. The dialog shows plausibility checks from `WaterHeatingBillChecks` (NeoVac ‰ vs. the optional ‰ of the property manager, implied property totals, prices per unit vs. the previous bill, flagged above ±25 %). Three charts (stacked m³, MWh, stacked CHF) and a guide image (`water-heating-bill-guide.svg`)
- **Strom** page (`Electricity`, `/electricity`) — grid and dialog (FluentDataGrid/`ElectricityBillDialog`) over `IElectricityBillRepository`'s `ElectricityBill` records (one yearly NeoVac bill each: kWh/CHF for grid and PV, side costs; `TotalKwh`, `PvShare`, `TotalChf`, `ChfPerKwh` are computed); three Chart.js charts via `ChartJsChart`, one value per calendar half-year (`ElectricityHalfYear` spreads each bill evenly over its months): stacked kWh, CHF/kWh lines, total CHF
### UI structure
@ -77,9 +74,9 @@ Pages live in `Schaad.Accounting.UI/Components/Pages/`. Each page typically has
- `Microsoft.FluentUI.AspNetCore.Components` — UI components (FluentDataGrid, FluentDialog, etc.)
- `Plotly.Blazor` — charts on the older chart pages
- `BlazorMonaco` — Monaco editor for the JSON editor page; loaded on demand by `wwwroot/js/monaco.js` instead of script tags in `App.razor`. Pages are interactive one by one, so `NavigationManager.NavigateTo` and menu links run enhanced navigation, which syncs `<head>` (removing Monaco's styles; `monaco.js` puts them back) and re-renders the page on the server. The editor therefore switches files in place and only rewrites the URL (`wwwroot/js/url.js`)
- Chart.js 4 + `chartjs-chart-treemap` — charts on the Analyse page; vendored in `wwwroot/lib/` (no CDN), wrapped by `wwwroot/js/charts.js` and `ChartJsChart.razor`; `charts.js` hides Monaco's global AMD `define` while loading them, otherwise the UMD bundles register as AMD modules and `window.Chart` stays undefined after visiting the JSON editor
- Bootstrap 5 — only `wwwroot/lib/bootstrap/dist/css/bootstrap.min.css` (base element styles and a few utilities like `text-danger`); no Bootstrap JS
- `BlazorMonaco` — Monaco editor for the JSON editor page; loaded on demand by `wwwroot/js/monaco.js` instead of script tags in `App.razor`
- Chart.js 4 + `chartjs-chart-treemap` — charts on the Analyse page; vendored in `wwwroot/lib/` (no CDN), wrapped by `wwwroot/js/charts.js` and `ChartJsChart.razor`
- `FreeSpire.PDF` — PDF parsing for bank statement imports
- `Schaad.Finance.dll` / `Schaad.Finance.Api.dll` — proprietary DLLs for MT940/CAMT053 parsing and FX rate lookups (FixerIo API key in `appsettings.Development.json`)
### Domain constants

View file

@ -5,6 +5,7 @@
<ItemGroup>
<PackageVersion Include="BlazorMonaco" Version="3.5.0" />
<PackageVersion Include="coverlet.collector" Version="10.1.0" />
<PackageVersion Include="FreeSpire.PDF" Version="12.4.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.13" />
<PackageVersion Include="Microsoft.FluentUI.AspNetCore.Components" Version="4.14.5" />
<PackageVersion Include="Microsoft.FluentUI.AspNetCore.Components.Emoji" Version="4.14.5" />

View file

@ -4,17 +4,21 @@ namespace Schaad.Accounting
/// Folder layout below DataPath:
/// <code>
/// {DataPath}/{mandator}/{year}/*.json data files
/// {DataPath}/uploads/{mandator}/{year}/ imported bank statements (+ creditCard/)
/// {DataPath}/backup/{mandator}/{year}/ backup zips
/// </code>
/// </summary>
public static class DataFolders
{
public const string Uploads = "uploads";
public const string Backup = "backup";
public const string CreditCard = "creditCard";
/// <summary>
/// True for the top-level folders that are not mandators.
/// </summary>
public static bool IsReserved(string folderName)
=> folderName.Equals(Backup, System.StringComparison.OrdinalIgnoreCase);
=> folderName.Equals(Uploads, System.StringComparison.OrdinalIgnoreCase)
|| folderName.Equals(Backup, System.StringComparison.OrdinalIgnoreCase);
}
}

View file

@ -9,6 +9,8 @@ namespace Schaad.Accounting.Interfaces
void SetYear(int year);
bool TrySetYear(int year);
string GetMandator();
IReadOnlyList<string> GetMandators(int year);
@ -16,13 +18,17 @@ namespace Schaad.Accounting.Interfaces
string GetBackupFilePath();
string GetUploadPath();
string GetCreditCardStatementPath();
string GetDbPath();
string GetLastYearDbPath();
/// <summary>
/// The mandator's folder, above the per-year folders. For data that is not kept per
/// year (e.g. the electricity and water bills, whose period doesn't align with calendar years).
/// year (e.g. the electricity bills, whose period doesn't align with calendar years).
/// </summary>
string GetMandatorPath();

View file

@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Schaad.Accounting.Models;
namespace Schaad.Accounting.Interfaces
{
public interface ISplitPredefinitionRepository
{
Task<List<SplitPredefinition>> GetSplitPredefinitionListAsync();
Task SaveSplitPredefinitionAsync(SplitPredefinition splitPredefinition);
}
}

View file

@ -14,6 +14,8 @@ namespace Schaad.Accounting.Interfaces
Task DeleteSubClassAsync(string id);
Dictionary<int, string> GetClasses();
string GetClass(int classId);
}
}

View file

@ -1,17 +0,0 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Schaad.Accounting.Models;
namespace Schaad.Accounting.Interfaces
{
public interface IWaterBillRepository
{
Task<List<WaterBill>> GetWaterBillListAsync();
Task SaveWaterBillAsync(WaterBill bill);
Task<WaterBill> GetWaterBillAsync(string id);
Task DeleteWaterBillAsync(string id);
}
}

View file

@ -1,17 +0,0 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Schaad.Accounting.Models;
namespace Schaad.Accounting.Interfaces
{
public interface IWaterHeatingBillRepository
{
Task<List<WaterHeatingBill>> GetWaterHeatingBillListAsync();
Task SaveWaterHeatingBillAsync(WaterHeatingBill bill);
Task<WaterHeatingBill> GetWaterHeatingBillAsync(string id);
Task DeleteWaterHeatingBillAsync(string id);
}
}

View file

@ -1,57 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Schaad.Accounting.Models
{
/// <summary>
/// What the charts on the Strom and Wasser pages show: how the bills are grouped (calendar year
/// by default) and which years. A null <see cref="FromYear"/>/<see cref="ToYear"/> means from the first/to the last
/// year with a bill, so a newly added bill shows up without touching the filter.
/// </summary>
public record BillChartFilter(BillPeriodKind Kind = BillPeriodKind.Year, int? FromYear = null, int? ToYear = null)
{
/// <summary>The years any bill touches, from the first to the last; empty without bills.</summary>
public static List<int> YearsOf<T>(IEnumerable<T> bills) where T : IPeriodBill<T>
{
var list = bills.ToList();
if (list.Count == 0)
{
return [];
}
var first = list.Min(b => b.PeriodFrom.Year);
var last = list.Max(b => b.PeriodTo.Year);
return Enumerable.Range(first, Math.Max(last - first, 0) + 1).ToList();
}
/// <summary>The selected years, clamped to <paramref name="years"/> (which must not be empty).</summary>
public (int From, int To) RangeIn(IReadOnlyList<int> years)
{
var from = Math.Clamp(FromYear ?? years[0], years[0], years[^1]);
var to = Math.Clamp(ToYear ?? years[^1], years[0], years[^1]);
return from <= to ? (from, to) : (to, from);
}
/// <summary>True if the filter covers all of <paramref name="years"/>.</summary>
public bool CoversAll(IReadOnlyList<int> years) => RangeIn(years) == (years[0], years[^1]);
/// <summary>
/// Groups the bills by <see cref="Kind"/> and keeps the periods that overlap the selected
/// years. A bill (or calendar period) reaching into the range is kept whole, e.g. the bill
/// 1.7.2023–30.6.2024 for the range 2024–2024.
/// </summary>
public List<BillPeriod<T>> Apply<T>(IEnumerable<T> bills) where T : class, IPeriodBill<T>, new()
{
var list = bills.ToList();
var years = YearsOf(list);
if (years.Count == 0)
{
return [];
}
var (from, to) = RangeIn(years);
return BillPeriod<T>.FromBills(list, Kind)
.Where(p => p.From.Year <= to && p.To.Year >= from)
.ToList();
}
}
}

View file

@ -1,121 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Schaad.Accounting.Models
{
/// <summary>How bills are grouped for the charts on the Strom and Wasser pages.</summary>
public enum BillPeriodKind
{
/// <summary>One entry per bill, exactly as entered.</summary>
Bill,
/// <summary>One entry per calendar year.</summary>
Year,
/// <summary>One entry per calendar half-year (January–June or July–December).</summary>
HalfYear
}
/// <summary>
/// One period of bills, for the charts on the Strom and Wasser pages. <see cref="Bill"/> holds
/// the bill values that fall into this period, or is null if no bill covers it.
/// </summary>
public class BillPeriod<T> where T : class, IPeriodBill<T>, new()
{
public BillPeriodKind Kind { get; init; }
public DateOnly From { get; init; }
public DateOnly To { get; init; }
public T Bill { get; init; }
/// <summary>
/// True if the values were (partly) spread from a bill whose period reaches beyond this one,
/// i.e. they are estimated rather than billed.
/// </summary>
public bool IsSplit { get; init; }
/// <summary>Short label for a chart axis, e.g. "23/24", "2024" or "H2 23".</summary>
public string Label => Kind switch
{
BillPeriodKind.Year => From.Year.ToString(),
BillPeriodKind.HalfYear => $"H{(From.Month <= 6 ? 1 : 2)} {From:yy}",
_ => IsWholeBillingYear ? $"{From:yy}/{To:yy}" : $"{From:dd.MM.yy}–{To:dd.MM.yy}"
};
private bool IsWholeBillingYear => From.Day == 1 && To == From.AddYears(1).AddDays(-1);
/// <summary>
/// Groups the bills by <paramref name="kind"/>. With <see cref="BillPeriodKind.Bill"/>
/// each bill is its own period. Otherwise the result runs from the first to the last covered
/// calendar period (periods in between that no bill covers are included with a null Bill),
/// and a bill's values are spread evenly over the months of its period, so a yearly bill
/// (1 July – 30 June) contributes exactly half to each of its two half-years or calendar years.
/// </summary>
public static List<BillPeriod<T>> FromBills(IEnumerable<T> bills, BillPeriodKind kind)
{
if (kind == BillPeriodKind.Bill)
{
return bills
.OrderBy(b => b.PeriodFrom)
.Select(b => new BillPeriod<T> { Kind = kind, From = b.PeriodFrom, To = b.PeriodTo, Bill = b })
.ToList();
}
var length = kind == BillPeriodKind.Year ? 12 : 6;
var sums = new SortedDictionary<DateOnly, T>();
var split = new HashSet<DateOnly>();
foreach (var bill in bills)
{
var months = MonthIndex(bill.PeriodTo) - MonthIndex(bill.PeriodFrom) + 1;
if (months <= 0)
{
continue;
}
var monthsPerPeriod = Enumerable.Range(0, months)
.Select(m => PeriodStart(bill.PeriodFrom.AddMonths(m), length))
.GroupBy(start => start)
.ToList();
foreach (var period in monthsPerPeriod)
{
var share = (decimal)period.Count() / months;
if (!sums.TryGetValue(period.Key, out var sum))
{
sum = new T { PeriodFrom = period.Key, PeriodTo = period.Key.AddMonths(length).AddDays(-1) };
sums[period.Key] = sum;
}
if (monthsPerPeriod.Count > 1)
{
split.Add(period.Key);
}
sum.AddShare(bill, share);
}
}
var result = new List<BillPeriod<T>>();
if (sums.Count == 0)
{
return result;
}
for (var start = sums.Keys.First(); start <= sums.Keys.Last(); start = start.AddMonths(length))
{
result.Add(new BillPeriod<T>
{
Kind = kind,
From = start,
To = start.AddMonths(length).AddDays(-1),
Bill = sums.GetValueOrDefault(start),
IsSplit = split.Contains(start)
});
}
return result;
}
private static int MonthIndex(DateOnly date) => date.Year * 12 + date.Month - 1;
private static DateOnly PeriodStart(DateOnly date, int length) => new(date.Year, (date.Month - 1) / length * length + 1, 1);
}
}

View file

@ -9,7 +9,7 @@ namespace Schaad.Accounting.Models
/// 1 July – 30 June, so these are not stored per calendar year like the other data files
/// (see ElectricityBillRepository in Schaad.Accounting.Db).
/// </summary>
public class ElectricityBill : IPeriodBill<ElectricityBill>
public class ElectricityBill
{
public string Id { get; set; }
@ -65,14 +65,5 @@ namespace Schaad.Accounting.Models
[JsonIgnore]
[Display(Name = "CHF/kWh PV")]
public decimal? PvChfPerKwh => PvKwh == 0 ? null : PvChf / PvKwh;
public void AddShare(ElectricityBill other, decimal share)
{
GridKwh += other.GridKwh * share;
PvKwh += other.PvKwh * share;
GridChf += other.GridChf * share;
PvChf += other.PvChf * share;
SideCostsChf += other.SideCostsChf * share;
}
}
}

View file

@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Schaad.Accounting.Models
{
/// <summary>
/// One calendar half-year (January–June or July–December) of electricity bills, for the
/// charts on the Strom page. <see cref="Bill"/> holds the bill values that fall into this
/// half-year, or is null if no bill covers it.
/// </summary>
public class ElectricityHalfYear
{
public DateOnly From { get; init; }
public ElectricityBill Bill { get; init; }
/// <summary>Short label for a chart axis, e.g. "H2 23".</summary>
public string Label => $"H{(From.Month <= 6 ? 1 : 2)} {From:yy}";
/// <summary>
/// Splits the bills into calendar half-years, from the first to the last covered one
/// (half-years in between that no bill covers are included with a null Bill). A bill's
/// values are spread evenly over the months of its period, so a yearly bill (1 July –
/// 30 June) contributes exactly half to each of its two half-years.
/// </summary>
public static List<ElectricityHalfYear> FromBills(IEnumerable<ElectricityBill> bills)
{
var sums = new SortedDictionary<DateOnly, ElectricityBill>();
foreach (var bill in bills)
{
var months = MonthIndex(bill.PeriodTo) - MonthIndex(bill.PeriodFrom) + 1;
if (months <= 0)
{
continue;
}
var monthsPerHalf = Enumerable.Range(0, months)
.Select(m => HalfYearStart(bill.PeriodFrom.AddMonths(m)))
.GroupBy(start => start);
foreach (var half in monthsPerHalf)
{
var share = (decimal)half.Count() / months;
if (!sums.TryGetValue(half.Key, out var sum))
{
sum = new ElectricityBill { PeriodFrom = half.Key, PeriodTo = half.Key.AddMonths(6).AddDays(-1) };
sums[half.Key] = sum;
}
sum.GridKwh += bill.GridKwh * share;
sum.PvKwh += bill.PvKwh * share;
sum.GridChf += bill.GridChf * share;
sum.PvChf += bill.PvChf * share;
sum.SideCostsChf += bill.SideCostsChf * share;
}
}
var result = new List<ElectricityHalfYear>();
if (sums.Count == 0)
{
return result;
}
for (var start = sums.Keys.First(); start <= sums.Keys.Last(); start = start.AddMonths(6))
{
result.Add(new ElectricityHalfYear { From = start, Bill = sums.GetValueOrDefault(start) });
}
return result;
}
private static int MonthIndex(DateOnly date) => date.Year * 12 + date.Month - 1;
private static DateOnly HalfYearStart(DateOnly date) => new(date.Year, date.Month <= 6 ? 1 : 7, 1);
}
}

View file

@ -1,18 +0,0 @@
using System;
namespace Schaad.Accounting.Models
{
/// <summary>
/// A bill over a period (e.g. the yearly NeoVac electricity or water bill), so it can be
/// grouped into calendar periods by <see cref="BillPeriod{T}"/>.
/// </summary>
public interface IPeriodBill<in T>
{
DateOnly PeriodFrom { get; set; }
DateOnly PeriodTo { get; set; }
/// <summary>Adds <paramref name="share"/> (0..1) of the other bill's values to this one.</summary>
void AddShare(T other, decimal share);
}
}

View file

@ -0,0 +1,13 @@
namespace Schaad.Accounting.Models
{
public class SplitPredefinition
{
public string Id { get; set; }
public string BookingText { get; set; }
public decimal BookingValue { get; set; }
public string AccountId { get; set; }
}
}

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text.Json.Serialization;
namespace Schaad.Accounting.Models
{
@ -43,6 +44,9 @@ namespace Schaad.Accounting.Models
[Display(Name = "Währungskurs")]
public decimal? FxRate { get; set; }
[JsonIgnore]
public bool ReadOnly {get; set;}
public Transaction()
{
}

View file

@ -1,63 +0,0 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace Schaad.Accounting.Models
{
/// <summary>
/// One water bill for the apartment. Like the electricity bills, these are stored once per
/// mandator instead of per calendar year, because the billing period (e.g. 1 July – 30 June)
/// doesn't align with calendar years (see WaterBillRepository in Schaad.Accounting.Db).
/// </summary>
public class WaterBill : IPeriodBill<WaterBill>
{
public string Id { get; set; }
[Display(Name = "Von")]
[Required]
public DateOnly PeriodFrom { get; set; }
[Display(Name = "Bis")]
[Required]
public DateOnly PeriodTo { get; set; }
[Display(Name = "Warmwasser")]
public decimal WarmWaterM3 { get; set; }
[Display(Name = "Kaltwasser")]
public decimal ColdWaterM3 { get; set; }
[Display(Name = "Warmwasser")]
public decimal WarmWaterChf { get; set; }
[Display(Name = "Kaltwasser")]
public decimal ColdWaterChf { get; set; }
[Display(Name = "Grundkosten")]
public decimal BaseCostsChf { get; set; }
/// <summary>Warm plus cold water, in m³.</summary>
[JsonIgnore]
[Display(Name = "Total")]
public decimal TotalM3 => WarmWaterM3 + ColdWaterM3;
/// <summary>Share of the consumption that was warm water, 0..1.</summary>
[JsonIgnore]
[Display(Name = "Warmwasser-Anteil")]
public decimal WarmWaterShare => TotalM3 == 0 ? 0 : WarmWaterM3 / TotalM3;
/// <summary>Warm water, cold water and base costs added up.</summary>
[JsonIgnore]
[Display(Name = "Total")]
public decimal TotalChf => WarmWaterChf + ColdWaterChf + BaseCostsChf;
public void AddShare(WaterBill other, decimal share)
{
WarmWaterM3 += other.WarmWaterM3 * share;
ColdWaterM3 += other.ColdWaterM3 * share;
WarmWaterChf += other.WarmWaterChf * share;
ColdWaterChf += other.ColdWaterChf * share;
BaseCostsChf += other.BaseCostsChf * share;
}
}
}

View file

@ -1,137 +0,0 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace Schaad.Accounting.Models
{
/// <summary>
/// One yearly NeoVac bill for water and heating. NeoVac only reports per-mille shares of the
/// property; the own share in CHF comes from the property manager's statement. The CHF parts
/// (base costs, warm/cold water, warm water heating) are calculated from both by CalculateCosts
/// and stored, so periods can add them up (see BillPeriod). Like the electricity bills, these
/// are stored once per mandator, because the billing period runs 1 July – 30 June
/// (see WaterHeatingBillRepository in Schaad.Accounting.Db).
/// </summary>
public class WaterHeatingBill : IPeriodBill<WaterHeatingBill>
{
public string Id { get; set; }
[Display(Name = "Von")]
[Required]
public DateOnly PeriodFrom { get; set; }
[Display(Name = "Bis")]
[Required]
public DateOnly PeriodTo { get; set; }
// NeoVac "Ablesequittung", consumption billed ("Verbrauch verrechnet").
[Display(Name = "Warmwasser")]
public decimal WarmWaterM3 { get; set; }
[Display(Name = "Kaltwasser")]
public decimal ColdWaterM3 { get; set; }
[Display(Name = "Wärme")]
public decimal HeatingMwh { get; set; }
// NeoVac per-mille shares of the property, column "Anteil (‰)".
[Display(Name = "Wasser Grundkosten-Anteil")]
public decimal WaterBasePermille { get; set; }
[Display(Name = "Wasser Verbrauchskosten-Anteil")]
public decimal WaterConsumptionPermille { get; set; }
/// <summary>Own share of the heating costs ("Wärmekostenanteil").</summary>
[Display(Name = "Wärmekostenanteil")]
public decimal HeatingPermille { get; set; }
/// <summary>Part of HeatingPermille spent on heating warm water.</summary>
[Display(Name = "Warmwasser-Anteil Heizung")]
public decimal WarmWaterHeatingPermille { get; set; }
// Own share in CHF, from the property manager's statement.
[Display(Name = "Wasserkosten")]
public decimal WaterCostsChf { get; set; }
[Display(Name = "Heizkosten")]
public decimal HeatingCostsChf { get; set; }
// Optional per-mille shares as listed by the property manager, only for the checks: they
// must match the NeoVac ones.
[Display(Name = "Wasser-Anteil Verwaltung")]
public decimal? ManagerWaterPermille { get; set; }
[Display(Name = "Heizungs-Anteil Verwaltung")]
public decimal? ManagerHeatingPermille { get; set; }
// Calculated by CalculateCosts.
[Display(Name = "Grundkosten Wasser")]
public decimal BaseCostsChf { get; set; }
[Display(Name = "Warmwasser")]
public decimal WarmWaterChf { get; set; }
[Display(Name = "Kaltwasser")]
public decimal ColdWaterChf { get; set; }
[Display(Name = "Heizung Warmwasser")]
public decimal WarmWaterHeatingChf { get; set; }
/// <summary>Warm plus cold water, in m³.</summary>
[JsonIgnore]
[Display(Name = "Total")]
public decimal TotalM3 => WarmWaterM3 + ColdWaterM3;
/// <summary>Share of the consumption that was warm water, 0..1.</summary>
[JsonIgnore]
[Display(Name = "Warmwasser-Anteil")]
public decimal WarmWaterShare => TotalM3 == 0 ? 0 : WarmWaterM3 / TotalM3;
/// <summary>Heating costs not spent on warm water, i.e. heating the rooms.</summary>
[JsonIgnore]
[Display(Name = "Heizung Räume")]
public decimal RoomHeatingChf => HeatingCostsChf - WarmWaterHeatingChf;
/// <summary>Water and heating costs added up.</summary>
[JsonIgnore]
[Display(Name = "Total")]
public decimal TotalChf => WaterCostsChf + HeatingCostsChf;
/// <summary>
/// Sets the calculated CHF values: the water costs are split into base and consumption
/// costs by their ‰, and since NeoVac bills warm and cold water consumption together, the
/// consumption costs are split by m³. The warm water part of the heating costs is
/// HeatingCostsChf × WarmWaterHeatingPermille / HeatingPermille.
/// </summary>
public void CalculateCosts()
{
var waterPermille = WaterBasePermille + WaterConsumptionPermille;
BaseCostsChf = waterPermille == 0 ? 0 : Round(WaterCostsChf * WaterBasePermille / waterPermille);
var consumptionChf = WaterCostsChf - BaseCostsChf;
WarmWaterChf = Round(consumptionChf * WarmWaterShare);
ColdWaterChf = consumptionChf - WarmWaterChf;
WarmWaterHeatingChf = HeatingPermille == 0 ? 0 : Round(HeatingCostsChf * WarmWaterHeatingPermille / HeatingPermille);
}
private static decimal Round(decimal value) => Math.Round(value, 2, MidpointRounding.AwayFromZero);
/// <summary>Adds up consumption and CHF values; the per-mille shares don't add up and are left out.</summary>
public void AddShare(WaterHeatingBill other, decimal share)
{
WarmWaterM3 += other.WarmWaterM3 * share;
ColdWaterM3 += other.ColdWaterM3 * share;
HeatingMwh += other.HeatingMwh * share;
WaterCostsChf += other.WaterCostsChf * share;
HeatingCostsChf += other.HeatingCostsChf * share;
BaseCostsChf += other.BaseCostsChf * share;
WarmWaterChf += other.WarmWaterChf * share;
ColdWaterChf += other.ColdWaterChf * share;
WarmWaterHeatingChf += other.WarmWaterHeatingChf * share;
}
}
}

View file

@ -1,113 +0,0 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
namespace Schaad.Accounting.Models
{
public enum BillCheckResult
{
/// <summary>A value to compare by hand with the statements.</summary>
Info,
Ok,
Warning
}
public record BillCheck(BillCheckResult Result, string Text);
/// <summary>
/// Plausibility checks for a <see cref="WaterHeatingBill"/>, shown in its dialog: the NeoVac and
/// property manager's per-mille shares must match, and the prices per unit shouldn't jump
/// against the previous bill. Checks whose optional inputs are missing are left out.
/// </summary>
public static class WaterHeatingBillChecks
{
/// <summary>Price changes against the previous bill above this share are flagged.</summary>
public const decimal MaxPriceChange = 0.25m;
private const decimal PermilleTolerance = 0.005m;
private static readonly CultureInfo SwissNumbers = CreateSwissNumbers();
/// <summary>The bill that ended last before <paramref name="bill"/> started, if any.</summary>
public static WaterHeatingBill PreviousOf(IEnumerable<WaterHeatingBill> bills, WaterHeatingBill bill)
=> bills.Where(b => b.Id != bill.Id && b.PeriodTo < bill.PeriodFrom).MaxBy(b => b.PeriodTo);
public static IReadOnlyList<BillCheck> Check(WaterHeatingBill bill, WaterHeatingBill previous)
{
var checks = new List<BillCheck>();
var waterPermille = bill.WaterBasePermille + bill.WaterConsumptionPermille;
if (bill.ManagerWaterPermille is decimal managerWater)
{
checks.Add(new BillCheck(
Result(Math.Abs(waterPermille - managerWater) < PermilleTolerance),
$"Wasser: NeoVac {N(bill.WaterBasePermille)} + {N(bill.WaterConsumptionPermille)} = {N(waterPermille)} ‰, Verwaltung {N(managerWater)} ‰"));
}
if (bill.ManagerHeatingPermille is decimal managerHeating)
{
checks.Add(new BillCheck(
Result(Math.Abs(bill.HeatingPermille - managerHeating) < PermilleTolerance),
$"Heizung: NeoVac {N(bill.HeatingPermille)} ‰, Verwaltung {N(managerHeating)} ‰"));
}
if (bill.WarmWaterHeatingPermille > bill.HeatingPermille)
{
checks.Add(new BillCheck(BillCheckResult.Warning,
$"Heizung WW {N(bill.WarmWaterHeatingPermille)} ‰ ist grösser als Heizung total {N(bill.HeatingPermille)} ‰"));
}
// The own share divided by the per-mille share gives the costs of the whole property,
// which are on the property manager's statement.
if (waterPermille != 0 && bill.HeatingPermille != 0)
{
checks.Add(new BillCheck(BillCheckResult.Info,
$"Liegenschaft: Wasserkosten {N(bill.WaterCostsChf * 1000 / waterPermille)} CHF, Heizkosten {N(bill.HeatingCostsChf * 1000 / bill.HeatingPermille)} CHF"));
}
AddPriceCheck(checks, "Wasser", "CHF/m³", WaterPrice(bill), previous is null ? null : WaterPrice(previous));
AddPriceCheck(checks, "Heizung Warmwasser", "CHF/m³", WarmWaterHeatingPrice(bill), previous is null ? null : WarmWaterHeatingPrice(previous));
AddPriceCheck(checks, "Heizung Räume", "CHF/MWh", RoomHeatingPrice(bill), previous is null ? null : RoomHeatingPrice(previous));
return checks;
}
private static void AddPriceCheck(List<BillCheck> checks, string name, string unit, decimal? price, decimal? previousPrice)
{
if (price is not decimal now)
{
return;
}
if (previousPrice is decimal before && before != 0)
{
var change = now / before - 1;
checks.Add(new BillCheck(Result(Math.Abs(change) <= MaxPriceChange),
$"{name}: {N(now)} {unit} (Vorperiode {N(before)}, {change.ToString("+0%;−0%;0%", SwissNumbers)})"));
}
else
{
checks.Add(new BillCheck(BillCheckResult.Info, $"{name}: {N(now)} {unit}"));
}
}
/// <summary>Water consumption costs (without base costs) per m³.</summary>
private static decimal? WaterPrice(WaterHeatingBill bill)
=> bill.TotalM3 == 0 ? null : (bill.WarmWaterChf + bill.ColdWaterChf) / bill.TotalM3;
private static decimal? WarmWaterHeatingPrice(WaterHeatingBill bill)
=> bill.WarmWaterM3 == 0 ? null : bill.WarmWaterHeatingChf / bill.WarmWaterM3;
private static decimal? RoomHeatingPrice(WaterHeatingBill bill)
=> bill.HeatingMwh == 0 ? null : bill.RoomHeatingChf / bill.HeatingMwh;
private static BillCheckResult Result(bool ok) => ok ? BillCheckResult.Ok : BillCheckResult.Warning;
private static string N(decimal value) => value.ToString("#,0.00", SwissNumbers);
private static CultureInfo CreateSwissNumbers()
{
var culture = new CultureInfo("de-CH");
culture.NumberFormat.NumberGroupSeparator = "'";
return culture;
}
}
}

View file

@ -26,8 +26,6 @@ namespace Schaad.Accounting.Repositories
private const string ACCOUNTS = "Accounts.json";
private const string TRANSACTIONS = "Transactions.json";
private const string ELECTRICITY = "electricity.json";
private const string WATER = "water.json";
private const string WATER_HEATING = "water-heating.json";
private const int MaxErrors = 20;
// Like the normal options, but property names that don't exist (typos) are errors instead
@ -49,10 +47,9 @@ namespace Schaad.Accounting.Repositories
"BankTransactions.json",
"BookingRules.json",
"BookingTexts.json",
"SplitPredefinitions.json",
"SubClasses.json",
ELECTRICITY,
WATER,
WATER_HEATING
ELECTRICITY
];
public async Task<RawDataFile> LoadAsync(string fileName)
@ -69,10 +66,9 @@ namespace Schaad.Accounting.Repositories
"BankTransactions.json" => SaveAsync<BankTransaction>(fileName, text, loadedHash),
"BookingRules.json" => SaveAsync<BookingRule>(fileName, text, loadedHash),
"BookingTexts.json" => SaveAsync<BookingText>(fileName, text, loadedHash),
"SplitPredefinitions.json" => SaveAsync<SplitPredefinition>(fileName, text, loadedHash),
"SubClasses.json" => SaveAsync<SubClass>(fileName, text, loadedHash),
ELECTRICITY => SaveAsync<ElectricityBill>(fileName, text, loadedHash),
WATER => SaveAsync<WaterBill>(fileName, text, loadedHash),
WATER_HEATING => SaveAsync<WaterHeatingBill>(fileName, text, loadedHash),
_ => throw new ArgumentException($"Unknown data file '{fileName}'", nameof(fileName))
};
@ -243,10 +239,10 @@ namespace Schaad.Accounting.Repositories
return Path.Combine(DirectoryOf(fileName), fileName);
}
// electricity.json, water.json and water-heating.json live at the mandator level, not per year (their period
// runs 1 July – 30 June, so it doesn't align with calendar years).
// electricity.json lives at the mandator level, not per year (its period runs 1 July –
// 30 June, so it doesn't align with calendar years).
private string DirectoryOf(string fileName)
=> fileName is ELECTRICITY or WATER or WATER_HEATING ? settingsService.GetMandatorPath() : settingsService.GetDbPath();
=> fileName == ELECTRICITY ? settingsService.GetMandatorPath() : settingsService.GetDbPath();
private static string Hash(byte[] bytes) => Convert.ToHexString(SHA256.HashData(bytes));

View file

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Schaad.Accounting.Interfaces;
using Schaad.Accounting.Models;
namespace Schaad.Accounting.Repositories
{
public class SplitPredefinitionRepository : BaseRepository, ISplitPredefinitionRepository
{
private readonly string SPLIT_PREDEFINITION = "SplitPredefinitions.json";
public SplitPredefinitionRepository(ISettingsService settingsService, RepositoryCache cache, ILogger<SplitPredefinitionRepository> logger)
: base(settingsService, cache, logger)
{
EnsureFileExists(SPLIT_PREDEFINITION);
}
public Task<List<SplitPredefinition>> GetSplitPredefinitionListAsync() => LoadListAsync<SplitPredefinition>(SPLIT_PREDEFINITION);
public async Task SaveSplitPredefinitionAsync(SplitPredefinition splitPredefinition)
{
var definitions = await GetSplitPredefinitionListAsync();
var idx = definitions.FindIndex(d => d.Id == splitPredefinition.Id);
if (idx >= 0)
{
definitions[idx] = splitPredefinition;
}
else
{
splitPredefinition.Id = Guid.NewGuid().ToString();
definitions.Add(splitPredefinition);
}
await SaveAsync(definitions, SPLIT_PREDEFINITION);
}
}
}

View file

@ -55,6 +55,11 @@ namespace Schaad.Accounting.Repositories
await SaveAsync(subclasses, SUBCLASSES);
}
public Dictionary<int, string> GetClasses()
{
return classes;
}
public string GetClass(int classId)
{
return classes[classId];

View file

@ -1,56 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Schaad.Accounting.Interfaces;
using Schaad.Accounting.Models;
namespace Schaad.Accounting.Repositories
{
/// <summary>
/// Water bills of the current mandator, stored once per mandator (not per year like the
/// other data files) because the billing period doesn't align with calendar years.
/// </summary>
public class WaterBillRepository : BaseRepository, IWaterBillRepository
{
private const string WATER = "water.json";
public WaterBillRepository(ISettingsService settingsService, RepositoryCache cache, ILogger<WaterBillRepository> logger)
: base(settingsService, cache, logger)
{
}
public Task<List<WaterBill>> GetWaterBillListAsync()
=> LoadListAsync<WaterBill>(settingsService.GetMandatorPath(), WATER);
public async Task SaveWaterBillAsync(WaterBill bill)
{
var bills = await GetWaterBillListAsync();
var idx = bills.FindIndex(b => b.Id == bill.Id);
if (idx >= 0)
{
bills[idx] = bill;
}
else
{
bill.Id = Guid.NewGuid().ToString();
bills.Add(bill);
}
await SaveAsync(bills, settingsService.GetMandatorPath(), WATER);
}
public async Task<WaterBill> GetWaterBillAsync(string id)
{
var bills = await GetWaterBillListAsync();
return bills.FirstOrDefault(b => b.Id == id);
}
public async Task DeleteWaterBillAsync(string id)
{
var bills = await GetWaterBillListAsync();
bills.RemoveAll(b => b.Id == id);
await SaveAsync(bills, settingsService.GetMandatorPath(), WATER);
}
}
}

View file

@ -1,56 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Schaad.Accounting.Interfaces;
using Schaad.Accounting.Models;
namespace Schaad.Accounting.Repositories
{
/// <summary>
/// NeoVac water and heating bills of the current mandator, stored once per mandator (not per
/// year like the other data files) because the billing period doesn't align with calendar years.
/// </summary>
public class WaterHeatingBillRepository : BaseRepository, IWaterHeatingBillRepository
{
private const string WATER_HEATING = "water-heating.json";
public WaterHeatingBillRepository(ISettingsService settingsService, RepositoryCache cache, ILogger<WaterHeatingBillRepository> logger)
: base(settingsService, cache, logger)
{
}
public Task<List<WaterHeatingBill>> GetWaterHeatingBillListAsync()
=> LoadListAsync<WaterHeatingBill>(settingsService.GetMandatorPath(), WATER_HEATING);
public async Task SaveWaterHeatingBillAsync(WaterHeatingBill bill)
{
var bills = await GetWaterHeatingBillListAsync();
var idx = bills.FindIndex(b => b.Id == bill.Id);
if (idx >= 0)
{
bills[idx] = bill;
}
else
{
bill.Id = Guid.NewGuid().ToString();
bills.Add(bill);
}
await SaveAsync(bills, settingsService.GetMandatorPath(), WATER_HEATING);
}
public async Task<WaterHeatingBill> GetWaterHeatingBillAsync(string id)
{
var bills = await GetWaterHeatingBillListAsync();
return bills.FirstOrDefault(b => b.Id == id);
}
public async Task DeleteWaterHeatingBillAsync(string id)
{
var bills = await GetWaterHeatingBillListAsync();
bills.RemoveAll(b => b.Id == id);
await SaveAsync(bills, settingsService.GetMandatorPath(), WATER_HEATING);
}
}
}

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Schaad.Accounting.Datasets;
using Schaad.Accounting.Datasets.Charts;
using Schaad.Accounting.Interfaces;

View file

@ -7,28 +7,35 @@ using Microsoft.Extensions.Logging;
using Schaad.Accounting.Datasets;
using Schaad.Accounting.Interfaces;
using Schaad.Finance.Api;
using Schaad.Finance.Api.Datasets;
namespace Schaad.Accounting.Services
{
public class FileService : IFileService
{
private readonly IAccountRepository accountRepository;
private readonly ITransactionRepository transactionsRepository;
private readonly IBankTransactionRepository bankTransactionRepository;
private readonly ISettingsService settingsService;
private readonly IAccountStatementService accountStatementService;
private readonly ICreditCardStatementService creditCardStatementService;
private readonly ILogger<FileService> logger;
public FileService(
ISettingsService settingsService,
IAccountRepository accountRepository,
ITransactionRepository transactionsRepository,
IBankTransactionRepository bankTransactionRepository,
IAccountStatementService accountStatementService,
ICreditCardStatementService creditCardStatementService,
ILogger<FileService> logger)
{
this.settingsService = settingsService;
this.accountRepository = accountRepository;
this.transactionsRepository = transactionsRepository;
this.bankTransactionRepository = bankTransactionRepository;
this.accountStatementService = accountStatementService;
this.creditCardStatementService = creditCardStatementService;
this.logger = logger;
}
@ -110,5 +117,46 @@ namespace Schaad.Accounting.Services
return messages;
}
public IReadOnlyList<CreditCardTransaction> ImportCreditCardStatementFile(CreditCardProvider creditCardProvider, string filePath)
{
var creditCardTransactions = creditCardStatementService.ReadFile(creditCardProvider, filePath, Encoding.UTF8);
return creditCardTransactions;
}
public async Task<byte[]> GetTransactionListCsvAsync(string accountId)
{
var sb = new StringBuilder();
var account = await accountRepository.GetAccountAsync(accountId);
var transactions = (await transactionsRepository.GetTransactionListAsync())
.Where(t => t.OriginAccountId == accountId || t.TargetAccountId == accountId)
.OrderBy(t => t.BookingDate)
.ThenBy(t => t.ValueDate)
.ThenBy(t => t.Value)
.ToList();
var balance = account.StartBalance;
sb.AppendLine($"Buchungsdatum;Valuta;Buchungstext;Belastung;Gutschrift;Saldo {account.Currency}");
sb.AppendLine($";;Startsaldo;;;{balance}");
foreach (var trx in transactions)
{
var credit = "";
var debit = "";
var signedValue = trx.Value;
if (trx.OriginAccountId == accountId)
{
debit = trx.Value.ToFormattedString();
signedValue = -trx.Value;
}
else
{
credit = trx.Value.ToFormattedString();
}
balance += signedValue;
sb.AppendLine($"{trx.BookingDate:dd.MM.yyyy};{trx.ValueDate:dd.MM.yyyy};{trx.Text};{debit};{credit};{balance.ToFormattedString()}");
}
var fileBytes = Encoding.GetEncoding("ISO-8859-1").GetBytes(sb.ToString());
return fileBytes;
}
}
}

View file

@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Schaad.Accounting.Datasets;
using Schaad.Finance.Api;
using Schaad.Finance.Api.Datasets;
namespace Schaad.Accounting.Interfaces
{
@ -8,5 +10,7 @@ namespace Schaad.Accounting.Interfaces
{
string Backup();
Task<IReadOnlyList<MessageDataset>> ImportAccountStatementFileAsync(string filePath);
IReadOnlyList<CreditCardTransaction> ImportCreditCardStatementFile(CreditCardProvider creditCardProvider, string filePath);
Task<byte[]> GetTransactionListCsvAsync(string accountId);
}
}

View file

@ -3,6 +3,7 @@ using System.Threading.Tasks;
using Schaad.Accounting.Datasets;
using Schaad.Accounting.Datasets.Reports;
using Schaad.Accounting.Models;
using Schaad.Finance.Api.Datasets;
namespace Schaad.Accounting.Interfaces
{
@ -26,5 +27,6 @@ namespace Schaad.Accounting.Interfaces
Task<List<Transaction>> MatchOpenBankTransactionsAsync();
Task<List<Transaction>> MatchCreditCardTransactionsAsync(string bankTransactionId, IReadOnlyList<CreditCardTransaction> creditCardTransactions);
}
}

View file

@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="FreeSpire.PDF" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
</ItemGroup>
<ItemGroup>

View file

@ -29,6 +29,18 @@ namespace Schaad.Accounting.Services
this.year = year;
}
public bool TrySetYear(int year)
{
var oldYear = this.year;
SetYear(year);
if (Directory.GetFiles(GetDbPath()).Any() == false)
{
SetYear(oldYear);
return false;
}
return true;
}
public string GetMandator()
{
return mandator;
@ -62,6 +74,16 @@ namespace Schaad.Accounting.Services
return Path.Combine(backupPath, DateTime.Now.ToString("yyyyMMddHHmmss") + ".zip");
}
public string GetUploadPath()
{
return EnsureDirectory(Path.Combine(GetSettings().DataPath, DataFolders.Uploads, mandator, year.ToString()));
}
public string GetCreditCardStatementPath()
{
return EnsureDirectory(Path.Combine(GetUploadPath(), DataFolders.CreditCard));
}
public string GetDbPath()
{
return EnsureDirectory(Path.Combine(GetSettings().DataPath, mandator, year.ToString()));

View file

@ -7,6 +7,7 @@ using Schaad.Accounting.Datasets;
using Schaad.Accounting.Datasets.Reports;
using Schaad.Accounting.Interfaces;
using Schaad.Accounting.Models;
using Schaad.Finance.Api.Datasets;
namespace Schaad.Accounting.Services
{
@ -189,8 +190,8 @@ namespace Schaad.Accounting.Services
{
var trx = new Transaction(bankTransaction, accounts);
MatchBankTransactionByBookingRule(bankTransaction.Text, trx, bookingRules);
MatchBankTransactionBySameAccountsLastMonth(trx, transactions);
MatchBankTransactionBySameValueLastMonth(trx, transactions);
MatchBankTransactionBySameAccountsLastMonth(bankTransaction, trx, transactions);
MatchBankTransactionBySameValueLastMonth(bankTransaction, trx, transactions);
newTransactionList.Add(trx);
}
@ -200,6 +201,32 @@ namespace Schaad.Accounting.Services
return newTransactionList;
}
public async Task<List<Transaction>> MatchCreditCardTransactionsAsync(string bankTransactionId, IReadOnlyList<CreditCardTransaction> creditCardTransactions)
{
var accounts = await accountRepository.GetAccountListAsync();
var bankTrx = await bankTransactionRepository.GetBankTransactionAsync(bankTransactionId);
var bookingRules = await bookingRuleRepository.GetBookingRuleListAsync();
var trxList = new List<Transaction>();
foreach (var creditCardTransaction in creditCardTransactions)
{
var trx = new Transaction(bankTrx, accounts);
trx.Value = -1 * creditCardTransaction.Amount;
trx.BookingDate = bankTrx.BookingDate;
trx.ValueDate = creditCardTransaction.TransactionDate;
MatchBankTransactionByBookingRule(creditCardTransaction.Transaction, trx, bookingRules);
if (string.IsNullOrEmpty(trx.Text))
{
trx.Text = creditCardTransaction.Transaction;
}
trxList.Add(trx);
}
return trxList;
}
private void MatchBankTransactionByBookingRule(string transactionText, Transaction trx, List<BookingRule> bookingRules)
{
if (string.IsNullOrEmpty(trx.Text) == false)
@ -231,7 +258,7 @@ namespace Schaad.Accounting.Services
}
}
private void MatchBankTransactionBySameAccountsLastMonth(Transaction trx, List<Transaction> transactions)
private void MatchBankTransactionBySameAccountsLastMonth(BankTransaction bankTransaction, Transaction trx, List<Transaction> transactions)
{
if (string.IsNullOrEmpty(trx.Text) == false)
return;
@ -253,7 +280,7 @@ namespace Schaad.Accounting.Services
MatchSameOrOtherDay(trx, lastMonthTransactions);
}
private void MatchBankTransactionBySameValueLastMonth(Transaction trx, List<Transaction> transactions)
private void MatchBankTransactionBySameValueLastMonth(BankTransaction bankTransaction, Transaction trx, List<Transaction> transactions)
{
if (string.IsNullOrEmpty(trx.Text) == false)
return;

View file

@ -1,91 +0,0 @@
using Schaad.Accounting.Models;
using Shouldly;
namespace Schaad.Accounting.Tests;
public class BillChartFilterTestShould
{
[Fact]
public void ListEveryYearFromFirstToLastBillWhenGettingYears()
{
BillChartFilter.YearsOf([YearlyBill(2025), YearlyBill(2022)]).ShouldBe([2022, 2023, 2024, 2025, 2026]);
}
[Fact]
public void ReturnNoYearsWhenThereAreNoBills()
{
BillChartFilter.YearsOf<ElectricityBill>([]).ShouldBeEmpty();
}
[Fact]
public void GroupPerCalendarYearWhenNoKindIsGiven()
{
new BillChartFilter().Kind.ShouldBe(BillPeriodKind.Year);
}
[Fact]
public void CoverAllYearsWhenNoYearIsSelected()
{
var filter = new BillChartFilter();
filter.RangeIn([2022, 2023, 2024]).ShouldBe((2022, 2024));
filter.CoversAll([2022, 2023, 2024]).ShouldBeTrue();
}
[Fact]
public void ClampSelectedYearsWhenTheyAreOutsideTheAvailableYears()
{
var filter = new BillChartFilter(FromYear: 2019, ToYear: 2030);
filter.RangeIn([2022, 2023, 2024]).ShouldBe((2022, 2024));
}
[Fact]
public void SwapYearsWhenFromIsAfterTo()
{
var filter = new BillChartFilter(FromYear: 2024, ToYear: 2022);
filter.RangeIn([2021, 2022, 2023, 2024]).ShouldBe((2022, 2024));
}
[Fact]
public void KeepBillsOverlappingTheRangeWhenGroupingPerBill()
{
var filter = new BillChartFilter(BillPeriodKind.Bill, 2024, 2024);
var periods = filter.Apply([YearlyBill(2022), YearlyBill(2023), YearlyBill(2024), YearlyBill(2025)]);
periods.Select(p => p.Label).ShouldBe(["23/24", "24/25"]);
}
[Fact]
public void KeepOnlyPeriodsInsideTheRangeWhenGroupingPerHalfYear()
{
var filter = new BillChartFilter(BillPeriodKind.HalfYear, 2024, 2024);
var periods = filter.Apply([YearlyBill(2023), YearlyBill(2024)]);
periods.Select(p => p.Label).ShouldBe(["H1 24", "H2 24"]);
}
[Fact]
public void KeepEmptyPeriodsInsideTheRangeWhenNoBillCoversThem()
{
var filter = new BillChartFilter(BillPeriodKind.Year, 2023, 2025);
var periods = filter.Apply([Bill(new DateOnly(2022, 1, 1), new DateOnly(2022, 12, 31)), Bill(new DateOnly(2026, 1, 1), new DateOnly(2026, 12, 31))]);
periods.Select(p => p.Label).ShouldBe(["2023", "2024", "2025"]);
periods.ShouldAllBe(p => p.Bill == null);
}
[Fact]
public void ReturnNoPeriodsWhenThereAreNoBills()
{
new BillChartFilter().Apply<WaterBill>([]).ShouldBeEmpty();
}
private static ElectricityBill YearlyBill(int startYear) => Bill(new DateOnly(startYear, 7, 1), new DateOnly(startYear + 1, 6, 30));
private static ElectricityBill Bill(DateOnly from, DateOnly to) => new() { PeriodFrom = from, PeriodTo = to };
}

View file

@ -1,142 +0,0 @@
using Schaad.Accounting.Models;
using Shouldly;
namespace Schaad.Accounting.Tests;
public class BillPeriodTestShould
{
[Fact]
public void KeepEachBillUnchangedWhenGroupingPerBill()
{
var later = YearlyBill(2024);
var first = YearlyBill(2023);
var periods = BillPeriod<ElectricityBill>.FromBills([later, first], BillPeriodKind.Bill);
periods.Select(p => p.Bill).ShouldBe([first, later]);
periods.ShouldAllBe(p => !p.IsSplit);
}
[Fact]
public void LabelBillAsBillingYearWhenItCoversAWholeYear()
{
var periods = BillPeriod<ElectricityBill>.FromBills([YearlyBill(2023)], BillPeriodKind.Bill);
periods[0].Label.ShouldBe("23/24");
}
[Fact]
public void LabelBillWithDatesWhenItIsNotAWholeYear()
{
var bill = Bill(new DateOnly(2024, 1, 1), new DateOnly(2024, 6, 30));
var periods = BillPeriod<ElectricityBill>.FromBills([bill], BillPeriodKind.Bill);
periods[0].Label.ShouldBe("01.01.24–30.06.24");
}
[Fact]
public void SplitYearlyBillIntoTwoHalvesWhenPeriodRunsJulyToJune()
{
var bill = YearlyBill(2023);
bill.GridKwh = 3000m;
bill.PvKwh = 2000m;
bill.GridChf = 900m;
bill.PvChf = 400m;
bill.SideCostsChf = 100m;
var halves = BillPeriod<ElectricityBill>.FromBills([bill], BillPeriodKind.HalfYear);
halves.Count.ShouldBe(2);
halves[0].From.ShouldBe(new DateOnly(2023, 7, 1));
halves[1].From.ShouldBe(new DateOnly(2024, 1, 1));
foreach (var half in halves)
{
half.IsSplit.ShouldBeTrue();
half.Bill.GridKwh.ShouldBe(1500m);
half.Bill.PvKwh.ShouldBe(1000m);
half.Bill.GridChf.ShouldBe(450m);
half.Bill.PvChf.ShouldBe(200m);
half.Bill.SideCostsChf.ShouldBe(50m);
}
}
[Fact]
public void SplitYearlyBillIntoTwoCalendarYearsWhenPeriodRunsJulyToJune()
{
var first = YearlyBill(2023);
first.GridKwh = 3000m;
var second = YearlyBill(2024);
second.GridKwh = 5000m;
var years = BillPeriod<ElectricityBill>.FromBills([first, second], BillPeriodKind.Year);
years.Select(y => y.Label).ShouldBe(["2023", "2024", "2025"]);
years.Select(y => y.Bill.GridKwh).ShouldBe([1500m, 4000m, 2500m]);
years.ShouldAllBe(y => y.IsSplit);
}
[Fact]
public void SplitWaterBillIntoTwoHalvesWhenPeriodRunsJulyToJune()
{
var bill = new WaterBill { PeriodFrom = new DateOnly(2023, 7, 1), PeriodTo = new DateOnly(2024, 6, 30), WarmWaterM3 = 10m, ColdWaterM3 = 30m, BaseCostsChf = 200m };
var halves = BillPeriod<WaterBill>.FromBills([bill], BillPeriodKind.HalfYear);
halves.Select(h => h.Label).ShouldBe(["H2 23", "H1 24"]);
halves.ShouldAllBe(h => h.Bill.WarmWaterM3 == 5m && h.Bill.ColdWaterM3 == 15m && h.Bill.BaseCostsChf == 100m);
}
[Fact]
public void KeepPricePerKwhOfTheBillWhenSplittingIt()
{
var bill = YearlyBill(2023);
bill.GridKwh = 3000m;
bill.GridChf = 900m;
var halves = BillPeriod<ElectricityBill>.FromBills([bill], BillPeriodKind.HalfYear);
halves.ShouldAllBe(h => h.Bill.GridChfPerKwh == 0.3m);
}
[Fact]
public void AddUpBillsWithoutSplittingWhenTheyShareAPeriod()
{
var first = Bill(new DateOnly(2024, 1, 1), new DateOnly(2024, 3, 31));
first.GridKwh = 100m;
var second = Bill(new DateOnly(2024, 4, 1), new DateOnly(2024, 6, 30));
second.GridKwh = 200m;
var halves = BillPeriod<ElectricityBill>.FromBills([first, second], BillPeriodKind.HalfYear);
halves.Count.ShouldBe(1);
halves[0].Bill.GridKwh.ShouldBe(300m);
halves[0].IsSplit.ShouldBeFalse();
}
[Fact]
public void IncludeEmptyHalfYearWhenNoBillCoversIt()
{
var first = YearlyBill(2022);
var later = YearlyBill(2024);
var halves = BillPeriod<ElectricityBill>.FromBills([later, first], BillPeriodKind.HalfYear);
halves.Select(h => h.Label).ShouldBe(["H2 22", "H1 23", "H2 23", "H1 24", "H2 24", "H1 25"]);
halves[2].Bill.ShouldBeNull();
halves[3].Bill.ShouldBeNull();
}
[Theory]
[InlineData(BillPeriodKind.Bill)]
[InlineData(BillPeriodKind.Year)]
[InlineData(BillPeriodKind.HalfYear)]
public void ReturnEmptyListWhenThereAreNoBills(BillPeriodKind kind)
{
BillPeriod<ElectricityBill>.FromBills([], kind).ShouldBeEmpty();
}
private static ElectricityBill YearlyBill(int startYear) => Bill(new DateOnly(startYear, 7, 1), new DateOnly(startYear + 1, 6, 30));
private static ElectricityBill Bill(DateOnly from, DateOnly to) => new() { PeriodFrom = from, PeriodTo = to };
}

View file

@ -1,3 +1,4 @@
using System.Linq;
using NSubstitute;
using Schaad.Accounting.Datasets;
using Schaad.Accounting.Interfaces;

View file

@ -0,0 +1,79 @@
using Schaad.Accounting.Models;
using Shouldly;
namespace Schaad.Accounting.Tests;
public class ElectricityHalfYearTestShould
{
[Fact]
public void SplitYearlyBillIntoTwoHalvesWhenPeriodRunsJulyToJune()
{
var bill = Bill(new DateOnly(2023, 7, 1), new DateOnly(2024, 6, 30));
bill.GridKwh = 3000m;
bill.PvKwh = 2000m;
bill.GridChf = 900m;
bill.PvChf = 400m;
bill.SideCostsChf = 100m;
var halves = ElectricityHalfYear.FromBills([bill]);
halves.Count.ShouldBe(2);
halves[0].From.ShouldBe(new DateOnly(2023, 7, 1));
halves[1].From.ShouldBe(new DateOnly(2024, 1, 1));
foreach (var half in halves)
{
half.Bill.GridKwh.ShouldBe(1500m);
half.Bill.PvKwh.ShouldBe(1000m);
half.Bill.GridChf.ShouldBe(450m);
half.Bill.PvChf.ShouldBe(200m);
half.Bill.SideCostsChf.ShouldBe(50m);
}
}
[Fact]
public void KeepPricePerKwhOfTheBillWhenSplittingIt()
{
var bill = Bill(new DateOnly(2023, 7, 1), new DateOnly(2024, 6, 30));
bill.GridKwh = 3000m;
bill.GridChf = 900m;
var halves = ElectricityHalfYear.FromBills([bill]);
halves.ShouldAllBe(h => h.Bill.GridChfPerKwh == 0.3m);
}
[Fact]
public void AddUpBillsWhenTheyShareAHalfYear()
{
var first = Bill(new DateOnly(2024, 1, 1), new DateOnly(2024, 3, 31));
first.GridKwh = 100m;
var second = Bill(new DateOnly(2024, 4, 1), new DateOnly(2024, 6, 30));
second.GridKwh = 200m;
var halves = ElectricityHalfYear.FromBills([first, second]);
halves.Count.ShouldBe(1);
halves[0].Bill.GridKwh.ShouldBe(300m);
}
[Fact]
public void IncludeEmptyHalfYearWhenNoBillCoversIt()
{
var first = Bill(new DateOnly(2022, 7, 1), new DateOnly(2023, 6, 30));
var later = Bill(new DateOnly(2024, 7, 1), new DateOnly(2025, 6, 30));
var halves = ElectricityHalfYear.FromBills([later, first]);
halves.Select(h => h.Label).ShouldBe(["H2 22", "H1 23", "H2 23", "H1 24", "H2 24", "H1 25"]);
halves[2].Bill.ShouldBeNull();
halves[3].Bill.ShouldBeNull();
}
[Fact]
public void ReturnEmptyListWhenThereAreNoBills()
{
ElectricityHalfYear.FromBills([]).ShouldBeEmpty();
}
private static ElectricityBill Bill(DateOnly from, DateOnly to) => new() { PeriodFrom = from, PeriodTo = to };
}

View file

@ -0,0 +1,98 @@
using System.Text;
using Microsoft.Extensions.Logging.Abstractions;
using NSubstitute;
using Schaad.Accounting.Interfaces;
using Schaad.Accounting.Models;
using Schaad.Accounting.Services;
using Schaad.Finance.Api;
using Shouldly;
namespace Schaad.Accounting.Tests;
public class FileServiceTestShould
{
private readonly ISettingsService settingsService = Substitute.For<ISettingsService>();
private readonly IAccountRepository accountRepo = Substitute.For<IAccountRepository>();
private readonly ITransactionRepository transactionRepo = Substitute.For<ITransactionRepository>();
private readonly IBankTransactionRepository bankTransactionRepo = Substitute.For<IBankTransactionRepository>();
private readonly IAccountStatementService accountStatementService = Substitute.For<IAccountStatementService>();
private readonly ICreditCardStatementService creditCardStatementService = Substitute.For<ICreditCardStatementService>();
public FileServiceTestShould()
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
}
private FileService BuildService() => new(
settingsService, accountRepo, transactionRepo, bankTransactionRepo,
accountStatementService, creditCardStatementService, NullLogger<FileService>.Instance);
[Fact]
public async Task EmitHeaderRowAndRunningBalanceWhenExportingTransactionsCsv()
{
var checking = new Account { Id = "chk", Number = 1010, Name = "Checking", Currency = "CHF", StartBalance = 1000m };
accountRepo.GetAccountAsync("chk").Returns(checking);
transactionRepo.GetTransactionListAsync().Returns(new List<Transaction>
{
new()
{
Id = "t1", OriginAccountId = "chk", TargetAccountId = "groc", Value = 50m, Text = "Coop",
BookingDate = new DateTime(2026, 1, 5), ValueDate = new DateTime(2026, 1, 5)
},
new()
{
Id = "t2", OriginAccountId = "sal", TargetAccountId = "chk", Value = 5000m, Text = "Salary",
BookingDate = new DateTime(2026, 1, 25), ValueDate = new DateTime(2026, 1, 25)
}
});
var bytes = await BuildService().GetTransactionListCsvAsync("chk");
var csv = Encoding.GetEncoding("ISO-8859-1").GetString(bytes);
var lines = csv.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
lines[0].ShouldBe("Buchungsdatum;Valuta;Buchungstext;Belastung;Gutschrift;Saldo CHF");
lines[1].ShouldBe(";;Startsaldo;;;1000");
lines[2].ShouldBe("05.01.2026;05.01.2026;Coop;50.00;;950.00");
lines[3].ShouldBe("25.01.2026;25.01.2026;Salary;;5'000.00;5'950.00");
}
[Fact]
public async Task OrderTransactionsByBookingDateThenValueDateThenValueWhenExporting()
{
var checking = new Account { Id = "chk", Number = 1010, Name = "Checking", Currency = "CHF", StartBalance = 0m };
accountRepo.GetAccountAsync("chk").Returns(checking);
transactionRepo.GetTransactionListAsync().Returns(new List<Transaction>
{
new() { OriginAccountId = "chk", TargetAccountId = "x", Value = 10m, Text = "later",
BookingDate = new DateTime(2026, 2, 1), ValueDate = new DateTime(2026, 2, 1) },
new() { OriginAccountId = "chk", TargetAccountId = "x", Value = 5m, Text = "earlier small",
BookingDate = new DateTime(2026, 1, 15), ValueDate = new DateTime(2026, 1, 15) },
new() { OriginAccountId = "chk", TargetAccountId = "x", Value = 20m, Text = "earlier large",
BookingDate = new DateTime(2026, 1, 15), ValueDate = new DateTime(2026, 1, 15) }
});
var csv = Encoding.GetEncoding("ISO-8859-1").GetString(await BuildService().GetTransactionListCsvAsync("chk"));
var lines = csv.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
lines[2].ShouldContain("earlier small");
lines[3].ShouldContain("earlier large");
lines[4].ShouldContain("later");
}
[Fact]
public async Task NotMutateTransactionValueWhenExportingCsv()
{
var checking = new Account { Id = "chk", Number = 1010, Name = "Checking", Currency = "CHF" };
accountRepo.GetAccountAsync("chk").Returns(checking);
var outgoing = new Transaction
{
OriginAccountId = "chk", TargetAccountId = "x", Value = 42m, Text = "test",
BookingDate = new DateTime(2026, 1, 1), ValueDate = new DateTime(2026, 1, 1)
};
transactionRepo.GetTransactionListAsync().Returns(new List<Transaction> { outgoing });
await BuildService().GetTransactionListCsvAsync("chk");
outgoing.Value.ShouldBe(42m);
}
}

View file

@ -190,40 +190,6 @@ public class RawDataRepositoryTestShould : IDisposable
File.Exists(Path.Combine(dbDir, "electricity.json")).ShouldBeFalse();
}
[Fact]
public async Task ReadAndWriteWaterFileInMandatorFolderNotYearFolderWhenEditing()
{
File.WriteAllText(Path.Combine(mandatorDir, "water.json"), """
[ { "Id": "w1", "PeriodFrom": "2023-07-01", "PeriodTo": "2024-06-30", "WarmWaterM3": 100 } ]
""");
var loaded = await sut.LoadAsync("water.json");
loaded.Text.ShouldContain("\"WarmWaterM3\": 100");
var result = await sut.SaveAsync("water.json", loaded.Text.Replace("100", "150"), loaded.Hash);
result.Errors.ShouldBeEmpty();
result.Saved.ShouldBeTrue();
File.Exists(Path.Combine(mandatorDir, "water.json")).ShouldBeTrue();
File.ReadAllText(Path.Combine(mandatorDir, "water.json")).ShouldContain("150");
File.Exists(Path.Combine(dbDir, "water.json")).ShouldBeFalse();
}
[Fact]
public async Task ReadAndWriteWaterHeatingFileInMandatorFolderNotYearFolderWhenEditing()
{
File.WriteAllText(Path.Combine(mandatorDir, "water-heating.json"), """
[ { "Id": "h1", "PeriodFrom": "2024-07-01", "PeriodTo": "2025-06-30", "HeatingCostsChf": 100 } ]
""");
var loaded = await sut.LoadAsync("water-heating.json");
var result = await sut.SaveAsync("water-heating.json", loaded.Text.Replace("100", "150"), loaded.Hash);
result.Errors.ShouldBeEmpty();
result.Saved.ShouldBeTrue();
File.ReadAllText(Path.Combine(mandatorDir, "water-heating.json")).ShouldContain("150");
File.Exists(Path.Combine(dbDir, "water-heating.json")).ShouldBeFalse();
}
[Fact]
public async Task RejectUnknownFileNameWhenLoading()
{

View file

@ -39,6 +39,13 @@ public class SettingsServiceTestShould : IDisposable
sut.GetMandatorPath().ShouldBe(Path.Combine(dataPath, "Mandator"));
}
[Fact]
public void ReturnFoldersBelowRootUploadsWhenGettingUploadPaths()
{
sut.GetUploadPath().ShouldBe(Path.Combine(dataPath, "uploads", "Mandator", "2025"));
sut.GetCreditCardStatementPath().ShouldBe(Path.Combine(dataPath, "uploads", "Mandator", "2025", "creditCard"));
}
[Fact]
public void ReturnZipBelowRootBackupWhenGettingBackupFilePath()
{
@ -54,6 +61,7 @@ public class SettingsServiceTestShould : IDisposable
Directory.CreateDirectory(Path.Combine(dataPath, "Mandator", "2025"));
Directory.CreateDirectory(Path.Combine(dataPath, "Other", "2025"));
Directory.CreateDirectory(Path.Combine(dataPath, "OnlyOlder", "2023"));
Directory.CreateDirectory(Path.Combine(dataPath, "uploads", "2025"));
Directory.CreateDirectory(Path.Combine(dataPath, "backup", "2025"));
sut.GetMandators(2025).OrderBy(m => m).ShouldBe(["Mandator", "Other"]);

View file

@ -1,94 +0,0 @@
using Microsoft.Extensions.Logging.Abstractions;
using NSubstitute;
using Schaad.Accounting.Interfaces;
using Schaad.Accounting.Models;
using Schaad.Accounting.Repositories;
using Shouldly;
namespace Schaad.Accounting.Tests;
public class WaterBillRepositoryTestShould : IDisposable
{
private readonly string mandatorDir;
private readonly ISettingsService settingsService;
private readonly WaterBillRepository sut;
public WaterBillRepositoryTestShould()
{
mandatorDir = Path.Combine(Path.GetTempPath(), "AccountingNext-tests-" + Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(mandatorDir);
settingsService = Substitute.For<ISettingsService>();
settingsService.GetMandatorPath().Returns(mandatorDir);
sut = new WaterBillRepository(settingsService, new RepositoryCache(), NullLogger<WaterBillRepository>.Instance);
}
public void Dispose()
{
if (Directory.Exists(mandatorDir))
{
Directory.Delete(mandatorDir, recursive: true);
}
}
[Fact]
public async Task ReturnEmptyListWhenFileDoesNotExistYet()
{
(await sut.GetWaterBillListAsync()).ShouldBeEmpty();
}
[Fact]
public async Task AssignNewIdWhenSavingBillWithoutId()
{
var bill = new WaterBill
{
PeriodFrom = new DateOnly(2023, 7, 1),
PeriodTo = new DateOnly(2024, 6, 30),
WarmWaterM3 = 12.345m,
ColdWaterM3 = 30.5m,
WarmWaterChf = 250.40m,
ColdWaterChf = 98.15m,
BaseCostsChf = 120m
};
await sut.SaveWaterBillAsync(bill);
var stored = (await sut.GetWaterBillListAsync()).Single();
stored.Id.ShouldNotBeNullOrEmpty();
stored.TotalM3.ShouldBe(42.845m);
stored.TotalChf.ShouldBe(468.55m);
}
[Fact]
public async Task UpdateInPlaceWhenSavingBillWithExistingId()
{
await sut.SaveWaterBillAsync(new WaterBill { PeriodFrom = new DateOnly(2023, 7, 1), PeriodTo = new DateOnly(2024, 6, 30), WarmWaterM3 = 10m });
var id = (await sut.GetWaterBillListAsync()).Single().Id;
await sut.SaveWaterBillAsync(new WaterBill { Id = id, PeriodFrom = new DateOnly(2023, 7, 1), PeriodTo = new DateOnly(2024, 6, 30), WarmWaterM3 = 13m });
var bills = await sut.GetWaterBillListAsync();
bills.Count.ShouldBe(1);
bills[0].WarmWaterM3.ShouldBe(13m);
}
[Fact]
public async Task RemoveBillWhenDeletingById()
{
await sut.SaveWaterBillAsync(new WaterBill { PeriodFrom = new DateOnly(2023, 7, 1), PeriodTo = new DateOnly(2024, 6, 30) });
var id = (await sut.GetWaterBillListAsync()).Single().Id;
await sut.DeleteWaterBillAsync(id);
(await sut.GetWaterBillListAsync()).ShouldBeEmpty();
}
[Fact]
public async Task StoreFileDirectlyInMandatorFolderWithoutYearSubfolder()
{
await sut.SaveWaterBillAsync(new WaterBill { PeriodFrom = new DateOnly(2023, 7, 1), PeriodTo = new DateOnly(2024, 6, 30) });
File.Exists(Path.Combine(mandatorDir, "water.json")).ShouldBeTrue();
}
}

View file

@ -1,53 +0,0 @@
using Schaad.Accounting.Models;
using Shouldly;
namespace Schaad.Accounting.Tests;
public class WaterBillTestShould
{
[Fact]
public void AddWarmAndColdWaterWhenCalculatingTotalM3()
{
var bill = new WaterBill { WarmWaterM3 = 12.345m, ColdWaterM3 = 30.5m };
bill.TotalM3.ShouldBe(42.845m);
}
[Fact]
public void DivideWarmWaterByTotalWhenCalculatingWarmWaterShare()
{
var bill = new WaterBill { WarmWaterM3 = 10m, ColdWaterM3 = 30m };
bill.WarmWaterShare.ShouldBe(0.25m);
}
[Fact]
public void ReturnZeroWarmWaterShareWhenThereIsNoConsumption()
{
var bill = new WaterBill { WarmWaterM3 = 0m, ColdWaterM3 = 0m };
bill.WarmWaterShare.ShouldBe(0m);
}
[Fact]
public void AddWarmColdAndBaseCostsWhenCalculatingTotalChf()
{
var bill = new WaterBill { WarmWaterChf = 250.40m, ColdWaterChf = 98.15m, BaseCostsChf = 120m };
bill.TotalChf.ShouldBe(468.55m);
}
[Fact]
public void AddShareOfAllValuesWhenAddingShareOfOtherBill()
{
var sum = new WaterBill { WarmWaterM3 = 1m, ColdWaterM3 = 2m, WarmWaterChf = 4m, ColdWaterChf = 5m, BaseCostsChf = 3m };
sum.AddShare(new WaterBill { WarmWaterM3 = 10m, ColdWaterM3 = 20m, WarmWaterChf = 40m, ColdWaterChf = 50m, BaseCostsChf = 300m }, 0.5m);
sum.WarmWaterM3.ShouldBe(6m);
sum.ColdWaterM3.ShouldBe(12m);
sum.WarmWaterChf.ShouldBe(24m);
sum.ColdWaterChf.ShouldBe(30m);
sum.BaseCostsChf.ShouldBe(153m);
}
}

View file

@ -1,114 +0,0 @@
using Schaad.Accounting.Models;
using Shouldly;
namespace Schaad.Accounting.Tests;
public class WaterHeatingBillChecksTestShould
{
// Values of the 2024/25 bill: NeoVac per-mille shares and the own share from the property manager.
private static WaterHeatingBill Bill()
{
var bill = new WaterHeatingBill
{
Id = "b2025",
PeriodFrom = new DateOnly(2024, 7, 1),
PeriodTo = new DateOnly(2025, 6, 30),
WarmWaterM3 = 16.399m,
ColdWaterM3 = 51.464m,
HeatingMwh = 2.458m,
WaterBasePermille = 19.52m,
WaterConsumptionPermille = 68.50m,
HeatingPermille = 62.82m,
WarmWaterHeatingPermille = 12.66m,
WaterCostsChf = 304.30m,
HeatingCostsChf = 451.65m
};
bill.CalculateCosts();
return bill;
}
[Fact]
public void PassWhenNeoVacPermilleMatchesPropertyManager()
{
var bill = Bill();
bill.ManagerWaterPermille = 88.02m;
bill.ManagerHeatingPermille = 62.82m;
var checks = WaterHeatingBillChecks.Check(bill, null);
checks.ShouldContain(c => c.Result == BillCheckResult.Ok && c.Text.StartsWith("Wasser: NeoVac 19.52 + 68.50 = 88.02 ‰"));
checks.ShouldContain(c => c.Result == BillCheckResult.Ok && c.Text.StartsWith("Heizung: NeoVac 62.82 ‰"));
}
[Fact]
public void WarnWhenNeoVacPermilleDiffersFromPropertyManager()
{
var bill = Bill();
bill.ManagerWaterPermille = 88.20m;
var checks = WaterHeatingBillChecks.Check(bill, null);
checks.ShouldContain(c => c.Result == BillCheckResult.Warning && c.Text.StartsWith("Wasser: NeoVac"));
}
[Fact]
public void LeaveOutPermilleChecksWhenPropertyManagerValuesAreMissing()
{
var checks = WaterHeatingBillChecks.Check(Bill(), null);
checks.ShouldNotContain(c => c.Text.StartsWith("Wasser: NeoVac") || c.Text.StartsWith("Heizung: NeoVac"));
}
[Fact]
public void WarnWhenWarmWaterHeatingPermilleIsAboveHeatingPermille()
{
var bill = Bill();
bill.WarmWaterHeatingPermille = 70m;
var checks = WaterHeatingBillChecks.Check(bill, null);
checks.ShouldContain(c => c.Result == BillCheckResult.Warning && c.Text.StartsWith("Heizung WW 70.00 ‰"));
}
[Fact]
public void ShowPropertyCostsDerivedFromOwnShare()
{
var checks = WaterHeatingBillChecks.Check(Bill(), null);
checks.ShouldContain(new BillCheck(BillCheckResult.Info, "Liegenschaft: Wasserkosten 3'457.17 CHF, Heizkosten 7'189.59 CHF"));
}
[Fact]
public void ShowPricesPerUnitWhenThereIsNoPreviousBill()
{
var checks = WaterHeatingBillChecks.Check(Bill(), null);
checks.ShouldContain(new BillCheck(BillCheckResult.Info, "Wasser: 3.49 CHF/m³"));
checks.ShouldContain(new BillCheck(BillCheckResult.Info, "Heizung Warmwasser: 5.55 CHF/m³"));
checks.ShouldContain(new BillCheck(BillCheckResult.Info, "Heizung Räume: 146.72 CHF/MWh"));
}
[Fact]
public void WarnWhenPriceChangesMoreThanAllowedAgainstPreviousBill()
{
var previous = Bill();
previous.HeatingCostsChf = 300m;
previous.CalculateCosts();
var checks = WaterHeatingBillChecks.Check(Bill(), previous);
checks.ShouldContain(c => c.Result == BillCheckResult.Warning && c.Text.StartsWith("Heizung Räume: 146.72 CHF/MWh (Vorperiode"));
checks.ShouldContain(c => c.Result == BillCheckResult.Ok && c.Text == "Wasser: 3.49 CHF/m³ (Vorperiode 3.49, 0%)");
}
[Fact]
public void PickBillThatEndedLastBeforeThisOneAsPrevious()
{
var bill = Bill();
var older = new WaterHeatingBill { Id = "a", PeriodFrom = new DateOnly(2022, 7, 1), PeriodTo = new DateOnly(2023, 6, 30) };
var last = new WaterHeatingBill { Id = "b", PeriodFrom = new DateOnly(2023, 7, 1), PeriodTo = new DateOnly(2024, 6, 30) };
var later = new WaterHeatingBill { Id = "c", PeriodFrom = new DateOnly(2025, 7, 1), PeriodTo = new DateOnly(2026, 6, 30) };
WaterHeatingBillChecks.PreviousOf([later, older, bill, last], bill).ShouldBeSameAs(last);
}
}

View file

@ -1,93 +0,0 @@
using Microsoft.Extensions.Logging.Abstractions;
using NSubstitute;
using Schaad.Accounting.Interfaces;
using Schaad.Accounting.Models;
using Schaad.Accounting.Repositories;
using Shouldly;
namespace Schaad.Accounting.Tests;
public class WaterHeatingBillRepositoryTestShould : IDisposable
{
private readonly string mandatorDir;
private readonly ISettingsService settingsService;
private readonly WaterHeatingBillRepository sut;
public WaterHeatingBillRepositoryTestShould()
{
mandatorDir = Path.Combine(Path.GetTempPath(), "AccountingNext-tests-" + Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(mandatorDir);
settingsService = Substitute.For<ISettingsService>();
settingsService.GetMandatorPath().Returns(mandatorDir);
sut = new WaterHeatingBillRepository(settingsService, new RepositoryCache(), NullLogger<WaterHeatingBillRepository>.Instance);
}
public void Dispose()
{
if (Directory.Exists(mandatorDir))
{
Directory.Delete(mandatorDir, recursive: true);
}
}
[Fact]
public async Task ReturnEmptyListWhenFileDoesNotExistYet()
{
(await sut.GetWaterHeatingBillListAsync()).ShouldBeEmpty();
}
[Fact]
public async Task AssignNewIdWhenSavingBillWithoutId()
{
var bill = new WaterHeatingBill
{
PeriodFrom = new DateOnly(2023, 7, 1),
PeriodTo = new DateOnly(2024, 6, 30),
WarmWaterM3 = 12.345m,
ColdWaterM3 = 30.5m,
WaterCostsChf = 304.30m,
HeatingCostsChf = 451.65m
};
await sut.SaveWaterHeatingBillAsync(bill);
var stored = (await sut.GetWaterHeatingBillListAsync()).Single();
stored.Id.ShouldNotBeNullOrEmpty();
stored.TotalM3.ShouldBe(42.845m);
stored.TotalChf.ShouldBe(755.95m);
}
[Fact]
public async Task UpdateInPlaceWhenSavingBillWithExistingId()
{
await sut.SaveWaterHeatingBillAsync(new WaterHeatingBill { PeriodFrom = new DateOnly(2023, 7, 1), PeriodTo = new DateOnly(2024, 6, 30), WarmWaterM3 = 10m });
var id = (await sut.GetWaterHeatingBillListAsync()).Single().Id;
await sut.SaveWaterHeatingBillAsync(new WaterHeatingBill { Id = id, PeriodFrom = new DateOnly(2023, 7, 1), PeriodTo = new DateOnly(2024, 6, 30), WarmWaterM3 = 13m });
var bills = await sut.GetWaterHeatingBillListAsync();
bills.Count.ShouldBe(1);
bills[0].WarmWaterM3.ShouldBe(13m);
}
[Fact]
public async Task RemoveBillWhenDeletingById()
{
await sut.SaveWaterHeatingBillAsync(new WaterHeatingBill { PeriodFrom = new DateOnly(2023, 7, 1), PeriodTo = new DateOnly(2024, 6, 30) });
var id = (await sut.GetWaterHeatingBillListAsync()).Single().Id;
await sut.DeleteWaterHeatingBillAsync(id);
(await sut.GetWaterHeatingBillListAsync()).ShouldBeEmpty();
}
[Fact]
public async Task StoreFileDirectlyInMandatorFolderWithoutYearSubfolder()
{
await sut.SaveWaterHeatingBillAsync(new WaterHeatingBill { PeriodFrom = new DateOnly(2023, 7, 1), PeriodTo = new DateOnly(2024, 6, 30) });
File.Exists(Path.Combine(mandatorDir, "water-heating.json")).ShouldBeTrue();
}
}

View file

@ -1,87 +0,0 @@
using Schaad.Accounting.Models;
using Shouldly;
namespace Schaad.Accounting.Tests;
public class WaterHeatingBillTestShould
{
// Values of the 2024/25 bill: NeoVac per-mille shares and the own share from the property manager.
private static WaterHeatingBill Bill() => new()
{
WarmWaterM3 = 16.399m,
ColdWaterM3 = 51.464m,
WaterBasePermille = 19.52m,
WaterConsumptionPermille = 68.50m,
HeatingPermille = 62.82m,
WarmWaterHeatingPermille = 12.66m,
WaterCostsChf = 304.30m,
HeatingCostsChf = 451.65m
};
[Fact]
public void SplitWaterCostsByPermilleAndM3WhenCalculatingCosts()
{
var bill = Bill();
bill.CalculateCosts();
bill.BaseCostsChf.ShouldBe(67.48m);
bill.WarmWaterChf.ShouldBe(57.23m);
bill.ColdWaterChf.ShouldBe(179.59m);
}
[Fact]
public void SplitHeatingCostsIntoWarmWaterAndRoomsWhenCalculatingCosts()
{
var bill = Bill();
bill.CalculateCosts();
bill.WarmWaterHeatingChf.ShouldBe(91.02m);
bill.RoomHeatingChf.ShouldBe(360.63m);
bill.TotalChf.ShouldBe(755.95m);
}
[Fact]
public void PutAllConsumptionCostsOnColdWaterWhenCalculatingCostsWithoutConsumption()
{
var bill = new WaterHeatingBill { WaterCostsChf = 100m, WaterBasePermille = 20m, WaterConsumptionPermille = 80m };
bill.CalculateCosts();
bill.BaseCostsChf.ShouldBe(20m);
bill.WarmWaterChf.ShouldBe(0m);
bill.ColdWaterChf.ShouldBe(80m);
}
[Fact]
public void LeaveHeatingCostsOnRoomsWhenCalculatingCostsWithoutPermilleShares()
{
var bill = new WaterHeatingBill { HeatingCostsChf = 450m };
bill.CalculateCosts();
bill.BaseCostsChf.ShouldBe(0m);
bill.WarmWaterHeatingChf.ShouldBe(0m);
bill.RoomHeatingChf.ShouldBe(450m);
}
[Fact]
public void AddShareOfConsumptionAndCostsWhenAddingShareOfOtherBill()
{
var other = Bill();
other.HeatingMwh = 2.458m;
other.CalculateCosts();
var sum = new WaterHeatingBill();
sum.AddShare(other, 0.5m);
sum.WarmWaterM3.ShouldBe(8.1995m);
sum.HeatingMwh.ShouldBe(1.229m);
sum.WaterCostsChf.ShouldBe(152.15m);
sum.HeatingCostsChf.ShouldBe(225.825m);
sum.ColdWaterChf.ShouldBe(89.795m);
sum.WarmWaterHeatingChf.ShouldBe(45.51m);
sum.WaterBasePermille.ShouldBe(0m);
}
}

View file

@ -1,3 +1,81 @@
.page {
position: relative;
display: flex;
flex-direction: column;
}
main {
flex: 1;
}
.sidebar {
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}
.top-row {
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
height: 3.5rem;
display: flex;
align-items: center;
}
.top-row ::deep a, .top-row ::deep .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
text-decoration: none;
}
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
text-decoration: underline;
}
.top-row ::deep a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}
@media (max-width: 640.98px) {
.top-row {
justify-content: space-between;
}
.top-row ::deep a, .top-row ::deep .btn-link {
margin-left: 0;
}
}
@media (min-width: 641px) {
.page {
flex-direction: row;
}
.sidebar {
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}
.top-row {
position: sticky;
top: 0;
z-index: 1;
}
.top-row.auth ::deep a:first-child {
flex: 1;
text-align: right;
width: 0;
}
.top-row, article {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}
#blazor-error-ui {
color-scheme: light only;
background: lightyellow;

View file

@ -5,10 +5,11 @@
<div class="navmenu hidePrint">
<nav class="sitenav" aria-labelledby="main-menu">
<FluentNavMenu Id="main-menu" Collapsible="true" Width="250" Title="Navigation menu" @bind-Expanded="expanded">
<FluentNavMenu Id="main-menu" Collapsible="true" Width="250" Title="Navigation menu" @bind-Expanded="expanded" CustomToggle="true">
<FluentNavLink Href="/" Match="NavLinkMatch.All" Icon="@(new Size20.Home())" IconColor="Color.Accent">Home</FluentNavLink>
<FluentNavLink Href="transactions" Icon="@(new Size20.NumberSymbolSquare())" IconColor="Color.Accent">Transaktionen</FluentNavLink>
<FluentNavLink Href="banktransactions" Icon="@(new Size20.BuildingBank())" IconColor="Color.Accent">Bank Transaktionen</FluentNavLink>
<FluentNavLink Href="electricity" Icon="@(new Size20.Flash())" IconColor="Color.Accent">Strom</FluentNavLink>
<FluentNavGroup Title="Stammdaten" Icon="@(new Size32.BookDatabase())">
<FluentNavLink Href="bookingrules" Icon="@(new Size20.Check())" IconColor="Color.Accent">Buchungsregeln</FluentNavLink>
<FluentNavLink Href="bookingtexts" Icon="@(new Size32.Text())" IconColor="Color.Accent">Buchungstexte</FluentNavLink>
@ -19,9 +20,6 @@
</FluentNavGroup>
<FluentNavGroup Title="Charts" Icon="@(new Size32.ChartMultiple())">
<FluentNavLink Href="analytics" Icon="@(new Size20.DataHistogram())" IconColor="Color.Accent">Analyse</FluentNavLink>
<FluentNavLink Href="electricity" Icon="@(new Size20.Flash())" IconColor="Color.Accent">Strom</FluentNavLink>
<FluentNavLink Href="water" Icon="@(new Size20.Drop())" IconColor="Color.Accent">Wasser</FluentNavLink>
<FluentNavLink Href="water-heating" Icon="@(new Size20.Temperature())" IconColor="Color.Accent">Wasser &amp; Heizung</FluentNavLink>
</FluentNavGroup>
<FluentNavGroup Title="Reports" Icon="@(new Size32.DocumentPrint())">
<FluentNavLink Href="ProfitLossReport" Icon="@(new Size32.DataTrending())" IconColor="Color.Accent">Erfolgsrechnung</FluentNavLink>

View file

@ -0,0 +1,105 @@
.navbar-toggler {
appearance: none;
cursor: pointer;
width: 3.5rem;
height: 2.5rem;
color: white;
position: absolute;
top: 0.5rem;
right: 1rem;
border: 1px solid rgba(255, 255, 255, 0.1);
background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1);
}
.navbar-toggler:checked {
background-color: rgba(255, 255, 255, 0.5);
}
.top-row {
min-height: 3.5rem;
background-color: rgba(0,0,0,0.4);
}
.navbar-brand {
font-size: 1.1rem;
}
.bi {
display: inline-block;
position: relative;
width: 1.25rem;
height: 1.25rem;
margin-right: 0.75rem;
top: -1px;
background-size: cover;
}
.bi-house-door-fill-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E");
}
.bi-plus-square-fill-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E");
}
.bi-list-nested-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
}
.nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
}
.nav-item:first-of-type {
padding-top: 1rem;
}
.nav-item:last-of-type {
padding-bottom: 1rem;
}
.nav-item ::deep .nav-link {
color: #d7d7d7;
background: none;
border: none;
border-radius: 4px;
height: 3rem;
display: flex;
align-items: center;
line-height: 3rem;
width: 100%;
}
.nav-item ::deep a.active {
background-color: rgba(255,255,255,0.37);
color: white;
}
.nav-item ::deep .nav-link:hover {
background-color: rgba(255,255,255,0.1);
color: white;
}
.nav-scrollable {
display: none;
}
.navbar-toggler:checked ~ .nav-scrollable {
display: block;
}
@media (min-width: 641px) {
.navbar-toggler {
display: none;
}
.nav-scrollable {
/* Never collapse the sidebar for wide screens */
display: block;
/* Allow sidebar to scroll for tall menus */
height: calc(100vh - 3.5rem);
overflow-y: auto;
}
}

View file

@ -100,7 +100,7 @@ public partial class Analytics : ComponentBase
{
(fromYear, toYear) = (toYear, fromYear);
}
period = ParsePeriod(Period) ?? AnalyticsPeriod.Year;
period = ParsePeriod(Period) ?? (fromYear == toYear ? AnalyticsPeriod.Month : AnalyticsPeriod.Quarter);
view = Enum.TryParse<AnalyticsView>(View, ignoreCase: true, out var parsedView) ? parsedView : AnalyticsView.Expenses;
node = Acc is { } account ? new AnalyticsNode(account / 100, account, IsAssets ? null : Text)

View file

@ -4,3 +4,26 @@
overflow-x: auto;
overflow-y: hidden;
}
article {
min-height: 32rem;
max-height: 80dvh;
}
.demo-section-content {
height: calc(100% - 10rem);
}
.demo-section-example {
min-height: 135px !important;
height: 100%;
}
fluent-tabs {
height: 100%;
}
#tab-example-autoitemsperpage-panel {
height: 100% !important;
max-height: calc(100% - 2rem) !important;
}

View file

@ -1,7 +1,7 @@
@if (config is not null && layout is not null && data is not null)
{
<FluentCard Style="padding: 16px;">
<PlotlyChart style="height: 400px; min-height: 300px" @bind-Config="config" @bind-Layout="layout" @bind-Data="data" />
<PlotlyChart style="height: 400px; min-height: 300px" @bind-Config="config" @bind-Layout="layout" @bind-Data="data" @ref="chart" />
</FluentCard>
}
else

View file

@ -1,11 +1,13 @@
using Microsoft.AspNetCore.Components;
using Plotly.Blazor;
using Plotly.Blazor.Traces;
using Schaad.Accounting.Interfaces;
namespace Schaad.Accounting.UI.Components.Pages.Charts;
public partial class BookingTextBreakdown : ComponentBase
{
private PlotlyChart chart = null!;
private Config? config;
private Plotly.Blazor.Layout? layout;
private IList<ITrace>? data;

View file

@ -1,7 +1,7 @@
@if (config is not null && layout is not null)
{
<FluentCard Style="padding: 16px;">
<PlotlyChart style="height: 400px; min-height: 300px" @bind-Config="config" @bind-Layout="layout" @bind-Data="data" />
<PlotlyChart style="height: 400px; min-height: 300px" @bind-Config="config" @bind-Layout="layout" @bind-Data="data" @ref="chart" />
</FluentCard>
}
else

View file

@ -1,12 +1,14 @@
using Microsoft.AspNetCore.Components;
using Plotly.Blazor;
using Plotly.Blazor.LayoutLib;
using Plotly.Blazor.Traces;
using Schaad.Accounting.Interfaces;
namespace Schaad.Accounting.UI.Components.Pages.Charts;
public partial class BookingTextOverTime : ComponentBase
{
private PlotlyChart chart = null!;
private Config? config;
private Plotly.Blazor.Layout? layout;
private IList<ITrace> data = new List<ITrace>();

View file

@ -1,3 +1,4 @@
using Schaad.Accounting;
using Schaad.Accounting.Datasets.Charts;
namespace Schaad.Accounting.UI.Components.Pages.Charts;

View file

@ -1,35 +0,0 @@
<div class="bill-chart-toolbar">
<div class="segmented" role="group" aria-label="Zeitraum">
@foreach (var kind in PeriodKinds)
{
<FluentButton Appearance="@(kind == Filter.Kind ? Appearance.Accent : Appearance.Neutral)"
aria-pressed="@(kind == Filter.Kind ? "true" : "false")"
OnClick="@(() => ChangeAsync(Filter with { Kind = kind }))">@PeriodKindName(kind)</FluentButton>
}
</div>
@if (Years.Count > 0)
{
<div class="years">
<FluentSelect TOption="int" Label="Von" Width="110px"
Items="@Years"
OptionText="@(y => y.ToString())"
OptionValue="@(y => y.ToString())"
SelectedOption="@Range.From"
SelectedOptionChanged="@OnFromChanged" />
<FluentSelect TOption="int" Label="Bis" Width="110px"
Items="@Years"
OptionText="@(y => y.ToString())"
OptionValue="@(y => y.ToString())"
SelectedOption="@Range.To"
SelectedOptionChanged="@OnToChanged" />
<FluentButton Appearance="Appearance.Lightweight" OnClick="@(() => ChangeAsync(Filter with { FromYear = null, ToYear = null }))"
Disabled="@Filter.CoversAll(Years)">Alle Jahre</FluentButton>
</div>
}
@if (IsSplit)
{
<span class="split-note">Werte anteilig auf die Monate der Abrechnungsperiode verteilt</span>
}
</div>

View file

@ -1,53 +0,0 @@
using Microsoft.AspNetCore.Components;
using Schaad.Accounting.Models;
namespace Schaad.Accounting.UI.Components.Pages.Controls;
/// <summary>
/// Filter above the charts on the Strom and Wasser pages: period toggle (bill, calendar year,
/// half-year), year range and the note shown when bills had to be split over several periods.
/// </summary>
public partial class BillChartToolbar : ComponentBase
{
private static readonly BillPeriodKind[] PeriodKinds =
[BillPeriodKind.Bill, BillPeriodKind.Year, BillPeriodKind.HalfYear];
[Parameter]
public BillChartFilter Filter { get; set; } = new();
[Parameter]
public EventCallback<BillChartFilter> FilterChanged { get; set; }
/// <summary>The years any bill touches (see <see cref="BillChartFilter.YearsOf{T}"/>).</summary>
[Parameter]
public IReadOnlyList<int> Years { get; set; } = [];
[Parameter]
public bool IsSplit { get; set; }
private (int From, int To) Range => Filter.RangeIn(Years);
/// <summary>Suffix for chart titles, e.g. "pro Halbjahr".</summary>
public static string PerPeriod(BillPeriodKind kind) => kind switch
{
BillPeriodKind.Year => "pro Jahr",
BillPeriodKind.HalfYear => "pro Halbjahr",
_ => "pro Abrechnung"
};
private static string PeriodKindName(BillPeriodKind kind) => kind switch
{
BillPeriodKind.Year => "Kalenderjahr",
BillPeriodKind.HalfYear => "Halbjahr",
_ => "Abrechnung"
};
// Picking a "from" after the current "to" (or the other way round) moves the other end along.
private Task OnFromChanged(int year)
=> year == Range.From ? Task.CompletedTask : ChangeAsync(Filter with { FromYear = year, ToYear = Math.Max(Range.To, year) });
private Task OnToChanged(int year)
=> year == Range.To ? Task.CompletedTask : ChangeAsync(Filter with { FromYear = Math.Min(Range.From, year), ToYear = year });
private Task ChangeAsync(BillChartFilter filter) => FilterChanged.InvokeAsync(filter);
}

View file

@ -1,25 +0,0 @@
.bill-chart-toolbar {
display: flex;
flex-wrap: wrap;
align-items: flex-end;
gap: 12px;
}
.segmented {
display: flex;
flex-wrap: wrap;
gap: 2px;
}
.years {
display: flex;
flex-wrap: wrap;
align-items: flex-end;
gap: 8px;
}
.split-note {
font-size: 12px;
color: var(--neutral-foreground-hint);
align-self: center;
}

View file

@ -13,15 +13,21 @@
<FluentDialogBody>
<EditForm EditContext="@editContext">
<DataAnnotationsValidator />
<div class="dialog-fields">
<div class="dialog-field"><FluentDatePicker @bind-Value="@periodFrom" Label="Von" /></div>
<div class="dialog-field"><FluentDatePicker @bind-Value="@periodTo" Label="Bis" /></div>
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.GridKwh" Label="Netzbezug (kWh)" /></div>
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.PvKwh" Label="PV-Produktion (kWh)" /></div>
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.GridChf" Label="Netzbezug (CHF)" /></div>
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.PvChf" Label="PV (CHF)" /></div>
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.SideCostsChf" Label="Nebenkosten (CHF)" /></div>
</div>
<FluentStack Orientation="Orientation.Horizontal">
<FluentDatePicker @bind-Value="@periodFrom" Label="Von" Style="width: 170px;" />
<FluentDatePicker @bind-Value="@periodTo" Label="Bis" Style="width: 170px;" />
</FluentStack>
<FluentStack Orientation="Orientation.Horizontal">
<FluentNumberField @bind-Value="@Content.GridKwh" Label="Netzbezug (kWh)" Style="width: 170px;" />
<FluentNumberField @bind-Value="@Content.PvKwh" Label="PV-Produktion (kWh)" Style="width: 170px;" />
</FluentStack>
<FluentStack Orientation="Orientation.Horizontal">
<FluentNumberField @bind-Value="@Content.GridChf" Label="Netzbezug (CHF)" Style="width: 170px;" />
<FluentNumberField @bind-Value="@Content.PvChf" Label="PV (CHF)" Style="width: 170px;" />
</FluentStack>
<FluentStack Orientation="Orientation.Horizontal">
<FluentNumberField @bind-Value="@Content.SideCostsChf" Label="Nebenkosten (CHF)" Style="width: 170px;" />
</FluentStack>
<div>
<FluentValidationSummary />
</div>

View file

@ -1,51 +0,0 @@
@implements IDialogContentComponent<Schaad.Accounting.Models.WaterBill>
@rendermode InteractiveServer
<FluentDialogHeader ShowDismiss="true">
<FluentStack VerticalAlignment="VerticalAlignment.Center">
<FluentIcon Value="@(new Icons.Regular.Size24.WindowApps())" />
<FluentLabel Typo="Typography.PaneHeader">
@Dialog.Instance.Parameters.Title
</FluentLabel>
</FluentStack>
</FluentDialogHeader>
<FluentDialogBody>
<EditForm EditContext="@editContext">
<DataAnnotationsValidator />
<FluentStack Orientation="Orientation.Horizontal">
<FluentDatePicker @bind-Value="@periodFrom" Label="Von" Style="width: 170px;" />
<FluentDatePicker @bind-Value="@periodTo" Label="Bis" Style="width: 170px;" />
</FluentStack>
<FluentStack Orientation="Orientation.Horizontal">
<FluentNumberField @bind-Value="@Content.WarmWaterM3" Label="Warmwasser (m³)" Style="width: 170px;" />
<FluentNumberField @bind-Value="@Content.ColdWaterM3" Label="Kaltwasser (m³)" Style="width: 170px;" />
</FluentStack>
<FluentStack Orientation="Orientation.Horizontal">
<FluentNumberField @bind-Value="@Content.WarmWaterChf" Label="Warmwasser (CHF)" Style="width: 170px;" />
<FluentNumberField @bind-Value="@Content.ColdWaterChf" Label="Kaltwasser (CHF)" Style="width: 170px;" />
</FluentStack>
<FluentStack Orientation="Orientation.Horizontal">
<FluentNumberField @bind-Value="@Content.BaseCostsChf" Label="Grundkosten (CHF)" Style="width: 170px;" />
</FluentStack>
<div>
<FluentValidationSummary />
</div>
</EditForm>
<div style="margin-top: 12px; font-size: 13px; color: #52514e;">
Total <strong>@M3(Content.TotalM3)</strong> · <strong>@Chf(Content.TotalChf)</strong>
</div>
</FluentDialogBody>
<FluentDialogFooter>
<FluentButton Appearance="Appearance.Neutral"
OnClick="@CancelAsync">
Abbrechen
</FluentButton>
<FluentButton Appearance="Appearance.Accent"
Disabled="@(periodFrom is null || periodTo is null)"
OnClick="@SaveAsync">
Speichern
</FluentButton>
</FluentDialogFooter>

View file

@ -1,66 +0,0 @@
using System.Globalization;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.FluentUI.AspNetCore.Components;
using Schaad.Accounting.Interfaces;
using Schaad.Accounting.Models;
namespace Schaad.Accounting.UI.Components.Pages.Dialogs;
public partial class WaterBillDialog : ComponentBase
{
private static readonly CultureInfo SwissNumbers = CreateSwissNumbers();
private EditContext editContext = null!;
// FluentDatePicker needs DateTime?; the model stores DateOnly (see WaterBill).
private DateTime? periodFrom;
private DateTime? periodTo;
[CascadingParameter]
public FluentDialog Dialog { get; set; } = null!;
[Parameter]
public WaterBill Content { get; set; } = null!;
[Inject]
private IWaterBillRepository waterBillRepository { get; set; } = null!;
protected override void OnInitialized()
{
periodFrom = Content.PeriodFrom == default ? null : Content.PeriodFrom.ToDateTime(TimeOnly.MinValue);
periodTo = Content.PeriodTo == default ? null : Content.PeriodTo.ToDateTime(TimeOnly.MinValue);
editContext = new EditContext(Content);
}
private async Task SaveAsync()
{
if (periodFrom is null || periodTo is null)
{
return;
}
Content.PeriodFrom = DateOnly.FromDateTime(periodFrom.Value);
Content.PeriodTo = DateOnly.FromDateTime(periodTo.Value);
if (editContext.Validate())
{
await waterBillRepository.SaveWaterBillAsync(Content);
await Dialog.CloseAsync(Content);
}
}
private async Task CancelAsync()
{
await Dialog.CancelAsync();
}
private static string M3(decimal value) => value.ToString("#,0.00", SwissNumbers) + " m³";
private static string Chf(decimal value) => value.ToString("#,0.00", SwissNumbers) + " CHF";
private static CultureInfo CreateSwissNumbers()
{
var culture = new CultureInfo("de-CH");
culture.NumberFormat.NumberGroupSeparator = "'";
return culture;
}
}

View file

@ -1,111 +0,0 @@
@implements IDialogContentComponent<Schaad.Accounting.Models.WaterHeatingBill>
@rendermode InteractiveServer
@using Schaad.Accounting.Models
<FluentDialogHeader ShowDismiss="true">
<FluentStack VerticalAlignment="VerticalAlignment.Center">
<FluentIcon Value="@(new Icons.Regular.Size24.WindowApps())" />
<FluentLabel Typo="Typography.PaneHeader">
@Dialog.Instance.Parameters.Title
</FluentLabel>
</FluentStack>
</FluentDialogHeader>
<FluentDialogBody>
<EditForm EditContext="@editContext">
<DataAnnotationsValidator />
<div class="dialog-fields">
<div class="dialog-field"><FluentDatePicker @bind-Value="@periodFrom" @bind-Value:after="SyncPeriod" Label="Von" /></div>
<div class="dialog-field"><FluentDatePicker @bind-Value="@periodTo" @bind-Value:after="SyncPeriod" Label="Bis" /></div>
</div>
<div style="@SectionStyle">NeoVac – Ablesequittung</div>
<div class="dialog-fields">
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.WarmWaterM3" @bind-Value:after="Content.CalculateCosts" Label="Warmwasser (m³)" /></div>
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.ColdWaterM3" @bind-Value:after="Content.CalculateCosts" Label="Kaltwasser (m³)" /></div>
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.HeatingMwh" Label="Wärme (MWh)" /></div>
</div>
<div style="@SectionStyle">NeoVac – Anteil (‰)</div>
<div class="dialog-fields">
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.WaterBasePermille" @bind-Value:after="Content.CalculateCosts" Label="Wasser Grund (‰)" /></div>
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.WaterConsumptionPermille" @bind-Value:after="Content.CalculateCosts" Label="Wasser Verbrauch (‰)" /></div>
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.HeatingPermille" @bind-Value:after="Content.CalculateCosts" Label="Heizung total (‰)" /></div>
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.WarmWaterHeatingPermille" @bind-Value:after="Content.CalculateCosts" Label="Heizung WW (‰)" /></div>
</div>
<div style="@SectionStyle">Verwaltung – Ihr Anteil</div>
<div class="dialog-fields">
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.WaterCostsChf" @bind-Value:after="Content.CalculateCosts" Label="Wasserkosten (CHF)" /></div>
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.HeatingCostsChf" @bind-Value:after="Content.CalculateCosts" Label="Heizkosten (CHF)" /></div>
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.ManagerWaterPermille" Label="Wasser (‰, optional)" /></div>
<div class="dialog-field"><FluentNumberField @bind-Value="@Content.ManagerHeatingPermille" Label="Heizung (‰, optional)" /></div>
</div>
<div>
<FluentValidationSummary />
</div>
</EditForm>
<div style="margin-top: 12px; font-size: 13px; color: #52514e;">
Wasser: Grundkosten <strong>@Chf(Content.BaseCostsChf)</strong>
· Warmwasser <strong>@Chf(Content.WarmWaterChf)</strong>
· Kaltwasser <strong>@Chf(Content.ColdWaterChf)</strong>
</div>
<div style="margin-top: 4px; font-size: 13px; color: #52514e;">
Heizung: Warmwasser <strong>@Chf(Content.WarmWaterHeatingChf)</strong>
· Räume <strong>@Chf(Content.RoomHeatingChf)</strong>
</div>
<div style="margin-top: 4px; font-size: 13px; color: #52514e;">
Total <strong>@M3(Content.TotalM3)</strong> · <strong>@Mwh(Content.HeatingMwh)</strong> · <strong>@Chf(Content.TotalChf)</strong>
</div>
@if (Checks is { Count: > 0 } checks)
{
<div style="@SectionStyle">Kontrolle</div>
@foreach (var check in checks)
{
<div style="font-size: 13px; color: @CheckColor(check.Result);">@CheckSymbol(check.Result) @check.Text</div>
}
}
<FluentButton Appearance="Appearance.Lightweight" Style="margin-top: 12px; padding: 0; font-size: 13px;" OnClick="ShowGuideAsync">
Woher kommen die Werte? (NeoVac-Abrechnung)
</FluentButton>
</FluentDialogBody>
<FluentDialogFooter>
<FluentButton Appearance="Appearance.Neutral"
OnClick="@CancelAsync">
Abbrechen
</FluentButton>
<FluentButton Appearance="Appearance.Accent"
Disabled="@(periodFrom is null || periodTo is null)"
OnClick="@SaveAsync">
Speichern
</FluentButton>
</FluentDialogFooter>
@code {
private const string SectionStyle = "margin-top: 14px; margin-bottom: 4px; font-size: 11px; font-weight: bold; color: #898781; text-transform: uppercase;";
// Shown in its own dialog (see ShowGuideAsync) instead of expanding inline: this dialog has a
// fixed Height, and FluentDialogBody doesn't resize to fit growing content.
private RenderFragment GuideImage =>
@<img src="/images/water-heating-bill-guide.svg"
alt="Beispiel-Abrechnung mit Markierungen, welcher Wert in welches Feld gehört"
style="width: 100%; height: auto; display: block;" />;
private static string CheckSymbol(BillCheckResult result) => result switch
{
BillCheckResult.Ok => "✓",
BillCheckResult.Warning => "⚠",
_ => "·"
};
private static string CheckColor(BillCheckResult result) => result switch
{
BillCheckResult.Ok => "#1a7f37",
BillCheckResult.Warning => "#c4314b",
_ => "#52514e"
};
}

View file

@ -1,109 +0,0 @@
using System.Globalization;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.FluentUI.AspNetCore.Components;
using Schaad.Accounting.Interfaces;
using Schaad.Accounting.Models;
namespace Schaad.Accounting.UI.Components.Pages.Dialogs;
/// <summary>
/// NeoVac water and heating bill: consumption and per-mille shares from NeoVac, own costs from the
/// property manager's statement; the CHF parts are calculated (see <see cref="WaterHeatingBill.CalculateCosts"/>)
/// and checked (see <see cref="WaterHeatingBillChecks"/>).
/// </summary>
public partial class WaterHeatingBillDialog : ComponentBase
{
private static readonly CultureInfo SwissNumbers = CreateSwissNumbers();
private EditContext editContext = null!;
// FluentDatePicker needs DateTime?; the model stores DateOnly (see WaterHeatingBill).
private DateTime? periodFrom;
private DateTime? periodTo;
// The other bills, to find the previous one for the price checks.
private List<WaterHeatingBill> bills = [];
[CascadingParameter]
public FluentDialog Dialog { get; set; } = null!;
[Parameter]
public WaterHeatingBill Content { get; set; } = null!;
[Inject]
private IWaterHeatingBillRepository waterHeatingBillRepository { get; set; } = null!;
[Inject]
private IDialogService dialogService { get; set; } = null!;
protected override async Task OnInitializedAsync()
{
bills = await waterHeatingBillRepository.GetWaterHeatingBillListAsync();
periodFrom = Content.PeriodFrom == default ? null : Content.PeriodFrom.ToDateTime(TimeOnly.MinValue);
periodTo = Content.PeriodTo == default ? null : Content.PeriodTo.ToDateTime(TimeOnly.MinValue);
editContext = new EditContext(Content);
}
private IReadOnlyList<BillCheck> Checks
=> WaterHeatingBillChecks.Check(Content, WaterHeatingBillChecks.PreviousOf(bills, Content));
// Keeps the period on the bill up to date while editing, so the checks find the right
// previous bill.
private void SyncPeriod()
{
if (periodFrom is not null)
{
Content.PeriodFrom = DateOnly.FromDateTime(periodFrom.Value);
}
if (periodTo is not null)
{
Content.PeriodTo = DateOnly.FromDateTime(periodTo.Value);
}
}
private async Task SaveAsync()
{
if (periodFrom is null || periodTo is null)
{
return;
}
Content.PeriodFrom = DateOnly.FromDateTime(periodFrom.Value);
Content.PeriodTo = DateOnly.FromDateTime(periodTo.Value);
Content.CalculateCosts();
if (editContext.Validate())
{
await waterHeatingBillRepository.SaveWaterHeatingBillAsync(Content);
await Dialog.CloseAsync(Content);
}
}
private async Task CancelAsync()
{
await Dialog.CancelAsync();
}
private async Task ShowGuideAsync()
{
await dialogService.ShowDialogAsync(GuideImage, new DialogParameters()
{
Width = "680px",
Title = "Woher kommen die Werte?",
PreventDismissOnOverlayClick = true,
PreventScroll = true,
});
}
private static string M3(decimal value) => value.ToString("#,0.00", SwissNumbers) + " m³";
private static string Mwh(decimal value) => value.ToString("#,0.000", SwissNumbers) + " MWh";
private static string Chf(decimal value) => value.ToString("#,0.00", SwissNumbers) + " CHF";
private static CultureInfo CreateSwissNumbers()
{
var culture = new CultureInfo("de-CH");
culture.NumberFormat.NumberGroupSeparator = "'";
return culture;
}
}

View file

@ -15,25 +15,23 @@
}
else
{
<BillChartToolbar Filter="@filter" FilterChanged="@OnFilterChanged" Years="@years" IsSplit="@isSplit" />
<div class="pair">
<FluentCard class="chart-card">
<div class="card-title">Verbrauch @PerPeriod</div>
<div class="card-title">Verbrauch pro Halbjahr</div>
<ChartJsChart Kind="stackedBar" Data="@barData" Height="360px"
AriaLabel="@($"Netzbezug und PV-Produktion {PerPeriod}, gestapelte Balken in kWh")" />
AriaLabel="Netzbezug und PV-Produktion pro Halbjahr, gestapelte Balken in kWh" />
</FluentCard>
<FluentCard class="chart-card">
<div class="card-title">Preis pro kWh</div>
<ChartJsChart Kind="line" Data="@lineData" Height="360px"
AriaLabel="@($"Preis pro kWh für Netz, PV und Total {PerPeriod}")" />
AriaLabel="Preis pro kWh für Netz, PV und Total pro Halbjahr" />
</FluentCard>
</div>
<FluentCard class="chart-card">
<div class="card-title">Gesamtkosten @PerPeriod</div>
<div class="card-title">Gesamtkosten pro Halbjahr</div>
<ChartJsChart Kind="line" Data="@costData" Height="320px"
AriaLabel="@($"Gesamtkosten {PerPeriod}")" />
AriaLabel="Gesamtkosten pro Halbjahr" />
</FluentCard>
}

View file

@ -3,7 +3,6 @@ using Microsoft.FluentUI.AspNetCore.Components;
using Schaad.Accounting.Interfaces;
using Schaad.Accounting.Models;
using Schaad.Accounting.UI.Components.Pages.Charts;
using Schaad.Accounting.UI.Components.Pages.Controls;
using Schaad.Accounting.UI.Components.Pages.Dialogs;
namespace Schaad.Accounting.UI.Components.Pages;
@ -11,9 +10,8 @@ namespace Schaad.Accounting.UI.Components.Pages;
/// <summary>
/// Yearly NeoVac electricity bills for the apartment (billing period 1 July – 30 June, so the
/// bills are stored once per mandator, not per calendar year; see
/// <see cref="IElectricityBillRepository"/>). Grid for entering/editing, plus charts per bill,
/// calendar year or half-year over a year range (see <see cref="BillChartToolbar"/> and
/// <see cref="BillPeriod{T}"/>): consumption grid/PV, price per kWh and total costs.
/// <see cref="IElectricityBillRepository"/>). Grid for entering/editing, plus charts per half-year
/// (see <see cref="ElectricityHalfYear"/>): consumption grid/PV, price per kWh and total costs.
/// </summary>
public partial class Electricity : ComponentBase
{
@ -28,14 +26,6 @@ public partial class Electricity : ComponentBase
private IReadOnlyList<ElectricityBill> source = [];
private BillChartFilter filter = new();
// Years any bill touches, for the year range of the charts.
private List<int> years = [];
// True if a bill had to be spread over several periods of the selected kind.
private bool isSplit;
private object barData = new();
private object lineData = new();
private object costData = new();
@ -50,29 +40,21 @@ public partial class Electricity : ComponentBase
source = (await electricityBillRepository.GetElectricityBillListAsync())
.OrderBy(b => b.PeriodFrom)
.ToList();
years = BillChartFilter.YearsOf(source);
BuildCharts();
}
private void OnFilterChanged(BillChartFilter value)
{
filter = value;
BuildCharts();
}
private void BuildCharts()
{
// A bill reaching over several periods is spread evenly over its months.
var periods = filter.Apply(source);
isSplit = periods.Any(p => p.IsSplit);
var labels = periods.Select(p => p.Label).ToList();
// One entry per half-year; a yearly bill is split evenly into its two halves.
var halves = ElectricityHalfYear.FromBills(source);
var labels = halves.Select(h => h.Label).ToList();
barData = new
{
labels,
series = new object[]
{
new { name = "Netz", color = ChartTheme.ColorAt(0), values = periods.Select(p => p.Bill?.GridKwh).ToList(), clickable = false },
new { name = "PV", color = ChartTheme.ColorAt(1), values = periods.Select(p => p.Bill?.PvKwh).ToList(), clickable = false }
new { name = "Netz", color = ChartTheme.ColorAt(0), values = halves.Select(h => h.Bill?.GridKwh).ToList(), clickable = false },
new { name = "PV", color = ChartTheme.ColorAt(1), values = halves.Select(h => h.Bill?.PvKwh).ToList(), clickable = false }
},
unit = "kWh"
};
@ -81,9 +63,9 @@ public partial class Electricity : ComponentBase
labels,
series = new object[]
{
new { name = "Netz", color = ChartTheme.ColorAt(0), values = periods.Select(p => p.Bill?.GridChfPerKwh).ToList(), width = 2 },
new { name = "PV", color = ChartTheme.ColorAt(1), values = periods.Select(p => p.Bill?.PvChfPerKwh).ToList(), width = 2 },
new { name = "Total", color = ChartTheme.OtherColor, values = periods.Select(p => p.Bill?.ChfPerKwh).ToList(), width = 2 }
new { name = "Netz", color = ChartTheme.ColorAt(0), values = halves.Select(h => h.Bill?.GridChfPerKwh).ToList(), width = 2 },
new { name = "PV", color = ChartTheme.ColorAt(1), values = halves.Select(h => h.Bill?.PvChfPerKwh).ToList(), width = 2 },
new { name = "Total", color = ChartTheme.OtherColor, values = halves.Select(h => h.Bill?.ChfPerKwh).ToList(), width = 2 }
},
unit = "CHF/kWh",
axisDecimals = 2
@ -93,7 +75,7 @@ public partial class Electricity : ComponentBase
labels,
series = new object[]
{
new { name = "Total", color = ChartTheme.ColorAt(2), values = periods.Select(p => p.Bill?.TotalChf).ToList(), width = 2 }
new { name = "Total", color = ChartTheme.ColorAt(2), values = halves.Select(h => h.Bill?.TotalChf).ToList(), width = 2 }
},
unit = "CHF"
};
@ -104,7 +86,7 @@ public partial class Electricity : ComponentBase
var data = new ElectricityBill();
var dialog = await dialogService.ShowDialogAsync<ElectricityBillDialog>(data, new DialogParameters()
{
Width = "760px",
Width = "560px",
Height = "460px",
Title = "Abrechnung hinzufügen",
PreventDismissOnOverlayClick = true,
@ -124,7 +106,7 @@ public partial class Electricity : ComponentBase
var data = await electricityBillRepository.GetElectricityBillAsync(id);
var dialog = await dialogService.ShowDialogAsync<ElectricityBillDialog>(data, new DialogParameters()
{
Width = "760px",
Width = "560px",
Height = "460px",
Title = "Abrechnung bearbeiten",
PreventDismissOnOverlayClick = true,
@ -152,7 +134,5 @@ public partial class Electricity : ComponentBase
}
}
private string PerPeriod => BillChartToolbar.PerPeriod(filter.Kind);
private static string FullLabel(ElectricityBill bill) => $"{bill.PeriodFrom:dd.MM.yyyy} – {bill.PeriodTo:dd.MM.yyyy}";
}

View file

@ -39,7 +39,6 @@ public partial class JsonEditor : ComponentBase, IAsyncDisposable
private StandaloneCodeEditor? editor;
private IJSObjectReference? unsavedGuard;
private IJSObjectReference? url;
private bool monacoLoaded;
private string? monacoError;
private RawDataFile? file;
@ -49,12 +48,20 @@ public partial class JsonEditor : ComponentBase, IAsyncDisposable
private bool saving;
private IReadOnlyList<string> errors = [];
// The file parameter is only read here: switching files doesn't navigate (see OnFileChanged),
// and while leaving the page the query changes again for a component that is about to go.
protected override async Task OnInitializedAsync()
protected override async Task OnParametersSetAsync()
{
fileName = repository.FileNames.Contains(FileParameter ?? "") ? FileParameter! : repository.FileNames[0];
var requested = repository.FileNames.Contains(FileParameter ?? "") ? FileParameter! : repository.FileNames[0];
if (requested == fileName)
{
return;
}
fileName = requested;
file = await repository.LoadAsync(fileName);
errors = [];
if (editor is not null)
{
await ShowFileAsync();
}
}
protected override async Task OnAfterRenderAsync(bool firstRender)
@ -64,7 +71,6 @@ public partial class JsonEditor : ComponentBase, IAsyncDisposable
return;
}
unsavedGuard = await js.InvokeAsync<IJSObjectReference>("import", "./js/unsaved-guard.js");
url = await js.InvokeAsync<IJSObjectReference>("import", "./js/url.js");
try
{
await using var module = await js.InvokeAsync<IJSObjectReference>("import", "./js/monaco.js");
@ -160,33 +166,24 @@ public partial class JsonEditor : ComponentBase, IAsyncDisposable
await ShowFileAsync();
}
// Loads the file in place and only puts it into the address bar (for bookmarks and reloads).
// Navigating instead would run an enhanced navigation, which re-renders the page on the server
// and merges it into the DOM; the editor doesn't survive that.
// Switching goes through the URL, so the file is part of bookmarks and back/forward.
private async Task OnFileChanged(string name)
{
if (name == fileName)
{
return;
}
if (dirty && await ConfirmDiscardAsync() == false)
if (dirty)
{
if (await ConfirmDiscardAsync() == false)
{
// Re-render puts the select back on the current file.
StateHasChanged();
return;
}
fileName = name;
file = await repository.LoadAsync(fileName);
errors = [];
// Before Monaco is up, the editor picks up the file when it is created (EditorOptions).
if (editor is not null)
{
await ShowFileAsync();
}
if (url is not null)
{
await url.InvokeVoidAsync("replace", navigation.GetUriWithQueryParameter("file", name));
await SetDirtyAsync(false);
}
navigation.NavigateTo(navigation.GetUriWithQueryParameter("file", name));
}
private async Task<bool> ConfirmDiscardAsync()
@ -229,10 +226,6 @@ public partial class JsonEditor : ComponentBase, IAsyncDisposable
await unsavedGuard.InvokeVoidAsync("set", (object?)null);
await unsavedGuard.DisposeAsync();
}
if (url is not null)
{
await url.DisposeAsync();
}
}
catch (JSDisconnectedException)
{

View file

@ -35,7 +35,7 @@ else
</td>
<td>
<div class="text-column">
<input list="texts" @bind="@transaction.Text" placeholder="Type or select..."/>
<input list="texts" @bind="@transaction.Text" placeholder="Type or select..." readonly="@transaction.ReadOnly"/>
<datalist id="texts">
@foreach (var text in bookingTexts.OrderBy(t => t))
{
@ -60,12 +60,13 @@ else
<td style="align-content: center">
<FluentButton IconEnd="@(new Icons.Regular.Size16.SplitVertical())" Appearance="Appearance.Neutral"
title="Aufteilen" aria-label="Aufteilen"
OnClick="@(() => SplitBankTransactionAsync(transaction))" Disabled="@(transaction.Value > 0)" />
OnClick="@(() => SplitBankTransactionAsync(transaction))" Disabled="@(transaction.Value > 0 || transaction.ReadOnly)" />
</td>
<td style="align-content: center">
<FluentButton IconEnd="@(new Icons.Regular.Size16.Save())" Appearance="Appearance.Neutral"
title="Buchen" aria-label="Buchen"
OnClick="@(() => BookBankTransactionAsync(transaction))" />
OnClick="@(() => BookBankTransactionAsync(transaction))"
Disabled="@transaction.ReadOnly" />
</td>
</tr>
}

View file

@ -58,9 +58,7 @@ public partial class PendingBookings : ComponentBase
return;
}
await transactionRepository.SaveTransactionAsync(transaction);
// Only drop the booked row: reloading would re-run the booking rules and
// discard edits on the other rows.
matchingBankTransactions?.Remove(transaction);
transaction.ReadOnly = true;
}
private async Task SplitBankTransactionAsync(Transaction transaction)
@ -77,7 +75,7 @@ public partial class PendingBookings : ComponentBase
var result = await dialog.Result;
if (!result.Cancelled && result.Data != null)
{
matchingBankTransactions?.Remove(transaction);
await LoadDataAsync();
}
}
}

View file

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Components;
using Schaad.Accounting;
using Schaad.Accounting.Datasets;
using Schaad.Accounting.Interfaces;

View file

@ -1,54 +0,0 @@
@page "/water"
@rendermode InteractiveServer
@using Schaad.Accounting.UI.Components.Pages.Analytics
<PageTitle>Wasser</PageTitle>
<div class="water">
<FluentStack Orientation="Orientation.Horizontal" VerticalAlignment="VerticalAlignment.Center">
<FluentButton IconStart="@(new Icons.Regular.Size16.Add())" Appearance="Appearance.Neutral" OnClick="AddAsync">Neue Abrechnung hinzufügen</FluentButton>
</FluentStack>
@if (source.Count == 0)
{
<FluentMessageBar Intent="MessageIntent.Info" AllowDismiss="false">Noch keine Abrechnungen erfasst.</FluentMessageBar>
}
else
{
<BillChartToolbar Filter="@filter" FilterChanged="@OnFilterChanged" Years="@years" IsSplit="@isSplit" />
<div class="pair">
<FluentCard class="chart-card">
<div class="card-title">Verbrauch @PerPeriod</div>
<ChartJsChart Kind="stackedBar" Data="@barData" Height="360px"
AriaLabel="@($"Warm- und Kaltwasserverbrauch {PerPeriod}, gestapelte Balken in m³")" />
</FluentCard>
<FluentCard class="chart-card">
<div class="card-title">Gesamtkosten @PerPeriod</div>
<ChartJsChart Kind="line" Data="@costData" Height="360px"
AriaLabel="@($"Gesamtkosten {PerPeriod}")" />
</FluentCard>
</div>
}
<div class="table-scroll">
<FluentDataGrid Items="@source.AsQueryable()" RowSize="DataGridRowSize.Medium">
<PropertyColumn Title="Von" Property="@(p => p.PeriodFrom)" Format="dd.MM.yyyy" Sortable="true" IsDefaultSortColumn="true" InitialSortDirection="SortDirection.Descending" />
<PropertyColumn Title="Bis" Property="@(p => p.PeriodTo)" Format="dd.MM.yyyy" Sortable="true" />
<PropertyColumn Title="Warmwasser m³" Property="@(p => p.WarmWaterM3)" Format="#,0.00" Align="Align.End" />
<PropertyColumn Title="Kaltwasser m³" Property="@(p => p.ColdWaterM3)" Format="#,0.00" Align="Align.End" />
<PropertyColumn Title="Total m³" Property="@(p => p.TotalM3)" Format="#,0.00" Align="Align.End" />
<PropertyColumn Title="Warmwasser-Anteil" Property="@(p => p.WarmWaterShare)" Format="P1" Align="Align.End" />
<PropertyColumn Title="Warmwasser CHF" Property="@(p => p.WarmWaterChf)" Format="C2" Align="Align.End" />
<PropertyColumn Title="Kaltwasser CHF" Property="@(p => p.ColdWaterChf)" Format="C2" Align="Align.End" />
<PropertyColumn Title="Grundkosten" Property="@(p => p.BaseCostsChf)" Format="C2" Align="Align.End" />
<PropertyColumn Title="Total CHF" Property="@(p => p.TotalChf)" Format="C2" Align="Align.End" />
<TemplateColumn Align="Align.Center" Width="50px">
<FluentButton IconEnd="@(new Icons.Regular.Size16.Delete())" Appearance="Appearance.Neutral" title="Löschen" aria-label="Löschen" OnClick="@(() => DeleteAsync(context.Id))" />
</TemplateColumn>
<TemplateColumn Align="Align.Center" Width="50px">
<FluentButton IconEnd="@(new Icons.Regular.Size16.Edit())" Appearance="Appearance.Neutral" title="Bearbeiten" aria-label="Bearbeiten" OnClick="@(() => EditAsync(context.Id))" />
</TemplateColumn>
</FluentDataGrid>
</div>
</div>

View file

@ -1,146 +0,0 @@
using Microsoft.AspNetCore.Components;
using Microsoft.FluentUI.AspNetCore.Components;
using Schaad.Accounting.Interfaces;
using Schaad.Accounting.Models;
using Schaad.Accounting.UI.Components.Pages.Charts;
using Schaad.Accounting.UI.Components.Pages.Controls;
using Schaad.Accounting.UI.Components.Pages.Dialogs;
namespace Schaad.Accounting.UI.Components.Pages;
/// <summary>
/// Water bills for the apartment, laid out like the Strom page (<see cref="Electricity"/>): the
/// bills are stored once per mandator, not per calendar year (see <see cref="IWaterBillRepository"/>).
/// Grid for entering/editing, plus charts per bill, calendar year or half-year over a year range
/// (see <see cref="BillChartToolbar"/> and <see cref="BillPeriod{T}"/>): warm/cold water
/// consumption and total costs.
/// </summary>
public partial class Water : ComponentBase
{
[Inject]
private IWaterBillRepository waterBillRepository { get; set; } = null!;
[Inject]
private IDialogService dialogService { get; set; } = null!;
[Inject]
private IToastService toastService { get; set; } = null!;
private IReadOnlyList<WaterBill> source = [];
private BillChartFilter filter = new();
// Years any bill touches, for the year range of the charts.
private List<int> years = [];
// True if a bill had to be spread over several periods of the selected kind.
private bool isSplit;
private object barData = new();
private object costData = new();
protected override async Task OnInitializedAsync()
{
await LoadAsync();
}
private async Task LoadAsync()
{
source = (await waterBillRepository.GetWaterBillListAsync())
.OrderBy(b => b.PeriodFrom)
.ToList();
years = BillChartFilter.YearsOf(source);
BuildCharts();
}
private void OnFilterChanged(BillChartFilter value)
{
filter = value;
BuildCharts();
}
private void BuildCharts()
{
// A bill reaching over several periods is spread evenly over its months.
var periods = filter.Apply(source);
isSplit = periods.Any(p => p.IsSplit);
var labels = periods.Select(p => p.Label).ToList();
// Cold water blue, warm water orange.
barData = new
{
labels,
series = new object[]
{
new { name = "Warmwasser", color = ChartTheme.ColorAt(1), values = periods.Select(p => p.Bill?.WarmWaterM3).ToList(), clickable = false },
new { name = "Kaltwasser", color = ChartTheme.ColorAt(0), values = periods.Select(p => p.Bill?.ColdWaterM3).ToList(), clickable = false }
},
unit = "m³"
};
costData = new
{
labels,
series = new object[]
{
new { name = "Total", color = ChartTheme.ColorAt(2), values = periods.Select(p => p.Bill?.TotalChf).ToList(), width = 2 }
},
unit = "CHF"
};
}
private async Task AddAsync()
{
var data = new WaterBill();
var dialog = await dialogService.ShowDialogAsync<WaterBillDialog>(data, new DialogParameters()
{
Width = "560px",
Height = "460px",
Title = "Abrechnung hinzufügen",
PreventDismissOnOverlayClick = true,
PreventScroll = true,
});
var result = await dialog.Result;
if (!result.Cancelled && result.Data != null)
{
await LoadAsync();
toastService.ShowToast(ToastIntent.Success, "Abrechnung gespeichert", 3000);
}
}
private async Task EditAsync(string id)
{
var data = await waterBillRepository.GetWaterBillAsync(id);
var dialog = await dialogService.ShowDialogAsync<WaterBillDialog>(data, new DialogParameters()
{
Width = "560px",
Height = "460px",
Title = "Abrechnung bearbeiten",
PreventDismissOnOverlayClick = true,
PreventScroll = true,
});
var result = await dialog.Result;
if (!result.Cancelled && result.Data != null)
{
await LoadAsync();
toastService.ShowToast(ToastIntent.Success, "Abrechnung gespeichert", 3000);
}
}
private async Task DeleteAsync(string id)
{
var bill = source.First(b => b.Id == id);
var dialog = await dialogService.ShowConfirmationAsync($"Abrechnung {FullLabel(bill)} wirklich löschen?", "Ja", "Nein", "Abrechnung löschen");
var result = await dialog.Result;
if (!result.Cancelled)
{
await waterBillRepository.DeleteWaterBillAsync(id);
await LoadAsync();
toastService.ShowToast(ToastIntent.Success, "Abrechnung gelöscht", 3000);
}
}
private string PerPeriod => BillChartToolbar.PerPeriod(filter.Kind);
private static string FullLabel(WaterBill bill) => $"{bill.PeriodFrom:dd.MM.yyyy} – {bill.PeriodTo:dd.MM.yyyy}";
}

View file

@ -1,32 +0,0 @@
.water {
display: flex;
flex-direction: column;
gap: 16px;
}
.table-scroll {
overflow-x: auto;
}
.pair {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
gap: 12px;
}
@media (max-width: 1100px) {
.pair {
grid-template-columns: minmax(0, 1fr);
}
}
::deep .chart-card {
padding: 16px;
min-width: 0;
}
.card-title {
font-weight: 600;
font-size: 15px;
margin-bottom: 12px;
}

View file

@ -1,61 +0,0 @@
@page "/water-heating"
@rendermode InteractiveServer
@using Schaad.Accounting.UI.Components.Pages.Analytics
<PageTitle>Wasser &amp; Heizung</PageTitle>
<div class="water-heating">
<FluentStack Orientation="Orientation.Horizontal" VerticalAlignment="VerticalAlignment.Center">
<FluentButton IconStart="@(new Icons.Regular.Size16.Add())" Appearance="Appearance.Neutral" OnClick="AddAsync">Neue Abrechnung hinzufügen</FluentButton>
</FluentStack>
@if (source.Count == 0)
{
<FluentMessageBar Intent="MessageIntent.Info" AllowDismiss="false">Noch keine Abrechnungen erfasst.</FluentMessageBar>
}
else
{
<BillChartToolbar Filter="@filter" FilterChanged="@OnFilterChanged" Years="@years" IsSplit="@isSplit" />
<div class="pair">
<FluentCard class="chart-card">
<div class="card-title">Wasserverbrauch @PerPeriod</div>
<ChartJsChart Kind="stackedBar" Data="@waterData" Height="360px"
AriaLabel="@($"Warm- und Kaltwasserverbrauch {PerPeriod}, gestapelte Balken in m³")" />
</FluentCard>
<FluentCard class="chart-card">
<div class="card-title">Wärmeverbrauch @PerPeriod</div>
<ChartJsChart Kind="stackedBar" Data="@heatData" Height="360px"
AriaLabel="@($"Wärmeverbrauch {PerPeriod}, Balken in MWh")" />
</FluentCard>
</div>
<FluentCard class="chart-card">
<div class="card-title">Kosten @PerPeriod</div>
<ChartJsChart Kind="stackedBar" Data="@costData" Height="320px"
AriaLabel="@($"Kosten {PerPeriod}, gestapelte Balken in CHF: Grundkosten Wasser, Kalt- und Warmwasser, Heizung Warmwasser und Räume")" />
</FluentCard>
}
<div class="table-scroll">
<FluentDataGrid Items="@source.AsQueryable()" RowSize="DataGridRowSize.Medium">
<PropertyColumn Title="Von" Property="@(p => p.PeriodFrom)" Format="dd.MM.yyyy" Sortable="true" IsDefaultSortColumn="true" InitialSortDirection="SortDirection.Descending" />
<PropertyColumn Title="Bis" Property="@(p => p.PeriodTo)" Format="dd.MM.yyyy" Sortable="true" />
<PropertyColumn Title="Warmwasser m³" Property="@(p => p.WarmWaterM3)" Format="#,0.00" Align="Align.End" />
<PropertyColumn Title="Kaltwasser m³" Property="@(p => p.ColdWaterM3)" Format="#,0.00" Align="Align.End" />
<PropertyColumn Title="Wärme MWh" Property="@(p => p.HeatingMwh)" Format="#,0.000" Align="Align.End" />
<PropertyColumn Title="Grundkosten" Property="@(p => p.BaseCostsChf)" Format="C2" Align="Align.End" />
<PropertyColumn Title="Warmwasser CHF" Property="@(p => p.WarmWaterChf)" Format="C2" Align="Align.End" />
<PropertyColumn Title="Kaltwasser CHF" Property="@(p => p.ColdWaterChf)" Format="C2" Align="Align.End" />
<PropertyColumn Title="Heizung Warmwasser" Property="@(p => p.WarmWaterHeatingChf)" Format="C2" Align="Align.End" />
<PropertyColumn Title="Heizung Räume" Property="@(p => p.RoomHeatingChf)" Format="C2" Align="Align.End" />
<PropertyColumn Title="Total CHF" Property="@(p => p.TotalChf)" Format="C2" Align="Align.End" />
<TemplateColumn Align="Align.Center" Width="50px">
<FluentButton IconEnd="@(new Icons.Regular.Size16.Delete())" Appearance="Appearance.Neutral" title="Löschen" aria-label="Löschen" OnClick="@(() => DeleteAsync(context.Id))" />
</TemplateColumn>
<TemplateColumn Align="Align.Center" Width="50px">
<FluentButton IconEnd="@(new Icons.Regular.Size16.Edit())" Appearance="Appearance.Neutral" title="Bearbeiten" aria-label="Bearbeiten" OnClick="@(() => EditAsync(context.Id))" />
</TemplateColumn>
</FluentDataGrid>
</div>
</div>

View file

@ -1,164 +0,0 @@
using Microsoft.AspNetCore.Components;
using Microsoft.FluentUI.AspNetCore.Components;
using Schaad.Accounting.Interfaces;
using Schaad.Accounting.Models;
using Schaad.Accounting.UI.Components.Pages.Charts;
using Schaad.Accounting.UI.Components.Pages.Controls;
using Schaad.Accounting.UI.Components.Pages.Dialogs;
namespace Schaad.Accounting.UI.Components.Pages;
/// <summary>
/// NeoVac water and heating bills, laid out like the Wasser page (<see cref="Water"/>), which holds
/// the bills with the CHF values entered directly: the bills are stored once per mandator, not per
/// calendar year (see <see cref="IWaterHeatingBillRepository"/>). Grid for entering/editing, plus
/// charts per bill, calendar year or half-year over a year range (see <see cref="BillChartToolbar"/>
/// and <see cref="BillPeriod{T}"/>): warm/cold water and heat consumption, and the costs split into
/// water base costs, cold/warm water and heating for warm water and the rooms.
/// </summary>
public partial class WaterHeating : ComponentBase
{
[Inject]
private IWaterHeatingBillRepository waterHeatingBillRepository { get; set; } = null!;
[Inject]
private IDialogService dialogService { get; set; } = null!;
[Inject]
private IToastService toastService { get; set; } = null!;
private IReadOnlyList<WaterHeatingBill> source = [];
private BillChartFilter filter = new();
// Years any bill touches, for the year range of the charts.
private List<int> years = [];
// True if a bill had to be spread over several periods of the selected kind.
private bool isSplit;
private object waterData = new();
private object heatData = new();
private object costData = new();
protected override async Task OnInitializedAsync()
{
await LoadAsync();
}
private async Task LoadAsync()
{
source = (await waterHeatingBillRepository.GetWaterHeatingBillListAsync())
.OrderBy(b => b.PeriodFrom)
.ToList();
years = BillChartFilter.YearsOf(source);
BuildCharts();
}
private void OnFilterChanged(BillChartFilter value)
{
filter = value;
BuildCharts();
}
private void BuildCharts()
{
// A bill reaching over several periods is spread evenly over its months.
var periods = filter.Apply(source);
isSplit = periods.Any(p => p.IsSplit);
var labels = periods.Select(p => p.Label).ToList();
// Cold water blue, warm water orange.
waterData = new
{
labels,
series = new object[]
{
new { name = "Warmwasser", color = ChartTheme.ColorAt(1), values = periods.Select(p => p.Bill?.WarmWaterM3).ToList(), clickable = false },
new { name = "Kaltwasser", color = ChartTheme.ColorAt(0), values = periods.Select(p => p.Bill?.ColdWaterM3).ToList(), clickable = false }
},
unit = "m³"
};
heatData = new
{
labels,
series = new object[]
{
new { name = "Wärme", color = ChartTheme.ColorAt(7), values = periods.Select(p => p.Bill?.HeatingMwh).ToList(), clickable = false }
},
unit = "MWh",
// A few MWh per year: whole-number ticks would repeat the same value.
axisDecimals = 1
};
// Water parts first, then the heating parts (warm water, rooms).
costData = new
{
labels,
series = new object[]
{
new { name = "Grundkosten Wasser", color = ChartTheme.ColorAt(2), values = periods.Select(p => p.Bill?.BaseCostsChf).ToList(), clickable = false },
new { name = "Kaltwasser", color = ChartTheme.ColorAt(0), values = periods.Select(p => p.Bill?.ColdWaterChf).ToList(), clickable = false },
new { name = "Warmwasser", color = ChartTheme.ColorAt(1), values = periods.Select(p => p.Bill?.WarmWaterChf).ToList(), clickable = false },
new { name = "Heizung Warmwasser", color = ChartTheme.ColorAt(3), values = periods.Select(p => p.Bill?.WarmWaterHeatingChf).ToList(), clickable = false },
new { name = "Heizung Räume", color = ChartTheme.ColorAt(7), values = periods.Select(p => p.Bill?.RoomHeatingChf).ToList(), clickable = false }
},
unit = "CHF"
};
}
private async Task AddAsync()
{
var data = new WaterHeatingBill();
var dialog = await dialogService.ShowDialogAsync<WaterHeatingBillDialog>(data, new DialogParameters()
{
Width = "760px",
Height = "820px",
Title = "Abrechnung hinzufügen",
PreventDismissOnOverlayClick = true,
PreventScroll = true,
});
var result = await dialog.Result;
if (!result.Cancelled && result.Data != null)
{
await LoadAsync();
toastService.ShowToast(ToastIntent.Success, "Abrechnung gespeichert", 3000);
}
}
private async Task EditAsync(string id)
{
var data = await waterHeatingBillRepository.GetWaterHeatingBillAsync(id);
var dialog = await dialogService.ShowDialogAsync<WaterHeatingBillDialog>(data, new DialogParameters()
{
Width = "760px",
Height = "820px",
Title = "Abrechnung bearbeiten",
PreventDismissOnOverlayClick = true,
PreventScroll = true,
});
var result = await dialog.Result;
if (!result.Cancelled && result.Data != null)
{
await LoadAsync();
toastService.ShowToast(ToastIntent.Success, "Abrechnung gespeichert", 3000);
}
}
private async Task DeleteAsync(string id)
{
var bill = source.First(b => b.Id == id);
var dialog = await dialogService.ShowConfirmationAsync($"Abrechnung {FullLabel(bill)} wirklich löschen?", "Ja", "Nein", "Abrechnung löschen");
var result = await dialog.Result;
if (!result.Cancelled)
{
await waterHeatingBillRepository.DeleteWaterHeatingBillAsync(id);
await LoadAsync();
toastService.ShowToast(ToastIntent.Success, "Abrechnung gelöscht", 3000);
}
}
private string PerPeriod => BillChartToolbar.PerPeriod(filter.Kind);
private static string FullLabel(WaterHeatingBill bill) => $"{bill.PeriodFrom:dd.MM.yyyy} – {bill.PeriodTo:dd.MM.yyyy}";
}

View file

@ -1,32 +0,0 @@
.water-heating {
display: flex;
flex-direction: column;
gap: 16px;
}
.table-scroll {
overflow-x: auto;
}
.pair {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
gap: 12px;
}
@media (max-width: 1100px) {
.pair {
grid-template-columns: minmax(0, 1fr);
}
}
::deep .chart-card {
padding: 16px;
min-width: 0;
}
.card-title {
font-weight: 600;
font-size: 15px;
margin-bottom: 12px;
}

View file

@ -22,8 +22,7 @@ namespace Schaad.Accounting.UI
services.AddScoped<IBookingRuleRepository, BookingRuleRepository>();
services.AddScoped<IBookingTextRepository, BookingTextRepository>();
services.AddScoped<IElectricityBillRepository, ElectricityBillRepository>();
services.AddScoped<IWaterBillRepository, WaterBillRepository>();
services.AddScoped<IWaterHeatingBillRepository, WaterHeatingBillRepository>();
services.AddScoped<ISplitPredefinitionRepository, SplitPredefinitionRepository>();
services.AddScoped<ISubclassRepository, SubclassRepository>();
services.AddScoped<ITransactionRepository, TransactionRepository>();
services.AddScoped<IMultiYearRepository, MultiYearRepository>();
@ -34,8 +33,10 @@ namespace Schaad.Accounting.UI
services.AddScoped<IViewService, ViewService>();
services.AddScoped<IFileService, FileService>();
services.AddScoped<IAccountStatementService, AccountStatementService>();
services.AddScoped<ICreditCardStatementService, CreditCardStatementService>();
services.AddSingleton<IFxService, DummyFxService>();
services.AddScoped<IFxConverter, FxConverter>();
services.AddSingleton<IPdfParsingService, PdfParsingService>();
return services;
}

View file

@ -2,10 +2,20 @@ html, body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
a {
a, .btn-link {
color: #006bb7;
}
.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}
.content {
padding-top: 1.1rem;
}
@ -17,34 +27,6 @@ a {
min-height: calc(100vh - 96px);
}
/* Fields in dialogs: two columns, each field a fixed-width label left of an input that fills the
rest, so labels and inputs line up across rows and sections. Fluent renders the label and the
input as siblings, so each field needs its own .dialog-field wrapper. */
.dialog-fields {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
column-gap: 24px;
row-gap: 8px;
}
.dialog-field {
display: flex;
align-items: center;
gap: 8px;
}
.dialog-field .fluent-input-label {
flex: 0 0 140px;
margin: 0;
}
.dialog-field fluent-number-field,
.dialog-field fluent-text-field {
flex: 1 1 auto;
min-width: 0;
width: auto;
}
h1:focus {
outline: none;
}
@ -61,6 +43,29 @@ h1:focus {
color: #e50000;
}
.blazor-error-boundary {
background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
padding: 1rem 1rem 1rem 3.7rem;
color: white;
}
.blazor-error-boundary::after {
content: "An error has occurred."
}
.darker-border-checkbox.form-check-input {
border-color: #929292;
}
.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
color: var(--bs-secondary-color);
text-align: end;
}
.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
text-align: start;
}
@media print {
.hidePrint {
display: none !important;

View file

@ -1,79 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 824" role="img" aria-labelledby="guide-title">
<title id="guide-title">Beispiel-Abrechnung: Wo stehen die Werte?</title>
<rect x="8" y="8" width="624" height="808" rx="10" fill="#fcfcfb" stroke="#e1e0d9" />
<text x="24" y="38" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="16" font-weight="bold" fill="#0b0b0b">Beispiel: Wo stehen die Werte auf der Abrechnung?</text>
<text x="24" y="58" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#52514e">Platzhalterwerte – der Aufbau entspricht der NeoVac-Abrechnung und der Aufstellung der Verwaltung.</text>
<line x1="24" y1="72" x2="616" y2="72" stroke="#e1e0d9" stroke-width="1" />
<text x="24" y="98" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#898781">NEOVAC – ABLESEQUITTUNG, SPALTE „VERBRAUCH VERRECHNET“</text>
<!-- Von / Bis -->
<text x="24" y="133" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" fill="#0b0b0b">Abrechnungsperiode</text>
<rect x="380" y="113" width="232" height="22" rx="4" fill="none" stroke="#e87ba4" stroke-width="2" />
<text x="604" y="129" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" font-weight="bold" fill="#0b0b0b">01.07.2025 – 30.06.2026</text>
<text x="604" y="147" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#e87ba4">→ Von / Bis</text>
<!-- Warmwasser (m³) -->
<text x="24" y="175" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" fill="#0b0b0b">Wasser – WAZ Pic. (WW)</text>
<rect x="380" y="155" width="232" height="22" rx="4" fill="none" stroke="#eb6834" stroke-width="2" />
<text x="604" y="171" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" font-weight="bold" fill="#0b0b0b">15.000</text>
<text x="604" y="189" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#eb6834">→ Warmwasser (m³)</text>
<!-- Kaltwasser (m³) -->
<text x="24" y="217" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" fill="#0b0b0b">Wasser – WAZ Pic. (KW)</text>
<rect x="380" y="197" width="232" height="22" rx="4" fill="none" stroke="#2a78d6" stroke-width="2" />
<text x="604" y="213" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" font-weight="bold" fill="#0b0b0b">45.000</text>
<text x="604" y="231" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#2a78d6">→ Kaltwasser (m³)</text>
<!-- Wärme (MWh) -->
<text x="24" y="259" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" fill="#0b0b0b">Wärme – Total Wärme (MWh)</text>
<rect x="380" y="239" width="232" height="22" rx="4" fill="none" stroke="#e34948" stroke-width="2" />
<text x="604" y="255" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" font-weight="bold" fill="#0b0b0b">2.400</text>
<text x="604" y="273" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#e34948">→ Wärme (MWh)</text>
<text x="24" y="298" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#52514e">Den Verbrauch übernehmen, nicht „Stand neu“ – das ist der Zählerstand.</text>
<line x1="24" y1="312" x2="616" y2="312" stroke="#e1e0d9" stroke-width="1" />
<text x="24" y="338" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#898781">NEOVAC – WASSERKOSTEN / WÄRMEKOSTEN, SPALTE „ANTEIL (‰)“</text>
<!-- Wasser Grund (‰) -->
<text x="24" y="373" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" fill="#0b0b0b">Wasser – Grundkosten</text>
<rect x="380" y="353" width="232" height="22" rx="4" fill="none" stroke="#1baf7a" stroke-width="2" />
<text x="604" y="369" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" font-weight="bold" fill="#0b0b0b">20.00</text>
<text x="604" y="387" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#1baf7a">→ Wasser Grund (‰)</text>
<!-- Wasser Verbrauch (‰) -->
<text x="24" y="415" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" fill="#0b0b0b">Wasser – Verbrauchskosten</text>
<rect x="380" y="395" width="232" height="22" rx="4" fill="none" stroke="#8a5cd1" stroke-width="2" />
<text x="604" y="411" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" font-weight="bold" fill="#0b0b0b">70.00</text>
<text x="604" y="429" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#8a5cd1">→ Wasser Verbrauch (‰)</text>
<!-- Heizung total (‰) -->
<text x="24" y="457" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" fill="#0b0b0b">Wärmekostenanteil (Gesamt)</text>
<rect x="380" y="437" width="232" height="22" rx="4" fill="none" stroke="#c98500" stroke-width="2" />
<text x="604" y="453" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" font-weight="bold" fill="#0b0b0b">60.00</text>
<text x="604" y="471" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#c98500">→ Heizung total (‰)</text>
<!-- Heizung WW (‰) -->
<text x="24" y="499" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" fill="#0b0b0b">Warmwasser (Gesamt)</text>
<rect x="380" y="479" width="232" height="22" rx="4" fill="none" stroke="#c98500" stroke-width="2" />
<text x="604" y="495" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" font-weight="bold" fill="#0b0b0b">12.00</text>
<text x="604" y="513" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#c98500">→ Heizung WW (‰)</text>
<line x1="24" y1="528" x2="616" y2="528" stroke="#e1e0d9" stroke-width="1" />
<text x="24" y="554" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#898781">VERWALTUNG – AUFSTELLUNG, IHR ANTEIL</text>
<!-- Wasserkosten (CHF) -->
<text x="24" y="589" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" fill="#0b0b0b">Wasserkosten</text>
<rect x="380" y="569" width="232" height="22" rx="4" fill="none" stroke="#1a9bb0" stroke-width="2" />
<text x="604" y="585" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" font-weight="bold" fill="#0b0b0b">300.00</text>
<text x="604" y="603" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#1a9bb0">→ Wasserkosten (CHF)</text>
<!-- Heizkosten (CHF) -->
<text x="24" y="631" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" fill="#0b0b0b">Heizkosten</text>
<rect x="380" y="611" width="232" height="22" rx="4" fill="none" stroke="#c98500" stroke-width="2" />
<text x="604" y="627" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" font-weight="bold" fill="#0b0b0b">450.00</text>
<text x="604" y="645" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#c98500">→ Heizkosten (CHF)</text>
<!-- Wasser / Heizung (‰, optional) -->
<text x="24" y="673" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" fill="#0b0b0b">Promille Wasser / Heizung</text>
<rect x="380" y="653" width="232" height="22" rx="4" fill="none" stroke="#898781" stroke-width="2" />
<text x="604" y="669" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" font-weight="bold" fill="#0b0b0b">90.000 / 60.000</text>
<text x="604" y="687" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#898781">→ Wasser / Heizung (‰, optional)</text>
<text x="24" y="712" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#52514e">Die Kontrolle vergleicht sie mit Grund + Verbrauch bzw. dem Wärmekostenanteil von NeoVac.</text>
<line x1="24" y1="726" x2="616" y2="726" stroke="#e1e0d9" stroke-width="1" />
<!-- Worked example, informational only -->
<text x="24" y="752" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">Grundkosten 300.00 × 20 / 90</text>
<text x="604" y="752" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">66.67</text>
<text x="24" y="774" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">Verbrauch 233.33, davon 15 von 60 m³ warm</text>
<text x="604" y="774" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">Warmwasser 58.33 · Kaltwasser 175.00</text>
<text x="24" y="796" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">Heizung Warmwasser 450.00 × 12 / 60</text>
<text x="604" y="796" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">Heizung Warmwasser 90.00 · Räume 360.00</text>
</svg>

Before

Width:  |  Height:  |  Size: 9.7 KiB

View file

@ -1,43 +1,28 @@
// Thin Chart.js wrapper for Blazor (see ChartJsChart.razor). Chart.js and the treemap plugin are
// loaded on first use from wwwroot/lib, so pages without charts don't pay for them.
let chartJsLoading;
let treemapLoading;
const scripts = new Map();
function loadScript(src) {
return new Promise((resolve, reject) => {
if (!scripts.has(src)) {
scripts.set(src, new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = src;
script.onload = resolve;
script.onerror = () => reject(new Error(`${src} could not be loaded`));
document.head.appendChild(script);
});
}));
}
return scripts.get(src);
}
// The JSON editor's Monaco loader (js/monaco.js) leaves a global AMD define() in the window, and
// pages switch without a full reload. Chart.js and the treemap plugin are UMD bundles that prefer
// define() when it exists, registering as AMD modules instead of setting window.Chart, so hide it
// while they load. Each script loads only once (see loadChartJs), so this never overlaps with
// itself and always restores Monaco's define.
async function loadUmdScript(src) {
const define = window.define;
window.define = undefined;
try {
await loadScript(src);
} finally {
window.define = define;
}
}
function loadChartJs(kind) {
chartJsLoading ??= loadUmdScript('lib/chartjs/chart.umd.min.js')
.then(() => { window.Chart.defaults.font.family = theme.font; });
if (kind !== 'treemap') {
return chartJsLoading;
}
async function loadChartJs(kind) {
await loadScript('lib/chartjs/chart.umd.min.js');
if (kind === 'treemap') {
// Registers itself with the global Chart.
treemapLoading ??= chartJsLoading.then(() => loadUmdScript('lib/chartjs-chart-treemap/chartjs-chart-treemap.min.js'));
return treemapLoading;
await loadScript('lib/chartjs-chart-treemap/chartjs-chart-treemap.min.js');
}
window.Chart.defaults.font.family = theme.font;
}
// Same look as ChartTheme.cs.

View file

@ -4,25 +4,6 @@
let loading;
// Enhanced navigation (moving between pages without a full reload) syncs <head> with the
// server-rendered page and so removes the stylesheets Monaco added at runtime. Monaco itself stays
// loaded in the window, so remember those elements and put them back before the next editor is
// created. Monaco keeps references to its <style> elements (e.g. the theme colors) and updates
// them in place, so they have to be the same elements, not copies.
const monacoStyles = new Set();
function isMonacoStyle(node) {
return node.tagName === 'STYLE' || (node.tagName === 'LINK' && node.href?.includes('/BlazorMonaco/'));
}
function restoreStyles() {
for (const node of monacoStyles) {
if (node.isConnected === false) {
document.head.appendChild(node);
}
}
}
function loadScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
@ -33,14 +14,7 @@ function loadScript(src) {
});
}
export async function ensureLoaded() {
if (loading === undefined) {
new MutationObserver(records => {
for (const record of records) {
record.addedNodes.forEach(node => isMonacoStyle(node) && monacoStyles.add(node));
}
}).observe(document.head, { childList: true });
}
export function ensureLoaded() {
loading ??= (async () => {
// Sets the AMD path config (var require = ...) and window.blazorMonaco.
await loadScript('_content/BlazorMonaco/jsInterop.js');
@ -49,6 +23,5 @@ export async function ensureLoaded() {
// editor.main registers itself as an AMD module; wait until it (and window.monaco) is ready.
await new Promise(resolve => window.require(['vs/editor/editor.main'], resolve));
})();
await loading;
restoreStyles();
return loading;
}

View file

@ -1,8 +0,0 @@
// Changes the address bar without navigating. Pages are interactive one by one, so
// NavigationManager.NavigateTo runs an enhanced navigation (the page is rendered again on the
// server and merged into the DOM), which the JSON editor can't survive.
/** Replaces the current history entry's URL, keeping Blazor's history state. */
export function replace(url) {
history.replaceState(history.state, '', url);
}

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,597 @@
/*!
* Bootstrap Reboot v5.3.3 (https://getbootstrap.com/)
* Copyright 2011-2024 The Bootstrap Authors
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
:root,
[data-bs-theme=light] {
--bs-blue: #0d6efd;
--bs-indigo: #6610f2;
--bs-purple: #6f42c1;
--bs-pink: #d63384;
--bs-red: #dc3545;
--bs-orange: #fd7e14;
--bs-yellow: #ffc107;
--bs-green: #198754;
--bs-teal: #20c997;
--bs-cyan: #0dcaf0;
--bs-black: #000;
--bs-white: #fff;
--bs-gray: #6c757d;
--bs-gray-dark: #343a40;
--bs-gray-100: #f8f9fa;
--bs-gray-200: #e9ecef;
--bs-gray-300: #dee2e6;
--bs-gray-400: #ced4da;
--bs-gray-500: #adb5bd;
--bs-gray-600: #6c757d;
--bs-gray-700: #495057;
--bs-gray-800: #343a40;
--bs-gray-900: #212529;
--bs-primary: #0d6efd;
--bs-secondary: #6c757d;
--bs-success: #198754;
--bs-info: #0dcaf0;
--bs-warning: #ffc107;
--bs-danger: #dc3545;
--bs-light: #f8f9fa;
--bs-dark: #212529;
--bs-primary-rgb: 13, 110, 253;
--bs-secondary-rgb: 108, 117, 125;
--bs-success-rgb: 25, 135, 84;
--bs-info-rgb: 13, 202, 240;
--bs-warning-rgb: 255, 193, 7;
--bs-danger-rgb: 220, 53, 69;
--bs-light-rgb: 248, 249, 250;
--bs-dark-rgb: 33, 37, 41;
--bs-primary-text-emphasis: #052c65;
--bs-secondary-text-emphasis: #2b2f32;
--bs-success-text-emphasis: #0a3622;
--bs-info-text-emphasis: #055160;
--bs-warning-text-emphasis: #664d03;
--bs-danger-text-emphasis: #58151c;
--bs-light-text-emphasis: #495057;
--bs-dark-text-emphasis: #495057;
--bs-primary-bg-subtle: #cfe2ff;
--bs-secondary-bg-subtle: #e2e3e5;
--bs-success-bg-subtle: #d1e7dd;
--bs-info-bg-subtle: #cff4fc;
--bs-warning-bg-subtle: #fff3cd;
--bs-danger-bg-subtle: #f8d7da;
--bs-light-bg-subtle: #fcfcfd;
--bs-dark-bg-subtle: #ced4da;
--bs-primary-border-subtle: #9ec5fe;
--bs-secondary-border-subtle: #c4c8cb;
--bs-success-border-subtle: #a3cfbb;
--bs-info-border-subtle: #9eeaf9;
--bs-warning-border-subtle: #ffe69c;
--bs-danger-border-subtle: #f1aeb5;
--bs-light-border-subtle: #e9ecef;
--bs-dark-border-subtle: #adb5bd;
--bs-white-rgb: 255, 255, 255;
--bs-black-rgb: 0, 0, 0;
--bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
--bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));
--bs-body-font-family: var(--bs-font-sans-serif);
--bs-body-font-size: 1rem;
--bs-body-font-weight: 400;
--bs-body-line-height: 1.5;
--bs-body-color: #212529;
--bs-body-color-rgb: 33, 37, 41;
--bs-body-bg: #fff;
--bs-body-bg-rgb: 255, 255, 255;
--bs-emphasis-color: #000;
--bs-emphasis-color-rgb: 0, 0, 0;
--bs-secondary-color: rgba(33, 37, 41, 0.75);
--bs-secondary-color-rgb: 33, 37, 41;
--bs-secondary-bg: #e9ecef;
--bs-secondary-bg-rgb: 233, 236, 239;
--bs-tertiary-color: rgba(33, 37, 41, 0.5);
--bs-tertiary-color-rgb: 33, 37, 41;
--bs-tertiary-bg: #f8f9fa;
--bs-tertiary-bg-rgb: 248, 249, 250;
--bs-heading-color: inherit;
--bs-link-color: #0d6efd;
--bs-link-color-rgb: 13, 110, 253;
--bs-link-decoration: underline;
--bs-link-hover-color: #0a58ca;
--bs-link-hover-color-rgb: 10, 88, 202;
--bs-code-color: #d63384;
--bs-highlight-color: #212529;
--bs-highlight-bg: #fff3cd;
--bs-border-width: 1px;
--bs-border-style: solid;
--bs-border-color: #dee2e6;
--bs-border-color-translucent: rgba(0, 0, 0, 0.175);
--bs-border-radius: 0.375rem;
--bs-border-radius-sm: 0.25rem;
--bs-border-radius-lg: 0.5rem;
--bs-border-radius-xl: 1rem;
--bs-border-radius-xxl: 2rem;
--bs-border-radius-2xl: var(--bs-border-radius-xxl);
--bs-border-radius-pill: 50rem;
--bs-box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
--bs-box-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
--bs-box-shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
--bs-box-shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.075);
--bs-focus-ring-width: 0.25rem;
--bs-focus-ring-opacity: 0.25;
--bs-focus-ring-color: rgba(13, 110, 253, 0.25);
--bs-form-valid-color: #198754;
--bs-form-valid-border-color: #198754;
--bs-form-invalid-color: #dc3545;
--bs-form-invalid-border-color: #dc3545;
}
[data-bs-theme=dark] {
color-scheme: dark;
--bs-body-color: #dee2e6;
--bs-body-color-rgb: 222, 226, 230;
--bs-body-bg: #212529;
--bs-body-bg-rgb: 33, 37, 41;
--bs-emphasis-color: #fff;
--bs-emphasis-color-rgb: 255, 255, 255;
--bs-secondary-color: rgba(222, 226, 230, 0.75);
--bs-secondary-color-rgb: 222, 226, 230;
--bs-secondary-bg: #343a40;
--bs-secondary-bg-rgb: 52, 58, 64;
--bs-tertiary-color: rgba(222, 226, 230, 0.5);
--bs-tertiary-color-rgb: 222, 226, 230;
--bs-tertiary-bg: #2b3035;
--bs-tertiary-bg-rgb: 43, 48, 53;
--bs-primary-text-emphasis: #6ea8fe;
--bs-secondary-text-emphasis: #a7acb1;
--bs-success-text-emphasis: #75b798;
--bs-info-text-emphasis: #6edff6;
--bs-warning-text-emphasis: #ffda6a;
--bs-danger-text-emphasis: #ea868f;
--bs-light-text-emphasis: #f8f9fa;
--bs-dark-text-emphasis: #dee2e6;
--bs-primary-bg-subtle: #031633;
--bs-secondary-bg-subtle: #161719;
--bs-success-bg-subtle: #051b11;
--bs-info-bg-subtle: #032830;
--bs-warning-bg-subtle: #332701;
--bs-danger-bg-subtle: #2c0b0e;
--bs-light-bg-subtle: #343a40;
--bs-dark-bg-subtle: #1a1d20;
--bs-primary-border-subtle: #084298;
--bs-secondary-border-subtle: #41464b;
--bs-success-border-subtle: #0f5132;
--bs-info-border-subtle: #087990;
--bs-warning-border-subtle: #997404;
--bs-danger-border-subtle: #842029;
--bs-light-border-subtle: #495057;
--bs-dark-border-subtle: #343a40;
--bs-heading-color: inherit;
--bs-link-color: #6ea8fe;
--bs-link-hover-color: #8bb9fe;
--bs-link-color-rgb: 110, 168, 254;
--bs-link-hover-color-rgb: 139, 185, 254;
--bs-code-color: #e685b5;
--bs-highlight-color: #dee2e6;
--bs-highlight-bg: #664d03;
--bs-border-color: #495057;
--bs-border-color-translucent: rgba(255, 255, 255, 0.15);
--bs-form-valid-color: #75b798;
--bs-form-valid-border-color: #75b798;
--bs-form-invalid-color: #ea868f;
--bs-form-invalid-border-color: #ea868f;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
@media (prefers-reduced-motion: no-preference) {
:root {
scroll-behavior: smooth;
}
}
body {
margin: 0;
font-family: var(--bs-body-font-family);
font-size: var(--bs-body-font-size);
font-weight: var(--bs-body-font-weight);
line-height: var(--bs-body-line-height);
color: var(--bs-body-color);
text-align: var(--bs-body-text-align);
background-color: var(--bs-body-bg);
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
hr {
margin: 1rem 0;
color: inherit;
border: 0;
border-top: var(--bs-border-width) solid;
opacity: 0.25;
}
h6, h5, h4, h3, h2, h1 {
margin-top: 0;
margin-bottom: 0.5rem;
font-weight: 500;
line-height: 1.2;
color: var(--bs-heading-color);
}
h1 {
font-size: calc(1.375rem + 1.5vw);
}
@media (min-width: 1200px) {
h1 {
font-size: 2.5rem;
}
}
h2 {
font-size: calc(1.325rem + 0.9vw);
}
@media (min-width: 1200px) {
h2 {
font-size: 2rem;
}
}
h3 {
font-size: calc(1.3rem + 0.6vw);
}
@media (min-width: 1200px) {
h3 {
font-size: 1.75rem;
}
}
h4 {
font-size: calc(1.275rem + 0.3vw);
}
@media (min-width: 1200px) {
h4 {
font-size: 1.5rem;
}
}
h5 {
font-size: 1.25rem;
}
h6 {
font-size: 1rem;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
abbr[title] {
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
cursor: help;
-webkit-text-decoration-skip-ink: none;
text-decoration-skip-ink: none;
}
address {
margin-bottom: 1rem;
font-style: normal;
line-height: inherit;
}
ol,
ul {
padding-left: 2rem;
}
ol,
ul,
dl {
margin-top: 0;
margin-bottom: 1rem;
}
ol ol,
ul ul,
ol ul,
ul ol {
margin-bottom: 0;
}
dt {
font-weight: 700;
}
dd {
margin-bottom: 0.5rem;
margin-left: 0;
}
blockquote {
margin: 0 0 1rem;
}
b,
strong {
font-weight: bolder;
}
small {
font-size: 0.875em;
}
mark {
padding: 0.1875em;
color: var(--bs-highlight-color);
background-color: var(--bs-highlight-bg);
}
sub,
sup {
position: relative;
font-size: 0.75em;
line-height: 0;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
a {
color: rgba(var(--bs-link-color-rgb), var(--bs-link-opacity, 1));
text-decoration: underline;
}
a:hover {
--bs-link-color-rgb: var(--bs-link-hover-color-rgb);
}
a:not([href]):not([class]), a:not([href]):not([class]):hover {
color: inherit;
text-decoration: none;
}
pre,
code,
kbd,
samp {
font-family: var(--bs-font-monospace);
font-size: 1em;
}
pre {
display: block;
margin-top: 0;
margin-bottom: 1rem;
overflow: auto;
font-size: 0.875em;
}
pre code {
font-size: inherit;
color: inherit;
word-break: normal;
}
code {
font-size: 0.875em;
color: var(--bs-code-color);
word-wrap: break-word;
}
a > code {
color: inherit;
}
kbd {
padding: 0.1875rem 0.375rem;
font-size: 0.875em;
color: var(--bs-body-bg);
background-color: var(--bs-body-color);
border-radius: 0.25rem;
}
kbd kbd {
padding: 0;
font-size: 1em;
}
figure {
margin: 0 0 1rem;
}
img,
svg {
vertical-align: middle;
}
table {
caption-side: bottom;
border-collapse: collapse;
}
caption {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
color: var(--bs-secondary-color);
text-align: left;
}
th {
text-align: inherit;
text-align: -webkit-match-parent;
}
thead,
tbody,
tfoot,
tr,
td,
th {
border-color: inherit;
border-style: solid;
border-width: 0;
}
label {
display: inline-block;
}
button {
border-radius: 0;
}
button:focus:not(:focus-visible) {
outline: 0;
}
input,
button,
select,
optgroup,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button,
select {
text-transform: none;
}
[role=button] {
cursor: pointer;
}
select {
word-wrap: normal;
}
select:disabled {
opacity: 1;
}
[list]:not([type=date]):not([type=datetime-local]):not([type=month]):not([type=week]):not([type=time])::-webkit-calendar-picker-indicator {
display: none !important;
}
button,
[type=button],
[type=reset],
[type=submit] {
-webkit-appearance: button;
}
button:not(:disabled),
[type=button]:not(:disabled),
[type=reset]:not(:disabled),
[type=submit]:not(:disabled) {
cursor: pointer;
}
::-moz-focus-inner {
padding: 0;
border-style: none;
}
textarea {
resize: vertical;
}
fieldset {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
legend {
float: left;
width: 100%;
padding: 0;
margin-bottom: 0.5rem;
font-size: calc(1.275rem + 0.3vw);
line-height: inherit;
}
@media (min-width: 1200px) {
legend {
font-size: 1.5rem;
}
}
legend + * {
clear: left;
}
::-webkit-datetime-edit-fields-wrapper,
::-webkit-datetime-edit-text,
::-webkit-datetime-edit-minute,
::-webkit-datetime-edit-hour-field,
::-webkit-datetime-edit-day-field,
::-webkit-datetime-edit-month-field,
::-webkit-datetime-edit-year-field {
padding: 0;
}
::-webkit-inner-spin-button {
height: auto;
}
[type=search] {
-webkit-appearance: textfield;
outline-offset: -2px;
}
/* rtl:raw:
[type="tel"],
[type="url"],
[type="email"],
[type="number"] {
direction: ltr;
}
*/
::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-color-swatch-wrapper {
padding: 0;
}
::-webkit-file-upload-button {
font: inherit;
-webkit-appearance: button;
}
::file-selector-button {
font: inherit;
-webkit-appearance: button;
}
output {
display: inline-block;
}
iframe {
border: 0;
}
summary {
display: list-item;
cursor: pointer;
}
progress {
vertical-align: baseline;
}
[hidden] {
display: none !important;
}
/*# sourceMappingURL=bootstrap-reboot.css.map */

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,594 @@
/*!
* Bootstrap Reboot v5.3.3 (https://getbootstrap.com/)
* Copyright 2011-2024 The Bootstrap Authors
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
:root,
[data-bs-theme=light] {
--bs-blue: #0d6efd;
--bs-indigo: #6610f2;
--bs-purple: #6f42c1;
--bs-pink: #d63384;
--bs-red: #dc3545;
--bs-orange: #fd7e14;
--bs-yellow: #ffc107;
--bs-green: #198754;
--bs-teal: #20c997;
--bs-cyan: #0dcaf0;
--bs-black: #000;
--bs-white: #fff;
--bs-gray: #6c757d;
--bs-gray-dark: #343a40;
--bs-gray-100: #f8f9fa;
--bs-gray-200: #e9ecef;
--bs-gray-300: #dee2e6;
--bs-gray-400: #ced4da;
--bs-gray-500: #adb5bd;
--bs-gray-600: #6c757d;
--bs-gray-700: #495057;
--bs-gray-800: #343a40;
--bs-gray-900: #212529;
--bs-primary: #0d6efd;
--bs-secondary: #6c757d;
--bs-success: #198754;
--bs-info: #0dcaf0;
--bs-warning: #ffc107;
--bs-danger: #dc3545;
--bs-light: #f8f9fa;
--bs-dark: #212529;
--bs-primary-rgb: 13, 110, 253;
--bs-secondary-rgb: 108, 117, 125;
--bs-success-rgb: 25, 135, 84;
--bs-info-rgb: 13, 202, 240;
--bs-warning-rgb: 255, 193, 7;
--bs-danger-rgb: 220, 53, 69;
--bs-light-rgb: 248, 249, 250;
--bs-dark-rgb: 33, 37, 41;
--bs-primary-text-emphasis: #052c65;
--bs-secondary-text-emphasis: #2b2f32;
--bs-success-text-emphasis: #0a3622;
--bs-info-text-emphasis: #055160;
--bs-warning-text-emphasis: #664d03;
--bs-danger-text-emphasis: #58151c;
--bs-light-text-emphasis: #495057;
--bs-dark-text-emphasis: #495057;
--bs-primary-bg-subtle: #cfe2ff;
--bs-secondary-bg-subtle: #e2e3e5;
--bs-success-bg-subtle: #d1e7dd;
--bs-info-bg-subtle: #cff4fc;
--bs-warning-bg-subtle: #fff3cd;
--bs-danger-bg-subtle: #f8d7da;
--bs-light-bg-subtle: #fcfcfd;
--bs-dark-bg-subtle: #ced4da;
--bs-primary-border-subtle: #9ec5fe;
--bs-secondary-border-subtle: #c4c8cb;
--bs-success-border-subtle: #a3cfbb;
--bs-info-border-subtle: #9eeaf9;
--bs-warning-border-subtle: #ffe69c;
--bs-danger-border-subtle: #f1aeb5;
--bs-light-border-subtle: #e9ecef;
--bs-dark-border-subtle: #adb5bd;
--bs-white-rgb: 255, 255, 255;
--bs-black-rgb: 0, 0, 0;
--bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
--bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));
--bs-body-font-family: var(--bs-font-sans-serif);
--bs-body-font-size: 1rem;
--bs-body-font-weight: 400;
--bs-body-line-height: 1.5;
--bs-body-color: #212529;
--bs-body-color-rgb: 33, 37, 41;
--bs-body-bg: #fff;
--bs-body-bg-rgb: 255, 255, 255;
--bs-emphasis-color: #000;
--bs-emphasis-color-rgb: 0, 0, 0;
--bs-secondary-color: rgba(33, 37, 41, 0.75);
--bs-secondary-color-rgb: 33, 37, 41;
--bs-secondary-bg: #e9ecef;
--bs-secondary-bg-rgb: 233, 236, 239;
--bs-tertiary-color: rgba(33, 37, 41, 0.5);
--bs-tertiary-color-rgb: 33, 37, 41;
--bs-tertiary-bg: #f8f9fa;
--bs-tertiary-bg-rgb: 248, 249, 250;
--bs-heading-color: inherit;
--bs-link-color: #0d6efd;
--bs-link-color-rgb: 13, 110, 253;
--bs-link-decoration: underline;
--bs-link-hover-color: #0a58ca;
--bs-link-hover-color-rgb: 10, 88, 202;
--bs-code-color: #d63384;
--bs-highlight-color: #212529;
--bs-highlight-bg: #fff3cd;
--bs-border-width: 1px;
--bs-border-style: solid;
--bs-border-color: #dee2e6;
--bs-border-color-translucent: rgba(0, 0, 0, 0.175);
--bs-border-radius: 0.375rem;
--bs-border-radius-sm: 0.25rem;
--bs-border-radius-lg: 0.5rem;
--bs-border-radius-xl: 1rem;
--bs-border-radius-xxl: 2rem;
--bs-border-radius-2xl: var(--bs-border-radius-xxl);
--bs-border-radius-pill: 50rem;
--bs-box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
--bs-box-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
--bs-box-shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
--bs-box-shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.075);
--bs-focus-ring-width: 0.25rem;
--bs-focus-ring-opacity: 0.25;
--bs-focus-ring-color: rgba(13, 110, 253, 0.25);
--bs-form-valid-color: #198754;
--bs-form-valid-border-color: #198754;
--bs-form-invalid-color: #dc3545;
--bs-form-invalid-border-color: #dc3545;
}
[data-bs-theme=dark] {
color-scheme: dark;
--bs-body-color: #dee2e6;
--bs-body-color-rgb: 222, 226, 230;
--bs-body-bg: #212529;
--bs-body-bg-rgb: 33, 37, 41;
--bs-emphasis-color: #fff;
--bs-emphasis-color-rgb: 255, 255, 255;
--bs-secondary-color: rgba(222, 226, 230, 0.75);
--bs-secondary-color-rgb: 222, 226, 230;
--bs-secondary-bg: #343a40;
--bs-secondary-bg-rgb: 52, 58, 64;
--bs-tertiary-color: rgba(222, 226, 230, 0.5);
--bs-tertiary-color-rgb: 222, 226, 230;
--bs-tertiary-bg: #2b3035;
--bs-tertiary-bg-rgb: 43, 48, 53;
--bs-primary-text-emphasis: #6ea8fe;
--bs-secondary-text-emphasis: #a7acb1;
--bs-success-text-emphasis: #75b798;
--bs-info-text-emphasis: #6edff6;
--bs-warning-text-emphasis: #ffda6a;
--bs-danger-text-emphasis: #ea868f;
--bs-light-text-emphasis: #f8f9fa;
--bs-dark-text-emphasis: #dee2e6;
--bs-primary-bg-subtle: #031633;
--bs-secondary-bg-subtle: #161719;
--bs-success-bg-subtle: #051b11;
--bs-info-bg-subtle: #032830;
--bs-warning-bg-subtle: #332701;
--bs-danger-bg-subtle: #2c0b0e;
--bs-light-bg-subtle: #343a40;
--bs-dark-bg-subtle: #1a1d20;
--bs-primary-border-subtle: #084298;
--bs-secondary-border-subtle: #41464b;
--bs-success-border-subtle: #0f5132;
--bs-info-border-subtle: #087990;
--bs-warning-border-subtle: #997404;
--bs-danger-border-subtle: #842029;
--bs-light-border-subtle: #495057;
--bs-dark-border-subtle: #343a40;
--bs-heading-color: inherit;
--bs-link-color: #6ea8fe;
--bs-link-hover-color: #8bb9fe;
--bs-link-color-rgb: 110, 168, 254;
--bs-link-hover-color-rgb: 139, 185, 254;
--bs-code-color: #e685b5;
--bs-highlight-color: #dee2e6;
--bs-highlight-bg: #664d03;
--bs-border-color: #495057;
--bs-border-color-translucent: rgba(255, 255, 255, 0.15);
--bs-form-valid-color: #75b798;
--bs-form-valid-border-color: #75b798;
--bs-form-invalid-color: #ea868f;
--bs-form-invalid-border-color: #ea868f;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
@media (prefers-reduced-motion: no-preference) {
:root {
scroll-behavior: smooth;
}
}
body {
margin: 0;
font-family: var(--bs-body-font-family);
font-size: var(--bs-body-font-size);
font-weight: var(--bs-body-font-weight);
line-height: var(--bs-body-line-height);
color: var(--bs-body-color);
text-align: var(--bs-body-text-align);
background-color: var(--bs-body-bg);
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
hr {
margin: 1rem 0;
color: inherit;
border: 0;
border-top: var(--bs-border-width) solid;
opacity: 0.25;
}
h6, h5, h4, h3, h2, h1 {
margin-top: 0;
margin-bottom: 0.5rem;
font-weight: 500;
line-height: 1.2;
color: var(--bs-heading-color);
}
h1 {
font-size: calc(1.375rem + 1.5vw);
}
@media (min-width: 1200px) {
h1 {
font-size: 2.5rem;
}
}
h2 {
font-size: calc(1.325rem + 0.9vw);
}
@media (min-width: 1200px) {
h2 {
font-size: 2rem;
}
}
h3 {
font-size: calc(1.3rem + 0.6vw);
}
@media (min-width: 1200px) {
h3 {
font-size: 1.75rem;
}
}
h4 {
font-size: calc(1.275rem + 0.3vw);
}
@media (min-width: 1200px) {
h4 {
font-size: 1.5rem;
}
}
h5 {
font-size: 1.25rem;
}
h6 {
font-size: 1rem;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
abbr[title] {
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
cursor: help;
-webkit-text-decoration-skip-ink: none;
text-decoration-skip-ink: none;
}
address {
margin-bottom: 1rem;
font-style: normal;
line-height: inherit;
}
ol,
ul {
padding-right: 2rem;
}
ol,
ul,
dl {
margin-top: 0;
margin-bottom: 1rem;
}
ol ol,
ul ul,
ol ul,
ul ol {
margin-bottom: 0;
}
dt {
font-weight: 700;
}
dd {
margin-bottom: 0.5rem;
margin-right: 0;
}
blockquote {
margin: 0 0 1rem;
}
b,
strong {
font-weight: bolder;
}
small {
font-size: 0.875em;
}
mark {
padding: 0.1875em;
color: var(--bs-highlight-color);
background-color: var(--bs-highlight-bg);
}
sub,
sup {
position: relative;
font-size: 0.75em;
line-height: 0;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
a {
color: rgba(var(--bs-link-color-rgb), var(--bs-link-opacity, 1));
text-decoration: underline;
}
a:hover {
--bs-link-color-rgb: var(--bs-link-hover-color-rgb);
}
a:not([href]):not([class]), a:not([href]):not([class]):hover {
color: inherit;
text-decoration: none;
}
pre,
code,
kbd,
samp {
font-family: var(--bs-font-monospace);
font-size: 1em;
}
pre {
display: block;
margin-top: 0;
margin-bottom: 1rem;
overflow: auto;
font-size: 0.875em;
}
pre code {
font-size: inherit;
color: inherit;
word-break: normal;
}
code {
font-size: 0.875em;
color: var(--bs-code-color);
word-wrap: break-word;
}
a > code {
color: inherit;
}
kbd {
padding: 0.1875rem 0.375rem;
font-size: 0.875em;
color: var(--bs-body-bg);
background-color: var(--bs-body-color);
border-radius: 0.25rem;
}
kbd kbd {
padding: 0;
font-size: 1em;
}
figure {
margin: 0 0 1rem;
}
img,
svg {
vertical-align: middle;
}
table {
caption-side: bottom;
border-collapse: collapse;
}
caption {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
color: var(--bs-secondary-color);
text-align: right;
}
th {
text-align: inherit;
text-align: -webkit-match-parent;
}
thead,
tbody,
tfoot,
tr,
td,
th {
border-color: inherit;
border-style: solid;
border-width: 0;
}
label {
display: inline-block;
}
button {
border-radius: 0;
}
button:focus:not(:focus-visible) {
outline: 0;
}
input,
button,
select,
optgroup,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button,
select {
text-transform: none;
}
[role=button] {
cursor: pointer;
}
select {
word-wrap: normal;
}
select:disabled {
opacity: 1;
}
[list]:not([type=date]):not([type=datetime-local]):not([type=month]):not([type=week]):not([type=time])::-webkit-calendar-picker-indicator {
display: none !important;
}
button,
[type=button],
[type=reset],
[type=submit] {
-webkit-appearance: button;
}
button:not(:disabled),
[type=button]:not(:disabled),
[type=reset]:not(:disabled),
[type=submit]:not(:disabled) {
cursor: pointer;
}
::-moz-focus-inner {
padding: 0;
border-style: none;
}
textarea {
resize: vertical;
}
fieldset {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
legend {
float: right;
width: 100%;
padding: 0;
margin-bottom: 0.5rem;
font-size: calc(1.275rem + 0.3vw);
line-height: inherit;
}
@media (min-width: 1200px) {
legend {
font-size: 1.5rem;
}
}
legend + * {
clear: right;
}
::-webkit-datetime-edit-fields-wrapper,
::-webkit-datetime-edit-text,
::-webkit-datetime-edit-minute,
::-webkit-datetime-edit-hour-field,
::-webkit-datetime-edit-day-field,
::-webkit-datetime-edit-month-field,
::-webkit-datetime-edit-year-field {
padding: 0;
}
::-webkit-inner-spin-button {
height: auto;
}
[type=search] {
-webkit-appearance: textfield;
outline-offset: -2px;
}
[type="tel"],
[type="url"],
[type="email"],
[type="number"] {
direction: ltr;
}
::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-color-swatch-wrapper {
padding: 0;
}
::-webkit-file-upload-button {
font: inherit;
-webkit-appearance: button;
}
::file-selector-button {
font: inherit;
-webkit-appearance: button;
}
output {
display: inline-block;
}
iframe {
border: 0;
}
summary {
display: list-item;
cursor: pointer;
}
progress {
vertical-align: baseline;
}
[hidden] {
display: none !important;
}
/*# sourceMappingURL=bootstrap-reboot.rtl.css.map */

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more