> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quinnsambal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Channels

<style>
  {`
    [class*="max-w-none"][class*="table"] {
      display: block !important;
      overflow-x: auto !important;
      max-width: 100% !important;
      width: 100% !important;
      flex-grow: 0 !important;
    }
    [class*="max-w-none"][class*="table"] > table {
      width: 100% !important;
      max-width: 100% !important;
      table-layout: fixed !important;
    }
    .mermaid {
      max-width: 100% !important;
      overflow-x: auto !important;
    }
    article svg[role="img"] {
      max-width: 100% !important;
      height: auto !important;
    }
    article img, .prose img {
      max-width: 100% !important;
      height: auto !important;
    }
    img[src*="LOGO"], img[src*="logo"] {
      max-width: 120px !important;
      max-height: 40px !important;
      width: auto !important;
      height: auto !important;
      object-fit: contain !important;
    }
    `}
</style>

***

title: "Sales Channels"
description: "Konfigurasi 8 channel penjualan dengan pricing per channel, default memory, quick switch, dan integrasi marketplace."
-----------------------------------------------------------------------------------------------------------------------------------

# Sales Channels

<img src="https://mintcdn.com/quinnofspicy/e4f_upKhVWcjsUmM/docs/mintlify/screenshots/pos/pos-members.png?fit=max&auto=format&n=e4f_upKhVWcjsUmM&q=85&s=0150cde7bf822b1c55b82794f1257772" alt="Sales Channels" width="1920" height="1080" data-path="docs/mintlify/screenshots/pos/pos-members.png" />

SNISHOP ERP mendukung **8 channel penjualan** dengan harga yang bisa berbeda per channel. Setiap channel memiliki karakteristik, strategi pricing, dan integrasi yang berbeda — memungkinkan bisnis menjangkau pelanggan melalui berbagai touchpoint.

## Channel yang Tersedia

| # | Channel | Harga | Verifikasi | Integrasi |
| - | - | - | - | - |
| 1 | **Offline** | Normal | Instant | Thermal printer |
| 2 | **Marketplace** | Custom (+commission) | Auto-sync | Shopee, Tokopedia |
| 3 | **Website** | Normal | Instant | Direct checkout |
| 4 | **WhatsApp** | Normal | Manual/Instant | WA Business API |
| 5 | **Reseller** | Diskon khusus | Manual | Reseller portal |
| 6 | **B2B** | Grosir | Invoice | Payment term 30 hari |
| 7 | **Grab** | Custom (+delivery) | Auto | GrabFood API |
| 8 | **Social Media** | Normal | Manual | DM/Comment |

### Detail per Channel

#### 1. Offline — Penjualan di Toko

| Fitur | Deskripsi |
| - | - |
| **Harga** | Harga normal sesuai katalog |
| **Pembayaran** | Cash, transfer, QRIS, debit, credit, e-wallet |
| **Receipt** | Cetak via thermal printer |
| **Membership** | Poin otomatis terkumpul |
| **Use Case** | Customer datang langsung ke toko |

#### 2. Marketplace — Shopee, Tokopedia

| Fitur | Deskripsi |
| - | - |
| **Harga** | Bisa lebih tinggi (cover commission) |
| **Stok** | Sync real-time ke marketplace |
| **Order** | Otomatis masuk ke order queue |
| **Resi** | Auto-upload nomor resi |
| **Use Case** | Jangkauan lebih luas |

#### 3. Website — Toko Online

| Fitur | Deskripsi |
| - | - |
| **URL** | `/toko` |
| **Checkout** | Shopee-like experience |
| **Variant** | Support product variants |
| **Display** | Best seller, total sold count |
| **Use Case** | Branding dan kontrol penuh |

#### 4. WhatsApp — Order via Chat

| Fitur | Deskripsi |
| - | - |
| **Order** | Customer chat → CS input manual |
| **Notifikasi** | WhatsApp notification otomatis |
| **Template** | Quick response template |
| **Linking** | Auto-link ke customer profile |
| **Use Case** | Personal touch |

