1. Data Infor
    1. Primary Key:
      1. ID(Mã đơn hàng)
    2. Foriegn Key:
      1. Supplier_id
      2. User_id
    3. Highlight Category Fields:
      1. City_id
      2. Status
      3. Service_id
      4. _extra_props
        1. Parent ID
        2. Child ID
      5. Cancel By
      6. Promo_code
      7. #SAMEDAY: 1. Khi KH tạo 1 đơn Same Day => Order tạo 1 record 1 service_id: ...._SAMEDAY 2. Sau khi pooling ghép trip => Order tạo đơn SAMEDAY_INTERNAL => _extra_props (Child_ID = service_id của các đơn SAMEDAY được ghép) 3. Trường hợp đơn SAMEDAY_INTERNAL không được nhận và chuyển lại thành các đơn POOL => Trạng thái ở đơn SAMEDAY và SAMEDAY_INTERNAL chuyển qua 'Cancel' => Record đơn Pool được tạo, _extra_props(Parent ID = service_id của đơn Same Day)
    4. Highlight Numeric Fields
      1. Stop Points
      2. Distance Fee
      3. Stop Fee
      4. Request Fee
      5. Partner Fee
      6. Partner Discount
      7. Discount
      8. Total Fee
      9. Total Pay
      10. GSV
    5. Highlight Datetime Fields
      1. Create_time
      2. Order_time
      3. Accept_time
      4. Pickup_time
      5. Complete_time
    6. 1. double precision => cast to timestamp 2. Calculate Lead_time
  2. Metrics
    1. 1. Request_Order
      1. Count(ID)
    2. 2. Accepted Order
      1. Count(Accept_time)
    3. 3. Fulfilled Order
      1. Count(ID) Where Status = 'Completed')
    4. 4. AR
      1. by Order: 2/1
      2. by Stoppoint: Sum(stoppoint) where Accept_time is not null / Sum(stoppoint)
    5. 5. FR
      1. by Order: 3/1
      2. by Stoppoint: Sum(stoppoint) where status LIKE 'Completed' / Sum(stoppoint)
    6. 6. GSV
      1. Same Day: GSV = Partner Fee(Không trừ Partner Discount)
      2. Others: GSV = Total Fee
    7. 7. Lead time
      1. Pick_up time - Accept_time
      2. Pick_up time - Order_time(Accept_time < Order_time)
  3. Logic
    1. If Partner_fee >= 0
      1. True
        1. Total_fee: Distance_fee+ Request_fee+ Stop_fee
        2. Total_pay = Partner_fee- Partner_Discount
        3. GSV = Partner_fee
        4. Discount = Total_fee - Total_Pay
      2. False
        1. Total_fee: Distance_fee+ Request_fee+ Stop_fee
        2. Total_Pay = Total_fee - Discount
        3. GSV = Total_fee
        4. Discount: Promocode
  4. Concerns
    1. 1. Request Order: Nếu count toàn bộ ID nghĩa là tính luôn order canceled by user => AR giảm? Có nên bỏ những đơn cancel by user không?
    2. 2. Accepted Order: Có hỏi Khanh, Khanh nói những đơn nào chỉ cần có Accept_time thì được tính. Nhưng trường hợp nếu supplier nhận đơn rồi nhưng sau đó user hoặc supplier cancel thì sẽ ntn?
    3. 3. Status: Paying trước Completed? => Fulfilled Order: chỉ count những order có status ' Completed' ?