{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/arcnm-io/json-schema/arcnm-io-calibration-import-create-schema.json",
  "title": "CalibrationImportCreate",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/arcnm-io-calibration-api-openapi.yml#/components/schemas/CalibrationImportCreate",
  "properties": {
    "env_id": {
      "type": "string",
      "format": "uuid",
      "title": "Env Id",
      "description": "The costing environment to calibrate."
    },
    "rows": {
      "items": {
        "$ref": "#/$defs/CalibrationImportRowIn"
      },
      "type": "array",
      "maxItems": 20000,
      "minItems": 1,
      "title": "Rows",
      "description": "Up to 20,000 historical actuals."
    },
    "currency": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 3,
          "minLength": 3
        },
        {
          "type": "null"
        }
      ],
      "title": "Currency",
      "description": "Currency the actuals are denominated in. Must match the environment's currency; defaults to it."
    },
    "basis": {
      "anyOf": [
        {
          "$ref": "#/$defs/CostBasis"
        },
        {
          "type": "null"
        }
      ],
      "description": "Which rung of the cost sheet the whole file is measured at: 'herstellkosten' (manufacturing cost per unit — what a work order books), 'selbstkosten' (total cost per unit, including administration, selling, freight and duty) or 'angebotspreis' (the price per unit, including the profit mark-up). One basis per file, like one currency per file. Each row is compared against the model's own figure at the same rung. A column header cannot answer this — 'unit cost' and 'unit price' are used interchangeably in exports — so it is asked rather than guessed. Omit it only if you genuinely do not know: an unstated basis is read as manufacturing cost and the environment's calibration report flags how many rows were unstated. Fixed when the import is created; re-posting the same rows returns the existing import unchanged."
    }
  },
  "additionalProperties": false,
  "type": "object",
  "required": [
    "env_id",
    "rows"
  ],
  "$defs": {
    "CalibrationImportRowIn": {
      "properties": {
        "part_number": {
          "type": "string",
          "maxLength": 64,
          "minLength": 1,
          "title": "Part Number",
          "description": "Your part number, matched verbatim against your part library (same rule as POST /parts/resolve-numbers)."
        },
        "actual_unit_cost": {
          "type": "number",
          "exclusiveMinimum": 0.0,
          "title": "Actual Unit Cost",
          "description": "What one part really cost you at this lot size, in the environment's currency."
        },
        "lot_size": {
          "type": "integer",
          "maximum": 1000000000.0,
          "minimum": 1.0,
          "title": "Lot Size",
          "description": "The lot the actual was produced at. Defaults to 1.",
          "default": 1
        },
        "annual_volume": {
          "anyOf": [
            {
              "type": "integer",
              "maximum": 100000000.0,
              "minimum": 1.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Annual Volume",
          "description": "Planned 12-month volume, when known (tooling amortization)."
        },
        "bin": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 120
            },
            {
              "type": "null"
            }
          ],
          "title": "Bin",
          "description": "Optional calibration bin label for this row (e.g. 'process:milling'). Unlabelled rows inherit the calculation's own process bin."
        },
        "source_ref": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 128
            },
            {
              "type": "null"
            }
          ],
          "title": "Source Ref",
          "description": "Your own line identity (work order / PO), for cross-import de-duplication."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "part_number",
        "actual_unit_cost"
      ],
      "title": "CalibrationImportRowIn",
      "description": "One historical actual: a part number, a lot, what it really cost."
    },
    "CostBasis": {
      "type": "string",
      "enum": [
        "herstellkosten",
        "selbstkosten",
        "angebotspreis"
      ],
      "title": "CostBasis",
      "description": "Which rung of the cost sheet a submitted actual sits on.\n\nAn observation is a pair: a number the shop measured and the number\nthe model produced for the same thing. \"The same thing\" was never\nstated, and three different quantities were reaching the same slot —\nan internal manufacturing cost booked on a work order, an operator's\nreported cost, and a supplier or marketplace price. A price carries\nselling costs and profit that a manufacturing cost does not, so\nregressing the two together makes the fitted correction the average\nof an under-statement and an over-statement. Netting is not\ncorrectness: each observation now says which rung it is on, and is\ncompared against the model's own quantity at that rung.\n\nThe three rungs are the German cost sheet's, which is also the ladder\nthe engine already builds around every quote (Eversheim,\n*Organisation in der Produktionstechnik 3*, §2.10):\n\n* ``herstellkosten``  — manufacturing cost per unit: the unit cost\n  (direct and machine cost plus burden and overhead) plus the reject-rate\n  material, the material overhead and the production overhead the\n  environment states. What a work order books. Equal to the\n  engine's unit cost on every environment that states none of\n  those three rates.\n* ``selbstkosten``    — total cost per unit: manufacturing cost plus\n  administration, selling, freight and duty.\n* ``angebotspreis``   — the quoted price per unit: total cost plus\n  the profit mark-up. What a supplier quote or a marketplace price\n  is.\n\n``None`` (unstated) is not a fourth rung: it means the submitter did\nnot say, and it is read exactly as the pre-declaration behaviour —\ncompared against the manufacturing cost — with the fit report saying\nout loud how many observations were unstated."
    }
  }
}