{
  "schemaVersion": "1.0",
  "name": "Northgate statement",
  "revision": 1,
  "input": {
    "encoding": "latin-1",
    "tabWidth": 8,
    "stripControl": true,
    "trimTrailingBlankLines": true
  },
  "detect": {
    "priority": 100,
    "all": [
      {
        "line": 0,
        "col": 0,
        "len": 3,
        "equals": "sta"
      }
    ]
  },
  "pagination": {
    "mode": "marker",
    "matches": "^\\s*sta\\s*$"
  },
  "split": {
    "mode": "keyChange",
    "key": {
      "at": {
        "line": 8,
        "col": 21,
        "len": 6
      }
    }
  },
  "defaults": {
    "money": {
      "emit": "string",
      "scale": 2,
      "stripThousands": true
    },
    "date": {
      "parse": "DD/MM/YYYY",
      "emit": "raw",
      "nullIf": [
        "",
        "--/--/----"
      ]
    },
    "string": {
      "trim": true
    }
  },
  "extract": {
    "fields": {
      "accountNumber": {
        "at": {
          "page": "first",
          "line": 8,
          "col": 21,
          "len": 6
        },
        "type": "string"
      },
      "statementDate": {
        "at": {
          "page": "first",
          "line": 8,
          "col": 49,
          "len": 10
        },
        "type": "date"
      },
      "totalDue": {
        "at": {
          "col": 51,
          "len": 11,
          "anchor": {
            "matches": "TOTAL DUE"
          },
          "lineOffset": 0
        },
        "type": "money"
      }
    },
    "blocks": {},
    "tables": {
      "transactions": {
        "mode": "band",
        "band": {
          "pages": "every",
          "rowStart": 12,
          "rowEnd": 16
        },
        "columns": {
          "date": {
            "col": 4,
            "len": 10,
            "type": "date"
          },
          "reference": {
            "col": 16,
            "len": 8,
            "type": "string"
          },
          "value": {
            "col": 37,
            "len": 8,
            "type": "money"
          }
        },
        "record": {
          "startWhen": {
            "column": "value",
            "nonBlank": true
          }
        }
      }
    }
  },
  "validate": {
    "onFailure": "warn",
    "required": [
      "accountNumber",
      "statementDate",
      "totalDue"
    ],
    "checks": [
      {
        "id": "transactions.value adds up to totalDue",
        "expr": "sum(transactions[].value) == totalDue"
      },
      {
        "id": "transactions is never empty",
        "expr": "count(transactions[]) >= 1"
      }
    ]
  }
}
