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

# Quality Control

> Fabric and garment QC, posting, and inventory effects

# Quality Control

QC gates two critical handoffs: **fabric** as it enters the building (before it is issued to cutting) and **garments** as they come off production (before they become sellable finished goods). A report is created, reviewed, and then **posted** — and posting is what drives stock disposition and the GL effect in [Finindex](/finindex/accounting/overview).

## What QC covers

| Report              | When                                  | Effect of posting                                                                 |
| ------------------- | ------------------------------------- | --------------------------------------------------------------------------------- |
| Fabric QC           | Incoming fabric, against inbound lots | Releases passed quantity to usable stock; quarantines or returns failed quantity. |
| Garment QC          | End of sewing / before finished goods | Passes garments to finished goods; routes failures to rework or scrap.            |
| Garment QC Spec     | Reference                             | The measurement/tolerance template a garment report is graded against.            |
| Inspections (`/qc`) | Ad-hoc                                | Lightweight inspections with attached defects.                                    |

## Flow

```mermaid theme={null}
flowchart LR
  Fabric[Incoming Fabric Lot] --> FR[Fabric QC Report]
  FR -->|pass| Post1[Post Report]
  FR -->|fail| Hold[Quarantine / Return]
  Post1 --> Usable[Usable Stock -> Cutting]
  Garment[Garments off Sewing] --> GR[Garment QC Report]
  GR -->|pass| Post2[Post Report]
  GR -->|fail| Rework[Rework / Scrap]
  Post2 --> FG[Finished Goods]
  Post1 -.disposition GL.-> Fin[Finindex]
  Post2 -.disposition GL.-> Fin
```

## Fabric QC: create, review, post

```mermaid theme={null}
sequenceDiagram
  participant QC as QC Inspector
  participant Rep as Fabric QC Report
  participant Stock as Stock
  participant Fin as Finindex
  QC->>Rep: POST /quality-control/fabric-qc-reports
  QC->>Rep: PATCH report (defects, pass/fail qty)
  Note over QC,Rep: review against spec
  QC->>Rep: POST /quality-control/fabric-qc-reports/{id}/post
  Rep->>Stock: passed -> usable; failed -> quarantine
  Stock-->>Fin: inventory disposition GL entry
```

## Fabric QC reports

```bash theme={null}
GET   /api/v1/quality-control/fabric-qc-reports
POST  /api/v1/quality-control/fabric-qc-reports
PATCH /api/v1/quality-control/fabric-qc-reports/{report_id}
POST  /api/v1/quality-control/fabric-qc-reports/{report_id}/post
```

### Create a fabric QC report

<ParamField body="lot_id" type="string" required>
  The inbound stock lot being inspected.
</ParamField>

<ParamField body="inspected_quantity" type="number" required>
  Quantity examined, in the lot's unit of measure.
</ParamField>

<ParamField body="passed_quantity" type="number" required>
  Quantity that met spec; the remainder is treated as failed.
</ParamField>

<ParamField body="defects" type="array">
  Defect records (type, severity, quantity) found during inspection.
</ParamField>

```bash theme={null}
POST /api/v1/quality-control/fabric-qc-reports
Authorization: Bearer <access_token>

{
  "lot_id": "uuid",
  "inspected_quantity": 500,
  "passed_quantity": 480,
  "defects": [
    { "type": "shade_variation", "severity": "minor", "quantity": 20 }
  ]
}
```

**Response (201):**

```json theme={null}
{
  "id": "uuid",
  "lot_id": "uuid",
  "status": "draft",
  "passed_quantity": 480,
  "failed_quantity": 20
}
```

### Post a fabric QC report

Posting locks the report and applies the disposition: passed quantity becomes usable stock, failed quantity is quarantined or returned, and the inventory effect is journaled.

```bash theme={null}
POST /api/v1/quality-control/fabric-qc-reports/{report_id}/post
Authorization: Bearer <access_token>
```

**Response (200):**

```json theme={null}
{
  "report_id": "uuid",
  "status": "posted",
  "passed_quantity": 480,
  "failed_quantity": 20,
  "ledger_entry_id": "uuid"
}
```

<Warning>
  Posting is irreversible. A report is editable only in `draft` — review defects and pass/fail quantities carefully before posting, since the failed quantity is removed from usable stock.
</Warning>

## Garment QC reports

Same lifecycle as fabric QC — create, review against a garment spec, post — but graded against a measurement template and applied to finished goods.

```bash theme={null}
GET   /api/v1/quality-control/garment-qc-reports
POST  /api/v1/quality-control/garment-qc-reports
POST  /api/v1/quality-control/garment-qc-reports/{report_id}/post
GET   /api/v1/quality-control/garment-qc-specs
```

<Info>
  A garment report references a **garment QC spec** (`/quality-control/garment-qc-specs`) that defines measurement points and tolerances. Posting a passed report moves garments into finished goods, making them eligible for [Warehouse Outbound](/cutmake/mes/warehouse-inventory) allocation.
</Info>

## Inspections and defects

A lighter-weight inspection model for ad-hoc checks, each with attachable defect records.

```bash theme={null}
GET  /api/v1/qc
POST /api/v1/qc
POST /api/v1/qc/{inspection_id}/defects
PUT  /api/v1/qc/defects/{defect_id}
```

## How QC posting hits the GL

<Steps>
  <Step title="Pass">
    Passed quantity is released to usable stock (fabric) or finished goods (garments) — no loss entry.
  </Step>

  <Step title="Fail">
    Failed quantity is written down to quarantine, returned to the supplier, or scrapped. The value adjustment posts to Finindex as an inventory write-down or supplier claim.
  </Step>

  <Step title="Audit">
    The returned `ledger_entry_id` links the QC report to its stock ledger entry and the corresponding journal entry in [Finindex](/finindex/accounting/journal-entries).
  </Step>
</Steps>

See the **API Reference** tab for the full endpoint list under the Quality Control tag.
