Finance — Kiến trúc & dữ liệu
Luồng chính
Ranh giới quan trọng
| Ranh giới | Quy tắc |
|---|---|
| Billing calculation core | Có thể trả invoice/credit-note projection trong memory, nhưng không gọi EF persistence hoặc scheduler. |
| Persistence boundary | Chỉ boundary persist thật mới được add invoice/credit note, finance log, scheduler và SaveChangesAsync. |
| Preview Billing Diff | Read-only; không ghi invoice, scheduler, finance log hoặc projection. |
| Payment domain | Đọc invoice/payment option để thu tiền, nhưng trạng thái chứng từ tài chính vẫn thuộc Finance. |
| Accounting sync | Sync provider là side effect; record Finance trong AIMY vẫn là nguồn nghiệp vụ nội bộ. |
Dữ liệu thường gặp
| Nhóm | Ví dụ |
|---|---|
| Billing | Billing, billing period, payment option, split rule, currency setting. |
| Invoice | Invoice, InvoiceLine, invoice scheduler, invoice lock/processing state. |
| Credit note | CreditNote, credit-note line, allocation/link về invoice. |
| Projection | Finance transaction search key, booking number sync, projection refresh state. |
| Settings | Finance/accounting settings, invoice templates, Xero provider config. |
Drift cần nhớ
- Projection có thể cần refresh khi booking number, credit-note allocation hoặc invoice status thay đổi.
- Invoice lock/processing giúp tránh thao tác admin đụng vào chứng từ đang chạy job.
- Preview Billing Diff dùng chung logic tính toán nhưng phải giữ zero side effect.