Skip to content

Statistics

service_omni — Endpoints: Statistics

Location: backend/service_omni/app/api/v1/endpoints/statistics.py

Base path: /api/v1/omni/statistics

Summary

  • Shopping table — populate from Google Sheets + cron
  • Profit / Plenty & Amazon — daily cron for orders, retours, and Amazon FBA sync; manual triggers

Shopping table

Method Route Description
POST /populate Manual sync from Google Sheets → shopping_table
GET /cron/status Shopping table cron status
POST /cron/start?cron_expression=… Start/update shopping table cron (default 0 3 * * *)
POST /cron/stop Stop shopping table cron

shopping_table is also the purchase-history source for Plenty stock valuation (POST /api/v1/plenty/stock/import-from-shopping-table). See Plenty service and Patch 1.11.0.


Profit cron (Plenty orders, retours & Amazon)

Used by Statistics → Profit tab. Job name in DB: plenty_orders_cron.

Method Route Description
GET /profit/cron/status Cron active state, schedule, last/next run
POST /profit/cron/start?cron_expression=… Start/update profit cron (default 0 6 * * *)
POST /profit/cron/stop Stop profit cron
POST /profit/populate Manual trigger: fetch yesterday's Plenty sales orders only

What the profit cron runs (plenty_orders_runner)

Each scheduled execution:

  1. Retry pending Plenty orders — re-fetch unpaid orders from plenty_pending_orders (up to 7 days)
  2. Yesterday's Plenty sales orders — enrich buy / fee / profit, upsert plenty_orders
  3. Yesterday's Plenty retours — store plenty_retours, backfill & mark parent orders (has_retour)
  4. Yesterday's Amazon FBA orders — sync all configured marketplaces; enrich buy / fee / profit
  5. Yesterday's Amazon FBA returnsamazon_returns + mark matching amazon_orders.has_retour

Manual imports (UI or direct API) complement the cron:

Data Manual API UI control (Profit tab)
Plenty sales orders (range) POST /plenty/orders/range Plenty Orders Import
Plenty retours (range) POST /plenty/retours/range Plenty Returns Import
Amazon FBA orders (range) POST /amazon/orders/sync Amazon FBA Orders Import
Amazon FBA returns (range) POST /amazon/returns/sync Amazon FBA Returns Import

Full behaviour (formulas, batching, Analysis): Profit imports, order economics & Analysis.

Also see Plenty endpoints, Amazon endpoints, and Plenty orders & retours data model.


Legacy / summary routes

Some lightweight summary routes may exist for dashboards. Prefer the cron and populate endpoints above for operational use.

Implementation