class SpendProfileTableCalculator {

    public List<BigDecimal> calculateGrantAllocationPerYear(ProjectResource project, List<BigDecimal> monthlyCost, List<LocalDateResource> months, Integer grantPercentage) {
        Integer startYear = new FinancialYearDate(DateUtil.asDate(project.getTargetStartDate())).getFiscalYear();
        Integer endYear = new FinancialYearDate(DateUtil.asDate(project.getTargetStartDate().plusMonths(project.getDurationInMonths()))).getFiscalYear();
        LinkedList<BigDecimal> grantAllocationPerYear = new LinkedList<>();
        IntStream.range(startYear, endYear + 1).
                mapToObj(
                        year -> {
                            BigDecimal totalForYear = BigDecimal.ZERO;

                            totalForYear = getEligibleCostMonthlyTotal(monthlyCost, months, year, totalForYear);
                            totalForYear = totalForYear.multiply(BigDecimal.valueOf(grantPercentage)).divide(BigDecimal.valueOf(100))
                                    .setScale(1, RoundingMode.CEILING);
                            return grantAllocationPerYear.add(totalForYear);
                        }

                ).collect(toList());

        return grantAllocationPerYear;
    }

}