Adjust location of classes further.
This commit is contained in:
+10
-7
@@ -1,14 +1,17 @@
|
||||
using FinancialApi.Application.Commands;
|
||||
using FinancialApi.Application.Events;
|
||||
using FinancialApi.Application.Queries;
|
||||
using FinancialApi.Application.Interfaces;
|
||||
using FinancialApi.Application.Models;
|
||||
using FinancialApi.Domain;
|
||||
using FinancialApi.Domain.Aggregates;
|
||||
using FinancialApi.Domain.Entities;
|
||||
using Wolverine.Persistence;
|
||||
|
||||
namespace FinancialApi.Application.Handlers;
|
||||
|
||||
public static class ApplyFeeHandler
|
||||
{
|
||||
public static async Task<FeePair> LoadAsync(
|
||||
public static async Task<FeeContext> LoadAsync(
|
||||
ApplyFeeCommand cmd,
|
||||
IAccountQuery query, TimeProvider timeProvider)
|
||||
{
|
||||
@@ -19,7 +22,7 @@ public static class ApplyFeeHandler
|
||||
throw new InvalidOperationException($"Cannot process transfer. Account(s) not found.");
|
||||
}
|
||||
|
||||
return new FeePair(source, dest, timeProvider.GetUtcNow());
|
||||
return new FeeContext(source, dest, timeProvider.GetUtcNow());
|
||||
}
|
||||
|
||||
public static (
|
||||
@@ -30,11 +33,11 @@ public static class ApplyFeeHandler
|
||||
)
|
||||
Handle(
|
||||
ApplyFeeCommand cmd,
|
||||
FeePair pair
|
||||
FeeContext context
|
||||
)
|
||||
{
|
||||
var updatedSource = pair.Source.ApplyPosting(cmd.Amount, EntryType.Debit);
|
||||
var updatedRevenue = pair.Destination.ApplyPosting(cmd.Amount, EntryType.Credit);
|
||||
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>
|
||||
@@ -46,7 +49,7 @@ public static class ApplyFeeHandler
|
||||
|
||||
var journalEntry = BalancedJournal.Create(Guid.NewGuid(),
|
||||
$"Service Fee Applied: {cmd.Amount} to Account {cmd.AccountId}",
|
||||
pair.TimeStamp, lines);
|
||||
context.TimeStamp, lines);
|
||||
|
||||
var @event = new FeeAppliedEvent(cmd.AccountId, cmd.Amount);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user