Guides

Recompute after a change

Refresh a category's stored summary after a change, so the app's shop page agrees at once, and read the fresh summary in the same call.

You rarely need it

Every figure the API answers with is worked out when you read it, from the category's newest report, its settings, its suppliers and its exceptions as they stand at that moment. A change made through the API or in the app shows on the next read of the reorder points (the level that triggers a new order), the order list or the stop-stocking list, with no recompute.

What a recompute refreshes is the category's stored summary: the sales, the sales you missed and the waste that the app's shop page shows. Call it after a change when a person is about to look at the shop page and should see the new summary at once:

  • after you changed a category's settings with PATCH /v1/categories/{id};
  • after you changed a supplier's delivery days or the categories it delivers.

A new report needs no recompute. The upload works the category out as part of filing it.

Recompute and read the summary

The call answers with the fresh summary, so one call does both:

curl -X POST https://panlytics.net/api/v1/categories/40/recompute \
  -H "Authorization: Bearer $PANLYTICS_KEY"

It needs See the figures in that category. A category with no report answers 409 report.none.

What it does not do

  • It does not change any setting, and it does not change any figure the other endpoints answer with.
  • It does not place an order. Panlytics tells you what to order; ordering stays with you.
  • It needs no Idempotency-Key: running it twice gives the same summary.