Some fixes to the queries and context records.

This commit is contained in:
2026-07-30 08:17:18 +02:00
parent acc8423fc6
commit f8b37815b0
15 changed files with 255 additions and 29 deletions
@@ -2,7 +2,6 @@ using FinancialApi.Application.Commands;
using FinancialApi.Application.Events;
using FinancialApi.Application.Interfaces;
using FinancialApi.Application.Models;
using FinancialApi.Domain;
using FinancialApi.Domain.Aggregates;
using FinancialApi.Domain.Entities;
using Wolverine.Persistence;
@@ -17,8 +16,19 @@ public static class ReverseJournalHandler
TimeProvider timeProvider
)
{
var data = await query.GetReversalDataAsync(cmd.OriginalJournalId);
return data ?? throw new InvalidOperationException($"Journal Entry {cmd.OriginalJournalId} does not exist");
var (journalEnty, accounts) = await query.GetReversalDataAsync(cmd.OriginalJournalId);
if (journalEnty == null)
{
throw new InvalidOperationException("Journal not found");
}
if (accounts == null)
{
throw new InvalidOperationException("Journal accounts not found");
}
return new JournalReversalContext(journalEnty, accounts, timeProvider.GetUtcNow()) ??
throw new InvalidOperationException($"Journal Entry {cmd.OriginalJournalId} does not exist");
}
public static ( IStorageAction<JournalEntry> JournalWrite, UnitOfWork<Account> AccountWrites, JournalReversedEvent