bhima icon indicating copy to clipboard operation
bhima copied to clipboard

Add bespoke routes for assets

Open jniles opened this issue 3 years ago • 1 comments

As mentioned in https://github.com/IMA-WorldHealth/bhima/pull/6432#discussion_r819188418 , our stock routes are somewhat over-loaded. For assets, for example, we probably do not need to know the weighted average cost, nor the average monthly consumption. Skipping those would increase performance generally, ensuring MySQL does not lock tables, and make things a bit more transparent.

I propose that we add a bespoke route for assets stock/assets that will load in assets with their required information, without passing through the getLots() function or getDepotLots() function. This will make it easier to debug the assets routes.

ALSO regarding the stock assignment server functions (from @jmcameron)

In https://github.com/IMA-WorldHealth/bhima/pull/6432, I've moved the lot assignments route into server/controllers/assign.js but retained the old /lot/:uuid/assign/:depot_uuid route. It should be updated to use one the 'list'/getStockAssignments() assignment CRUD path.

It does not appear that we are using the deleteAssignment() CRUD function anywhere but in the tests. Should we keep it around?

jniles avatar Mar 04 '22 16:03 jniles

Note: This was partly done in PR 6505 by adding the getAssets() function in core.js. Since Assets are really lots, it is not clear that this needs to be done in a separate file with full CRUD, etc?

Also, note that this function is called from the server side so there is no route for it. So that should probably be done.

jmcameron avatar Apr 11 '22 07:04 jmcameron