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 async Task <IList <AccountProjectionModel> > Get(long employerAccountId) { var projections = await _accountProjectionDataSession.Get(employerAccountId); if (!projections.Any()) { return(null); } var firstProjection = projections.OrderBy(o => o.Year).ThenBy(m => m.Month).First(); firstProjection.IsFirstMonth = true; return(projections); }