From b0f67760d799ded54d5bf1fdc9dff136428436cb Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Sat, 22 Jan 2022 04:24:26 +0000 Subject: [PATCH] latest projection crime --- .../Services/SettlementDomainService.cs | 1 + .../Settlement/Settlement.feature | 34 +++++++++--------- .../Settlement/Settlement.feature.cs | 36 +++++++++---------- .../Shared/SharedSteps.cs | 27 ++------------ .../continuous/TransactionEnricher.js | 4 +-- ...ctionProcessorSubscriptionStreamBuilder.js | 1 + 6 files changed, 42 insertions(+), 61 deletions(-) diff --git a/TransactionProcessor.BusinessLogic/Services/SettlementDomainService.cs b/TransactionProcessor.BusinessLogic/Services/SettlementDomainService.cs index 76c9190f..49cd79e3 100644 --- a/TransactionProcessor.BusinessLogic/Services/SettlementDomainService.cs +++ b/TransactionProcessor.BusinessLogic/Services/SettlementDomainService.cs @@ -28,6 +28,7 @@ public async Task ProcessSettlement(DateTime settleme if (settlementAggregate.IsCreated == false) { + Logger.LogInformation($"No pending settlement for {settlementDate.ToString("yyyy-MM-dd")}"); // Not pending settlement for this date return response; } diff --git a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature index 1c5186c4..93644c1e 100644 --- a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature +++ b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature @@ -76,14 +76,14 @@ Scenario: Get Pending Settlement When I perform the following transactions | DateTime | TransactionNumber | TransactionType | MerchantName | DeviceIdentifier | EstateName | OperatorName | TransactionAmount | CustomerAccountNumber | CustomerEmailAddress | ContractDescription | ProductName | RecipientEmail | RecipientMobile | - | Today | 1 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Safaricom | 100.00 | 123456789 | | Safaricom Contract | Variable Topup | | | - | Today | 2 | Sale | Test Merchant 2 | 123456781 | Test Estate 1 | Safaricom | 100.00 | 123456789 | | Safaricom Contract | Variable Topup | | | - | Today | 3 | Sale | Test Merchant 3 | 123456782 | Test Estate 1 | Safaricom | 100.00 | 123456789 | | Safaricom Contract | Variable Topup | | | - | Today | 4 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Safaricom | 100.00 | 123456789 | testcustomer@customer.co.uk | Safaricom Contract | Variable Topup | | | - | Today | 5 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Voucher | 10.00 | | | Hospital 1 Contract | 10 KES | test@recipient.co.uk | | - | Today | 6 | Sale | Test Merchant 2 | 123456781 | Test Estate 1 | Voucher | 10.00 | | | Hospital 1 Contract | 10 KES | | 123456789 | - | Today | 7 | Sale | Test Merchant 3 | 123456782 | Test Estate 1 | Voucher | 10.00 | | | Hospital 1 Contract | 10 KES | test@recipient.co.uk | | - | Today | 8 | Sale | Test Merchant 3 | 123456782 | Test Estate 1 | Voucher | 10.00 | | | Hospital 1 Contract | 10 KES | test@recipient.co.uk | | + | 2022-01-06 | 1 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Safaricom | 100.00 | 123456789 | | Safaricom Contract | Variable Topup | | | + | 2022-01-06 | 2 | Sale | Test Merchant 2 | 123456781 | Test Estate 1 | Safaricom | 100.00 | 123456789 | | Safaricom Contract | Variable Topup | | | + | 2022-01-06 | 3 | Sale | Test Merchant 3 | 123456782 | Test Estate 1 | Safaricom | 100.00 | 123456789 | | Safaricom Contract | Variable Topup | | | + | 2022-01-06 | 4 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Safaricom | 100.00 | 123456789 | testcustomer@customer.co.uk | Safaricom Contract | Variable Topup | | | + | 2022-01-06 | 5 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Voucher | 10.00 | | | Hospital 1 Contract | 10 KES | test@recipient.co.uk | | + | 2022-01-06 | 6 | Sale | Test Merchant 2 | 123456781 | Test Estate 1 | Voucher | 10.00 | | | Hospital 1 Contract | 10 KES | | 123456789 | + | 2022-01-06 | 7 | Sale | Test Merchant 3 | 123456782 | Test Estate 1 | Voucher | 10.00 | | | Hospital 1 Contract | 10 KES | test@recipient.co.uk | | + | 2022-01-06 | 8 | Sale | Test Merchant 3 | 123456782 | Test Estate 1 | Voucher | 10.00 | | | Hospital 1 Contract | 10 KES | test@recipient.co.uk | | Then transaction response should contain the following information | EstateName | MerchantName | TransactionNumber | ResponseCode | ResponseMessage | @@ -98,8 +98,8 @@ Scenario: Get Pending Settlement When I get the pending settlements the following information should be returned | SettlementDate | EstateName | NumberOfFees | - | NextWeek | Test Estate 1 | 1 | - | NextMonth | Test Estate 1 | 1 | + | 2022-01-13 | Test Estate 1 | 1 | + | 2022-02-06 | Test Estate 1 | 1 | @PRTest Scenario: Process Settlement @@ -127,11 +127,11 @@ Scenario: Process Settlement When I perform the following transactions | DateTime | TransactionNumber | TransactionType | MerchantName | DeviceIdentifier | EstateName | OperatorName | TransactionAmount | CustomerAccountNumber | CustomerEmailAddress | ContractDescription | ProductName | RecipientEmail | RecipientMobile | - | LastWeek | 1 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Safaricom | 100.00 | 123456789 | | Safaricom Contract | Variable Topup | | | - | LastWeek | 2 | Sale | Test Merchant 2 | 123456781 | Test Estate 1 | Safaricom | 100.00 | 123456789 | | Safaricom Contract | Variable Topup | | | - | LastWeek | 4 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Safaricom | 100.00 | 123456789 | testcustomer@customer.co.uk | Safaricom Contract | Variable Topup | | | - | LastWeek | 5 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Voucher | 10.00 | | | Hospital 1 Contract | 10 KES | test@recipient.co.uk | | - | LastWeek | 6 | Sale | Test Merchant 2 | 123456781 | Test Estate 1 | Voucher | 10.00 | | | Hospital 1 Contract | 10 KES | | 123456789 | + | 2022-01-06 | 1 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Safaricom | 100.00 | 123456789 | | Safaricom Contract | Variable Topup | | | + | 2022-01-06 | 2 | Sale | Test Merchant 2 | 123456781 | Test Estate 1 | Safaricom | 100.00 | 123456789 | | Safaricom Contract | Variable Topup | | | + | 2022-01-06 | 4 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Safaricom | 100.00 | 123456789 | testcustomer@customer.co.uk | Safaricom Contract | Variable Topup | | | + | 2022-01-06 | 5 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Voucher | 10.00 | | | Hospital 1 Contract | 10 KES | test@recipient.co.uk | | + | 2022-01-06 | 6 | Sale | Test Merchant 2 | 123456781 | Test Estate 1 | Voucher | 10.00 | | | Hospital 1 Contract | 10 KES | | 123456789 | Then transaction response should contain the following information | EstateName | MerchantName | TransactionNumber | ResponseCode | ResponseMessage | @@ -143,8 +143,8 @@ Scenario: Process Settlement When I get the pending settlements the following information should be returned | SettlementDate | EstateName | NumberOfFees | - | Today | Test Estate 1 | 1 | + | 2022-01-13 | Test Estate 1 | 1 | - When I process the settlement for 'Today' on Estate 'Test Estate 1' then 1 fees are marked as settled and the settlement is completed + When I process the settlement for '2022-01-13' on Estate 'Test Estate 1' then 1 fees are marked as settled and the settlement is completed diff --git a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs index c852de07..cfe77d5d 100644 --- a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs +++ b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs @@ -425,7 +425,7 @@ public virtual void GetPendingSettlement() "RecipientEmail", "RecipientMobile"}); table75.AddRow(new string[] { - "Today", + "2022-01-06", "1", "Sale", "Test Merchant 1", @@ -440,7 +440,7 @@ public virtual void GetPendingSettlement() "", ""}); table75.AddRow(new string[] { - "Today", + "2022-01-06", "2", "Sale", "Test Merchant 2", @@ -455,7 +455,7 @@ public virtual void GetPendingSettlement() "", ""}); table75.AddRow(new string[] { - "Today", + "2022-01-06", "3", "Sale", "Test Merchant 3", @@ -470,7 +470,7 @@ public virtual void GetPendingSettlement() "", ""}); table75.AddRow(new string[] { - "Today", + "2022-01-06", "4", "Sale", "Test Merchant 1", @@ -485,7 +485,7 @@ public virtual void GetPendingSettlement() "", ""}); table75.AddRow(new string[] { - "Today", + "2022-01-06", "5", "Sale", "Test Merchant 1", @@ -500,7 +500,7 @@ public virtual void GetPendingSettlement() "test@recipient.co.uk", ""}); table75.AddRow(new string[] { - "Today", + "2022-01-06", "6", "Sale", "Test Merchant 2", @@ -515,7 +515,7 @@ public virtual void GetPendingSettlement() "", "123456789"}); table75.AddRow(new string[] { - "Today", + "2022-01-06", "7", "Sale", "Test Merchant 3", @@ -530,7 +530,7 @@ public virtual void GetPendingSettlement() "test@recipient.co.uk", ""}); table75.AddRow(new string[] { - "Today", + "2022-01-06", "8", "Sale", "Test Merchant 3", @@ -609,11 +609,11 @@ public virtual void GetPendingSettlement() "EstateName", "NumberOfFees"}); table77.AddRow(new string[] { - "NextWeek", + "2022-01-13", "Test Estate 1", "1"}); table77.AddRow(new string[] { - "NextMonth", + "2022-02-06", "Test Estate 1", "1"}); #line 99 @@ -774,7 +774,7 @@ public virtual void ProcessSettlement() "RecipientEmail", "RecipientMobile"}); table82.AddRow(new string[] { - "LastWeek", + "2022-01-06", "1", "Sale", "Test Merchant 1", @@ -789,7 +789,7 @@ public virtual void ProcessSettlement() "", ""}); table82.AddRow(new string[] { - "LastWeek", + "2022-01-06", "2", "Sale", "Test Merchant 2", @@ -804,7 +804,7 @@ public virtual void ProcessSettlement() "", ""}); table82.AddRow(new string[] { - "LastWeek", + "2022-01-06", "4", "Sale", "Test Merchant 1", @@ -819,7 +819,7 @@ public virtual void ProcessSettlement() "", ""}); table82.AddRow(new string[] { - "LastWeek", + "2022-01-06", "5", "Sale", "Test Merchant 1", @@ -834,7 +834,7 @@ public virtual void ProcessSettlement() "test@recipient.co.uk", ""}); table82.AddRow(new string[] { - "LastWeek", + "2022-01-06", "6", "Sale", "Test Merchant 2", @@ -895,15 +895,15 @@ public virtual void ProcessSettlement() "EstateName", "NumberOfFees"}); table84.AddRow(new string[] { - "Today", + "2022-01-13", "Test Estate 1", "1"}); #line 144 testRunner.When("I get the pending settlements the following information should be returned", ((string)(null)), table84, "When "); #line hidden #line 148 - testRunner.When("I process the settlement for \'Today\' on Estate \'Test Estate 1\' then 1 fees are ma" + - "rked as settled and the settlement is completed", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); + testRunner.When("I process the settlement for \'2022-01-13\' on Estate \'Test Estate 1\' then 1 fees a" + + "re marked as settled and the settlement is completed", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line hidden } this.ScenarioCleanup(); diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index 6bc6e438..96461e8f 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -888,7 +888,7 @@ public async Task WhenIGetThePendingSettlementsTheFollowingInformationShouldBeRe EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow); String settlementDateString = SpecflowTableHelper.GetStringRowValue(tableRow, "SettlementDate"); Int32 numberOfFees = SpecflowTableHelper.GetIntValue(tableRow, "NumberOfFees"); - DateTime settlementDate = this.GetSettlementDate(DateTime.UtcNow.Date, settlementDateString); + DateTime settlementDate = SpecflowTableHelper.GetDateForDateString(settlementDateString, DateTime.UtcNow.Date); var aggregateid = settlementDate.ToGuid(); await Retry.For(async () => @@ -907,8 +907,8 @@ await this.TestingContext.DockerHelper.TransactionProcessorClient.GetSettlementB [When(@"I process the settlement for '([^']*)' on Estate '([^']*)' then (.*) fees are marked as settled and the settlement is completed")] public async Task WhenIProcessTheSettlementForOnEstateThenFeesAreMarkedAsSettledAndTheSettlementIsCompleted(String dateString, String estateName, Int32 numberOfFeesSettled) { - DateTime settlementDate = this.GetSettlementDate(DateTime.UtcNow.Date, dateString); - + DateTime settlementDate = SpecflowTableHelper.GetDateForDateString(dateString, DateTime.UtcNow.Date); + EstateDetails estateDetails = this.TestingContext.GetEstateDetails(estateName); await this.TestingContext.DockerHelper.TransactionProcessorClient.ProcessSettlement(this.TestingContext.AccessToken, settlementDate, @@ -928,26 +928,5 @@ await this.TestingContext.DockerHelper.TransactionProcessorClient.GetSettlementB settlement.SettlementCompleted.ShouldBeTrue(); }, TimeSpan.FromMinutes(2)); } - - private DateTime GetSettlementDate(DateTime now, - String nextSettlementDate) - { - if (nextSettlementDate == "Yesterday") - { - return now.AddDays(-1).Date; - } - - if (nextSettlementDate == "NextWeek") - { - return now.AddDays(7).Date; - } - - if (nextSettlementDate == "NextMonth") - { - return now.AddMonths(1).Date.Date; - } - - return now.Date; - } } } diff --git a/TransactionProcessor.IntegrationTests/projections/continuous/TransactionEnricher.js b/TransactionProcessor.IntegrationTests/projections/continuous/TransactionEnricher.js index bfb97273..a8c21180 100644 --- a/TransactionProcessor.IntegrationTests/projections/continuous/TransactionEnricher.js +++ b/TransactionProcessor.IntegrationTests/projections/continuous/TransactionEnricher.js @@ -41,7 +41,7 @@ function merchantFeeAddedToTransactionEventHandler(s, e) { feeCalculationType: e.data.feeCalculationType, eventId: e.eventId } - emit(getStreamName(s), "MerchantFeeAddedToTransactionEnrichedEvent", newEvent, null); + emit(getStreamName(s), "MerchantFeeAddedToTransactionEnrichedEvent", newEvent, {}); } function serviceProviderFeeAddedToTransactionEventHandler(s, e) { @@ -56,7 +56,7 @@ function serviceProviderFeeAddedToTransactionEventHandler(s, e) { feeCalculationType: e.data.feeCalculationType, eventId: e.eventId } - emit(getStreamName(s), "ServiceProviderFeeAddedToTransactionEnrichedEvent", newEvent, null); + emit(getStreamName(s), "ServiceProviderFeeAddedToTransactionEnrichedEvent", newEvent, { }); } function getStreamName(s) { diff --git a/TransactionProcessor.IntegrationTests/projections/continuous/TransactionProcessorSubscriptionStreamBuilder.js b/TransactionProcessor.IntegrationTests/projections/continuous/TransactionProcessorSubscriptionStreamBuilder.js index ebdb00e0..e7c99c25 100644 --- a/TransactionProcessor.IntegrationTests/projections/continuous/TransactionProcessorSubscriptionStreamBuilder.js +++ b/TransactionProcessor.IntegrationTests/projections/continuous/TransactionProcessorSubscriptionStreamBuilder.js @@ -8,6 +8,7 @@ getSupportedEventTypes = function () { eventTypes.push('CustomerEmailReceiptRequestedEvent'); eventTypes.push('TransactionHasBeenCompletedEvent'); + eventTypes.push('MerchantFeeAddedToTransactionEvent'); return eventTypes; }