sales_snapshot
Compare sales performance between two periods, identify top customers and products, detect stale quotations, and receive a growth verdict.
Instructions
Report how sales are going versus the previous period, in one call.
Composes confirmed sale.order records over the last two periods into revenue/order deltas, top customers, top products (server-side aggregate over order lines), a stale-quotation count, and a growing / steady / declining verdict.
Args: period_days: Length of the comparison window in days (default 7). stale_quote_days: Age in days after which a draft/sent quotation counts as stale (default 7). top_n: Rows in the top-customers / top-products lists (default 5). timezone_offset: UTC offset for "today" (default 7 = Asia/Ho_Chi_Minh). growth_threshold_pct: Delta (%) beyond which the verdict is growing / declining (default 10). company: Optional company name (ilike) or id to scope the report. trend_weeks: Weeks of history bucketed into the weekly_revenue trend series; 0 disables the extra query (default 8).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| top_n | No | ||
| company | No | ||
| period_days | No | ||
| trend_weeks | No | ||
| timezone_offset | No | ||
| stale_quote_days | No | ||
| growth_threshold_pct | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |