# Role Permission Matrix Sistem Inventory Walet

## 1. Tujuan
Dokumen ini mendefinisikan hak akses per role agar implementasi backend, frontend, dan audit trail konsisten.

## 2. Role Utama
- Owner
- Admin Purchasing
- Admin Gudang
- Tim Sortasi / QC
- Admin Sales

## 3. Prinsip Akses
- setiap aksi sensitif harus tercatat user-nya
- role hanya boleh akses modul yang relevan
- owner default lebih banyak read daripada write
- aksi yang memengaruhi qty lot harus dibatasi ketat
- traceability dan report penting minimal bisa dibaca owner

## 4. Matrix Hak Akses

| Modul / Aksi | Owner | Purchasing | Gudang | QC | Sales |
|---|---|---|---|---|---|
| Lihat Dashboard | Yes | Yes | Yes | Yes | Yes |
| Lihat Master Data | Yes | Yes | Yes | Yes | Yes |
| Buat/Edit Supplier | Yes | Yes | No | No | No |
| Buat/Edit Customer | Yes | No | No | No | Yes |
| Buat/Edit Jenis & Grade | Yes | Limited | No | Limited | No |
| Buat/Edit Gudang & Lokasi | Yes | No | Yes | No | No |
| Buat Pembelian | Yes | Yes | No | No | No |
| Edit Draft Pembelian | Yes | Yes | No | No | No |
| Submit Pembelian | Yes | Yes | No | No | No |
| Cancel Pembelian | Yes | Yes | No | No | No |
| Lihat Histori Harga Beli | Yes | Yes | No | No | No |
| Buat Receipt | Yes | No | Yes | No | No |
| Finalize Receipt | Yes | No | Yes | No | No |
| Generate Lot | Yes | No | Yes | No | No |
| Print/Reprint Label | Yes | No | Yes | Yes | No |
| Lihat Stock Summary | Yes | Yes | Yes | Yes | Yes |
| Lihat Stock Lot | Yes | No | Yes | Yes | Yes |
| Lihat Lot Detail | Yes | No | Yes | Yes | Yes |
| Hold/Release Lot | Yes | No | Yes | Limited | No |
| Transfer Lot | Yes | No | Yes | No | No |
| Stock Opname | Yes | No | Yes | No | No |
| Stock Adjustment | Yes | No | Yes | Limited | No |
| Buat Sorting Session | Yes | No | No | Yes | No |
| Submit Hasil Sortasi | Yes | No | No | Yes | No |
| Regrade Lot | Yes | No | No | Yes | No |
| Lihat Traceability | Yes | Limited | Yes | Yes | Yes |
| Buat Sales Order | Yes | No | No | No | Yes |
| Edit Draft Sales | Yes | No | No | No | Yes |
| Allocate Lot ke Sales | Yes | No | No | No | Yes |
| Auto Allocate | Yes | No | No | No | Yes |
| Confirm Picking | Yes | No | Yes | No | Yes |
| Finalize Sales | Yes | No | No | No | Yes |
| Buat Sales Return | Yes | No | Yes | No | Yes |
| Buat Purchase Return | Yes | Yes | Yes | No | No |
| Lihat Reports | Yes | Limited | Limited | Limited | Limited |
| Export Reports | Yes | Limited | Limited | Limited | Limited |
| Ubah Settings Sistem | Yes | No | No | No | No |
| Kelola User & Role | Yes | No | No | No | No |

## 5. Keterangan Limited
Limited berarti akses dibatasi konteks tertentu.

### Owner
- full read
- write untuk approval, oversight, dan kondisi pengecualian

### Purchasing limited pada jenis/grade
- boleh usulkan / manage jika memang proses bisnis mengizinkan
- idealnya tetap lewat owner/admin utama

### QC limited pada hold/release atau adjustment
- QC bisa memberi rekomendasi
- aksi final bisa dibatasi butuh approval gudang/owner jika diinginkan

### Reports limited
Role non-owner hanya melihat laporan relevan:
- Purchasing: pembelian, supplier quality sederhana
- Gudang: stok, aging, shrinkage operasional
- QC: sortasi, regrade, shrinkage
- Sales: sales, margin dasar, trace per order

## 6. Rekomendasi Rule Akses Tambahan
### Rule 1
Lot CLOSED atau REJECTED tidak bisa dipakai untuk sales allocation.

### Rule 2
Lot HOLD tidak bisa dipicking sampai dilepas.

### Rule 3
Adjustment dengan dampak besar bisa diberi approval tambahan.

### Rule 4
Reprint label harus tercatat siapa yang melakukan.

### Rule 5
Finalize receipt, finalize sales, stock adjustment, regrade, dan sorting submit harus masuk audit log wajib.

## 7. Audit Log Minimum
Aksi yang wajib tercatat:
- create/update/cancel purchase
- finalize receipt
- generate lot
- transfer lot
- hold/release lot
- stock adjustment
- sorting submit
- regrade
- allocation submit
- picking confirm
- finalize sales
- returns
- label reprint

## 8. Frontend Visibility Rules
### Owner
Lihat semua menu.

### Purchasing
Tampilkan:
- dashboard
- supplier
- purchases
- purchase returns
- laporan pembelian

### Gudang
Tampilkan:
- dashboard
- receipts
- lots
- transfer
- stock adjustments
- barcode
- stock reports

### QC
Tampilkan:
- dashboard
- lots
- sorting
- regrade
- QC-related reports

### Sales
Tampilkan:
- dashboard
- customers
- sales
- allocation
- picking
- sales returns
- traceability lookup
- sales reports

## 9. Kesimpulan
Matrix ini menjaga agar sistem tetap aman, jelas, dan sesuai alur kerja nyata. Role paling sensitif terhadap integritas stok adalah Gudang, QC, dan Sales, sehingga semua aksi mereka harus terhubung ke audit trail yang kuat.