Doc_chelvyn/Mito/Sfa/Fitur/SFA — Revisi Reward MoM 22-...

613 lines
43 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
judul: SFA — Revisi Reward MoM 22-10-2026 (checklist)
proyek: SFA API · SFA CMS · mito_odoo
terkait: Mito · Odoo 18 · SFA Mobile
kategori: Fitur
status: 10 dari 10 selesai · revisi customer per baris produk ter-deploy dev 31-10-2026 · Odoo (Jobsheet) menunggu review senior · mobile Staff Dealer belum · mobile Staff Dealer belum
tipe: dokumen-internal
tags:
- sfa
- reward
- imei
- jobsheet
- mom
diperbarui: 2026-10-30
---
> Index: [[SFA — Index]] · Kategori: **Fitur** · Sumber: [[Fix sfa aftrer meet with mito]] (MoM 22-10-2026, HO Mito)
> Fitur induk: [[SFA — Reward]]
# SFA — Revisi Reward MoM 22-10-2026
**Cara baca dokumen ini**
| Pembaca | Bagian |
|---|---|
| Functional / PM / Mito | [Ringkasan](#Ringkasan) · [Checklist](#Checklist) · [Keputusan yang Dibutuhkan](#Keputusan%20yang%20Dibutuhkan) · [Info ke Tim Mobile](#Info%20ke%20Tim%20Mobile) |
| Developer / Senior | [Detail Teknis per Poin](#Detail%20Teknis%20per%20Poin) · [Commit & Status Deploy](#Commit%20&%20Status%20Deploy) · [Catatan Deploy](#Catatan%20Deploy) |
## Ringkasan
- **10 dari 10 poin selesai** dan teruji lokal. Sebagian sudah ter-deploy di dev, sisanya tinggal commit / deploy (lihat
[Commit & Status Deploy](#Commit%20&%20Status%20Deploy)).
- **Jobsheet (poin 8 & 9), 30-10-2026:** admin memilih nomor Jobsheet Odoo di Reward Program (tidak bisa typo), nomornya
ikut ke Vendor Bill claim sebagai **referensi teks** (field **Jobsheet No.**), tidak memotong budget Jobsheet.
1 claim = 1 bill (keputusan K1 & K2, usulan Oliver).
- **Mobile:** menu saldo / claim untuk Staff Dealer masih perlu disembunyikan tim mobile (API sudah menolak).
## Checklist
Legenda: ✅ selesai · 🟡 sebagian · ⬜ belum
| # | Poin MoM | Status | Hasil (bahasa bisnis) | Catatan teknis |
|---|---|---|---|---|
| 1 | IMEI hanya boleh discan 1 kali | ✅ | Satu IMEI hanya sekali dapat reward, **apa pun produknya**, termasuk yang saldonya sudah di-claim | Sebelumnya unik per IMEI + produk |
| 2 | IMEI yang bisa discan hanya yang sudah terjual | ✅ | IMEI yang masih ada stok / diretur tidak bisa discan | Odoo kirim `product_qty`; CMS hanya simpan IMEI `product_qty = 0` |
| 3 | Upload attachment tidak mandatory | ✅ | Nota boleh menyusul | `attachment` opsional di `POST /reward/imei`, susulan lewat `PUT /reward/imei/attachment` |
| 4 | Minimum claim reward Rp 500.000 | ✅ | Saldo di bawah Rp 500.000 tidak bisa di-claim; tombol Claim CMS disembunyikan | `422 BELOW_MIN_CLAIM`; `GET /reward/balance` kirim `min_claim_amount` & `claimable` |
| 5 | Reward bisa multi customer | ✅ | **Customer menempel di baris produk** (revisi Oliver 30-10-2026): produk yang sama boleh beberapa baris dengan nominal & customer berbeda. Baris tanpa customer = dealer lain | Dealer tidak tercakup baris mana pun → `NO_ACTIVE_REWARD`. Revisi ter-deploy dev 31-10-2026 (CMS `0da379f`, API `c6fc18a`) |
| 6 | Export & import | ✅ | Tombol **Import / Export** Excel di list Reward Program (program + produk + customer, 1 sheet). Bisa **centang program** lalu **Export terpilih** | Upsert; 1 baris error = semua ditolak |
| 7 | Take out effective from & to | ✅ | Periode reward ikut header program. Nominal boleh diubah, riwayat lama aman | Kolom DB tidak di-drop |
| 8 | Field nomor Jobsheet + format anti-typo | ✅ | Field **Jobsheet** di Reward Program: nomor **dipilih dari daftar Odoo** (status On Progress), bukan diketik → tidak mungkin typo. Ikut Export / Import Excel | Odoo `GET /api/v1/jobsheets` + CMS dropdown realtime. Teruji lokal, di-push (Odoo `bb955bd2`, CMS `54285e6`), **belum deploy** |
| 9 | Nomor Jobsheet ikut ke Vendor Bill Odoo | ✅ | Vendor Bill claim punya field **Jobsheet No.** berisi nomor Jobsheet program asal saldo (lebih dari satu dipisah koma). Murni referensi, budget Jobsheet tidak terpotong | `jobsheet_no` di `POST /api/v1/reward-bills`. Teruji lokal, di-push, **belum deploy** |
| 10 | Staff Dealer tidak boleh lihat reward balance | ✅ API · ⬜ Mobile | Staff hanya scan; reward masuk **saldo dealer** | API `403 STAFF_NOT_ALLOWED`. Mobile belum sembunyikan menu |
**Progress: 10 / 10 selesai** (poin 10 sisi mobile belum).
## Keputusan yang Dibutuhkan
| Kode | Pertanyaan | Kenapa penting | Opsi | Saran dev | Status |
|---|---|---|---|---|---|
| **K1** | Satu claim berisi reward dari **beberapa program** (= beberapa Jobsheet). Vendor Bill-nya bagaimana? | Claim selalu *full balance* lintas program | a) 1 bill per Jobsheet · b) claim dipisah per program · c) **1 bill per claim** | — | ✅ **Diputuskan 30-10-2026: 1 bill per claim** (seperti sekarang). Jobsheet lebih dari satu → ditulis semua, dipisah koma |
| **K2** | Jobsheet di Vendor Bill = **AP Form** (terhubung budget) atau **teks** saja? | AP Form → saat Finance post bill, budget Jobsheet terpotong & dicek cukup / tidak | a) AP Form (`snk_ap_form`) · b) **field teks "Jobsheet No."** | — | ✅ **Diputuskan 30-10-2026 (Oliver): teks referensi.** "1 jobsheet bisa banyak reward, inputan nomor jobsheet pure hanya untuk referensi di vendor bill" |
| K3 | Nominal reward **per customer × produk** (1 program, harga beda per dealer) | Sekarang nominal hanya per produk | a) customer di baris produk · b) tier dealer (Gold/Silver) | — | ✅ **Diputuskan 30-10-2026 (Oliver): a.** Customer nempel ke baris produk, tab Customer dihapus. Detail di [Poin 5](#Poin%205%20·%20Reward%20multi%20customer%20(customer%20per%20baris%20produk)) |
| K4 | IMEI yang **belum pernah masuk gudang** ikut terhitung "terjual" (`product_qty = 0`) | Celah: IMEI hasil generate sebelum GR bisa discan | Tambah syarat "pernah keluar lewat DO" | Tutup celah (1 query per halaman sync) | ⏳ Belum diputuskan |
| K5 | Nominal reward per IMEI masih terlihat Staff Dealer di riwayat pengajuan | Poin 10 hanya menyebut saldo | Sembunyikan / biarkan | — | ✅ **Diputuskan 11-11-2026: boleh lihat, milik sendiri saja.** Staff melihat nominal IMEI yang dia scan; Dealer melihat dirinya + semua staff-nya. Sudah sesuai kode (tanpa perubahan) |
## Info ke Tim Mobile
- **Minimum claim:** tombol Claim pakai field `claimable` dari `GET /reward/balance`; pesan error pakai `BELOW_MIN_CLAIM`.
- **Staff Dealer:** sembunyikan menu saldo, riwayat ledger, claim, riwayat claim. Kalau tetap dipanggil → `403 STAFF_NOT_ALLOWED`.
Respon submit IMEI untuk staff **tidak punya** field `balance`.
- **Attachment:** opsional saat submit, bisa diunggah belakangan lewat `PUT /reward/imei/attachment`.
- **Scan:** gunakan `GET /reward/imei/check` sebelum memasukkan IMEI ke list (kode error di diagram di bawah).
## Alur Scan IMEI (setelah revisi)
Urutan cek sama di `GET /reward/imei/check` (saat scan, tanpa lock), `POST /reward/imei` (submit, di dalam transaksi
+ lock), dan input IMEI dari CMS (`RewardImeiSubmissionService::check`).
```mermaid
flowchart TD
A["Mobile scan IMEI"] --> B["GET /reward/imei/check"]
B --> C{"Ada di master IMEI CMS?<br/>(hanya product_qty = 0)"}
C -- "tidak (belum terjual / diretur / tidak ada)" --> E1["IMEI_NOT_FOUND"]
C -- "ya" --> D{"Sudah pernah dapat reward?<br/>(apa pun produknya)"}
D -- "ya" --> E2["IMEI_ALREADY_REWARDED"]
D -- "tidak" --> F{"Sedang menunggu approval?"}
F -- "ya" --> E3["IMEI_PENDING_APPROVAL"]
F -- "tidak" --> G{"product_qty = 0?"}
G -- "tidak" --> E4["IMEI_NOT_SOLD"]
G -- "ya" --> H{"Produk punya mapping<br/>reward ACTIVE hari ini?"}
H -- "tidak" --> E5["NO_ACTIVE_REWARD"]
H -- "ya" --> I["scannable = true<br/>masuk list mobile"]
I --> J["POST /reward/imei<br/>(attachment opsional)"]
J --> K["Pengajuan SUBMITTED<br/>menunggu approval CMS"]
K -- "approve CMS" --> L{"Saldo >= Rp 500.000?"}
L -- "tidak" --> E6["422 BELOW_MIN_CLAIM<br/>claimable = false"]
L -- "ya" --> N["Claim full balance<br/>→ Draft Vendor Bill Odoo"]
N --> M["+ Jobsheet No. di Vendor Bill<br/>(referensi)"]
classDef ok fill:#d1fae5,stroke:#059669,color:#064e3b
classDef err fill:#fee2e2,stroke:#dc2626,color:#7f1d1d
classDef todo fill:#f3f4f6,stroke:#9ca3af,color:#374151,stroke-dasharray:4 3
class I,K,N,M ok
class E1,E2,E3,E4,E5,E6 err
```
Keterangan warna: hijau = lolos, merah = ditolak (kode error dari API).
> [!note] `IMEI_NOT_SOLD` sekarang jarang muncul
> Karena master IMEI CMS hanya berisi IMEI `product_qty = 0`, IMEI yang masih ada stok biasanya sudah ditolak di
> langkah pertama sebagai `IMEI_NOT_FOUND` ("IMEI tidak terdaftar"). `IMEI_NOT_SOLD` tetap dicek sebagai pengaman
> kalau data CMS belum ter-update.
---
## Detail Teknis per Poin
### Poin 1–3 · Sync stok IMEI Odoo → CMS
- **Odoo** `GET /api/v1/imeis` mengirim `product_qty` (`stock.lot.product_qty`, stok di lokasi internal).
`updated_since` ikut menangkap perubahan stok lewat `write_date` quant, karena DO / retur tidak mengubah
`write_date` IMEI.
- **CMS** `odoo:sync-imeis`:
- IMEI dengan `product_qty` NULL / bukan 0 **tidak disimpan**; kalau sudah ada → soft delete (statistik `removed=`).
- Incremental (tiap 5 menit) tetap menarik semua IMEI yang berubah, supaya IMEI yang **diretur** langsung terbuang.
- Akhir full cycle membuang sisa IMEI NULL / bukan 0, tidak bergantung error mapping product.
- Kolom **Stok Odoo** di list IMEI CMS, label "Terjual" untuk stok 0.
**Celah yang diketahui (K4):** `product_qty = 0` juga berlaku untuk IMEI yang **belum pernah masuk gudang**
(di-generate sebelum GR). Opsi penutup: syarat tambahan "pernah keluar lewat DO" — `stock.move.line` done dengan
`picking_code = 'outgoing'` (logika yang sama dengan smart button **Transfers** di Lot/Serial Odoo), dicek 1 query
per halaman sync.
### Poin 4 · Minimum claim Rp 500.000
- Konstanta `MIN_CLAIM_AMOUNT = 500000` di Node (`routes/helpers/enums/reward.js`) dan CMS
(`RewardClaimService::MIN_CLAIM_AMOUNT`) — **ubah dua-duanya** kalau nominal berubah.
- Urutan cek claim: saldo `<= 0` → `BALANCE_EMPTY`, saldo `< 500.000` → `BELOW_MIN_CLAIM`, nominal beda → `BALANCE_CHANGED`.
- `GET /reward/balance` tambah `min_claim_amount`; `claimable` jadi `balance >= min_claim_amount`.
Hasil uji lokal 28-10-2026 (user 445, data dikembalikan setelah tes):
| Saldo | Mobile `claimable` / `POST /reward/claim` | CMS tombol Claim / `claimFullBalance` |
|---|---|---|
| Rp 50.000 | `false` / 422 `BELOW_MIN_CLAIM` | hilang / ditolak |
| Rp 499.999,99 | `false` / 422 `BELOW_MIN_CLAIM` | hilang / ditolak |
| Rp 500.000 | `true` / claim berhasil, saldo jadi 0 | tampil / claim berhasil |
### Poin 5 · Reward multi customer (customer per baris produk)
**Revisi 30-10-2026 (Oliver):** "harusnya customer nempel ke productnya, jadi ga bikin tab baru … biar bisa ada product
yg sama, tapi nominalnya beda … jadi 1 lines". Customer per baris = **many2one** (1 customer per baris, kolom
`reward_product_mapping.user_id`), dikonfirmasi 31-10-2026. Versi pertama (29-10-2026, `609ed39`) memakai tab
**Customer** di level program — diganti oleh versi ini.
Contoh Oliver (customer A, B, C dapat 10.000; D, E dapat 15.000 → 1 baris per customer):
| Reward 1 · Produk | Nominal | Customer |
|---|---|---|
| Product A | 10.000 | A |
| Product A | 10.000 | B |
| Product A | 10.000 | C |
| Product A | 15.000 | D |
| Product A | 15.000 | E |
| Product A | 12.000 | *(kosong = dealer lain, opsional)* |
Dealer D / E scan IMEI Product A → reward **15.000**; dealer A / B / C → **10.000**.
**Aturan (disepakati 30-10-2026):**
| # | Aturan |
|---|---|
| 1 | Baris **tanpa customer** = berlaku untuk dealer yang **tidak disebut** di baris lain produk yang sama. Tidak ada baris kosong → dealer lain tidak dapat reward produk itu |
| 2 | Produk sama di **program yang sama**: 1 dealer hanya 1 baris; baris tanpa customer maksimal satu |
| 3 | Produk sama di **program lain** yang periodenya beririsan (bukan ENDED): bentrok kalau customer-nya sama, atau salah satu baris tanpa customer (= semua dealer) |
| 4 | Customer = **akun dealer** (`users` EXTERNAL, APPROVED, bukan Staff Dealer). Scan Staff Dealer dihitung untuk dealer-nya |
| 5 | Data tab Customer lama dipindah ke baris: tiap baris produk program itu diisi customer pertama, lalu diduplikasi untuk customer berikutnya (perilaku tetap sama) |
```mermaid
flowchart TD
A["Scan IMEI mobile / input IMEI CMS"] --> B["Pemilik saldo<br/>(dealer; scan Staff Dealer → dealer-nya)"]
B --> C{"Ada baris produk IMEI ACTIVE<br/>di program ACTIVE & periode hari ini?"}
C -- "tidak" --> E1["NO_ACTIVE_REWARD"]
C -- "ya" --> D{"Ada baris dengan<br/>customer = dealer ini?"}
D -- "ya" --> F["Reward = nominal baris itu<br/>(mis. D → 15.000)"]
D -- "tidak" --> G{"Ada baris tanpa customer?"}
G -- "ya" --> H["Reward = nominal baris tanpa customer"]
G -- "tidak" --> E2["Mobile: NO_ACTIVE_REWARD<br/>CMS: Produk … tidak sedang mendapat reward /<br/>Reward program ini tidak berlaku untuk customer tersebut."]
F --> I["Nominal di-snapshot ke line pengajuan"]
H --> I
classDef ok fill:#d1fae5,stroke:#059669,color:#064e3b
classDef err fill:#fee2e2,stroke:#dc2626,color:#7f1d1d
class F,H,I ok
class E1,E2 err
```
Keterangan warna: hijau = dapat reward, merah = ditolak (kode / pesan error persis dari API & CMS).
**Yang dibuat (revisi 30/31-10-2026, CMS `0da379f`, API `c6fc18a`, ter-deploy dev 31-10-2026):**
| Bagian | Isi |
|---|---|
| Migration `2026_10_31_000001_add_user_id_to_reward_product_mapping_table` | Kolom `reward_product_mapping.user_id` (nullable) + index (`product_id`, `user_id`). Pindah data `reward_program_customer` → baris (aturan 5). Idempotent (`hasColumn`; program yang barisnya sudah punya `user_id` dilewati). Tabel lama **tidak di-drop** (API lama masih membacanya sampai ikut ter-deploy) |
| Form baris produk (`ProductMappingsRelationManager`) | Field **Customer** (1 dealer, opsional, hanya akun dealer — dicek ulang di server). Kolom **Customer** di tabel (kosong tampil "Semua dealer"), urut per produk |
| `RewardMappingOverlap` (baru) | Aturan bentrok 2 & 3, dipakai form dan import |
| Tab **Customer** di program | **Dihapus** (`CustomersRelationManager`) |
| `RewardProductMapping::customer()`, scope `appliesToUser()` | Relasi many2one + filter baris "`user_id` kosong atau = user ini" |
| `RewardProgram::appliesToUser()` | Program berlaku kalau punya baris ACTIVE untuk user ini (dipakai pilihan program di input IMEI CMS) |
| CMS `findActiveMapping`, Node `findActiveMappings` (+ field `user_id` di model Node) | Urutan pilih: baris customer = dealer ini → baris tanpa customer → mapping terbaru |
| `User::scopeRewardDealer()` | Query akun dealer (pindahan dari tab Customer) |
Hasil uji lokal 30-10-2026 (data tes dihapus / di-rollback):
| Skenario | Hasil |
|---|---|
| Produk `MX - 003`: 10.000 [443], 15.000 [445], 12.000 tanpa customer | CMS & Node: 443 → 10.000, 444 → 12.000, 445 → 15.000 |
| Baris tanpa customer di-INACTIVE-kan | 444 → CMS "tidak sedang mendapat reward", Node `NO_ACTIVE_REWARD`; program tidak muncul di pilihan input IMEI CMS untuk 444 |
| Form: produk sama, customer beda | Tersimpan |
| Form: dealer sudah punya baris produk sama | Ditolak "Dealer TEST REGISTRASI sudah punya baris produk ini di program ini. Satu dealer hanya boleh satu baris per produk." |
| Form: baris tanpa customer kedua | Ditolak "Produk ini sudah punya baris untuk semua dealer (tanpa customer) di program ini." |
| Form: program lain periode beririsan, program pertama punya baris tanpa customer | Ditolak "Produk ini sudah aktif di program TMP-F1 (…) untuk semua dealer." |
| Form: periode tidak beririsan | Tersimpan |
| Form: user internal dipilih | Ditolak "Hanya akun dealer (EXTERNAL, APPROVED, bukan staff) yang bisa dipilih." |
| Halaman List / Edit Reward Program, tabel baris produk, form input IMEI CMS | Render OK, tab Customer sudah tidak ada |
| Migration lokal | Program #1 (customer lama [443, 445], 6 baris produk) → 6 baris `user_id` 443 + 6 baris `user_id` 445; `up()` dijalankan ulang → tetap 12 (tidak dobel) |
> [!info] Deploy
> CMS dulu (`php artisan migrate --path=database/migrations/2026_10_31_000001_add_user_id_to_reward_product_mapping_table.php`),
> **baru** restart API — query Node baru membaca kolom `reward_product_mapping.user_id`. Setelah keduanya ter-deploy,
> `reward_program_customer` boleh di-drop lewat migration terpisah.
### Poin 6 · Export & Import Reward Program (Excel)
Tombol **Import** dan **Export** di halaman list Reward Program (`ListRewardPrograms`), logika di
`app/Services/RewardProgramExcelService.php`. Format **.xlsx** (OpenSpout), proses **sinkron** — bukan Import/Export
bawaan Filament, karena yang bawaan hanya baca CSV dan butuh queue worker (VPS hanya punya cron `schedule:run`).
**Format file** (file hasil Export = template Import) — **1 sheet**, 1 blok per program. Data program hanya di
baris pertama blok; **1 baris = 1 baris produk** (produk + nominal + 1 customer, kolom `customer_email`). Revisi
30-10-2026: customer pindah ke baris produk (sebelumnya kolom customer berjejer terpisah per program) — file format
lama ditolak dengan pesan untuk Export ulang.
| program_code | program_name | … | jobsheet_no | mapping_id | product_code | product_name | customer_email | customer_name | reward_amount | mapping_status |
|---|---|---|---|---|---|---|---|---|---|---|
| RWD-A | Program A | … | 001/NOV/2026/AREA | 12 | P-1 | … | a@… | A | 10000 | ACTIVE |
| | | | | 13 | P-1 | … | d@… | D | 15000 | ACTIVE |
| | | | | | P-2 | … | | | 20000 | ACTIVE |
| RWD-B | Program B | … | | 20 | P-1 | … | | | 10000 | INACTIVE |
Urutan kolom baris produk: **produk → customer → reward_amount** (permintaan 31-10-2026). Import membaca berdasarkan
nama header, jadi urutan kolom di file bebas.
Aturan:
- Export ikut filter / pencarian tabel yang sedang aktif.
- Import = **upsert, tidak menghapus baris**: program by `program_code`, baris produk by **`mapping_id`** (dari Export;
kosong = baris baru). Customer baris yang punya `mapping_id` **diganti** sesuai file. `mapping_id` harus milik program
& produk yang sama, tidak boleh dobel. Hapus baris tetap lewat form program.
- Baris dengan `program_code` = awal blok program baru; baris tanpa `program_code` = lanjutan program di atasnya.
Satu program cukup satu blok (program_code dobel ditolak). Kolom program di baris lanjutan harus kosong.
- `status` kosong = `DRAFT`, `mapping_status` kosong = `ACTIVE`, `claim_mode` hanya `FULL_BALANCE`.
`product_name` & `customer_name` hanya info, diabaikan saat import.
- Tanggal: cell tanggal Excel, `YYYY-MM-DD`, `DD/MM/YYYY`, atau `DD-MM-YYYY`. `end_date` kosong = tanpa batas.
- Mapping **baru** wajib produk aktif di master. Mapping **lama** tetap bisa di-update walau produknya sudah dihapus
(hilang dari sync Odoo), supaya file Export bisa di-Import balik.
- Aturan bentrok sama dengan form ([Poin 5](#Poin%205%20·%20Reward%20multi%20customer%20(customer%20per%20baris%20produk)) aturan 2 & 3) — dihitung dari kondisi
**setelah** import (antar baris file + data CMS, termasuk periode program lama yang digeser lewat file).
- Customer: **1 email per baris** (lebih dari satu → error "Buat baris baru untuk customer lain"), harus akun dealer
(EXTERNAL, APPROVED, bukan staff) — query sama dengan form baris produk.
- **1 baris error = tidak ada yang disimpan** (keputusan 30-10-2026). Notifikasi menampilkan maksimal 20 error per baris.
- Tombol Import hanya muncul untuk user dengan izin create + update Reward Program.
- **Export terpilih** (revisi 30-10-2026): centang program di kiri tabel → bulk action **Export terpilih** hanya
meng-export program yang dicentang. Tombol **Export** di header tetap meng-export semua sesuai filter.
- Kolom `jobsheet_no` di baris program — aturannya di [Poin 8–9](#Poin%208–9%20·%20Jobsheet%20Odoo%20→%20CMS%20→%20Vendor%20Bill).
#### Alur Import
```mermaid
flowchart TD
A["Upload .xlsx<br/>(Import di list Reward Program)"] --> B{"File bisa dibaca<br/>dan kolom template ada?"}
B -- "tidak" --> E1["Import dibatalkan<br/>(file tidak valid / kolom tidak ditemukan)"]
B -- "ya" --> C["Baca baris per blok program<br/>(program_code terisi = program baru,<br/>kosong = lanjutan program di atasnya)"]
C --> D["Validasi: data program, mapping_id milik program & produk,<br/>product_code, reward_amount >= 1, email = akun dealer,<br/>program / mapping_id / customer per baris tidak dobel"]
D --> F{"Ada error?"}
F -- "tidak" --> G["Cek bentrok baris ACTIVE<br/>(produk sama, periode beririsan,<br/>customer beririsan / tanpa customer)"]
G --> H{"Ada error?"}
F -- "ya" --> E2["Import dibatalkan,<br/>tidak ada data yang disimpan<br/>(daftar error per baris)"]
H -- "ya" --> E2
H -- "tidak" --> I["DB transaction:<br/>upsert program by program_code<br/>upsert baris by mapping_id (kosong = baru)<br/>customer baris = isi file"]
I --> J["Import selesai<br/>(jumlah program baru / update,<br/>baris produk baru / update)"]
classDef ok fill:#d1fae5,stroke:#059669,color:#064e3b
classDef err fill:#fee2e2,stroke:#dc2626,color:#7f1d1d
class J ok
class E1,E2 err
```
Hijau = sukses, merah = ditolak.
Teruji lokal 30-10-2026 (semua di-rollback): export 1 sheet berbentuk blok; import program baru + mapping
ACTIVE/INACTIVE + customer; import ulang file yang sama (update, tidak dobel); round-trip Export → Import `RWD-OKT26`
(produk sudah terhapus); error validasi per baris (baris tanpa program, data program di baris lanjutan, program /
produk / customer dobel); bentrok antar baris file, bentrok dengan data CMS, periode tidak beririsan / INACTIVE lolos,
program lama di-ENDED lewat file lalu produknya dipakai program baru lolos, periode program lama digeser jadi bentrok
ditolak; tombol Import / Export lewat Livewire.
Teruji lokal revisi customer per baris 31-10-2026 (di-rollback): export 1 baris = 1 baris produk + 1 email customer;
import ulang file export → 3 update; ganti customer baris lewat `mapping_id` 443 → 444 → tersimpan; baris baru dengan
dealer yang sudah punya baris → "Baris 5 (TMP-F1, produk MX - 003): Dealer CV MAJU JAYA sudah punya baris produk ini di
program ini. … (bentrok dengan baris 3)"; 2 email di 1 baris → "customer_email hanya boleh 1 email per baris";
`mapping_id` tidak dikenal / file format lama → ditolak.
### Poin 7 · Hapus effective from & to di mapping produk
**Kenapa dulu ada:** FDD Reward §3.2 — supaya nominal bisa diganti di tengah program (mapping lama diberi
`effective_to`, buat mapping baru). Akibatnya dua lapis tanggal (header program + mapping) dan produk bisa "tidak
dapat reward" padahal programnya aktif.
**Kenapa aman dihapus:** nominal di-snapshot ke line pengajuan IMEI saat submit (`reward_amount`) dan EARN di ledger
memakai nilai line itu, jadi mengubah nominal mapping tidak mengubah reward yang sudah tercatat.
| Bagian | Sebelum | Sesudah |
|---|---|---|
| Form & tabel mapping CMS | Effective From / To | Produk, nominal, status saja |
| Cek reward aktif (CMS `findActiveMapping`, Node `findActiveMappings`) | Tanggal mapping **dan** tanggal program | Tanggal program saja |
| Aturan bentrok | 1 produk 1 mapping ACTIVE per tanggal mapping | 1 produk 1 mapping ACTIVE di program yang periodenya beririsan |
| Mapping sudah dipakai ledger | Produk + nominal + tanggal dikunci | Produk dikunci, **nominal boleh diedit** (berlaku untuk scan berikutnya) |
| Kolom DB `effective_from` / `effective_to` | Dipakai | **Tidak di-drop** (tanpa migrasi); `effective_from` diisi `start_date` program saat create karena NOT NULL |
Hasil uji lokal 28-10-2026 (Livewire + transaksi di-rollback, program `RWD-OKT26` 01–31 Okt 2026):
| # | Skenario | Hasil |
|---|---|---|
| 1 | Produk 1824, mapping `effective_to` 14 Okt sudah lewat, program masih aktif | Dulu `NO_ACTIVE_REWARD` → sekarang **lolos** (Node `checkImei` & cek IMEI CMS), Rp 10.000 |
| 2 | Tambah mapping produk baru dari CMS | OK, `effective_from` otomatis 01-10-2026 (= `start_date` program) |
| 3 | Tambah produk yang sudah ACTIVE di program yang sama | Ditolak: "Produk ini sudah punya mapping aktif di program RWD-OKT26 (01 Oct 2026 s/d 31 Oct 2026)…" |
| 4 | Edit nominal mapping yang sudah dipakai ledger 10.000 → 25.000 | OK, ledger lama tetap Rp 10.000 |
| 5 | Kolom "Effective" di tabel mapping | Sudah tidak ada |
> [!warning] Belum dicek: ubah tanggal header program
> Bentrok antar program hanya divalidasi saat simpan **mapping**. Kalau `start_date` / `end_date` program diubah
> sampai beririsan dengan program lain yang punya produk sama, tidak ada validasi — sistem memilih mapping terbaru.
### Poin 8–9 · Jobsheet Odoo → CMS → Vendor Bill
**Konsep:** nomor Jobsheet **tidak diketik** di CMS, tapi **dipilih** dari dropdown yang memanggil Odoo **realtime**
→ anti-typo tanpa perlu masking format.
**Keputusan teknis 30-10-2026 — tanpa tabel master jobsheet di CMS (tanpa cron sync):**
- Odoo sumber kebenaran; status Jobsheet (`done` / `cancel` / periode habis) langsung kelihatan, tidak basi menunggu cron.
- Setup Reward Program jarang (beberapa kali sebulan) → tidak perlu cron yang jalan terus.
- CMS cukup simpan **snapshot** `odoo_jobsheet_id` + `jobsheet_no` di `reward_program`, supaya list / export / histori
tetap tampil walau Odoo mati. Ketergantungan ke Odoo bukan risiko baru — claim → Vendor Bill memang sudah butuh Odoo.
**Keputusan bisnis 30-10-2026 (Oliver):** "1 jobsheet bisa banyak reward, inputan nomor jobsheet pure hanya untuk
referensi di vendor bill". Jadi Jobsheet **tidak** dihubungkan ke AP Form (`snk_ap_form`) dan **tidak** memotong budget
Jobsheet saat bill di-post. 1 claim tetap 1 bill.
**Yang dibuat (30-10-2026, Odoo `bb955bd2` di `cj/api`, CMS `54285e6` di `develop`, belum deploy):**
| Repo | Bagian | Isi |
|---|---|---|
| mito_odoo · `snk_jobsheet_operation` | `controllers/api_jobsheets.py` | `GET /api/v1/jobsheets` + `GET /api/v1/jobsheets/<id>` (lihat di bawah). Di modul jobsheet karena `mito_base` tidak depend ke modul ini; tetap pakai `api_route` `mito_base` → auth, format respons, Swagger tag **Jobsheet** |
| mito_odoo · `mito_base` | `account.move.snk_reward_jobsheet_ref` | Field Char **Jobsheet No.** (tracking). Tampil di form Vendor Bill di bawah Bill Reference, **hanya untuk bill hasil claim reward**, bisa diedit selama Draft |
| mito_odoo · `mito_base` | `POST /api/v1/reward-bills` | Body opsional `jobsheet_no` (string, tidak divalidasi), respons ikut `jobsheet_no`. Retry Claim ID sama → bill lama dikembalikan apa adanya |
| mito_odoo · `mito_base` | `__manifest__.py` | Version `18.0.1.0.5` (develop sudah `1.0.4`). Kolom baru dibuat otomatis oleh `-u`, tanpa migration script |
| sfa-cms | Migration `2026_10_30_000001_add_jobsheet_to_reward_program_table` | Kolom `reward_program.odoo_jobsheet_id` + `jobsheet_no` (snapshot nomor). Idempotent (`hasColumn`) |
| sfa-cms | Form Reward Program | Field **Jobsheet**: dropdown cari realtime ke Odoo (label `nomor — subject`), nomor di-snapshot ke `jobsheet_no`. Gagal ambil nomor → form error, tidak tersimpan |
| sfa-cms | Tabel Reward Program | Kolom **Jobsheet** (bisa dicari) |
| sfa-cms | Export / Import Excel | Kolom `jobsheet_no` di baris program (lihat aturan di bawah) |
| sfa-cms | `RewardClaimOdooService` | Kirim `jobsheet_no` = Jobsheet program asal saldo claim (`jobsheetNo()`) |
| sfa-cms | `JobsheetOdooService` (baru) | Panggilan `GET /api/v1/jobsheets` untuk form & import |
**Nomor Jobsheet sebuah claim** (`RewardClaimOdooService::jobsheetNo`): claim selalu seluruh saldo, jadi saldonya =
EARN user itu **sejak CLAIM_DEBIT sebelumnya sampai CLAIM_DEBIT claim ini** (id ledger berurutan, saldo di-lock saat
claim — berlaku untuk claim dari mobile maupun CMS). Ambil `jobsheet_no` program-program EARN tersebut, unik, urut,
dipisah koma. Program tanpa Jobsheet dilewati; kalau tidak ada sama sekali, `jobsheet_no` tidak dikirim.
**Aturan Jobsheet di Import Excel:**
- Kolom `jobsheet_no` **tidak ada** di file (template lama) → Jobsheet program tidak disentuh.
- Kosong → Jobsheet program dihapus.
- Nomor **baru / berubah** → dicek ke Odoo dalam **1 request batch**; harus ada & On Progress. Tidak ketemu → error
per baris, seluruh file ditolak (aturan import yang sama).
- Nomor **sama** dengan data CMS → tidak dicek ulang, supaya file Export tetap bisa di-Import walau Jobsheet-nya sudah Done.
- Odoo tidak bisa dihubungi → import ditolak dengan pesan jelas.
#### API `GET /api/v1/jobsheets`
| Param | Isi |
|---|---|
| `search` | Cari di nomor Jobsheet / subject — untuk dropdown |
| `reference` | Exact match, pisahkan koma untuk banyak nomor — validasi import Excel 1 request |
| `state` | Default `on_progress`. Boleh beberapa dipisah koma, atau `all`. Nilai lain → `422 validation_error` |
| `limit` / `offset` | Default 50, max 200 |
Jobsheet yang masih bernomor `New` (belum di-confirm) tidak pernah dikirim. Contoh 1 record:
```json
{
"id": 958,
"reference": "091/SEP/2026/DEP-TM",
"subject": "Produksi Flyer,POP, dan Wobbler untuk September",
"category": "support",
"operating_unit": {"id": 612, "name": "HO-Trade Marketing"},
"pic": {"id": 1206, "name": "[False] [00] Administrator"},
"date_from": "2026-09-13",
"date_to": "2026-09-30",
"state": "on_progress",
"write_date": "2026-10-26 07:10:50"
}
```
Label dropdown CMS yang disarankan: `reference — subject` (mis. `091/SEP/2026/DEP-TM — Produksi Flyer…`).
Hasil uji lokal 30-10-2026, DB `MITO_PRODUCTION_20082026` (copy production):
| Skenario | Hasil |
|---|---|
| Tanpa API key | `401 unauthorized` |
| Default | **729** Jobsheet `on_progress` = jumlah di DB (user API tidak terhalang operating unit rule) |
| `reference` = 2 nomor benar + 1 typo | Hanya 2 yang kembali → nomor typo terdeteksi |
| `search=2026` | OK |
| `state=all` | **761** = semua Jobsheet bernomor (729 + 1 + 2 + 13 + 16) |
| `state=approved` (tidak ada di Odoo) | `422 validation_error` |
| `GET /jobsheets/999999` | `404 not_found` |
| `limit=500` | Dibatasi 200 |
#### Alur 1 · Pilih Jobsheet di Reward Program (realtime)
```mermaid
sequenceDiagram
autonumber
actor MKT as Marketing (Odoo)
participant OD as Odoo (jobsheet.operation)
participant API as Odoo REST /api/v1/jobsheets
participant CMS as CMS SFA (Filament)
actor ADM as Admin CMS
MKT->>OD: Confirm Jobsheet
OD->>OD: state = on_progress<br/>snk_reference = "001/OKT/2026/CODE"
rect rgb(240, 253, 244)
Note over API: Di-push 30-10-2026 (bb955bd2), belum deploy
end
ADM-->>CMS: Form Reward Program → ketik di dropdown Jobsheet
CMS->>API: GET /api/v1/jobsheets?search=OKT/2026
API->>CMS: [{id, reference, subject, date_from, date_to, state}]<br/>(default hanya on_progress)
ADM-->>CMS: Pilih satu Jobsheet
CMS-->>CMS: simpan reward_program.odoo_jobsheet_id<br/>+ snapshot jobsheet_no
Note over CMS,API: Import Excel: 1 request batch
CMS->>API: GET /api/v1/jobsheets?reference=A,B,C
API->>CMS: hanya nomor yang ada & on_progress
CMS-->>CMS: ada nomor yang tidak kembali → seluruh file ditolak
```
Panah utuh = request ke Odoo, panah putus-putus = aksi admin / proses di CMS.
#### Alur 2 · Claim → Draft Vendor Bill bawa Jobsheet No.
```mermaid
flowchart TD
A["Claim full balance<br/>(mobile / CMS)<br/>reward_claim QUEUED"] --> B["Cron odoo:push-reward-claims<br/>RewardClaimOdooService"]
B --> C["jobsheetNo(): EARN sejak CLAIM_DEBIT<br/>sebelumnya s/d CLAIM_DEBIT claim ini"]
C --> D{"Program asal saldo<br/>punya Jobsheet?"}
D -- "tidak satu pun" --> E["POST /api/v1/reward-bills<br/>tanpa jobsheet_no"]
D -- "ya (1 atau lebih)" --> F["POST /api/v1/reward-bills<br/>jobsheet_no = 'A, B' (unik, urut)"]
E --> G{"Vendor & Reward Product valid?"}
F --> G
G -- "tidak" --> E1["422 vendor_not_found / vendor_inactive /<br/>reward_product_not_set / reward_product_invalid<br/>→ PERMANENT_ERROR"]
G -- "ya" --> H["1 Draft Vendor Bill per claim<br/>Jobsheet No. = referensi<br/>(tanpa AP Form, budget tidak terpotong)"]
H --> I["Finance post & bayar seperti biasa"]
classDef ok fill:#d1fae5,stroke:#059669,color:#064e3b
classDef err fill:#fee2e2,stroke:#dc2626,color:#7f1d1d
class H,I ok
class E1 err
```
Keterangan warna: hijau = bill dibuat, merah = ditolak (kode error persis dari API Odoo). Nomor Jobsheet **tidak**
divalidasi Odoo saat bill dibuat (murni referensi) — validasinya sudah terjadi saat admin memilih Jobsheet di CMS.
Hasil uji lokal 30-10-2026 (CMS di-rollback, bill tes di Odoo dihapus):
| Skenario | Hasil |
|---|---|
| Odoo `-u mito_base` di `MITO_DEV` + `TestRewardClaimBill` | **12 / 12 lolos** (2 test baru: simpan Jobsheet, Jobsheet kosong) |
| `POST /reward-bills` + `jobsheet_no` 2 nomor | 201, bill Draft, **Jobsheet No.** = `001/OKT/2026/AREA, 005/OKT/2026/DEP-MKT` |
| Retry Claim ID sama, `jobsheet_no` beda | 200 `created: false`, Jobsheet bill tidak berubah |
| CMS form: pilih Jobsheet #149 | Tersimpan `odoo_jobsheet_id = 149`, `jobsheet_no = 001/JUN/2026/JABO` |
| CMS form: id Jobsheet tidak ada di Odoo | Error form, tidak tersimpan |
| CMS form: kosongkan Jobsheet | Dua kolom jadi NULL |
| Export | Kolom `jobsheet_no` terisi |
| Import: 1 nomor benar + 1 typo | Seluruh file ditolak: "Baris 3: Jobsheet 999/XXX/2026/TYPO tidak ditemukan di Odoo atau statusnya bukan On Progress." |
| Import: nomor benar / kosong / sama dengan CMS / file tanpa kolom | Tersimpan + id Odoo / NULL / tidak dicek ulang / tidak disentuh |
| Claim: EARN 2 program Jobsheet sama + 1 Jobsheet lain + 1 tanpa Jobsheet, EARN sebelum claim lalu & sesudah claim ini | `jobsheet_no` = `001/OKT/2026/AREA, 005/OKT/2026/DEP-MKT` (EARN di luar rentang tidak ikut) |
| Claim → Odoo lewat `OdooClient` | 201, Jobsheet No. tersimpan di bill |
> [!warning] Belum teruji end-to-end lewat `send()`
> Di CMS lokal belum ada dealer yang terhubung ke partner Odoo (`customer_not_linked`), jadi payload dikirim langsung
> lewat `OdooClient` dengan partner tes. Logika pencarian partner di `send()` tidak berubah. Uji ulang di dev setelah deploy.
### Poin 10 · Staff Dealer hanya scan
**Keputusan 28-10-2026:** reward dari IMEI yang di-scan staff masuk ke **saldo dealer**-nya. Sebelumnya masuk ke saldo
staff sendiri — kalau saldo cuma disembunyikan, reward-nya tertahan dan tidak bisa di-claim siapa pun.
Staff dikenali dari tabel `staff_registration` (`user_id` staff → `dealer_user_id`), **bukan nama role** — nama role
pernah di-rename (Customer → Dealer, lihat [[2026-10-20_registrasi-role-customer-direname-dealer]]).
```mermaid
flowchart TD
A["Request /reward/* (token /auth/login)"] --> B{"user_id ada di<br/>staff_registration?"}
B -- "tidak" --> C["Dealer / customer biasa<br/>owner = dirinya sendiri"]
B -- "ya" --> D{"Dealer APPROVED?"}
D -- "tidak" --> E1["403 DEALER_NOT_ACTIVE"]
D -- "ya" --> F{"Endpoint?"}
F -- "balance / transactions / claim / claims" --> E2["403 STAFF_NOT_ALLOWED"]
F -- "imei/check, imei (submit)" --> G["Pengajuan atas nama dealer<br/>user_id = dealer, submitted_by = staff<br/>respon tanpa balance"]
F -- "imei-submissions" --> H["Hanya pengajuan berisi IMEI scan staff tsb<br/>line & total dari IMEI staff saja"]
F -- "imei/attachment" --> I{"Line di-scan staff ini?"}
I -- "tidak" --> E3["404 LINE_NOT_FOUND"]
I -- "ya" --> J["Nota diganti"]
G --> K["Approve CMS → EARN ke saldo dealer"]
M["Mobile: sembunyikan menu saldo / claim untuk staff"]
classDef ok fill:#d1fae5,stroke:#059669,color:#064e3b
classDef err fill:#fee2e2,stroke:#dc2626,color:#7f1d1d
classDef todo fill:#f3f4f6,stroke:#9ca3af,color:#374151,stroke-dasharray:4 3
class C,G,H,J,K ok
class E1,E2,E3 err
class M todo
```
Keterangan warna: hijau = diizinkan, merah = ditolak (kode error API), abu-abu putus-putus = belum dikerjakan (mobile).
Hasil uji lokal 28-10-2026 (user 26 dijadikan staff dealer 445 CV MAJU JAYA sementara, data dihapus setelah tes):
| Skenario | Hasil |
|---|---|
| Staff `GET /reward/balance`, `/transactions`, `/claims`, `POST /reward/claim` | 403 `STAFF_NOT_ALLOWED` |
| Staff `GET /reward/imei/check` | `scannable: true` |
| Staff submit IMEI | Masuk header dealer, DB `user_id = 445`, `submitted_by = 26`, respon tanpa `balance` |
| Dealer submit IMEI lain | Masuk header terbuka yang sama |
| Staff `GET /reward/imei-submissions` | Hanya IMEI miliknya, `total_amount` dari IMEI staff saja |
| Dealer `GET /reward/imei-submissions` / balance | Melihat IMEI staff + dealer, `pending_approval` ikut naik |
| Staff ganti nota IMEI milik dealer | 404 `LINE_NOT_FOUND` |
---
## Commit & Status Deploy
| Repo | Commit | Branch | Poin | Isi | Status |
|---|---|---|---|---|---|
| sfa-api | `4e31c0f` | `develop` | 1–3 | 1 IMEI 1x reward, hanya terjual, attachment opsional, `GET /reward/imei/check` | Ter-deploy dev 28-10-2026 |
| sfa-cms | `fdb639f` | `develop` | 2 | Kolom `product_qty`, sync stok, cek input CMS | Ter-deploy dev |
| sfa-cms | `14d3d87` | `develop` | 2 | Master IMEI hanya simpan `product_qty = 0` | Ter-deploy dev 28-10-2026 |
| mito_odoo | `42b94a81` | `develop` | 2 | API IMEI kirim `product_qty` | Sudah di `develop` |
| sfa-cms | `2a8e1a0` | `develop` | 4 | Minimum claim Rp 500.000 | Ter-deploy dev 28-10-2026 (Jenkins) |
| sfa-cms | `e785045` | `develop` | 7 | Hapus effective from/to mapping, periode ikut header program | Ter-deploy dev 28-10-2026 (Jenkins) |
| sfa-api | `5c1c203` | `develop` | 4, 7, 10 | Minimum claim + mapping tanpa effective date + Staff Dealer hanya scan | Ter-deploy dev 28-10-2026 (git bundle + `sudo pm2 restart sfa-api-dev`) |
| sfa-cms | `609ed39` | `develop` | 5 | Multi customer: tabel `reward_program_customer`, tab Customer, filter program per dealer | Ter-deploy dev 30-10-2026 (Jenkins, migration ikut jalan) |
| sfa-api | `35e312d` | `develop` | 5 | Multi customer (versi tab Customer): filter program per dealer di `findActiveMappings` | Ter-deploy dev 30-10-2026 (git bundle + `sudo pm2 restart sfa-api-dev`) |
| sfa-cms | `085b73e` | `develop` | 6 | Export & import Excel Reward Program (1 sheet, blok per program) | Ter-deploy dev 30-10-2026 |
| mito_odoo | `bb955bd2` | `cj/api` | 8, 9 | `GET /api/v1/jobsheets` (`snk_jobsheet_operation`) + field **Jobsheet No.** di Vendor Bill + `jobsheet_no` di `POST /reward-bills`, version `18.0.1.0.5` | Di-push 30-10-2026, `develop` sudah di-merge ke `cj/api` (`08c9413a`, tanpa konflik) → **menunggu review senior / deploy** |
| sfa-cms | `54285e6` | `develop` | 6, 8, 9 | Export program terpilih (centang), field Jobsheet (dropdown Odoo), kolom `jobsheet_no` Excel, kirim `jobsheet_no` saat claim | Ter-deploy dev 30-10-2026, migration `2026_10_30_000001` sudah Ran. Dropdown Jobsheet masih **404** sampai Odoo dev di-deploy |
| sfa-cms | `0da379f` | `develop` | 5, 6 | Revisi: customer per baris produk (kolom `reward_product_mapping.user_id`, field Customer many2one di baris, tab Customer dihapus, aturan bentrok baru), format Excel 1 baris = 1 baris produk + 1 customer + `mapping_id`, urutan kolom produk → customer → reward_amount | Ter-deploy dev 31-10-2026 (Jenkins, migration `2026_10_31_000001` Ran; program #7 customer [478, 479] → 2 baris) |
| sfa-api | `c6fc18a` | `develop` | 5 | Revisi: `findActiveMappings` pilih baris per dealer (`user_id` = dealer → `user_id` kosong) + field `user_id` di model | Ter-deploy dev 31-10-2026 (git bundle + `sudo pm2 restart sfa-api-dev`); smoke test `checkImei` dealer 478 / 479 → 500.000 dari baris masing-masing |
| mito_odoo | `89351a4d` | `cj/api` | 2 | Param `sold_only` di `GET /api/v1/imeis` — **dipakai CMS full sync** (`SyncOdooImeis`: `sold_only=1` saat bukan incremental) supaya hanya menarik IMEI terjual | Ikut PR `cj/api` (diputuskan 30-10-2026) |
## Catatan Deploy
> [!info] Deploy API dev (`/var/www/sfa_api_mito`)
> Server tidak bisa `git pull` HTTPS (tanpa kredensial) → kirim **git bundle** dari lokal lalu
> `git pull --ff-only <bundle> develop`, restart **`sudo pm2 restart sfa-api-dev`** (pm2 milik root, port 3069, route tanpa
> prefix: `/reward/...`). 28-10-2026 pull sempat gagal karena `routes/handler/reward`, `swagger`, dan sebagian `.git`
> milik root → `sudo chown -R ubuntu:ubuntu /var/www/sfa_api_mito`. **Jangan deploy API pakai sudo** supaya tidak terulang.
> [!warning] Poin 2 — setelah deploy CMS wajib full sync IMEI
> `php artisan migrate` lalu `php artisan odoo:sync-imeis --reset`. Incremental saja tidak menarik IMEI lama, jadi
> `product_qty` tetap NULL. Dev: full sync dijalankan 28-10-2026 (±810 ribu IMEI ditarik).
> [!info] Poin 5 — urutan deploy customer per baris produk (revisi 30-10-2026)
> 1. CMS: `php artisan migrate --path=database/migrations/2026_10_31_000001_add_user_id_to_reward_product_mapping_table.php`
> (kolom `user_id` + pindah data tab Customer lama ke baris).
> 2. **Baru** API: git bundle + `sudo pm2 restart sfa-api-dev` — query Node baru membaca kolom `user_id`.
> 3. `reward_program_customer` (versi tab Customer 29-10-2026) dibiarkan dulu; drop lewat migration terpisah setelah
> keduanya ter-deploy.
> [!info] Poin 8 & 9 — deploy Jobsheet (urutan: Odoo dulu, baru CMS)
> 1. Odoo: `-u mito_base` (field **Jobsheet No.** + view, version `18.0.1.0.5`) lalu restart — `snk_jobsheet_operation`
> cukup restart (hanya controller). Ikuti [[Mito — Upgrade Playbook Production]]: **upgrade semua server** yang share DB.
> 2. CMS: `php artisan migrate --path=database/migrations/2026_10_30_000001_add_jobsheet_to_reward_program_table.php`.
> Kalau CMS lebih dulu dari Odoo, claim yang membawa `jobsheet_no` tetap diterima Odoo lama (field tak dikenal diabaikan),
> tapi nomornya tidak tersimpan — jadi tetap deploy Odoo dulu.
> - `develop` sudah di-merge ke `cj/api` 30-10-2026 (`08c9413a`, konflik version diselesaikan → `18.0.1.0.5`).
> Teruji `MITO_DEV` 1.0.3 → 1.0.5: upgrade OK, `TestRewardClaimBill` 12/12.
> - `tests/__init__.py` (juga di `develop`) meng-import `test_partner_credit_limit_validation` yang filenya tidak ada →
> `--test-enable` di `mito_base` gagal load. Bukan dari PR ini; perlu diperbaiki pemilik test tersebut.
> - **Lokal saja:** `-u mito_base` di DB `MITO_PRODUCTION_20082026` gagal `open_customer_statement is not a valid action
> on res.partner` — view `account_followup` di DB berasal dari Enterprise production yang lebih baru, sedangkan
> `addons_e` lokal lama. Tidak terjadi di server (kode Enterprise sama dengan DB-nya).
> - User API (`mito_base.api_user_id`) wajib punya akses baca `jobsheet.operation`; kalau kena operating unit rule,
> Jobsheet di luar cabangnya tidak muncul.
> - Server wajib `db_name` / `dbfilter` satu database. Tanpa itu, request CMS (tanpa session) tidak tahu DB mana →
> **semua** `/api/v1/*` balas 404. Di lokal ada 2 DB (`MITO_DEV`, `MITO_PRODUCTION_20082026`) dan `odoo.conf` tidak
> set `db_name` / `dbfilter`, jadi tes lokal butuh cookie session `/web/login?db=...` dulu.
## Sisa Pekerjaan (urutan saran)
1. **PR** mito_odoo `cj/api` → `develop` (`sold_only` + Jobsheet, tanpa konflik) — menunggu review senior.
2. ~~Commit sfa-cms~~ ✅ `54285e6` di-push ke `develop`.
3. **Deploy Odoo dev** (`mitodev.sinerka.id`, DB `MITO_PRODUCTION_20082026`) setelah review senior: `-u mito_base` + restart. CMS & API dev sudah ter-deploy 30-10-2026; sampai Odoo di-deploy, dropdown Jobsheet CMS dapat 404 ("Daftar Jobsheet Odoo tidak bisa diambil").
4. **Uji di dev** claim end-to-end dengan dealer yang sudah terhubung ke partner Odoo → cek Jobsheet No. di Vendor Bill.
5. **Mobile:** sembunyikan menu saldo / claim untuk Staff Dealer.
6. ~~Commit + deploy revisi customer per baris produk~~ ✅ dev 31-10-2026. Sisa: migration drop `reward_program_customer` (tabel sudah tidak dipakai).
7. Keputusan K4 (celah IMEI belum masuk gudang), ~~K5 (nominal terlihat staff)~~ ✅ 11-11-2026.