#### 5. Reseller — Penjualan via Reseller

| Fitur | Deskripsi |
| - | - |
| **Harga** | Harga khusus reseller (lebih rendah) |
| **Tracking** | Penjualan per reseller terpantau |
| **Komisi** | Commission calculation otomatis |
| **Dashboard** | Reseller dashboard terpisah |
| **Use Case** | Scale tanpa biaya marketing |

#### 6. B2B — Bisnis ke Bisnis

| Fitur | Deskripsi |
| - | - |
| **Harga** | Harga grosir (volume besar) |
| **Invoice** | Generate invoice otomatis |
| **Payment Term** | 30 hari payment term |
| **Tracking** | BTT (Bukti Transfer Terima) tracking |
| **Partial** | Support partial payment |
| **Use Case** | Volume besar, pelanggan korporat |

#### 7. GrabFood — Delivery

| Fitur | Deskripsi |
| - | - |
| **Integrasi** | Terintegrasi dengan Grab |
| **Order** | Otomatis masuk, auto-accept |
| **Menu** | Sync menu ke Grab |
| **Delivery** | Delivery tracking |
| **Use Case** | Instant delivery |

#### 8. Social Media — Instagram/Facebook

| Fitur | Deskripsi |
| - | - |
| **Order** | Via DM atau comment |
| **Input** | CS input manual |
| **Payment** | Manual verification |
| **Delivery** | Arrangement via chat |
| **Use Case** | Brand awareness + penjualan |

## Channel-Specific Pricing

Setiap produk bisa memiliki **harga berbeda per channel**:

### Contoh Pricing — Ayam Suwir Petir (150g)

| Channel | Harga | Margin Adjustment |
| - | - | - |
| **Offline** | Rp 45.000 | Base price |
| **Marketplace** | Rp 48.000 | +6.7% (cover commission) |
| **Website** | Rp 45.000 | Same as offline |
| **WhatsApp** | Rp 45.000 | Same as offline |
| **Reseller** | Rp 38.000 | -15.6% (reseller margin) |
| **B2B** | Rp 35.000 | -22.2% (volume discount) |
| **Grab** | Rp 50.000 | +11.1% (delivery fee) |
| **Social Media** | Rp 45.000 | Same as offline |

### Setup Channel Pricing

| Langkah | Aksi |
| - | - |
| 1 | Buka halaman produk (`/companyproducts`) |
| 2 | Pilih produk yang ingin diatur harganya |
| 3 | Klik tab **Harga per Channel** |
| 4 | Input harga untuk setiap channel |
| 5 | Klik **Simpan** |

## Default Channel Memory

Sistem mengingat channel terakhir yang digunakan oleh setiap user:

```mermaid theme={null}
sequenceDiagram
    participant K as Kasir
    participant S as Sistem
    
    K->>S: Pilih channel "WhatsApp"
    S->>S: Simpan preferensi
    Note over S: Transaksi berikutnya...
    S->>K: Auto-select "WhatsApp"
    K->>S: Ganti ke "B2B"
    S->>S: Update preferensi
```

**Benefit:**

* Lebih cepat checkout — tidak perlu pilih channel setiap kali
* Mengurangi human error — channel konsisten
* Bisa diganti kapan saja — satu klik

## Quick Channel Switch

Kasir bisa dengan cepat ganti channel dengan satu klik:

| Langkah | Aksi |
| - | - |
| 1 | Klik tombol channel di POS |
| 2 | Pilih channel baru dari dropdown |
| 3 | Transaksi langsung menggunakan channel baru |

**Use Case:**

* Handle order dari berbagai channel dalam satu shift
* Switch dari offline ke WhatsApp saat ada order WhatsApp masuk
* Switch ke B2B saat ada customer B2B datang

## Entity Relationship Diagram — Channel Pricing

