Creating a Journal Reversal handler.

This commit is contained in:
2026-07-15 17:29:02 +02:00
parent 0376b58a33
commit e109c1c695
7 changed files with 122 additions and 6 deletions
@@ -8,9 +8,11 @@ public record ApplyFeeCommand(int AccountId, decimal Amount);
public record FeeAppliedEvent(int AccountId, decimal Amount);
public record FeePair(Account Source, Account Destination);
public static class ApplyFeeHandler
{
public static async Task<(Account, Account)> LoadAsync(
public static async Task<FeePair> LoadAsync(
ApplyFeeCommand cmd,
IAccountQuery query)
{
@@ -20,7 +22,7 @@ public static class ApplyFeeHandler
{
throw new InvalidOperationException($"Cannot process transfer. Account(s) not found.");
}
return (source, dest);
return new FeePair(source, dest);
}
public static (
@@ -31,12 +33,11 @@ public static class ApplyFeeHandler
)
Handle(
ApplyFeeCommand cmd,
Account source,
Account dest
FeePair pair
)
{
var updatedSource = source.ApplyPosting(cmd.Amount, EntryType.Debit);
var updatedRevenue = dest.ApplyPosting(cmd.Amount, EntryType.Credit);
var updatedSource = pair.Source.ApplyPosting(cmd.Amount, EntryType.Debit);
var updatedRevenue = pair.Destination.ApplyPosting(cmd.Amount, EntryType.Credit);
var lines = new List<JournalLine>
{
new(updatedSource.Id, cmd.Amount, EntryType.Debit),