{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "enum": [
        "form138_workbook"
      ]
    },
    "@entity": {
      "type": "string",
      "enum": [
        "workbook"
      ]
    },
    "sheets": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "enum": [
                  "payer_sheet"
                ]
              },
              "@entity": {
                "type": "string",
                "enum": [
                  "sheet"
                ]
              },
              "blocks": {
                "type": "array",
                "items": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "enum": [
                            "payer_list"
                          ]
                        },
                        "@entity": {
                          "type": "string",
                          "enum": [
                            "list"
                          ]
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string",
                                "pattern": "^(?=.*[A-Za-z0-9])(?!.*\\^)[\\x20-\\x7E]{1,75}$",
                                "minLength": 1,
                                "maxLength": 75
                              },
                              "tan": {
                                "type": "string"
                              },
                              "pan": {
                                "type": "string"
                              },
                              "country": {
                                "type": "string"
                              },
                              "flat_door_block_number": {
                                "type": "string"
                              },
                              "post_office": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "road_street_block_sector": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "area_locality": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "district": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "state": {
                                "type": "string"
                              },
                              "postal_code": {
                                "type": "string"
                              },
                              "email": {
                                "type": "string"
                              },
                              "contact_country_code": {
                                "type": "string"
                              },
                              "contact_number": {
                                "type": "string"
                              },
                              "deductor_type": {
                                "type": "string"
                              },
                              "government_state_code": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "ministry_code": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "ministry_name_other": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "account_office_identification_number": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "gstin": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            },
                            "additionalProperties": true
                          }
                        }
                      },
                      "required": [
                        "name",
                        "@entity",
                        "items"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "enum": [
                            "responsible_person_list"
                          ]
                        },
                        "@entity": {
                          "type": "string",
                          "enum": [
                            "list"
                          ]
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "designation": {
                                "type": "string"
                              },
                              "pan": {
                                "type": "string"
                              },
                              "flat_door_block_number": {
                                "type": "string"
                              },
                              "post_office": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "road_street_block_sector": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "area_locality": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "district": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "state": {
                                "type": "string"
                              },
                              "postal_code": {
                                "type": "string"
                              },
                              "email": {
                                "type": "string"
                              },
                              "country": {
                                "type": "string"
                              },
                              "contact_country_code": {
                                "type": "string"
                              },
                              "contact_number": {
                                "type": "string"
                              }
                            },
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "name",
                        "@entity",
                        "items"
                      ]
                    }
                  ]
                }
              }
            },
            "required": [
              "name",
              "@entity",
              "blocks"
            ]
          },
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "enum": [
                  "payee_sheet"
                ]
              },
              "@entity": {
                "type": "string",
                "enum": [
                  "sheet"
                ]
              },
              "blocks": {
                "type": "array",
                "items": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "enum": [
                            "payee_table"
                          ]
                        },
                        "@entity": {
                          "type": "string",
                          "enum": [
                            "table"
                          ]
                        },
                        "header": {
                          "type": "array",
                          "items": [
                            {
                              "type": "string",
                              "enum": [
                                "sr_no"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "pan"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "name"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "is_pan_operative"
                              ]
                            }
                          ],
                          "additionalItems": false,
                          "minItems": 4,
                          "maxItems": 4
                        },
                        "rows": {
                          "type": "array",
                          "items": {
                            "type": "array",
                            "items": [
                              {
                                "type": "integer",
                                "format": "Long"
                              },
                              {
                                "type": "string",
                                "pattern": "^(?:[A-Z]{3}[PCFTGHLABJ][A-Z][0-9]{4}[A-Z]|PANNOTAVBL|PANAPPLIED|PANINVALID)$",
                                "minLength": 10,
                                "maxLength": 10
                              },
                              {
                                "type": "string",
                                "pattern": "^(?!.*\\^)[\\x20-\\x7E]{1,75}$",
                                "minLength": 1,
                                "maxLength": 75
                              },
                              {
                                "type": "boolean",
                                "description": "Whether the payee PAN is operative. Required for every row, including false."
                              }
                            ],
                            "additionalItems": false,
                            "minItems": 4,
                            "maxItems": 4
                          }
                        }
                      },
                      "required": [
                        "name",
                        "@entity",
                        "header",
                        "rows"
                      ]
                    }
                  ]
                }
              }
            },
            "required": [
              "name",
              "@entity",
              "blocks"
            ]
          },
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "enum": [
                  "challan_sheet"
                ]
              },
              "@entity": {
                "type": "string",
                "enum": [
                  "sheet"
                ]
              },
              "blocks": {
                "type": "array",
                "items": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "enum": [
                            "challan_table"
                          ]
                        },
                        "@entity": {
                          "type": "string",
                          "enum": [
                            "table"
                          ]
                        },
                        "header": {
                          "type": "array",
                          "items": [
                            {
                              "type": "string",
                              "enum": [
                                "bank_challan_number_or_ddo_serial_number"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "bsr_code_or_form_24g_receipt_number"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "bank_challan_or_transfer_voucher_date_epoch"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "minor_head"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "mode_of_payment"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "nil_challan_indicator"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "total_tax_deducted"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "total_interest"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "total_fee"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "total_penalty"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "total_tax_deposited"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "utilized_amount"
                              ]
                            }
                          ],
                          "additionalItems": false,
                          "minItems": 12,
                          "maxItems": 12
                        },
                        "rows": {
                          "type": "array",
                          "items": {
                            "type": "array",
                            "items": [
                              {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              {
                                "type": "integer",
                                "format": "Long"
                              },
                              {
                                "type": "string"
                              },
                              {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              {
                                "type": "string"
                              },
                              {
                                "type": "number",
                                "format": "BigDecimal"
                              },
                              {
                                "type": "number",
                                "format": "BigDecimal"
                              },
                              {
                                "type": "number",
                                "format": "BigDecimal"
                              },
                              {
                                "type": "number",
                                "format": "BigDecimal"
                              },
                              {
                                "type": "number",
                                "format": "BigDecimal"
                              },
                              {
                                "type": "number",
                                "format": "BigDecimal",
                                "minimum": 0,
                                "multipleOf": 0.01,
                                "description": "Challan tax already consumed outside this statement. Excludes current payment allocations, interest, fees, and penalty."
                              }
                            ],
                            "additionalItems": false,
                            "minItems": 12,
                            "maxItems": 12
                          }
                        }
                      },
                      "required": [
                        "name",
                        "@entity",
                        "header",
                        "rows"
                      ]
                    }
                  ]
                }
              }
            },
            "required": [
              "name",
              "@entity",
              "blocks"
            ]
          },
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "enum": [
                  "payment_sheet"
                ]
              },
              "@entity": {
                "type": "string",
                "enum": [
                  "sheet"
                ]
              },
              "blocks": {
                "type": "array",
                "items": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "enum": [
                            "payment_table"
                          ]
                        },
                        "@entity": {
                          "type": "string",
                          "enum": [
                            "table"
                          ]
                        },
                        "header": {
                          "type": "array",
                          "items": [
                            {
                              "type": "string",
                              "enum": [
                                "payee_sr_no"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "bank_challan_number_or_ddo_serial_number"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "bsr_code_or_form_24g_receipt_number"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "nature_of_payment"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "payment_amount"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "payment_date_epoch"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "total_tax_deducted"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "deduction_date_epoch"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "total_tax_deposited"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "deposit_date_epoch"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "reason_for_lower_deduction"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "certificate_number"
                              ]
                            }
                          ],
                          "additionalItems": false,
                          "minItems": 12,
                          "maxItems": 12
                        },
                        "rows": {
                          "type": "array",
                          "items": {
                            "type": "array",
                            "items": [
                              {
                                "type": "integer",
                                "format": "Long"
                              },
                              {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              {
                                "type": "string"
                              },
                              {
                                "type": "number",
                                "maximum": 999999999999.99,
                                "format": "BigDecimal"
                              },
                              {
                                "type": "integer",
                                "description": "Earlier of payment or credit, in epoch milliseconds.",
                                "format": "Long"
                              },
                              {
                                "type": "number",
                                "format": "BigDecimal"
                              },
                              {
                                "type": [
                                  "integer",
                                  "null"
                                ],
                                "format": "Long"
                              },
                              {
                                "type": "number",
                                "format": "BigDecimal"
                              },
                              {
                                "type": [
                                  "integer",
                                  "null"
                                ],
                                "format": "Long"
                              },
                              {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            ],
                            "additionalItems": false,
                            "minItems": 12,
                            "maxItems": 12
                          }
                        }
                      },
                      "required": [
                        "name",
                        "@entity",
                        "header",
                        "rows"
                      ]
                    }
                  ]
                }
              }
            },
            "required": [
              "name",
              "@entity",
              "blocks"
            ]
          }
        ]
      }
    }
  },
  "required": [
    "name",
    "@entity",
    "sheets"
  ]
}
