Skip to content

Commit db90ebf

Browse files
Merge pull request #428 from TransactionProcessing/bug/#427_transactioncompletedeventnullableobjecterror
Dont calculate fees for Verify Account transactions
2 parents 15b0f8c + c8a01c2 commit db90ebf

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,21 +142,25 @@ private async Task<TokenResponse> GetToken(CancellationToken cancellationToken)
142142
return this.TokenResponse;
143143
}
144144

145+
private Boolean RequireFeeCalculation(TransactionAggregate transactionAggregate){
146+
return transactionAggregate switch{
147+
_ when transactionAggregate.IsAuthorised == false => false,
148+
_ when transactionAggregate.IsCompleted == false => false,
149+
_ when transactionAggregate.TransactionType == TransactionType.Logon => false,
150+
_ when transactionAggregate.ContractId == Guid.Empty => false,
151+
_ when transactionAggregate.ProductId == Guid.Empty => false,
152+
_ when transactionAggregate.TransactionAmount == null => false,
153+
_ => true
154+
};
155+
}
156+
145157
private async Task HandleSpecificDomainEvent(TransactionHasBeenCompletedEvent domainEvent,
146158
CancellationToken cancellationToken) {
147159
TransactionAggregate transactionAggregate =
148160
await this.TransactionAggregateRepository.GetLatestVersion(domainEvent.TransactionId, cancellationToken);
149161

150-
if (transactionAggregate.IsAuthorised == false) {
151-
// Ignore not successful transactions
152-
return;
153-
}
154-
155-
if (transactionAggregate.IsCompleted == false || transactionAggregate.TransactionType == TransactionType.Logon ||
156-
(transactionAggregate.ContractId == Guid.Empty || transactionAggregate.ProductId == Guid.Empty)) {
157-
// These transactions cannot have fee values calculated so skip
162+
if (RequireFeeCalculation(transactionAggregate) == false)
158163
return;
159-
}
160164

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

0 commit comments

Comments
 (0)