Files
Betriebsf-hrungssoftware/test/stundensatz.test.ts
Claude 45c21943bf
Some checks failed
Prüfung / tests (push) Has been cancelled
Prüfung / container (push) Has been cancelled
Stundensätze im Personalmodul, Übergabe ans Angebot (0.26.0)
Rechentabellen je Lohnart wie Hennings Excel (Zeit, Kosten, Vollkostensatz),
Mittellohn mit Schaltern, Versionen mit gilt ab. Excel-Fassung centgenau
(80,38 / 107,81 EUR), Fassung nach S2 mit Akquise/Verwaltung als Kosten.
Angebote schreiben die geltenden Sätze fest, Lohnzuschlag 0 %, Nachfrage
bei neuer Version.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmyPfuNc4sCRfaF3oURXZz
2026-10-22 06:55:22 +00:00

86 lines
3.9 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from "vitest";
import { rechneStundensaetze, saetzeFuerAngebot, schluesselFuer, zeitRechnen } from "../src/domain/stundensatz.js";
import { stundensaetzeAusExcel, stundensaetzeNachS2 } from "../src/domain/stundensatz-excel.js";
const umfeld = { koepfe: 2, personen: { chef: 1, geselle: 1 }, laufend: {} };
describe("Stundensätze wie Hennings Excel (Abnahme M19)", () => {
const e = rechneStundensaetze(stundensaetzeAusExcel(), umfeld);
const t = (id: string) => e.tabellen.find((x) => x.id === id)!;
it("Personalzeit: 2.000 Std Jahresarbeitszeit, 208 Tage anwesend, 1.184 produktive Std", () => {
const z = t("chef").zeit;
expect(z.jahresStd).toBe(2000);
expect(z.ausfallStd).toBe(336);
expect(z.anwesenheitTage).toBe(208);
expect(z.produktiv).toBe(1184);
expect(z.unproduktiv.map((u) => u.tage)).toEqual([11, 11, 26, 13]);
});
it("Chef: 95.174,51 € im Jahr = 80,38 €/Std", () => {
expect(t("chef").summe / 100).toBeCloseTo(95174.51237, 2);
expect(t("chef").satz).toBe(8038);
expect(t("chef").bloecke.map((b) => Math.round(b.bis) / 100)).toEqual([51548.57, 71137.03, 71787.03, 86981.44, 95174.51]);
});
it("Planer: 127.648,54 € im Jahr = 107,81 €/Std", () => {
expect(t("planer").summe / 100).toBeCloseTo(127648.544, 2);
expect(t("planer").satz).toBe(10781);
});
it("Mittellohn 60,63 € und Gemeinkostenanteil 19,75 € beim Chef", () => {
expect(t("chef").lohnkostensatz).toBe(6063);
expect(t("chef").gemeinkostenanteil).toBe(1975);
});
it("Umsatzbedarf 183.027,91 € (Chef-Blatt) und 131.596,44 € (Planer-Blatt)", () => {
expect(Math.round(t("chef").umsatzbedarf) / 100).toBe(183027.91);
expect(Math.round(t("planer").umsatzbedarf) / 100).toBe(131596.44);
});
it("Mittellohn gewichtet nach Stunden: Chef und Geselle gleich", () => {
expect(e.mittellohn.satz).toBe(8038);
expect(e.mittellohn.personen).toBe(2);
expect(saetzeFuerAngebot(e).stundensaetze).toMatchObject({ mittellohn: 8038, chef: 8038, planer: 10781, geselle: 8038 });
});
});
describe("Fassung nach S2: Akquise und Verwaltung als Kosten", () => {
const d = stundensaetzeNachS2(stundensaetzeAusExcel());
const e = rechneStundensaetze(d, umfeld);
const chef = e.tabellen.find((x) => x.id === "chef")!;
it("kein Zeitabzug mehr: 1.352 produktive Std", () => expect(chef.zeit.produktiv).toBe(1352));
it("14 Std/Monat × Lohnkostensatz des Gesellen, keine pauschalen 65 € mehr", () => {
const lks = Math.round(7178702.857142859 / 1352);
expect(e.bewertungssatz).toBe(lks);
const z = chef.zeilen.filter((x) => x.ausZeit);
expect(z.map((x) => x.jahr)).toEqual([84 * lks, 84 * lks]);
expect(chef.zeilen.some((x) => x.name === "Verwaltung" && !x.ausZeit)).toBe(false);
expect(chef.satz).toBe(Math.round((9517451.237156226 - 624000 + 168 * lks) / 1352));
});
it("Mittellohn gewichtet: Σ(Satz × Std × Personen) ÷ Σ(Std × Personen)", () => {
const x = structuredClone(d);
x.tabellen.find((t) => t.id === "geselle")!.kosten[0]!.betrag = 250000;
x.mittellohn.geselle = { an: true, personen: 2 };
const r = rechneStundensaetze(x, umfeld);
const c = r.tabellen.find((t) => t.id === "chef")!, g = r.tabellen.find((t) => t.id === "geselle")!;
expect(r.mittellohn.satz).toBe(Math.round((c.satz * c.zeit.produktiv + g.satz * g.zeit.produktiv * 2) / (c.zeit.produktiv + g.zeit.produktiv * 2)));
});
});
describe("Hilfen", () => {
it("Schlüssel aus dem Namen, eindeutig", () => {
expect(schluesselFuer("2. Vorarbeiter", [])).toBe("2-vorarbeiter");
expect(schluesselFuer("Geselle", ["geselle"])).toBe("geselle-2");
expect(schluesselFuer("Mittellohn", [])).toBe("lohnart");
});
it("Rüstzeit je Anwesenheitstag", () => {
const t = stundensaetzeAusExcel().tabellen[0]!;
t.zeit.ausfall[0]!.tage = 25;
expect(zeitRechnen(t).unproduktiv[2]!.std).toBe(213);
});
});