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' into dev
  • Loading branch information
xKeCo committed Dec 2, 2024
2 parents c1708d6 + c2da92c commit c6539c4
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ 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 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ 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;
});
console.log(this.eoisData);
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
61 changes: 40 additions & 21 deletions onecgiar-pr-client/src/app/shared/services/export-tables.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,29 +256,44 @@ export class ExportTablesService {

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}`;
}
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');

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_achieved_narrative: indicator.indicator_achieved_narrative ?? 'Not defined',
indicator_supporting_results: supportingResults
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 @@ -345,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 c6539c4

Please sign in to comment.