{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/folio/json-schema/folio-charge-results-schema.json",
  "title": "ChargeResults",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/folio-charges-api-openapi.yml#/components/schemas/ChargeResults",
  "type": "object",
  "required": [
    "results"
  ],
  "allOf": [
    {
      "$ref": "#/$defs/ResultsMeta"
    },
    {
      "type": "object"
    },
    {
      "properties": {
        "results": {
          "$ref": "#/$defs/ChargeResultsArray"
        }
      }
    }
  ],
  "$defs": {
    "Charge": {
      "type": "object",
      "required": [
        "id",
        "amount"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "readOnly": true
        },
        "dateCreated": {
          "type": "string",
          "format": "date-time",
          "readOnly": true
        },
        "lastUpdated": {
          "type": "string",
          "format": "date-time",
          "readOnly": true
        },
        "owner": {
          "type": "string",
          "format": "uuid",
          "writeOnly": true
        },
        "amount": {
          "$ref": "#/$defs/MonetaryValue"
        },
        "exchangeRate": {
          "$ref": "#/$defs/ExchangeRate"
        },
        "description": {
          "type": "string"
        },
        "paymentPeriod": {
          "type": "string",
          "pattern": "^([0-9]{4})?$"
        },
        "category": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/Refdata"
            }
          ]
        },
        "discount": {
          "type": "number",
          "default": 0
        },
        "discountType": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/Refdata"
            }
          ]
        },
        "discountNote": {
          "type": "string"
        },
        "tax": {
          "type": "number"
        },
        "chargeStatus": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/Refdata"
            }
          ]
        },
        "invoiceReference": {
          "type": "string",
          "format": "uuid"
        },
        "invoiceLineItemReference": {
          "type": "string",
          "format": "uuid"
        },
        "payers": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Payer"
          }
        },
        "estimatedInvoicePrice": {
          "readOnly": true,
          "$ref": "#/$defs/MonetaryValue"
        },
        "estimatedPrice": {
          "readOnly": true,
          "$ref": "#/$defs/MonetaryValue"
        }
      }
    },
    "ChargeResultsArray": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Charge"
      }
    },
    "ExchangeRate": {
      "type": "object",
      "required": [
        "id",
        "fromCurrency",
        "toCurrency",
        "coefficient"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "readOnly": true
        },
        "fromCurrency": {
          "type": "string"
        },
        "toCurrency": {
          "type": "string"
        },
        "coefficient": {
          "type": "number"
        }
      }
    },
    "MonetaryValue": {
      "type": "object",
      "required": [
        "id",
        "baseCurrency",
        "value"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "readOnly": true
        },
        "baseCurrency": {
          "type": "string"
        },
        "value": {
          "type": "number",
          "multipleOf": 0.01,
          "description": "Monetary amount, fixed to 2 decimal places"
        }
      }
    },
    "Payer": {
      "type": "object",
      "required": [
        "id",
        "payer",
        "payerAmount"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "readOnly": true
        },
        "payer": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/Refdata"
            }
          ]
        },
        "payerAmount": {
          "type": "number"
        },
        "payerNote": {
          "type": "string"
        }
      }
    },
    "Refdata": {
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "type": "string",
          "readOnly": true
        },
        "label": {
          "type": "string"
        },
        "value": {
          "type": "string"
        }
      }
    },
    "ResultsMeta": {
      "type": "object",
      "properties": {
        "meta": {
          "type": "object"
        },
        "page": {
          "type": "integer"
        },
        "pageSize": {
          "type": "integer"
        },
        "total": {
          "type": "integer"
        },
        "totalPages": {
          "type": "integer"
        },
        "totalRecords": {
          "type": "integer"
        }
      }
    }
  }
}