{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ucp.dev/2026-08-25/schemas/shopping/types/adjustment.json",
  "title": "Adjustment",
  "description": "Post-order event that exists independently of fulfillment. Typically represents money movements but can be any post-order change. Polymorphic type that can optionally reference line items.",
  "type": "object",
  "required": [
    "id",
    "type",
    "occurred_at",
    "status"
  ],
  "properties": {
    "id": {
      "type": "string",
      "description": "Adjustment event identifier."
    },
    "type": {
      "type": "string",
      "description": "Type of adjustment (open string). Typically money-related like: refund, return, credit, price_adjustment, dispute, cancellation. Can be any value that makes sense for the merchant's business."
    },
    "occurred_at": {
      "type": "string",
      "format": "date-time",
      "description": "RFC 3339 timestamp when this adjustment occurred."
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "completed",
        "failed"
      ],
      "description": "Adjustment status."
    },
    "line_items": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "quantity"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Line item ID reference."
          },
          "quantity": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "Signed integer count of steps of the referenced line item's `quantity_unit` (`10^-scale` × `unit`); when `quantity_unit` is absent, it counts whole items (`each`). Negative values represent reductions (e.g. returns); positive values represent additions (e.g. exchanges)."
          },
          "measure": {
            "$ref": "https://ucp.dev/2026-08-25/schemas/common/types/measure.json",
            "description": "The settled measurement this adjustment reconciles (for example, actual picked weight), present when the line's price settles by measurement. Its unit identity MUST match the line's pricing basis (`item.unit_price` measure/reference unit); no unit conversion. A pure price settlement uses `quantity: 0` together with `measure` and a totals delta."
          }
        }
      },
      "description": "Which line items and quantities are affected (optional)."
    },
    "totals": {
      "type": "array",
      "items": {
        "$ref": "https://ucp.dev/2026-08-25/schemas/common/types/total.json"
      },
      "description": "Adjustment totals breakdown. Signed values - negative for money returned to buyer (refunds, credits), positive for additional charges (exchanges)."
    },
    "description": {
      "type": "string",
      "description": "Human-readable reason or description (e.g., 'Defective item', 'Customer requested')."
    }
  }
}