# Mutual Fund — AMC + Leadership

**Controller:** `App\Http\Controllers\MfAmcController`  
**Models:** `App\Models\MfAmc`, `App\Models\MfAmcsLeader`  
**Tables:** `mf_amcs`, `mf_amcs_leaders`  
**Middleware:** `jwt.auth`, `check.token`, `dynamic.permission`

An AMC has many leaders. Store, show, update, and delete all happen in this one controller. Leadership is nested under `leaders`.

Assign these route names to the back-office role in route-API permissions before calling them.

---

## Purpose

Master data for Asset Management Companies and their leadership team. Used when creating/editing funds (`mf_funds.amc_id`) and anywhere an AMC dropdown is needed.

## AMC fields

| Column | Type | Notes |
|--------|------|--------|
| `id` | bigint | PK |
| `name` | varchar(128) | Required |
| `slug` | varchar(128) | Unique. Auto from `name` if omitted |
| `partner_code` | varchar(32) | Optional |
| `color_code` | varchar(32) | Required (e.g. `#1A73E8`) |
| `founded_year` | smallint | Required |
| `location` | varchar(128) | Optional |
| `data_source_type` | enum `SCRAPE` / `API` / `CMS` | Required |
| `website_url` | varchar(255) | Optional |
| `is_launch_partner` | tinyint | `0` or `1`, default `0` |
| `agreed_commission_share` | decimal(5,2) | Optional |
| `management_fee_rate` | decimal(5,2) | Optional |
| `description` | text | Optional |
| `philosophy` | text | Optional |
| `onboarding_status` | enum `Y` / `N` | Required |
| `status` | enum `A` / `I` | Default `A` |
| `create_by` / `update_by` | int | `fintra_back_users.user_id` via `users_id` |

## Leader fields (`leaders[]`)

| Column | Type | Notes |
|--------|------|--------|
| `id` | bigint | Send on update to keep/edit that row |
| `leader_name` | varchar(128) | Required |
| `position` | varchar(128) | Required |
| `image` | varchar(128) | Required on create. Upload as `file|image|mimes:jpeg,png,jpg,gif` to fi_bo (`/api/upload-file`), same as Quick BO |
| `slug` | varchar(64) | Unique per AMC. Auto from `leader_name` if omitted |
| `profile_link` | varchar(128) | Optional |
| `status` | enum `A` / `I` | Default `A` |

Leader images are uploaded to the fi_bo server (`mfAmcLeaders` directory) via `upload-file`, same as Quick BO profile images. Responses return the full `FI_BO_IMAGES_URL` path. Use multipart form-data for store/update when sending images.

## Endpoints

| Action | Method | Path | Route name |
|--------|--------|------|------------|
| List | GET | `/api/mf-amc/mf-amc-index` | `mf-amc-index` |
| Show | GET | `/api/mf-amc/mf-amc-show/{id}` | `mf-amc-show/{id}` |
| Dropdown | GET | `/api/mf-amc/mf-amc-dropdown` | `mf-amc-dropdown` |
| Create | POST | `/api/mf-amc/mf-amc-store` | `mf-amc-store` |
| Update | POST | `/api/mf-amc/mf-amc-update/{id}` | `mf-amc-update/{id}` |
| Delete | DELETE | `/api/mf-amc/mf-amc-delete/{id}` | `mf-amc-delete/{id}` |

Update is **POST**, not PUT.

## Leadership sync on update

If `leaders` is sent:

- Row with `id` belonging to this AMC → update
- Row without `id` → create
- Existing leaders **not** in the array → deleted (and image files removed)

If `leaders` is omitted, existing leaders are left unchanged.  
If `leaders` is `[]`, all leaders for that AMC are deleted.

## Query params

**Index**

| Param | Default | Description |
|-------|---------|-------------|
| `per_page` | 10 | 1–100 |
| `status` | — | `A` or `I` |
| `onboarding_status` | — | `Y` or `N` |
| `data_source_type` | — | `SCRAPE`, `API`, `CMS` |
| `q` | — | Search `name`, `slug`, `partner_code` |

**Dropdown**

| Param | Default | Description |
|-------|---------|-------------|
| `status` | `A` | `A`, `I`, or `all` |

Dropdown returns `id`, `name`, `slug`, `partner_code`.

## Delete rule

If any row in `mf_funds` uses this AMC, delete returns **409** with `funds_count`. Soft-inactivate with `status = I` instead. When delete is allowed, leaders cascade.

## Related docs

- cURL examples: `mf_amc_api_curl.md`
- Postman collection: `mf_amc.postman_collection.json`
