{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/dbt-se/main/json-schema/dbt-se-portfolio-organization-schema.json",
  "title": "PortfolioOrganization",
  "x-generated": "2026-10-16",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/dbt-se-openapi.json#/components/schemas/PortfolioOrganization",
  "type": "object",
  "properties": {
    "orgId": {
      "type": "string"
    },
    "name": {
      "type": [
        "string",
        "null"
      ]
    },
    "displayName": {
      "type": "string"
    },
    "timezone": {
      "type": "string"
    },
    "naceFirstLetter": {
      "type": [
        "string",
        "null"
      ]
    },
    "creditLimitGroupId": {
      "type": [
        "string",
        "null"
      ]
    },
    "loanStatistics": {
      "$ref": "#/$defs/OrganizationLoanStatistics"
    },
    "loanIds": {
      "type": [
        "string",
        "null"
      ]
    },
    "clientStatus": {
      "anyOf": [
        {
          "$ref": "#/$defs/ClientStatus"
        },
        {
          "type": "null"
        }
      ]
    },
    "performanceStatus": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "performing",
        "worried",
        "workout",
        "watchlist",
        "bankruptcy",
        null
      ]
    },
    "registrationDate": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "default",
            "missingValue",
            "error"
          ]
        },
        "value": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "dateString": {
              "type": "string"
            },
            "day": {
              "type": "number"
            },
            "monthIndex": {
              "type": "number"
            },
            "timeZone": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": [
                "date"
              ]
            },
            "year": {
              "type": "number"
            }
          },
          "required": [
            "dateString",
            "day",
            "monthIndex",
            "timeZone",
            "type",
            "year"
          ]
        }
      },
      "required": [
        "text",
        "type",
        "value"
      ]
    },
    "dbtProbabilityOfDefault": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "default",
            "missingValue",
            "error"
          ]
        },
        "value": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "format": {
              "type": "object",
              "properties": {
                "maximumFractionDigits": {
                  "type": "number",
                  "minimum": 0
                },
                "maximumIntegerDigits": {
                  "type": "number",
                  "minimum": 0
                },
                "minimumFractionDigits": {
                  "type": "number",
                  "minimum": 0
                },
                "minimumIntegerDigits": {
                  "type": "number",
                  "minimum": 0
                }
              }
            },
            "percentageAsFraction": {
              "type": "number"
            },
            "type": {
              "type": "string",
              "enum": [
                "percent"
              ]
            }
          },
          "required": [
            "percentageAsFraction",
            "type"
          ]
        }
      },
      "required": [
        "text",
        "type",
        "value"
      ]
    },
    "dbtCreditScore": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "default",
            "missingValue",
            "error"
          ]
        },
        "value": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "format": {
              "type": "object",
              "properties": {
                "maximumFractionDigits": {
                  "type": "number",
                  "minimum": 0
                },
                "minimumFractionDigits": {
                  "type": "number",
                  "minimum": 0
                }
              }
            },
            "number": {
              "type": "number"
            },
            "type": {
              "type": "string",
              "enum": [
                "number"
              ]
            }
          },
          "required": [
            "number",
            "type"
          ]
        }
      },
      "required": [
        "text",
        "type",
        "value"
      ]
    },
    "counterpartyId": {
      "type": [
        "string",
        "null"
      ]
    },
    "ucCreditRisk": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "default",
            "missingValue",
            "error"
          ]
        },
        "value": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "summary": {
              "type": "object",
              "properties": {
                "compact": {
                  "type": "string"
                },
                "withDate": {
                  "type": "string"
                }
              },
              "required": [
                "compact",
                "withDate"
              ]
            },
            "date": {
              "type": "object",
              "properties": {
                "dateString": {
                  "type": "string"
                },
                "day": {
                  "type": "number"
                },
                "monthIndex": {
                  "type": "number"
                },
                "timeZone": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "date"
                  ]
                },
                "year": {
                  "type": "number"
                }
              },
              "required": [
                "dateString",
                "day",
                "monthIndex",
                "timeZone",
                "type",
                "year"
              ]
            },
            "riskForecast": {
              "type": [
                "object",
                "null"
              ],
              "properties": {
                "format": {
                  "type": "object",
                  "properties": {
                    "maximumFractionDigits": {
                      "type": "number",
                      "minimum": 0
                    },
                    "maximumIntegerDigits": {
                      "type": "number",
                      "minimum": 0
                    },
                    "minimumFractionDigits": {
                      "type": "number",
                      "minimum": 0
                    },
                    "minimumIntegerDigits": {
                      "type": "number",
                      "minimum": 0
                    }
                  }
                },
                "percentageAsFraction": {
                  "type": "number"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "percent"
                  ]
                }
              },
              "required": [
                "percentageAsFraction",
                "type"
              ]
            },
            "importance": {
              "type": "string",
              "enum": [
                "normal",
                "elevated",
                "critical"
              ]
            }
          },
          "required": [
            "summary",
            "date",
            "riskForecast",
            "importance"
          ]
        }
      },
      "required": [
        "text",
        "type",
        "value"
      ]
    },
    "ucCreditRiskForecast": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "default",
            "missingValue",
            "error"
          ]
        },
        "value": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "format": {
              "type": "object",
              "properties": {
                "maximumFractionDigits": {
                  "type": "number",
                  "minimum": 0
                },
                "maximumIntegerDigits": {
                  "type": "number",
                  "minimum": 0
                },
                "minimumFractionDigits": {
                  "type": "number",
                  "minimum": 0
                },
                "minimumIntegerDigits": {
                  "type": "number",
                  "minimum": 0
                }
              }
            },
            "percentageAsFraction": {
              "type": "number"
            },
            "type": {
              "type": "string",
              "enum": [
                "percent"
              ]
            }
          },
          "required": [
            "percentageAsFraction",
            "type"
          ]
        }
      },
      "required": [
        "text",
        "type",
        "value"
      ]
    },
    "ucCreditRiskForecastDate": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "default",
            "missingValue",
            "error"
          ]
        },
        "value": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "dateString": {
              "type": "string"
            },
            "day": {
              "type": "number"
            },
            "monthIndex": {
              "type": "number"
            },
            "timeZone": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": [
                "date"
              ]
            },
            "year": {
              "type": "number"
            }
          },
          "required": [
            "dateString",
            "day",
            "monthIndex",
            "timeZone",
            "type",
            "year"
          ]
        }
      },
      "required": [
        "text",
        "type",
        "value"
      ]
    },
    "ucLastCompanyReportOrderDate": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "default",
            "missingValue",
            "error"
          ]
        },
        "value": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "dateString": {
              "type": "string"
            },
            "day": {
              "type": "number"
            },
            "monthIndex": {
              "type": "number"
            },
            "timeZone": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": [
                "date"
              ]
            },
            "year": {
              "type": "number"
            }
          },
          "required": [
            "dateString",
            "day",
            "monthIndex",
            "timeZone",
            "type",
            "year"
          ]
        }
      },
      "required": [
        "text",
        "type",
        "value"
      ]
    },
    "ucRiskClass": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "default",
            "missingValue",
            "error"
          ]
        },
        "value": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "string": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": [
                "string"
              ]
            }
          },
          "required": [
            "string",
            "type"
          ]
        }
      },
      "required": [
        "text",
        "type",
        "value"
      ]
    },
    "dbtContact": {
      "$ref": "#/$defs/OrganizationStaff"
    },
    "kyc": {
      "type": "object",
      "properties": {
        "company": {
          "type": "object",
          "properties": {
            "status": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "default",
                    "missingValue",
                    "error"
                  ]
                },
                "value": {
                  "type": "string",
                  "enum": [
                    "NO_HITS",
                    "HITS_FOUND",
                    "NO_DATA"
                  ]
                }
              },
              "required": [
                "text",
                "type",
                "value"
              ]
            }
          },
          "required": [
            "status"
          ]
        },
        "persons": {
          "type": "object",
          "properties": {
            "status": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "default",
                    "missingValue",
                    "error"
                  ]
                },
                "value": {
                  "type": "string",
                  "enum": [
                    "NO_HITS",
                    "HITS_FOUND",
                    "NO_DATA"
                  ]
                }
              },
              "required": [
                "text",
                "type",
                "value"
              ]
            }
          },
          "required": [
            "status"
          ]
        }
      },
      "required": [
        "company",
        "persons"
      ]
    },
    "lgd": {
      "type": "object",
      "properties": {
        "lgdAmount": {
          "type": "object",
          "properties": {
            "text": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": [
                "default",
                "missingValue",
                "error"
              ]
            },
            "value": {
              "type": [
                "object",
                "null"
              ],
              "properties": {
                "amount": {
                  "type": "string"
                },
                "currency": {
                  "type": "string"
                },
                "format": {
                  "type": "object",
                  "properties": {
                    "notation": {
                      "type": "string",
                      "enum": [
                        "scientific",
                        "engineering",
                        "compact"
                      ]
                    },
                    "roundingPriority": {
                      "type": "string",
                      "enum": [
                        "morePrecision",
                        "lessPrecision"
                      ]
                    }
                  }
                },
                "numericAmount": {
                  "type": "number"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "currency"
                  ]
                }
              },
              "required": [
                "amount",
                "currency",
                "numericAmount",
                "type"
              ]
            }
          },
          "required": [
            "text",
            "type",
            "value"
          ]
        },
        "lgdPercentage": {
          "type": "object",
          "properties": {
            "text": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": [
                "default",
                "missingValue",
                "error"
              ]
            },
            "value": {
              "type": [
                "object",
                "null"
              ],
              "properties": {
                "format": {
                  "type": "object",
                  "properties": {
                    "maximumFractionDigits": {
                      "type": "number",
                      "minimum": 0
                    },
                    "maximumIntegerDigits": {
                      "type": "number",
                      "minimum": 0
                    },
                    "minimumFractionDigits": {
                      "type": "number",
                      "minimum": 0
                    },
                    "minimumIntegerDigits": {
                      "type": "number",
                      "minimum": 0
                    }
                  }
                },
                "percentageAsFraction": {
                  "type": "number"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "percent"
                  ]
                }
              },
              "required": [
                "percentageAsFraction",
                "type"
              ]
            }
          },
          "required": [
            "text",
            "type",
            "value"
          ]
        }
      },
      "required": [
        "lgdAmount",
        "lgdPercentage"
      ]
    }
  },
  "required": [
    "orgId",
    "name",
    "displayName",
    "timezone",
    "naceFirstLetter",
    "creditLimitGroupId",
    "loanStatistics",
    "loanIds",
    "clientStatus",
    "performanceStatus",
    "registrationDate",
    "dbtProbabilityOfDefault",
    "dbtCreditScore",
    "counterpartyId",
    "ucCreditRisk",
    "ucCreditRiskForecast",
    "ucCreditRiskForecastDate",
    "ucLastCompanyReportOrderDate",
    "ucRiskClass",
    "dbtContact",
    "kyc",
    "lgd"
  ],
  "$defs": {
    "ClientMonitoringReviewSchedule": {
      "type": "object",
      "properties": {
        "interval": {
          "type": "object",
          "properties": {
            "text": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": [
                "default",
                "missingValue",
                "error"
              ]
            },
            "value": {
              "type": [
                "string",
                "null"
              ],
              "enum": [
                "monthly",
                "quaterly",
                "half_yearly",
                "yearly",
                null
              ]
            }
          },
          "required": [
            "text",
            "type",
            "value"
          ]
        },
        "startDate": {
          "type": "object",
          "properties": {
            "text": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": [
                "default",
                "missingValue",
                "error"
              ]
            },
            "value": {
              "type": [
                "object",
                "null"
              ],
              "properties": {
                "dateString": {
                  "type": "string"
                },
                "day": {
                  "type": "number"
                },
                "monthIndex": {
                  "type": "number"
                },
                "timeZone": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "date"
                  ]
                },
                "year": {
                  "type": "number"
                }
              },
              "required": [
                "dateString",
                "day",
                "monthIndex",
                "timeZone",
                "type",
                "year"
              ]
            }
          },
          "required": [
            "text",
            "type",
            "value"
          ]
        },
        "nextReviewDate": {
          "type": "object",
          "properties": {
            "text": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": [
                "default",
                "missingValue",
                "error"
              ]
            },
            "value": {
              "type": [
                "object",
                "null"
              ],
              "properties": {
                "dateString": {
                  "type": "string"
                },
                "day": {
                  "type": "number"
                },
                "monthIndex": {
                  "type": "number"
                },
                "timeZone": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "date"
                  ]
                },
                "year": {
                  "type": "number"
                }
              },
              "required": [
                "dateString",
                "day",
                "monthIndex",
                "timeZone",
                "type",
                "year"
              ]
            }
          },
          "required": [
            "text",
            "type",
            "value"
          ]
        },
        "frequencyString": {
          "type": "object",
          "properties": {
            "short": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "default",
                    "missingValue",
                    "error"
                  ]
                },
                "value": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "text",
                "type",
                "value"
              ]
            },
            "long": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "default",
                    "missingValue",
                    "error"
                  ]
                },
                "value": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "text",
                "type",
                "value"
              ]
            }
          },
          "required": [
            "short",
            "long"
          ]
        }
      },
      "required": [
        "interval",
        "startDate",
        "nextReviewDate",
        "frequencyString"
      ]
    },
    "ClientStatus": {
      "type": "object",
      "properties": {
        "orgId": {
          "type": "string"
        },
        "createdBy": {
          "$ref": "#/$defs/ClientStatusCreatedBy"
        },
        "status": {
          "type": "string",
          "enum": [
            "performing",
            "watchlist",
            "worried",
            "workout",
            "bankruptcy"
          ]
        },
        "monitoringApproach": {
          "type": "string",
          "enum": [
            "tech_driven",
            "human_driven"
          ]
        },
        "reviewSchedule": {
          "$ref": "#/$defs/ClientMonitoringReviewSchedule"
        },
        "defaultReviewType": {
          "type": "string",
          "enum": [
            "limited",
            "full"
          ]
        },
        "isPublicCompany": {
          "type": "boolean"
        },
        "comment": {
          "type": [
            "string",
            "null"
          ]
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "orgId",
        "createdBy",
        "status",
        "monitoringApproach",
        "reviewSchedule",
        "defaultReviewType",
        "isPublicCompany",
        "comment",
        "createdAt"
      ]
    },
    "ClientStatusCreatedBy": {
      "oneOf": [
        {
          "$ref": "#/$defs/ClientStatusCreatedBySystem"
        },
        {
          "$ref": "#/$defs/ClientStatusCreatedByStaff"
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "review-assessment"
              ]
            },
            "assessmentId": {
              "type": "string"
            }
          },
          "required": [
            "type",
            "assessmentId"
          ]
        }
      ]
    },
    "ClientStatusCreatedByStaff": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "staff"
          ]
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "id": {
          "type": "string"
        }
      },
      "required": [
        "type",
        "name",
        "id"
      ]
    },
    "ClientStatusCreatedBySystem": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "system"
          ]
        }
      },
      "required": [
        "type"
      ]
    },
    "OrganizationLoanStatistics": {
      "type": "object",
      "properties": {
        "numberOfActiveLoans": {
          "type": "number"
        },
        "numberOfLoans": {
          "type": "number"
        }
      },
      "required": [
        "numberOfActiveLoans",
        "numberOfLoans"
      ]
    },
    "OrganizationStaff": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "email": {
          "type": "string"
        },
        "avatarUrl": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "name",
        "email",
        "avatarUrl"
      ]
    }
  }
}