private AccountProjectionModel CreateProjection(DateTime period, decimal levyFundsIn, decimal lastBalance, ProjectionGenerationType projectionGenerationType, bool isFirstMonth, int periodStartDay)
        {
            var totalCostOfTraning = _employerCommitments.GetTotalCostOfTraining(period);
            var completionPayments = _employerCommitments.GetTotalCompletionPayments(period);

            var currentBalance = GetCurrentBalance(lastBalance, completionPayments.TransferOutCompletionPayment, totalCostOfTraning.TransferOut, isFirstMonth);

            var trainingCosts = totalCostOfTraning.LevyFunded + completionPayments.LevyFundedCompletionPayment;

            var coInvestmentAmount = GetCoInvestmentAmountBasedOnCurrentBalanceAndTrainingCosts(currentBalance, trainingCosts);

            var moneyOut = isFirstMonth ? coInvestmentAmount : trainingCosts - coInvestmentAmount;

            var moneyIn = isFirstMonth && projectionGenerationType == ProjectionGenerationType.LevyDeclaration ? 0:
                          levyFundsIn;

            var futureFunds = GetMonthEndBalance(currentBalance, moneyOut, moneyIn, projectionGenerationType, isFirstMonth, periodStartDay);


            var projection = new AccountProjectionModel
            {
                LevyFundsIn       = _account.LevyDeclared,
                EmployerAccountId = _account.EmployerAccountId,
                Month             = (short)period.Month,
                Year = (short)period.Year,

                LevyFundedCostOfTraining  = totalCostOfTraning.LevyFunded,
                TransferInCostOfTraining  = totalCostOfTraning.TransferIn,
                TransferOutCostOfTraining = totalCostOfTraning.TransferOut,

                LevyFundedCompletionPayments  = completionPayments.LevyFundedCompletionPayment,
                TransferInCompletionPayments  = completionPayments.TransferInCompletionPayment,
                TransferOutCompletionPayments = completionPayments.TransferOutCompletionPayment,

                CoInvestmentEmployer     = coInvestmentAmount > 0 ? (coInvestmentAmount * 0.1m) : 0m,
                CoInvestmentGovernment   = coInvestmentAmount > 0 ? (coInvestmentAmount * 0.9m) : 0m,
                FutureFunds              = futureFunds,
                ProjectionCreationDate   = DateTime.UtcNow,
                ProjectionGenerationType = projectionGenerationType
            };

            return(projection);
        }
Exemple #2
0
        public void SetUp()
        {
            _config = new Mock <IApplicationConfiguration>();
            _config.Setup(x => x.FeatureExpiredFunds).Returns(true);

            _mapper          = new ForecastingMapper(_config.Object);
            _projectionModel =
                new AccountProjectionModel
            {
                Id = 1,
                EmployerAccountId        = 14,
                ProjectionCreationDate   = DateTime.Today,
                ProjectionGenerationType = ProjectionGenerationType.LevyDeclaration,
                Month = (short)DateTime.Today.Month,
                Year  = DateTime.Today.Year,

                LevyFundsIn = 100,
                LevyFundedCostOfTraining     = 100,
                LevyFundedCompletionPayments = 100,


                TransferInCostOfTraining  = 100,
                TransferOutCostOfTraining = 100,

                TransferInCompletionPayments  = 100,
                TransferOutCompletionPayments = 100,

                CommittedTransferCost           = 100,
                CommittedTransferCompletionCost = 100,
                FutureFunds            = 100,
                CoInvestmentEmployer   = 100,
                CoInvestmentGovernment = 100,
                ExpiredFunds           = 10
            };

            _models = new List <AccountProjectionModel>
            {
                _projectionModel
            };
        }