Skip to content
Updated Sep 26, 2026 by Barča Dvořáková · Owner: analysisactiveentityconfluence-migration Edit on GitHub

Entity: organisation ​

Entity Type: Database table

Description: A legal entity or natural person associated with a client (a subject, Czech subjekt). The organisation registry is the single source of truth for subject data referenced across buildings (as owner, manager, delegated manager) and gauges (as subscriber). Every client is itself the first organisation in its own registry. Corresponds to Person in the Data Model high-level overview.

Schema placement decision (2026-07-28). The organisation table is tenant-side — it lives in the tenant application schema and mirrors the building/gauge template (tenant_id NOT NULL + row-level security policy). The former clientId attribute has been removed from the model: it is derivable via tenant.client_id (client : tenant = 1 : 0..1), so a stored column would be redundant. This executes the rewrite agreed in the client/tenant relationship decision of 2026-06-25. API routes are top-level /v1/organisations within the tenant context, not nested under /v1/clients/:id.

Invoicing attributes — type finalisation pending. The fields invoicePaymentMethod and invoiceDeliveryMethod are stored as plain strings in v1. Their allowed values (e.g. bankTransfer, email, dataBox) will be formalised as enums in the Invoicing feature epic. Until then, treat them as free-text fields with no application-layer validation beyond non-empty. Implement as VARCHAR — no migration will be required when the Invoicing epic converts them to enum columns.

Data Attributes Table ​

Attribute NameDescriptionData TypeDefault ValueRequired (= Nullable)UniqueFormatValidationsIndexExample
idPrimary key.UUIDGenerated in code (app layer)YesYesUUID v7-Primary Key018ed0b3-c298-7c7a-96d5-8b36f5a7f8d2
tenantIdTenant this record belongs to.UUID-YesNoUUID v7Foreign Key → tenant; must existname: idx_organisation_tenantId, type: btree018fa51f-fda1-79f4-8461-2cb8f1cabc10
nameOfficial name of the organisation or full name of the natural person.String-YesNo-Non-empty; max 255 chars.name: idx_organisation_name, type: btreeStavební s.r.o.
icoCzech company tax ID (IČO). Null for natural persons without IČO.String-NoNo8-digit stringNullable; if set must be 8 digits.-27082440
dicVAT number (DIČ).String-NoNo-Nullable.-CZ27082440
legalFormLegal form of the organisation (e.g. s.r.o., a.s., fyzická osoba).String-NoNo-Nullable.-s.r.o.
pxeIdentifierPXE exchange identifier (energy market).String-NoNo-Nullable.-PXE-12345
dataBoxIdCzech data box ID (datová schránka).String-NoNo-Nullable.-ab3cd4e
isSelfMarks the one organisation row, per tenant, that represents the tenant's own client.BooleanfalseYesNo-At most one true row per tenant (partial unique index, active rows only). Never writable through any DTO — create-only, set only by tenant provisioning.name: uq_organisation_self, type: unique btree (partial: WHERE isSelf = true AND deletedAt IS NULL)false
emailThe subject's own e-mail (e.g. info@…), independent of the contact-person users.String-NoNoE-mailNullable; max 254 chars; valid e-mail format.-info@stavebni.cz
registeredStreetRegistered address — street and house number.String-NoNo-Nullable.-Náměstí Svobody 8
registeredCityRegistered address — city.String-NoNo-Nullable.-Brno
registeredZipRegistered address — postal code.String-NoNo-Nullable.-602 00
billingAddressSameAsRegisteredWhen true, billing address equals the registered address.BooleantrueYesNo---true
billingStreetBilling address — street and house number. Used only when billingAddressSameAsRegistered = false.String-NoNo-Nullable.-Poštovská 3
billingCityBilling address — city.String-NoNo-Nullable.-Brno
billingZipBilling address — postal code.String-NoNo-Nullable.-602 00
bankAccountBank account number for invoicing.String-NoNo-Nullable.-123456789/0800
invoicePaymentTermDaysStandard payment term in days for invoices issued to this organisation.Integer-NoNo-Nullable; positive integer.-30
invoicePaymentMethodPreferred payment method. Stored as free text in v1 — will be converted to an enum in the Invoicing feature epic. See panel note above.String-NoNo-Nullable.-bankTransfer
invoiceDeliveryMethodHow invoices are delivered. Stored as free text in v1 — will be converted to an enum in the Invoicing feature epic. See panel note above.String-NoNo-Nullable.-email
contactEnmsUserIdUser acting as EnMS contact for this organisation.UUID-NoNoUUID v7No database foreign key exists; validated at the application layer only (plain nullable UUID).-018ed0b3-c298-7c7a-96d5-8b36f5a7f8d2
contactBillingUserIdUser acting as billing contact for this organisation.UUID-NoNoUUID v7No database foreign key exists; validated at the application layer only (plain nullable UUID).-018ed0b3-c298-7c7a-96d5-8b36f5a7f8d2
contactTechnicalUserIdUser acting as technical contact for this organisation.UUID-NoNoUUID v7No database foreign key exists; validated at the application layer only (plain nullable UUID).-018ed0b3-c298-7c7a-96d5-8b36f5a7f8d2
contactRegulatoryUserIdUser acting as regulatory contact for this organisation.UUID-NoNoUUID v7No database foreign key exists; validated at the application layer only (plain nullable UUID).-018ed0b3-c298-7c7a-96d5-8b36f5a7f8d2
createdAtTimestamp of when the record was created. Immutable after insert.Timestamp with time zonenow() — set in codeYesNoISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZCannot be null; cannot be modified after creation.-2025-03-16T18:00:00Z
updatedAtTimestamp of the last update to the record.Timestamp with time zonenow() — set in codeYesNoISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZCannot be null.-2025-03-16T18:00:00Z
deletedAtTimestamp of soft deletion. Null means the record is active. Once set, immutable.Timestamp with time zone-NoNoISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZImmutable once set. Active records: WHERE deletedAt IS NULL-2025-06-01T09:00:00Z
createdByIdentifier of the actor who created the record.String-YesNotype:actorNon-empty.-user:018ed0b3-c298-7c7a-96d5-8b36f5a7f8d2
updatedByIdentifier of the actor who last updated the record.String-YesNotype:actorNon-empty.-system:migration-v25

