Add estimate row project device handoff
This commit is contained in:
parent
8b1923e8ec
commit
a6500e2b26
9 changed files with 434 additions and 21 deletions
|
|
@ -28,6 +28,7 @@ import {
|
|||
getTodayIsoDate,
|
||||
parseGermanDecimal,
|
||||
} from "../src/frontend/estimate-balance/estimate-balance-format.js";
|
||||
import { createEstimateProjectDeviceInitialValues } from "../src/frontend/estimate-balance/estimate-project-device-prefill.js";
|
||||
import {
|
||||
ApiRequestError,
|
||||
createEstimateBalance,
|
||||
|
|
@ -264,6 +265,55 @@ describe("estimate balance document editing", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("estimate row to project device prefill", () => {
|
||||
it("maps a piece row to one reusable project-device template", () => {
|
||||
const balance = sampleBalance();
|
||||
const group = balance.groups[0]!;
|
||||
const row = {
|
||||
...group.rows[0]!,
|
||||
name: " Hebeanlage ",
|
||||
quantity: 4,
|
||||
connection: "fixed" as const,
|
||||
powerPerUnitW: 1250,
|
||||
simultaneityFactor: 0.8,
|
||||
cosPhi: 0.9,
|
||||
remark: "bauseits",
|
||||
};
|
||||
|
||||
assert.deepEqual(createEstimateProjectDeviceInitialValues(group, row), {
|
||||
name: "Hebeanlage",
|
||||
displayName: "Hebeanlage",
|
||||
category: "single_phase",
|
||||
connectionKind: "Festanschluss",
|
||||
costGroup: "410",
|
||||
quantity: 1,
|
||||
powerPerUnit: 1.25,
|
||||
simultaneityFactor: 0.8,
|
||||
cosPhi: 0.9,
|
||||
remark: "bauseits",
|
||||
});
|
||||
});
|
||||
|
||||
it("leaves quantity and power blank for an area row", () => {
|
||||
const balance = sampleBalance();
|
||||
const group = balance.groups[1]!;
|
||||
const row = {
|
||||
...createEstimateRow(0, () => "area-row"),
|
||||
name: "Bürofläche",
|
||||
unit: "area" as const,
|
||||
connection: "socket" as const,
|
||||
quantity: 250,
|
||||
powerPerUnitW: 15,
|
||||
};
|
||||
|
||||
const initial = createEstimateProjectDeviceInitialValues(group, row);
|
||||
assert.equal(initial.quantity, null);
|
||||
assert.equal(initial.powerPerUnit, null);
|
||||
assert.equal(initial.connectionKind, "Steckdose");
|
||||
assert.equal(initial.costGroup, "440");
|
||||
});
|
||||
});
|
||||
|
||||
describe("estimate balance saving", () => {
|
||||
it("builds the trimmed server document with null for empty optional texts", () => {
|
||||
let balance = sampleBalance();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue