Improve testing and some cleanup refactoring.
This commit is contained in:
@@ -31,13 +31,10 @@ public static class ApplyFeeHandler
|
||||
{
|
||||
var updatedSource = context.Source.ApplyPosting(cmd.Amount, EntryType.Debit);
|
||||
var updatedRevenue = context.Destination.ApplyPosting(cmd.Amount, EntryType.Credit);
|
||||
var serviceFee = 0.5m;
|
||||
|
||||
var lines = new List<JournalLine>
|
||||
{
|
||||
new(updatedSource.Id, cmd.Amount, EntryType.Debit),
|
||||
new(updatedRevenue.Id, cmd.Amount - serviceFee, EntryType.Credit),
|
||||
new(updatedRevenue.Id, serviceFee, EntryType.Credit)
|
||||
new(updatedSource.Id, cmd.Amount, EntryType.Debit), new(updatedRevenue.Id, cmd.Amount, EntryType.Credit)
|
||||
};
|
||||
|
||||
var journalEntry = BalancedJournal.Create(
|
||||
|
||||
+6
-3
@@ -20,7 +20,10 @@ public static class TransferFundsHandler
|
||||
var source = await query.FindByIdAsync(cmd.SourceAccountId);
|
||||
var dest = await query.FindByIdAsync(cmd.DestinationAccountId);
|
||||
|
||||
if (source == null || dest == null) return null;
|
||||
if (source == null || dest == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new TransferContext(source, dest, timeProvider.GetUtcNow());
|
||||
}
|
||||
@@ -28,8 +31,8 @@ public static class TransferFundsHandler
|
||||
public static ( IStorageAction<Account> SourceWrite, IStorageAction<Account> DestWrite, IStorageAction<JournalEntry>
|
||||
JournalWrite, FundsTransferredEvent Event ) Handle(TransferFundsCommand cmd, TransferContext context)
|
||||
{
|
||||
var updatedSource = context.Source.Debit(cmd.Amount);
|
||||
var updatedDest = context.Destination.Credit(cmd.Amount);
|
||||
var updatedSource = context.Source.ApplyPosting(cmd.Amount, EntryType.Debit);
|
||||
var updatedDest = context.Destination.ApplyPosting(cmd.Amount, EntryType.Credit);
|
||||
|
||||
var lines = new List<JournalLine>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user