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 @@ -108,7 +108,7 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet
this.TransactionAggregateManager.Setup(t => t.GetAggregate(It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(TestData.GetCompletedAuthorisedSaleTransactionAggregate);

this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>())).Returns(new List<CalculatedFee>
this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>(), It.IsAny<DateTime>())).Returns(new List<CalculatedFee>
{
TestData.CalculatedFeeMerchantFee(),
TestData.CalculatedFeeServiceProviderFee
Expand Down Expand Up @@ -154,7 +154,7 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet
this.SettlementAggregateRepository.Setup(p => p.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(pendingSettlementAggregate);

this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>())).Returns(new List<CalculatedFee>
this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>(), It.IsAny<DateTime>())).Returns(new List<CalculatedFee>
{
TestData.CalculatedFeeMerchantFee(),
TestData.CalculatedFeeServiceProviderFee
Expand Down Expand Up @@ -204,7 +204,7 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet
this.SettlementAggregateRepository.Setup(p => p.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(pendingSettlementAggregate);

this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>())).Returns(new List<CalculatedFee>
this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>(), It.IsAny<DateTime>())).Returns(new List<CalculatedFee>
{
TestData.CalculatedFeeMerchantFee(),
TestData.CalculatedFeeServiceProviderFee
Expand Down Expand Up @@ -251,7 +251,7 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet
this.TransactionAggregateManager.Setup(t => t.GetAggregate(It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(TestData.GetCompletedAuthorisedSaleTransactionAggregate);

this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>())).Returns(new List<CalculatedFee>
this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>(), It.IsAny<DateTime>())).Returns(new List<CalculatedFee>
{
TestData.CalculatedFeeMerchantFee(),
TestData.CalculatedFeeServiceProviderFee
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private async Task HandleSpecificDomainEvent(TransactionHasBeenCompletedEvent do
}

// Do the fee calculation
List<CalculatedFee> resultFees = this.FeeCalculationManager.CalculateFees(feesForCalculation, transactionAggregate.TransactionAmount.Value);
List<CalculatedFee> resultFees = this.FeeCalculationManager.CalculateFees(feesForCalculation, transactionAggregate.TransactionAmount.Value, domainEvent.CompletedDateTime);

// Process the non merchant fees
IEnumerable<CalculatedFee> nonMerchantFees = resultFees.Where(f => f.FeeType == FeeType.ServiceProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public class FeeCalculationManager : IFeeCalculationManager
/// <param name="transactionAmount">The transaction amount.</param>
/// <returns></returns>
public List<CalculatedFee> CalculateFees(List<TransactionFeeToCalculate> feeList,
Decimal transactionAmount)
Decimal transactionAmount,
DateTime calculationDateTime = new DateTime())
{
List<CalculatedFee> calculatedFees = new List<CalculatedFee>();

Expand All @@ -37,7 +38,7 @@ public List<CalculatedFee> CalculateFees(List<TransactionFeeToCalculate> feeList
FeeCalculationType = transactionFeeToCalculate.CalculationType,
FeeId = transactionFeeToCalculate.FeeId,
FeeValue = transactionFeeToCalculate.Value,
FeeCalculatedDateTime = DateTime.Now
FeeCalculatedDateTime = calculationDateTime == DateTime.MinValue ? DateTime.Now : calculationDateTime
});
}

Expand All @@ -51,7 +52,7 @@ public List<CalculatedFee> CalculateFees(List<TransactionFeeToCalculate> feeList
FeeCalculationType = transactionFeeToCalculate.CalculationType,
FeeId = transactionFeeToCalculate.FeeId,
FeeValue = transactionFeeToCalculate.Value,
FeeCalculatedDateTime = DateTime.Now
FeeCalculatedDateTime = calculationDateTime == DateTime.MinValue ? DateTime.Now : calculationDateTime
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public interface IFeeCalculationManager
/// </summary>
/// <param name="feeList">The fee list.</param>
/// <param name="transactionAmount">The transaction amount.</param>
/// <param name="calculationDateTime">The calculation date time.</param>
/// <returns></returns>
List<CalculatedFee> CalculateFees(List<TransactionFeeToCalculate> feeList,
Decimal transactionAmount);
Decimal transactionAmount,
DateTime calculationDateTime = new DateTime());

#endregion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ Scenario: Logon Transaction with Existing Device
| EstateName | MerchantName | TransactionNumber | ResponseCode | ResponseMessage |
| Test Estate 1 | Test Merchant 1 | 1 | 0000 | SUCCESS |

@PRTest
Scenario: Logon Transaction with Invalid Device

Given I have assigned the following devices to the merchants
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ Scenario: Sale Transactions
| Test Estate 1 | Test Merchant 2 | 6 | 0000 | SUCCESS |
| Test Estate 2 | Test Merchant 3 | 7 | 0000 | SUCCESS |

@PRTest
Scenario: Sale Transaction with Invalid Device

When I perform the following transactions
Expand Down Expand Up @@ -135,7 +134,6 @@ Scenario: Sale Transaction with Invalid Merchant
| EstateName | MerchantName | TransactionNumber | ResponseCode | ResponseMessage |
| Test Estate 1 | InvalidMerchant | 1 | 1002 | Merchant Id [d59320fa-4c3e-4900-a999-483f6a10c69a] is not a valid merchant for estate [Test Estate 1] |

@PRTest
Scenario: Sale Transaction with Not Enough Credit Available

When I perform the following transactions
Expand Down
Loading