{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/oyster-hr/json-schema/oyster-hr-credit-notes-schema.json",
  "title": "creditNotes",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/oyster-hr-credit-notes-api-openapi.yml#/components/schemas/creditNotes",
  "type": "array",
  "items": {
    "$ref": "#/$defs/creditNote"
  },
  "$defs": {
    "amount": {
      "type": "object",
      "properties": {
        "decimal": {
          "type": "string",
          "pattern": "^\\d+([.]\\d+)?$"
        },
        "currencyCode": {
          "type": "string",
          "minLength": 3,
          "maxLength": 3
        }
      },
      "required": [
        "decimal",
        "currencyCode"
      ]
    },
    "creditNote": {
      "type": "object",
      "required": [
        "id",
        "referenceCode",
        "type",
        "status",
        "payrollMonth",
        "payrollYear",
        "issueDate",
        "totalAmount",
        "amountRemaining"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "referenceCode": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "payrollMonth": {
          "type": "string"
        },
        "payrollYear": {
          "type": "string"
        },
        "issueDate": {
          "type": "string",
          "format": "date"
        },
        "totalAmount": {
          "$ref": "#/$defs/amount"
        },
        "amountRemaining": {
          "$ref": "#/$defs/amount"
        },
        "customer": {
          "type": "object",
          "required": [
            "id",
            "name"
          ],
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          }
        },
        "files": {
          "type": [
            "object",
            "null"
          ],
          "required": [
            "document"
          ],
          "properties": {
            "document": {
              "type": "object",
              "required": [
                "title",
                "url",
                "contentType"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "contentType": {
                  "type": "string"
                }
              }
            }
          }
        },
        "appliedToInvoices": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "object",
            "required": [
              "id",
              "referenceCode",
              "appliedAt",
              "amount"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "referenceCode": {
                "type": "string"
              },
              "amount": {
                "$ref": "#/$defs/amount"
              },
              "appliedAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        }
      }
    }
  }
}