Creating a Journal Reversal handler.

This commit is contained in:
brianj committed 2026-07-15 17:29:02 +02:00
1 parent 0376b58a33
commit e109c1c695
7 files changed
+122 -6

No files matched your search

@@ -20,4 +20,13 @@ public record BalancedJournal
return new(new JournalEntry(id, description, createdAt, lines));
}
public static BalancedJournal CreateReversal(JournalEntry original, string reason, DateTimeOffset now)
{
var reversedLines = original.Lines.Select(l =>
l with { Type = l.Type == EntryType.Debit ? EntryType.Credit : EntryType.Debit })
.ToList();
return Create(Guid.NewGuid(), reason, now, reversedLines);
}
}
@@ -7,6 +7,10 @@ public record JournalEntry
public DateTimeOffset CreatedAt { get; init; }
public List<JournalLine> Lines { get; init; } = [];
internal JournalEntry()
{
}
internal JournalEntry(Guid id, string description, DateTimeOffset createdAt, List<JournalLine> lines)
{
Lines = lines;