So, I have an erp endpoint which parses purchase order and then does some pre processing before returning the response. Now, I would like to generate a receipt from the purchase order post data. The question here is 1. Storing the purchase data on my end seems redundant as every company using the system has their DB. 2. Considering, I want to scale is there an approach I can take to generate receipt on the fly or may be use a staging table. I am using ERPnext. What would be a good design considering receipt generation shouldn't cause latency to the requests response thread of the purchase order API endpoint.
1 Answers
My Understanding: Request comes to ERP endpoint, which then led to pre processing and then response is sent. You want to also print receipt now without effecting latency of the API response.
Solution: Once you have your pre processing done, you can then save it in a DB with status as pending and return the response. Now in a different thread you can keep looking for DB changes and print receipt for any of the data which has status as pending and then delete the processed record.
Now why save it in DB as you can directly pass the newly parsed data to the Async method too? You can actually just pass the processed data to an ansyc method which will not wait for printing to be completed and will return the response but in case you meet an error or has any downtime it's a good idea to store the required data to be processed in case of a multi-server/single server hosting.

- 110
- 9