Adding journal entries and database tables. Increased starting balances.

This commit is contained in:
2026-07-15 12:08:28 +02:00
parent 0de38ef2df
commit 656f545281
13 changed files with 498 additions and 34 deletions
@@ -28,16 +28,31 @@ public static class TransferFundsHandler
public static (
IStorageAction<Account> SourceWrite,
IStorageAction<Account> DestWrite,
IStorageAction<JournalEntry> JournalWrite,
FundsTransferredEvent Event
) Handle(TransferFundsCommand cmd, TransferPair pair)
{
var updatedSource = pair.Source.Debit(cmd.Amount);
var updatedDest = pair.Destination.Credit(cmd.Amount);
var sourcePersistence = Storage.Update(updatedSource);
var destPersistence = Storage.Update(updatedDest);
var lines = new List<JournalLine>
{
new (pair.Source.Id, cmd.Amount, EntryType.Debit),
new (pair.Destination.Id, cmd.Amount, EntryType.Credit)
};
var journalEntry =
BalancedJournal.Create(Guid.NewGuid(),
$"Transfer: {cmd.Amount} from {cmd.SourceAccountId} to {cmd.DestinationAccountId}",
DateTimeOffset.UtcNow, lines);
var @event = new FundsTransferredEvent(cmd.SourceAccountId, cmd.DestinationAccountId, cmd.Amount);
return (sourcePersistence, destPersistence, @event);
return (
Storage.Update(updatedSource),
Storage.Update(updatedDest),
Storage.Insert(journalEntry.Entry),
@event
);
}
}