diff --git a/grails-app/controllers/au/org/ala/merit/ProjectController.groovy b/grails-app/controllers/au/org/ala/merit/ProjectController.groovy index 5e615c014..62bbd6df8 100644 --- a/grails-app/controllers/au/org/ala/merit/ProjectController.groovy +++ b/grails-app/controllers/au/org/ala/merit/ProjectController.groovy @@ -226,7 +226,8 @@ class ProjectController { model.details.meriPlanTemplate = config.meriPlanTemplate ? config.meriPlanTemplate+"View" : RLP_MERI_PLAN_TEMPLATE+'View' boolean serviceDeliveryVisible = model.dashboard.visible && userHasViewAccess - model.serviceDelivery = [label: 'Dashboard', visible: serviceDeliveryVisible, type: 'tab', template: 'rlpServiceDashboard', includeInvoiced:config.supportsOutcomeTargets()] + boolean showDashboardInvoiceField = (config.showsDashboardInvoiceField == null) ? config.supportsOutcomeTargets() : config.showsDashboardInvoiceField + model.serviceDelivery = [label: 'Dashboard', visible: serviceDeliveryVisible, type: 'tab', template: 'rlpServiceDashboard', includeInvoiced:showDashboardInvoiceField] if (model.serviceDelivery.visible) { // This can be a slow call so don't make it if the data won't be displayed model.serviceDelivery.servicesDashboard = projectService.getServiceDashboardData(project.projectId, false) diff --git a/src/main/groovy/au/org/ala/merit/config/ProgramConfig.groovy b/src/main/groovy/au/org/ala/merit/config/ProgramConfig.groovy index 6730d792d..3f22e6b68 100644 --- a/src/main/groovy/au/org/ala/merit/config/ProgramConfig.groovy +++ b/src/main/groovy/au/org/ala/merit/config/ProgramConfig.groovy @@ -151,6 +151,9 @@ class ProgramConfig implements Map { template != null } + /** This flag controls whether the invoice field in the dashboard is shown */ + boolean showsDashboardInvoiceField = true + } diff --git a/src/main/groovy/au/org/ala/merit/reports/RegionalCapacityServicesReportLifecycleListener.groovy b/src/main/groovy/au/org/ala/merit/reports/RegionalCapacityServicesReportLifecycleListener.groovy index 1241eba5b..69eeecdcc 100644 --- a/src/main/groovy/au/org/ala/merit/reports/RegionalCapacityServicesReportLifecycleListener.groovy +++ b/src/main/groovy/au/org/ala/merit/reports/RegionalCapacityServicesReportLifecycleListener.groovy @@ -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 + + } } diff --git a/src/main/groovy/au/org/ala/merit/reports/ReportLifecycleListener.groovy b/src/main/groovy/au/org/ala/merit/reports/ReportLifecycleListener.groovy index c606e7536..546842b41 100644 --- a/src/main/groovy/au/org/ala/merit/reports/ReportLifecycleListener.groovy +++ b/src/main/groovy/au/org/ala/merit/reports/ReportLifecycleListener.groovy @@ -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] }