Skip to content

Commit

Permalink
Added funding for report year to form context #3369
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Dec 10, 2024
1 parent 6342fc9 commit df6d1eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,20 @@ class RegionalCapacityServicesReportLifecycleListener extends ReportLifecycleLis
Map getContextData(Map organisation, Map report) {
List outputTargets = organisation.custom?.details?.services?.targets
Map periodTargets = getTargetsForReportPeriod(report, outputTargets)
BigDecimal funding = new BigDecimal(0) // TODO get budget from the correct period of the budget table
def funding = getFundingForPeriod(organisation, report)
[periodTargets:periodTargets, totalContractValue:funding]
}

private static def getFundingForPeriod(Map organisation, Map report) {
String endDate = report.toDate
String previousPeriod = ''
def index = organisation.custom?.details?.funding?.headers?.findIndexOf {
String period = it.data.value
boolean result = previousPeriod < endDate && period >= endDate
previousPeriod = period
result
}
index >= 0 ? organisation.custom?.details?.funding?.rows[0].costs[index].dollar : 0

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ class ReportLifecycleListener {
String name = scoreName(scoreId) ?: scoreId
String previousPeriod = ''
Map matchingPeriodTarget = outputTarget?.periodTargets?.find { Map periodTarget ->
previousPeriod < endDate && periodTarget.period >= endDate
boolean result = previousPeriod < endDate && periodTarget.period >= endDate
previousPeriod = periodTarget.period
result
}
[(name): matchingPeriodTarget?.target]
}
Expand Down

0 comments on commit df6d1eb

Please sign in to comment.