Skip to content

Commit 18297aa

Browse files
Merge pull request #626 from TransactionProcessing/task/#623_record_datetime_in_transactionevents
Add the Transaction Date time to all the transaction/recon events
2 parents 0f446b1 + d46bf7f commit 18297aa

File tree

12 files changed

+102
-62
lines changed

12 files changed

+102
-62
lines changed

TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/VoucherDomainEventHandlerTests.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,13 @@ public async Task VoucherDomainEventHandler_VoucherIssuedEvent_WithEmailAddress_
7474
context.Transactions.Add(new EstateManagement.Database.Entities.Transaction()
7575
{
7676
TransactionId = TestData.TransactionId,
77-
MerchantReportingId = TestData.MerchantReportingId,
78-
ContractReportingId = TestData.ContractReportingId
77+
MerchantId = TestData.MerchantId,
78+
ContractId = TestData.ContractId
7979
});
8080
context.Contracts.Add(new Contract
8181
{
8282
ContractId = TestData.ContractId,
83-
ContractReportingId = TestData.ContractReportingId,
84-
EstateReportingId = TestData.EstateReportingId,
83+
EstateId = TestData.EstateId,
8584
Description = TestData.OperatorIdentifier
8685
});
8786
await context.SaveChangesAsync(CancellationToken.None);
@@ -124,14 +123,13 @@ public async Task VoucherDomainEventHandler_VoucherIssuedEvent_WithRecipientMobi
124123
context.Transactions.Add(new EstateManagement.Database.Entities.Transaction()
125124
{
126125
TransactionId = TestData.TransactionId,
127-
MerchantReportingId = TestData.MerchantReportingId,
128-
ContractReportingId = TestData.ContractReportingId
126+
MerchantId = TestData.MerchantId,
127+
ContractId = TestData.ContractId
129128
});
130129
context.Contracts.Add(new Contract
131130
{
132131
ContractId = TestData.ContractId,
133-
ContractReportingId = TestData.ContractReportingId,
134-
EstateReportingId = TestData.EstateReportingId,
132+
EstateId = TestData.EstateId,
135133
Description = TestData.OperatorIdentifier
136134
});
137135
await context.SaveChangesAsync(CancellationToken.None);

TransactionProcessor.BusinessLogic/EventHandling/VoucherDomainEventHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ private async Task<String> GetVoucherOperator(Models.Voucher voucherModel,
139139
EstateManagementGenericContext context = await this.DbContextFactory.GetContext(voucherModel.EstateId, ConnectionStringIdentifier, cancellationToken);
140140

141141
Transaction transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == voucherModel.TransactionId, cancellationToken);
142-
Contract contract = await context.Contracts.SingleOrDefaultAsync(c => c.ContractReportingId == transaction.ContractReportingId);
142+
Contract contract = await context.Contracts.SingleOrDefaultAsync(c => c.ContractId == transaction.ContractId, cancellationToken);
143143

144144
return contract.Description;
145145
}

TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="EstateManagement.Client" Version="2024.4.3-build103" />
9-
<PackageReference Include="EstateManagement.Database" Version="2024.4.3-build103" />
8+
<PackageReference Include="EstateManagement.Client" Version="2024.6.3-build111" />
9+
<PackageReference Include="EstateManagement.Database" Version="2024.6.3-build111" />
1010
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.3" />
1111
<PackageReference Include="MessagingService.Client" Version="2024.4.2" />
1212
<PackageReference Include="SecurityService.Client" Version="2024.4.2" />

TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="EstateManagement.Client" Version="2024.4.3-build103" />
11-
<PackageReference Include="EstateManagement.IntegrationTesting.Helpers" Version="2024.4.3-build103" />
10+
<PackageReference Include="EstateManagement.Client" Version="2024.6.3-build111" />
11+
<PackageReference Include="EstateManagement.IntegrationTesting.Helpers" Version="2024.6.3-build111" />
1212
<PackageReference Include="Reqnroll" Version="1.0.1" />
1313
</ItemGroup>
1414

TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<ItemGroup>
1010
<PackageReference Include="ClientProxyBase" Version="2024.4.3" />
1111
<PackageReference Include="Ductus.FluentDocker" Version="2.10.59" />
12-
<PackageReference Include="EstateManagement.Client" Version="2024.4.3-build103" />
13-
<PackageReference Include="EstateManagement.IntegrationTesting.Helpers" Version="2024.4.3-build103" />
12+
<PackageReference Include="EstateManagement.Client" Version="2024.6.3-build111" />
13+
<PackageReference Include="EstateManagement.IntegrationTesting.Helpers" Version="2024.6.3-build111" />
1414
<PackageReference Include="EventStoreProjections" Version="2023.12.3" />
1515
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
1616
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.3" />

TransactionProcessor.ProjectionEngine.Tests/TestData.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ public static SettledMerchantFeeAddedToTransactionEvent GetSettledMerchantFeeAdd
107107
TestData.FeeValue,
108108
TestData.FeeCalculatedDateTime,
109109
TestData.SettledDateTime,
110-
TestData.SettlementId);
110+
TestData.SettlementId,
111+
TestData.TransactionDateTime);
111112

112113
public static TransactionHasBeenCompletedEvent GetTransactionHasBeenCompletedEvent(Boolean? isAuthorised = true,
113114
Decimal? amount = null){
@@ -121,7 +122,8 @@ public static TransactionHasBeenCompletedEvent GetTransactionHasBeenCompletedEve
121122
TestData.ResponseMessage,
122123
isAuthorised.Value,
123124
TestData.TransactionDateTime,
124-
amount);
125+
amount,
126+
TestData.TransactionDateTime);
125127
}
126128

127129
public static TransactionHasStartedEvent GetTransactionHasStartedEvent(Decimal? amount = null, String type = null){

TransactionProcessor.ProjectionEngine/TransactionProcessor.ProjectionEngine.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="EstateManagement.Estate.DomainEvents" Version="2024.4.3-build99" />
11-
<PackageReference Include="EstateManagement.Merchant.DomainEvents" Version="2024.4.3-build99" />
10+
<PackageReference Include="EstateManagement.Estate.DomainEvents" Version="2024.6.3-build111" />
11+
<PackageReference Include="EstateManagement.Merchant.DomainEvents" Version="2024.6.3-build111" />
1212
<PackageReference Include="FileProcessor.File.DomainEvents" Version="2024.4.3-build56" />
1313
<PackageReference Include="FileProcessor.FileImportLog.DomainEvents" Version="2024.4.3-build56" />
1414

TransactionProcessor.Reconciliation.DomainEvents/ReconciliationAggregateDomainEvents.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,30 @@ public record OverallTotalsRecordedEvent(Guid TransactionId,
1010
Guid EstateId,
1111
Guid MerchantId,
1212
Int32 TransactionCount,
13-
Decimal TransactionValue) : DomainEvent(TransactionId, Guid.NewGuid());
13+
Decimal TransactionValue,
14+
DateTime TransactionDateTime) : DomainEvent(TransactionId, Guid.NewGuid());
1415

1516
[ExcludeFromCodeCoverage]
1617
public record ReconciliationHasBeenLocallyAuthorisedEvent(Guid TransactionId,
1718
Guid EstateId,
1819
Guid MerchantId,
1920
String ResponseCode,
20-
String ResponseMessage) : DomainEvent(TransactionId, Guid.NewGuid());
21+
String ResponseMessage,
22+
DateTime TransactionDateTime) : DomainEvent(TransactionId, Guid.NewGuid());
2123

2224
[ExcludeFromCodeCoverage]
2325
public record ReconciliationHasBeenLocallyDeclinedEvent(Guid TransactionId,
2426
Guid EstateId,
2527
Guid MerchantId,
2628
String ResponseCode,
27-
String ResponseMessage) : DomainEvent(TransactionId, Guid.NewGuid());
29+
String ResponseMessage,
30+
DateTime TransactionDateTime) : DomainEvent(TransactionId, Guid.NewGuid());
2831

