Skip to content

Configuration

1. Biến môi trường

Nguồn: packages/core/src/common/environments.ts (EnvironmentKeys) + src/common/ của package này.

Core

TênKiểuMặc địnhBắt buộcMô tả
APP_ENV_PORTnumber3000Port HTTP lắng nghe (dev external 31040)
APP_ENV_HOSTstring0.0.0.0Host bind
APP_ENV_BASE_PATHstring/v1/api/financePrefix route
APP_ENV_NODE_IDnumber4Snowflake worker ID
APP_ENV_LOG_LEVELinfo|debug|warn|errorinfoMức logger
NODE_ENVstringproductionPhân vùng env đóng dấu lên tài khoản

Database

TênKiểuMặc địnhBắt buộcMô tả
APP_ENV_DB_URLstringURL kết nối PostgreSQL
APP_ENV_DB_POOL_MAXnumber10Kích thước pool tối đa

Kafka

TênKiểuMặc địnhBắt buộcMô tả
APP_ENV_KAFKA_BROKERSstringBroker phân tách bằng dấu phẩy (rỗng → component throw khi boot)
APP_ENV_KAFKA_CLIENT_IDstringSVC-00040-FINANCE_PRODUCER / _CONSUMERClient id
APP_ENV_KAFKA_GROUP_IDstringSVC-00040-FINANCE_CONSUMER_GROUPConsumer group
APP_ENV_KAFKA_SASL_ENABLEbooleanfalseBật SASL
APP_ENV_KAFKA_SASL_MECHANISM / _USERNAME / _PASSWORDstringCredential SASL (khi bật)

WebSocket Redis

TênKiểuMặc địnhBắt buộcMô tả
APP_ENV_WEBSOCKET_REDIS_MODEsingle|clustersingleTopology Redis của emitter
APP_ENV_WEBSOCKET_REDIS_HOSTstringlocalhost
APP_ENV_WEBSOCKET_REDIS_PORTnumber6379
APP_ENV_WEBSOCKET_REDIS_PASSWORDstring
APP_ENV_WEBSOCKET_REDIS_DBnumber0
APP_ENV_WEBSOCKET_REDIS_IDENTIFIERstringfinance-ws-redisTên kết nối

Cache / Authorization Redis

TênKiểuMặc địnhBắt buộcMô tả
APP_ENV_REDIS_HOSTstringHost cache authorization (useCacheRedis)
APP_ENV_REDIS_PORTnumber6379

2. Feature Flags

Không. Finance không có runtime feature flag. Các công tắc hành vi (một tiền tệ, sự hiện diện của tài khoản kiểm soát) là cấu trúc, không gate bằng flag. Đa tiền tệ đang ngủ: cột exchangeRate tồn tại nhưng hard-set thành 1.

3. Dữ liệu Seed

Các migration process trong src/migrations/processes/ — load bởi migration-process.ts, idempotent.

FileSeedsAlways-runGhi chú
finance-0001-seed-categories.ts14 dòng FinanceCategory hệ thống (merchantId=null)noUpsert theo (name, type, identifier, merchantId=null)
finance-0002-seed-permissions.tsTất cả dòng Permission financeyesUpsert theo code
finance-0003-seed-role-permissions.tsCấp TẤT CẢ quyền finance cho OWNER, EMPLOYEE, CASHIERyesBaseline khoan dung; siết sau qua merchant policy API

14 danh mục hệ thống

IdentifierTypeName (en)
000_SALEINCOMESales Revenue
001_OTHER_INCOMEINCOMEOther Income
002_REFUND_INCOMEINCOMERefund Received
300_COLLECT_INTERESTINCOMEInterest Income
100_PURCHASEEXPENSEPurchase - Inventory
101_OTHER_EXPENSEEXPENSEOther Expenses
102_REFUND_EXPENSEEXPENSERefund to Customer
200_OPERATINGEXPENSEOperating Expenses
201_SALARYEXPENSESalaries & Wages
202_RENT_UTILITIESEXPENSERent & Utilities
203_MARKETINGEXPENSEMarketing & Advertising
204_SHIPPINGEXPENSETransportation & Delivery
205_MAINTENANCEEXPENSEMaintenance & Repairs
301_PAY_INTERESTEXPENSEInterest Expense

Hằng số trong FixedFinanceCategories. Merchant thêm danh mục con tùy chỉnh dưới các danh mục này qua category API. Tài khoản kiểm soát INVENTORY/COGS không phải seed — chúng được đối soát theo từng merchant khi sự kiện merchant CDC đầu tiên.

4. Lưu trữ Configuration (bảng Configuration)

Config runtime theo từng merchant / hệ thống đọc qua ConfigurationRepository.

ConfigurationGroupRead byMục đích
DEFAULT_FINANCE_ACCOUNTSSYSTEM (principal null)FinanceWorkerService._loadDefaultAccountConfigMảng template tài khoản mặc định seed cho merchant mới khi thiếu merchant.metadata.finance.accounts; validate bởi DefaultFinanceAccountsConfigSchema
PaymentIntegration.credential— (bảng riêng)PaymentIntegrationService / FinanceIntegrationServiceCredential gateway encrypted; mask trong API response

5. Trang liên quan

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