Derive device voltages from project settings
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
toCircuitDeviceRowSnapshot,
|
||||
} from "./circuit-device-row-structure.persistence.js";
|
||||
import { executeProjectCommandTransaction } from "./project-command-transaction.persistence.js";
|
||||
import { resolveCircuitVoltage } from "./project-voltage.persistence.js";
|
||||
|
||||
export class CircuitStructureProjectCommandRepository
|
||||
implements CircuitStructureProjectCommandStore
|
||||
@@ -77,6 +78,19 @@ export class CircuitStructureProjectCommandRepository
|
||||
snapshot: CircuitSnapshot
|
||||
) {
|
||||
this.assertCircuitLocation(database, projectId, snapshot);
|
||||
if (source === "user") {
|
||||
const derivedVoltage = resolveCircuitVoltage(
|
||||
database,
|
||||
projectId,
|
||||
snapshot.sectionId,
|
||||
snapshot.deviceRows.map((row) => row.phaseType)
|
||||
);
|
||||
if (snapshot.voltage !== derivedVoltage) {
|
||||
throw new Error(
|
||||
"Circuit voltage must match the project phase voltage."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const existingCircuit = database
|
||||
.select({ id: circuits.id })
|
||||
|
||||
Reference in New Issue
Block a user