Creating a Journal Reversal handler.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user