CPG-CRM FSD Setting General

FSD — Admin CRM

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

Doc IDCPG-FSD-CPG-CRM_FSD_Setting_General
VersionPhiên bản1.1
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 14/01/2026 Khoa Trinh Version 1.0
1.1 02/08/2026 Khoa Trinh Version 1.1: Add document types; Security

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

D. ContentD. Nội dung

1. Module Scope

The General Settings module is responsible for managing system-wide master configurations used across the platform. These configurations define operational rules, classifications, and organizational structures that affect merchants, employees, tickets, fees, and internal workflows.

This module includes management of:

  • Merchant Tiers
  • Merchant Business Types
  • Support Ticket Categories
  • Employee Positions
  • Departments

The module is accessible only to authorized administrative users and all changes are auditable.

2. User Roles

Role

Description

System Admin

Full access to create, edit, approve, reject, and delete all general settings

Operations Admin

Create and edit settings, limited approval rights

Compliance Admin

View settings, approve/reject sensitive configurations

Read-only Admin

View-only access

3. Functional Requirements

3.1 Features

3.1.1 Merchant Tiers Management

Description: Manage merchant tier definitions including fees, limits, settlement rules, and rate limits.

Functions

  • View list of merchant tiers with status (Draft, Pending, Approved, Rejected)
  • Create new merchant tier
  • Edit existing tier (restricted for Approved tiers)
  • Submit tier for approval
  • Approve or reject tier with reason
  • Delete tier (only if not assigned to merchants)
  • View active merchant count per tier

Business Rules

  • Approved tiers cannot be deleted
  • Tier assigned to merchants cannot be deleted
  • Settlement Period format must be T+X (X = 1–31)
  • Rate limits must be positive integers
  • "Unlimited" allowed for Max Accounts

3.1.2 Merchant Business Types Management

Description: Define merchant business classifications used for onboarding, reporting, and compliance.

Functions

  • View business types list
  • Create business type
  • Edit business type
  • Delete business type (only if no merchants assigned)
  • View active merchant count

Business Rules

  • Business type names must be unique
  • Deletion is blocked if active merchants exist

3.1.3 Support Ticket Categories Management

Description: Manage categories used for classifying support tickets.

Functions

  • View ticket categories
  • Create new ticket category
  • Edit category name and description
  • Delete category (only if no tickets linked)
  • View total tickets per category

Business Rules

  • Category name must be unique
  • Categories with active tickets cannot be deleted

3.1.4 Employee Positions Management

Description: Define internal employee roles used for HR, access control, and reporting.

Functions

  • View employee positions
  • Create new position
  • Edit position details
  • Delete position (only if no employees assigned)
  • View employee count per position

Business Rules

  • Position name must be unique
  • Positions assigned to employees cannot be deleted

3.1.5 Departments Management

Description: Manage organizational departments for internal structure and reporting.

Functions

  • View departments
  • Create department
  • Edit department information
  • Delete department (only if no employees assigned)
  • View employee count per department

Business Rules

  • Department name must be unique
  • Departments with employees cannot be deleted

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

4.1 General Layout

  • Tab-based navigation:
    • Merchant Tiers

    • Merchant Business Types

    • Document Types

    • Support Ticket Categories

    • Employee Positions

    • Departments

  • Search bar per tab
  • Card-based layout displaying key information
  • Action icons: Edit, Delete
  • "Add" action button per tab

4.2 Merchant Tier Add/Edit Screen

  • Sections:
    • Basic Information
    • Fee Structure
    • Limits & Configuration
    • Rate Limiting
    • Valid From
  • Actions:
    • Save Changes
    • Cancel
    • Submit for Approval
    • Approve / Reject (role-based)

5. Data Requirements

5.1 Data Dictionary

tiers

Field

Type

Description

id

UUID

Unique tier identifier

name

String

Tier name

description

String

Tier description

monthly_fee

Decimal

Monthly subscription fee

chargeback_fee_percent

Decimal

Chargeback percentage

chargeback_fee_fixed

Decimal

Fixed chargeback fee

settlement_fee_percent

Decimal

Settlement fee percentage

settlement_fee_fixed

Decimal

Fixed settlement fee

settlement_period

String

Settlement delay (T+X)

max_accounts

Integer/String

Max accounts or "Unlimited"

rate_limit_sec

Integer

Requests per second

rate_limit_min

Integer

Requests per minute

rate_limit_hour

Integer

Requests per hour

status

Enum

Draft, Pending, Approved, Rejected

valid_from

DateTime

Effective start date

approved_by

UUID

Approver user ID

approved_at

DateTime

Approval timestamp

BusinessType / TicketCategory / Position / Department (Common Fields)

Field

Type

Description

id

UUID

Unique identifier

name

String

Entity name

description

String

Description

status

Enum

Active, Inactive

created_at

DateTime

Creation timestamp

updated_at

DateTime

Last update timestamp

5.2 Data Models

Relationships

  • Merchant -> tiers (Many-to-One)
  • Merchant -> BusinessType (Many-to-One)
  • Ticket -> TicketCategory (Many-to-One)
  • Employee -> Position (Many-to-One)
  • Employee -> Department (Many-to-One)

Enums

  • TierStatus: Draft, Pending, Approved, Rejected
  • GeneralStatus: Active, Inactive

