WIP
This commit is contained in:
1 parent
4281924ee5
commit
fc702adfcd
13 files changed
+69
-22
No files matched your search
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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.
Reference in new issue
Block a user