Skip to content

Sales And Finance — Business Rules

Tổng quan

Domain này gom các báo cáo thiên về doanh thu, công nợ, dòng tiền và hiệu suất tài chính:

  • revenue
  • debt
  • actual revenue
  • commission
  • fund
  • expense
  • employee revenue

Một phần rank theo chi nhánh/phòng ban cũng chạm vùng này, nhưng không phải finance thuần; nó được tách sang doc org-performance-and-compliance.

Scope nghiệp vụ

NhómVai tròVí dụ page
RevenueTheo dõi doanh thu theo loại đơn và hình thức thuRevenueReport.tsx
DebtTheo dõi công nợ vào/raDebtReport.tsx
Actual revenueĐọc doanh thu thực sau khi đã qua action tổng hợpActualRevenueReport.tsx
Commission / employee revenueTheo dõi phân bổ doanh thu và commission theo ngườiCommissionReport.tsx, EmployeeRevenueReport.tsx
Fund / expenseĐọc dòng tiền quỹ và chi phí phát sinhFundReport.tsx, ExpenseReport.tsx

Luồng chính

text
Report cards
  -> chọn group revenue / debt / fund / expense / commission
  -> FE kiểm tra `reportRoles`
  -> mở filter theo ngày / branch / order kind / user
  -> query trực tiếp table/view/function hoặc Hasura action
  -> render card + table + aggregate

Quy tắc nghiệp vụ

Quy tắc
BR-RSF-001Finance reports không dựa vào route guard FE; quyền xem thực tế đến từ report_role, reportRoles và scope query backend.
BR-RSF-002revenue là họ nhiều tab, tách theo loại đơn và hình thức thu: service order, service payment, product order, prepaid order.
BR-RSF-003actual revenue là engine riêng, không đồng nghĩa 1-1 với revenue total; nó đi qua action tổng hợp thay vì chỉ query bảng/view trực tiếp.
BR-RSF-004commissionemployee revenue là read model cho phân bổ doanh thu theo nhân sự, không phải sổ cái wallet trực tiếp.
BR-RSF-005fundexpense đọc lớp tài chính vận hành, nhưng ownership dữ liệu vẫn rải giữa ecommerce, hrm, wallet.
BR-RSF-006Root card và tab-level access có thể thay đổi theo report_role; cùng một route shell nhưng role khác nhau có thể thấy tập tab khác nhau.

Boundary

BoundaryGhi chú
ecommerceNguồn dữ liệu lớn nhất: order, invoice, order_item, order_commission, invoice_commission, fund
walletXuất hiện ở payment method wallet, wallet_promotion và transaction log phía expense
settingsDashboardReportPermission là control plane để cấp report_role

Rủi ro / Findings

MứcFinding
P1actual revenue hiện lẫn một phần UI/customer-rate, nên domain boundary chưa sạch.
P1employee revenue về semantics gần “invoice commission allocation” hơn là “doanh thu nhân viên” thuần.
P1commission là report tổng hợp riêng, không cùng định nghĩa với payout/settlement trong wallet.
P2reportRoles được cache localStorage 1 giờ ở login flow, nên thay đổi phân quyền có thể không phản ánh ngay.
P2audit report hiện vẫn là placeholder, chưa nên tính là coverage thực của finance/compliance.