2932
[ExcludeFromCodeCoverage]
3033
public record ReconciliationHasCompletedEvent(Guid TransactionId,
3134
Guid EstateId,
32-
Guid MerchantId) : DomainEvent(TransactionId, Guid.NewGuid());
35+
Guid MerchantId,
36+
DateTime TransactionDateTime) : DomainEvent(TransactionId, Guid.NewGuid());
3337

3438
[ExcludeFromCodeCoverage]
3539
public record ReconciliationHasStartedEvent(Guid TransactionId,

TransactionProcessor.ReconciliationAggregate/ReconciliationAggregate.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public static void PlayEvent(this ReconciliationAggregate aggregate, Reconciliat
1515
aggregate.EstateId = domainEvent.EstateId;
1616
aggregate.MerchantId = domainEvent.MerchantId;
1717
aggregate.IsStarted = true;
18+
aggregate.TransactionDateTime = domainEvent.TransactionDateTime;
1819
}
1920

2021
public static void PlayEvent(this ReconciliationAggregate aggregate, OverallTotalsRecordedEvent domainEvent)
@@ -91,7 +92,7 @@ public static void RecordOverallTotals(this ReconciliationAggregate aggregate, I
9192
aggregate.CheckReconciliationHasBeenStarted();
9293
aggregate.CheckReconciliationNotAlreadyCompleted();
9394

94-
OverallTotalsRecordedEvent overallTotalsRecordedEvent = new OverallTotalsRecordedEvent(aggregate.AggregateId, aggregate.EstateId, aggregate.MerchantId, totalCount, totalValue);
95+
OverallTotalsRecordedEvent overallTotalsRecordedEvent = new OverallTotalsRecordedEvent(aggregate.AggregateId, aggregate.EstateId, aggregate.MerchantId, totalCount, totalValue, aggregate.TransactionDateTime);
9596
aggregate.ApplyAndAppend(overallTotalsRecordedEvent);
9697
}
9798

@@ -103,7 +104,7 @@ public static void Authorise(this ReconciliationAggregate aggregate, String resp
103104
aggregate.CheckReconciliationNotAlreadyDeclined();
104105

105106
ReconciliationHasBeenLocallyAuthorisedEvent reconciliationHasBeenLocallyAuthorisedEvent = new ReconciliationHasBeenLocallyAuthorisedEvent(aggregate.AggregateId, aggregate.EstateId, aggregate.MerchantId,
106-
responseCode, responseMessage);
107+
responseCode, responseMessage, aggregate.TransactionDateTime);
107108

108109
aggregate.ApplyAndAppend(reconciliationHasBeenLocallyAuthorisedEvent);
109110
}
@@ -140,7 +141,7 @@ public static void Decline(this ReconciliationAggregate aggregate,String respons
140141
aggregate.CheckReconciliationNotAlreadyDeclined();
141142

142143
ReconciliationHasBeenLocallyDeclinedEvent reconciliationHasBeenLocallyDeclinedEvent = new ReconciliationHasBeenLocallyDeclinedEvent(aggregate.AggregateId, aggregate.EstateId, aggregate.MerchantId,
143-
responseCode, responseMessage);
144+
responseCode, responseMessage, aggregate.TransactionDateTime);
144145

