{"action":"created","issue":{"url":"https://api.github.com/repos/18F/cms-hitech-apd/issues/1051","repository_url":"https://api.github.com/repos/18F/cms-hitech-apd","labels_url":"https://api.github.com/repos/18F/cms-hitech-apd/issues/1051/labels{/name}","comments_url":"https://api.github.com/repos/18F/cms-hitech-apd/issues/1051/comments","events_url":"https://api.github.com/repos/18F/cms-hitech-apd/issues/1051/events","html_url":"https://github.com/18F/cms-hitech-apd/pull/1051","id":370820643,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIzNDEyMjQ2","number":1051,"title":"Round everything to whole dollars when calculating budgets","user":{"login":"mgwalker","id":1775733,"node_id":"MDQ6VXNlcjE3NzU3MzM=","avatar_url":"https://avatars3.githubusercontent.com/u/1775733?v=4","gravatar_id":"","url":"https://api.github.com/users/mgwalker","html_url":"https://github.com/mgwalker","followers_url":"https://api.github.com/users/mgwalker/followers","following_url":"https://api.github.com/users/mgwalker/following{/other_user}","gists_url":"https://api.github.com/users/mgwalker/gists{/gist_id}","starred_url":"https://api.github.com/users/mgwalker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgwalker/subscriptions","organizations_url":"https://api.github.com/users/mgwalker/orgs","repos_url":"https://api.github.com/users/mgwalker/repos","events_url":"https://api.github.com/users/mgwalker/events{/privacy}","received_events_url":"https://api.github.com/users/mgwalker/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-10-16T22:10:44Z","updated_at":"2018-10-26T22:52:14Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/18F/cms-hitech-apd/pulls/1051","html_url":"https://github.com/18F/cms-hitech-apd/pull/1051","diff_url":"https://github.com/18F/cms-hitech-apd/pull/1051.diff","patch_url":"https://github.com/18F/cms-hitech-apd/pull/1051.patch"},"body":"When calculating all the budget values, rounds everything to whole dollars while making sure we maintain the original sums so everything should check out.  This is only used where we deal with percents:\r\n\r\n- we sum up total costs for each funding source (HIE, HIT, MMIS), by cost category (personnel, contractor, non-personnel)\r\n- we compute the federal and state shares of the totals\r\n  - this is computed by subtracting any other funding amount and then using the percentages the user provided in the cost allocation section: `(total - other) * percent`\r\n  - we use our magic rounding method on this one, to guarantee that the federal + state shares will always sum to the total\r\n- we compute what percent each cost category contributes to the total\r\n  - the values provided by the user implicitly include part of the \"other funding\" amount\r\n  - this percent is `category-amount / total`\r\n  - the cost categories contribute the same percentage to the federal and state shares as computed above\r\n- we compute the federal and state shares of the individual cost categories\r\n  - we use our magic rounding again, this time to take the total share and spread it across the cost categories, based on what percentage each one contributed to the total\r\n  - e.g., `federal-total * state-personnel-percent` would be the federal share of state personnel costs\r\n\r\nUses a slight modification of the [largest remainder method](https://en.wikipedia.org/wiki/Largest_remainder_method)\r\n\r\nCloses #788.  There's a change identified at the end of the conversation in #788 that we should capture elsewhere, but that one will require keeping track of the Medicaid grand total, which is the original grand total minus any other funding.  I think that already exists in the code, we just need to make sure it goes out to the rest of the app, and some of our tables will need to be adjusted to use it.\r\n\r\n### This pull request changes...\r\n- Maybe no visible changes?  Maybe some.  It really depends on whether the numbers you've put in resulted in any weird rounding situations.  😄\r\n\r\n### This pull request is ready to merge when...\r\n- [ ] Tests have been updated (and all tests are passing)\r\n- [ ] This code has been reviewed by someone other than the original author"},"comment":{"url":"https://api.github.com/repos/18F/cms-hitech-apd/issues/comments/433563737","html_url":"https://github.com/18F/cms-hitech-apd/pull/1051#issuecomment-433563737","issue_url":"https://api.github.com/repos/18F/cms-hitech-apd/issues/1051","id":433563737,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMzU2MzczNw==","user":{"login":"cms-eapd-bot","id":39502791,"node_id":"MDQ6VXNlcjM5NTAyNzkx","avatar_url":"https://avatars2.githubusercontent.com/u/39502791?v=4","gravatar_id":"","url":"https://api.github.com/users/cms-eapd-bot","html_url":"https://github.com/cms-eapd-bot","followers_url":"https://api.github.com/users/cms-eapd-bot/followers","following_url":"https://api.github.com/users/cms-eapd-bot/following{/other_user}","gists_url":"https://api.github.com/users/cms-eapd-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/cms-eapd-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cms-eapd-bot/subscriptions","organizations_url":"https://api.github.com/users/cms-eapd-bot/orgs","repos_url":"https://api.github.com/users/cms-eapd-bot/repos","events_url":"https://api.github.com/users/cms-eapd-bot/events{/privacy}","received_events_url":"https://api.github.com/users/cms-eapd-bot/received_events","type":"User","site_admin":false},"created_at":"2018-10-26T22:52:14Z","updated_at":"2018-10-26T22:52:14Z","author_association":"NONE","body":"See this pull request in action: http://pr1051.hitech.eapd.cms.gov.s3-website-us-east-1.amazonaws.com/"}}
{"actor":{"display_login":"cms-eapd-bot"}}