This commit is contained in:
rossmill76 committed 2026-04-02 19:28:18 +01:00
1 parent 4281924ee5
commit fc702adfcd
13 files changed
+69 -22

No files matched your search

+2 -1
View File
@@ -6,5 +6,6 @@ public enum RecurrenceType
Daily,
Weekly,
Monthly,
Yearly
Yearly,
FourWeekly
}
+5 -4
View File
@@ -27,10 +27,11 @@ public class Salary
public string GetPaydaySummary() => RecurrenceType switch
{
RecurrenceType.Weekly => $"Every week on {StartDate:dddd}",
RecurrenceType.Monthly => $"Monthly on the {GetOrdinal(StartDate.Day)}",
RecurrenceType.Yearly => $"Annually on {StartDate:MMMM d}",
_ => RecurrenceType.ToString()
RecurrenceType.Weekly => $"Every week on {StartDate:dddd}",
RecurrenceType.FourWeekly => $"Every 4 weeks on {StartDate:dddd}",
RecurrenceType.Monthly => $"Monthly on the {GetOrdinal(StartDate.Day)}",
RecurrenceType.Yearly => $"Annually on {StartDate:MMMM d}",
_ => RecurrenceType.ToString()
};
private static string GetOrdinal(int day) => day switch
@@ -129,9 +129,10 @@ public class SalaryRepository(ApplicationDbContext db) : ISalaryRepository
private static DateTime GetNextDate(DateTime from, Salary salary) => salary.RecurrenceType switch
{
RecurrenceType.Weekly => from.AddDays(7),
RecurrenceType.Monthly => from.AddMonths(1),
RecurrenceType.Yearly => from.AddYears(1),
_ => from.AddMonths(1)
RecurrenceType.Weekly => from.AddDays(7),
RecurrenceType.FourWeekly => from.AddDays(28),
RecurrenceType.Monthly => from.AddMonths(1),
RecurrenceType.Yearly => from.AddYears(1),
_ => from.AddMonths(1)
};
}
@@ -278,10 +278,11 @@ public class TransactionRepository(ApplicationDbContext db) : ITransactionReposi
internal static DateTime GetNextOccurrence(DateTime current, RecurrenceType recurrence) => recurrence switch
{
RecurrenceType.Daily => current.AddDays(1),
RecurrenceType.Weekly => current.AddDays(7),
RecurrenceType.Monthly => current.AddMonths(1),
RecurrenceType.Yearly => current.AddYears(1),
_ => DateTime.MaxValue
RecurrenceType.Daily => current.AddDays(1),
RecurrenceType.Weekly => current.AddDays(7),
RecurrenceType.FourWeekly => current.AddDays(28),
RecurrenceType.Monthly => current.AddMonths(1),
RecurrenceType.Yearly => current.AddYears(1),
_ => DateTime.MaxValue
};
}
+6
View File
@@ -24,4 +24,10 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.3" />
</ItemGroup>
<ItemGroup>
<None Update="budgetapp.db">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
+1
View File
@@ -110,6 +110,7 @@ else
<option value="@RecurrenceType.None">None</option>
<option value="@RecurrenceType.Daily">Daily</option>
<option value="@RecurrenceType.Weekly">Weekly</option>
<option value="@RecurrenceType.FourWeekly">4 Weekly</option>
<option value="@RecurrenceType.Monthly">Monthly</option>
<option value="@RecurrenceType.Yearly">Yearly</option>
</InputSelect>
+9 -4
View File
@@ -287,9 +287,14 @@ public partial class Home
private static string GetRecurrenceLabel(Transaction t)
{
if (t.RecurrenceType != RecurrenceType.None)
return t.RecurrenceType.ToString();
return t.ParentTransaction?.RecurrenceType.ToString() ?? "Recurring";
var type = t.RecurrenceType != RecurrenceType.None
? t.RecurrenceType
: (t.ParentTransaction?.RecurrenceType ?? RecurrenceType.None);
return type switch
{
RecurrenceType.FourWeekly => "4 Weekly",
_ => type.ToString()
};
}
private void ComputeProjectedBalances()
@@ -342,7 +347,7 @@ public partial class Home
if (_nextPayday is null) return;
var txnsToPayday = await TransactionService.GetTransactionsInRangeAsync(
_userId, DateTime.Today.AddDays(1), _nextPayday.Value);
_userId, DateTime.Today.AddDays(1), _nextPayday.Value.AddDays(-1));
foreach (var account in _data.Accounts)
{
+2
View File
@@ -51,6 +51,7 @@
<label class="form-label">Recurrence</label>
<InputSelect @bind-Value="_formModel.RecurrenceType" class="form-select">
<option value="@RecurrenceType.Weekly">Weekly</option>
<option value="@RecurrenceType.FourWeekly">4 Weekly</option>
<option value="@RecurrenceType.Monthly">Monthly</option>
<option value="@RecurrenceType.Yearly">Yearly</option>
</InputSelect>
@@ -192,6 +193,7 @@ else
<label class="form-label">Recurrence</label>
<InputSelect @bind-Value="_editFormModel.RecurrenceType" class="form-select">
<option value="@RecurrenceType.Weekly">Weekly</option>
<option value="@RecurrenceType.FourWeekly">4 Weekly</option>
<option value="@RecurrenceType.Monthly">Monthly</option>
<option value="@RecurrenceType.Yearly">Yearly</option>
</InputSelect>
+13 -4
View File
@@ -80,6 +80,7 @@
<option value="@RecurrenceType.None">None</option>
<option value="@RecurrenceType.Daily">Daily</option>
<option value="@RecurrenceType.Weekly">Weekly</option>
<option value="@RecurrenceType.FourWeekly">4 Weekly</option>
<option value="@RecurrenceType.Monthly">Monthly</option>
<option value="@RecurrenceType.Yearly">Yearly</option>
</InputSelect>
@@ -178,8 +179,15 @@ else
</tr>
</thead>
<tbody>
@foreach (var t in PagedTransactions)
@foreach (var group in GroupedPagedTransactions)
{
<tr>
<td colspan="7" class="py-1 px-3 table-light" style="font-size: 0.78rem;">
<span class="text-muted fw-semibold">@group.Key.ToString("dddd, d MMMM")</span>
</td>
</tr>
@foreach (var t in OrderGroupByIncomeFirst(group))
{
<tr class="row-clickable" @onclick="() => OpenEditModal(t)">
<td @onclick:stopPropagation="true">
@if (t.SalaryId is null)
@@ -221,11 +229,11 @@ else
<td class="d-none d-md-table-cell">
@if (t.RecurrenceType != RecurrenceType.None)
{
<span class="badge bg-info">🔁 @t.RecurrenceType</span>
<span class="badge bg-info">🔁 @GetRecurrenceLabel(t.RecurrenceType)</span>
}
else if (t.ParentTransactionId is not null)
{
<span class="badge bg-info">🔁 @(t.ParentTransaction?.RecurrenceType.ToString() ?? "Recurring")</span>
<span class="badge bg-info">🔁 @GetRecurrenceLabel(t.ParentTransaction?.RecurrenceType ?? RecurrenceType.None)</span>
}
else
{
@@ -236,7 +244,8 @@ else
@(t.Type == TransactionType.Income ? "+" : "-")@t.Account.FormatAmount(t.Amount)
</td>
</tr>
}
}
}
</tbody>
</table>
</div>
@@ -26,6 +26,20 @@ public partial class Transactions
.Take(_pageSize)
.ToList();
private IEnumerable<IGrouping<DateTime, Transaction>> GroupedPagedTransactions
{
get
{
var groups = PagedTransactions.GroupBy(t => t.Date.Date);
return _sortColumn == "date" && _sortAscending
? groups.OrderBy(g => g.Key)
: groups.OrderByDescending(g => g.Key);
}
}
private static IEnumerable<Transaction> OrderGroupByIncomeFirst(IGrouping<DateTime, Transaction> group) =>
group.OrderByDescending(t => t.Type == TransactionType.Income).ThenBy(t => t.Description);
private string _sortColumn = "date";
private bool _sortAscending = true;
@@ -305,6 +319,12 @@ public partial class Transactions
_bulkDeleteCount = 0;
}
private static string GetRecurrenceLabel(RecurrenceType type) => type switch
{
RecurrenceType.FourWeekly => "4 Weekly",
_ => type.ToString()
};
private async Task TogglePaid(Transaction t)
{
if (_userId is null) return;
Binary file not shown.
Binary file not shown.
Binary file not shown.