The Versorgung field suggests ELT and MSR (plus values already used in the balance) through a datalist and still accepts free text. The circuit number column is not needed in early design phases; it is removed from the data model, the regenerated migration 0010, the editor and the print. All cells are centered except "Verbraucher / Flächen", group titles and total labels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.2 KiB
TypeScript
60 lines
2.2 KiB
TypeScript
import { index, integer, real, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
|
import { projects } from "./projects.js";
|
|
|
|
// Grobe Leistungsbilanz (LPH 2/3): a separate module without links into the
|
|
// circuit structure. See docs/estimate-balance.md.
|
|
export const estimateBalances = sqliteTable(
|
|
"estimate_balances",
|
|
{
|
|
id: text("id").primaryKey(),
|
|
projectId: text("project_id")
|
|
.notNull()
|
|
.references(() => projects.id, { onDelete: "cascade" }),
|
|
name: text("name").notNull(),
|
|
workStage: text("work_stage"),
|
|
dateIso: text("date_iso"),
|
|
reserveAvPercent: real("reserve_av_percent").notNull().default(0),
|
|
reserveSvPercent: real("reserve_sv_percent").notNull().default(0),
|
|
sortOrder: integer("sort_order").notNull().default(0),
|
|
},
|
|
(table) => [index("estimate_balances_project_id_idx").on(table.projectId)]
|
|
);
|
|
|
|
export const estimateGroups = sqliteTable(
|
|
"estimate_groups",
|
|
{
|
|
id: text("id").primaryKey(),
|
|
balanceId: text("balance_id")
|
|
.notNull()
|
|
.references(() => estimateBalances.id, { onDelete: "cascade" }),
|
|
costGroup: text("cost_group").notNull().default(""),
|
|
title: text("title").notNull(),
|
|
editor: text("editor"),
|
|
sortOrder: integer("sort_order").notNull().default(0),
|
|
},
|
|
(table) => [index("estimate_groups_balance_id_idx").on(table.balanceId)]
|
|
);
|
|
|
|
export const estimateRows = sqliteTable(
|
|
"estimate_rows",
|
|
{
|
|
id: text("id").primaryKey(),
|
|
groupId: text("group_id")
|
|
.notNull()
|
|
.references(() => estimateGroups.id, { onDelete: "cascade" }),
|
|
sortOrder: integer("sort_order").notNull().default(0),
|
|
supply: text("supply"),
|
|
name: text("name").notNull().default(""),
|
|
quantity: real("quantity").notNull().default(0),
|
|
unit: text("unit", { enum: ["piece", "area"] }).notNull().default("piece"),
|
|
connection: text("connection", { enum: ["fixed", "socket"] }),
|
|
powerPerUnitW: real("power_per_unit_w").notNull().default(0),
|
|
simultaneityFactor: real("simultaneity_factor").notNull().default(1),
|
|
cosPhi: real("cos_phi").notNull().default(1),
|
|
safetySupply: integer("safety_supply", { mode: "boolean" })
|
|
.notNull()
|
|
.default(false),
|
|
remark: text("remark"),
|
|
},
|
|
(table) => [index("estimate_rows_group_id_idx").on(table.groupId)]
|
|
);
|