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 AccountEstimationProjection(Account account, AccountEstimationProjectionCommitments accountEstimationProjectionCommitments, IDateTimeService dateTimeService, bool showExpiredFunds) { _dateTimeService = dateTimeService; _showExpiredFunds = showExpiredFunds; _account = account ?? throw new ArgumentNullException(nameof(account)); if (accountEstimationProjectionCommitments == null) { throw new ArgumentNullException(nameof(accountEstimationProjectionCommitments)); } _virtualEmployerCommitments = accountEstimationProjectionCommitments.VirtualEmployerCommitments ?? throw new ArgumentNullException(nameof(accountEstimationProjectionCommitments.VirtualEmployerCommitments)); _actualAccountProjections = accountEstimationProjectionCommitments.ActualAccountProjections.ToList().AsReadOnly() ?? throw new ArgumentNullException(nameof(accountEstimationProjectionCommitments.ActualAccountProjections)); _estimatedProjections = new List <AccountEstimationProjectionModel>(); }