示例#1
0
        public Dictionary <CalendarPeriod, decimal> GetExpiringFunds(IList <AccountProjectionModel> projections, IEnumerable <LevyPeriod> levyPeriodTotals, Dictionary <CalendarPeriod, decimal> paymentsTotals, ProjectionSource messageProjectionSource, DateTime projectionDate)
        {
            var previousLevyTotals =
                levyPeriodTotals.ToDictionary(k => new CalendarPeriod(k.CalendarYear, k.CalendarMonth),
                                              v => v.TotalNetLevyDeclared);

            var fundsIn = projections
                          .ToDictionary(d => new CalendarPeriod(d.Year, d.Month), v => v.LevyFundsIn);

            var fundsOut = projections
                           .OrderBy(c => c.Year)
                           .ThenBy(c => c.Month)
                           .Skip(ShouldSkipFirstMonthPaymentValue(projectionDate, messageProjectionSource))
                           .ToDictionary(d => new CalendarPeriod(d.Year, d.Month),
                                         v => v.LevyFundedCostOfTraining + v.LevyFundedCompletionPayments
                                         + v.TransferOutCostOfTraining + v.TransferOutCompletionPayments);

            fundsIn = fundsIn.Concat(previousLevyTotals).GroupBy(g => g.Key).ToDictionary(t => t.Key, t => t.Last().Value);

            fundsOut = fundsOut.Concat(paymentsTotals).GroupBy(g => g.Key).ToDictionary(t => t.Key, t => t.Last().Value);

            var expiringFunds = _expiredFunds.GetExpiringFunds(fundsIn, fundsOut, null, 24);

            return((Dictionary <CalendarPeriod, decimal>)expiringFunds);
        }
示例#2
0
        public static IDictionary <CalendarPeriod, decimal> GetExpiredFunds(this IExpiredFunds expiredFundsService, IDictionary <CalendarPeriod, decimal> fundsIn, IDictionary <CalendarPeriod, decimal> fundsOut, IDictionary <CalendarPeriod, decimal> expired, int expiryPeriod, DateTime today)
        {
            var currentCalendarPeriod = new CalendarPeriod(today.Year, today.Month);
            var expiringFunds         = expiredFundsService.GetExpiringFunds(fundsIn, fundsOut, expired, expiryPeriod);

            var expiredFunds = expiringFunds
                               .Where(ef => ef.Key <= currentCalendarPeriod && ef.Value >= 0 && !expired.Any(e => e.Key == ef.Key && e.Value == ef.Value))
                               .ToDictionary(e => e.Key, e => e.Value);

            return(expiredFunds);
        }