# Mutual Fund — Sell Fund Request

**Controller:** `App\Http\Controllers\MfSellFundRequestController`  
**Source tables:** `mf_orders` (`order_type = SELL`), `mf_funds`, `mf_amcs`, `mf_investor_amc_profiles`, `mf_bank_accounts`  
**Middleware:** `api` only (no JWT)

Same queue pattern as buy requests, but **sell only** — no lumpsum/SIP split and no `mf_payment_transactions`.

---

## Processable or not

Lookup: `mf_orders.fund_id` → `mf_funds.amc_id` + `mf_orders.fintr_customer_id` → `mf_investor_amc_profiles`.

| `can_process` | When |
|---------------|------|
| `true` | Profile exists, `is_onboarded = 1`, investor code set, order still `INIT` |
| `false` | No profile, not onboarded, or already processed |

Accept is **409** when `can_process` is false. Reject is still allowed on `INIT`.

| Action | Result |
|--------|--------|
| Accept | `mf_orders.status = DONE` (copies `amc_investor_code` from the profile if the order is missing it) |
| Reject | `mf_orders.status = FAILED` |

---

## Endpoints

| Action | Method | Path |
|--------|--------|------|
| List | GET | `/api/mf-sell-fund-request/mf-sell-fund-request-index` |
| Show | GET | `/api/mf-sell-fund-request/mf-sell-fund-request-show/{id}` |
| Accept | POST | `/api/mf-sell-fund-request/mf-sell-fund-request-accept/{id}` |
| Reject | POST | `/api/mf-sell-fund-request/mf-sell-fund-request-reject/{id}` |

`{id}` is `mf_orders.id`. Accept / reject are **POST**.

---

## Query params (index)

| Param | Default | Description |
|-------|---------|-------------|
| `per_page` | 10 | 1–100 |
| `page` | 1 | Laravel paginator |
| `amc_id` | — | Fund's AMC |
| `fund_id` | — | Fund |
| `request_status` | `pending` | `pending` (`INIT`), `accepted` (`DONE`), `failed`, `all` |
| `can_process` | — | `1` onboarded INIT only |
| `q` | — | Customer code, investor code, reference, fund name, BO id, user name |

---

## Accept / reject body

| Field | Required | Notes |
|-------|----------|--------|
| `users_id` | no | Back-office user |
| `remark` | no | Reject only |

Already-processed rows return **409**.
