Admin CRM — Invoice Use Cases

A. Document controlA. Kiểm soát tài liệu

Doc IDCPG-UC-CPG-CRM_UC_Invoice
VersionPhiên bản1.0
StatusTrạng tháiDraft
OwnerCPG BA / Architecture
AudienceĐối tượngBA, QA, Product, Frontend, Backend
ClassificationPhân loạiInternal
Effective dateNgày hiệu lực01/12/2026
Related docs CRM Invoice TC · CRM Invoice FSD

B. Version historyB. Lịch sử phiên bản

Version Date Author ChangesThay đổi
1.0 01/12/2026 Khoa Trinh Version 1.0

C. Table of contentsC. Mục lục

D. ContentD. Nội dung

Catalog

UC ID Name Linked TC count Categories
UC-INV-ACCESS Sidebar hides Invoices without invoice:view 6 Security
UC-INV-F1 Default list load shows invoices sorted by invoice date DESC 7 Function
UC-INV-F2 Changing filters without Search does not reload list 10 Function, Validation
UC-INV-F4 Click Invoice Number opens detail modal 10 Function
UC-INV-F5 Status badges use correct colors on list 2 Function
UC-INV-F6 Export CSV downloads with applied filters 5 Function, NFR
UC-INV-NAV List merchant name navigates to merchant detail 3 Function
UC-INV-ERR List API failure shows toast and empty list 5 Function, Security
UC-INV-ADMIN Unfiltered Admin list spans multiple merchants 3 Function

Use cases

UC-INV-ACCESS — Sidebar hides Invoices without invoice:view

  • Actor: Admin CRM user (role per RBAC)
  • Goal: Sidebar hides Invoices without invoice:view
  • Primary BR (from TC): API-Invoice-Admin; invoice:view

Linked test cases

  • TC-CRM-INV-001 — Sidebar hides Invoices without invoice:view (Security)
  • TC-CRM-INV-002 — Route /invoices requires invoice:view (Security)
  • TC-CRM-INV-003 — Tab read deny shows no-access message (Security)
  • TC-CRM-INV-004 — Export buttons hidden for view-only user (Security)
  • TC-CRM-INV-005 — Detail Download PDF hidden for view-only user (Security)
  • TC-CRM-INV-006 — Manage without view cannot open invoices route (Security)

Representative preconditions

Signed in as Admin-NoInvoice.

Representative main flow

  1. Open Admin CRM after sign-in.
  2. Inspect the left sidebar menu.

Expected outcome

Invoices menu item is not visible. Direct navigation to /invoices is blocked by PermissionGuard (redirect away from invoices).

UC-INV-F1 — Default list load shows invoices sorted by invoice date DESC

  • Actor: Admin CRM user (role per RBAC)
  • Goal: Default list load shows invoices sorted by invoice date DESC
  • Primary BR (from TC): F1; INV-LIST-02

Linked test cases

  • TC-CRM-INV-007 — Default list load shows invoices sorted by invoice date DESC (Function)
  • TC-CRM-INV-008 — Page size is 10 and footer shows entry range (Function)
  • TC-CRM-INV-009 — Empty list shows empty state (Function)
  • TC-CRM-INV-010 — Pagination next/prev navigates pages with applied filters (Function)
  • TC-CRM-INV-011 — List columns render required Admin fields (Function)
  • TC-CRM-INV-012 — Row # is pagination-aware (Function)
  • TC-CRM-INV-013 — Loading state shown while list request in flight (Function)

Representative preconditions

Admin-Manage. ≥11 invoices.

Representative main flow

  1. Note # values on page 1.
  2. Go to page 2.
  3. Note # values.

Expected outcome

Page 1 # values are 1–10. Page 2 starts at 11 (startIndex + index + 1).

UC-INV-F2 — Changing filters without Search does not reload list

  • Actor: Admin CRM user (role per RBAC)
  • Goal: Changing filters without Search does not reload list
  • Primary BR (from TC): F2; INV-FILTER-08

Linked test cases

  • TC-CRM-INV-014 — Changing filters without Search does not reload list (Function)
  • TC-CRM-INV-015 — Search by Order ID filters list (Function)
  • TC-CRM-INV-016 — Search by Invoice Number filters list (Function)
  • TC-CRM-INV-017 — Status filter maps UI label to API enum (Function)
  • TC-CRM-INV-018 — From Date after To Date blocks Search (Validation)
  • TC-CRM-INV-019 — Valid date range filters by invoice date (Function)
  • TC-CRM-INV-020 — Merchant filter sends UUID not business code (Function)
  • TC-CRM-INV-021 — Combined filters and clear merchant restore broader list (Function)
  • TC-CRM-INV-022 — Merchant autocomplete requires min 2 characters (Function)
  • TC-CRM-INV-023 — Empty filters after Search returns all invoices (Function)

Representative preconditions

Admin-Manage. Known invoice_code e.g. INV000001.

Representative main flow

  1. Enter INV000001 in Invoice Number.
  2. Click Search.

Expected outcome

Matching invoice(s) returned. API query uses invoice_id=INV000001.

UC-INV-F4 — Click Invoice Number opens detail modal

  • Actor: Admin CRM user (role per RBAC)
  • Goal: Click Invoice Number opens detail modal
  • Primary BR (from TC): F4; INV-LIST-03

