Phase 1A done

This commit is contained in:
2026-05-03 21:16:52 +02:00
parent 49190c5d7e
commit b8995b3a1b
21 changed files with 1038 additions and 3 deletions
@@ -0,0 +1,57 @@
export interface LegacyConsumerForPlanning {
id: string;
circuitNumber: string | null;
category: string | null;
phaseType: string | null;
phaseCount: number | null;
}
export function normalizeCircuitNumber(value: string | null): string | null {
if (!value) {
return null;
}
const trimmed = value.trim().toUpperCase();
if (!trimmed) {
return null;
}
if (!/^-\d+F\d+$/.test(trimmed)) {
return null;
}
return trimmed;
}
export function inferSectionKeyFromLegacyInput(consumer: LegacyConsumerForPlanning): string | null {
const category = (consumer.category ?? "").toLowerCase();
if (category.includes("light") || category.includes("beleuchtung")) {
return "lighting";
}
if (consumer.phaseCount === 3) {
return "three_phase";
}
if (consumer.phaseCount === 1) {
return "single_phase";
}
const phaseType = (consumer.phaseType ?? "").toLowerCase();
if (phaseType.includes("three") || phaseType.includes("3")) {
return "three_phase";
}
if (phaseType.includes("single") || phaseType.includes("1")) {
return "single_phase";
}
return null;
}
export function inferSectionKeyFromEquipmentIdentifier(equipmentIdentifier: string): string | null {
if (equipmentIdentifier.startsWith("-1F")) {
return "lighting";
}
if (equipmentIdentifier.startsWith("-2F")) {
return "single_phase";
}
if (equipmentIdentifier.startsWith("-3F")) {
return "three_phase";
}
return null;
}