6. API Routes

Base path: /api/v1/settings

Method

Route

Purpose

Notes

GET

/merchant-tiers

List merchant tiers

Supports search & pagination

POST

/merchant-tiers

Create merchant tier

Status = Draft

PUT

/merchant-tiers/{id}

Update merchant tier

Restricted if Approved

POST

/merchant-tiers/{id}/submit

Submit tier for approval

Draft -> Pending

POST

/merchant-tiers/{id}/approve

Approve tier

Role restricted

POST

/merchant-tiers/{id}/reject

Reject tier

Reason required

DELETE

/merchant-tiers/{id}

Delete tier

Only if unused

GET

/business-types

List business types

POST

/business-types

Create business type

PUT

/business-types/{id}

Update business type

DELETE

/business-types/{id}

Delete business type

If no merchants

GET

/ticket-categories

List ticket categories

POST

/ticket-categories

Create ticket category

PUT

/ticket-categories/{id}

Update ticket category

DELETE

/ticket-categories/{id}

Delete ticket category

If no tickets

GET

/positions

List employee positions

POST

/positions

Create position

DELETE

/positions/{id}

Delete position

If no employees

GET

/departments

List departments

POST

/departments

Create department

DELETE

/departments/{id}

Delete department

If no employees

7. Security

7.1 Application security (Doc03)

Fleet-wide application security is defined in Doc03 - Application Security. This FSD does not restate Doc03.

Doc03 area

Relevance

Part A trust zones / identity planes

Admin JWT only; no merchant self-service for system master data

Principles P1–P3, P7

Authenticate/authorize every settings mutation; least privilege by admin role; auditable change

G1–G9 General controls

JWT via pkg/auth, Vault secrets, validation, logging, SDLC

APPSEC-ID-01

All /api/v1/settings/* require authentication

APPSEC-ID-06

URG/flat permissions for view vs manage (system:settings_view / system:settings_manage pattern)

APPSEC-ID-13 / 14

Secrets via Vault; no hardcoded admin keys

APPSEC-ID-15

Stable error envelope - Partial on common-service (GAP-S03)

APPSEC-ID-16 / 18 / 20

Input validation; request_id; no secrets/PII in logs

APPSEC-ID-19

Security/audit logging of configuration changes (ties to Audit FSD)

Doc03 S5. common-service

Flat + grant authz helpers; error-contract gap

8.2 Specific security

Aligned with product FR (merchant tiers + approval, business types, ticket categories, positions, departments) and Doc03 S5 / PI1 integrity for fee/limit masters.

Control

Requirement

Notes

AuthN

All list/create/update/delete/approve APIs require valid admin Bearer JWT

No public settings write/read for unauthenticated clients

AuthZ - role matrix

System Admin: full CRUD + approve/reject; Operations: create/edit, limited approve; Compliance: view + approve/reject sensitive; Read-only: view only

Enforce server-side flat permissions (e.g. system:settings_view / system:settings_manage + approve grant); not FE-only

AuthZ - approve path

POST .../approve and .../reject restricted to roles with approval rights

SoD preferred: submitter ≠ approver where org policy requires it

Merchant tier integrity

Tiers drive fees, limits, settlement period, rate limits - treat as financial configuration

Stronger validation + dual control (Draft → Pending → Approved/Rejected)

Tier lifecycle

Draft editable; Approved update restricted; delete only if unused and not Approved

Server rejects illegal transitions with stable codes (CONFLICT / validation)

Tier validation

Settlement T+X (X=1–31); rate limits positive integers; max accounts int or Unlimited

VALIDATION_ERROR field details; reject negative/zero limits silently becoming “unlimited”

Referential delete guards

Block delete of: tiers with merchants; business types with merchants; categories with tickets; positions/departments with employees

Prevent orphaning and silent reclassification

Uniqueness

Business type, category, position, department names unique

Race-safe unique index + API conflict

Approved tier immutability

Changes to fee/limit fields after Approved require re-approval path (or explicit superseding version)

Avoid silent fee change affecting live merchants

effective application

Only Approved (+ valid_from) tiers assignable to merchants

Downstream merchant-service re-check status

Ticket category linkage

Category taxonomy used by ticket-service RBAC scoping

Malicious rename/delete of categories used in policy → integrity risk; block delete if tickets exist; coordinate with ticket category RBAC (pkg/rbac/ticket_categories.go)

Position/department data

Org masters used for URG/HR reporting - not authorization grants themselves

Still admin-only write; no cross-tenant exposure

Input sanitization

Names/descriptions free text - no script injection in admin UI if rendered rich

Store plain text; escape on render

Audit (UC-08)

Every create/update/delete/submit/approve/reject logged with actor, entity id, before/after or diff, reason (reject), request_id

APPSEC-ID-19 / Audit FSD; high value for fee/approve events

Errors

Canonical envelope preferred; avoid leaking stack/SQL

Logging

Log entity ids + actor; do not log full fee payloads if they embed secrets (they usually do not - still avoid bulk PII dumps)

G5

Idempotency

Approve/reject and create under retry

GAP-G05 residual; use status guards so double-approve is no-op/CONFLICT

Secrets

No API keys or credentials in general settings entities

Rate-limit values are policy numbers, not gateway secrets

E. ReferencesE. Tham chiếu