{
  "$defs": {
    "__schema0": {
      "const": "1.0",
      "type": "string"
    },
    "__schema1": {
      "items": {
        "$ref": "#/$defs/__schema2"
      },
      "maxItems": 1000,
      "type": "array"
    },
    "__schema10": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "items": {
            "$ref": "#/$defs/__schema10"
          },
          "type": "array"
        },
        {
          "additionalProperties": {
            "$ref": "#/$defs/__schema10"
          },
          "propertyNames": {
            "type": "string"
          },
          "type": "object"
        }
      ]
    },
    "__schema11": {
      "items": {
        "$ref": "#/$defs/__schema12"
      },
      "maxItems": 1000,
      "type": "array"
    },
    "__schema12": {
      "maxLength": 5000,
      "minLength": 1,
      "type": "string"
    },
    "__schema13": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema14": {
      "const": "remittance_advice",
      "type": "string"
    },
    "__schema15": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema16": {
      "description": "An ISO 8601 calendar date",
      "format": "date",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
      "type": "string"
    },
    "__schema17": {
      "additionalProperties": false,
      "description": "A business party participating in a document",
      "properties": {
        "address": {
          "$ref": "#/$defs/__schema27"
        },
        "contacts": {
          "$ref": "#/$defs/__schema35"
        },
        "extensions": {
          "$ref": "#/$defs/__schema43"
        },
        "identifiers": {
          "$ref": "#/$defs/__schema19"
        },
        "name": {
          "$ref": "#/$defs/__schema26"
        },
        "role": {
          "$ref": "#/$defs/__schema18"
        }
      },
      "required": [
        "role",
        "identifiers"
      ],
      "type": "object"
    },
    "__schema18": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema19": {
      "items": {
        "$ref": "#/$defs/__schema20"
      },
      "maxItems": 100,
      "minItems": 1,
      "type": "array"
    },
    "__schema2": {
      "additionalProperties": false,
      "description": "A typed business reference",
      "properties": {
        "description": {
          "$ref": "#/$defs/__schema6"
        },
        "extensions": {
          "$ref": "#/$defs/__schema7"
        },
        "issuer": {
          "$ref": "#/$defs/__schema5"
        },
        "type": {
          "$ref": "#/$defs/__schema3"
        },
        "value": {
          "$ref": "#/$defs/__schema4"
        }
      },
      "required": [
        "type",
        "value"
      ],
      "type": "object"
    },
    "__schema20": {
      "additionalProperties": false,
      "description": "A value qualified by an identifier scheme",
      "properties": {
        "agency": {
          "$ref": "#/$defs/__schema23"
        },
        "description": {
          "$ref": "#/$defs/__schema24"
        },
        "extensions": {
          "$ref": "#/$defs/__schema25"
        },
        "scheme": {
          "$ref": "#/$defs/__schema21"
        },
        "value": {
          "$ref": "#/$defs/__schema22"
        }
      },
      "required": [
        "scheme",
        "value"
      ],
      "type": "object"
    },
    "__schema21": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema22": {
      "maxLength": 500,
      "minLength": 1,
      "type": "string"
    },
    "__schema23": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema24": {
      "maxLength": 500,
      "minLength": 1,
      "type": "string"
    },
    "__schema25": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema26": {
      "maxLength": 300,
      "minLength": 1,
      "type": "string"
    },
    "__schema27": {
      "additionalProperties": false,
      "description": "A postal address with country-neutral field names",
      "properties": {
        "administrativeArea": {
          "$ref": "#/$defs/__schema31"
        },
        "countryCode": {
          "$ref": "#/$defs/__schema33"
        },
        "extensions": {
          "$ref": "#/$defs/__schema34"
        },
        "lines": {
          "$ref": "#/$defs/__schema28"
        },
        "locality": {
          "$ref": "#/$defs/__schema30"
        },
        "postalCode": {
          "$ref": "#/$defs/__schema32"
        }
      },
      "required": [
        "lines",
        "countryCode"
      ],
      "type": "object"
    },
    "__schema28": {
      "items": {
        "$ref": "#/$defs/__schema29"
      },
      "maxItems": 5,
      "minItems": 1,
      "type": "array"
    },
    "__schema29": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema3": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema30": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema31": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema32": {
      "maxLength": 40,
      "minLength": 1,
      "type": "string"
    },
    "__schema33": {
      "description": "ISO 3166-1 alpha-2 country code",
      "pattern": "^[A-Z]{2}$",
      "type": "string"
    },
    "__schema34": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema35": {
      "items": {
        "$ref": "#/$defs/__schema36"
      },
      "maxItems": 100,
      "type": "array"
    },
    "__schema36": {
      "additionalProperties": false,
      "description": "Contact information associated with a party",
      "properties": {
        "department": {
          "$ref": "#/$defs/__schema39"
        },
        "email": {
          "$ref": "#/$defs/__schema40"
        },
        "extensions": {
          "$ref": "#/$defs/__schema42"
        },
        "name": {
          "$ref": "#/$defs/__schema38"
        },
        "phone": {
          "$ref": "#/$defs/__schema41"
        },
        "role": {
          "$ref": "#/$defs/__schema37"
        }
      },
      "type": "object"
    },
    "__schema37": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema38": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema39": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema4": {
      "maxLength": 500,
      "minLength": 1,
      "type": "string"
    },
    "__schema40": {
      "format": "email",
      "maxLength": 320,
      "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
      "type": "string"
    },
    "__schema41": {
      "maxLength": 50,
      "minLength": 1,
      "type": "string"
    },
    "__schema42": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema43": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema44": {
      "additionalProperties": false,
      "description": "A precision-safe monetary amount",
      "properties": {
        "amount": {
          "$ref": "#/$defs/__schema45"
        },
        "currency": {
          "$ref": "#/$defs/__schema46"
        },
        "extensions": {
          "$ref": "#/$defs/__schema47"
        }
      },
      "required": [
        "amount",
        "currency"
      ],
      "type": "object"
    },
    "__schema45": {
      "description": "A base-10 decimal value without exponent notation",
      "maxLength": 100,
      "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
      "type": "string"
    },
    "__schema46": {
      "description": "ISO 4217 currency code",
      "pattern": "^[A-Z]{3}$",
      "type": "string"
    },
    "__schema47": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema48": {
      "$ref": "#/$defs/__schema16"
    },
    "__schema49": {
      "$ref": "#/$defs/__schema20"
    },
    "__schema5": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema50": {
      "items": {
        "$ref": "#/$defs/__schema51"
      },
      "maxItems": 100000,
      "minItems": 1,
      "type": "array"
    },
    "__schema51": {
      "additionalProperties": false,
      "description": "An informational allocation of remittance data to an invoice",
      "properties": {
        "adjustments": {
          "$ref": "#/$defs/__schema57"
        },
        "discountAmount": {
          "$ref": "#/$defs/__schema55"
        },
        "extensions": {
          "$ref": "#/$defs/__schema64"
        },
        "invoiceDate": {
          "$ref": "#/$defs/__schema53"
        },
        "invoiceNumber": {
          "$ref": "#/$defs/__schema52"
        },
        "originalAmount": {
          "$ref": "#/$defs/__schema54"
        },
        "paidAmount": {
          "$ref": "#/$defs/__schema44"
        },
        "references": {
          "$ref": "#/$defs/__schema63"
        },
        "remainingAmount": {
          "$ref": "#/$defs/__schema56"
        }
      },
      "required": [
        "invoiceNumber",
        "paidAmount"
      ],
      "type": "object"
    },
    "__schema52": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema53": {
      "$ref": "#/$defs/__schema16"
    },
    "__schema54": {
      "$ref": "#/$defs/__schema44"
    },
    "__schema55": {
      "$ref": "#/$defs/__schema44"
    },
    "__schema56": {
      "$ref": "#/$defs/__schema44"
    },
    "__schema57": {
      "items": {
        "$ref": "#/$defs/__schema58"
      },
      "maxItems": 1000,
      "type": "array"
    },
    "__schema58": {
      "additionalProperties": false,
      "description": "An informational remittance allocation adjustment",
      "properties": {
        "amount": {
          "$ref": "#/$defs/__schema44"
        },
        "code": {
          "$ref": "#/$defs/__schema60"
        },
        "description": {
          "$ref": "#/$defs/__schema61"
        },
        "extensions": {
          "$ref": "#/$defs/__schema62"
        },
        "kind": {
          "$ref": "#/$defs/__schema59"
        }
      },
      "required": [
        "kind",
        "amount"
      ],
      "type": "object"
    },
    "__schema59": {
      "enum": [
        "allowance",
        "charge",
        "discount",
        "correction",
        "other"
      ],
      "type": "string"
    },
    "__schema6": {
      "maxLength": 500,
      "minLength": 1,
      "type": "string"
    },
    "__schema60": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema61": {
      "maxLength": 500,
      "minLength": 1,
      "type": "string"
    },
    "__schema62": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema63": {
      "items": {
        "$ref": "#/$defs/__schema2"
      },
      "maxItems": 1000,
      "type": "array"
    },
    "__schema64": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema7": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema8": {
      "additionalProperties": {
        "$ref": "#/$defs/__schema10"
      },
      "description": "Namespaced, JSON-compatible extension values",
      "propertyNames": {
        "$ref": "#/$defs/__schema9"
      },
      "type": "object"
    },
    "__schema9": {
      "pattern": "^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*:[A-Za-z][A-Za-z0-9_.-]*$",
      "type": "string"
    }
  },
  "$id": "urn:loomedi:canonical:v1:remittance-advice",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "Data-only remittance advice, commonly mapped from X12 820",
  "properties": {
    "adviceDate": {
      "$ref": "#/$defs/__schema16"
    },
    "allocations": {
      "$ref": "#/$defs/__schema50"
    },
    "documentType": {
      "$ref": "#/$defs/__schema14"
    },
    "extensions": {
      "$ref": "#/$defs/__schema13"
    },
    "notes": {
      "$ref": "#/$defs/__schema11"
    },
    "payee": {
      "$ref": "#/$defs/__schema17"
    },
    "payer": {
      "$ref": "#/$defs/__schema17"
    },
    "references": {
      "$ref": "#/$defs/__schema1"
    },
    "remittanceAdviceNumber": {
      "$ref": "#/$defs/__schema15"
    },
    "remittedAmount": {
      "$ref": "#/$defs/__schema44"
    },
    "schemaVersion": {
      "$ref": "#/$defs/__schema0"
    },
    "settlementDate": {
      "$ref": "#/$defs/__schema48"
    },
    "settlementReference": {
      "$ref": "#/$defs/__schema49"
    }
  },
  "required": [
    "schemaVersion",
    "documentType",
    "remittanceAdviceNumber",
    "adviceDate",
    "payer",
    "payee",
    "remittedAmount",
    "allocations"
  ],
  "title": "RemittanceAdvice",
  "type": "object"
}
