FIx
This commit is contained in:
1 parent
b6b794f0b4
commit
75d804b7ff
5 files changed
+14
-13
No files matched your search
@@ -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))
|
||||
|
||||
Reference in new issue
Block a user