Skip to content

Commit

Permalink
IPPRS / RCS reporting WIP #3369
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Dec 6, 2024
1 parent b492164 commit 4eb5c56
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class OrganisationController {
dashboard: dashboard,
roles:roles,
user:user,
services: organisationService.findApplicableServices(organisation, metadataService.getProjectServices()),
isAdmin:orgRole?.role == RoleService.PROJECT_ADMIN_ROLE,
isGrantManager:orgRole?.role == RoleService.GRANT_MANAGER_ROLE,
content:content(organisation)]
Expand All @@ -73,10 +72,15 @@ class OrganisationController {
def dashboardReports = [[name:'dashboard', label:'Activity Outputs']]

Map availableReportCategories = null
List services = null
List targetPeriods = null
if (adminVisible) {
dashboardReports += [name:'announcements', label:'Announcements']
availableReportCategories = settingService.getJson(SettingPageType.ORGANISATION_REPORT_CONFIG)
services = organisationService.findApplicableServices(organisation, metadataService.getProjectServices())
targetPeriods = organisationService.generateTargetPeriods(organisation)
}
boolean showTargets = services != null

List reportOrder = null
if (reportingVisible) {
Expand All @@ -102,13 +106,12 @@ class OrganisationController {
List projects = organisation.projects ?: []
List programGroups = organisation.config?.programGroups ?: []
Map projectGroups = projectGroupingHelper.groupProjectsByProgram(projects, programGroups, ["organisationId:"+organisation.organisationId], true)
List targetPeriods = organisationService.generateTargetPeriods(organisation)

[about : [label: 'About', visible: true, stopBinding: false, type:'tab', default:!reportingVisible, displayedPrograms:projectGroups.displayedPrograms, servicesDashboard:[visible:true]],
projects : [label: 'Reporting', template:"/shared/projectListByProgram", visible: reportingVisible, stopBinding:true, default:reportingVisible, type: 'tab', reports:organisation.reports, adHocReportTypes:adHocReportTypes, reportOrder:reportOrder, hideDueDate:true, displayedPrograms:projectGroups.displayedPrograms, reportsFirst:true, declarationType:SettingPageType.RDP_REPORT_DECLARATION],
sites : [label: 'Sites', visible: reportingVisible, type: 'tab', stopBinding:true, projectCount:organisation.projects?.size()?:0, showShapefileDownload:adminVisible],
dashboard : [label: 'Dashboard', visible: reportingVisible, stopBinding:true, type: 'tab', template:'/shared/dashboard', reports:dashboardReports],
admin : [label: 'Admin', visible: adminVisible, type: 'tab', template:'admin', showEditAnnoucements:showEditAnnoucements, availableReportCategories:availableReportCategories, targetPeriods:targetPeriods]]
admin : [label: 'Admin', visible: adminVisible, type: 'tab', template:'admin', showEditAnnoucements:showEditAnnoucements, availableReportCategories:availableReportCategories, targetPeriods:targetPeriods, services: services, showTargets:showTargets]]

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ class OrganisationService {
def findApplicableServices(Map organisation, List allServices) {

List supportedServices = organisation.config?.organisationReports?.collect{it.activityType}?.findAll{it}
List result = allServices
List result = []
if (supportedServices) {
result = allServices.findAll{ supportedServices.intersect(it.outputs.formName) }
}
Expand Down
5 changes: 4 additions & 1 deletion grails-app/views/organisation/_admin.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<a class="nav-link" data-toggle="pill" href="#reporting-config" id="reporting-config-tab" role="tab">Reporting</a>
<a class="nav-link" data-toggle="pill" href="#config" id="config-tab" role="tab">Configuration</a>
</g:if>
<g:if test="${showTargets}">
<a class="nav-link" data-toggle="pill" href="#organisation-targets" id="organisation-targets-tab" role="tab">Targets</a>

</g:if>
</div>

<div class="tab-content col-9">
Expand Down Expand Up @@ -153,9 +154,11 @@
</div>
<!-- /ko -->
</g:else>
<g:if test="${showTargets}">
<div id="organisation-targets" class="tab-pane">
<h3>Service Targets</h3>
<g:render template="/organisation/serviceTargets" model="[services:organisation.services, periods:organisation.periods, showTargetDate:organisation.showTargetDate]"/>
</div>
</g:if>
</div>
</div>
16 changes: 4 additions & 12 deletions grails-app/views/organisation/_serviceTargets.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@
<th class="index" rowspan="2"></th>
<th class="service required" rowspan="2">${serviceName ?: "Service"}</th>
<th class="score required" rowspan="2" style="width: 20px">Target measure</th>
<th class="budget-cell required" rowspan="2">Total to be delivered <g:if test="${totalHelpText}"> <fc:iconHelp> ${totalHelpText} </fc:iconHelp></g:if> <g:else><fc:iconHelp html="true">The overall total of Organsiation Services to be delivered during the organisation delivery period.
<b>Note: this total is not necessarily the sum of the minimum annual targets set out for the service.</b></fc:iconHelp></g:else> </th>
<th class="budget-cell required" rowspan="2">Overall target <g:if test="${totalHelpText}"> <fc:iconHelp> ${totalHelpText} </fc:iconHelp></g:if></th>
<g:if test="${showTargetDate}">
<th class="target-date required" rowspan="2">
Delivery date <g:if test="${deliveryHelpText}"> <fc:iconHelp> ${deliveryHelpText} </fc:iconHelp> </g:if>
</th>
</g:if>
<!-- ko if: periods && periods.length -->
<th data-bind="attr:{colspan:periods.length+1}">Minimum annual targets <fc:iconHelp>${minHelptext ?:"Specify the minimum total target for each Project Service to be delivered each financial year. Note: the sum of these targets will not necessarily equal the total services to be delivered."}</fc:iconHelp></th>
<th data-bind="attr:{colspan:periods.length+1}">${periodTargetsLabel ?: "Targets by date"}</th>
<!-- /ko -->
</tr>
<!-- ko if: periods && periods.length -->
<tr>

<!-- ko foreach: periods -->
<th class="budget-cell"><div data-bind="text:$data.label"></div></th>
<!-- /ko -->
</tr>
<!-- /ko -->
</thead>
<tbody data-bind="foreach : services">
<tr>
Expand Down Expand Up @@ -63,16 +64,7 @@
<!-- /ko -->
</tr>
</tbody>
%{-- <tfoot>--}%

%{-- <tr>--}%
%{-- <td data-bind="attr:{colspan:periods.length+${showTargetDate ? 6 : 5}}">--}%
%{-- <button type="button" class="btn btn-sm"--}%
%{-- data-bind="disable: $parent.isProjectDetailsLocked(), click: addService">--}%
%{-- <i class="fa fa-plus"></i> Add a row</button>--}%
%{-- </td>--}%
%{-- </tr>--}%
%{-- </tfoot>--}%
</table>
<!-- /ko -->
<!-- /ko -->
Expand Down
11 changes: 7 additions & 4 deletions grails-app/views/organisation/index.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@
returnTo: '${g.createLink(action:'index', id:"${organisation.organisationId}")}',
dashboardCategoryUrl: "${g.createLink(controller: 'report', action: 'activityOutputs', params: [fq:'organisationFacet:'+organisation.name])}",
reportOwner: {organisationId:'${organisation.organisationId}'},
projects : <fc:modelAsJavascript model="${organisation.projects}"/>,
services: <fc:modelAsJavascript model="${services}"/>
projects : <fc:modelAsJavascript model="${organisation.projects}"/>
};
</script>
<asset:stylesheet src="common-bs4.css"/>
Expand Down Expand Up @@ -82,11 +80,16 @@

var organisation =<fc:modelAsJavascript model="${organisation}"/>;
var availableReportCategories = <fc:modelAsJavascript model="${content.admin?.availableReportCategories}"/>;
var services = <fc:modelAsJavascript model="${content.admin?.services}"/>;
var targetPeriods = <fc:modelAsJavascript model="${content.admin?.targetPeriods}"/>;
var config = _.extend({
reportingConfigSelector:'#reporting-config form',
availableReportCategories:availableReportCategories,
targetPeriods: <fc:modelAsJavascript model="${content.admin?.targetPeriods}"/>
targetPeriods: targetPeriods,
services: services

}, fcConfig);

var organisationViewModel = new OrganisationPageViewModel(organisation, config);

ko.applyBindings(organisationViewModel);
Expand Down
105 changes: 105 additions & 0 deletions src/main/scripts/releases/4.1/configureIPPRS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
load("../../utils/uuid.js");
load( "../../utils/audit.js");
load( "../../utils/addService.js");

let adminUserId = '<system>'
addService("Indigenous Procurement", NumberInt(47), 'Regional Capacity Services Report', 'Regional capacity services - reporting', undefined, adminUserId);


// These have been pre-generated as there is value in having the same id in all environments
var indigenousWorkforcePerformanceScoreId = '5d28e47f-5182-4ad7-91f7-074908fb66e4';
var indigenousSupplyChainPerformanceScoreId = 'f7a537fd-cb38-4392-a0db-5e02beec6aa0';

var scores = [
{
"category": "Indigenous Procurement",
"configuration": {
"childAggregations": [{
"property": "data.workforcePerformancePercentage",
"type": "AVERAGE"
}]
},
"description": "",
"displayType": "",
"entity": "Activity",
"entityTypes": [],
"isOutputTarget": true,
"label": "Indigenous workforce performance",
"outputType": "Regional capacity services - reporting",
"scoreId": indigenousWorkforcePerformanceScoreId,
"status": "active"
},
{
"category": "Indigenous Procurement",
"configuration": {
"childAggregations": [{
"property": "data.workforcePerformancePercentage",
"type": "AVERAGE"
}]
},
"description": "",
"displayType": "",
"entity": "Activity",
"entityTypes": [],
"isOutputTarget": true,
"label": "Indigenous supply chain performance",
"outputType": "Regional capacity services - reporting",
"scoreId": indigenousSupplyChainPerformanceScoreId,
"status": "active"
}
];

for (var i=0; i<scores.length; i++) {
var existing = db.score.find({label:scores[i].label});
if (existing.hasNext()) {
var existingScore = existing.next();
existingScore.configuration = scores[i].configuration;
db.score.replaceOne({label:scores[i].label}, existingScore);
}
else {
db.score.insert(scores[i]);
}
audit(scores[i], scores[i].scoreId, 'au.org.ala.ecodata.Score', adminUserId, undefined, 'Update');

}

const targetsConfig = {
"periodGenerationConfig": {
"reportType": "Administrative",
"reportDescriptionFormat": "Regional capacity services report %d for %4$s",
"reportNameFormat": "Regional capacity report %d",
"reportingPeriodInMonths": 12,
"minimumReportDurationInDays": 1,
"label": "Annual",
"category": "Regional Capacity Services Reporting",
"activityType": "Regional Capacity Services Report",
"periodStart": "2022-06-30T14:00:00Z",
"periodEnd": "2027-06-30T13:59:59Z"
},
"periodLabelFormat": "MMM YYYY"
};

function findRcsReportConfig(reports) {
for (let i=0; i<reports.length; i++) {
if (reports[i].activityType == 'Regional Capacity Services Report') {
return reports[i];
}
}
return null;
}
db.organisation.find({'config.organisationReports':{$exists:true}}).forEach(function(org){
let rcsReportConfig = findRcsReportConfig(org.config.organisationReports);
if (!rcsReportConfig) {
return;
}
// Adjust the target config to match the period in which the RCS reporting is happening.
targetsConfig.periodGenerationConfig.periodStart = rcsReportConfig.periodStart;
targetsConfig.periodGenerationConfig.periodEnd = rcsReportConfig.periodEnd;

org.config.targets = targetsConfig;

//org.config.serviceTargets = serviceTargetsConfig;
print("updating organisation "+org.name+' , id: '+org.organisationId);
db.organisation.replaceOne({organisationId:org.organisationId}, org);
audit(org, org.organisationId, 'au.org.ala.ecodata.Organisation', adminUserId, undefined, 'Update');
});
3 changes: 1 addition & 2 deletions src/main/scripts/utils/addService.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("../../../utils/uuid.js");
load( "../../../utils/audit.js");

function addService (newServiceName, legacyId, serviceFormName, sectionName, outputs, userId) {
var eventType;
legacyId = NumberInt(legacyId);
Expand Down

0 comments on commit 4eb5c56

Please sign in to comment.