private void CreateCommitmentModel(decimal monthlyInstallment, decimal completionAmount) { _commitment = new CommitmentModel { EmployerAccountId = 1, ApprenticeshipId = 2, LearnerId = 3, StartDate = DateTime.Today.AddMonths(-1), PlannedEndDate = DateTime.Today.AddMonths(25), MonthlyInstallment = monthlyInstallment, NumberOfInstallments = 4, CompletionAmount = completionAmount, FundingSource = Models.Payments.FundingSource.Levy }; _commitments = new EmployerCommitmentsModel { LevyFundedCommitments = new List <CommitmentModel> { _commitment } }; var employerCommitments = new EmployerCommitments(1, _commitments); Moqer.SetInstance(employerCommitments); }
public void SetUp() { Moqer = new AutoMoqer(); endDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddYears(1); startDate = endDate.AddYears(-1); Commitments = new EmployerCommitmentsModel(); }
public void SetUp() { Moqer = new AutoMoqer(); _account = new Account(1, 12000, 300, 0, 0); Moqer.SetInstance(_account); _commitment = new CommitmentModel { EmployerAccountId = 1, ApprenticeshipId = 2, LearnerId = 3, StartDate = DateTime.Today.AddMonths(-1), PlannedEndDate = DateTime.Today.AddMonths(25), MonthlyInstallment = 2100, NumberOfInstallments = 24, CompletionAmount = 3000, FundingSource = Models.Payments.FundingSource.Levy }; _commitments = new EmployerCommitmentsModel { LevyFundedCommitments = new List <CommitmentModel> { _commitment } }; var employerCommitments = new EmployerCommitments(1, _commitments); Moqer.SetInstance(employerCommitments); }
public async Task <IAccountEstimationProjection> Get(AccountEstimation accountEstimation, bool showExpiredFunds = false) { var balance = await _currentBalanceRepository.Get(accountEstimation.EmployerAccountId); var commitments = _commitmentModelListBuilder.Build(accountEstimation.EmployerAccountId, accountEstimation.Apprenticeships); var actualProjections = await _accountProjectionRepository.Get(accountEstimation.EmployerAccountId); var employerCommitmentsModel = new EmployerCommitmentsModel { SendingEmployerTransferCommitments = commitments .Where(m => m.FundingSource == Models.Payments.FundingSource.Transfer || m.FundingSource == 0) .ToList(), LevyFundedCommitments = commitments .Where(m => m.FundingSource == Models.Payments.FundingSource.Levy) .ToList() }; var levyFundsIn = actualProjections?.FirstOrDefault()?.LevyFundsIn ?? 0; var employerCommitments = new EmployerCommitments(accountEstimation.EmployerAccountId, employerCommitmentsModel); var accountEstimationProjectionCommitments = new AccountEstimationProjectionCommitments(employerCommitments, actualProjections); return(new AccountEstimationProjection(new Account(accountEstimation.EmployerAccountId, balance.Amount, levyFundsIn, balance.TransferAllowance, balance.RemainingTransferBalance), accountEstimationProjectionCommitments, _dateTimeService, showExpiredFunds)); }
public EmployerCommitments( long employerAccountId, EmployerCommitmentsModel commitments) { EmployerAccountId = employerAccountId; _employerCommitmentsModel = commitments ?? throw new ArgumentNullException(nameof(commitments)); _levyFundedCommitments = _employerCommitmentsModel.LevyFundedCommitments.AsReadOnly(); _receivingEmployerTransferCommitments = _employerCommitmentsModel.ReceivingEmployerTransferCommitments.AsReadOnly(); _sendingEmployerTransferCommitments = _employerCommitmentsModel.SendingEmployerTransferCommitments.AsReadOnly(); _coInvestmentCommitments = _employerCommitmentsModel.CoInvestmentCommitments.AsReadOnly(); }
public async Task <EmployerCommitmentsModel> GetCurrentCommitments(long employerAccountId, DateTime?forecastLimitDate = null) { var stopwatch = new Stopwatch(); stopwatch.Start(); var model = new EmployerCommitmentsModel { LevyFundedCommitments = await GetCommitments(GetLevyFundedCommiments(employerAccountId, forecastLimitDate), "Levy Funded Commitments"), ReceivingEmployerTransferCommitments = await GetCommitments(GetReceivingEmployerTransferCommitments(employerAccountId, forecastLimitDate), "Receiving Employer Transfer Commitments"), SendingEmployerTransferCommitments = await GetCommitments(GetSendingEmployerTransferCommitments(employerAccountId, forecastLimitDate), "Sending Employer Transfer Commitments"), CoInvestmentCommitments = await GetCommitments(GetCoInvestmentCommitments(employerAccountId), "Co-Investment Commitments") }; stopwatch.Stop(); _telemetry.TrackDuration("Get Current Commitments", stopwatch.Elapsed); return(model); }
public void Then_The_Estimation_Only_Includes_Modelled_Transfer_Estimates_And_Not_Projection_Estimates() { //Arrange var commitments = new EmployerCommitmentsModel { SendingEmployerTransferCommitments = { new CommitmentModel { CompletionAmount = 100, EmployerAccountId = EmployerAccountId, MonthlyInstallment = 50, PlannedEndDate = new DateTime(DateTime.Now.Year, 5, 1), StartDate = new DateTime(DateTime.Now.Year, 1, 1), NumberOfInstallments = 5, FundingSource = Models.Payments.FundingSource.Levy } } }; var employerCommitments = new EmployerCommitments(EmployerAccountId, commitments); var accountEstimationProjectionCommitments = new AccountEstimationProjectionCommitments(employerCommitments, _accountProjection.AsReadOnly()); _moqer.SetInstance(accountEstimationProjectionCommitments); _estimationProjection = new AccountEstimationProjection(_moqer.Resolve <Account>(), _moqer.Resolve <AccountEstimationProjectionCommitments>(), _moqer.Resolve <IDateTimeService>(), false); //Act _estimationProjection.BuildProjections(); //Assert var actual = _estimationProjection.Projections.OrderBy(c => c.Year).ThenBy(c => c.Month).FirstOrDefault(); Assert.IsNotNull(actual); Assert.AreEqual(9990, actual.AvailableTransferFundsBalance); }
public void SetUp() { _moqer = new AutoMoqer(); _commitments = new EmployerCommitmentsModel { LevyFundedCommitments = new List <CommitmentModel> { new CommitmentModel { StartDate = DateTime.Now.AddMonths(-1), PlannedEndDate = DateTime.Now.AddMonths(12), ApprenticeName = "Alan Wake", EmployerAccountId = ExpectedAccountId, SendingEmployerAccountId = ExpectedAccountId, MonthlyInstallment = 10.6m, NumberOfInstallments = 10, CompletionAmount = 100.8m, CourseName = "My Course", CourseLevel = 1, LearnerId = 90, ProviderName = "Test Provider", ProviderId = 99876, FundingSource = FundingSource.Levy, HasHadPayment = true }, new CommitmentModel { StartDate = DateTime.Now.AddMonths(2), PlannedEndDate = DateTime.Now.AddMonths(12), ApprenticeName = "Jane Doe", EmployerAccountId = ReceivingEmployerAccountId, SendingEmployerAccountId = ExpectedAccountId, MonthlyInstallment = 10, NumberOfInstallments = 10, CompletionAmount = 100, CourseName = "My Course", CourseLevel = 1, LearnerId = 997, ProviderName = "Test Provider", ProviderId = 99876, FundingSource = FundingSource.Transfer, HasHadPayment = true }, new CommitmentModel { StartDate = DateTime.Now.AddMonths(2), PlannedEndDate = DateTime.Now.AddMonths(12), ApprenticeName = "Jane Doe", EmployerAccountId = ReceivingEmployerAccountId, SendingEmployerAccountId = ExpectedAccountId, MonthlyInstallment = 10, NumberOfInstallments = 10, CompletionAmount = 100, CourseName = "My Course", CourseLevel = 1, LearnerId = 998, ProviderName = "Test Provider", ProviderId = 99876, FundingSource = FundingSource.Levy, HasHadPayment = false }, new CommitmentModel { StartDate = DateTime.Now.AddMonths(-2), PlannedEndDate = DateTime.Now.AddMonths(12), ApprenticeName = "Jane Doe", EmployerAccountId = ReceivingEmployerAccountId, SendingEmployerAccountId = ExpectedAccountId, MonthlyInstallment = 10, NumberOfInstallments = 10, CompletionAmount = 100, CourseName = "My Course", CourseLevel = 1, LearnerId = 999, ProviderName = "Test Provider", ProviderId = 99876, FundingSource = FundingSource.Levy, HasHadPayment = false } } }; _moqer.GetMock <ICommitmentsDataService>() .Setup(x => x.GetCurrentCommitments(It.IsAny <long>(), It.IsAny <DateTime?>())) .ReturnsAsync(_commitments); var hashingService = _moqer.GetMock <IHashingService>(); hashingService .Setup(m => m.DecodeValue("ABBA12")) .Returns(ExpectedAccountId); hashingService .Setup(m => m.DecodeValue("CDDC12")) .Returns(ReceivingEmployerAccountId); _balance = new BalanceModel { EmployerAccountId = 12345, Amount = 50000, TransferAllowance = 5000, RemainingTransferBalance = 5000, UnallocatedCompletionPayments = 2000 }; _moqer.GetMock <IAccountBalanceService>() .Setup(m => m.GetAccountBalance(It.IsAny <long>())) .ReturnsAsync(_balance); var balanceService = _moqer.GetMock <IAccountBalanceService>(); var currentBalance = new CurrentBalance(_balance, balanceService.Object, new Domain.Commitments.EmployerCommitments(12345, new EmployerCommitmentsModel())); _moqer.GetMock <ICurrentBalanceRepository>() .Setup(x => x.Get(It.IsAny <long>())) .ReturnsAsync(currentBalance); _moqer.SetInstance <IForecastingMapper>(new ForecastingMapper(Mock.Of <IApplicationConfiguration>())); }
public void SetUp() { _moqer = new AutoMoqer(); _commitments = new EmployerCommitmentsModel { SendingEmployerTransferCommitments = { new CommitmentModel { CompletionAmount = 100, EmployerAccountId = EmployerAccountId, MonthlyInstallment = 50, PlannedEndDate = new DateTime(DateTime.Now.Year, 5, 1), StartDate = new DateTime(DateTime.Now.Year, 1, 1), NumberOfInstallments = 5, FundingSource = Models.Payments.FundingSource.Levy }, new CommitmentModel { CompletionAmount = 100, EmployerAccountId = EmployerAccountId, MonthlyInstallment = 50, PlannedEndDate = new DateTime(DateTime.Now.Year + 1, 9, 1), StartDate = new DateTime(DateTime.Now.Year + 1, 3, 1), NumberOfInstallments = 5, FundingSource = Models.Payments.FundingSource.Levy }, new CommitmentModel { CompletionAmount = 100, EmployerAccountId = EmployerAccountId, MonthlyInstallment = 50, PlannedEndDate = new DateTime(DateTime.Now.Year, 5, 1), StartDate = new DateTime(DateTime.Now.Year, 1, 1), NumberOfInstallments = 5, FundingSource = Models.Payments.FundingSource.Transfer }, } }; var employerCommitments = new EmployerCommitments(EmployerAccountId, _commitments); _accountProjection = new List <AccountProjectionModel> { new AccountProjectionModel { EmployerAccountId = 54321, Month = 1, Year = DateTime.Now.Year, LevyFundsIn = 100, TransferOutCostOfTraining = 10, TransferOutCompletionPayments = 0, LevyFundedCompletionPayments = 50, LevyFundedCostOfTraining = 50, FutureFunds = 500, FutureFundsNoExpiry = 100 }, new AccountProjectionModel { EmployerAccountId = 54321, Month = 2, Year = DateTime.Now.Year, LevyFundsIn = 100, TransferOutCostOfTraining = 10, TransferOutCompletionPayments = 0, LevyFundedCompletionPayments = 0, LevyFundedCostOfTraining = 50, FutureFunds = 540, FutureFundsNoExpiry = 140 }, new AccountProjectionModel { EmployerAccountId = 54321, Month = 3, Year = DateTime.Now.Year, LevyFundsIn = 100, TransferOutCostOfTraining = 10, TransferOutCompletionPayments = 0, LevyFundedCompletionPayments = 0, LevyFundedCostOfTraining = 50, FutureFunds = 580, FutureFundsNoExpiry = 180 }, new AccountProjectionModel { EmployerAccountId = 54321, Month = 4, Year = DateTime.Now.Year, LevyFundsIn = 100, TransferOutCostOfTraining = 10, TransferOutCompletionPayments = 0, LevyFundedCompletionPayments = 0, LevyFundedCostOfTraining = 50, FutureFunds = 620, FutureFundsNoExpiry = 220 }, new AccountProjectionModel { EmployerAccountId = 54321, Month = 5, Year = DateTime.Now.Year, LevyFundsIn = 100, TransferOutCostOfTraining = 10, TransferOutCompletionPayments = 0, LevyFundedCompletionPayments = 0, LevyFundedCostOfTraining = 50, FutureFunds = 660, FutureFundsNoExpiry = 260 }, new AccountProjectionModel { EmployerAccountId = 54321, Month = 6, Year = DateTime.Now.Year, LevyFundsIn = 100, TransferOutCostOfTraining = 0, TransferOutCompletionPayments = 20, LevyFundedCompletionPayments = 0, LevyFundedCostOfTraining = 50, FutureFunds = 690, FutureFundsNoExpiry = 290 } }; var accountEstimationProjectionCommitments = new AccountEstimationProjectionCommitments(employerCommitments, _accountProjection.AsReadOnly()); _moqer.GetMock <IDateTimeService>() .Setup(x => x.GetCurrentDateTime()).Returns(new DateTime(DateTime.Now.Year, 2, 1)); _moqer.SetInstance(accountEstimationProjectionCommitments); _account = new Account(EmployerAccountId, 10000, 0, TransferAllowance, 10000); _moqer.SetInstance(_account); _estimationProjection = new AccountEstimationProjection(_moqer.Resolve <Account>(), _moqer.Resolve <AccountEstimationProjectionCommitments>(), _moqer.Resolve <IDateTimeService>(), false); }