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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public async Task<ProcessSettlementResponse> 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;
}
Expand Down
34 changes: 17 additions & 17 deletions TransactionProcessor.IntegrationTests/Settlement/Settlement.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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
Expand Down Expand Up @@ -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 |
Expand All @@ -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


Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 3 additions & 24 deletions TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 () =>
Expand All @@ -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,
Expand All @@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ getSupportedEventTypes = function () {

eventTypes.push('CustomerEmailReceiptRequestedEvent');
eventTypes.push('TransactionHasBeenCompletedEvent');
eventTypes.push('MerchantFeeAddedToTransactionEvent');

return eventTypes;
}
Expand Down