PRD: Revenue report by time range
| Module | Reports | PRD ID | PRD-SLS-002 |
| Status | Ready to dev | FEAT | SLS |
| Epic | — | Plane | BANA-1516 |
| Date | 2026-06-05 | Version | v0.1 |
| Packages | @nx/sale | URD | SLS |
| Surface | Client · Owner/MgrBO · Ops | ||
| Owner | Phát Nguyễn | ||
TL;DR
Group revenue by Day, Month, or Year over any date range, with a trend chart and a detailed breakdown table - so owners can read the long view, not just a flat daily list.
1. Context & Problem
Owners and managers need to read revenue across longer intervals - months, quarters, years - not just the daily flat list of PRD-SLS-001. That longer view is what drives financial and marketing planning.
Today the system only groups sales by individual calendar day. Over a long window - 6 months, a year, several years - daily rows overflow the table and chart markers crowd into unreadable noise.
The fix: let users group by Day, Month, or Year, so the same data reads cleanly at both the detail and the macro level.
2. Goals & Non-Goals
Goals
- Flexible date range: quick presets (Today, Yesterday, This Week, Last Week, This Month, Last Month, This Quarter, This Year, Last Year) or a custom range.
- Selectable grouping: toggle between Day, Month, and Year.
- Interactive chart: a bar or line chart of net-revenue and order-count trends at the chosen interval.
- Detailed table: one row per period (group by Month → one row per month) showing gross revenue, discounts, tax, net revenue, and order count, with a sticky totals row.
- Scope & accuracy: confined to the user's own merchant, only completed orders, day boundaries in the merchant's local timezone.
Non-Goals
- Detailed cost and profit margin breakdowns (owned by advanced analytics
ADV). - Exporting reports to Excel/PDF formats (owned by advanced analytics
ADV).
3. Success Metrics
| Metric | Target / signal |
|---|---|
| Data accuracy | 100% of revenue figures grouped by Month or Year match the cumulative sum of the daily reports within the same range |
| Response time | Reports return quickly for date ranges spanning up to 2 years of order history |
| UI Experience | The chart automatically adjusts axis label spacing and formatting to prevent overlapping text based on the number of results |
4. Personas & Use Cases
| Persona | Goal in this feature |
|---|---|
| Owner | View the current year's revenue grouped by Month to analyze high/low seasons and compare monthly performances |
| Manager | View the current quarter's revenue grouped by Day/Month to reconcile figures and draft periodic reports |
Core scenarios: User accesses the Reporting Dashboard -> Selects the filter range (e.g., last 12 months) -> Toggles grouping to Month -> The system aggregates the data -> The screen renders a trend chart of the 12 months and a detailed data table showing 12 corresponding rows with a summary row at the bottom.
5. User Stories
- As an owner, I want to see revenue summaries grouped by month so that I can easily identify seasonal business trends.
- As a manager, I want to toggle the aggregation grouping interval between day, month, or year depending on the active date range, so that I am not overwhelmed by unnecessary granular details.
- As a developer, I want the system to compute grouped totals before returning them rather than transferring every individual order, to reduce network load and keep page loads fast.
6. Functional Requirements
| # | Requirement | URD ref |
|---|---|---|
| FR-1 | Date range picker on UI supports Quick Presets and Custom Range | URD-ACC-002 |
| FR-2 | User can toggle the Group By interval (Day, Month, Year) on the UI | URD-SLS-006 |
| FR-3 | The report accepts a start date, an end date, and a grouping selection (Day, Month, or Year) as inputs | URD-SLS-006 |
| FR-4 | The report returns an overall cumulative summary for the whole range plus a breakdown for each period according to the chosen grouping | URD-SLS-006 |
| FR-5 | Calculations include only completed orders belonging to the user's own merchant | URD-ACC-001, URD-ACC-003 |
| FR-6 | Dashboard interface updates charts (bar/line) and data table according to the chosen group interval | URD-SLS-006 |
| FR-7 | Empty result sets render cumulative zero totals instead of throwing errors | URD-ACC-004 |
Business Rules
- BR-01: Revenue is recognized by the time of completion of the order.
- BR-02: Only sales orders in completed status are aggregated.
- BR-03: Cycles with no data must still be displayed with a value of 0.
- BR-04: Data must be sorted in ascending order of time.
7. Non-Functional Requirements
| Area | Requirement |
|---|---|
| Tenancy & Security | Scope every report strictly to the user's own merchant; never expose data belonging to another merchant |
| Performance | Reports must remain responsive even over large historical order volumes, avoiding full data scans |
| i18n | Time-period labels automatically localize based on the user's active language preference (e.g., "Tháng 01/2026" vs "January 2026") |
| Timezone | Apply day and period boundaries consistently using the merchant's local timezone to ensure correct aggregation |
8. UX & Flows
9. Data & Domain
| Entity | Role |
|---|---|
| Sales order | The order record used to aggregate revenue totals (gross revenue, discounts, tax, net revenue, order count) based on each order's completion date |
10. Dependencies & Assumptions
Dependencies
- Orders (CORE-07) - Completed orders are the single source of truth for revenue calculations.
- Identity & Authz (CORE-02) - Identifies the user's own merchant from the request context.
Assumptions
- The system defaults to the merchant's local business timezone for daily/monthly/yearly groupings.
11. Risks & Open Questions
| Risk / open question | Mitigation / status |
|---|---|
| Slow report loading over large historical order volumes | Ensure the data layer is optimized so large ranges still return promptly without full scans |
| Overlapping text labels on the chart | The interface dynamically calculates and offsets tick display intervals on the X-axis based on result density |
12. Release Plan & Launch Criteria
| Aspect | Plan |
|---|---|
| Phase | SLS P2 increment - periodic revenue reports |
| Rollout | Available to all merchants |
| Migration | No data migration required (read-only aggregation over existing records) |
| Launch criteria | All grouping intervals (Day/Month/Year) return correct totals; charts and tables update smoothly |
13. FAQ
Are draft or cancelled orders included in the calculations? No, only sales orders in completed status are aggregated.
What happens if there are no sales in the selected range? The system returns zero totals and renders an empty chart, without throwing errors.
References
- URD: Reports - Sales Reports · Access & Scoping
- Module: Reports - URD
- Developer: Sale - developer docs