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

Milestone editor (popup)

Milestone là sự kiện trong vòng đời HĐ có thể gắn với % thanh toán. Vd “Ký HĐ → 30%”, “Bàn giao đất → 40%”, “Đi vào vận hành → 30%”.

Trên form Sale Order (Báo giá) hoặc Zone Contract (HĐ):

  • Tab “Order Lines” → click 1 line → mở popup line detail
  • Popup có tab “Milestones”
  • HOẶC: click nút ”🎯 Sửa milestone” (dedicated modal - task #23)
sale.order.line.milestone (task #18-20)
├── name: "Ký HĐ" / "Bàn giao đất" / ...
├── description: Text mô tả
├── date_planned: Ngày dự kiến
├── date_actual: Ngày thực tế (khi hoàn thành)
├── amount_pct: % thanh toán khi milestone hoàn thành
├── amount_fixed: Số tiền cố định (thay vì %)
├── state: draft / open / done / overdue / cancelled
└── line_id: order line liên kết

Click 1 order line → click nút ”🎯 Sửa milestone” → modal opens

Click ”+ Add” → điền:

  • Name: “Ký HĐ”
  • Date planned: (Đại chọn)
  • Amount pct: 30 (nghĩa là 30% giá order line)
  • State: draft

Milestone lưu, popup close. Order line hiển thị số milestone (vd “3 milestones”).

Đại có thể tạo milestone template sẵn dùng lại nhiều lần.

Cấu hình → Parkone → Milestone Templates → Mới

Preset chuẩn “50-30-20”:

  • Ký HĐ: 50%, T+0
  • Bàn giao: 30%, T+30
  • Vận hành: 20%, T+90

Trên popup → click ”📋 Apply template” → chọn template

  • Wizard mở với preview 3 milestones
  • Adjust ngày cụ thể (auto-fill T+0/30/90 từ ngày HĐ)
  • Click Apply → 3 milestones tạo sẵn

Xem chi tiết templates ở Milestone template presets.

Khi milestone hoàn thành (vd bàn giao đất xong):

  1. Mở popup milestone
  2. Click milestone → set:
    • State: done
    • Date actual: today (auto-fill)
  3. Save

Cron auto-sinh Invoice với amount = amount_pct × order_line.total_amount nếu milestone gắn payment.

StateÝ nghĩaAction
draftChưa bắt đầuSales rep set khi tạo
openĐang thực hiệnAuto khi HĐ active + date_planned ≤ today
doneĐã hoàn thànhManual set + auto-trigger Invoice
overdueQuá hạn date_plannedCron flag, activity to responsible
cancelledKhông thực hiệnManual set nếu milestone bị bỏ

Khi milestone → done:

  1. Cron detect (chạy 30 phút/lần) hoặc trigger ngay (nếu instant flag)
  2. Tính amount = amount_pct × line.price_subtotal HOẶC amount_fixed
  3. Tạo Invoice draft với 1 line: mô tả = milestone name, amount = tính trên
  4. Link Invoice ↔ milestone (field invoice_id)
  5. Activity to FC review + post

Contract PDF template có bảng render milestone schedule (task #71):

BẢNG THANH TOÁN THEO MỐC
| Mốc | Ngày dự kiến | % / Số tiền |
| Ký HĐ | 1/8/2026 | 30% = 1.5 tỷ |
| Bàn giao đất | 1/9/2026 | 40% = 2.0 tỷ |
| Vận hành | 1/12/2026 | 30% = 1.5 tỷ |

Wizard render Contract → auto-fill bảng này từ milestones.

Phần tiêu đề “Milestone không link với billing_item — chỉ với order line?”

Milestone gắn với sale.order.line, không phải billing_item. Khi convert SO → HĐ, milestones migrate cùng.

Có thể có nhiều milestone cho 1 line không?

Phần tiêu đề “Có thể có nhiều milestone cho 1 line không?”

Có. Line “Tiền cọc 5 tỷ” → 3 milestones 30/40/30 = 3 lần trả cho line này.

Tự động sinh Invoice khi milestone done — có thể tắt không?

Phần tiêu đề “Tự động sinh Invoice khi milestone done — có thể tắt không?”

Có. Field auto_invoice trên milestone (Advanced) — set False → Invoice không auto sinh, FC sinh manual sau.

Milestone template khác milestone thường thế nào?

Phần tiêu đề “Milestone template khác milestone thường thế nào?”

Template là “khuôn” reusable trong Cấu hình. Milestone thường là instance thực trên order line, có date + state cụ thể.

Template chỉ define name + amount_pct + delay_days. Apply → tạo milestones thực với date = HĐ date + delay_days.

Chia sẻ: