Skip to content

Commit 0269a8b

Browse files
authored
feat(finance): add functionality to fetch and display recurring finan… (#131)
1 parent 167262b commit 0269a8b

File tree

8 files changed

+100
-46
lines changed

8 files changed

+100
-46
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ riderModule.iml
99
# Generated GraphQL schema (generated during build)
1010
frontend/schema.graphql
1111

12+
# Build output
13+
frontend/dist/
14+
1215
# Test Results
1316
TestResults/
1417
CoverageReport/

PhantomDave.BankTracking.Api/Services/FinanceRecordService.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ public FinanceRecordService(IUnitOfWork unitOfWork)
1919
public Task<FinanceRecord?> GetFinanceRecordAsync(int id) =>
2020
_unitOfWork.FinanceRecords.GetByIdAsync(id);
2121

22+
public async Task<IEnumerable<FinanceRecord>> GetRecurringFinanceRecordsAsync(int accountId) =>
23+
await _unitOfWork.FinanceRecords.Query()
24+
.AsNoTracking()
25+
.Where(record => record.IsRecurring &&
26+
record.AccountId == accountId &&
27+
(!record.RecurrenceEndDate.HasValue ||
28+
record.RecurrenceEndDate.Value >= DateTime.UtcNow))
29+
.OrderByDescending(record => record.Date)
30+
.ThenByDescending(record => record.Id)
31+
.ToListAsync();
32+
2233
public async Task<IEnumerable<FinanceRecord>> GetFinanceRecordsForAccountAsync(
2334
int accountId,
2435
DateTime? startDate = null,

PhantomDave.BankTracking.Api/Types/Queries/FinanceRecordQueries.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,21 @@ public async Task<IEnumerable<FinanceRecordType>> GetFinanceRecordsForAccount(
5858
return FinanceRecordType.FromFinanceRecord(financeRecord);
5959
}
6060

61+
/// <summary>
62+
/// Get all active recurring finance records for an account.
63+
/// Returns only recurring records that haven't expired or have no end date.
64+
/// </summary>
65+
[Authorize]
66+
public async Task<IEnumerable<FinanceRecordType>> GetRecurringFinanceRecords(
67+
[Service] FinanceRecordService financeRecordService,
68+
[Service] IHttpContextAccessor httpContextAccessor)
69+
{
70+
var accountId = httpContextAccessor.GetAccountIdFromContext();
71+
var records = await financeRecordService.GetRecurringFinanceRecordsAsync(accountId);
72+
73+
return records.Select(FinanceRecordType.FromFinanceRecord);
74+
}
75+
6176
/// <summary>
6277
/// Get monthly comparison statistics for an account
6378
/// </summary>

frontend/package-lock.json

Lines changed: 2 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/app/components/tracking/tracking/tracking.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
style="width: 100%"
1919
[title]="'Recurring Movements'"
2020
[loading]="loading()"
21-
[records]="records()"
21+
[records]="recurringRecords()"
2222
/>
2323
</app-flex>
2424
}

0 commit comments

Comments
 (0)