IMA-WorldHealth / bhima-1.X

A hospital information system for developing countries.
GNU General Public License v2.0
10 stars 14 forks source link

Proposal: Create client-side routes for receipts #815

Open jniles opened 9 years ago

jniles commented 9 years ago

Working on #738, some interesting things have been revealed. Here are some of them:

  1. There really isn't any "shared" data between the receipts. We used to download the enterprise in the shared controller, but this is not appropriate -- which enterprise do we download? In practice, it is true that every receipt so far is from the same enterprise, but, conceptually, it is impossible to know what enterprise's data to load before loading the receipt. Loading all enterprises seems wasteful.
  2. If you refresh a receipt, you will notice that there are about three stages of loading:
    1. Angular + bhima is downloaded and executed
    2. "Shared" data (exchange rates, currencies, etc) are downloaded
    3. The actual receipt is downloaded and the currencies are formatted appropriately.

Here's a screen shot illustrating that: receiptloading

I propose that we simply our receipts considerably combining steps 2 and 3 on the server, and shipping a JSON to the client that will simply be templated in. The routes would be RESTful, meaning we would have sales/:uuid --> sale invoice data, cash/:uuid --> cash aux invoice data.

Advantages:

  1. Only requires two steps to load the receipt interface (combining steps 2 and 3).
  2. Sends MUCH less data across HTTP. We only send what we need.
  3. Should be faster, since there is no client-side logic, only templating.
  4. Allows other modules to import receipt/invoice information by GET-ing the receipt path.

Disadvantages:

  1. The server might do slightly more logic -- however, given that we are reducing the size and number of HTTP requests, I assume this will actually not be the case.