Skip to content

PRD: Revenue report by time range

ModuleReportsPRD IDPRD-SLS-002
StatusReady to devFEATSLS
EpicPlaneBANA-1516
Date2026-06-05Versionv0.1
Packages@nx/saleURDSLS
SurfaceClient · Owner/MgrBO · Ops
OwnerPhá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

MetricTarget / signal
Data accuracy100% of revenue figures grouped by Month or Year match the cumulative sum of the daily reports within the same range
Response timeReports return quickly for date ranges spanning up to 2 years of order history
UI ExperienceThe chart automatically adjusts axis label spacing and formatting to prevent overlapping text based on the number of results

4. Personas & Use Cases

PersonaGoal in this feature
OwnerView the current year's revenue grouped by Month to analyze high/low seasons and compare monthly performances
ManagerView 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

#RequirementURD ref
FR-1Date range picker on UI supports Quick Presets and Custom RangeURD-ACC-002
FR-2User can toggle the Group By interval (Day, Month, Year) on the UIURD-SLS-006
FR-3The report accepts a start date, an end date, and a grouping selection (Day, Month, or Year) as inputsURD-SLS-006
FR-4The report returns an overall cumulative summary for the whole range plus a breakdown for each period according to the chosen groupingURD-SLS-006
FR-5Calculations include only completed orders belonging to the user's own merchantURD-ACC-001, URD-ACC-003
FR-6Dashboard interface updates charts (bar/line) and data table according to the chosen group intervalURD-SLS-006
FR-7Empty result sets render cumulative zero totals instead of throwing errorsURD-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

AreaRequirement
Tenancy & SecurityScope every report strictly to the user's own merchant; never expose data belonging to another merchant
PerformanceReports must remain responsive even over large historical order volumes, avoiding full data scans
i18nTime-period labels automatically localize based on the user's active language preference (e.g., "Tháng 01/2026" vs "January 2026")
TimezoneApply day and period boundaries consistently using the merchant's local timezone to ensure correct aggregation

8. UX & Flows

9. Data & Domain

EntityRole
Sales orderThe 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 questionMitigation / status
Slow report loading over large historical order volumesEnsure the data layer is optimized so large ranges still return promptly without full scans
Overlapping text labels on the chartThe interface dynamically calculates and offsets tick display intervals on the X-axis based on result density

12. Release Plan & Launch Criteria

AspectPlan
PhaseSLS P2 increment - periodic revenue reports
RolloutAvailable to all merchants
MigrationNo data migration required (read-only aggregation over existing records)
Launch criteriaAll 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

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.