Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion EventStoreProjections/tests/MerchantBalanceAggregatorTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ test('Projection Can Handle Merchant Events',
var automaticDepositMadeEvent =
testData.getAutomaticDepositMadeEvent(estateId, merchantId, depositDateTime, depositAmount);

var withdrawalMadeEvent =
testData.getWithdrawalMadeEvent(estateId, merchantId, depositDateTime, depositAmount);

projection.processEvent(
'MerchantAggregate-' + merchantId.replace(/-/gi, ""),
merchantCreatedEvent.eventType,
Expand All @@ -39,8 +42,13 @@ test('Projection Can Handle Merchant Events',
automaticDepositMadeEvent.eventType,
automaticDepositMadeEvent.data);

projection.processEvent(
'MerchantAggregate-' + merchantId.replace(/-/gi, ""),
withdrawalMadeEvent.eventType,
withdrawalMadeEvent.data);

var events = projection.emittedEvents;
t.equal(events.length, 3);
t.equal(events.length, 4);
t.end();
});

Expand Down
16 changes: 16 additions & 0 deletions EventStoreProjections/tests/TestData.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,22 @@ module.exports = {
}
},

getWithdrawalMadeEvent: function (estateId, merchantId, withdrawalDateTime, withdrawalAmount) {
return {
eventType: 'WithdrawalMadeEvent',
data: {
"amount": withdrawalAmount,
"withdrawalDateTime": withdrawalDateTime,
"withdrawalId": "ff106578-8495-afe1-1e50-6889d76065a6",
"estateId": estateId,
"merchantId": merchantId
},
metadata: {
},
eventId: "4772BD21-BB70-4F46-9360-F9A6FE04C640"
}
},

getTransactionHasStartedEvent: function(estateId, merchantId, transactionId, transactionAmount, transactionType)
{
return {
Expand Down
2 changes: 1 addition & 1 deletion NugetPackage/obj/NugetPackage.csproj.nuget.dgspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.100-rc.2.22477.23\\RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.100\\RuntimeIdentifierGraph.json"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion NugetPackage/obj/NugetPackage.csproj.nuget.g.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\stuar\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.4.0</NuGetToolVersion>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.5.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\stuar\.nuget\packages\" />
Expand Down
2 changes: 1 addition & 1 deletion NugetPackage/obj/project.assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.100-rc.2.22477.23\\RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.100\\RuntimeIdentifierGraph.json"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion NugetPackage/obj/project.nuget.cache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 2,
"dgSpecHash": "zKSi6wid/WSnBVdoC/xTn5nYXu7whOdnAbYDX2c907cmEVYMfmCreIiWizMZeX0Heo5FKLmFLarJl29Q9A9qJg==",
"dgSpecHash": "7AutP7BXMcuvvQ1EOT2ftQPHtpFOmPoQR5NLE0CkKpPNqaySPU6lJwsWisU7bGIh/mPhalKYHsGOc3JHGhSVNw==",
"success": true,
"projectFilePath": "C:\\Projects\\TransactionProcessing\\EventStoreProjections\\NugetPackage\\NugetPackage.csproj",
"expectedPackageFiles": [],
Expand Down
26 changes: 18 additions & 8 deletions NugetPackage/projections/continuous/MerchantBalanceAggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,30 @@ getMerchantId = function (e) {
return e.data.merchantId;
};

isEventSupported = function (e) {
if (e.eventType == "MerchantCreatedEvent" ||
e.eventType === "ManualDepositMadeEvent" ||
e.eventType === "AutomaticDepositMadeEvent" ||
e.eventType === "TransactionHasStartedEvent" ||
e.eventType === "TransactionHasBeenCompletedEvent" ||
e.eventType === "MerchantFeeAddedToTransactionEvent" ||
e.eventType === "WithdrawalMadeEvent") {
return true;
}
return false;
}

fromAll()
.when({
$any: function (s, e) {
if (isValidEvent(e)) {
var merchantId = getMerchantId(e);
if (merchantId !== null) {
if (e.eventType == "MerchantCreatedEvent" ||
e.eventType === "ManualDepositMadeEvent" ||
e.eventType === "AutomaticDepositMadeEvent" ||
e.eventType === "TransactionHasStartedEvent" ||
e.eventType === "TransactionHasBeenCompletedEvent" ||
e.eventType === "MerchantFeeAddedToTransactionEvent") {
var streamName = "MerchantBalanceArchive-" + merchantId.replace(/-/gi, "");
linkTo(streamName, e);
{
if (isEventSupported(e)) {
var streamName = "MerchantBalanceArchive-" + merchantId.replace(/-/gi, "");
linkTo(streamName, e);
}
}
}
}
Expand Down