145146
aggregate.ApplyAndAppend(reconciliationHasBeenLocallyDeclinedEvent);
146147
}
@@ -152,7 +153,7 @@ public static void CompleteReconciliation(this ReconciliationAggregate aggregate
152153
aggregate.CheckReconciliationHasBeenAuthorisedOrDeclined();
153154

154155
ReconciliationHasCompletedEvent reconciliationHasCompletedEvent =
155-
new ReconciliationHasCompletedEvent(aggregate.AggregateId, aggregate.EstateId, aggregate.MerchantId);
156+
new ReconciliationHasCompletedEvent(aggregate.AggregateId, aggregate.EstateId, aggregate.MerchantId, aggregate.TransactionDateTime);
156157

157158
aggregate.ApplyAndAppend(reconciliationHasCompletedEvent);
158159

@@ -208,6 +209,8 @@ private ReconciliationAggregate(Guid aggregateId)
208209

209210
public Decimal TransactionValue { get; internal set; }
210211

212+
public DateTime TransactionDateTime { get; internal set; }
213+
211214
public static ReconciliationAggregate Create(Guid aggregateId)
212215
{
213216
return new ReconciliationAggregate(aggregateId);

TransactionProcessor.Testing/TestData.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -997,10 +997,10 @@ public static TokenResponse TokenResponse()
997997
}
998998

999999
public static CustomerEmailReceiptRequestedEvent CustomerEmailReceiptRequestedEvent =
1000-
new CustomerEmailReceiptRequestedEvent(TestData.TransactionId, TestData.EstateId, TestData.MerchantId, TestData.CustomerEmailAddress);
1000+
new CustomerEmailReceiptRequestedEvent(TestData.TransactionId, TestData.EstateId, TestData.MerchantId, TestData.CustomerEmailAddress, TestData.TransactionDateTime);
10011001

10021002
public static CustomerEmailReceiptResendRequestedEvent CustomerEmailReceiptResendRequestedEvent =
1003-
new CustomerEmailReceiptResendRequestedEvent(TestData.TransactionId, TestData.EstateId, TestData.MerchantId);
1003+
new CustomerEmailReceiptResendRequestedEvent(TestData.TransactionId, TestData.EstateId, TestData.MerchantId, TestData.TransactionDateTime);
10041004

10051005
public static SettledMerchantFeeAddedToTransactionEvent SettledMerchantFeeAddedToTransactionEvent(DateTime settlementDueDate) => new SettledMerchantFeeAddedToTransactionEvent(TestData.SettlementAggregateId,
10061006
TestData.EstateId,
@@ -1011,7 +1011,8 @@ public static TokenResponse TokenResponse()
10111011
TestData.CalculatedFeeValue,
10121012
TestData.TransactionFeeCalculateDateTime,
10131013
TestData.SettlementDate,
1014-
TestData.SettlementAggregateId);
1014+
TestData.SettlementAggregateId,
1015+
TestData.TransactionDateTime);
10151016

10161017
public static TransactionHasBeenCompletedEvent TransactionHasBeenCompletedEvent = new TransactionHasBeenCompletedEvent(TestData.TransactionId,
10171018
TestData.EstateId,
@@ -1020,7 +1021,8 @@ public static TokenResponse TokenResponse()
10201021
TestData.ResponseMessage,
10211022
TestData.IsAuthorised,
10221023
TestData.TransactionDateTime,
1023-
TestData.TransactionAmount);
1024+
TestData.TransactionAmount,
1025+
TestData.TransactionDateTime);
10241026

10251027
public static Guid TransactionFeeId = Guid.Parse("B83FCCCE-0D45-4FC2-8952-ED277A124BDB");
10261028

@@ -1400,7 +1402,8 @@ public static SettlementAggregate GetSettlementAggregateWithNotAllFeesSettled(In
14001402
TestData.EstateId,
14011403
TestData.MerchantId,
14021404
TestData.UnitCostPrice,
1403-
TestData.TotalCostPrice);
1405+
TestData.TotalCostPrice,
1406+
TestData.TransactionDateTime);
14041407

14051408
public static RecordCreditPurchaseForFloatRequest RecordCreditPurchaseForFloatRequest => RecordCreditPurchaseForFloatRequest.Create(TestData.EstateId, TestData.FloatAggregateId, TestData.FloatCreditAmount, TestData.FloatCreditCostPrice, TestData.CreditPurchasedDateTime);
14061409

0 commit comments

Comments
 (0)