# Maintenance sparepart demo seed

Run from apps/api after migrations and Prisma Client generation:

```powershell
npm.cmd run prisma:seed:maintenance-sparepart
```

Requires an existing active ADMIN/SUPERVISOR. Optionally select one with `MAINTENANCE_SEED_ACTOR_EMAIL`; otherwise the first eligible account is used. No login account is created.

Creates dedicated `DEMO-MAINT-*` spareparts, each with three units received and one quarantined, and these corrective WOs:

| WO | Target | Status |
| --- | --- | --- |
| DEMO-WO-SP-VALVE | Ball Valve 1 Inch | OPEN |
| DEMO-WO-SP-ACTUATOR | Pneumatic Actuator | IN_PROGRESS |
| DEMO-WO-SP-CONTACTOR | Contactor 9A | COMPLETED |

These spareparts are the repair targets. All WOs use WAREHOUSE_QUARANTINE with a linked case, no Pilot Plant target, assignment, checkout or ISSUE/RETURN usage. Receipts and holds use the shared inventory ledger. The completed case remains HELD awaiting explicit release/scrap; completion does not release stock automatically.

Open Maintenance and filter the source to Karantina Gudang, or search `DEMO-WO-SP`. The cases also appear in Inventory quarantine review and the receipts/holds in Stock Movement.

The seed is atomic. Repeated runs preserve existing fixtures and subsequent edits/stock decisions; conflicting identities abort with rollback. It does not reset existing inventory. The main `seed`/`prisma:seed` command includes this demo seed; use `prisma:seed:admin` for admin only.

Verification in a disposable MySQL database:

```powershell
node --env-file=.env prisma/verify-maintenance-api.cjs --seed
```
