Finance — Tổng quan
Finance là lớp nghiệp vụ theo dõi tiền sau khi Booking hoặc Subscription tạo nghĩa vụ thanh toán:
Billing,Invoice,CreditNote, finance transaction, invoice manager và đồng bộ kế toán.
Finance không quyết định khách được book session nào. Nó nhận dữ liệu từ Booking/Subscription → chứng từ tài chính → theo dõi trạng thái → dữ liệu cho Payment, CreditNote, báo cáo, Xero sync.
Hình dung nhanh
Finance bao phủ những gì?
| Mảng | Một câu |
|---|---|
| Billing | Nhóm booking/enrollment thành nghĩa vụ tính tiền, giữ PaymentOptionId, split rule, currency/context. |
| Invoice | Chứng từ phải thu, có lifecycle từ khởi tạo, phát hành, approve, lock, paid/cancel. |
| CreditNote | Chứng từ điều chỉnh âm hoặc hoàn giảm, liên kết invoice/booking để cân bằng tài chính. |
| FinanceTransaction | Projection phục vụ invoice manager, tìm kiếm, booking number sync và credit-note allocation sync. |
| Invoice Manager | Bề mặt admin để xem, lọc, lock, xử lý invoice và các integrity rule quanh booking id. |
| Preview Billing Diff | Tính thử chênh lệch tài chính khi edit booking đã confirm, không ghi dữ liệu. |
| Accounting sync | Đồng bộ sang provider như Xero, gồm account settings và provider sync lifecycle. |
| Invoice email & reminder | Gửi invoice email single/batch không PDF và nhắc nợ tự động ≤3 rule/BU (OnInvoiceDate/BeforeDueDate/AfterDueDate). |
| Invoice notification & tracking | Invoice_Fully_Paid notification khi chuyển Paid, đánh dấu Viewed khi customer mở invoice, tag Processing khi invoice bị lock. |
| Subscription Enrichment boundary | Phí Enrichment thuộc Booking Billing/Reconciliation; Subscription Billing chỉ sinh invoice từ schedule/add-on. |
| Subsidy | Trợ cấp ảnh hưởng eligibility/finance, gồm allocation batch/estimation và site licence setup (SWN/Program ID). |
Implementation hiện tại
- Closure Day credit chỉ đảo phần tiền đã invoiced nhưng chưa credited, giữ tax/currency/line type theo nguồn; line đã convert thành no-charge là zero vĩnh viễn và không bị re-invoice.
- Invoice Manager có Booking Info read-only theo
BillingId; Booking ID có billing link và có thể handoff sang Booking Manager với filter billing đã áp dụng. - Preview Billing Difference, invoice setting preview và confirm dùng billing calculation core chung; preview không persist, confirm mới commit atomic.
- Subscription Billing không đọc hoặc cộng
TermBookingLineEnrichment vàoEnrollmentBillingSchedule,SubscriptionTermBillingSchedulehay Subscription invoice line. Booking reconciliation là charge path duy nhất của Enrichment occurrence.
Đọc theo thứ tự
- Khái niệm cốt lõi
- Kiến trúc & dữ liệu
- So sánh Edit Booking có/không có Preview Billing Diff
- Code flow Preview Billing Diff
- Dữ liệu & bảng đọc/ghi
- Subsidy
- Case thường gặp
Liên quan
- Booking tạo billing/invoice sau submit/confirm.
- Payment thu tiền dựa trên invoice/payment option.
- Platform nhận EntityEvent/history từ invoice, credit note và transaction.
- Subscription tạo lịch billing định kỳ và invoice theo schedule.
Ví dụ thực tế: Closure Day đã invoiced $80 và credited $20 trên line $120. → Finance chỉ đảo thêm $60, rồi giữ line converted ở zero vĩnh viễn.