Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,25 @@ private async Task<TokenResponse> GetToken(CancellationToken cancellationToken)
return this.TokenResponse;
}

private Boolean RequireFeeCalculation(TransactionAggregate transactionAggregate){
return transactionAggregate switch{
_ when transactionAggregate.IsAuthorised == false => false,
_ when transactionAggregate.IsCompleted == false => false,
_ when transactionAggregate.TransactionType == TransactionType.Logon => false,
_ when transactionAggregate.ContractId == Guid.Empty => false,
_ when transactionAggregate.ProductId == Guid.Empty => false,
_ when transactionAggregate.TransactionAmount == null => false,
_ => true
};
}

private async Task HandleSpecificDomainEvent(TransactionHasBeenCompletedEvent domainEvent,
CancellationToken cancellationToken) {
TransactionAggregate transactionAggregate =
await this.TransactionAggregateRepository.GetLatestVersion(domainEvent.TransactionId, cancellationToken);

if (transactionAggregate.IsAuthorised == false) {
// Ignore not successful transactions
return;
}

if (transactionAggregate.IsCompleted == false || transactionAggregate.TransactionType == TransactionType.Logon ||
(transactionAggregate.ContractId == Guid.Empty || transactionAggregate.ProductId == Guid.Empty)) {
// These transactions cannot have fee values calculated so skip
if (RequireFeeCalculation(transactionAggregate) == false)
return;
}

this.TokenResponse = await this.GetToken(cancellationToken);

Expand Down