Diagram berikut menunjukkan relasi antar-entitas yang terlibat dalam mekanisme channel pricing dan transaksi multi-channel.

```mermaid theme={null}
erDiagram
    CompanyPOSProduct {
        string company_id PK
        string name
        string sku UK
        number price "harga base/default"
        number cost "HPP"
        number stock
        object channel_pricing "harga per 8 channel"
        boolean is_active
        string product_type "finished_good | raw_material | bundle"
    }

    CompanyPOSTransaction {
        string company_id FK
        string transaction_number PK
        string transaction_date
        number subtotal
        number total
        string source "enum: 10 nilai sumber transaksi"
        string sales_channel "enum: 11 nilai channel ternormalisasi"
        string payment_method "enum: 13 metode bayar"
        string payment_status "enum: 7 status bayar"
        string order_status "enum: 7 status order"
        string customer_id FK
        string cashier_id FK
    }

    MarketplaceOrder {
        string order_number PK
        string customer_id FK
        string company_id FK
        number total_amount
        number commission_rate
        number commission_amount
        number company_amount
        string status "enum: 5 status order"
        string payment_status "enum: 3 status bayar"
        object shipping_address
    }

    MarketplaceCommissionSettings {
        number commission_rate "default 10%"
        number min_withdrawal "default 100000"
        number withdrawal_fee "default 5000"
        boolean is_active
    }

    MarketplaceCart {
        string user_id FK
        string company_id FK
        string product_id FK
        number quantity
        number product_price
        number subtotal
    }

    ProductOrder {
        string product_id FK
        string customer_id FK
        number product_price
        number reseller_discount
        number voucher_discount_amount
        number final_price
        string status "enum: 4 status"
    }

    CompanyPOSSettings {
        string company_id PK
        object receipt_settings "konfigurasi struk"
    }

    CompanyPOSProduct ||--o{ CompanyPOSTransaction : "produk terjual via transaksi"
    CompanyPOSProduct ||--o{ MarketplaceCart : "produk masuk keranjang"
    CompanyPOSProduct ||--o{ ProductOrder : "produk di-order"
    MarketplaceOrder }o--|| CompanyPOSProduct : "order mengandung produk"
    MarketplaceOrder }o--|| MarketplaceCommissionSettings : "mengikuti aturan komisi"
    MarketplaceCart }o--|| MarketplaceOrder : "keranjang jadi order"
    CompanyPOSTransaction }o--|| CompanyPOSSettings : "transaksi pakai setting perusahaan"
```

### Penjelasan Relasi

| Relasi | Kardinalitas | Deskripsi |
| - | - | - |
| `CompanyPOSProduct → CompanyPOSTransaction` | 1 : N | Satu produk bisa muncul di banyak transaksi (offline, online, marketplace, dll) |
| `CompanyPOSProduct → MarketplaceCart` | 1 : N | Satu produk bisa masuk ke banyak keranjang belanja di marketplace |
| `CompanyPOSProduct → ProductOrder` | 1 : N | Satu produk bisa di-order berkali-kali oleh berbagai customer |
| `MarketplaceOrder → MarketplaceCommissionSettings` | N : 1 | Semua order marketplace mengikuti satu set aturan komisi yang sama |
| `MarketplaceCart → MarketplaceOrder` | N : 1 | Banyak item di keranjang bergabung menjadi satu order |
| `CompanyPOSTransaction → CompanyPOSSettings` | N : 1 | Semua transaksi dalam satu perusahaan memakai konfigurasi POS yang sama |

***

## Entity Schema — Channel Pricing

### `channel_pricing` Object dalam `CompanyPOSProduct`

Field `channel_pricing` adalah **object nested** di dalam entitas `CompanyPOSProduct` yang menyimpan harga khusus untuk setiap channel penjualan. Jika suatu channel tidak diatur, sistem akan fallback ke field `price` (harga base).

