Skip to content

Commit 9d90acf

Browse files
Remove obsolete TODOs and commented code; add AddFile method
Clean up codebase by deleting outdated TODO comments and commented-out code from tests and services. Remove unused statement methods from repository. Add AddFile method to ITransactionProcessorReadModelRepository for handling FileCreatedEvent.
1 parent e5f6ed8 commit 9d90acf

6 files changed

Lines changed: 1 addition & 119 deletions

File tree

TransactionProcessor.BusinessLogic.Tests/Manager/TransactionProcessorManagerTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public async Task TransactionProcessorManager_GetEstate_EstateIsReturned()
7979
estateModel.Name.ShouldBe(TestData.EstateModel.Name);
8080
estateModel.Operators.ShouldHaveSingleItem();
8181
estateModel.Operators.Single().OperatorId.ShouldBe(TestData.OperatorId);
82-
// TODO: add back in with operator aggregate
8382
estateModel.Operators.Single().Name.ShouldBe(TestData.OperatorName);
8483
estateModel.Operators.Single().IsDeleted.ShouldBeFalse();
8584
}

TransactionProcessor.BusinessLogic.Tests/Mediator/MediatorTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ public MediatorTests()
4343
this.Requests.Add(TestData.Commands.RecordTransactionCommand);
4444
this.Requests.Add(TestData.Commands.SendCustomerEmailReceiptCommand);
4545
this.Requests.Add(TestData.Commands.ResendTransactionReceiptCommand);
46-
// TODO: this needs the query handling function refactoring to use a repository not the context direct
47-
//this.Requests.Add(TestData.GetVoucherByVoucherCodeQuery);
48-
//this.Requests.Add(TestData.GetVoucherByTransactionIdQuery);
4946

5047
// Estate Commands and Queries
5148
this.Requests.Add(TestData.Commands.CreateEstateCommand);

TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ public async Task TransactionDomainService_RequireFeeCalculation_IsNotAuthorised
505505
transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, TransactionType.Sale, TestData.TransactionReference, new TransactionStartContext { EstateId = TestData.EstateId, MerchantId = TestData.MerchantId, DeviceIdentifier = TestData.DeviceIdentifier }, TestData.TransactionAmount);
506506
transactionAggregate.DeclineTransaction(TestData.OperatorId, "111", "SUCCESS", TransactionResponseCode.Success, "SUCCESS");
507507

508-
// TODO: maybe move this to an extension on aggregate
509508
var result = TransactionHelpers.RequireFeeCalculation(transactionAggregate);
510509
result.ShouldBeFalse();
511510
}

TransactionProcessor.BusinessLogic/Services/MerchantDomainService.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,6 @@ public async Task<Result> CreateMerchantUser(MerchantCommands.CreateMerchantUser
263263
if (stateResult.IsFailed)
264264
return stateResult;
265265

266-
// TODO: add a delete user here in case the aggregate add fails...
267-
268266
Result saveResult = await this.AggregateService.Save(merchantAggregate, cancellationToken);
269267
if (saveResult.IsFailed)
270268
return ResultHelpers.CreateFailure(saveResult);

TransactionProcessor.BusinessLogic/Services/MerchantStatementDomainService.cs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -258,50 +258,6 @@ static String EncodeTo64(String toEncode)
258258
return returnValue;
259259
}
260260

