Projektseite wie Plancraft, Zahlungsplan automatisch, Spaltenbreiten im Terminplan (0.6.0)
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:
@@ -241,28 +241,42 @@ describe.skipIf(!url)("Übernahme aus V70 über die API", () => {
|
||||
expect((await app.inject(`/api/projekte/${p.id}`)).json().baustelle_ort).toBe("Mölln");
|
||||
});
|
||||
|
||||
it("Zahlungsplan wird als Meilensteine vorgeschlagen und wandert mit seinem Vorgang", async () => {
|
||||
it("Zahlungsplan entsteht automatisch, folgt Auftragswert und Terminen, bis er von Hand geändert wird", async () => {
|
||||
const neu = async (pfad: string, body: object) => (await app.inject({ method: "POST", url: `/api/${pfad}`, payload: body })).json();
|
||||
const raten = async (id: string) => (await app.inject("/api/zahlungen")).json()
|
||||
.filter((z: { projekt_id: string }) => z.projekt_id === id).sort((a: { reihenfolge: number }, b: { reihenfolge: number }) => a.reihenfolge - b.reihenfolge);
|
||||
const p = await neu("projekte", { nummer: "P-26-098", bezeichnung: "Dachstuhl Ziegelei" });
|
||||
expect((await app.inject({ method: "POST", url: `/api/projekte/${p.id}/zahlungsplan` })).statusCode).toBe(400);
|
||||
await app.inject({ method: "PATCH", url: `/api/projekte/${p.id}`, payload: { umsatz_netto: 2_000_000 } });
|
||||
expect(await raten(p.id)).toHaveLength(0); // noch keine Termine
|
||||
const a = await neu("abschnitte", { projekt_id: p.id, name: "Ausführung" });
|
||||
const richten = await neu("vorgaenge", { abschnitt_id: a.id, name: "Richten", start: "2026-11-02", dauer: 2 });
|
||||
await neu("vorgaenge", { abschnitt_id: a.id, name: "Dach", start: "2026-11-09", dauer: 3 });
|
||||
const r = await app.inject({ method: "POST", url: `/api/projekte/${p.id}/zahlungsplan` });
|
||||
expect(r.statusCode, r.body).toBe(201);
|
||||
const raten = r.json();
|
||||
expect(raten.map((z: { netto: number }) => z.netto)).toEqual([600_000, 800_000, 400_000, 200_000]);
|
||||
expect(raten[1]).toMatchObject({ vorgang_id: richten.id, termin: "2026-11-03" });
|
||||
expect((await raten(p.id)).map((z: { netto: number }) => z.netto)).toEqual([600_000, 800_000, 400_000, 200_000]);
|
||||
// ein später angelegter Vorgang „Richten“ bekommt die 40-%-Rate
|
||||
const richten = await neu("vorgaenge", { abschnitt_id: a.id, name: "Richten", start: "2026-11-02", dauer: 2 });
|
||||
expect((await raten(p.id))[1]).toMatchObject({ vorgang_id: richten.id, termin: "2026-11-03" });
|
||||
// neuer Auftragswert: Raten anteilig
|
||||
await app.inject({ method: "PATCH", url: `/api/projekte/${p.id}`, payload: { umsatz_netto: 3_000_000 } });
|
||||
expect((await raten(p.id)).map((z: { netto: number }) => z.netto)).toEqual([900_000, 1_200_000, 600_000, 300_000]);
|
||||
expect((await app.inject({ method: "POST", url: `/api/projekte/${p.id}/zahlungsplan` })).statusCode).toBe(409);
|
||||
// Richten verschiebt sich um eine Woche: die geplante Rate geht mit
|
||||
await app.inject({ method: "PATCH", url: `/api/vorgaenge/${richten.id}`, payload: { start: "2026-11-09" } });
|
||||
expect((await app.inject(`/api/zahlungen/${raten[1].id}`)).json().termin).toBe("2026-11-10");
|
||||
// gestellte Raten bleiben stehen
|
||||
await app.inject({ method: "PATCH", url: `/api/zahlungen/${raten[1].id}`, payload: { status: "gestellt" } });
|
||||
const r1 = (await raten(p.id))[1];
|
||||
expect(r1.termin).toBe("2026-11-10");
|
||||
// von Hand geändert: Plan ist fest, Auftragswert ändert die Raten nicht mehr
|
||||
await app.inject({ method: "PATCH", url: `/api/zahlungen/${r1.id}`, payload: { netto: 1_000_000 } });
|
||||
expect((await app.inject(`/api/projekte/${p.id}`)).json().zahlungsplan).toBe("fest");
|
||||
await app.inject({ method: "PATCH", url: `/api/projekte/${p.id}`, payload: { umsatz_netto: 4_000_000 } });
|
||||
expect((await raten(p.id))[1].netto).toBe(1_000_000);
|
||||
// gestellte Raten bleiben stehen, geplante wandern weiter mit
|
||||
await app.inject({ method: "PATCH", url: `/api/zahlungen/${r1.id}`, payload: { status: "gestellt" } });
|
||||
await app.inject({ method: "PATCH", url: `/api/vorgaenge/${richten.id}`, payload: { start: "2026-11-16" } });
|
||||
expect((await app.inject(`/api/zahlungen/${raten[1].id}`)).json().termin).toBe("2026-11-10");
|
||||
expect((await app.inject(`/api/zahlungen/${r1.id}`)).json().termin).toBe("2026-11-10");
|
||||
expect((await app.inject("/api/terminplan")).json().zahlungen.filter((z: { projekt_id: string }) => z.projekt_id === p.id)).toHaveLength(4);
|
||||
// alle gelöscht: es kommt kein neuer automatisch
|
||||
for (const z of await raten(p.id)) await app.inject({ method: "DELETE", url: `/api/zahlungen/${z.id}` });
|
||||
await neu("vorgaenge", { abschnitt_id: a.id, name: "Abnahme", start: "2026-11-30", dauer: 0 });
|
||||
expect(await raten(p.id)).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("Kalender-Abo nur mit gültigem Geheimnis", async () => {
|
||||
@@ -302,6 +316,23 @@ describe.skipIf(!url)("Projektordner in der Nextcloud über die API", () => {
|
||||
expect(f.relativ()).toContain("02 laufende Projekte/P-26-021 Carport Most/02 Umsetzung");
|
||||
});
|
||||
|
||||
it("Ablage zeigt den Projektordner und reicht Dateien durch", async () => {
|
||||
const p = (await app.inject({ method: "POST", url: "/api/projekte", payload: { nummer: "P-26-022", bezeichnung: "Gaube Lüth", status: "auftrag" } })).json();
|
||||
f.dateien.set(`${f.wurzel}/${p.nextcloud_link}/01 Auftrag/Angebot A-26-140.pdf`, "%PDF-Probe");
|
||||
const wurzel = (await app.inject(`/api/projekte/${p.id}/ablage`)).json();
|
||||
expect(wurzel.eintraege.map((e: { name: string }) => e.name)).toEqual(["01 Auftrag", "02 Umsetzung", "03 Bilder"]);
|
||||
const auftrag = (await app.inject(`/api/projekte/${p.id}/ablage?pfad=${encodeURIComponent("01 Auftrag")}`)).json();
|
||||
expect(auftrag.eintraege).toEqual([
|
||||
{ name: "03 Stundenlohnarb.", ordner: true, groesse: 0, geaendert: null },
|
||||
{ name: "Angebot A-26-140.pdf", ordner: false, groesse: 10, geaendert: "2026-10-19T08:00:00.000Z" },
|
||||
]);
|
||||
const d = await app.inject(`/api/projekte/${p.id}/ablage/datei?pfad=${encodeURIComponent("01 Auftrag/Angebot A-26-140.pdf")}`);
|
||||
expect(d.statusCode).toBe(200);
|
||||
expect(d.body).toBe("%PDF-Probe");
|
||||
expect((await app.inject(`/api/projekte/${p.id}/ablage?pfad=..%2F..`)).statusCode).toBe(400);
|
||||
expect((await app.inject(`/api/projekte/${p.id}/ablage/datei?pfad=gibtsnicht.pdf`)).statusCode).toBe(404);
|
||||
});
|
||||
|
||||
it("Fehler der Nextcloud verhindert das Speichern nicht", async () => {
|
||||
f.ordner.clear(); // Wurzel fehlt: jede Anlage schlägt fehl
|
||||
const r = await app.inject({ method: "POST", url: "/api/projekte", payload: { nummer: "A-26-131", bezeichnung: "Gaube", status: "angebot" } });
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Nextcloud } from "../src/server/nextcloud.js";
|
||||
|
||||
/** Kleine WebDAV-Nachbildung im Speicher: nur Ordner, wie Nextcloud sie beantwortet */
|
||||
/** Kleine WebDAV-Nachbildung im Speicher: Ordner und Dateien, wie Nextcloud sie beantwortet */
|
||||
export function falscheNextcloud(basis = "https://cloud.test/remote.php/dav/files/henning/Projekte") {
|
||||
const ordner = new Set<string>();
|
||||
const dateien = new Map<string, string>();
|
||||
const pfad = (u: string) => decodeURIComponent(new URL(u).pathname).replace(/\/+$/, "");
|
||||
const wurzel = pfad(basis);
|
||||
ordner.add(wurzel);
|
||||
@@ -13,10 +14,16 @@ export function falscheNextcloud(basis = "https://cloud.test/remote.php/dav/file
|
||||
switch (init?.method) {
|
||||
case "PROPFIND": {
|
||||
if (!ordner.has(p)) return new Response(null, { status: 404 });
|
||||
const kinder = kopf.depth === "1" ? [...ordner].filter((o) => o.startsWith(p + "/") && !o.slice(p.length + 1).includes("/")) : [];
|
||||
const hrefs = [p, ...kinder].map((o) => `<d:response><d:href>${o.split("/").map(encodeURIComponent).join("/")}/</d:href></d:response>`).join("");
|
||||
const direkt = (o: string) => o.startsWith(p + "/") && !o.slice(p.length + 1).includes("/");
|
||||
const kinder = kopf.depth === "1" ? [...ordner].filter(direkt) : [];
|
||||
const href = (o: string) => o.split("/").map(encodeURIComponent).join("/");
|
||||
const hrefs = [p, ...kinder].map((o) => `<d:response><d:href>${href(o)}/</d:href><d:propstat><d:prop><d:resourcetype><d:collection/></d:resourcetype></d:prop></d:propstat></d:response>`).join("")
|
||||
+ (kopf.depth === "1" ? [...dateien].filter(([d]) => direkt(d)).map(([d, inhalt]) =>
|
||||
`<d:response><d:href>${href(d)}</d:href><d:propstat><d:prop><d:resourcetype/><d:getcontentlength>${inhalt.length}</d:getcontentlength><d:getlastmodified>Mon, 19 Oct 2026 08:00:00 GMT</d:getlastmodified></d:prop></d:propstat></d:response>`).join("") : "");
|
||||
return new Response(`<?xml version="1.0"?><d:multistatus xmlns:d="DAV:">${hrefs}</d:multistatus>`, { status: 207 });
|
||||
}
|
||||
case "GET":
|
||||
return dateien.has(p) ? new Response(dateien.get(p)!, { status: 200, headers: { "content-type": "application/pdf" } }) : new Response(null, { status: 404 });
|
||||
case "MKCOL":
|
||||
if (ordner.has(p)) return new Response(null, { status: 405 });
|
||||
if (!ordner.has(eltern)) return new Response(null, { status: 409 });
|
||||
@@ -32,5 +39,5 @@ export function falscheNextcloud(basis = "https://cloud.test/remote.php/dav/file
|
||||
return new Response(null, { status: 400 });
|
||||
}) as typeof fetch;
|
||||
const relativ = () => [...ordner].filter((o) => o !== wurzel).map((o) => o.slice(wurzel.length + 1)).sort();
|
||||
return { nc: new Nextcloud({ url: basis, benutzer: "henning", passwort: "geheim" }, abruf), ordner, wurzel, relativ };
|
||||
return { nc: new Nextcloud({ url: basis, benutzer: "henning", passwort: "geheim" }, abruf), ordner, dateien, wurzel, relativ };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user