| Field | Tipe | Wajib | Deskripsi |
| - | - | - | - |
| `channel_pricing.offline_pos` | `number` | Tidak | Harga produk saat dijual via POS offline (toko fisik). Biasanya sama dengan `price`. |
| `channel_pricing.marketplace` | `number` | Tidak | Harga produk di marketplace (Shopee, Tokopedia). Biasanya **+5-10%** dari base untuk cover commission. |
| `channel_pricing.website` | `number` | Tidak | Harga produk di website toko online (`/toko`). Biasanya sama dengan base price untuk mendorong direct purchase. |
| `channel_pricing.whatsapp` | `number` | Tidak | Harga produk untuk order via WhatsApp. Biasanya sama dengan base price. |
| `channel_pricing.reseller` | `number` | Tidak | Harga khusus reseller. Biasanya **-15-20%** dari base agar reseller punya margin. |
| `channel_pricing.b2b` | `number` | Tidak | Harga grosir B2B. Biasanya **-20-25%** dari base untuk volume besar. |
| `channel_pricing.grab` | `number` | Tidak | Harga produk di GrabFood. Biasanya **+10-15%** untuk cover delivery fee. |
| `channel_pricing.social_media` | `number` | Tidak | Harga produk untuk order dari Instagram/Facebook. Biasanya sama dengan base price. |

### Contoh Data `channel_pricing`

```jsonc theme={null}
// CompanyPOSProduct — Ayam Suwir Petir (150g)
{
  "name": "Ayam Suwir Petir",
  "sku": "ASP-150",
  "price": 45000,          // base price (fallback)
  "cost": 22000,           // HPP
  "channel_pricing": {
    "offline_pos":  45000, // = base
    "marketplace":  48000, // +6.7% cover commission
    "website":      45000, // = base
    "whatsapp":     45000, // = base
    "reseller":     38000, // -15.6% reseller margin
    "b2b":          35000, // -22.2% volume discount
    "grab":         50000, // +11.1% delivery fee
    "social_media": 45000  // = base
  }
}
```

### `source` Enum dalam `CompanyPOSTransaction`

Field `source` pada `CompanyPOSTransaction` mencatat dari channel mana transaksi berasal. Nilai ini digunakan untuk reporting dan analytics per channel.

| Nilai `source` | Label | Deskripsi |
| - | - | - |
| `pos` | POS / Kasir | Transaksi dari mesin kasir di toko fisik |
| `online_catalog` | Katalog Online | Order dari katalog produk online (link sharing) |
| `website` | Website | Order dari website toko online (`/toko`) |
| `marketplace` | Marketplace | Order dari Shopee, Tokopedia, dll |
| `landing_page` | Landing Page | Order dari landing page khusus campaign |
| `whatsapp` | WhatsApp | Order yang diinput dari chat WhatsApp |
| `reseller` | Reseller | Order dari portal reseller |
| `b2b` | B2B | Order bisnis ke bisnis (korporat) |
| `grab` | GrabFood | Order dari platform GrabFood |
| `social_media` | Social Media | Order dari DM Instagram/Facebook/TikTok |

### `sales_channel` Enum (Ternormalisasi)

Field `sales_channel` adalah versi ternormalisasi dari `source` yang ditambahkan untuk kompatibilitas. Field ini memiliki nilai lebih lengkap dan menjadi sumber kebenaran baru, sementara `source` dipertahankan untuk backward compatibility.

| Nilai `sales_channel` | Padanan `source` | Catatan |
| - | - | - |
| `offline_pos` | `pos` | Default untuk transaksi POS |
| `offline` | — | Alias legacy untuk offline |
| `website` | `website` | Langsung map |
| `online_catalog` | `online_catalog` | Langsung map |
| `marketplace` | `marketplace` | Langsung map |
| `landing_page` | `landing_page` | Langsung map |
| `whatsapp` | `whatsapp` | Langsung map |
| `reseller` | `reseller` | Langsung map |
| `b2b` | `b2b` | Langsung map |
| `grab` | `grab` | Langsung map |
| `social_media` | `social_media` | Langsung map |

