Bỏ qua để đến nội dung

fct_sales — Bảng fact bán hàng

Bảng fact trung tâm của DataValue — mỗi dòng là một dòng của một đơn bán (sale.order.line), đã làm giàu đủ chiều phân tích và các chỉ tiêu lợi nhuận (MPA).

  • Grain: một dòng = một dòng hàng trong một đơn bán.
  • Engine: MergeTree · ORDER BY (order_date).
  • Nguồn (dbt): stg_sale_order_line ⋈ stg_sale_order ⋈ stg_res_partner ⋈ stg_product_product ⋈ stg_product_template ⋈ dim_product (Ngành + Nhóm) ⋈ stg_crm_team ⋈ dim_vn_geo ⋈ dim_salesman ⋈ dim_customer.
  • Cube: sales (21 chỉ tiêu).
CộtKiểuMô tả
order_dateDateNgày đặt đơn — khoá sắp xếp. Từ sale_order.date_order.
order_idInt64Mã đơn bán. Từ sale_order.id.
customerNullable(String)Tên khách hàng. Từ res_partner.name.
customer_groupStringNhóm khách theo giá trị (Chiến lược/Khách lớn/Khách vừa/Khách nhỏ). Từ dim_customer.
salesmanStringNhân viên bán. Từ dim_salesman (gán theo khách — demo).
productStringTên sản phẩm. Từ product_template.name (đã tách jsonb).
channelStringKênh bán. Từ crm.team (đã Việt hoá).
business_lineStringNgành hàng. Từ dim_product (định nghĩa Ngành 1 nơi).
categoryStringNhóm sản phẩm (danh mục Odoo). Từ dim_product.
regionStringMiền (Bắc/Trung/Nam). Từ dim_vn_geo theo tỉnh.
provinceStringTỉnh/Thành. Từ res_partner.city.

Nguồn giá trị: Odoo = field gốc của Odoo (dbt bê thẳng / ép kiểu / join) · dbt tính = công thức đơn giản trên số Odoo. Giá vốn (COGS) lấy từ cost master của Odoo (standard_price) — dbt chỉ join × qty, không bịa.

CộtKiểuNguồnMô tả
qtyDecimal(38,9)OdooSố lượng bán. Từ sale_order_line.product_uom_qty.
revenueFloat64OdooDoanh thu thuần (chưa thuế). Từ price_subtotal.
amount_totalFloat64OdooDoanh thu gồm thuế. Từ price_total.
taxFloat64OdooTiền thuế (VAT). Từ price_tax — field gốc của Odoo.
list_amountFloat64OdooGiá niêm yết × SL (trước chiết khấu) = qty × price_unit.
costFloat64OdooGiá vốn (COGS) = qty × standard_price (cost master Odoo, qua dim_product). Demo thiếu → tạm 62% giá niêm yết; production dùng stock.valuation.layer.
gross_profitFloat64dbt tínhLợi nhuận gộp = revenue − cost.
discount_amountFloat64dbt tínhChiết khấu = list_amount − revenue.

Doanh thu · Doanh thu gồm thuế · Thuế · Giá vốn · Lợi nhuận gộp · Biên lợi nhuận % · Giá trị niêm yết · Chiết khấu · Tỷ lệ chiết khấu · Sản lượng · Số đơn · Số dòng · Số khách hàng · Số sản phẩm · Giá trị đơn TB · Giá bán TB · SL/đơn · Doanh thu/khách · LN gộp/đơn · Đơn đầu tiên · Đơn gần nhất.

  • product → dim_product → business_line (Ngành) + category (Nhóm).
  • province → dim_vn_geo → region (VN → Miền → Tỉnh).
  • partner_id (đơn) → dim_customer → customer_group; → dim_salesman → salesman.
  • customer/product/channel/tax/cost = từ Odoo (cost = standard_price); region/salesman/customer_group = gán/suy diễn (demo); business_line/category = từ dim_product.
Chia sẻ: