{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.demiton.io/registers/rework_risk_verdict/v2.json",
  "title": "rework_risk_verdict contract v2",
  "type": "object",
  "required": [
    "detail",
    "first_seen",
    "item_key",
    "kind",
    "last_seen",
    "line_cost",
    "occurrences"
  ],
  "properties": {
    "kind": {
      "type": "string",
      "description": "repeat_purchase (the same item bought again inside the window), over_purchase (more of it ordered than the job task planned) or revision_drift (a test lot built to a drawing revision already superseded when its work began; item_key is `drawing:<number>` and the lots are named in `detail`).",
      "x-demiton-requiredness": "required"
    },
    "cause": {
      "type": "string",
      "description": "The cause the user marks: principal (routes to a claim), supplier (back-charge), or own (prevent).",
      "x-demiton-requiredness": "optional"
    },
    "detail": {
      "type": "string",
      "description": "One line naming the item, the job and cost code, and what repeated.",
      "x-demiton-requiredness": "required"
    },
    "currency": {
      "type": "currency",
      "description": "the currency of every amount on this record (`line_cost`), an ISO 4217 alpha-3 code as the source states it. A record with no currency has no usable amount.",
      "x-demiton-requiredness": "optional"
    },
    "item_key": {
      "type": "string",
      "description": "The matched item's stable key: its item number when the lines carry one, else the normalised description.",
      "x-demiton-requiredness": "required"
    },
    "cost_code": {
      "type": "string",
      "description": "The job task number the offending lines are coded to.",
      "x-demiton-requiredness": "optional"
    },
    "last_seen": {
      "type": "string",
      "description": "The latest matched order line's date, ISO date.",
      "x-demiton-requiredness": "required"
    },
    "line_cost": {
      "type": "number",
      "description": "The rework's measured cost: the offending order lines' line amount, ex-GST.",
      "x-demiton-requiredness": "required"
    },
    "first_seen": {
      "type": "string",
      "description": "The earliest matched order line's date, ISO date.",
      "x-demiton-requiredness": "required"
    },
    "description": {
      "type": "string",
      "description": "The item description as the order lines carry it.",
      "x-demiton-requiredness": "optional"
    },
    "item_number": {
      "type": "string",
      "description": "The item number the order lines carry, when they carry one.",
      "x-demiton-requiredness": "optional"
    },
    "occurrences": {
      "type": "number",
      "description": "How many order lines matched.",
      "x-demiton-requiredness": "required"
    },
    "window_days": {
      "type": "number",
      "description": "The repeat window applied, in days, from the org's configured exclusion settings.",
      "x-demiton-requiredness": "optional"
    },
    "line_fact_ids": {
      "type": "array",
      "description": "The purchase_line facts the verdict cites.",
      "x-demiton-requiredness": "optional"
    },
    "cause_category": {
      "type": "string",
      "description": "The subcategory of the verdict's disease: the stage or control that failed. One of that disease's `causes[].key` in vocab/diseases.json, checked by `taxonomy.check_cause` before the write. Absent when the detector does not determine it.",
      "x-demiton-requiredness": "optional"
    },
    "excess_quantity": {
      "type": "number",
      "description": "For over_purchase, the quantity ordered beyond the planned amount.",
      "x-demiton-requiredness": "optional"
    }
  },
  "x-demiton-register-type": "rework_risk_verdict",
  "x-demiton-contract-version": "2.1.1",
  "x-demiton-store": "tenant",
  "x-demiton-axes": [],
  "x-demiton-measures": [],
  "x-demiton-provenance": {
    "standards": []
  },
  "description": "The Rework risk verdict register contract, version 2. JSON Schema (draft 2020-12); x-demiton-* keywords carry Demiton's own meaning and standard validators ignore them.",
  "x-demiton-contract-url": "https://docs.demiton.io/registers/rework_risk_verdict/",
  "x-demiton-register-catalog": "https://docs.demiton.io/concepts/register-catalog"
}