{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://backpr.com/standard/v1/registration.schema.json",
  "$comment": "Open Youth Registration format 1.x, BackPR, https://backpr.com/open-youth-registration. CC BY 4.0: https://creativecommons.org/licenses/by/4.0/",
  "title": "Registration",
  "description": "One participant's enrollment in one program, with pricing and payments. participantId must match a participant, programId a program and sessionIds sessions of that program in the same file or the receiving system. Custom fields must start with x- (for example x-bunk); other names are reserved for this format. Software that rewrites a file must keep fields it doesn't recognize.",
  "type": "object",
  "properties": {
    "id": {
      "$ref": "common.schema.json#/$defs/id"
    },
    "participantId": {
      "type": "string"
    },
    "programId": {
      "type": "string"
    },
    "sessionIds": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "status": {
      "enum": [
        "pending",
        "enrolled",
        "waitlisted",
        "canceled",
        "completed"
      ]
    },
    "createdAt": {
      "$ref": "common.schema.json#/$defs/dateTime"
    },
    "updatedAt": {
      "$ref": "common.schema.json#/$defs/dateTime",
      "description": "When this record last changed. When two files disagree, the later updatedAt wins."
    },
    "price": {
      "type": "object",
      "properties": {
        "list": {
          "$ref": "common.schema.json#/$defs/money"
        },
        "discounts": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "description": "For example sibling, early-bird or scholarship."
              },
              "amount": {
                "type": "number",
                "minimum": 0,
                "description": "Positive number subtracted from list."
              }
            }
          }
        },
        "total": {
          "$ref": "common.schema.json#/$defs/money"
        }
      }
    },
    "payments": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "$ref": "common.schema.json#/$defs/id"
          },
          "date": {
            "$ref": "common.schema.json#/$defs/date"
          },
          "amount": {
            "$ref": "common.schema.json#/$defs/money"
          },
          "method": {
            "enum": [
              "card",
              "bank",
              "cash",
              "check",
              "voucher",
              "other"
            ]
          },
          "status": {
            "enum": [
              "paid",
              "refunded",
              "partially-refunded",
              "failed",
              "pending"
            ]
          },
          "refundedAmount": {
            "type": "number",
            "minimum": 0
          },
          "payerId": {
            "type": "string",
            "description": "Guardian id."
          },
          "reference": {
            "type": "string",
            "description": "Processor or check number. Never a card or bank account number."
          }
        },
        "required": [
          "id",
          "amount"
        ]
      }
    },
    "installments": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "dueDate": {
            "$ref": "common.schema.json#/$defs/date"
          },
          "amount": {
            "$ref": "common.schema.json#/$defs/money"
          },
          "status": {
            "enum": [
              "scheduled",
              "paid",
              "failed",
              "canceled"
            ]
          }
        },
        "required": [
          "dueDate",
          "amount"
        ]
      }
    }
  },
  "required": [
    "id",
    "participantId",
    "programId"
  ],
  "additionalProperties": true
}