﻿# Rencana Penyusunan Laporan Pivot Final (Modul Estimates)

## 1) Tujuan
Menyusun laporan manajemen berbasis data yang sudah ada di aplikasi (tanpa menunggu data warehouse baru), dengan output terpisah per role:
- Direksi
- Sales Manager
- Sales Ops

## 2) Scope Versi 1 (Data Existing)
Laporan hanya memakai data existing dari modul saat ini:
- Header estimate: tanggal, status, owner, nilai
- Context client/lead: `is_lead` (lead vs client)
- Item summary: `item_count`, `item_qty`
- Aktivitas historis estimate (event timeline)
- Priority data (incomplete, urgent >=3 hari, urgent >=7 hari, ready)

Out of scope sementara:
- Model scoring ML
- Materialized summary table baru
- Integrasi lintas sistem eksternal

## 3) Sumber Data dan Endpoint yang Dipakai
Controller utama: `app/Controllers/Estimates.php`

Endpoint aktif untuk laporan:
- `estimates/kpi_core_data`
  - KPI inti: total count, total value, accepted rate, accepted/declined, draft aging
- `estimates/pivot_role_matrix_data`
  - Pivot multi dimensi by role
  - Sudah mencakup: lead_count, client_count, item_count, item_qty
- `estimates/pivot_owner_week_status_data`
  - Pivot owner x week x status
  - Sudah mencakup: lead_count, client_count, item_count, item_qty
- `estimates/prioritas_data_summary_data`
  - KPI operasional backlog dan readiness

## 4) Struktur Laporan per Role

### A. Direksi (1 halaman ringkas)
Urutan konten:
1. Executive KPI Card
   - Total Estimate Value
   - Accepted Rate
   - Draft Aging >=7 Hari
   - Ready to Convert SO
2. Trend Bulanan (3-6 bulan terakhir)
3. Risk Radar
   - Owner dengan backlog tertinggi
   - Source dengan conversion terendah
4. Keputusan/Action minggu ini

Pivot utama:
- Role matrix profile `direksi`
- Owner x Week x Status (summary only)

### B. Sales Manager (kontrol tim)
Urutan konten:
1. Team Performance Summary
2. Owner x Month x Status + Accepted Rate
3. Backlog Aging by Owner
4. Lead vs Client mix per owner
5. Item load (item line, qty) untuk indikasi kompleksitas penawaran

Pivot utama:
- Role matrix profile `sales_manager`
- Owner x Week x Status (full table)

### C. Sales Ops (eksekusi harian)
Urutan konten:
1. Queue prioritas follow-up (urgent >=7, >=3)
2. Daftar owner yang perlu tindakan hari ini
3. Estimate dengan rework/edit tinggi (dari activity)
4. Monitoring kualitas data (incomplete vs ready)

Pivot utama:
- Role matrix profile `sales_ops`
- Priority data summary + listing operasional

## 5) Format Output Dokumen
Deliverable utama:
1. Laporan Ringkas Direksi (PDF/Doc)
2. Laporan Kendali Sales Manager (PDF/Doc)
3. Laporan Operasional Sales Ops (PDF/Doc)
4. Lampiran Data Evidence (CSV/XLS export pivot)

Standar tampilan:
- Semua angka currency konsisten
- Semua persen 2 desimal
- Timezone tunggal: Asia/Jakarta
- Soft-deleted record tidak dihitung

## 6) Timeline Eksekusi (Tanggal Konkret)
- 18 April 2026: Freeze scope, freeze KPI dictionary, freeze filter standard
- 19 April 2026: Tarik data awal + draft narasi per role
- 20 April 2026: Validasi angka (rekonsiliasi endpoint vs UI)
- 21 April 2026: Review bisnis (Direksi/Sales Manager/Sales Ops)
- 22 April 2026: Finalisasi dokumen + sign-off versi 1

## 7) Quality Control Wajib
Checklist QC sebelum final:
1. Total estimate count match antara KPI dan pivot (+/- <1%)
2. Accepted/declined konsisten antar tabel
3. Lead_count + client_count sejalan dengan estimate_count pada level agregat
4. Item_count dan item_qty tidak null di total row
5. Filter owner/month/status menghasilkan angka konsisten antar endpoint
6. Angka di laporan sama dengan angka di layar saat timestamp sama

## 8) Risk dan Mitigasi
- Risiko: perbedaan definisi accepted rate antar tim
  - Mitigasi: pakai definisi baku `accepted/(accepted+declined)`
- Risiko: data terasa "kurang detail" untuk item level
  - Mitigasi: versi 1 pakai item aggregate (`item_count`, `item_qty`), detail item per SKU masuk versi 2
- Risiko: user non-teknis bingung membaca pivot besar
  - Mitigasi: pisah laporan per role + ringkasan insight di halaman awal

## 9) Kriteria Selesai (Definition of Done)
Laporan dianggap selesai jika:
1. Tiga dokumen role-based sudah terbit
2. Semua KPI utama sudah tervalidasi
3. Selisih rekonsiliasi <1%
4. Stakeholder menyetujui output versi 1

---

## Lampiran Singkat: Susunan Bab Dokumen Final
Bab 1 Ringkasan Eksekutif
Bab 2 KPI dan Definisi
Bab 3 Analisa Direksi
Bab 4 Analisa Sales Manager
Bab 5 Analisa Sales Ops
Bab 6 Risiko dan Rencana Aksi 30 Hari
Bab 7 Lampiran Evidence dan Query Mapping
