Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4503 Update the budget to calculate totals for match rates #4606

Merged
merged 27 commits into from
Mar 24, 2023

Conversation

amyd11
Copy link
Contributor

@amyd11 amyd11 commented Mar 15, 2023

Resolves #4503

Description

These backend changes update the budget for MMIS to include new fields in the MMIS budget (ddi and mando) and remove unused fields.

Significant changes or possible side effects

  • Model updates
    • MMIS budget model
      • Removed federalShareByFFYQuarter and mmisByFFP fields
      • Added ddi and mando fields
    • Altered activities in the default budget model to remove quarterlyFFP key, so it’s no longer part of the default budget or MMIS budgets, but is now unique to HITECH
  • Added a migration file to handle MMIS budget changes. This will find all existing MMIS budgets, recalculate the budget and replace the existing budget with the newly calculated one
  • Updated seed file with new values for costAllocation
  • Added constant FUNDING_CATEGORY_TYPE_KEY_LOOKUP so we can find the key name of the funding source to save budget data
  • Moved some test input data into common/untils/test-data directory, which we may or may not want to continue doing. It shortens the file and makes the tests a little easier to navigate, however it visually separates the input data from the test
  • Calculate budget changes
    • Added a couple switch statements to compartmentalize sections of the calculateBudget code that pertains to specific APD types
    • Abstracted code to add values to the highest level 'combined' key of the budget into its own function (sumShareCostsForCombinedTotals). This will make it easier when/if we end up removing the mmis key from MMIS in the future because then we can call this function from elsewhere (currently it’s getting called from the function calculating mmis).
    • Added function sumShareCostsForFundingCategory to populate values inside the funding category keys (ddi, & mando)
    • Renamed defaultQuarterlyFFPObject to defaultActivitiesFFPObject since it no longer contains the quarterlyFFP data and added defaultHITECHActivitiesFFPObject which still contains the quarterlyFFP key

Automated test cases written

Given When Then Type (jest, tap, cypress)
defaultActivitiesFFPObject with no years matches default object with zeroed values jest
defaultActivitiesFFPObject with years matches default object containing years with zeroed values jest
sumShareCostsForCombinedTotals no values passed in empty object is returned jest
sumShareCostsForCombinedTotals values passed in adds values to the combined totals for the year and overall total jest
sumShareCostsForFundingCategory no values passed in empty object is returned jest
sumShareCostsForFundingCategory values passed in but funding category is null returns original budget unchanged when there is no fundingCategory jest
sumShareCostsForFundingCategory values passed in updates budget with new values for each cost category's year and total *includes lots of assertions to check each individual calculation jest

Steps to manually verify this change

  1. In the browser go to an MMIS APD, then open dev tools.
  2. Open dev tools network tab to find the APD data being returned
  3. Look at the budget object
  4. The mmis key should remain unchanged
  5. There should be no federalShareByFFYQuarter or mmisByFFP keys
  6. There should be both ddi and mando keys following the general structure
  ddi: {
    "90-10": {
      statePersonnel: {
        "2023": {
          total: 0,
          federal: 0,
          medicaid: 0,
          state: 0,
        },
        "2024": {
          total: 0,
          federal: 0,
          medicaid: 0,
          state: 0,
        },
        total: {
          total: 0,
          federal: 0,
          medicaid: 0,
          state: 0,
        },
      },
      contractors: {...},
      expenses: {...},
      combined: {
        "2023": {
          total: 0,
          federal: 0,
          medicaid: 0,
          state: 0,
        },
        "2024": {
          total: 0,
          federal: 0,
          medicaid: 0,
          state: 0,
        },
        total: {
          total: 0,
          federal: 0,
          medicaid: 0,
          state: 0,
        },
      },
    },
    "75-25": {...},
    "50-50": {...},
    combined: {...},
  },
  mando: {...}
}
  1. When the APD contains at least one activity, the activities key will be broken up by activity id and then should contain costsByFFY, but NOT contain quarterlyFFP. When no activities, it's an empty object.
"activities": {
  "152a1e2b": {
    "_id": "6413536ee8d2331a391fe5a5",
    "costsByFFY": {
      "2023": {
        "federal": 2924848,
        "medicaid": 3249831,
        "state": 324983,
        "total": 3354831
      },
      "2024": {
        "federal": 1428184,
        "medicaid": 1904245,
        "state": 476061,
        "total": 1904245
      },
      "total": {
        "federal": 4353032,
        "medicaid": 5154076,
        "state": 801044,
        "total": 5259076
      }
    }
  }
}
  1. Checking calculations can be tedious, but use this test as a reference
  2. HITECH budget should remain unchanged.

This pull request is ready to code review when

  • Automated tests are updated (and all tests are passing)
  • New automated test cases are documented above
  • Chromatic link added above
  • Pull request has been labeled, if applicable with feature, content, bug,
    tests, refactor
  • Associated OpenAPI documentation has been updated
  • The experience passes a basic manual accessibility audit (keyboard nav,
    screenreader, text scaling) OR an exemption is documented

