Appearance
Entity: usageType
Entity Type: Database table (platform schema)
Description: Platform-level catalogue of what measured consumption is used for (účel užití): heating, hot water, cooling, lighting, vehicle charging, irrigation … It replaces the compile-time union behind ConsumptionUsageType for gauge channels (the enum stays for buildingCalculatedConsumption). One catalogue for every tenant (decision R7, 1 Oct 2026 — tenant sub-items under other are a v2 candidate), maintained by the Porsenna superadmin; no tenantId, no RLS, the same precedent as platform.contract_item_type and distributionRate. Each item carries what the rest of the system needs from it: a category for grouping, the climate-normalisation method (Epic 3.2 normalises only hdd / cdd items), and the media × channel meanings it may be offered on (K1 matrix). A channel refers to it through gaugeUsageAllocationItem. Decided 1 Oct 2026 (R1–R7); the offer matrix (K1–K4) awaits stakeholder confirmation.
Data Attributes Table
| Attribute Name | Description | Data Type | Default Value | Required (= Nullable) | Unique | Format | Validations | Index | Example |
|---|---|---|---|---|---|---|---|---|---|
| id | Primary key of the entity. | UUID | Generated in code (app layer) | Yes | Yes | UUID v7 | - | Primary Key | 01960000-0000-7000-8000-000000000701 |
| code | Stable machine code. | String | - | Yes | Yes | lowerCamelCase — heating, hotWater, cooling, ventilation, lighting, baseLoad, cooking, evCharging, transport, sanitary, processWater, irrigation, other | Max 40 characters; unique among active rows. | name: idx_usageType_code, type: btree (unique, partial deletedAt IS NULL) | hotWater |
| nameCs | Czech label shown in the gauge form, the allocation modal and reports. | String | - | Yes | No | - | Max 100 characters; non-empty. | - | Ohřev teplé vody |
| labelByMedium | Optional medium-specific label (K2: a water meter shows Teplá voda for hotWater, an energy meter Ohřev teplé vody). | JSON (map medium → label) | null | No | No | {"water": "Teplá voda"} | Keys from enum Medium. | - | {"water": "Teplá voda"} |
| category | Grouping for reports and the modal: heat, technology, electric, fuel, water, production, other. | String | - | Yes | No | enum (fixed list above) | - | - | heat |
| normalizationMethod | How Epic 3.2 normalises consumption of this usage: none, hdd (heating degree days), cdd (cooling degree days). | String | none | Yes | No | enum | - | - | none |
| allowedFor | Which channels may carry this usage: list of (medium, purpose meaning) pairs — the K1 matrix as data, not two independent lists (N01). | JSON (array of {medium, purpose}) | [] | Yes | No | [{"medium":"electricity","purpose":"consumption"}, …] | Non-empty for an active row; media from enum Medium, purposes from the gauge purpose meanings consumption / production / export. v1 lists consumption only (K3). | - | [{"medium":"gas","purpose":"consumption"},{"medium":"heat","purpose":"consumption"}] |
| sortOrder | Display order within the filtered offer (N10). | Integer | 0 | Yes | No | - | - | - | 20 |
| isActive | Whether the item is offered for new assignments. Deactivating keeps existing allocations readable (N09). | Boolean | true | Yes | No | - | - | - | true |
| em2Code | EM2 gauge_consumption_usage code the item migrates from (1 heating, 2 hot water, 5 other, 6 lighting, 7 other non-weather). Null for new items. | Integer | null | No | No | - | - | - | 2 |
| createdAt | Timestamp of creation. Immutable. | Timestamp with time zone | Set in code | Yes | No | ISO 8601 | - | - | 2026-10-05T10:00:00Z |
| updatedAt | Timestamp of last update. | Timestamp with time zone | Set in code | Yes | No | ISO 8601 | - | - | 2026-10-05T10:00:00Z |
| deletedAt | Soft-delete timestamp. | Timestamp with time zone | null | No | No | ISO 8601 | - | - | null |
| createdBy | Actor who created the record. | String | - | Yes | No | type:actor | - | - | system:seed |
| updatedBy | Actor who last updated the record. | String | - | Yes | No | type:actor | - | - | system:seed |
Notes
- Seed (v1, full set — decision R4):
heating(HDD),hotWater,cooling(CDD),ventilation,lighting,baseLoad(Ostatní provoz — bez vlivu počasí),cooking,evCharging,transport,sanitary,processWater,irrigation,other.gridExportandsharingare not seeded as consumption usages — production, export and sharing stay outside the v1 split (K3) and are classified by the channel'spurpose. No item is a default for any channel (D01): a new channel is Neurčeno until the user chooses. - Offer per medium (K1, consumption channels): electricity — heating, hotWater, cooling, ventilation, lighting, baseLoad, cooking, evCharging, other · gas — heating, hotWater, cooking, other · heat — heating, hotWater, other · cold — cooling, other · water — sanitary, hotWater, processWater, irrigation, other · solid and liquid fuel — heating, hotWater, other · vehicle fuel — transport, other. KVP channels carry no usage.
- EM2 codes 3, 4, 8 (combi heating measured / combi coefficient / combi hot water measured) are not usages — they become the
modeof gaugeUsageAllocation. EM2 code 0 migrates as no allocation (null), not asother, so the gap stays visible. - Administration: superadmin read in v1 (same read-only pattern as the distribution-rate catalogue); the tenant reads
GET /v1/usage-types?medium=&purpose=for the select and the modal; the backend validates every allocation againstallowedFor(N10 — no second matrix in the frontend).