WIP
This commit is contained in:
1 parent
4281924ee5
commit
fc702adfcd
13 files changed
+55
-8
No files matched your search
@@ -6,5 +6,6 @@ public enum RecurrenceType
|
|||||||
Daily,
|
Daily,
|
||||||
Weekly,
|
Weekly,
|
||||||
Monthly,
|
Monthly,
|
||||||
Yearly
|
Yearly,
|
||||||
|
FourWeekly
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,7 @@ public class Salary
|
|||||||
public string GetPaydaySummary() => RecurrenceType switch
|
public string GetPaydaySummary() => RecurrenceType switch
|
||||||
{
|
{
|
||||||
RecurrenceType.Weekly => $"Every week on {StartDate:dddd}",
|
RecurrenceType.Weekly => $"Every week on {StartDate:dddd}",
|
||||||
|
RecurrenceType.FourWeekly => $"Every 4 weeks on {StartDate:dddd}",
|
||||||
RecurrenceType.Monthly => $"Monthly on the {GetOrdinal(StartDate.Day)}",
|
RecurrenceType.Monthly => $"Monthly on the {GetOrdinal(StartDate.Day)}",
|
||||||
RecurrenceType.Yearly => $"Annually on {StartDate:MMMM d}",
|
RecurrenceType.Yearly => $"Annually on {StartDate:MMMM d}",
|
||||||
_ => RecurrenceType.ToString()
|
_ => RecurrenceType.ToString()
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ public class SalaryRepository(ApplicationDbContext db) : ISalaryRepository
|
|||||||
private static DateTime GetNextDate(DateTime from, Salary salary) => salary.RecurrenceType switch
|
private static DateTime GetNextDate(DateTime from, Salary salary) => salary.RecurrenceType switch
|
||||||
{
|
{
|
||||||
RecurrenceType.Weekly => from.AddDays(7),
|
RecurrenceType.Weekly => from.AddDays(7),
|
||||||
|
RecurrenceType.FourWeekly => from.AddDays(28),
|
||||||
RecurrenceType.Monthly => from.AddMonths(1),
|
RecurrenceType.Monthly => from.AddMonths(1),
|
||||||
RecurrenceType.Yearly => from.AddYears(1),
|
RecurrenceType.Yearly => from.AddYears(1),
|
||||||
_ => from.AddMonths(1)
|
_ => from.AddMonths(1)
|
||||||
|
|||||||
@@ -280,6 +280,7 @@ public class TransactionRepository(ApplicationDbContext db) : ITransactionReposi
|
|||||||
{
|
{
|
||||||
RecurrenceType.Daily => current.AddDays(1),
|
RecurrenceType.Daily => current.AddDays(1),
|
||||||
RecurrenceType.Weekly => current.AddDays(7),
|
RecurrenceType.Weekly => current.AddDays(7),
|
||||||
|
RecurrenceType.FourWeekly => current.AddDays(28),
|
||||||
RecurrenceType.Monthly => current.AddMonths(1),
|
RecurrenceType.Monthly => current.AddMonths(1),
|
||||||
RecurrenceType.Yearly => current.AddYears(1),
|
RecurrenceType.Yearly => current.AddYears(1),
|
||||||
_ => DateTime.MaxValue
|
_ => DateTime.MaxValue
|
||||||
|
|||||||
@@ -24,4 +24,10 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.3" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="budgetapp.db">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -110,6 +110,7 @@ else
|
|||||||
<option value="@RecurrenceType.None">None</option>
|
<option value="@RecurrenceType.None">None</option>
|
||||||
<option value="@RecurrenceType.Daily">Daily</option>
|
<option value="@RecurrenceType.Daily">Daily</option>
|
||||||
<option value="@RecurrenceType.Weekly">Weekly</option>
|
<option value="@RecurrenceType.Weekly">Weekly</option>
|
||||||
|
<option value="@RecurrenceType.FourWeekly">4 Weekly</option>
|
||||||
<option value="@RecurrenceType.Monthly">Monthly</option>
|
<option value="@RecurrenceType.Monthly">Monthly</option>
|
||||||
<option value="@RecurrenceType.Yearly">Yearly</option>
|
<option value="@RecurrenceType.Yearly">Yearly</option>
|
||||||
</InputSelect>
|
</InputSelect>
|
||||||
|
|||||||
@@ -287,9 +287,14 @@ public partial class Home
|
|||||||
|
|
||||||
private static string GetRecurrenceLabel(Transaction t)
|
private static string GetRecurrenceLabel(Transaction t)
|
||||||
{
|
{
|
||||||
if (t.RecurrenceType != RecurrenceType.None)
|
var type = t.RecurrenceType != RecurrenceType.None
|
||||||
return t.RecurrenceType.ToString();
|
? t.RecurrenceType
|
||||||
return t.ParentTransaction?.RecurrenceType.ToString() ?? "Recurring";
|
: (t.ParentTransaction?.RecurrenceType ?? RecurrenceType.None);
|
||||||
|
return type switch
|
||||||
|
{
|
||||||
|
RecurrenceType.FourWeekly => "4 Weekly",
|
||||||
|
_ => type.ToString()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ComputeProjectedBalances()
|
private void ComputeProjectedBalances()
|
||||||
@@ -342,7 +347,7 @@ public partial class Home
|
|||||||
if (_nextPayday is null) return;
|
if (_nextPayday is null) return;
|
||||||
|
|
||||||
var txnsToPayday = await TransactionService.GetTransactionsInRangeAsync(
|
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)
|
foreach (var account in _data.Accounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
<label class="form-label">Recurrence</label>
|
<label class="form-label">Recurrence</label>
|
||||||
<InputSelect @bind-Value="_formModel.RecurrenceType" class="form-select">
|
<InputSelect @bind-Value="_formModel.RecurrenceType" class="form-select">
|
||||||
<option value="@RecurrenceType.Weekly">Weekly</option>
|
<option value="@RecurrenceType.Weekly">Weekly</option>
|
||||||
|
<option value="@RecurrenceType.FourWeekly">4 Weekly</option>
|
||||||
<option value="@RecurrenceType.Monthly">Monthly</option>
|
<option value="@RecurrenceType.Monthly">Monthly</option>
|
||||||
<option value="@RecurrenceType.Yearly">Yearly</option>
|
<option value="@RecurrenceType.Yearly">Yearly</option>
|
||||||
</InputSelect>
|
</InputSelect>
|
||||||
@@ -192,6 +193,7 @@ else
|
|||||||
<label class="form-label">Recurrence</label>
|
<label class="form-label">Recurrence</label>
|
||||||
<InputSelect @bind-Value="_editFormModel.RecurrenceType" class="form-select">
|
<InputSelect @bind-Value="_editFormModel.RecurrenceType" class="form-select">
|
||||||
<option value="@RecurrenceType.Weekly">Weekly</option>
|
<option value="@RecurrenceType.Weekly">Weekly</option>
|
||||||
|
<option value="@RecurrenceType.FourWeekly">4 Weekly</option>
|
||||||
<option value="@RecurrenceType.Monthly">Monthly</option>
|
<option value="@RecurrenceType.Monthly">Monthly</option>
|
||||||
<option value="@RecurrenceType.Yearly">Yearly</option>
|
<option value="@RecurrenceType.Yearly">Yearly</option>
|
||||||
</InputSelect>
|
</InputSelect>
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
<option value="@RecurrenceType.None">None</option>
|
<option value="@RecurrenceType.None">None</option>
|
||||||
<option value="@RecurrenceType.Daily">Daily</option>
|
<option value="@RecurrenceType.Daily">Daily</option>
|
||||||
<option value="@RecurrenceType.Weekly">Weekly</option>
|
<option value="@RecurrenceType.Weekly">Weekly</option>
|
||||||
|
<option value="@RecurrenceType.FourWeekly">4 Weekly</option>
|
||||||
<option value="@RecurrenceType.Monthly">Monthly</option>
|
<option value="@RecurrenceType.Monthly">Monthly</option>
|
||||||
<option value="@RecurrenceType.Yearly">Yearly</option>
|
<option value="@RecurrenceType.Yearly">Yearly</option>
|
||||||
</InputSelect>
|
</InputSelect>
|
||||||
@@ -178,7 +179,14 @@ else
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<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)">
|
<tr class="row-clickable" @onclick="() => OpenEditModal(t)">
|
||||||
<td @onclick:stopPropagation="true">
|
<td @onclick:stopPropagation="true">
|
||||||
@@ -221,11 +229,11 @@ else
|
|||||||
<td class="d-none d-md-table-cell">
|
<td class="d-none d-md-table-cell">
|
||||||
@if (t.RecurrenceType != RecurrenceType.None)
|
@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)
|
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
|
else
|
||||||
{
|
{
|
||||||
@@ -237,6 +245,7 @@ else
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -26,6 +26,20 @@ public partial class Transactions
|
|||||||
.Take(_pageSize)
|
.Take(_pageSize)
|
||||||
.ToList();
|
.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 string _sortColumn = "date";
|
||||||
private bool _sortAscending = true;
|
private bool _sortAscending = true;
|
||||||
|
|
||||||
@@ -305,6 +319,12 @@ public partial class Transactions
|
|||||||
_bulkDeleteCount = 0;
|
_bulkDeleteCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetRecurrenceLabel(RecurrenceType type) => type switch
|
||||||
|
{
|
||||||
|
RecurrenceType.FourWeekly => "4 Weekly",
|
||||||
|
_ => type.ToString()
|
||||||
|
};
|
||||||
|
|
||||||
private async Task TogglePaid(Transaction t)
|
private async Task TogglePaid(Transaction t)
|
||||||
{
|
{
|
||||||
if (_userId is null) return;
|
if (_userId is null) return;
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user