Deferred attributes ​

Attributes that are not part of the v1 implementation. Retained here for documentation purposes, as on the source page.

Attribute NameDescriptionData TypeExampleReason to deferNotes
roleAtClientPrimary role of this organisation in relation to the client (free text label).StringSprávce nemovitostíReplaced by derived roles.Not stored. The roles are derived from live references (owner, manager, delegated manager, subscriber) and isSelf — see Organisation & Distribution Registry.
clientIdClient this organisation belongs to (was: UUID, required, FK → client, idx_organisation_clientId).UUID018fa51f-fda1-79f4-8461-2cb8f1cabc10Removed by the schema-placement decision (2026-07-28).Derivable via tenant.client_id (client : tenant = 1 : 0..1) — a stored column would be redundant. See the schema placement decision panel above.

Audited fields ​

Recorded on created (in full), updated (changed only) and deleted (in full): name, ico, dic, legalForm, pxeIdentifier, dataBoxId, isSelf, email, registeredStreet, registeredCity, registeredZip, billingAddressSameAsRegistered, billingStreet, billingCity, billingZip, bankAccount, invoicePaymentTermDays, invoicePaymentMethod, invoiceDeliveryMethod, contactEnmsUserId, contactBillingUserId, contactTechnicalUserId, contactRegulatoryUserId.

Excluded: none.

isSelf is create-only — absent from every update path, so it appears in a created entry but never in an updated entry's changed fields.

A reference to an organisation from building (ownerId/managerId/delegatedManagerId) or from gauge (subscriberId/supplierOrganisationId) is recorded only as a changed field on that referencing entity's own entry — never as a subject pin here. organisation's own history shows only its own row's changes.

Correction: the four contact-user-id rows above previously claimed an enforced foreign key with onDelete SET NULL; no such constraint exists in the database — corrected to plain application-validated UUIDs.

Registered for entityName resolution — resolves to name (architecture 61-audit-log.md §7.4 in the code repo).