***

## Flowchart — Channel Pricing Gate (A3)

Flowchart berikut menggambarkan bagaimana sistem memilih harga yang benar saat kasir atau customer melakukan transaksi. Logika ini berjalan di **backend** setiap kali produk ditambahkan ke cart atau transaksi di-finalize.

```mermaid theme={null}
flowchart TD
    A([Mulai: Produk Ditambahkan ke Cart]) --> B{Apakah transaksi punya<br/>sales_channel?}
    B -->|Ya| C{Apakah channel_pricing<br/>untuk channel ini ada?}
    B -->|Tidak / null| D[Gunakan field price<br/>sebagai base price]

    C -->|Ada / bukan null| E{Apakah nilai<br/>channel_pricing > 0?}
    C -->|Tidak ada / null| D

    E -->|Ya| F[Pakai harga channel_pricing<br/>sesuai channel]
    E -->|Tidak / 0| D

    D --> G{Apakah ada diskon<br/>member / voucher?}
    F --> G

    G -->|Ya| H[Hitung: harga_channel -<br/>diskon_member - voucher]
    G -->|Tidak| I[Harga final = harga channel]

    H --> J[Simpan ke item.price<br/>di transaksi]
    I --> J

    J --> K([Lanjut ke Checkout])

    style A fill:#e1f5fe
    style K fill:#e8f5e9
    style F fill:#fff3e0
    style D fill:#f3e5f5
```

### Aturan Fallback Harga

| Prioritas | Sumber Harga | Kondisi |
| - | - | - |
| 1 | `channel_pricing[channel]` | Jika field ini ada dan > 0 untuk channel aktif |
| 2 | `price` (base price) | Jika `channel_pricing` tidak diset, null, atau 0 |
| 3 | `price - discount` | Setelah harga terpilih, terapkan diskon member/voucher jika ada |

### Contoh Skenario Pricing Gate

| Skenario | Channel | `channel_pricing` | `price` | Harga Dipakai |
| - | - | - | - | - |
| Harga channel diset | Marketplace | 48.000 | 45.000 | **48.000** |
| Harga channel kosong | Reseller | null | 45.000 | **45.000** (fallback) |
| Harga channel = 0 | B2B | 0 | 45.000 | **45.000** (fallback) |
| Harga channel + voucher | Offline | 45.000 | 45.000 | **42.000** (setelah voucher Rp 3.000) |

***

## Perbandingan Lengkap 8 Channel

Tabel berikut merangkum perbedaan karakteristik, strategi, dan konfigurasi dari kedelapan channel penjualan yang didukung SNISHOP ERP.

| Aspek | Offline | Marketplace | Website | WhatsApp | Reseller | B2B | Grab | Social Media |
| - | - | - | - | - | - | - | - | - |
| **Harga default** | Base price | +5-10% | Base price | Base price | -15-20% | -20-25% | +10-15% | Base price |
| **Pembayaran** | Cash/Transfer/QRIS/Debit/Credit/E-wallet | Gateway marketplace | Gateway website | Transfer/E-wallet | Transfer | Invoice 30 hari | Auto (Grab) | Transfer manual |
| **Verifikasi bayar** | Instant | Auto-sync | Instant | Manual/Instant | Manual | Invoice approval | Auto | Manual |
| **Stok sync** | Real-time | Real-time API | Real-time | Manual deduction | Manual | Manual deduction | Real-time API | Manual deduction |
| **Pencetakan struk** | Thermal printer | Tidak (digital) | Tidak (digital) | Tidak | Tidak | Invoice PDF | Tidak | Tidak |
| **Membership poin** | Ya | Tidak | Ya | Ya | Ya | Tidak | Ya | Ya |
| **Input order** | Kasir scan barcode | Otomatis (API) | Customer self-checkout | CS input manual | Portal reseller | Sales input | Otomatis (API) | CS input manual |
| **Tracking resi** | N/A | Auto-upload | Manual/API | Manual | Manual | N/A | Auto (Grab) | Manual |
| **Commission/fee** | Tidak ada | 5-10% ke marketplace | Payment gateway fee | Tidak ada | Komisi reseller | Tidak ada | 20-25% ke Grab | Tidak ada |
| **Cocok untuk** | Customer datang ke toko | Jangkauan nasional | Branding + kontrol penuh | Personal touch | Scale tanpa marketing | Volume korporat | Instant delivery | Brand awareness |

