{
  "$schema": "../cases.schema.json",
  "format": 1,
  "domain": "cstIbsCbs",
  "title": {
    "en": "CST IBS/CBS",
    "pt-BR": "CST IBS/CBS"
  },
  "functions": [
    {
      "id": "cstIbsCbs.get",
      "level": "extended",
      "summary": "Looks up a CST-IBS/CBS code in the official table.",
      "description": "Looks up a CST-IBS/CBS code in the official table and returns its code and description.\n\n- Same input rules as `cstIbsCbs.isValid`. Returns `null` exactly when that function returns `false`.\n- The returned code has 3 digits, padded with zeros. The description is the text of the CST sheet of the official table.",
      "params": [
        {
          "name": "value",
          "type": "string | number"
        }
      ],
      "returns": "CstIbsCbs?",
      "cases": [
        {
          "id": "cstIbsCbs.get#[410]",
          "args": [
            410
          ],
          "expect": {
            "returns": {
              "code": "410",
              "description": "Imunidade e não incidência"
            }
          },
          "note": "from the maintainer briefing, #566"
        },
        {
          "id": "cstIbsCbs.get#[\"000\"]",
          "args": [
            "000"
          ],
          "expect": {
            "returns": {
              "code": "000",
              "description": "Tributação integral"
            }
          },
          "note": "JavaScript's own test: should return the entry of a known code"
        },
        {
          "id": "cstIbsCbs.get#[620]",
          "args": [
            620
          ],
          "expect": {
            "returns": {
              "code": "620",
              "description": "Tributação monofásica"
            }
          },
          "note": "JavaScript's own test: should return the entry of a known code"
        },
        {
          "id": "cstIbsCbs.get#[\"200\"]",
          "args": [
            "200"
          ],
          "expect": {
            "returns": {
              "code": "200",
              "description": "Alíquota reduzida"
            }
          },
          "note": "JavaScript's own test: should take the description from the CST sheet, not the per classification wording of the cClassTrib sheet"
        },
        {
          "id": "cstIbsCbs.get#[\"011\"]",
          "args": [
            "011"
          ],
          "expect": {
            "returns": {
              "code": "011",
              "description": "Tributação com alíquotas uniformes reduzidas"
            }
          },
          "note": "JavaScript's own test: should take the description from the CST sheet, not the per classification wording of the cClassTrib sheet"
        },
        {
          "id": "cstIbsCbs.get#[\"820\"]",
          "args": [
            "820"
          ],
          "expect": {
            "returns": {
              "code": "820",
              "description": "Tributação em documento específico"
            }
          },
          "note": "JavaScript's own test: should carry the wording Informe Técnico 2025.002 v.1.40 gave CST 820"
        },
        {
          "id": "cstIbsCbs.get#[\"222\"]",
          "args": [
            "222"
          ],
          "expect": {
            "returns": {
              "code": "222",
              "description": "Redução de base de cálculo"
            }
          },
          "note": "JavaScript's own test: should carry the codes later versions of the table added (222, 515 and 811)"
        },
        {
          "id": "cstIbsCbs.get#[\"515\"]",
          "args": [
            "515"
          ],
          "expect": {
            "returns": {
              "code": "515",
              "description": "Diferimento com redução de alíquota"
            }
          },
          "note": "JavaScript's own test: should carry the codes later versions of the table added (222, 515 and 811)"
        },
        {
          "id": "cstIbsCbs.get#[\"811\"]",
          "args": [
            "811"
          ],
          "expect": {
            "returns": {
              "code": "811",
              "description": "Ajustes"
            }
          },
          "note": "JavaScript's own test: should carry the codes later versions of the table added (222, 515 and 811)"
        },
        {
          "id": "cstIbsCbs.get#[10]",
          "args": [
            10
          ],
          "expect": {
            "returns": {
              "code": "010",
              "description": "Tributação com alíquotas uniformes"
            }
          },
          "note": "JavaScript's own test: should pad a value with leading zeros, as a number or as a string"
        },
        {
          "id": "cstIbsCbs.get#[\"10\"]",
          "args": [
            "10"
          ],
          "expect": {
            "returns": {
              "code": "010",
              "description": "Tributação com alíquotas uniformes"
            }
          },
          "note": "JavaScript's own test: should pad a value with leading zeros, as a number or as a string"
        },
        {
          "id": "cstIbsCbs.get#[\" 010 \"]",
          "args": [
            " 010 "
          ],
          "expect": {
            "returns": {
              "code": "010",
              "description": "Tributação com alíquotas uniformes"
            }
          },
          "note": "JavaScript's own test: should pad a value with leading zeros, as a number or as a string"
        },
        {
          "id": "cstIbsCbs.get#[0]",
          "args": [
            0
          ],
          "expect": {
            "returns": {
              "code": "000",
              "description": "Tributação integral"
            }
          },
          "note": "JavaScript's own test: should pad a value with leading zeros, as a number or as a string"
        },
        {
          "id": "cstIbsCbs.get#[\"100\"]",
          "args": [
            "100"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a code the table does not carry"
        },
        {
          "id": "cstIbsCbs.get#[\"060\"]",
          "args": [
            "060"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a code the table does not carry"
        },
        {
          "id": "cstIbsCbs.get#[\"0000\"]",
          "args": [
            "0000"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a code the table does not carry"
        },
        {
          "id": "cstIbsCbs.get#[\"200001\"]",
          "args": [
            "200001"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a code the table does not carry"
        },
        {
          "id": "cstIbsCbs.get#[\"cst200\"]",
          "args": [
            "cst200"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a string that is not bare digits"
        },
        {
          "id": "cstIbsCbs.get#[\"2-00\"]",
          "args": [
            "2-00"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a string that is not bare digits"
        },
        {
          "id": "cstIbsCbs.get#empty",
          "args": [
            ""
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a string that is not bare digits"
        },
        {
          "id": "cstIbsCbs.get#[\"__proto__\"]",
          "args": [
            "__proto__"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a string that is not bare digits"
        },
        {
          "id": "cstIbsCbs.get#[-200]",
          "args": [
            -200
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a number that is not a non-negative safe integer"
        },
        {
          "id": "cstIbsCbs.get#[20.5]",
          "args": [
            20.5
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a number that is not a non-negative safe integer"
        }
      ]
    },
    {
      "id": "cstIbsCbs.isValid",
      "level": "extended",
      "summary": "Checks whether a CST-IBS/CBS code exists in the official table.",
      "description": "Checks whether a CST-IBS/CBS code (Código de Situação Tributária of the IBS and the CBS) exists in the official table. It is the code the `CST` field of the `IBSCBS` group carries in the electronic fiscal documents of the tax reform (NF-e, NFC-e, CT-e, NFS-e and others), and the check behind NF-e rejection 1020.\n\n- Accepts a string of bare digits, with optional surrounding whitespace, or a non-negative safe integer. A value shorter than 3 digits is left-padded with zeros, as a string or as a number, since the codes start with zeros a numeric field drops: `0`, `\"0\"` and `\"000\"` are all the code `000`, and `10` and `\"10\"` are `010`.\n- Any other string is rejected (`\"cst200\"`, `\"2.00\"`). The function does not extract its digits. A negative or fractional number is invalid.\n- The table published on 2026-06-23 has 18 codes: 000, 010, 011, 200, 220, 221, 222, 400, 410, 510, 515, 550, 620, 800, 810, 811, 820 and 830. CST 220 stays valid, although its classifications were excluded (see `classTrib.isValid`).\n- The IBS and the CBS share this table. It is separate from `cst.isValid` because its 3-digit codes collide with the ICMS CST, and `cst.isValid` without a `tax` accepts a code of any table, so adding these codes would change what that default accepts.",
      "params": [
        {
          "name": "value",
          "type": "string | number"
        }
      ],
      "returns": "boolean",
      "cases": [
        {
          "id": "cstIbsCbs.isValid#[10]",
          "args": [
            10
          ],
          "expect": {
            "returns": true
          },
          "note": "from the maintainer briefing, #566"
        },
        {
          "id": "cstIbsCbs.isValid#[\"000\"]",
          "args": [
            "000"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate the 18 codes of the CST table published on 23/06/2026"
        },
        {
          "id": "cstIbsCbs.isValid#[\"410\"]",
          "args": [
            "410"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate the 18 codes of the CST table published on 23/06/2026"
        },
        {
          "id": "cstIbsCbs.isValid#[\"830\"]",
          "args": [
            "830"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate the 18 codes of the CST table published on 23/06/2026"
        },
        {
          "id": "cstIbsCbs.isValid#[200]",
          "args": [
            200
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate a code given as a number"
        },
        {
          "id": "cstIbsCbs.isValid#[0]",
          "args": [
            0
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should pad a value with leading zeros, as a number or as a string"
        },
        {
          "id": "cstIbsCbs.isValid#[\"0\"]",
          "args": [
            "0"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should pad a value with leading zeros, as a number or as a string"
        },
        {
          "id": "cstIbsCbs.isValid#[\"11\"]",
          "args": [
            "11"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should pad a value with leading zeros, as a number or as a string"
        },
        {
          "id": "cstIbsCbs.isValid#[\" 410 \"]",
          "args": [
            " 410 "
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate a code with surrounding whitespace"
        },
        {
          "id": "cstIbsCbs.isValid#[\"220\"]",
          "args": [
            "220"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should keep CST 220 valid, which the CST table still lists after its classifications were excluded"
        },
        {
          "id": "cstIbsCbs.isValid#[\"100\"]",
          "args": [
            "100"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a 3 digit code the table does not carry"
        },
        {
          "id": "cstIbsCbs.isValid#[\"999\"]",
          "args": [
            "999"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a 3 digit code the table does not carry"
        },
        {
          "id": "cstIbsCbs.isValid#[20]",
          "args": [
            20
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a 3 digit code the table does not carry"
        },
        {
          "id": "cstIbsCbs.isValid#[\"060\"]",
          "args": [
            "060"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for an ICMS, IPI, PIS or COFINS CST"
        },
        {
          "id": "cstIbsCbs.isValid#[\"49\"]",
          "args": [
            "49"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for an ICMS, IPI, PIS or COFINS CST"
        },
        {
          "id": "cstIbsCbs.isValid#[\"0000\"]",
          "args": [
            "0000"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a wider value, a cClassTrib included"
        },
        {
          "id": "cstIbsCbs.isValid#[\"200001\"]",
          "args": [
            "200001"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a wider value, a cClassTrib included"
        },
        {
          "id": "cstIbsCbs.isValid#[\"cst200\"]",
          "args": [
            "cst200"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a string that is not bare digits"
        },
        {
          "id": "cstIbsCbs.isValid#[\"2.00\"]",
          "args": [
            "2.00"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a string that is not bare digits"
        },
        {
          "id": "cstIbsCbs.isValid#[\"200\\n1\"]",
          "args": [
            "200\n1"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a string that is not bare digits"
        },
        {
          "id": "cstIbsCbs.isValid#empty",
          "args": [
            ""
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a string that is not bare digits"
        },
        {
          "id": "cstIbsCbs.isValid#whitespace",
          "args": [
            "   "
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a string that is not bare digits"
        },
        {
          "id": "cstIbsCbs.isValid#[-200]",
          "args": [
            -200
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a number that is not a non-negative safe integer"
        },
        {
          "id": "cstIbsCbs.isValid#[20.5]",
          "args": [
            20.5
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a number that is not a non-negative safe integer"
        },
        {
          "id": "cstIbsCbs.isValid#[\"constructor\"]",
          "args": [
            "constructor"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for a key of the prototype chain"
        }
      ]
    }
  ]
}
