Fix the mismatch between headers and rows #2197
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes in this PR
In certain circumstances, such as when a report has forecasts but no actual spend, there is an extra column for the data that is not matched to a header.
The reason the extra column shows up is due to the data structures used for the actuals and variance, which will always return a hash with keys and values, even if the values are not meaningful (empty arrays or zero values).
We cannot simply filter out empty arrays or zero values, because they can be meaningful in other contexts, such as when there are some nil or zero values in some quarters, but they are surrounded by quarters with non-zero values, so we have to include them.
The simplest solution is to trust the logic of the headers generation, and not attempt to compute actuals or variance for reports where the app has already determined there are no actuals or variance to display.
Screenshots of UI changes
N/A
Next steps
CHANGELOG.md
, unless this PR is a small tweak which has no impact outside the development team.