{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "schema-processamento-xls",
  "title": "ProcessamentoXls",
  "description": "Resultado canônico do processamento de um arquivo .xlsx de transporte Vantroba. Produzido por Java (ProcessamentoJsonExporter) e por Python (exportar-json.py); os dois artefatos devem ser semanticamente idênticos.\n\nMapeamento das abas:\n  Aba 10 — período: E1 (col 4) = dataInicial ddMMyyyy, F1 (col 5) = dataFinal ddMMyyyy\n  Aba 20 — faturamentos: dados a partir da linha 2 (row index 1); linha 1 = cabeçalho ignorado; colunas AH–AK: tipoFrota, marcaVeiculo, modeloVeiculo, anos (texto AK → anoConstrucao/anoModelo). Atenção: colunas AD–AG (índices 29–32) entre AC e AH NÃO são mapeadas — inserir/remover coluna nessa faixa quebra o mapeamento.\n  Aba 30 — movimentos:   dados a partir da linha 2 (row index 1); linha 1 = cabeçalho ignorado; colunas AB–AE após processo (AA): tipoFrota, marcaVeiculo, modeloVeiculo, anos (texto AE → anoConstrucao/anoModelo)\n\nRegras gerais:\n  - Datas sempre ISO-8601 yyyy-MM-dd (string).\n  - Números sempre JSON number; nunca string, nunca NaN, nunca notação científica.\n  - Strings truncadas conforme maxLength; null quando ausentes/vazias.\n  - Ordem dos registros = ordem das linhas na planilha (linhas filtradas omitidas).",
  "type": "object",
  "required": ["periodo", "faturamentos", "movimentos"],
  "additionalProperties": false,
  "properties": {
    "periodo": {
      "description": "Período de referência do relatório (aba 10, células E1 e F1).",
      "type": "object",
      "required": ["dataInicial", "dataFinal"],
      "additionalProperties": false,
      "properties": {
        "dataInicial": {
          "description": "Data inicial do período. Aba 10, col E (índice 4), formato ddMMyyyy lido como texto.",
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
          "examples": ["2025-07-01"]
        },
        "dataFinal": {
          "description": "Data final do período. Aba 10, col F (índice 5), formato ddMMyyyy lido como texto.",
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
          "examples": ["2025-07-31"]
        }
      }
    },

    "faturamentos": {
      "description": "Registros da aba 20 (FATURAMENTO). Linhas sem dtFrete ou sem valor são descartadas.",
      "type": "array",
      "items": {
        "$ref": "#/definitions/Faturamento"
      }
    },

    "movimentos": {
      "description": "Registros da aba 30 (MOVIMENTO). Linhas sem dataLcto ou sem valor são descartadas.",
      "type": "array",
      "items": {
        "$ref": "#/definitions/Movimento"
      }
    }
  },

  "definitions": {
    "Faturamento": {
      "description": "Linha da aba 20. Mapeamento por índice 0-based: A=0, B=1, C=2, D=3, E=4, F=5, G=6, H=7, I=8, J=9, K=10, L=11, M=12, N=13, O=14, P=15, Q=16, R=17, S=18, T=19, U=20(ignorado), V=21(ignorado), W=22(ignorado? ver abaixo), X=23...",
      "type": "object",
      "required": ["dtFrete", "valor"],
      "additionalProperties": false,
      "properties": {
        "classifCtb":  { "description": "Classificação contábil. Col B (índice 1). maxLength=3.",  "type": ["string", "null"], "maxLength": 3  },
        "identGer":    { "description": "Identificador gerencial. Col C (índice 2). maxLength=2.",  "type": ["string", "null"], "maxLength": 2  },
        "nroFrete":    { "description": "Número do frete. Col D (índice 3). maxLength=6.",           "type": ["string", "null"], "maxLength": 6  },
        "dtFrete":     { "description": "Data do frete (obrigatório). Col E (índice 4). ddMMyyyy → yyyy-MM-dd.", "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
        "nroDocto":    { "description": "Número do documento. Col F (índice 5). maxLength=6.",        "type": ["string", "null"], "maxLength": 6  },
        "serie":       { "description": "Série do documento. Col G (índice 6). maxLength=3.",         "type": ["string", "null"], "maxLength": 3  },
        "dtEm":        { "description": "Data de emissão. Col H (índice 7). ddMMyyyy → yyyy-MM-dd.",  "type": ["string", "null"], "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
        "dbCr":        { "description": "Débito/Crédito. Col I (índice 8). maxLength=1.",             "type": ["string", "null"], "maxLength": 1  },
        "tanque":      { "description": "Tanque. Col J (índice 9). maxLength=1.",                     "type": ["string", "null"], "maxLength": 1  },
        "placa":       { "description": "Placa do veículo. Col K (índice 10). maxLength=10.",         "type": ["string", "null"], "maxLength": 10 },
        "placaComp":   { "description": "Placa complementar. Col L (índice 11). maxLength=10.",       "type": ["string", "null"], "maxLength": 10 },
        "segmento":    { "description": "Segmento. Col M (índice 12). maxLength=3.",                  "type": ["string", "null"], "maxLength": 3  },
        "descSeg":     { "description": "Descrição do segmento. Col N (índice 13). maxLength=30.",    "type": ["string", "null"], "maxLength": 30 },
        "seqProj":     { "description": "Sequência do projeto. Col O (índice 14). maxLength=6.",      "type": ["string", "null"], "maxLength": 6  },
        "codProj":     { "description": "Código do projeto. Col P (índice 15). maxLength=10.",        "type": ["string", "null"], "maxLength": 10 },
        "filial":      { "description": "Filial. Col Q (índice 16). maxLength=2.",                    "type": ["string", "null"], "maxLength": 2  },
        "valor":       { "description": "Valor (obrigatório). Col R (índice 17). Número decimal.",    "type": "number" },
        "fatorFat":    { "description": "Fator de faturamento. Col S (índice 18). Número decimal ou null.", "type": ["number", "null"] },
        "distancia":   { "description": "Distância. Col T (índice 19). Número decimal ou null.",      "type": ["number", "null"] },
        "especVeic":   { "description": "Especificação do veículo. Col U (índice 20). maxLength=10.", "type": ["string", "null"], "maxLength": 10 },
        "munOrig":     { "description": "Município de origem. Col V (índice 21). maxLength=30.",      "type": ["string", "null"], "maxLength": 30 },
        "munDest":     { "description": "Município de destino. Col W (índice 22). maxLength=30.",     "type": ["string", "null"], "maxLength": 30 },
        "codMot":      { "description": "Código do motorista. Col X (índice 23). maxLength=6.",       "type": ["string", "null"], "maxLength": 6  },
        "nomeMot":     { "description": "Nome do motorista. Col Y (índice 24). maxLength=30.",        "type": ["string", "null"], "maxLength": 30 },
        "cpfMot":      { "description": "CPF do motorista. Col Z (índice 25). maxLength=11.",         "type": ["string", "null"], "maxLength": 11 },
        "gestor":      { "description": "Código do gestor. Col AA (índice 26). maxLength=6.",         "type": ["string", "null"], "maxLength": 6  },
        "nomeGestor":  { "description": "Nome do gestor. Col AB (índice 27). maxLength=30.",          "type": ["string", "null"], "maxLength": 30 },
        "descClassif": { "description": "Descrição da classificação. Col AC (índice 28). maxLength=70.", "type": ["string", "null"], "maxLength": 70 },
        "tipoFrota":     { "description": "EMPRESA ou TERCEIROS (frota). Col AH (índice 33). maxLength=20.", "type": ["string", "null"], "maxLength": 20 },
        "marcaVeiculo":  { "description": "Marca do caminhão. Col AI (índice 34). maxLength=80.", "type": ["string", "null"], "maxLength": 80 },
        "modeloVeiculo": { "description": "Modelo do caminhão. Col AJ (índice 35). maxLength=80.", "type": ["string", "null"], "maxLength": 80 },
        "anoConstrucao": { "description": "Ano de construção (4 dígitos), parseado de Col AK (índice 36) texto AAAA/AAAA.", "type": ["integer", "null"], "minimum": 1900, "maximum": 2100 },
        "anoModelo":     { "description": "Ano do modelo (4 dígitos), parseado de Col AK (índice 36) texto AAAA/AAAA.", "type": ["integer", "null"], "minimum": 1900, "maximum": 2100 }
      }
    },

    "Movimento": {
      "description": "Linha da aba 30. Mapeamento por índice 0-based: A=0, B=1, C=2, D=3, E=4, F=5, G=6, H=7, I=8, J=9, K=10, L=11, M=12, N=13, O=14, P=15, Q=16, R=17, S=18, T=19, U=20, V=21. Colunas W–Z (22–25) sem campo mapeado. AA=26.",
      "type": "object",
      "required": ["dataLcto", "valor"],
      "additionalProperties": false,
      "properties": {
        "classifCtb":    { "description": "Classificação contábil. Col B (índice 1). maxLength=3.",       "type": ["string", "null"], "maxLength": 3  },
        "identGer":      { "description": "Identificador gerencial. Col C (índice 2). maxLength=2.",       "type": ["string", "null"], "maxLength": 2  },
        "identCusto":    { "description": "Identificador de custo. Col D (índice 3). maxLength=1.",        "type": ["string", "null"], "maxLength": 1  },
        "atribCusto":    { "description": "Atribuição de custo. Col E (índice 4). maxLength=1.",           "type": ["string", "null"], "maxLength": 1  },
        "identRat":      { "description": "Identificador de rateio. Col F (índice 5). maxLength=1.",       "type": ["string", "null"], "maxLength": 1  },
        "dbCr":          { "description": "Débito/Crédito. Col G (índice 6). maxLength=1.",               "type": ["string", "null"], "maxLength": 1  },
        "tanque":        { "description": "Tanque. Col H (índice 7). maxLength=1.",                       "type": ["string", "null"], "maxLength": 1  },
        "placa":         { "description": "Placa do veículo. Col I (índice 8). maxLength=10.",            "type": ["string", "null"], "maxLength": 10 },
        "placaComp":     { "description": "Placa complementar. Col J (índice 9). maxLength=10.",          "type": ["string", "null"], "maxLength": 10 },
        "segmento":      { "description": "Segmento. Col K (índice 10). maxLength=3.",                    "type": ["string", "null"], "maxLength": 3  },
        "descSeg":       { "description": "Descrição do segmento. Col L (índice 11). maxLength=30.",      "type": ["string", "null"], "maxLength": 30 },
        "seqProj":       { "description": "Sequência do projeto. Col M (índice 12). maxLength=6.",        "type": ["string", "null"], "maxLength": 6  },
        "codProj":       { "description": "Código do projeto. Col N (índice 13). maxLength=10.",          "type": ["string", "null"], "maxLength": 10 },
        "filial":        { "description": "Filial. Col O (índice 14). maxLength=2.",                      "type": ["string", "null"], "maxLength": 2  },
        "valor":         { "description": "Valor (obrigatório). Col P (índice 15). Número decimal.",      "type": "number" },
        "dataLcto":      { "description": "Data de lançamento (obrigatório). Col Q (índice 16). ddMMyyyy → yyyy-MM-dd.", "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
        "especVeic":     { "description": "Especificação do veículo. Col R (índice 17). maxLength=10.",   "type": ["string", "null"], "maxLength": 10 },
        "codConta":      { "description": "Código da conta. Col S (índice 18). maxLength=5.",             "type": ["string", "null"], "maxLength": 5  },
        "classifConta":  { "description": "Classificação da conta. Col T (índice 19). maxLength=18.",     "type": ["string", "null"], "maxLength": 18 },
        "descConta":     { "description": "Descrição da conta. Col U (índice 20). maxLength=70.",         "type": ["string", "null"], "maxLength": 70 },
        "descClassif":   { "description": "Descrição da classificação. Col V (índice 21). maxLength=70.", "type": ["string", "null"], "maxLength": 70 },
        "processo":      { "description": "Processo. Col AA (índice 26). maxLength=6.",                   "type": ["string", "null"], "maxLength": 6  },
        "tipoFrota":     { "description": "EMPRESA ou TERCEIROS (frota). Col AB (índice 27). maxLength=20.", "type": ["string", "null"], "maxLength": 20 },
        "marcaVeiculo":  { "description": "Marca do caminhão. Col AC (índice 28). maxLength=80.", "type": ["string", "null"], "maxLength": 80 },
        "modeloVeiculo": { "description": "Modelo do caminhão. Col AD (índice 29). maxLength=80.", "type": ["string", "null"], "maxLength": 80 },
        "anoConstrucao": { "description": "Ano de construção (4 dígitos), parseado de Col AE (índice 30) texto AAAA/AAAA.", "type": ["integer", "null"], "minimum": 1900, "maximum": 2100 },
        "anoModelo":     { "description": "Ano do modelo (4 dígitos), parseado de Col AE (índice 30) texto AAAA/AAAA.", "type": ["integer", "null"], "minimum": 1900, "maximum": 2100 }
      }
    }
  }
}
