Skip to content

Commit fc7a09f

Browse files
authored
PnP: Walk up to find the latest available cumulative summary (#3084)
Fixes cumulative being extracted as zero, but last fiscal year is 100% (or any percent)
1 parent 086435f commit fc7a09f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/components/progress-summary/progress-summary.extractor.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ProgressSummaryExtractor {
1818
return {
1919
reportPeriod: summaryFrom(yearRow, quarterCol, quarterCol),
2020
fiscalYear: summaryFrom(yearRow, ...sheet.columnsForFiscalYear),
21-
cumulative: summaryFrom(yearRow, ...sheet.columnsForCumulative),
21+
cumulative: findLatestCumulative(yearRow),
2222
};
2323
}
2424
}
@@ -32,6 +32,21 @@ const findFiscalYearRow = (sheet: ProgressSheet, fiscalYear: number) => {
3232
throw new Error('Unable to find fiscal year in pnp file');
3333
};
3434

35+
const findLatestCumulative = (currentYear: Row<ProgressSheet>) => {
36+
const { sheet } = currentYear;
37+
// eslint-disable-next-line no-constant-condition
38+
while (true) {
39+
const summary = summaryFrom(currentYear, ...sheet.columnsForCumulative);
40+
if (summary) {
41+
return summary;
42+
}
43+
currentYear = currentYear.move(-1);
44+
if (currentYear < sheet.summaryFiscalYears.start.row) {
45+
return null;
46+
}
47+
}
48+
};
49+
3550
const summaryFrom = (
3651
fiscalYear: Row<ProgressSheet>,
3752
plannedColumn: Column,

0 commit comments

Comments
 (0)