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

Entity: calorificValue ​

Entity Type: Database table

Description: A calorific value stated inside a tenant, at one of two scopes: for a whole client, or for a single gauge. gaugeId is what distinguishes them — set means the value applies to that gauge alone, null means it applies to every gauge of the client with the same medium and primary source that has no value of its own.

The columns are identical to the platform-wide defaultCalorificValue, so a resolver walking gauge → client → platform compares the same fields at every step and applies the same validity rule. The two tables are separate only because platform defaults must live in the cross-tenant schema and a per-gauge value must not.

Every scope is dated. A value carries validFrom and runs until the next value at the same scope begins. This is what makes a historical consumption figure reproducible: energy computed for last January uses the value that was valid last January, and correcting that value recomputes that period rather than silently repricing it.

Data Attributes Table ​

Attribute NameDescriptionData TypeDefault ValueRequired (= Nullable)UniqueFormatValidationsIndexExample
idPrimary key of the entity.UUIDGenerated in code (app layer)YesYesUUID v7-Primary Key018f9c4d-2c11-7a3e-9b77-4f0d3a5e6b51
tenantIdTenant this record belongs to.UUID-YesNoUUID v7Foreign Key → tenant; must existname: idx_calorific_value_tenantId, type: btree018fa51f-fda1-79f4-8461-2cb8f1cabc10
clientIdClient the value belongs to. Set on both scopes: a gauge-scoped value still belongs to the client that owns the gauge, so one client's values can be listed without joining.UUID-YesPart of composite uniqueUUID v7Foreign Key → client; must existPart of the unique index below018fa51f-fda1-79f4-8461-2cb8f1cabc10
gaugeIdThe gauge this value applies to, or null for a value that applies to the whole client. The column is the scope discriminator.UUIDnullNoPart of composite uniqueUUID v7Foreign Key → gauge; must exist if set. Its medium and primarySource must match the two columns below.name: idx_calorific_value_gauge_id, type: btree018f6e2a-…
mediumMedium the value applies to.Enum-YesPart of composite uniqueEnum - GaugeMediumAn entry from the enum.Part of the unique index belowgas
primarySourceFuel or source within the medium.Integer-YesPart of composite uniqueEnum - PrimarySourceAn entry from the enum.Part of the unique index below1
valueThe conversion factor: how much energy one unit of unitFrom yields, expressed in unitTo.Decimal-YesNonumeric(12,6)Must be > 0.-9.500000
unitFromUnit the factor converts from.Enum-YesNoEnum - UnitMust be a volume or mass unit.-m³
unitToUnit the factor converts to.Enum-YesNoEnum - UnitMust be an energy unit.-kWh
validFromFirst day the value applies at this scope. No explicit end: it runs until the next value at the same scope begins.Date-YesPart of composite uniqueYYYY-MM-DDUnique per (clientId, gaugeId, medium, primarySource, validFrom) among rows where deletedAt is null.Part of the unique index below2026-01-01
noteWhere the value comes from — typically the supplier's certificate or declaration, with its reference.StringnullNoNo-Max 500 characters.-Certifikát dodavatele 2026-Q1
createdAtTimestamp of record creation.Timestamp with time zonenow() — set in codeYesNoISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZCannot be null.-2026-01-05T08:00:00Z
updatedAtTimestamp of the last update.Timestamp with time zonenow() — set in codeYesNoISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZCannot be null.-2026-01-05T08:00:00Z
deletedAtSoft-delete marker. Null means active. A superseded value is never deleted — it reproduces the consumption of the period it covered.Timestamp with time zonenullNoNoISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZImmutable once set. Active rows: WHERE deletedAt IS NULL.-null
createdByActor who created the record.String-YesNotype:actorNon-empty.-user:018ed0b3-…
updatedByActor who last updated the record.String-YesNotype:actorNon-empty.-user:018ed0b3-…

Indexes ​

NameColumnsTypeWhy
uq_calorific_value_scopeclientId, gaugeId, medium, primarySource, validFrom where deletedAt is null — nulls not distinctUnique, partialOne value per scope and start date, with gaugeId null treated as its own scope rather than as "any".
idx_calorific_value_gauge_idgaugeIdbtreeThe gauge-scope lookup, which is the first step of every resolution.
idx_calorific_value_tenantIdtenantIdbtreeTenant predicate.

Row-level security ​

Enabled and forced, with the tenant-isolation policy every tenant-schema table carries.

Audited fields ​

Recorded on created (in full), updated (changed only) and deleted (in full): clientId, gaugeId, medium, primarySource, value, unitFrom, unitTo, validFrom, note.

Excluded: none — every column of a calorific value changes the energy figures derived from it.

Not registered for entityName resolution, and has no independent human-readable attribute to register — identified by its clientId/gaugeId/medium/primarySource/validFrom scope.