261-
/*public async Task<Result> BuildStatement(MerchantStatementCommands.BuildMerchantStatementCommand command,
262-
CancellationToken cancellationToken) {
263-
try {
264-
// Work out the next statement date
265-
Result<MerchantStatementAggregate> getMerchantStatementResult = await DomainServiceHelper.GetAggregateOrFailure(ct => this.AggregateService.GetLatest<MerchantStatementAggregate>(command.MerchantStatementId, ct), command.MerchantStatementId, cancellationToken);
266-
if (getMerchantStatementResult.IsFailed)
267-
return ResultHelpers.CreateFailure(getMerchantStatementResult);
268-
269-
MerchantStatementAggregate merchantStatementAggregate = getMerchantStatementResult.Data;
270-
MerchantStatement statement = merchantStatementAggregate.GetStatement();
271-
Result<MerchantAggregate> getMerchantResult = await DomainServiceHelper.GetAggregateOrFailure(ct => this.AggregateService.Get<MerchantAggregate>(statement.MerchantId, ct), statement.MerchantId, cancellationToken);
272-
if (getMerchantResult.IsFailed)
273-
return ResultHelpers.CreateFailure(getMerchantResult);
274-
275-
if (getMerchantResult.Data.IsCreated == false)
276-
return Result.Invalid("Merchant must be created to build a statement");
277-
278-
Merchant merchantModel = getMerchantResult.Data.GetMerchant();
279-
280-
if (merchantModel.Addresses.Any() == false)
281-
return Result.Invalid("Merchant must have an address to build a statement");
282-
283-
Result<String> htmlResult = await this.StatementBuilder.GetStatementHtml(merchantStatementAggregate, merchantModel, cancellationToken);
284-
if (htmlResult.IsFailed)
285-
return ResultHelpers.CreateFailure(htmlResult);
286-
287-
// TODO: Record the html to the statement aggregate so we can use it later if needed
288-
String base64 = EncodeTo64(htmlResult.Data);
289-
290-
Result stateResult = merchantStatementAggregate.BuildStatement(DateTime.Now, base64);
291-
if (stateResult.IsFailed)
292-
return ResultHelpers.CreateFailure(stateResult);
293-
294-
Result saveResult = await this.AggregateService.Save(merchantStatementAggregate, cancellationToken);
295-
if (saveResult.IsFailed)
296-
return ResultHelpers.CreateFailure(saveResult);
297-
298-
return Result.Success();
299-
}
300-
catch (Exception ex) {
301-
return Result.Failure(ex.GetExceptionMessages());
302-
}
303-
}*/
304-
305261
public async Task<Result> BuildStatement(MerchantStatementCommands.BuildMerchantStatementCommand command,
306262
CancellationToken cancellationToken)
307263
{

TransactionProcessor.Repository/ITransactionProcessorReadModelRepository.cs

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,39 +1874,6 @@ public async Task<Result> MarkStatementAsGenerated(StatementGeneratedEvent domai
18741874
return await context.SaveChangesAsync(cancellationToken);
18751875
}
18761876

1877-
// TODO@ Add this back in
1878-
//public async Task<Result> AddSettledFeeToStatement(SettledFeeAddedToStatementEvent domainEvent,
1879-
// CancellationToken cancellationToken)
1880-
//{
1881-
// EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken);
1882-
1883-
// // Find the corresponding transaction
1884-
// var getTransactionResult = await context.LoadTransaction(domainEvent, cancellationToken);
1885-
// if (getTransactionResult.IsFailed)
1886-
// return ResultHelpers.CreateFailure(getTransactionResult);
1887-
// var transaction = getTransactionResult.Data;
1888-
1889-
// Result<Operator> operatorResult = await context.LoadOperator(transaction.OperatorId, cancellationToken);
1890-
// if (operatorResult.IsFailed)
1891-
// return ResultHelpers.CreateFailure(operatorResult);
1892-
// var @operator = operatorResult.Data;
1893-
1894-
// StatementLine line = new StatementLine
1895-
// {
1896-
// StatementId = domainEvent.MerchantStatementId,
1897-
// ActivityDateTime = domainEvent.SettledDateTime,
1898-
// ActivityDate = domainEvent.SettledDateTime.Date,
1899-
// ActivityDescription = $"{@operator.Name} Transaction Fee",
1900-
// ActivityType = 2, // Transaction Fee
1901-
// TransactionId = domainEvent.TransactionId,
1902-
// InAmount = domainEvent.SettledValue
1903-
// };
1904-
1905-
// await context.StatementLines.AddAsync(line, cancellationToken);
1906-
1907-
// return await context.SaveChangesWithDuplicateHandling(cancellationToken);
1908-
//}
1909-
19101877
public async Task<Result> CreateStatement(StatementCreatedEvent domainEvent,
19111878
CancellationToken cancellationToken)
19121879
{
@@ -1924,41 +1891,7 @@ public async Task<Result> CreateStatement(StatementCreatedEvent domainEvent,
19241891

19251892
return await context.SaveChangesWithDuplicateHandling(cancellationToken);
19261893
}
1927-
1928-
// TODO@ Add this back in
1929-
//public async Task<Result> AddTransactionToStatement(TransactionAddedToStatementEvent domainEvent,
1930-
// CancellationToken cancellationToken)
1931-
//{
1932-
// EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken);
1933-
1934-
// // Find the corresponding transaction
1935-
// Result<Transaction> transactionResult = await context.LoadTransaction(domainEvent, cancellationToken);
1936-
// if (transactionResult.IsFailed)
1937-
// return ResultHelpers.CreateFailure(transactionResult);
1938-
1939-
// Transaction transaction = transactionResult.Data;
1940-
1941-
// Result<Operator> operatorResult = await context.LoadOperator(transaction.OperatorId, cancellationToken);
1942-
// if (operatorResult.IsFailed)
1943-
// return ResultHelpers.CreateFailure(operatorResult);
1944-
// Operator @operator = operatorResult.Data;
1945-
1946-
// StatementLine line = new StatementLine
1947-
// {
1948-
// StatementId = domainEvent.MerchantStatementId,
1949-
// ActivityDateTime = domainEvent.TransactionDateTime,
1950-
// ActivityDate = domainEvent.TransactionDateTime.Date,
1951-
// ActivityDescription = $"{@operator.Name} Transaction",
1952-
// ActivityType = 1, // Transaction
1953-
// TransactionId = domainEvent.TransactionId,
1954-
// OutAmount = domainEvent.TransactionValue
1955-
// };
1956-
1957-
// await context.StatementLines.AddAsync(line, cancellationToken);
1958-
1959-
// return await context.SaveChangesWithDuplicateHandling(cancellationToken);
1960-
//}
1961-
1894+
19621895
public async Task<Result> AddFile(FileCreatedEvent domainEvent,
19631896
CancellationToken cancellationToken)
19641897
{

0 commit comments

Comments
 (0)