***

## Sequence Diagram — Order Flow per Channel

### 1. Offline (POS) — Transaksi di Toko

```mermaid theme={null}
sequenceDiagram
    participant C as Customer
    participant K as Kasir (POS)
    participant S as SNISHOP Backend
    participant P as Printer

    C->>K: Datang ke toko, pilih produk
    K->>S: Scan barcode / pilih produk
    S->>S: Lookup channel_pricing["offline_pos"]
    S-->>K: Tampilkan harga + cart
    K->>S: Finalize transaksi (payment_method: cash/transfer/qris)
    S->>S: Kurangi stok, catat poin member
    S->>P: Kirim data struk
    P->>K: Cetak struk thermal
    K->>C: Berikan produk + struk
```

### 2. Marketplace — Shopee / Tokopedia

```mermaid theme={null}
sequenceDiagram
    participant C as Customer
    participant MP as Marketplace API
    participant S as SNISHOP Backend
    participant W as Warehouse

    C->>MP: Browse + checkout di marketplace
    MP->>S: Webhook: order baru
    S->>S: Lookup channel_pricing["marketplace"]
    S->>S: Hitung commission (MarketplaceCommissionSettings)
    S->>S: Kurangi stok (sync real-time)
    S->>W: Buat picking order
    W->>S: Confirm packed
    S->>MP: Upload nomor resi
    MP->>C: Notifikasi: pesanan dikirim
    C->>MP: Confirm terima
    MP->>S: Webhook: delivered
```

### 3. Website — Toko Online `/toko`

```mermaid theme={null}
sequenceDiagram
    participant C as Customer
    participant W as Website /toko
    participant S as SNISHOP Backend
    participant PG as Payment Gateway

    C->>W: Browse produk, add to cart
    W->>S: GET /api/products (harga dari channel_pricing.website)
    S-->>W: List produk + harga
    C->>W: Checkout + pilih pembayaran
    W->>PG: Create payment intent
    PG-->>C: Halaman pembayaran
    C->>PG: Bayar
    PG->>S: Webhook: payment success
    S->>S: Kurangi stok, catat transaksi (source: website)
    S->>W: Update status order
    W->>C: Email konfirmasi + tracking
```

### 4. WhatsApp — Order via Chat

```mermaid theme={null}
sequenceDiagram
    participant C as Customer
    participant WA as WhatsApp Business
    participant CS as CS / Kasir
    participant S as SNISHOP Backend

    C->>WA: Chat: "Mau pesan Ayam Suwir Petir 2"
    WA->>CS: Notifikasi chat masuk
    CS->>S: Buka POS, pilih channel = WhatsApp
    S->>S: Lookup channel_pricing["whatsapp"]
    CS->>S: Input item + qty
    S-->>CS: Tampilkan total
    CS->>WA: Kirim total + no rekening ke customer
    C->>WA: Kirim bukti transfer
    CS->>S: Finalize + verifikasi pembayaran
    S->>S: Kurangi stok, catat transaksi (source: whatsapp)
    CS->>WA: Konfirmasi order diterima
```

### 5. Reseller — Portal Reseller

