Skip to content

Commit

Permalink
[PnP] Fix regression finding latest cumulative summary (#3353)
Browse files Browse the repository at this point in the history
Regressed with #3324

Since that PR changed the `summaryFrom` to always return an object with zeros, this check on line 64 failed.
Updated to check to ignore zeros, or fallback to returning zeros.

Regrettably this would've been caught had this eslint rule been enabled:
https://github.com/SeedCompany/cord-api-v3/blob/79875d5134689bf979bfd42a73d6b7c430a2ff2c/.eslintrc.cjs#L190-L191
  • Loading branch information
CarsonF authored Feb 12, 2025
1 parent e90e011 commit 4558689
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/progress-summary/progress-summary.extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ const findLatestCumulative = (currentYear: Row<ProgressSheet>) => {
// eslint-disable-next-line no-constant-condition
while (true) {
const summary = summaryFrom(currentYear, ...sheet.columnsForCumulative);
if (summary) {
if (summary.planned > 0 || summary.actual > 0) {
return summary;
}
currentYear = currentYear.move(-1);
if (currentYear < sheet.summaryFiscalYears.start.row) {
return null;
return summary;
}
}
};
Expand All @@ -75,7 +75,7 @@ const summaryFrom = (
fiscalYear: Row<ProgressSheet>,
plannedColumn: Column,
actualColumn: Column,
): Progress => {
) => {
let planned = fiscalYear.cell(plannedColumn).asNumber ?? 0;
let actual = fiscalYear.cell(actualColumn).asNumber ?? 0;
const normalize = (val: number) => {
Expand All @@ -88,7 +88,7 @@ const summaryFrom = (
};
planned = normalize(planned);
actual = normalize(actual);
return { planned, actual };
return { planned, actual } satisfies Progress;
};

const MismatchedReportingQuarter = PnpProblemType.register({
Expand Down

0 comments on commit 4558689

Please sign in to comment.