From 75d804b7ffb213353c5ff34376a582c1688b3f2e Mon Sep 17 00:00:00 2001 From: Ross Miller Date: Fri, 6 Mar 2026 11:24:20 +0000 Subject: [PATCH] FIx --- BudgetApp/Components/Pages/Accounts.razor.cs | 2 +- BudgetApp/Services/DashboardService.cs | 18 ++++++------------ BudgetApp/budgetapp.db-shm | Bin 32768 -> 32768 bytes BudgetApp/budgetapp.db-wal | Bin 41232 -> 49472 bytes Dockerfile | 7 +++++++ 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/BudgetApp/Components/Pages/Accounts.razor.cs b/BudgetApp/Components/Pages/Accounts.razor.cs index 749179a..a6c5686 100644 --- a/BudgetApp/Components/Pages/Accounts.razor.cs +++ b/BudgetApp/Components/Pages/Accounts.razor.cs @@ -1,4 +1,3 @@ - using BudgetApp.Data.Entities; namespace BudgetApp.Components.Pages; @@ -133,4 +132,5 @@ public partial class Accounts [System.ComponentModel.DataAnnotations.MaxLength(3)] public string CurrencyCode { get; set; } = "GBP"; } + } \ No newline at end of file diff --git a/BudgetApp/Services/DashboardService.cs b/BudgetApp/Services/DashboardService.cs index 8ade703..5bb0382 100644 --- a/BudgetApp/Services/DashboardService.cs +++ b/BudgetApp/Services/DashboardService.cs @@ -76,22 +76,16 @@ public class DashboardService(ITransactionRepository transactionRepository, IAcc if (startDate.Date <= today) { - foreach (var t in accountTransactions - .Where(t => t.Date.Date >= startDate.Date && t.Date.Date <= today) - .OrderByDescending(t => t.Date)) - { - runningBalance -= t.Type == TransactionType.Income ? t.Amount : -t.Amount; - } + runningBalance = accountTransactions.Where(t => t.Date.Date >= startDate.Date && t.Date.Date <= today) + .OrderByDescending(t => t.Date) + .Aggregate(runningBalance, (current, t) => current - (t.Type == TransactionType.Income ? t.Amount : -t.Amount)); } else { // Future-only window: project forward from CurrentBalance using only unpaid transactions - foreach (var t in accountTransactions - .Where(t => t.Date.Date > today && t.Date.Date < startDate.Date && !t.IsPaid) - .OrderBy(t => t.Date)) - { - runningBalance += t.Type == TransactionType.Income ? t.Amount : -t.Amount; - } + runningBalance += accountTransactions.Where(t => t.Date.Date > today && t.Date.Date < startDate.Date && !t.IsPaid) + .OrderBy(t => t.Date) + .Sum(t => t.Type == TransactionType.Income ? t.Amount : -t.Amount); } for (var d = startDate; d <= endDate; d = d.AddDays(1)) diff --git a/BudgetApp/budgetapp.db-shm b/BudgetApp/budgetapp.db-shm index 8b03f4d7d294b26dd19eaea4b68a597459c4a185..3d42b32354f62425d6779755ece45d979afc10ad 100644 GIT binary patch delta 159 zcmZo@U}|V!s+V}A%K!pQK+MR%Aix8pHGw#B)!qBT6RYQ&Fo*ouKhe-Z=;NZhC%is> sAXPokC@=t-`yUBFg_#(*CN}C%T)?q$gNy6rKdvIo+zdP$H@>w50HbC!*Z=?k delta 155 zcmZo@U}|V!s+V}A%K!pQK+MR%AixErHGz1+;{5yB2ZElMFo*ouKhe{@S2~`(8|!j%G5&7)WY1@#A5Qt2@>pg aS0&D`o+!Mz!QeH&D5|`nwt<0_fdK%H&>9T@ delta 9 QcmX@m#5~~;(*}Ws02J{9`v3p{ diff --git a/Dockerfile b/Dockerfile index 5237ce2..279bdaa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,9 +5,16 @@ EXPOSE 8080 FROM mcr.microsoft.com/dotnet/sdk:10.0-preview AS build WORKDIR /src + +# Copy project files first so the restore layer is cached independently of source changes +COPY BudgetApp.Data/BudgetApp.Data.csproj BudgetApp.Data/ COPY BudgetApp/BudgetApp.csproj BudgetApp/ RUN dotnet restore BudgetApp/BudgetApp.csproj + +# Copy all source (BudgetApp.Data must be present before building BudgetApp) +COPY BudgetApp.Data/ BudgetApp.Data/ COPY BudgetApp/ BudgetApp/ + WORKDIR /src/BudgetApp RUN dotnet publish -c Release -o /app/publish