```mermaid theme={null}
sequenceDiagram
    participant R as Reseller
    participant RP as Reseller Portal
    participant S as SNISHOP Backend
    participant W as Warehouse

    R->>RP: Login, browse produk
    RP->>S: GET /api/products (harga dari channel_pricing.reseller)
    S-->>RP: List produk + harga reseller (diskon 15-20%)
    R->>RP: Add to cart + checkout
    RP->>S: Create order (source: reseller)
    S->>S: Hitung reseller_discount, kurangi stok
    S->>W: Buat picking order
    W->>S: Confirm packed
    S->>RP: Update status + tracking
    RP->>R: Notifikasi: pesanan diproses
```

### 6. B2B — Bisnis ke Bisnis

```mermaid theme={null}
sequenceDiagram
    participant B2B as Customer B2B
    participant SL as Sales
    participant S as SNISHOP Backend
    participant FIN as Finance

    B2B->>SL: Request order bulk (email/WA/telepon)
    SL->>S: Buka POS, pilih channel = B2B
    S->>S: Lookup channel_pricing["b2b"] (diskon 20-25%)
    SL->>S: Input item + qty besar
    S-->>SL: Tampilkan total (harga grosir)
    SL->>S: Finalize → generate invoice (payment_status: pending)
    S->>FIN: Notifikasi invoice baru
    FIN->>B2B: Kirim invoice + payment term 30 hari
    Note over FIN,B2B: 30 hari kemudian...
    B2B->>FIN: Transfer pembayaran
    FIN->>S: Verifikasi transfer → payment_status: paid
    S->>S: Update order status, kurangi stok
```

### 7. Grab — GrabFood Delivery

```mermaid theme={null}
sequenceDiagram
    participant C as Customer
    participant GR as GrabFood API
    participant S as SNISHOP Backend
    participant K as Kitchen

    C->>GR: Order via app Grab
    GR->>S: Webhook: order baru
    S->>S: Lookup channel_pricing["grab"] (+10-15%)
    S->>S: Kurangi stok (sync real-time)
    S->>K: Tampilkan order di kitchen display
    K->>S: Confirm siap
    S->>GR: Order ready for pickup
    GR->>C: Notifikasi: pesanan sedang diantar
    GR->>S: Webhook: delivered
    S->>S: Catat transaksi (source: grab)
```

### 8. Social Media — Instagram / Facebook / TikTok

```mermaid theme={null}
sequenceDiagram
    participant C as Customer
    participant SM as Instagram/Facebook
    participant CS as CS / Kasir
    participant S as SNISHOP Backend

    C->>SM: DM: "Mau order yang ini!"
    SM->>CS: Notifikasi DM masuk
    CS->>S: Buka POS, pilih channel = Social Media
    S->>S: Lookup channel_pricing["social_media"]
    CS->>S: Input item + qty
    S-->>CS: Tampilkan total
    CS->>SM: Reply: total + no rekening
    C->>SM: Kirim bukti transfer
    CS->>S: Verifikasi pembayaran manual
    S->>S: Finalize transaksi (source: social_media)
    CS->>SM: Konfirmasi + arrangement delivery via chat
```

***

## State Machine — Order Status per Channel

Setiap channel memiliki flow status order yang sedikit berbeda. Berikut state machine untuk transaksi di SNISHOP ERP:

```mermaid theme={null}
stateDiagram-v2
    [*] --> pending: Order dibuat

    state "Transaksi Offline (POS)" as offline {
        pending --> completed: Bayar langsung
        completed --> refunded: Retur
    }

    state "Transaksi Online (Marketplace/Website/Grab)" as online {
        pending --> processing: Dikemas
        processing --> shipped: Dikirim + resi
        shipped --> delivered: Diterima customer
        delivered --> completed: Selesai
    }

    state "Transaksi B2B (Invoice)" as b2b {
        pending --> processing: Invoice disetujui
        processing --> pending_verification: Menunggu transfer
        pending_verification --> completed: Transfer verified
    }

    state "Transaksi Manual (WhatsApp/Reseller/Social)" as manual {
        pending --> pending_verification: Menunggu bukti bayar
        pending_verification --> processing: Verifikasi OK
        processing --> completed: Order selesai
    }

    pending --> cancelled: Dibatalkan
    processing --> cancelled: Dibatalkan
    completed --> [*]
    cancelled --> [*]
    refunded --> [*]
```

