Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Story card:** None - bug fix ## Because Needed to refactor monthIndexFromDateKey() function. This will be needed in a follow up PR that fixes a bug on the dashed lines of the overdue chart ## This addresses Refactor complete plus some additional work to simplify the goal lines functionality and make it easier to follow Changes: - goalPeriodValue() renamed to getThreeMonthAverageAndImprovementRatio() - improvement ratio is calculated inside the getThreeMonthAverageAndImprovementRatio() rather than passing data around - simplified check for isEndMonthOfYear() (previously named isLastDateKeysArrayMonthDec) - improved variable naming - monthIndexFromDateKey() uses built in javascript function - calculateGoalUpwards() and calculateGoalDownwards() have parameter names that match the data being passed (monthValue -> threeMonthAverage) - correction to how the remaining months in the year is calculated: ``` const monthsRemainingForYear = monthThreeIndex === 11 ? 12 : 11 - monthThreeIndex; ``` ## Test instructions Switch between this branch and the current master branch to check that the figures are the same. Note: there was a previous miscalculation on the goal lines. When checking the figures are the same there might be a small chance 'this branch/PR' shows a figure that is 1% less than that shows on the current master. This is correct - the master was +0.0083 higher than it should have been after running the calculations. Figures are rounded so there should be no change unless it crosses to the next integer. To view the goal lines add the commented line to your reports.js file ``` const enabledRegions = { IN: ["state"], // add this line <- BD: ["organization", "state", "district"], ET: ["organization", "state"], LK: ["organization"], }; ``` the line for copying ``` IN: ["state"], ``` --------- Co-authored-by: Priyanga P Kini <[email protected]>
- Loading branch information