{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://app.creditcresttechnologies.com.au/v1/statement/document/schema",
  "title": "Creditcrest bank statement, version 1.1",
  "type": "object",
  "required": [
    "standard",
    "version",
    "id",
    "createdAt",
    "preparedFor",
    "reference",
    "invented",
    "source",
    "period",
    "holders",
    "accounts",
    "notes",
    "seal"
  ],
  "properties": {
    "standard": {
      "const": "creditcrest/bank-statement"
    },
    "version": {
      "type": "string",
      "pattern": "^1\\.\\d+$"
    },
    "id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{6,64}$"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "preparedFor": {
      "type": [
        "string",
        "null"
      ],
      "description": "The lender the statement was made for."
    },
    "reference": {
      "type": [
        "string",
        "null"
      ],
      "description": "The lender’s own reference, such as the application’s."
    },
    "invented": {
      "type": "boolean",
      "description": "Made from invented data, to show the standard."
    },
    "source": {
      "type": "object",
      "required": [
        "method",
        "via",
        "provider",
        "retrievedAt",
        "file"
      ],
      "properties": {
        "method": {
          "enum": [
            "open banking",
            "bank login",
            "file",
            "invented"
          ]
        },
        "via": {
          "enum": [
            "connection",
            "sent"
          ],
          "description": "connection: Creditcrest’s own connection fetched the data; sent: it was sent to Creditcrest, as a file or by a lender’s program."
        },
        "provider": {
          "type": [
            "string",
            "null"
          ],
          "description": "Who fetched the data, where a provider did."
        },
        "retrievedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "file": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "format": {
              "type": [
                "string",
                "null"
              ],
              "enum": [
                "pdf",
                "csv",
                "xlsx",
                "xls",
                "ods",
                "html",
                "xml2003",
                "ofx",
                "qif",
                "mt940",
                "camt",
                null
              ]
            },
            "sha256": {
              "type": [
                "string",
                "null"
              ],
              "pattern": "^[0-9a-f]{64}$"
            },
            "bytes": {
              "type": [
                "integer",
                "null"
              ]
            },
            "pages": {
              "type": [
                "integer",
                "null"
              ]
            },
            "recognised": {
              "type": "boolean"
            }
          },
          "required": [
            "format",
            "sha256",
            "bytes",
            "pages",
            "recognised"
          ]
        }
      }
    },
    "period": {
      "type": "object",
      "properties": {
        "from": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "to": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "days": {
          "type": [
            "integer",
            "null"
          ]
        }
      },
      "required": [
        "from",
        "to",
        "days"
      ]
    },
    "holders": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "address": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "name",
          "address"
        ]
      }
    },
    "accounts": {
      "type": "array",
      "minItems": 1,
      "maxItems": 20,
      "items": {
        "type": "object",
        "required": [
          "id",
          "institution",
          "name",
          "product",
          "kind",
          "holders",
          "ownership",
          "bsb",
          "number",
          "currency",
          "status",
          "period",
          "balanceSource",
          "balances",
          "summary",
          "checks",
          "transactions"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "institution": {
            "type": [
              "string",
              "null"
            ],
            "description": "The bank’s name."
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "product": {
            "type": [
              "string",
              "null"
            ]
          },
          "kind": {
            "enum": [
              "transaction",
              "savings",
              "credit card",
              "loan",
              "term deposit",
              "investment",
              "other"
            ]
          },
          "holders": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ownership": {
            "enum": [
              "sole",
              "joint",
              null
            ]
          },
          "bsb": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^\\d{3}-\\d{3}$"
          },
          "number": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^xxxx\\d{1,4}",
            "description": "The account number’s last four digits, never more."
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[A-Z]{3}$"
          },
          "status": {
            "enum": [
              "open",
              "closed",
              null
            ]
          },
          "period": {
            "type": "object",
            "properties": {
              "from": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "to": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "days": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "required": [
              "from",
              "to",
              "days"
            ]
          },
          "balanceSource": {
            "enum": [
              "printed",
              "worked",
              null
            ]
          },
          "balances": {
            "type": "object",
            "required": [
              "opening",
              "closing",
              "current",
              "available",
              "limit",
              "asAt"
            ],
            "properties": {
              "opening": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "closing": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "current": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "available": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "limit": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "asAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          },
          "summary": {
            "type": "object",
            "required": [
              "moneyIn",
              "moneyOut",
              "lowest",
              "highest",
              "averageDayEnd",
              "daysBelowZero",
              "months"
            ],
            "properties": {
              "moneyIn": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "integer"
                  },
                  "total": {
                    "type": "number"
                  }
                },
                "required": [
                  "count",
                  "total"
                ]
              },
              "moneyOut": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "integer"
                  },
                  "total": {
                    "type": "number"
                  }
                },
                "required": [
                  "count",
                  "total"
                ]
              },
              "lowest": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "balance": {
                    "type": "number"
                  },
                  "on": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  }
                },
                "required": [
                  "balance",
                  "on"
                ]
              },
              "highest": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "balance": {
                    "type": "number"
                  },
                  "on": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  }
                },
                "required": [
                  "balance",
                  "on"
                ]
              },
              "averageDayEnd": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "daysBelowZero": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "months": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "month": {
                      "type": "string",
                      "pattern": "^\\d{4}-\\d{2}$"
                    },
                    "days": {
                      "type": "integer"
                    },
                    "moneyIn": {
                      "type": "number"
                    },
                    "moneyOut": {
                      "type": "number"
                    },
                    "closing": {
                      "type": [
                        "number",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "month",
                    "days",
                    "moneyIn",
                    "moneyOut",
                    "closing"
                  ]
                }
              }
            }
          },
          "checks": {
            "type": "object",
            "required": [
              "reconciles",
              "balanceChain",
              "firstTransaction",
              "lastTransaction",
              "longestGap",
              "possibleDuplicates"
            ],
            "properties": {
              "reconciles": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Whether the stated opening balance and the transactions come to the stated closing one; null where the bank stated neither, or the balances were worked out."
              },
              "balanceChain": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "tested": {
                    "type": "integer"
                  },
                  "held": {
                    "type": "integer"
                  }
                },
                "required": [
                  "tested",
                  "held"
                ],
                "description": "Of the printed balances that could be checked against the one before, how many agree."
              },
              "firstTransaction": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "lastTransaction": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "longestGap": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "days": {
                    "type": "integer"
                  },
                  "from": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  "to": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  }
                },
                "required": [
                  "days",
                  "from",
                  "to"
                ]
              },
              "possibleDuplicates": {
                "type": "integer"
              }
            }
          },
          "transactions": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "id",
                "date",
                "description",
                "amount",
                "balance"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "date": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                },
                "description": {
                  "type": "string"
                },
                "amount": {
                  "type": "number",
                  "description": "Dollars (the account’s currency) to the cent: money in positive, money out negative."
                },
                "balance": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "type": {
                  "enum": [
                    "FEE",
                    "INTEREST_CHARGED",
                    "INTEREST_PAID",
                    "TRANSFER_OUTGOING",
                    "TRANSFER_INCOMING",
                    "PAYMENT",
                    "DIRECT_DEBIT",
                    "OTHER"
                  ]
                },
                "reference": {
                  "type": "string"
                },
                "merchant": {
                  "type": "string"
                },
                "mcc": {
                  "type": "string",
                  "pattern": "^\\d{4}$"
                },
                "biller": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "code",
                    "name"
                  ]
                },
                "category": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "code",
                    "label"
                  ],
                  "description": "Creditcrest’s reading of the line, where the statement was made with one; null where it declined."
                },
                "party": {
                  "type": "string",
                  "description": "The party paid or paying, where Creditcrest named one."
                },
                "detail": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "code",
                    "label"
                  ],
                  "description": "What the line’s words settle: a dishonour, an overdrawn or late payment fee, a small-amount lender, a pay-advance app, a debt collector, or which government payment."
                }
              }
            }
          }
        }
      }
    },
    "reader": {
      "type": "object",
      "properties": {
        "setting": {
          "enum": [
            "strict",
            "balanced",
            "broad"
          ]
        },
        "version": {
          "type": "string"
        }
      },
      "required": [
        "setting",
        "version"
      ]
    },
    "analysis": {
      "type": "object",
      "description": "Creditcrest’s analysis, from the same reading as the categories: figures with references, income and credit streams with a status, conduct, and the parties in each category.",
      "required": [
        "version",
        "asAt",
        "days",
        "months",
        "metrics",
        "income",
        "credit",
        "categories",
        "accounts",
        "signals",
        "quality"
      ],
      "properties": {
        "version": {
          "type": "string"
        },
        "asAt": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "days": {
          "type": "integer"
        },
        "months": {
          "type": "number"
        },
        "metrics": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "ref",
              "group",
              "label",
              "value",
              "unit"
            ],
            "properties": {
              "ref": {
                "type": "string",
                "pattern": "^(?:IN|RL|LI|EX|PO)\\d{2}$"
              },
              "group": {
                "enum": [
                  "IN",
                  "RL",
                  "LI",
                  "EX",
                  "PO"
                ]
              },
              "label": {
                "type": "string"
              },
              "value": {
                "type": [
                  "number",
                  "string",
                  "null"
                ],
                "description": "Null where the statement cannot say. A date is YYYY-MM-DD."
              },
              "unit": {
                "enum": [
                  "money",
                  "count",
                  "share",
                  "days",
                  "date"
                ]
              },
              "per": {
                "const": "month"
              },
              "window": {
                "enum": [
                  30,
                  90,
                  "period",
                  "next 30"
                ]
              },
              "field": {
                "type": "string",
                "description": "The Decisioning field that reads the same figure."
              },
              "category": {
                "type": "string"
              },
              "on": {
                "type": "string",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "account": {
                "type": "string"
              },
              "from": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "The transactions it came from, by id: the first 400."
              }
            }
          }
        },
        "income": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "party",
              "category",
              "frequency",
              "typical",
              "monthly",
              "count",
              "first",
              "last",
              "next",
              "status",
              "transactions"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "party": {
                "type": "string"
              },
              "named": {
                "type": "boolean"
              },
              "category": {
                "type": "string"
              },
              "benefit": {
                "type": "string"
              },
              "frequency": {
                "enum": [
                  "weekly",
                  "fortnightly",
                  "monthly",
                  "quarterly",
                  null
                ]
              },
              "weekday": {
                "type": "string"
              },
              "dayOfMonth": {
                "type": "integer"
              },
              "typical": {
                "type": "number"
              },
              "assessed": {
                "type": "number"
              },
              "variable": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "monthly": {
                "type": "number",
                "description": "Counted as regular income: ongoing streams only."
              },
              "monthlyWhenPaid": {
                "type": "number"
              },
              "count": {
                "type": "integer"
              },
              "first": {
                "type": "string",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "last": {
                "type": "string",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "daysSinceLast": {
                "type": "integer"
              },
              "next": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "expected": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "missed": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "last30": {
                "type": "number"
              },
              "last90": {
                "type": "number"
              },
              "status": {
                "enum": [
                  "ongoing",
                  "skipped",
                  "stopped",
                  "irregular"
                ],
                "description": "ongoing: the last one due came; skipped: it did not, by up to one more period; stopped: none for more than a period past due; irregular: no steady rhythm."
              },
              "inferred": {
                "type": "boolean"
              },
              "accounts": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "transactions": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "The transactions it came from, by id: the first 400."
              }
            }
          }
        },
        "credit": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "party",
              "kind",
              "frequency",
              "typical",
              "monthly",
              "count",
              "total",
              "status",
              "received",
              "ends",
              "transactions"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "party": {
                "type": "string"
              },
              "named": {
                "type": "boolean"
              },
              "kind": {
                "enum": [
                  "debt_collector",
                  "small_amount_lender",
                  "pay_advance",
                  "buy_now_pay_later",
                  "card",
                  "mortgage",
                  "loan"
                ]
              },
              "frequency": {
                "enum": [
                  "weekly",
                  "fortnightly",
                  "monthly",
                  "quarterly",
                  null
                ]
              },
              "weekday": {
                "type": "string"
              },
              "dayOfMonth": {
                "type": "integer"
              },
              "typical": {
                "type": "number"
              },
              "monthly": {
                "type": "number"
              },
              "monthlyWhenPaid": {
                "type": "number"
              },
              "count": {
                "type": "integer"
              },
              "total": {
                "type": "number"
              },
              "first": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "last": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "daysSinceLast": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "next": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "last90": {
                "type": "number"
              },
              "status": {
                "enum": [
                  "ongoing",
                  "skipped",
                  "stopped",
                  "irregular"
                ],
                "description": "ongoing: the last one due came; skipped: it did not, by up to one more period; stopped: none for more than a period past due; irregular: no steady rhythm."
              },
              "received": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "date": {
                      "type": "string",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                    },
                    "amount": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "date",
                    "amount"
                  ]
                }
              },
              "ends": {
                "type": [
                  "object",
                  "null"
                ],
                "description": "When the repayments may end: covered (repaid on `on`), stopped (last repaid on `on`), or between `from` and `to` (to only where the law caps the cost).",
                "properties": {
                  "basis": {
                    "enum": [
                      "stopped",
                      "covered",
                      "amount lent",
                      "small amount credit contract",
                      "medium amount credit contract"
                    ]
                  },
                  "on": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  "from": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  "to": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  "lent": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "date": {
                        "type": "string",
                        "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                      },
                      "amount": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "id",
                      "date",
                      "amount"
                    ]
                  }
                },
                "required": [
                  "basis"
                ]
              },
              "dishonours": {
                "type": "array",
                "description": "The refusals (analysis.dishonours ids) of a repayment to this provider.",
                "items": {
                  "type": "string"
                }
              },
              "accounts": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "transactions": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "The transactions it came from, by id: the first 400."
              }
            }
          }
        },
        "dishonours": {
          "type": "array",
          "description": "Each payment refused, once — the debit, the money coming back and the fee are one — and each overdrawn fee, with the payment it was and how that was found (`basis`).",
          "items": {
            "type": "object",
            "required": [
              "id",
              "kind",
              "on",
              "account",
              "fee",
              "lines",
              "basis",
              "payment"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "kind": {
                "enum": [
                  "dishonour",
                  "overdrawn"
                ]
              },
              "on": {
                "type": "string",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                "description": "The day the bank refused it, or charged the overdrawn fee."
              },
              "account": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "fee": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "lines": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "The transactions it came from, by id: the first 400."
              },
              "basis": {
                "enum": [
                  "returned",
                  "returned in",
                  "named",
                  "due",
                  "overdrew",
                  null
                ],
                "description": "returned: The payment came back: the same amount, out of the same account, up to five days before. returned in: Money paid in was taken back: the same amount, up to 14 days after it came. named: The fee’s own words name the party. due: A regular payment to the party was due up to four days before and did not go out. overdrew: The payment that took the account below zero, up to three days before the fee."
              },
              "payment": {
                "type": [
                  "object",
                  "null"
                ],
                "description": "The payment refused (or, for an overdrawn fee, the one that took the account below zero): a transaction where the statement holds it, else the party and the day it was due.",
                "properties": {
                  "id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "party": {
                    "type": "string"
                  },
                  "credit": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The credit stream it was a repayment of."
                  },
                  "amount": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "on": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  "in": {
                    "type": "boolean",
                    "description": "Money paid in that was taken back."
                  },
                  "paidLater": {
                    "type": [
                      "object",
                      "null"
                    ],
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "on": {
                        "type": "string",
                        "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                      }
                    },
                    "required": [
                      "id",
                      "on"
                    ]
                  }
                },
                "required": [
                  "id",
                  "party",
                  "credit",
                  "amount",
                  "on"
                ]
              }
            }
          }
        },
        "split": {
          "type": "object",
          "description": "Whose split of essential and discretionary spending the figures are (since analysis 1.3): the lender’s own, or Creditcrest’s; and the categories it counts as discretionary.",
          "required": [
            "by",
            "discretionary"
          ],
          "properties": {
            "by": {
              "enum": [
                "lender",
                "creditcrest"
              ]
            },
            "discretionary": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        },
        "categories": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "code",
              "label",
              "group",
              "in",
              "out",
              "parties"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "own": {
                "type": "boolean",
                "description": "Transfers only: between the holder’s own accounts, or to and from anybody else."
              },
              "label": {
                "type": "string"
              },
              "group": {
                "type": "string"
              },
              "in": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "integer"
                  },
                  "total": {
                    "type": "number"
                  }
                },
                "required": [
                  "count",
                  "total"
                ]
              },
              "out": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "integer"
                  },
                  "total": {
                    "type": "number"
                  },
                  "monthly": {
                    "type": "number"
                  }
                },
                "required": [
                  "count",
                  "total",
                  "monthly"
                ]
              },
              "parties": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "key",
                    "name",
                    "count",
                    "in",
                    "out",
                    "first",
                    "last"
                  ],
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "named": {
                      "type": "boolean"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "in": {
                      "type": "number"
                    },
                    "out": {
                      "type": "number"
                    },
                    "monthly": {
                      "type": "number"
                    },
                    "average": {
                      "type": "number"
                    },
                    "first": {
                      "type": "string",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                    },
                    "last": {
                      "type": "string",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                    },
                    "daysSinceLast": {
                      "type": "integer"
                    },
                    "frequency": {
                      "enum": [
                        "weekly",
                        "fortnightly",
                        "monthly",
                        "quarterly",
                        null
                      ]
                    },
                    "weekday": {
                      "type": "string"
                    },
                    "dayOfMonth": {
                      "type": "integer"
                    },
                    "last30": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "accounts": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "belowZero",
              "dishonours",
              "income"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "belowZero": {
                "type": "object",
                "properties": {
                  "days30": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "days90": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "period": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "days30",
                  "days90",
                  "period"
                ]
              },
              "dishonours": {
                "type": "object",
                "properties": {
                  "days30": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "days90": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "period": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "days30",
                  "days90",
                  "period"
                ],
                "description": "Payments refused, each once (since analysis 1.2 without the overdrawn fees)."
              },
              "overdrawnFees": {
                "type": "object",
                "properties": {
                  "days30": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "days90": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "period": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "days30",
                  "days90",
                  "period"
                ],
                "description": "Fees charged for the account going below zero (since analysis 1.2)."
              },
              "stretches": {
                "type": "array",
                "description": "Each run of days the account ended below zero: the last 24.",
                "items": {
                  "type": "object",
                  "properties": {
                    "from": {
                      "type": "string",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                    },
                    "to": {
                      "type": "string",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                    },
                    "days": {
                      "type": "integer"
                    },
                    "lowest": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "from",
                    "to",
                    "days",
                    "lowest"
                  ]
                }
              },
              "income": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "integer"
                  },
                  "total": {
                    "type": "number"
                  },
                  "kinds": {
                    "type": "array",
                    "description": "The regular income paid into it: salary, government, other.",
                    "items": {
                      "enum": [
                        "salary",
                        "government",
                        "other"
                      ]
                    }
                  }
                },
                "required": [
                  "count",
                  "total"
                ]
              },
              "median": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "The median of its day-end balances over the period."
              }
            }
          }
        },
        "signals": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "code",
              "severity",
              "statement",
              "from"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "severity": {
                "enum": [
                  "high",
                  "note"
                ]
              },
              "statement": {
                "type": "string"
              },
              "from": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "The transactions it came from, by id: the first 400."
              }
            }
          }
        },
        "quality": {
          "type": "object",
          "properties": {
            "categorisedShare": {
              "type": "number"
            },
            "spendCategorisedShare": {
              "type": "number"
            },
            "enoughHistory": {
              "type": "boolean"
            }
          },
          "required": [
            "categorisedShare",
            "spendCategorisedShare",
            "enoughHistory"
          ]
        }
      }
    },
    "notes": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "seal": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "alg": {
          "const": "HMAC-SHA256"
        },
        "kid": {
          "type": "string"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "value": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        }
      },
      "required": [
        "alg",
        "kid",
        "sha256",
        "value"
      ]
    }
  }
}