Add Revit return workbook export

This commit is contained in:
Julian Appel 2026-09-30 15:15:17 +02:00
parent 77d775fde1
commit 1a4c8cad8c
17 changed files with 3783 additions and 6 deletions

View file

@ -0,0 +1,43 @@
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { projectExternalXlsxReturn } from "../src/external-model/application/external-xlsx-return-projection.js";
import type { ExternalModelObjectSnapshot } from "../src/external-model/domain/external-model-contracts.js";
function object(): ExternalModelObjectSnapshot {
return {
id: "object-1", projectId: "project-1", sourceId: "source-1",
worksharingId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee-ffffffff", ifcGuid: null,
deviceTypeId: "type-1", lastSeenImportBatchId: "batch-1", lastAcceptedImportBatchId: "batch-1",
acceptedSourceValues: { rowNumber: 2, roomNumber: "101", roomName: "Büro", familyAndType: "Steckdose", selectionMarker: "SD", socketCount: 2, sourceRemark: null, circuitCombined: "UV 1-2F1.1", boardName: "UV 1", circuitIdentifier: "-2F1.1", designation: "Steckdose", electricalPowerW: "240", voltageV: 230, currentA: "1,16" },
planningValues: { displayName: "Steckdose", category: "single_phase", connectionKind: "socket", effectiveQuantity: 2, powerPerUnitW: 120, simultaneityFactor: 1, cosPhi: 0.9, costGroup: null, remark: null },
overriddenFields: [], externalRoomMappingId: null, distributionBoardId: "board-1", linkedProjectDeviceId: null, circuitDeviceRowId: "row-1", presenceStatus: "present",
};
}
describe("external XLSX return projection", () => {
it("projects typed row values and compares normalized imported scalars", () => {
const result = projectExternalXlsxReturn({ object: object(), circuitMode: "combined", singlePhaseVoltageV: 230, threePhaseVoltageV: 400, row: { rowId: "row-1", displayName: "Steckdose", powerPerUnitKw: 0.12, cosPhi: 0.9, phaseType: "single_phase", category: "single_phase", circuitIdentifier: "-2F1.1", circuitVoltageV: 230, distributionBoardName: "UV 1" } });
assert.deepEqual(result.values, { circuitCombined: "UV 1-2F1.1", designation: "Steckdose", electricalPowerW: 240, voltageV: 230, currentA: 1.16 });
assert.equal(result.differsFromImported, false);
assert.deepEqual(result.warnings, []);
});
it("uses object planning without a row and leaves an uncomputable current empty", () => {
const input = object(); input.circuitDeviceRowId = null; input.planningValues.cosPhi = null;
const result = projectExternalXlsxReturn({ object: input, row: null, circuitMode: "separate", singlePhaseVoltageV: 230, threePhaseVoltageV: 400 });
assert.equal(result.values.boardName, "");
assert.equal(result.values.circuitIdentifier, "");
assert.equal(result.values.electricalPowerW, 240);
assert.equal(result.values.currentA, null);
assert.equal(result.differsFromImported, true);
assert.match(result.warnings.join(" "), /Stromstärke/);
});
it("uses three-phase current and object-specific effective quantity", () => {
const input = object(); input.planningValues.category = "three_phase"; input.planningValues.effectiveQuantity = 3;
const result = projectExternalXlsxReturn({ object: input, row: null, circuitMode: "combined", singlePhaseVoltageV: 230, threePhaseVoltageV: 400 });
assert.equal(result.values.electricalPowerW, 360);
assert.equal(result.values.voltageV, 400);
assert.equal(result.values.currentA, 0.58);
});
});