Skip to content

Integration

Ledger không có lệnh gọi HTTP đồng bộ tới service anh em. Mọi dữ liệu xuyên service được đọc trực tiếp qua repository @nx/core (schema dùng chung, cùng database). Nó phụ thuộc @nx/asset để lưu file và identity chỉ để xác minh JWT.

1. Service anh em

Direction: gọi / được gọi / hai chiều.

Anh emHướngBề mặtHợp đồngAuthFailure ModeIdempotency
@nx/identityXác minh JWKS mỗi requestVerifierApplicationJWKS (ES256)401 khi JWT không hợp lệ/hết hạn
@nx/assetMetaLinkService + upload/download S3in-process (repo @nx/core + BunS3Helper)lỗi upload → job REJECTEDdọn link mồ côi trước/sau run
@nx/financeĐọc DB: FinanceTransactionRepositoryschema dùng chungkết quả rỗng → sổ rỗngchỉ đọc
@nx/saleĐọc DB: SaleOrderRepositoryschema dùng chungchỉ đọc
@nx/commerceĐọc DB: MerchantRepository, TaxInfoRepository, VnProvince/VnWardschema dùng chungthiếu merchant → lỗi validatechỉ đọc

Đọc xuyên package chỉ S1a-HKD (dữ liệu thật). S2a–S2e hiện dùng JSON fixture qua LedgerDataFixtureService (placeholder chờ tích hợp thật).

2. Hệ thống ngoài

Hệ thốngHướngBề mặtAuthFailure Mode
Kafkaproduce + consume ledger.generateSASL SCRAM-SHA-512 (bật/tắt APP_ENV_KAFKA_SASL_ENABLE)broker down → enqueue throw → job REJECTED (ENQUEUE_FAILED)
S3 / Minioput/get PDF/XLSX mã hoá (BunS3Helper)access/secret keylỗi upload → job REJECTED
Rediscache auth + WS pubsubpasswordWS emit best-effort
Typstin-procrender PDF NodeCompilerlỗi compile → compiler mới, rồi rethrow

3. Luồng xuyên service quan trọng

3.1 Lấy dữ liệu S1a-HKD (dữ liệu thật)

BướcChi tiết
1Facade LedgerDataFetcherService định tuyến theo loại tới S1aHkdDataFetcherService
5Worker validate bằng SCHEMA_MAP['S1a-HKD'].safeParse; parse thất bại → REJECTED

3.2 Upload file qua @nx/asset

BướcChi tiết
2originalName phải là filename phẳngBunS3Helper.isValidName() từ chối /; path dựng trong normalizeNameFn
4Download đảo ngược: getLedgerFromS3Decrypted → decrypt → stream tới client

4. Độ ổn định hợp đồng

Bề mặtĐộ ổn địnhVersioning
HTTP /v1/api/ledger/*ổn địnhURL /v1/
Kafka ledger.generateổn định (self-loop nội bộ)trường payload chỉ thêm
Bố cục key S3 ledgers/{period}/{merchantId}/{version}/ổn định
Nguồn dữ liệu S2a–S2ebeta — placeholder fixture, fetch thật còn chờ

5. Trang liên quan

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