{"action":"created","comment":{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/comments/65864841","id":65864841,"diff_hunk":"@@ -53,6 +53,6 @@\n </div>\n \n <div class=\"modal-footer\">\n-  <button class=\"btn btn-default btn-sm\" ng-click=\"ReceiptCtrl.close()\">Close</button>\n-  <button class=\"btn btn-primary btn-sm\" ng-click=\"ReceiptCtrl.print()\"><span class=\"glyphicon glyphicon-print\"></span> Print</button>\n+  <button class=\"btn btn-default btn-sm\" ng-click=\"ReceiptCtrl.close()\" data-action=\"close\">Close</button>","path":"client/src/js/services/receipts/modal/receiptModal.tmpl.html","position":6,"original_position":6,"commit_id":"5f14215479d775c04b4ce783a39c7f7b75c23085","original_commit_id":"5f14215479d775c04b4ce783a39c7f7b75c23085","user":{"login":"sfount","id":2844572,"avatar_url":"https://avatars.githubusercontent.com/u/2844572?v=3","gravatar_id":"","url":"https://api.github.com/users/sfount","html_url":"https://github.com/sfount","followers_url":"https://api.github.com/users/sfount/followers","following_url":"https://api.github.com/users/sfount/following{/other_user}","gists_url":"https://api.github.com/users/sfount/gists{/gist_id}","starred_url":"https://api.github.com/users/sfount/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfount/subscriptions","organizations_url":"https://api.github.com/users/sfount/orgs","repos_url":"https://api.github.com/users/sfount/repos","events_url":"https://api.github.com/users/sfount/events{/privacy}","received_events_url":"https://api.github.com/users/sfount/received_events","type":"User","site_admin":false},"body":"These should eventually be translated. I believe this was first introduced by @sfount.","created_at":"2016-06-06T09:56:28Z","updated_at":"2016-06-06T09:56:28Z","html_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/462#discussion_r65864841","pull_request_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/462","_links":{"self":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/comments/65864841"},"html":{"href":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/462#discussion_r65864841"},"pull_request":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/462"}}},"pull_request":{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/462","id":72468110,"html_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/462","diff_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/462.diff","patch_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/462.patch","issue_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/462","number":462,"state":"open","locked":false,"title":"Refactor: Patient Invoice services","user":{"login":"jniles","id":896472,"avatar_url":"https://avatars.githubusercontent.com/u/896472?v=3","gravatar_id":"","url":"https://api.github.com/users/jniles","html_url":"https://github.com/jniles","followers_url":"https://api.github.com/users/jniles/followers","following_url":"https://api.github.com/users/jniles/following{/other_user}","gists_url":"https://api.github.com/users/jniles/gists{/gist_id}","starred_url":"https://api.github.com/users/jniles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jniles/subscriptions","organizations_url":"https://api.github.com/users/jniles/orgs","repos_url":"https://api.github.com/users/jniles/repos","events_url":"https://api.github.com/users/jniles/events{/privacy}","received_events_url":"https://api.github.com/users/jniles/received_events","type":"User","site_admin":false},"body":"This pull request refactors the Patient Invoice module.  The goals of this refactor were:\r\n 1. Clearly separate logic and validation of the PatientInvoiceForm\r\n 2. Re-implement caching (it was broken in master) of form data.\r\n 3. Rename and use existing services, and remove duplicates.\r\n 4. Make sure tests work.\r\n\r\nAll the points above have been addressed.  Here are some extra improvements:\r\n 1. I've unit-tested the `Store` service, and implemented a new `Pool` service (see below).\r\n 2. The resizing bug on the totals footer has been fixed - the tree now broadcasts an event when it changes state.  However,  calculated width is not quite correct yet.\r\n 3. The PatientInvoice grid has three validation states:\r\n  1. Uninitialized (warning) - no inventory item selected\r\n  2. Invalid (danger) - invalid prices or quantities\r\n  3. Valid (success) - everything correct\r\n 4. No more `$watch()` calls on the grid.  The grid uses `ngChange` to re-calculate totals and validation states.  This is much more efficient.\r\n 5. No more `gulp lint` errors.\r\n\r\nThe `PatientInvoiceController` now creates a new `PatientInvoiceForm`.  The task of setting the patient, setting the service, and calculating totals is completely contained in the `PatientInvoiceForm` service.\r\n\r\nThe `PatientInvoiceForm` houses the `ui-grid` rows in a store.  The rows are instances of the `PatientInvoiceItem` service.  Each row is responsible for its own validation and state, and provides methods to apply a patient's price list and configure a row with a new inventory item.\r\n\r\n**New Class: Pool**\r\nInventory Items should only be used once.  Previously, the `Invoice` service used two separate stores to model this, manually removing items from an \"available\" store and putting them in an \"unavailable\" store.  I've created a `Pool` service to formalize this behavior.\r\n\r\n_Usage_\r\n```js\r\n// the pool constructor takes in an id property and a data array.\r\n// if not provided, these will default to 'id', and an empty array\r\nvar pool = new Pool('id', [{ id: 1 }, { id : 2 }]);\r\n\r\n// pool.use(id) removes the id from the \"available\" pool and returns the object\r\nvar firstObject = pool.use(1);  // => { id : 1 }\r\n\r\n// calling pool.use(1) a second time will return nothing\r\nvar duplicate = pool.use(1)  // => null\r\n\r\n// to return the object to the pool, call pool.release(id)\r\npool.release(1);\r\n\r\n// you can now find id : 1 again in the pool\r\npool.use(1);   // => { id : 1 }\r\n```\r\nFor a more detailed usage, see the tests.\r\n\r\n**Todos**\r\n 1. Determine if Billing Services, Price Lists, and/or Subsidies are all percentages.  If so, we can simply logic.\r\n 2. Subsidies should not be able to exceed the amount of the bill.  There is currently no logic for this.\r\n 3. Billing Services and Subsidies should be ignored for specific debtor groups (conventions, etc).  There isn't any logic for this yet.\r\n 4. Should the Patient Invoice page alert a user of a pre-existing caution?  If so, how?\r\n 5. More complete testing of the above scenarios.\r\n\r\n\r\n---\r\nThank you for contributing!\r\n\r\nBefore submitting this pull request, please verify that you have:\r\n - [x] Run your code through JSHint.  [Check out our styleguide](https://github.com/IMA-WorldHealth/bhima-2.X/blob/master/docs/STYLEGUIDE.md).\r\n - [x] Run integration tests.\r\n - [x] Run end-to-end tests.\r\n - [x] Accurately described the changes your are making in this pull request.\r\n\r\nFor a more detailed checklist, [see the official review checklist](https://docs.google.com/document/d/1nupLVLRXgSZJQo_acLgrwvPnN8RukfSiwRhSToj81uU/pub) that this PR will be evaluated against.\r\n\r\nEnsuring that the above checkboxes are completed will help speed the review process and help build a stronger application.  Thanks!","created_at":"2016-06-03T08:02:20Z","updated_at":"2016-06-06T09:56:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8ae0213cff6007fbbb6df2d985479d433d0e2dd4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/462/commits","review_comments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/462/comments","review_comment_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/comments{/number}","comments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/462/comments","statuses_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/statuses/5f14215479d775c04b4ce783a39c7f7b75c23085","head":{"label":"jniles:refactor-patient-invoice-services","ref":"refactor-patient-invoice-services","sha":"5f14215479d775c04b4ce783a39c7f7b75c23085","user":{"login":"jniles","id":896472,"avatar_url":"https://avatars.githubusercontent.com/u/896472?v=3","gravatar_id":"","url":"https://api.github.com/users/jniles","html_url":"https://github.com/jniles","followers_url":"https://api.github.com/users/jniles/followers","following_url":"https://api.github.com/users/jniles/following{/other_user}","gists_url":"https://api.github.com/users/jniles/gists{/gist_id}","starred_url":"https://api.github.com/users/jniles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jniles/subscriptions","organizations_url":"https://api.github.com/users/jniles/orgs","repos_url":"https://api.github.com/users/jniles/repos","events_url":"https://api.github.com/users/jniles/events{/privacy}","received_events_url":"https://api.github.com/users/jniles/received_events","type":"User","site_admin":false},"repo":{"id":49059888,"name":"bhima-2.X","full_name":"jniles/bhima-2.X","owner":{"login":"jniles","id":896472,"avatar_url":"https://avatars.githubusercontent.com/u/896472?v=3","gravatar_id":"","url":"https://api.github.com/users/jniles","html_url":"https://github.com/jniles","followers_url":"https://api.github.com/users/jniles/followers","following_url":"https://api.github.com/users/jniles/following{/other_user}","gists_url":"https://api.github.com/users/jniles/gists{/gist_id}","starred_url":"https://api.github.com/users/jniles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jniles/subscriptions","organizations_url":"https://api.github.com/users/jniles/orgs","repos_url":"https://api.github.com/users/jniles/repos","events_url":"https://api.github.com/users/jniles/events{/privacy}","received_events_url":"https://api.github.com/users/jniles/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jniles/bhima-2.X","description":"A fresh start for bhima to remove large commits","fork":true,"url":"https://api.github.com/repos/jniles/bhima-2.X","forks_url":"https://api.github.com/repos/jniles/bhima-2.X/forks","keys_url":"https://api.github.com/repos/jniles/bhima-2.X/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jniles/bhima-2.X/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jniles/bhima-2.X/teams","hooks_url":"https://api.github.com/repos/jniles/bhima-2.X/hooks","issue_events_url":"https://api.github.com/repos/jniles/bhima-2.X/issues/events{/number}","events_url":"https://api.github.com/repos/jniles/bhima-2.X/events","assignees_url":"https://api.github.com/repos/jniles/bhima-2.X/assignees{/user}","branches_url":"https://api.github.com/repos/jniles/bhima-2.X/branches{/branch}","tags_url":"https://api.github.com/repos/jniles/bhima-2.X/tags","blobs_url":"https://api.github.com/repos/jniles/bhima-2.X/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jniles/bhima-2.X/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jniles/bhima-2.X/git/refs{/sha}","trees_url":"https://api.github.com/repos/jniles/bhima-2.X/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jniles/bhima-2.X/statuses/{sha}","languages_url":"https://api.github.com/repos/jniles/bhima-2.X/languages","stargazers_url":"https://api.github.com/repos/jniles/bhima-2.X/stargazers","contributors_url":"https://api.github.com/repos/jniles/bhima-2.X/contributors","subscribers_url":"https://api.github.com/repos/jniles/bhima-2.X/subscribers","subscription_url":"https://api.github.com/repos/jniles/bhima-2.X/subscription","commits_url":"https://api.github.com/repos/jniles/bhima-2.X/commits{/sha}","git_commits_url":"https://api.github.com/repos/jniles/bhima-2.X/git/commits{/sha}","comments_url":"https://api.github.com/repos/jniles/bhima-2.X/comments{/number}","issue_comment_url":"https://api.github.com/repos/jniles/bhima-2.X/issues/comments{/number}","contents_url":"https://api.github.com/repos/jniles/bhima-2.X/contents/{+path}","compare_url":"https://api.github.com/repos/jniles/bhima-2.X/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jniles/bhima-2.X/merges","archive_url":"https://api.github.com/repos/jniles/bhima-2.X/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jniles/bhima-2.X/downloads","issues_url":"https://api.github.com/repos/jniles/bhima-2.X/issues{/number}","pulls_url":"https://api.github.com/repos/jniles/bhima-2.X/pulls{/number}","milestones_url":"https://api.github.com/repos/jniles/bhima-2.X/milestones{/number}","notifications_url":"https://api.github.com/repos/jniles/bhima-2.X/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jniles/bhima-2.X/labels{/name}","releases_url":"https://api.github.com/repos/jniles/bhima-2.X/releases{/id}","deployments_url":"https://api.github.com/repos/jniles/bhima-2.X/deployments","created_at":"2016-01-05T10:44:42Z","updated_at":"2016-04-20T10:58:44Z","pushed_at":"2016-06-06T09:29:00Z","git_url":"git://github.com/jniles/bhima-2.X.git","ssh_url":"git@github.com:jniles/bhima-2.X.git","clone_url":"https://github.com/jniles/bhima-2.X.git","svn_url":"https://github.com/jniles/bhima-2.X","homepage":null,"size":4323,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"IMA-WorldHealth:master","ref":"master","sha":"c6b2bd61348e34caf38c857b620acd867922fb4f","user":{"login":"IMA-WorldHealth","id":5330583,"avatar_url":"https://avatars.githubusercontent.com/u/5330583?v=3","gravatar_id":"","url":"https://api.github.com/users/IMA-WorldHealth","html_url":"https://github.com/IMA-WorldHealth","followers_url":"https://api.github.com/users/IMA-WorldHealth/followers","following_url":"https://api.github.com/users/IMA-WorldHealth/following{/other_user}","gists_url":"https://api.github.com/users/IMA-WorldHealth/gists{/gist_id}","starred_url":"https://api.github.com/users/IMA-WorldHealth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IMA-WorldHealth/subscriptions","organizations_url":"https://api.github.com/users/IMA-WorldHealth/orgs","repos_url":"https://api.github.com/users/IMA-WorldHealth/repos","events_url":"https://api.github.com/users/IMA-WorldHealth/events{/privacy}","received_events_url":"https://api.github.com/users/IMA-WorldHealth/received_events","type":"Organization","site_admin":false},"repo":{"id":49052669,"name":"bhima-2.X","full_name":"IMA-WorldHealth/bhima-2.X","owner":{"login":"IMA-WorldHealth","id":5330583,"avatar_url":"https://avatars.githubusercontent.com/u/5330583?v=3","gravatar_id":"","url":"https://api.github.com/users/IMA-WorldHealth","html_url":"https://github.com/IMA-WorldHealth","followers_url":"https://api.github.com/users/IMA-WorldHealth/followers","following_url":"https://api.github.com/users/IMA-WorldHealth/following{/other_user}","gists_url":"https://api.github.com/users/IMA-WorldHealth/gists{/gist_id}","starred_url":"https://api.github.com/users/IMA-WorldHealth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IMA-WorldHealth/subscriptions","organizations_url":"https://api.github.com/users/IMA-WorldHealth/orgs","repos_url":"https://api.github.com/users/IMA-WorldHealth/repos","events_url":"https://api.github.com/users/IMA-WorldHealth/events{/privacy}","received_events_url":"https://api.github.com/users/IMA-WorldHealth/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/IMA-WorldHealth/bhima-2.X","description":"A fresh start for bhima to remove large commits","fork":false,"url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X","forks_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/forks","keys_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/teams","hooks_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/hooks","issue_events_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/events{/number}","events_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/events","assignees_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/assignees{/user}","branches_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/branches{/branch}","tags_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/tags","blobs_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/git/refs{/sha}","trees_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/statuses/{sha}","languages_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/languages","stargazers_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/stargazers","contributors_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/contributors","subscribers_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/subscribers","subscription_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/subscription","commits_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/commits{/sha}","git_commits_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/git/commits{/sha}","comments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/comments{/number}","issue_comment_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/comments{/number}","contents_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/contents/{+path}","compare_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/merges","archive_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/downloads","issues_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues{/number}","pulls_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls{/number}","milestones_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/milestones{/number}","notifications_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/labels{/name}","releases_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/releases{/id}","deployments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/deployments","created_at":"2016-01-05T08:30:30Z","updated_at":"2016-05-25T12:28:41Z","pushed_at":"2016-06-06T09:31:14Z","git_url":"git://github.com/IMA-WorldHealth/bhima-2.X.git","ssh_url":"git@github.com:IMA-WorldHealth/bhima-2.X.git","clone_url":"https://github.com/IMA-WorldHealth/bhima-2.X.git","svn_url":"https://github.com/IMA-WorldHealth/bhima-2.X","homepage":null,"size":4600,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":92,"forks":6,"open_issues":92,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/462"},"html":{"href":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/462"},"issue":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/462"},"comments":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/462/comments"},"review_comments":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/462/comments"},"review_comment":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/462/commits"},"statuses":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/statuses/5f14215479d775c04b4ce783a39c7f7b75c23085"}}}}
{"actor":{"display_login":"sfount"}}