### Penjelasan State

| State | Deskripsi | Channel yang umum |
| - | - | - |
| `pending` | Order baru dibuat, belum diproses | Semua channel |
| `pending_verification` | Menunggu verifikasi pembayaran non-tunai | WhatsApp, B2B, Social Media |
| `processing` | Sedang dikemas / disiapkan | Marketplace, Website, Grab, Reseller |
| `shipped` | Sudah diserahkan ke kurir | Marketplace, Website, Grab |
| `delivered` | Sampai di tangan customer | Marketplace, Website, Grab |
| `completed` | Transaksi selesai (final) | Semua channel |
| `cancelled` | Order dibatalkan | Semua channel |
| `rejected` | Order ditolak (misal stok habis) | Marketplace, Grab |
| `refunded` | Dana dikembalikan ke customer | Offline, Website |

***

## Payment State Machine

```mermaid theme={null}
stateDiagram-v2
    [*] --> pending: Transaksi dibuat

    pending --> paid: Bayar tunai / gateway success
    pending --> pending_verification: Upload bukti transfer
    pending --> partially_paid: DP / partial payment (B2B)

    pending_verification --> paid: Verifikasi OK
    pending_verification --> rejected: Bukti invalid

    partially_paid --> paid: Pelunasan verified

    paid --> refunded: Retur / cancel
    paid --> [*]
    rejected --> pending: Upload ulang bukti
    refunded --> [*]
```

***

## Channel Reporting

Laporan penjualan per channel tersedia di Dashboard, Analytics, dan Advanced Analytics:

| Metrik | Deskripsi |
| - | - |
| **Total Revenue** | Pendapatan per channel |
| **Transaction Count** | Jumlah transaksi per channel |
| **Average Order Value** | Rata-rata nilai order per channel |
| **Top Products** | Produk terlaris per channel |
| **Growth Rate** | Pertumbuhan revenue per channel |
| **Profit Margin** | Margin keuntungan per channel |

## Channel Integration

### Marketplace Integration

| Fitur | Status |
| - | - |
| Sync produk ke marketplace | ✅ |
| Sync stok real-time | ✅ |
| Order otomatis masuk | ✅ |
| Resi auto-upload | ✅ |
| Price sync | ✅ |

### WhatsApp Integration

| Fitur | Status |
| - | - |
| Notifikasi order baru | ✅ |
| Quick response template | ✅ |
| Customer linking | ✅ |
| Order history | ✅ |

### Grab Integration

| Fitur | Status |
| - | - |
| Menu sync | ✅ |
| Stok sync | ✅ |
| Order auto-accept | ✅ |
| Delivery tracking | ✅ |

## Strategi Pricing per Channel

| Channel | Strategi | Alasan |
| - | - | - |
| **Offline** | Harga normal | Base price |
| **Marketplace** | +5-10% | Cover commission marketplace |
| **Website** | Harga normal | Dorong direct purchase |
| **WhatsApp** | Harga normal | Personal service |
| **Reseller** | -15-20% | Margin untuk reseller |
| **B2B** | -20-25% | Volume discount |
| **Grab** | +10-15% | Cover delivery fee |
| **Social Media** | Harga normal | Brand awareness |

## Tips

* **Pilih channel yang tepat** sesuai karakteristik pelanggan target
* **Set buffer stock** untuk marketplace untuk menghindari overselling
* **Monitor margin per channel** — channel dengan revenue tertinggi belum tentu yang paling profitable
* **Prioritas channel berdasarkan margin** — fokus pada channel dengan profit margin terbaik
* **Sync stok real-time** ke semua channel untuk menghindari overselling


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.