{
  "$schema": "../cases.schema.json",
  "format": 1,
  "domain": "classTrib",
  "title": {
    "en": "cClassTrib",
    "pt-BR": "cClassTrib"
  },
  "functions": [
    {
      "id": "classTrib.get",
      "level": "extended",
      "summary": "Looks up a cClassTrib code in the official table.",
      "description": "Looks up a cClassTrib code in the official table and returns its code, its CST-IBS/CBS, its name and its description.\n\n- Same input rules as `classTrib.isValid` without `options.cst`. Returns `null` exactly when `classTrib.isValid` called without `options.cst` returns `false`.\n- `cst` is the first 3 digits of the code: every classification belongs to one CST.\n- `name` is the short name the official table gives for display (the column \"Nome cClassTrib\") and `description` the situation the classification refers to (the column \"Descrição cClassTrib\"), both copied word for word from the official spreadsheet, on one line. The legal wording of the spreadsheet (article of Lei Complementar 214/2025 and of the regulations) is not returned.\n- The SVRS online table (Portal dos Documentos Fiscais Eletrônicos) differs from the official workbook in 5 names and 7 descriptions; the differences for 550017 and 200041 change the meaning. The function follows the workbook.",
      "params": [
        {
          "name": "value",
          "type": "string | number"
        }
      ],
      "returns": "ClassTrib?",
      "cases": [
        {
          "id": "classTrib.get#[\"000002\"]",
          "args": [
            "000002"
          ],
          "expect": {
            "returns": {
              "code": "000002",
              "cst": "000",
              "name": "Exploração de via",
              "description": "Exploração de via, observado o art. 11 da Lei Complementar nº 214, de 2025."
            }
          },
          "note": "from the maintainer briefing, #566"
        },
        {
          "id": "classTrib.get#[\"410999\"]",
          "args": [
            "410999"
          ],
          "expect": {
            "returns": {
              "code": "410999",
              "cst": "410",
              "name": "Operações não onerosas sem previsão de tributação, não especificadas anteriormente",
              "description": "Operações não onerosas sem previsão de tributação, não especificadas anteriormente, observado o art. 4º da Lei Complementar nº 214, de 2025."
            }
          },
          "note": "JavaScript's own test: should return the entry of a known code, with its CST, its name and its description"
        },
        {
          "id": "classTrib.get#[811001]",
          "args": [
            811001
          ],
          "expect": {
            "returns": {
              "code": "811001",
              "cst": "811",
              "name": "Anulação de Crédito por Saídas Imunes/Isentas",
              "description": "Anulação de crédito proporcional ao valor das operações imunes e isentas, observado o art. 51 da Lei Complementar nº 214, de 2025."
            }
          },
          "note": "JavaScript's own test: should return the entry of a code given as a number"
        },
        {
          "id": "classTrib.get#[1]",
          "args": [
            1
          ],
          "expect": {
            "returns": {
              "code": "000001",
              "cst": "000",
              "name": "Situações tributadas integralmente pelo IBS e CBS.",
              "description": "Situações tributadas integralmente pelo IBS e CBS."
            }
          },
          "note": "JavaScript's own test: should pad a value with leading zeros, as a number or as a string"
        },
        {
          "id": "classTrib.get#[\"1\"]",
          "args": [
            "1"
          ],
          "expect": {
            "returns": {
              "code": "000001",
              "cst": "000",
              "name": "Situações tributadas integralmente pelo IBS e CBS.",
              "description": "Situações tributadas integralmente pelo IBS e CBS."
            }
          },
          "note": "JavaScript's own test: should pad a value with leading zeros, as a number or as a string"
        },
        {
          "id": "classTrib.get#[\" 000001 \"]",
          "args": [
            " 000001 "
          ],
          "expect": {
            "returns": {
              "code": "000001",
              "cst": "000",
              "name": "Situações tributadas integralmente pelo IBS e CBS.",
              "description": "Situações tributadas integralmente pelo IBS e CBS."
            }
          },
          "note": "JavaScript's own test: should pad a value with leading zeros, as a number or as a string"
        },
        {
          "id": "classTrib.get#[10002]",
          "args": [
            10002
          ],
          "expect": {
            "returns": {
              "code": "010002",
              "cst": "010",
              "name": "Operações do serviço financeiro",
              "description": "Operações do serviço financeiro"
            }
          },
          "note": "JavaScript's own test: should pad a value with leading zeros, as a number or as a string"
        },
        {
          "id": "classTrib.get#[\"620007\"]",
          "args": [
            "620007"
          ],
          "expect": {
            "returns": {
              "code": "620007",
              "cst": "620",
              "name": "Perecimento, deteriorização, roubo, furto ou extravio no regime monofásico",
              "description": "Perecimento, deteriorização, roubo, furto ou extravio no regime monofásico sem estorno de crédito, observado o art. 47 da Lei Complementar nº 214, de 2025."
            }
          },
          "note": "JavaScript's own test: should carry a code Informe Técnico 2025.002 v.1.60 created (620007)"
        },
        {
          "id": "classTrib.get#[\"830001\"]",
          "args": [
            "830001"
          ],
          "expect": {
            "returns": {
              "code": "830001",
              "cst": "830",
              "name": "Documento com exclusão da BC da CBS e do IBS de energia elétrica fornecida pela distribuidora à UC",
              "description": "Documento com exclusão da base de cálculo da CBS e do IBS refrente à energia elétrica fornecida pela distribuidora à unidade consumidora, conforme Art 28, parágrafos 3° e 4°."
            }
          },
          "note": "JavaScript's own test: should keep the workbook text on one line, without the line breaks of its cells"
        },
        {
          "id": "classTrib.get#[\"220001\"]",
          "args": [
            "220001"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for the classifications of CST 220 Informe Técnico 2025.002 v.1.60 excluded"
        },
        {
          "id": "classTrib.get#[\"220002\"]",
          "args": [
            "220002"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for the classifications of CST 220 Informe Técnico 2025.002 v.1.60 excluded"
        },
        {
          "id": "classTrib.get#[\"220003\"]",
          "args": [
            "220003"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for the classifications of CST 220 Informe Técnico 2025.002 v.1.60 excluded"
        },
        {
          "id": "classTrib.get#[\"999999\"]",
          "args": [
            "999999"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a code the table does not carry"
        },
        {
          "id": "classTrib.get#[\"000000\"]",
          "args": [
            "000000"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a code the table does not carry"
        },
        {
          "id": "classTrib.get#[\"2000010\"]",
          "args": [
            "2000010"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a code the table does not carry"
        },
        {
          "id": "classTrib.get#[\"200\"]",
          "args": [
            "200"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a code the table does not carry"
        },
        {
          "id": "classTrib.get#[\"c200001\"]",
          "args": [
            "c200001"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a string that is not bare digits"
        },
        {
          "id": "classTrib.get#[\"200.001\"]",
          "args": [
            "200.001"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a string that is not bare digits"
        },
        {
          "id": "classTrib.get#empty",
          "args": [
            ""
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a string that is not bare digits"
        },
        {
          "id": "classTrib.get#[\"__proto__\"]",
          "args": [
            "__proto__"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a string that is not bare digits"
        },
        {
          "id": "classTrib.get#[-200001]",
          "args": [
            -200001
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a number that is not a non-negative safe integer"
        },
        {
          "id": "classTrib.get#[200001.5]",
          "args": [
            200001.5
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a number that is not a non-negative safe integer"
        }
      ]
    },
    {
      "id": "classTrib.isValid",
      "level": "extended",
      "summary": "Checks whether a cClassTrib code exists in the official table, optionally together with its CST-IBS/CBS.",
      "description": "Checks whether a cClassTrib code (Código de Classificação Tributária of the IBS and the CBS) exists in the official table. This is the check behind NF-e rejection 1023.\n\n- Accepts a string of bare digits, with optional surrounding whitespace, or a safe non-negative integer. A value shorter than 6 digits is left-padded with zeros: `1` and `\"1\"` are the code `000001`.\n- Any other string is rejected (`\"c200001\"`, `\"200.001\"`). A negative, fractional or unsafe number is invalid.\n- The first 3 digits of a cClassTrib are its CST-IBS/CBS. `options.cst` checks the pair, as NF-e rejection 1024 does. It is read like `cstIbsCbs.isValid` reads a code. A `cst` that is given and does not match makes the result false, whatever its value.\n- `options.cst` is optional. An `undefined` or omitted `cst` checks the cClassTrib alone. A `cst` that is `null`, empty or not written as a code (`\"\"`, `\"200001\"`, `-200`) makes the result false. It is padded to 3 digits (`0` and `\"000\"` are the same CST).\n- A `null` or non-object `options` is read as no options, so the cClassTrib is checked alone.\n- Only the classifications in force in the table count: one the Informe Técnico excluded by closing its validity (`dFimVig`) is not in it. 220001, 220002 and 220003 (excluded by v.1.60) are invalid. CST 220 itself stays valid in `cstIbsCbs.isValid`.\n- The table is the version published on 2026-06-23 and has 161 classifications in force. The function does not read the date: the validity was applied when the table was built.",
      "params": [
        {
          "name": "value",
          "type": "string | number"
        },
        {
          "name": "options",
          "type": "IsValidClassTribOptions",
          "optional": true
        }
      ],
      "returns": "boolean",
      "cases": [
        {
          "id": "classTrib.isValid#[\"200001\",{\"cst\":\"000\"}]",
          "args": [
            "200001",
            {
              "cst": "000"
            }
          ],
          "expect": {
            "returns": false
          },
          "note": "from the maintainer briefing, #566"
        },
        {
          "id": "classTrib.isValid#[\"220001\"]",
          "args": [
            "220001"
          ],
          "expect": {
            "returns": false
          },
          "note": "from the maintainer briefing, #566"
        },
        {
          "id": "classTrib.isValid#[\"000001\"]",
          "args": [
            "000001"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate a known code, the first and the last of the table included"
        },
        {
          "id": "classTrib.isValid#[\"200001\"]",
          "args": [
            "200001"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate a known code, the first and the last of the table included"
        },
        {
          "id": "classTrib.isValid#[\"410999\"]",
          "args": [
            "410999"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate a known code, the first and the last of the table included"
        },
        {
          "id": "classTrib.isValid#[\"830001\"]",
          "args": [
            "830001"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate a known code, the first and the last of the table included"
        },
        {
          "id": "classTrib.isValid#[200001]",
          "args": [
            200001
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate a code given as a number"
        },
        {
          "id": "classTrib.isValid#[1]",
          "args": [
            1
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should pad a value with leading zeros, as a number or as a string"
        },
        {
          "id": "classTrib.isValid#[\"11001\"]",
          "args": [
            "11001"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should pad a value with leading zeros, as a number or as a string"
        },
        {
          "id": "classTrib.isValid#[\" 200001 \"]",
          "args": [
            " 200001 "
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate a code with surrounding whitespace"
        },
        {
          "id": "classTrib.isValid#[\"221004\"]",
          "args": [
            "221004"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate the codes Informe Técnico 2025.002 v.1.50 and v.1.60 created"
        },
        {
          "id": "classTrib.isValid#[\"220003\"]",
          "args": [
            "220003"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject the classifications of CST 220 Informe Técnico 2025.002 v.1.60 excluded"
        },
        {
          "id": "classTrib.isValid#[\"999999\"]",
          "args": [
            "999999"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a 6 digit code the table does not carry"
        },
        {
          "id": "classTrib.isValid#[0]",
          "args": [
            0
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a 6 digit code the table does not carry"
        },
        {
          "id": "classTrib.isValid#[\"0200001\"]",
          "args": [
            "0200001"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a value wider than 6 digits and for a CST alone"
        },
        {
          "id": "classTrib.isValid#[\"200\"]",
          "args": [
            "200"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a value wider than 6 digits and for a CST alone"
        },
        {
          "id": "classTrib.isValid#[\"c200001\"]",
          "args": [
            "c200001"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a string that is not bare digits"
        },
        {
          "id": "classTrib.isValid#[\"200 001\"]",
          "args": [
            "200 001"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a string that is not bare digits"
        },
        {
          "id": "classTrib.isValid#empty",
          "args": [
            ""
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a string that is not bare digits"
        },
        {
          "id": "classTrib.isValid#[-200001]",
          "args": [
            -200001
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a number that is not a non-negative safe integer"
        },
        {
          "id": "classTrib.isValid#[200001.5]",
          "args": [
            200001.5
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a number that is not a non-negative safe integer"
        },
        {
          "id": "classTrib.isValid#[\"200001\",{\"cst\":\"200\"}]",
          "args": [
            "200001",
            {
              "cst": "200"
            }
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should accept a classification together with the CST it belongs to"
        },
        {
          "id": "classTrib.isValid#[\"410999\",{\"cst\":410}]",
          "args": [
            "410999",
            {
              "cst": 410
            }
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should accept a classification together with the CST it belongs to"
        },
        {
          "id": "classTrib.isValid#[\"620007\",{\"cst\":\" 620 \"}]",
          "args": [
            "620007",
            {
              "cst": " 620 "
            }
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should accept a classification together with the CST it belongs to"
        },
        {
          "id": "classTrib.isValid#[1,{\"cst\":0}]",
          "args": [
            1,
            {
              "cst": 0
            }
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should pad the CST the way the code is padded"
        },
        {
          "id": "classTrib.isValid#[\"011001\",{\"cst\":\"11\"}]",
          "args": [
            "011001",
            {
              "cst": "11"
            }
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should pad the CST the way the code is padded"
        },
        {
          "id": "classTrib.isValid#[\"010001\",{\"cst\":\"011\"}]",
          "args": [
            "010001",
            {
              "cst": "011"
            }
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject a classification together with another CST (rejection 1024)"
        },
        {
          "id": "classTrib.isValid#[\"220001\",{\"cst\":\"220\"}]",
          "args": [
            "220001",
            {
              "cst": "220"
            }
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject an unknown classification even when its first digits are the CST"
        },
        {
          "id": "classTrib.isValid#[\"200001\",{\"cst\":\"\"}]",
          "args": [
            "200001",
            {
              "cst": ""
            }
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject a CST that is not written as a code"
        },
        {
          "id": "classTrib.isValid#[\"200001\",{\"cst\":\"200001\"}]",
          "args": [
            "200001",
            {
              "cst": "200001"
            }
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject a CST that is not written as a code"
        },
        {
          "id": "classTrib.isValid#[\"200001\",{\"cst\":-200}]",
          "args": [
            "200001",
            {
              "cst": -200
            }
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject a CST that is not written as a code"
        },
        {
          "id": "classTrib.isValid#[\"200001\",{}]",
          "args": [
            "200001",
            {}
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should check the cClassTrib alone when the CST is omitted"
        },
        {
          "id": "classTrib.isValid#[\"999999\",{}]",
          "args": [
            "999999",
            {}
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should check the cClassTrib alone when the CST is omitted"
        },
        {
          "id": "classTrib.isValid#[\"200001\",null]",
          "args": [
            "200001",
            null
          ],
          "expect": {
            "returns": true
          },
          "note": "a null options is read as none. JavaScript's own test: should read null or a non-object options value as none, checking the cClassTrib alone"
        },
        {
          "id": "classTrib.isValid#[\"999999\",null]",
          "args": [
            "999999",
            null
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should read null or a non-object options value as none, checking the cClassTrib alone"
        },
        {
          "id": "classTrib.isValid#[\"200001\",\"foo\"]",
          "args": [
            "200001",
            "foo"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should read null or a non-object options value as none, checking the cClassTrib alone"
        },
        {
          "id": "classTrib.isValid#[\"200001\",{\"cst\":null}]",
          "args": [
            "200001",
            {
              "cst": null
            }
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject a CST that is not a string or a number"
        }
      ]
    }
  ]
}
