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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user