{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "DeclarationPayload",
  "description": "Payload della POST di invio dichiarazione (specifica v2.2). La regola «mese_fine non precedente a mese_inizio» non è esprimibile in JSON Schema.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "declaration_year",
    "tax_year",
    "tipo_dichiarazione",
    "fiscal_code",
    "quadri"
  ],
  "properties": {
    "declaration_year": {
      "type": "integer",
      "minimum": 1000,
      "maximum": 9999
    },
    "tax_year": {
      "type": "integer",
      "minimum": 1000,
      "maximum": 9999
    },
    "tipo_dichiarazione": {
      "type": "string",
      "enum": [
        "ordinaria",
        "correttiva"
      ]
    },
    "fiscal_code": {
      "type": "string",
      "minLength": 1
    },
    "quadri": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "lm",
        "rs",
        "rr"
      ],
      "properties": {
        "lm": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "lm21_col_3_nuova_attivita",
            "lm22",
            "lm23",
            "lm24",
            "lm25",
            "lm26",
            "lm27",
            "lm35_contributi_contabilita",
            "lm44_eccedenza_compensata_f24",
            "lm45_versato_f24"
          ],
          "properties": {
            "lm21_col_3_nuova_attivita": {
              "type": "boolean"
            },
            "lm22": {
              "anyOf": [
                {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "col_1_codice_attivita",
                    "col_3_componenti_positivi",
                    "col_6_impresa_lavoro_autonomo",
                    "col_7_casi_particolari"
                  ],
                  "properties": {
                    "col_1_codice_attivita": {
                      "type": "string",
                      "minLength": 1
                    },
                    "col_3_componenti_positivi": {
                      "anyOf": [
                        {
                          "type": "string",
                          "pattern": "^\\d+\\.\\d{2}$"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "col_6_impresa_lavoro_autonomo": {
                      "type": "string",
                      "enum": [
                        "2"
                      ]
                    },
                    "col_7_casi_particolari": {
                      "type": "null"
                    }
                  }
                },
                {
                  "type": "null"
                }
              ]
            },
            "lm23": {
              "anyOf": [
                {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "col_1_codice_attivita",
                    "col_3_componenti_positivi",
                    "col_6_impresa_lavoro_autonomo",
                    "col_7_casi_particolari"
                  ],
                  "properties": {
                    "col_1_codice_attivita": {
                      "type": "string",
                      "minLength": 1
                    },
                    "col_3_componenti_positivi": {
                      "anyOf": [
                        {
                          "type": "string",
                          "pattern": "^\\d+\\.\\d{2}$"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "col_6_impresa_lavoro_autonomo": {
                      "type": "string",
                      "enum": [
                        "2"
                      ]
                    },
                    "col_7_casi_particolari": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "1",
                            "2"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                },
                {
                  "type": "null"
                }
              ]
            },
            "lm24": {
              "anyOf": [
                {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "col_1_codice_attivita",
                    "col_3_componenti_positivi",
                    "col_6_impresa_lavoro_autonomo",
                    "col_7_casi_particolari"
                  ],
                  "properties": {
                    "col_1_codice_attivita": {
                      "type": "string",
                      "minLength": 1
                    },
                    "col_3_componenti_positivi": {
                      "anyOf": [
                        {
                          "type": "string",
                          "pattern": "^\\d+\\.\\d{2}$"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "col_6_impresa_lavoro_autonomo": {
                      "type": "string",
                      "enum": [
                        "2"
                      ]
                    },
                    "col_7_casi_particolari": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "1",
                            "2"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                },
                {
                  "type": "null"
                }
              ]
            },
            "lm25": {
              "anyOf": [
                {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "col_1_codice_attivita",
                    "col_3_componenti_positivi",
                    "col_6_impresa_lavoro_autonomo",
                    "col_7_casi_particolari"
                  ],
                  "properties": {
                    "col_1_codice_attivita": {
                      "type": "string",
                      "minLength": 1
                    },
                    "col_3_componenti_positivi": {
                      "anyOf": [
                        {
                          "type": "string",
                          "pattern": "^\\d+\\.\\d{2}$"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "col_6_impresa_lavoro_autonomo": {
                      "type": "string",
                      "enum": [
                        "2"
                      ]
                    },
                    "col_7_casi_particolari": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "1",
                            "2"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                },
                {
                  "type": "null"
                }
              ]
            },
            "lm26": {
              "anyOf": [
                {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "col_1_codice_attivita",
                    "col_3_componenti_positivi",
                    "col_6_impresa_lavoro_autonomo",
                    "col_7_casi_particolari"
                  ],
                  "properties": {
                    "col_1_codice_attivita": {
                      "type": "string",
                      "minLength": 1
                    },
                    "col_3_componenti_positivi": {
                      "anyOf": [
                        {
                          "type": "string",
                          "pattern": "^\\d+\\.\\d{2}$"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "col_6_impresa_lavoro_autonomo": {
                      "type": "string",
                      "enum": [
                        "2"
                      ]
                    },
                    "col_7_casi_particolari": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "1",
                            "2"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                },
                {
                  "type": "null"
                }
              ]
            },
            "lm27": {
              "anyOf": [
                {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "col_1_codice_attivita",
                    "col_3_componenti_positivi",
                    "col_6_impresa_lavoro_autonomo",
                    "col_7_casi_particolari"
                  ],
                  "properties": {
                    "col_1_codice_attivita": {
                      "type": "string",
                      "minLength": 1
                    },
                    "col_3_componenti_positivi": {
                      "anyOf": [
                        {
                          "type": "string",
                          "pattern": "^\\d+\\.\\d{2}$"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "col_6_impresa_lavoro_autonomo": {
                      "type": "string",
                      "enum": [
                        "2"
                      ]
                    },
                    "col_7_casi_particolari": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "1",
                            "2"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                },
                {
                  "type": "null"
                }
              ]
            },
            "lm35_contributi_contabilita": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^\\d+\\.\\d{2}$"
                },
                {
                  "type": "null"
                }
              ]
            },
            "lm44_eccedenza_compensata_f24": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^\\d+\\.\\d{2}$"
                },
                {
                  "type": "null"
                }
              ]
            },
            "lm45_versato_f24": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^\\d+\\.\\d{2}$"
                },
                {
                  "type": "null"
                }
              ]
            }
          }
        },
        "rs": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "rs40_ritenute",
            "rs140_conservazione_documenti",
            "rs381_assenza_dati"
          ],
          "properties": {
            "rs40_ritenute": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^\\d+\\.\\d{2}$"
                },
                {
                  "type": "null"
                }
              ]
            },
            "rs140_conservazione_documenti": {
              "type": "string",
              "enum": [
                "1",
                "2"
              ]
            },
            "rs381_assenza_dati": {
              "type": "boolean"
            }
          }
        },
        "rr": {
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "aliquota",
                "sede_inps",
                "importo",
                "mese_inizio",
                "mese_fine"
              ],
              "properties": {
                "aliquota": {
                  "type": "string",
                  "pattern": "^(0(\\.\\d+)?|1(\\.0+)?)$"
                },
                "sede_inps": {
                  "type": "string",
                  "minLength": 1
                },
                "importo": {
                  "type": "string",
                  "pattern": "^\\d+\\.\\d{2}$"
                },
                "mese_inizio": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 12
                },
                "mese_fine": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 12
                }
              }
            },
            {
              "type": "null"
            }
          ]
        }
      }
    }
  }
}