This pull request is ready to test when

  • Code has been reviewed by someone other than the original author

This pull request is ready to review when QA has

  • Verified the functionality related to the change
  • Verified that the change works with Narrator on Windows
  • Verified that the change works with VoiceOver on Mac
  • Verified all updated pages with the WAVE tool
  • Verified tab and keyboard navigation functionality

This pull request can be merged when

  • Design has approved the experience
  • Product has approved the experience

@amyd11 amyd11 self-assigned this Mar 15, 2023
@codecov
Copy link

codecov bot commented Mar 15, 2023

Codecov Report

Merging #4606 (ca760cb) into main (c5ac1e4) will decrease coverage by 0.04%.
The diff coverage is 96.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4606      +/-   ##
==========================================
- Coverage   94.33%   94.29%   -0.04%     
==========================================
  Files         274      276       +2     
  Lines        8704     8771      +67     
  Branches     1751     1749       -2     
==========================================
+ Hits         8211     8271      +60     
- Misses        469      476       +7     
  Partials       24       24              
Flag Coverage Δ
api ∅ <ø> (∅)
common 99.33% <96.51%> (-0.67%) ⬇️
web 94.02% <100.00%> (-0.06%) ⬇️
Impacted Files Coverage Δ
e2e/cypress/helpers/mmis/mmis-navigation.js 86.48% <ø> (ø)
common/utils/budget.js 99.19% <96.20%> (-0.81%) ⬇️
common/utils/constants.js 100.00% <100.00%> (ø)
common/utils/test-data/calculateBudget.js 100.00% <100.00%> (ø)
...utils/test-data/sumShareCostsForFundingCategory.js 100.00% <100.00%> (ø)
...es/apd/executive-summary/ExecutiveSummaryBudget.js 85.71% <100.00%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c5ac1e4...ca760cb. Read the comment docs.

@amyd11 amyd11 force-pushed the ad/4503-budget-match-rates branch from 624aa72 to 8b4220a Compare March 15, 2023 16:36
@cms-eapd-bot
Copy link

cms-eapd-bot commented Mar 15, 2023

See this pull request in action: https://ec2-3-215-45-51.compute-1.amazonaws.com

ca760cb

@amyd11 amyd11 marked this pull request as ready for review March 16, 2023 18:25
@amyd11 amyd11 requested review from thetif, tbolt and Sun-Mountain March 16, 2023 18:25
Copy link
Contributor

@thetif thetif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for tackling this big ticket. And I'm very impressed that you were able to do it in 13 files, most of which are tests.

There is an issue though the format isn't exactly what we need. We need to separate everything by fed-state split too because the tables that we are working on next need them split up like that, see:
Proposed Budget
Executive Summary

I also wanted to make sure you were storing medicaid, federal, state, and total for all of these new fields.

Just need a little more work, but amazing job so far.

const fundingCategory = 'mando';
const year = '2023';
const expected = {
mando: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment above, we need to be storing these values grouped by split type

* },
* mando: {
* statePersonnel: {...}, contractors: {...}, expenses: {...}, combined: {...}
* // see getDefaultFundingSourceByCategoryObject for details
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see message above about nesting under the fed-state split

const stateShare = costCategoryShare.stateShare[costCategory];

// add to costCategory for the particular year (for particular funding category)
updatedBudget[fundingCategory][costCategory][year].total += costTotal;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is where we also need to store it under fed-state split, it should be

updatedBudget[fundingCategory][fedSplit][costCategory][year].total += costTotal;

all the way down, whenever there is [fundingCategory] it should be followed by [fedSplit]

// - key state personnel
// - structure of activities key broken up by activity id
// - funding source
switch (apdType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great idea

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ agreed

@amyd11 amyd11 requested a review from thetif March 21, 2023 17:10
@amyd11 amyd11 changed the title Ad/4503 budget match rates 4503 Update the budget to calculate totals for match rates Mar 22, 2023
Copy link
Contributor

@thetif thetif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Thanks for resolving the previous comments so quickly! This was a big one and it's impressive that you were able to get it done in so few files.

total: {
medicaid: 1010,
federal: 909,
state: 101
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is total being stored too? or is that calculated somewhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, total.total (and the year.totals) are being added via sumTotalCostsByCategory. Do you think there's a better name for the function to help clarify?

Copy link
Contributor

@tbolt tbolt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work

// - key state personnel
// - structure of activities key broken up by activity id
// - funding source
switch (apdType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ agreed

@mirano-darren mirano-darren self-requested a review March 23, 2023 12:55
Copy link
Contributor

@mirano-darren mirano-darren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, well done tackling the budget!

Copy link
Contributor

@jeromeleecms jeromeleecms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing much for me to review here - passes Dev/Quality/Automated Testing - good to go on my end.

@amyd11 amyd11 merged commit a0a75f6 into main Mar 24, 2023
@amyd11 amyd11 deleted the ad/4503-budget-match-rates branch March 24, 2023 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Update the budget to calculate totals for match rates
6 participants