CPG-CRM FSD Invoice

FSD — Admin CRM

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

Doc IDCPG-FSD-CPG-CRM_FSD_Invoice
VersionPhiên bản1.0
StatusTrạng tháiDraft
OwnerCPG BA / Architecture
AudienceĐối tượngFrontend, Backend, FlyPay Support, QA, Product
ClassificationPhân loạiInternal
Effective dateNgày hiệu lực01/12/2026
Related docs Admin CRM Index · BR/NFR Catalog

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

1. Module Scope

The Invoices Module enables merchants to view, search, manage, and export invoices generated from crypto payment transactions (QR Code, Checkout Link, API Payment).

The module supports:

  • Invoice listing with advanced filters
  • Invoice detail view (read-only)
  • Invoice status tracking (Paid, Pending, Overdue, Cancelled)
  • Exporting invoices to CSV / Excel / PDF
  • Mapping invoices to orders, services, and transactions

2. User Roles

Role

Permissions

System Admin

Full access to invoice list, detail, and export

Finance Manager

View invoices, export data

Support Agent

View invoice details for support purposes

3. Functional Requirements

3.1 Features

F1. Invoice List View

Description: Displays a paginated list of invoices generated by the system.

Displayed Fields

  • Invoice Number
  • Order ID
  • Merchant
  • Service Type (QR Code / Checkout Link / API Payment)
  • Customer Email
  • Amount (with currency)
  • Invoice Status
  • Invoice Date
  • Due Date

Capabilities

  • Pagination
  • Sort by Invoice Date (default descending)
  • Click Invoice Number to open detail view

F2. Advanced Invoice Filters

Filter Criteria

  • Merchant
  • Account (All Accounts / specific account)
  • Order ID
  • Invoice Number
  • Service
  • Invoice Status
  • From Date
  • To Date

Rules

  • Filters can be combined
  • Date range is applied to Invoice Date
  • Empty filters return all invoices

F3. Invoice Detail View

Description
Displays full invoice information in a printable, read-only format.

Sections

  1. Header
    • Invoice Number
    • Invoice Status (Paid / Pending / Overdue / Cancelled)
  2. Merchant Information
    • Merchant Name
    • Merchant ID
    • Blockchain Network
  3. Billing Information
    • Customer Email
  4. Invoice Metadata
    • Order ID
    • Invoice Date
    • Due Date
    • Paid Date (if applicable)
  5. Invoice Items
    • Item Description
    • Quantity
    • Unit Price
    • Line Total
  6. Summary
    • Subtotal
    • Tax
    • Total Amount
  7. Notes (optional)

Rules

  • Invoice content is immutable after generation
  • Status badge color reflects current state

F4. Invoice Status Management (System-Driven)

Supported Statuses

  • Paid
  • Pending
  • Overdue
  • Cancelled

Behavior

  • Status is automatically updated based on:
    • Payment confirmation
    • Due date expiration
    • Transaction cancellation
  • Manual status changes are not allowed

F5. Export Invoices

Supported Formats

  • CSV
  • Excel
  • PDF

Export Scope

  • Current filtered result set
  • Includes invoice summary data

Rules

  • Export respects applied filters
  • PDF export formats invoices in printable layout

3.2 Use Cases

Detailed use-case catalog for this module is maintained under 08_UC:Catalog use case chi tiết của module này được quản lý tại 08_UC:

4. User Interface

Screens

  1. Invoice List Page

    • Filters section
    • Invoice table
    • Export buttons (CSV / Excel / PDF)
  1. Invoice Detail

    • Printable invoice layout
    • Status badge
    • Amount summary

UI Rules

  • Invoice Number and Order ID are clickable
  • Status uses color indicators:
    • Paid (Green)
    • Pending (Yellow)
    • Overdue (Red)
    • Cancelled (Gray)

5. Data Requirements

5.1 Data Dictionary

invoices

Field

Type

Description

invoice_id

UUID

Primary key

invoice_number

VARCHAR

Human-readable invoice number

merchant_id

UUID

Merchant identifier

account_id

UUID

Linked account

order_id

VARCHAR

Order reference

service_type

ENUM

QR_CODE / CHECKOUT_LINK / API_PAYMENT

customer_email

VARCHAR

Customer email

blockchain

VARCHAR

Blockchain network

currency

VARCHAR

Token symbol (USDT, USDC, etc.)

subtotal_amount

DECIMAL

Subtotal

tax_amount

DECIMAL

Tax amount

total_amount

DECIMAL

Total invoice amount

status

ENUM

Invoice status

invoice_date

DATE

Invoice creation date

due_date

DATE

Payment due date

paid_date

DATE

Payment date (nullable)

notes

TEXT

Optional notes

created_at

TIMESTAMP

Record creation

updated_at

TIMESTAMP

Last update

invoice_items

Field

Type

Description

item_id

UUID

Primary key

invoice_id

UUID

Parent invoice

description

VARCHAR

Item description

quantity

INT

Quantity

unit_price

DECIMAL

Unit price

total_price

DECIMAL

Line total

5.2 Data Models

Entity Relationships

  • merchants (1) - (N) invoices
  • invoices (1) - (N) invoice_items
  • Invoices (1) - (N) transactions

Enums

InvoiceStatus

  • PAID
  • PENDING
  • OVERDUE
  • CANCELLED

ServiceType

  • QR_CODE
  • CHECKOUT_LINK
  • API_PAYMENT

6. API Routes

Base path: /api/v1

Invoice APIs

Method

Route

Purpose

Notes

GET

/invoices

Get invoice list

Supports filters & pagination

GET

/invoices/{id}

Get invoice detail

Read-only

GET

/invoices/export

Export invoices

Format: csv / excel / pdf

GET

/invoices/{id}/pdf

Download invoice PDF

Printable layout

E. ReferencesE. Tham chiếu