{
  "$defs": {
    "CategoryTotal": {
      "description": "CategoryTotal groups together all rates inside a given category.",
      "properties": {
        "amount": {
          "$ref": "https://gobl.org/draft-0/num/amount",
          "title": "Amount"
        },
        "code": {
          "$ref": "https://gobl.org/draft-0/cbc/code",
          "title": "Code"
        },
        "rates": {
          "items": {
            "$ref": "#/$defs/RateTotal"
          },
          "title": "Rates",
          "type": "array"
        },
        "retained": {
          "title": "Retained",
          "type": "boolean"
        },
        "surcharge": {
          "$ref": "https://gobl.org/draft-0/num/amount",
          "title": "Surcharge"
        }
      },
      "required": [
        "code",
        "rates",
        "amount"
      ],
      "type": "object"
    },
    "RateTotal": {
      "description": "RateTotal contains a sum of all the tax rates in the document with a matching category and rate.",
      "properties": {
        "amount": {
          "$ref": "https://gobl.org/draft-0/num/amount",
          "description": "Total amount of rate, excluding surcharges",
          "title": "Amount"
        },
        "base": {
          "$ref": "https://gobl.org/draft-0/num/amount",
          "description": "Base amount that the percentage is applied to.",
          "title": "Base"
        },
        "ext": {
          "$ref": "https://gobl.org/draft-0/tax/extensions",
          "description": "If the rate is defined with extensions, they'll be used to group by also.",
          "title": "Ext"
        },
        "key": {
          "$ref": "https://gobl.org/draft-0/cbc/key",
          "description": "Optional rate key is required when grouping.",
          "title": "Key"
        },
        "percent": {
          "$ref": "https://gobl.org/draft-0/num/percentage",
          "description": "Percentage of the rate, which may be nil for exempt rates.",
          "title": "Percent"
        },
        "surcharge": {
          "$ref": "#/$defs/RateTotalSurcharge",
          "description": "Surcharge applied to the rate.",
          "title": "Surcharge"
        }
      },
      "required": [
        "base",
        "amount"
      ],
      "type": "object"
    },
    "RateTotalSurcharge": {
      "description": "RateTotalSurcharge reflects the sum surcharges inside the rate.",
      "properties": {
        "amount": {
          "$ref": "https://gobl.org/draft-0/num/amount",
          "title": "Amount"
        },
        "percent": {
          "$ref": "https://gobl.org/draft-0/num/percentage",
          "title": "Percent"
        }
      },
      "required": [
        "percent",
        "amount"
      ],
      "type": "object"
    },
    "Total": {
      "description": "Total contains a set of Category Totals which in turn contain all the accumulated taxes contained in the document.",
      "properties": {
        "categories": {
          "description": "Grouping of all the taxes by their category",
          "items": {
            "$ref": "#/$defs/CategoryTotal"
          },
          "title": "Categories",
          "type": "array"
        },
        "sum": {
          "$ref": "https://gobl.org/draft-0/num/amount",
          "description": "Total value of all the taxes applied.",
          "title": "Sum"
        }
      },
      "required": [
        "sum"
      ],
      "type": "object"
    }
  },
  "$id": "https://gobl.org/draft-0/tax/total",
  "$ref": "#/$defs/Total",
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}