{ "$schema":                        "http://json-schema.org/draft/2020-12/schema",
  "$id":                             "https://schemas.mpai.community/CUI1/V2.0/data/FinancialDescriptors.json",
  "title":                           "Financial Descriptors V2.0",
  "type":                            "object",
  "required":                        [ "oType" ] ,
  "properties":                      {
    "Header":                        {    "type": "string", "pattern": "^CUI-FND-V[0-9],{1,2},[.][0-9],{1,2}$" },
    "MInstanceID":                   {    "type": "string" },
    "UEnvironmentID":                {    "type": "string" },
    "FinancialDescriptorsID":        {    "type": "string" },
    "FinancialDescriptorsTime":      {    "$ref": "https://schemas.mpai.community/OSD/V1.5/data/Time.json" },

    "FinancialDescriptors":          {    "type": "object", "required": [ "AQ" ], "properties": {
      "AQ":                          {    "type": "array", "items": {    "type": "object",
                                          "required": [ "id", "module_id", "poweruser_id", "survey_company_id", "period_start",
                                          "period_end", "input", "simulation", "consolidated", "created_at", "updated_at"  ],
                                          "properties": {
        "id":                        {    "type": "integer" },
        "module_id":                 {    "type": "string" },
        "poweruser_id":              {    "type": "integer" },
        "survey_company_id":         {    "type": "integer" },
        "period_start":              {    "type": "string", "format": "date-time" },
        "period_end":                {    "type": "string", "format": "date-time" },
        "input":                     {    "type": "array", "items": {    "type": "object", "required": [ "code", "type",
                                          "editable", "value", "saves" ], "properties": {
          "code":                   {    "type": "string" },
          "type":                   {    "type": "string", "enum": [ "text", "select", "fixed-row" ] },
          "editable":               {    "type": "boolean" },
          "required":               {    "type": [ "boolean", "null" ] },
          "value":                  {    "type": [ "string", "null" ] },
          "options":                {    "type": [ "array", "null" ], "items": {    "type": "string" } },
          "min":                    {    "type": [ "integer", "null" ] },
          "max":                    {    "type": [ "integer", "null" ] },
          "columns":                {    "type": [ "array", "null" ], "items": {    "type": "object",
                                         "required": [ "type", "code", "required" ], "properties": {
            "type":                 {    "type": "string" },
            "code":                 {    "type": "string" },
            "required":             {    "type": "boolean" } } } },
          "fixedRows":              {    "type": [ "array", "null" ], "items": {    "type": "object", "required": [ "code", "values" ], "properties": {
            "code":                 {    "type": "string" },
            "values":               {    "type": "array", "items": {    "type": "object", "required": [ "code", "value" ], "properties": {
              "code":               {    "type": "string" },
              "value":              {    "type": "string" } } } } } } },
          "saves":                  {    "type": "array", "items": {} },

          "SPAA1": { "type": [ "object","null" ] },
          "SPAA2": { "type": [ "object","null" ] },
          "SPAA3": { "type": [ "object","null" ] },

          "SPABI1": { "type": [ "object","null" ] },
          "SPABI2": { "type": [ "object","null" ] },
          "SPABI3": { "type": [ "object","null" ] },
          "SPABI4": { "type": [ "object","null" ] },
          "SPABI5": { "type": [ "object","null" ] },
          "SPABI6": { "type": [ "object","null" ] },
          "SPABI7": { "type": [ "object","null" ] },

          "SPABII1": { "type": [ "object","null" ] },
          "SPABII2": { "type": [ "object","null" ] },
          "SPABII3": { "type": [ "object","null" ] },
          "SPABII4": { "type": [ "object","null" ] },
          "SPABII5": { "type": [ "object","null" ] },

          "SPABIII1A": { "type": [ "object","null" ] },
          "SPABIII1B": { "type": [ "object","null" ] },
          "SPABIII1C": { "type": [ "object","null" ] },
          "SPABIII1D": { "type": [ "object","null" ] },

          "SPABIII2A": { "type": [ "object","null" ] },
          "SPABIII2B": { "type": [ "object","null" ] },
          "SPABIII2C": { "type": [ "object","null" ] },
          "SPABIII2D": { "type": [ "object","null" ] },

          "SPABIII3": { "type": [ "object","null" ] },
          "SPABIII4": { "type": [ "object","null" ] },
          "SPACI1": { "type": [ "object","null" ] },
          "SPACI2": { "type": [ "object","null" ] },
          "SPACI3": { "type": [ "object","null" ] },
          "SPACI4": { "type": [ "object","null" ] },
          "SPACI5": { "type": [ "object","null" ] },
          "SPACITOT": { "type": [ "object","null" ] },

          "SPACII1": { "type": [ "object","null" ] },
          "SPACII1OLTRE": { "type": [ "object","null" ] },
          "SPACII2": { "type": [ "object","null" ] },
          "SPACII2OLTRE": { "type": [ "object","null" ] },
          "SPACII3": { "type": [ "object","null" ] },
          "SPACII3OLTRE": { "type": [ "object","null" ] },
          "SPACII4": { "type": [ "object","null" ] },
          "SPACII4OLTRE": { "type": [ "object","null" ] },
          "SPACII5": { "type": [ "object","null" ] },
          "SPACII5OLTRE": { "type": [ "object","null" ] },
          "SPACII6": { "type": [ "object","null" ] },
          "SPACII6OLTRE": { "type": [ "object","null" ] },
          "SPACII7": { "type": [ "object","null" ] },
          "SPACII7OLTRE": { "type": [ "object","null" ] },

          "SPACIITOT": { "type": [ "object","null" ] },
          "SPACIIOLTRETOT": { "type": [ "object","null" ] },

          "SPACIII1": { "type": [ "object","null" ] },
          "SPACIII2": { "type": [ "object","null" ] },
          "SPACIII3": { "type": [ "object","null" ] },
          "SPACIII4": { "type": [ "object","null" ] },
          "SPACIII5": { "type": [ "object","null" ] },
          "SPACIII6": { "type": [ "object","null" ] },
          "SPACIIITOT": { "type": [ "object","null" ] },

          "SPACIV1": { "type": [ "object","null" ] },
          "SPACIV2": { "type": [ "object","null" ] },
          "SPACIV3": { "type": [ "object","null" ] },
          "SPACIVTOT": { "type": [ "object","null" ] },

          "SPACTOT": { "type": [ "object","null" ] },
          "SPAD1": { "type": [ "object","null" ] },
          "SPAD2": { "type": [ "object","null" ] },

          "SPAPA1": { "type": [ "object","null" ] },
          "SPAPA2": { "type": [ "object","null" ] },
          "SPAPA3": { "type": [ "object","null" ] },
          "SPAPA4": { "type": [ "object","null" ] },
          "SPAPA5": { "type": [ "object","null" ] },
          "SPAPA6": { "type": [ "object","null" ] },
          "SPAPA7": { "type": [ "object","null" ] },
          "SPAPA8": { "type": [ "object","null" ] },
          "SPAPA9": { "type": [ "object","null" ] },

          "SPPB1": { "type": [ "object","null" ] },
          "SPPB2": { "type": [ "object","null" ] },
          "SPPB3": { "type": [ "object","null" ] },

          "SPPC1": { "type": [ "object","null" ] },

          "SPPD1": { "type": [ "object","null" ] },
          "SPPD1OLTRE": { "type": [ "object","null" ] },
          "SPPD2": { "type": [ "object","null" ] },
          "SPPD2OLTRE": { "type": [ "object","null" ] },
          "SPPD3": { "type": [ "object","null" ] },
          "SPPD3OLTRE": { "type": [ "object","null" ] },
          "SPPD4": { "type": [ "object","null" ] },
          "SPPD4OLTRE": { "type": [ "object","null" ] },
          "SPPD5": { "type": [ "object","null" ] },
          "SPPD5OLTRE": { "type": [ "object","null" ] },
          "SPPD6": { "type": [ "object","null" ] },
          "SPPD6OLTRE": { "type": [ "object","null" ] },
          "SPPD7": { "type": [ "object","null" ] },
          "SPPD7OLTRE": { "type": [ "object","null" ] },
          "SPPD8": { "type": [ "object","null" ] },
          "SPPD8OLTRE": { "type": [ "object","null" ] },
          "SPPD9": { "type": [ "object","null" ] },
          "SPPD9OLTRE": { "type": [ "object","null" ] },
          "SPPD10": { "type": [ "object","null" ] },
          "SPPD10OLTRE": { "type": [ "object","null" ] },
          "SPPD11": { "type": [ "object","null" ] },
          "SPPD11OLTRE": { "type": [ "object","null" ] },
          "SPPD12": { "type": [ "object","null" ] },
          "SPPD12OLTRE": { "type": [ "object","null" ] },
          "SPPD13": { "type": [ "object","null" ] },
          "SPPD13OLTRE": { "type": [ "object","null" ] },
          "SPPD14": { "type": [ "object","null" ] },
          "SPPD14OLTRE": { "type": [ "object","null" ] },

          "SPPE1": { "type": [ "object","null" ] },
          "SPPE2": { "type": [ "object","null" ] },
          "CEA1": { "type": [ "object","null" ] },
          "CEA2": { "type": [ "object","null" ] },
          "CEA3": { "type": [ "object","null" ] },
          "CEA4": { "type": [ "object","null" ] },
          "CEA5": { "type": [ "object","null" ] },

          "CEB1": { "type": [ "object","null" ] },
          "CEB2": { "type": [ "object","null" ] },
          "CEB3": { "type": [ "object","null" ] },
          "CEB4a": { "type": [ "object","null" ] },
          "CEB4b": { "type": [ "object","null" ] },
          "CEB4c": { "type": [ "object","null" ] },
          "CEB4d": { "type": [ "object","null" ] },
          "CEB4e": { "type": [ "object","null" ] },
          "CEB5a": { "type": [ "object","null" ] },
          "CEB5b": { "type": [ "object","null" ] },
          "CEB5c": { "type": [ "object","null" ] },
          "CEB6": { "type": [ "object","null" ] },
          "CEB7": { "type": [ "object","null" ] },
          "CEB8": { "type": [ "object","null" ] },
          "CEB9": { "type": [ "object","null" ] },

          "CEC1": { "type": [ "object","null" ] },
          "CEC2": { "type": [ "object","null" ] },
          "CEC3": { "type": [ "object","null" ] },
          "CEC4": { "type": [ "object","null" ] },

          "CED1a": { "type": [ "object","null" ] },
          "CED1b": { "type": [ "object","null" ] },
          "CED1c": { "type": [ "object","null" ] },
          "CED2a": { "type": [ "object","null" ] },
          "CED2b": { "type": [ "object","null" ] },
          "CED2c": { "type": [ "object","null" ] },

          "CEE1": { "type": [ "object","null" ] },
          "CEE1PLUS": { "type": [ "object","null" ] },
          "CEE2": { "type": [ "object","null" ] },
          "CEE2MINUS": { "type": [ "object","null" ] },

          "RFA1": { "type": [ "object","null" ] },
          "RFA2": { "type": [ "object","null" ] },
          "RFA3": { "type": [ "object","null" ] },
          "RFA4": { "type": [ "object","null" ] },
          "RFA5": { "type": [ "object","null" ] },
          "RFA6": { "type": [ "object","null" ] },
          "RFA7": { "type": [ "object","null" ] },
          "RFA8": { "type": [ "object","null" ] },

          "RFB1": { "type": [ "object","null" ] },
          "RFB2": { "type": [ "object","null" ] },
          "RFB3": { "type": [ "object","null" ] },
          "RFB4": { "type": [ "object","null" ] } },
        "allOf": [
          { "if": { "properties":   { "type": { "const": "select" } } },
            "then": { "required":   [ "options" ] } },
          { "if": { "properties":   { "type": { "const": "fixed-row" } } },
            "then": { "required":   [ "min", "max",  "columns", "fixedRows" ] } } ] } },
      "output":                     {    "type": [ "object", "null" ] },
      "simulation":                 {    "type": "boolean" },
      "consolidated":               {    "type": "boolean" },
      "last_processing_datetime":   {    "type": [ "string", "null" ], "format": "date-time" },
      "created_at":                 {    "type": "string", "format": "date-time" },
      "updated_at":                 {    "type": "string", "format": "date-time" } } } } } },

    "oType":                        {    "type": "integer" },
    "DataXMData":                   {    "$ref": "https://schemas.mpai.community/PTF/V1.0/data/DataExchangeMetadata.json" },
    "DescrMetadata":                {    "type": "string", "maxLength": 2048 } } }