Linked test cases

  • TC-CRM-INV-024 — Click Invoice Number opens detail modal (Function)
  • TC-CRM-INV-025 — Click Order ID opens same detail modal (Function)
  • TC-CRM-INV-026 — Detail modal is read-only (Function)
  • TC-CRM-INV-027 — Paid Date shown only for Paid invoices (Function)
  • TC-CRM-INV-028 — Detail shows line items with # and totals including discount (Function)
  • TC-CRM-INV-029 — Bill To shows customer name and email (Function)
  • TC-CRM-INV-030 — From section shows Merchant ID link only (Function)
  • TC-CRM-INV-031 — Notes section appears when notes present (Function)
  • TC-CRM-INV-032 — Detail refresh banner while GET detail in flight (Function)
  • TC-CRM-INV-040 — Modal Download PDF fetches single invoice PDF (Function)

Representative preconditions

Admin-Manage. List has a row with order id.

Representative main flow

  1. Click Order ID on a row.

Expected outcome

Same invoice detail modal opens for that invoice.

UC-INV-F5 — Status badges use correct colors on list

  • Actor: Admin CRM user (role per RBAC)
  • Goal: Status badges use correct colors on list
  • Primary BR (from TC): F5; INV-LIST-05; INV-DETAIL-03

Linked test cases

  • TC-CRM-INV-033 — Status badges use correct colors on list (Function)
  • TC-CRM-INV-034 — No manual status change control on Admin UI (Function)

Representative preconditions

Admin-Manage. Samples of Paid, Pending, Overdue, Cancelled.

Representative main flow

  1. Locate each status in the list.
  2. Compare badge styling.

Expected outcome

Paid=green, Pending=yellow, Overdue=red, Cancelled=gray. Detail badge matches list status for the same invoice.

UC-INV-F6 — Export CSV downloads with applied filters

  • Actor: Admin CRM user (role per RBAC)
  • Goal: Export CSV downloads with applied filters
  • Primary BR (from TC): F6; INV-EXPORT-01; INV-EXPORT-03

Linked test cases

  • TC-CRM-INV-035 — Export CSV downloads with applied filters (Function)
  • TC-CRM-INV-036 — Export Excel downloads with applied filters (Function)
  • TC-CRM-INV-037 — Export PDF (list) downloads with applied filters (Function)
  • TC-CRM-INV-038 — Async export 202 polls then downloads file (NFR)
  • TC-CRM-INV-039 — Starting second export aborts in-flight export (NFR)

Representative preconditions

Admin-Manage. Filters applied (e.g. date range).

Representative main flow

  1. Apply filters and Search.
  2. Click Export Excel.

Expected outcome

Spreadsheet download succeeds. Filename sanitized from Content-Disposition when provided. Respects applied filters.

UC-INV-NAV — List merchant name navigates to merchant detail

  • Actor: Admin CRM user (role per RBAC)
  • Goal: List merchant name navigates to merchant detail
  • Primary BR (from TC): API-Invoice-Admin

Linked test cases

  • TC-CRM-INV-041 — List merchant name navigates to merchant detail (Function)
  • TC-CRM-INV-042 — Detail Merchant ID link closes modal and opens merchant (Function)
  • TC-CRM-INV-043 — Breadcrumb Home navigates to dashboard (Function)

Representative preconditions

Admin-Manage on /invoices.

Representative main flow

  1. Click Home in breadcrumb.

Expected outcome

Navigates to /dashboard.

UC-INV-ERR — List API failure shows toast and empty list

  • Actor: Admin CRM user (role per RBAC)
  • Goal: List API failure shows toast and empty list
  • Primary BR (from TC): F1

Linked test cases

  • TC-CRM-INV-044 — List API failure shows toast and empty list (Function)
  • TC-CRM-INV-045 — Detail 404 shows Invoice not found toast (Function)
  • TC-CRM-INV-046 — Detail non-404 error shows failure toast (Function)
  • TC-CRM-INV-047 — Export API 403 surfaces error toast (Security)
  • TC-CRM-INV-048 — Merchant search failure clears options silently (Function)

Representative preconditions

Admin-Manage. Detail GET returns 500.

Representative main flow

  1. Open detail while API errors.

Expected outcome

Toast “Failed to load invoice detail.” (or API message).

UC-INV-ADMIN — Unfiltered Admin list spans multiple merchants

  • Actor: Admin CRM user (role per RBAC)
  • Goal: Unfiltered Admin list spans multiple merchants
  • Primary BR (from TC): API-Invoice-Admin

Linked test cases

  • TC-CRM-INV-049 — Unfiltered Admin list spans multiple merchants (Function)
  • TC-CRM-INV-050 — Admin can open detail for another merchant invoice (Function)
  • TC-CRM-INV-051 — Admin export without merchant filter can include cross-merchant rows (Function)

Representative preconditions

Admin overlay live. Invoice owned by Merchant-B visible in list.

Representative main flow

  1. Open detail for Merchant-B invoice.

Expected outcome

Detail loads successfully (not 404 ownership hide). Merchant ID links to Merchant-B detail.

E. ReferencesE. Tham chiếu