{"action":"created","issue":{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima/issues/764","labels_url":"https://api.github.com/repos/IMA-WorldHealth/bhima/issues/764/labels{/name}","comments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima/issues/764/comments","events_url":"https://api.github.com/repos/IMA-WorldHealth/bhima/issues/764/events","html_url":"https://github.com/IMA-WorldHealth/bhima/pull/764","id":107935928,"number":764,"title":"Feat(stock api): moves client-side processing to configurable (via HTTP) server-side database functions.","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},"labels":[{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima/labels/needs%20translation","name":"needs translation","color":"f7c6c7"},{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima/labels/requires%20db%20rebuild","name":"requires db rebuild","color":"bfdadc"},{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima/labels/requires%20npm%20install","name":"requires npm install","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-23T14:45:19Z","updated_at":"2015-10-01T15:09:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima/pulls/764","html_url":"https://github.com/IMA-WorldHealth/bhima/pull/764","diff_url":"https://github.com/IMA-WorldHealth/bhima/pull/764.diff","patch_url":"https://github.com/IMA-WorldHealth/bhima/pull/764.patch"},"body":"This pull request rewrites a lot of stock modules.  For details, see the commit messages.  Here are some of the highlights:\r\n 1. Many of the `#/stock/.../:depotId/` routes have been migrated to `#/depot/:depotId/.../` routes.  One prominent exception is the `#/stock` route itself, which needs to be change to `#/depots/`.  However, I felt this change was too large for this PR.\r\n 2. A robust inventory and depot HTTP API has been implemented to allow querying \r\n    1. Expiration dates\r\n    2. Consumption rates (both average and total)\r\n    3. Stock Levels\r\n    4. Stock donations\r\n    5. Stock Lead Times\r\n    6. And more...\r\n\r\n Most API routes take in a start and end date parameter, allowing flexible reporting.\r\n 3. Many routes removed from `uncategorised.js` to various inventory, depot, or stock controllers.\r\n\r\n### What should be done after this PR\r\n\r\n - This PR makes many of the uncategorised routes obsolete.  These, as well as obsolete translations, should be removed.\r\n - Stock Consumption Loss needs a complete redesign to be both compatible and bug-free.  There will be an issue about this shortly.\r\n - Add API tests for all documented API routes using `chai-http`.\r\n - Implement as many stock reports + dashboards as possible to determine if new API features need to added, or old ones revised.\r\n - Fully implement CRUD for all depot distributions, migrating clientside logic to serverside logic.\r\n\r\n### Bonus\r\n\r\nIf you are using `DateService` in your client controllers, please consider using `DateService.util.str()` to convert your dates to a string before passing them to the database.  This service does not yield the timezone errors that plague our dataset so far.\r\n\r\nCloses #624 "},"comment":{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima/issues/comments/144756255","html_url":"https://github.com/IMA-WorldHealth/bhima/pull/764#issuecomment-144756255","issue_url":"https://api.github.com/repos/IMA-WorldHealth/bhima/issues/764","id":144756255,"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},"created_at":"2015-10-01T15:09:30Z","updated_at":"2015-10-01T15:09:30Z","body":"@DedrickEnc this is ready for a second round of testing.  *Note that distribution loss is broken in this PR*.\r\n\r\nI would like to continue working on stock.  I think this PR fixes more bugs than it introduces, but there are still more issues to work on.  My current plan is to work on:\r\n 1. #777 -- this will allow me to clean up the depot's posting journal hooks, and introduce better error handling.\r\n 2. #766  -- after stock distribution loss is cleaned up, our depot/stock interfaces should be bug free.\r\n 3. Continue migrating to `/depots/:depotId/{{module-name}}` url scheme for everything currently in `stock/`.\r\n 4. Fully implement the stock min/max calculates we discussed together for the stock status report (it currently defaults to the `stock_min` and `stock_max` properties).\r\n 5. #779 -- this should round out the inventory features that bhima plans to support for version 1.\r\n\r\nWhat do you think?   Also interesting in hearing @sfount's opinion."}}