Working on #738, some interesting things have been revealed. Here are some of them:
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.
If you refresh a receipt, you will notice that there are about three stages of loading:
Angular + bhima is downloaded and executed
"Shared" data (exchange rates, currencies, etc) are downloaded
The actual receipt is downloaded and the currencies are formatted appropriately.
Here's a screen shot illustrating that:
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:
Only requires two steps to load the receipt interface (combining steps 2 and 3).
Sends MUCH less data across HTTP. We only send what we need.
Should be faster, since there is no client-side logic, only templating.
Allows other modules to import receipt/invoice information by GET-ing the receipt path.
Disadvantages:
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.
Working on #738, some interesting things have been revealed. Here are some of them:
Here's a screen shot illustrating that:
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:
Disadvantages: