Skip to content

Commit

Permalink
Merge branch 'P2-903-Tracking-of-outcomes-achievements-against-target…
Browse files Browse the repository at this point in the history
…s' of https://github.com/AllianceBioversityCIAT/onecgiar_pr into P2-903-Tracking-of-outcomes-achievements-against-targets
  • Loading branch information
German Martinez committed Dec 2, 2024
2 parents b0d0fff + 51bc442 commit d1ab46e
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ <h1 class="indicator_title">
<app-pr-field-header label="Cumulative value achieved by end of 2024" [required]="true"></app-pr-field-header>
<p-inputNumber
[(ngModel)]="this.indicatorData.achieved_in_2024"
[inputStyle]="{ width: '44px' }"
[inputStyle]="{ width: '103px' }"
[min]="0"
[max]="999999999999999"
placeholder="100"
[readonly]="isSubmitted"></p-inputNumber>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ export class OutcomeIndicatorHomeComponent {

exportIndicatorsToExcel() {
const wscolsEOIs = [
{ header: 'Outcome name', key: 'toc_result_title', width: 50 },
{ header: 'Indicator name', key: 'indicator_name', width: 50 },
{ header: 'Outcome', key: 'toc_result_title', width: 50 },
{ header: 'Indicator', key: 'indicator_name', width: 50 },
{ header: 'Indicator Type', key: 'indicator_type', width: 50 },
{ header: 'Expected target', key: 'expected_target', width: 22 },
{ header: 'Actual target achieved', key: 'actual_target_achieved', width: 30 },
{ header: 'Achieved status', key: 'achieved_status', width: 22 },
{ header: 'Reporting status', key: 'reporting_status', width: 22 }
{ header: 'Reporting status', key: 'reporting_status', width: 22 },
{ header: 'Narrative', key: 'indicator_achieved_narrative', width: 50 },
{ header: 'Supporting results', key: 'indicator_supporting_results', width: 60 }
];

const wscolsWPs = [
Expand All @@ -40,7 +42,9 @@ export class OutcomeIndicatorHomeComponent {
{ header: 'Expected target', key: 'expected_target', width: 22 },
{ header: 'Actual target achieved', key: 'actual_target_achieved', width: 30 },
{ header: 'Achieved status', key: 'achieved_status', width: 22 },
{ header: 'Reporting status', key: 'reporting_status', width: 22 }
{ header: 'Reporting status', key: 'reporting_status', width: 22 },
{ header: 'Narrative', key: 'indicator_achieved_narrative', width: 50 },
{ header: 'Supporting results', key: 'indicator_supporting_results', width: 60 }
];

this.exportTablesSE.exportOutcomesIndicatorsToExcel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ export class OutcomeIndicatorService {
this.loading.set(true);
this.api.resultsSE.GET_contributionsToIndicatorsEOIS(this.initiativeIdFilter).subscribe({
next: res => {
this.eoisData = res?.data;
this.eoisData = res?.data.map(item => {
if (item.indicators === null) {
item.indicators = [];
}
return item;
});
this.loading.set(false);
},
error: error => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe('ExportTablesService', () => {
month = '0' + month;
}

const dateCET = month + day + year;
const dateCET = year + month + day;

const timeCET = dateCETTime.split(',')[1].trim().replace(':', '').slice(0, 4);

Expand Down
64 changes: 47 additions & 17 deletions onecgiar-pr-client/src/app/shared/services/export-tables.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ export class ExportTablesService {
indicatorType = `${prefix} ${data.indicators[0]?.indicator_name}`;
}

const supportingResults = !data.indicators[0]?.indicator_supporting_results
? 'Not defined'
: data.indicators[0]?.indicator_supporting_results.map(item => `• ${item.result_type} ${item.result_code} - ${item.result_title}`).join('\n');

worksheet.addRow({
toc_result_title: data.toc_result_description ?? 'Not defined',
indicator_name: data.indicators[0]?.indicator_description ?? 'Not defined',
Expand All @@ -244,30 +248,52 @@ export class ExportTablesService {
achieved_status: this.outcomeIService.achievedStatus(data.indicators[0]?.indicator_target_value, data.indicators[0]?.indicator_achieved_value)
? 'Yes'
: 'No',
reporting_status: data.indicators[0]?.indicator_submission_status ? 'Submitted' : 'Editing'
reporting_status: data.indicators[0]?.indicator_submission_status ? 'Submitted' : 'Editing',
indicator_achieved_narrative: data.indicators[0]?.indicator_achieved_narrative ?? 'Not defined',
indicator_supporting_results: supportingResults
});
}

private addWPSRow(worksheet: ExcelJS.Worksheet, data: any) {
data.toc_results.forEach(result => {
result.indicators.forEach(indicator => {
let indicatorType = 'Not defined';
if (indicator.indicator_name) {
const prefix = indicator.is_indicator_custom ? 'Custom - ' : 'Standard - ';
indicatorType = `${prefix} ${indicator.indicator_name}`;
}

if (result.indicators.length > 0) {
result.indicators.forEach(indicator => {
let indicatorType = 'Not defined';
if (indicator.indicator_name) {
const prefix = indicator.is_indicator_custom ? 'Custom - ' : 'Standard - ';
indicatorType = `${prefix} ${indicator.indicator_name}`;
}
const supportingResults = !indicator.indicator_supporting_results
? 'Not defined'
: indicator.indicator_supporting_results.map(item => `• ${item.result_type} ${item.result_code} - ${item.result_title}`).join('\n');

worksheet.addRow({
workpackage_name: `${data.workpackage_short_name}: ${data.workpackage_name}`,
toc_result_description: result.toc_result_description ?? 'Not defined',
indicator_name: indicator.indicator_description ?? 'Not defined',
indicator_type: indicatorType,
expected_target: indicator.indicator_target_value ?? 'Not defined',
actual_target_achieved: indicator.indicator_achieved_value ?? 'Not defined',
achieved_status: this.outcomeIService.achievedStatus(indicator.indicator_target_value, indicator.indicator_achieved_value) ? 'Yes' : 'No',
reporting_status: indicator.indicator_submission_status ? 'Submitted' : 'Editing',
indicator_achieved_narrative: indicator.indicator_achieved_narrative ?? 'Not defined',
indicator_supporting_results: supportingResults
});
});
} else {
worksheet.addRow({
workpackage_name: `${data.workpackage_short_name}: ${data.workpackage_name}`,
toc_result_description: result.toc_result_description ?? 'Not defined',
indicator_name: indicator.indicator_description ?? 'Not defined',
indicator_type: indicatorType,
expected_target: indicator.indicator_target_value ?? 'Not defined',
actual_target_achieved: indicator.indicator_achieved_value ?? 'Not defined',
achieved_status: this.outcomeIService.achievedStatus(indicator.indicator_target_value, indicator.indicator_achieved_value) ? 'Yes' : 'No',
reporting_status: indicator.indicator_submission_status ? 'Submitted' : 'Editing'
indicator_name: 'Not defined',
indicator_type: 'Not defined',
expected_target: 'Not defined',
actual_target_achieved: 'Not defined',
achieved_status: 'No',
reporting_status: 'Editing',
indicator_achieved_narrative: 'Not defined',
indicator_supporting_results: 'Not defined'
});
});
}
});
}

Expand Down Expand Up @@ -334,8 +360,12 @@ export class ExportTablesService {
day: '2-digit',
...(includeTime && { hour: '2-digit', minute: '2-digit' })
};
const formatted = date.toLocaleString('en-US', options).replace(/[/,:\s]/g, '');
return includeTime ? formatted.slice(0, 8) + '_' + formatted.slice(8, 12) + 'cet' : formatted.slice(0, 8);
const formatted = date.toLocaleString('en-GB', options).replace(/[/,:\s]/g, '');
let formattedDate = formatted.slice(4, 8) + formatted.slice(2, 4) + formatted.slice(0, 2);
if (includeTime) {
formattedDate += '_' + formatted.slice(8, 12) + (isIPSR ? 'cet' : '');
}
return formattedDate;
};

const saveFile = (suffix: string) => {
Expand Down

0 comments on commit d1ab46e

Please sign in to comment.