Zeiterfassung mit Pausenabzug, offline am Handy, Ansicht für alle (0.9.0)
Some checks failed
Prüfung / tests (push) Has been cancelled
Prüfung / container (push) Has been cancelled

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmyPfuNc4sCRfaF3oURXZz
This commit is contained in:
Claude
2026-10-20 06:43:52 +00:00
parent 859a076e83
commit e4754f329a
16 changed files with 832 additions and 18 deletions

59
test/zeit.test.ts Normal file
View File

@@ -0,0 +1,59 @@
import { describe, it, expect } from "vitest";
import { dauerText, minuten, rechneTag, regelPause, uhrzeit } from "../src/domain/zeit.js";
const h = (s: string) => minuten(s);
describe("Pausenabzug nach M3", () => {
it("Regel: bis 6 Std keiner, über 6 bis 9 Std 30 Min, über 9 bis 10 Std 45 Min, über 10 Std 1 Std", () => {
expect([h("6:00"), h("6:01"), h("9:00"), h("9:01"), h("10:00"), h("10:01"), h("12:00")].map(regelPause)).toEqual([0, 30, 30, 45, 45, 60, 60]);
});
it.each([
// Anwesenheit, Abzug bis zur Grenze, Netto, Abzug voll, Netto voll
["5:59", 0, "5:59", 0, "5:59"],
["6:00", 0, "6:00", 0, "6:00"],
["6:10", 10, "6:00", 30, "5:40"],
["6:30", 30, "6:00", 30, "6:00"],
["8:30", 30, "8:00", 30, "8:00"],
["9:00", 30, "8:30", 30, "8:30"],
["9:10", 40, "8:30", 45, "8:25"],
["9:20", 45, "8:35", 45, "8:35"],
["10:00", 45, "9:15", 45, "9:15"],
["10:10", 55, "9:15", 60, "9:10"],
["11:00", 60, "10:00", 60, "10:00"],
])("%s anwesend", (an, abzug, netto, abzugVoll, nettoVoll) => {
const g = rechneTag(h(an), 0, true, "bis_grenze");
expect([g.abzug, dauerText(g.netto)]).toEqual([abzug, netto]);
const v = rechneTag(h(an), 0, true, "voll");
expect([v.abzug, dauerText(v.netto)]).toEqual([abzugVoll, nettoVoll]);
});
it("länger da sein ergibt bis zur Grenze nie weniger Stunden", () => {
let vorher = 0;
for (let m = 0; m <= 14 * 60; m++) {
const n = rechneTag(m, 0, true).netto;
expect(n).toBeGreaterThanOrEqual(vorher);
vorher = n;
}
});
it("von Hand eingetragene Pausen werden angerechnet, der Rest wird abgezogen", () => {
expect(rechneTag(h("7:00"), 15, true)).toMatchObject({ handPause: 15, abzug: 15, netto: h("6:30") });
expect(rechneTag(h("8:00"), 45, true)).toMatchObject({ handPause: 45, abzug: 0, netto: h("7:15") });
expect(rechneTag(h("10:30"), 90, true)).toMatchObject({ abzug: 0, netto: h("9:00") });
});
it("nicht für den Inhaber; Hinweis über 10 Std", () => {
expect(rechneTag(h("11:00"), 0, false)).toMatchObject({ abzug: 0, netto: h("11:00"), ueberZehn: true });
expect(rechneTag(h("11:00"), 0, true).ueberZehn).toBe(false);
expect(rechneTag(h("11:30"), 0, true).ueberZehn).toBe(true);
});
it("Uhrzeiten", () => {
expect(minuten("7:05")).toBe(425);
expect(uhrzeit(425)).toBe("07:05");
expect(minuten("16:30:00")).toBe(990);
expect(() => minuten("25:00")).toThrow();
expect(dauerText(-30)).toBe("−0:30");
});
});