0.17.2: Kostenart Fahrt (2 × Strecke × Einsatztage × Fahrzeuge)
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-21 15:22:39 +00:00
parent 4d82336f73
commit 4c9f0643d6
12 changed files with 91 additions and 39 deletions

View File

@@ -200,15 +200,17 @@ async function editor(id: string, gross: string | null): Promise<void> {
}
if (pfad === "saetze") {
// Sätze dieses Angebots (A36): ganze Gruppe zurückschreiben
const s = { stundensaetze: { ...d.saetze.stundensaetze }, zuschlaege: { ...d.saetze.zuschlaege }, mengen: { ...d.saetze.mengen }, stand: d.angebot.saetze?.stand ?? heute() };
(s as Zeile)[zid][feld] = wert ?? 0;
const s: Zeile = { stundensaetze: { ...d.saetze.stundensaetze }, zuschlaege: { ...d.saetze.zuschlaege }, mengen: { ...d.saetze.mengen }, kilometersatz: d.saetze.kilometersatz, stand: d.angebot.saetze?.stand ?? heute() };
if (zid === "km") s.kilometersatz = wert ?? 0;
else s[zid][feld] = wert ?? 0;
return api(`angebote/${id}`, "PATCH", { saetze: s });
}
let body: Zeile = { [feld]: wert };
if (pfad === "angebot-positionen" && feld === "art" && wert !== "alternativ") body = { ...body, grundposition_id: null };
if (pfad === "angebot-kosten" && feld === "kostenart") {
const kz = d.kosten.find((x: Zeile) => x.id === zid);
body = { ...body, lohnart: wert === "lohn" ? kz?.lohnart ?? "geselle" : null, ...(wert === "lohn" ? { einheit: "h" } : kz?.einheit === "h" ? { einheit: null } : {}) };
body = { ...body, lohnart: wert === "lohn" ? kz?.lohnart ?? "geselle" : null,
...(wert === "lohn" ? { einheit: "h" } : wert === "fahrt" ? { einheit: "km" } : ["h", "km"].includes(kz?.einheit) ? { einheit: null } : {}) };
}
return api(`${pfad}/${pfad === "angebote" ? id : zid}`, "PATCH", body);
};
@@ -386,8 +388,10 @@ async function editor(id: string, gross: string | null): Promise<void> {
const art = b.dataset.art!;
const p = pos(zid)!;
const blatt = p.mit_aufmass ? alsBlatt(p.aufmass) : null;
const fahrt = art === "fahrt";
const k = await api<Zeile>("angebot-kosten", "POST", { position_id: zid, kostenart: art, lohnart: art === "lohn" ? "geselle" : null, menge: art === "lohn" ? 0.1 : 1,
bezug: blatt?.menge?.trim() || null, einheit: art === "lohn" ? "h" : p.einheit ?? null, reihenfolge: kostenVon(zid).reduce((m, x) => Math.max(m, Number(x.reihenfolge) + 1), 0) });
beschreibung: fahrt ? "Fahrt zur Baustelle" : null,
bezug: fahrt ? null : blatt?.menge?.trim() || null, einheit: art === "lohn" ? "h" : fahrt ? "km" : p.einheit ?? null, reihenfolge: kostenVon(zid).reduce((m, x) => Math.max(m, Number(x.reihenfolge) + 1), 0) });
await neuLaden();
wurzel.querySelector<HTMLInputElement>(`[data-k="angebot-kosten:${k.id}:beschreibung"]`)?.focus();
return;
@@ -481,7 +485,7 @@ async function editor(id: string, gross: string | null): Promise<void> {
type Feldoptionen = { typ?: string; klasse?: string; leer?: string; spalte?: string; titel?: string; platz?: string; liste?: string; nurLesen?: boolean };
const feldBau = (frei: boolean) => (k: string, wert: unknown, o: Feldoptionen = {}) =>
`<input data-k="${k}"${o.typ ? ` data-typ="${o.typ}"` : ""}${o.leer ? ` data-leer="${o.leer}"` : ""}${o.spalte ? ` data-spalte="${o.spalte}"` : ""} value="${esc(wert)}"
${o.typ === "euro" || o.typ === "zahl" ? 'inputmode="decimal"' : ""} class="${o.klasse ?? ""}"${o.titel ? ` aria-label="${esc(o.titel)}"` : ""}${o.platz ? ` placeholder="${esc(o.platz)}"` : ""}${o.liste ? ` list="${o.liste}"` : ""}${frei ? "" : " disabled"}>`;
${o.typ === "euro" || o.typ === "zahl" ? 'inputmode="decimal"' : ""} class="${o.klasse ?? ""}"${o.titel ? ` aria-label="${esc(o.titel)}" title="${esc(o.titel)}"` : ""}${o.platz ? ` placeholder="${esc(o.platz)}"` : ""}${o.liste ? ` list="${o.liste}"` : ""}${frei ? "" : " disabled"}>`;
const auswahlBau = (frei: boolean) => (k: string, optionen: [string, string][], wert: string, titel: string) =>
`<select data-k="${k}" aria-label="${esc(titel)}"${frei ? "" : " disabled"}>${optionenHtml(optionen, wert)}</select>`;
const euroFeld = (c: number | null | undefined) => (c == null ? "" : formatEuro(Number(c), false));
@@ -498,17 +502,19 @@ function kostenTabelle(d: Zeile, p: Zeile, frei: boolean): string {
let lohnStd = 0, summe = 0;
const rumpf = zeilen.map((k: Zeile, i: number) => {
const z = r.kostenzeilen[i] ?? { kosten: 0, menge_gesamt: 0, aktiv: true, fehler: null };
const lohn = k.kostenart === "lohn";
const lohn = k.kostenart === "lohn", fahrt = k.kostenart === "fahrt", mitPers = lohn || fahrt;
if (lohn && z.aktiv) lohnStd += z.menge_gesamt;
if (z.aktiv) summe += z.kosten * menge;
// Fahrt: 2 × Strecke × Einsatztage × Fahrzeuge (Henning, 21.10.2026)
const fahrtText = fahrt && !z.fehler ? `<span class="kz-rechnung">2 × ${esc(k.bezug ?? "")} km × ${zahlText(k.menge)} ${Number(k.menge) === 1 ? "Tag" : "Tage"}${Number(k.personen ?? 1) !== 1 ? ` × ${zahlText(k.personen)} Fahrzeuge` : ""}</span>` : "";
return `<tr class="kz-${k.kostenart}${z.aktiv ? "" : " aus"}"><td>${auswahl(`angebot-kosten:${k.id}:kostenart`, KOSTENARTEN.map((x) => [x, KOSTENART_NAME[x]]), k.kostenart, "Kostenart")}</td>
<td>${feld(`angebot-kosten:${k.id}:beschreibung`, k.beschreibung ?? "", { klasse: "w-bez", titel: "Bezeichnung", platz: lohn ? "Tätigkeit" : "z. B. KVH 6/12" })}</td>
<td>${feld(`angebot-kosten:${k.id}:bezug`, k.bezug ?? "", { klasse: `am-formel w-bezug${z.fehler ? " mit-fehler" : ""}`, titel: "Bezug (Kürzel aus dem Mengenblatt, leer = je Einheit)", platz: `je ${p.einheit}`, liste: "am-kuerzel" })}${z.fehler ? `<span class="am-fehler">${esc(z.fehler)}</span>` : ""}</td>
<td>${feld(`angebot-kosten:${k.id}:menge`, zahlText(k.menge), { typ: "zahl", klasse: "zahl w-ansatz am-eingabe", titel: lohn ? "Std je Einheit" : "Menge je Einheit", spalte: `km-${p.id}` })}</td>
<td>${lohn ? feld(`angebot-kosten:${k.id}:personen`, zahlText(k.personen ?? 1), { typ: "zahl", klasse: "zahl w-pers am-eingabe", titel: "Personen" }) : ""}</td>
<td class="zahl"><b>${zahlDeutsch(z.menge_gesamt, lohn ? "h" : k.einheit)}</b>${lohn ? " h" : ""}</td>
<td>${lohn ? auswahl(`angebot-kosten:${k.id}:lohnart`, LOHNARTEN.map((x) => [x, LOHNART_NAME[x]]), k.lohnart ?? "geselle", "Lohnart") : feld(`angebot-kosten:${k.id}:einheit`, k.einheit ?? "", { klasse: "w-einheit", titel: "Einheit", platz: "Einheit", liste: "einheiten" })}</td>
<td>${feld(`angebot-kosten:${k.id}:ek`, euroFeld(k.ek), { typ: "euro", klasse: "zahl w-ek", leer: "null", titel: "Einkaufspreis", platz: lohn ? euroFeld(s.stundensaetze[k.lohnart ?? "geselle"]) : "0,00", spalte: `ke-${p.id}` })}</td>
<td>${feld(`angebot-kosten:${k.id}:beschreibung`, k.beschreibung ?? "", { klasse: "w-bez", titel: "Bezeichnung", platz: lohn ? "Tätigkeit" : fahrt ? "Fahrt zur Baustelle" : "z. B. KVH 6/12" })}${fahrtText}</td>
<td>${feld(`angebot-kosten:${k.id}:bezug`, k.bezug ?? "", { klasse: `am-formel w-bezug${z.fehler ? " mit-fehler" : ""}`, titel: fahrt ? "Strecke einfach in km" : "Bezug (Kürzel aus dem Mengenblatt, leer = je Einheit)", platz: fahrt ? "km einfach" : `je ${p.einheit}`, liste: "am-kuerzel" })}${z.fehler ? `<span class="am-fehler">${esc(z.fehler)}</span>` : ""}</td>
<td>${feld(`angebot-kosten:${k.id}:menge`, zahlText(k.menge), { typ: "zahl", klasse: "zahl w-ansatz am-eingabe", titel: lohn ? "Std je Einheit" : fahrt ? "Einsatztage" : "Menge je Einheit", platz: fahrt ? "Tage" : "", spalte: `km-${p.id}` })}</td>
<td>${mitPers ? feld(`angebot-kosten:${k.id}:personen`, zahlText(k.personen ?? 1), { typ: "zahl", klasse: "zahl w-pers am-eingabe", titel: fahrt ? "Fahrzeuge" : "Personen" }) : ""}</td>
<td class="zahl"><b>${zahlDeutsch(z.menge_gesamt, lohn ? "h" : k.einheit)}</b>${lohn ? " h" : fahrt ? " km" : ""}</td>
<td>${lohn ? auswahl(`angebot-kosten:${k.id}:lohnart`, LOHNARTEN.map((x) => [x, LOHNART_NAME[x]]), k.lohnart ?? "geselle", "Lohnart") : fahrt ? "" : feld(`angebot-kosten:${k.id}:einheit`, k.einheit ?? "", { klasse: "w-einheit", titel: "Einheit", platz: "Einheit", liste: "einheiten" })}</td>
<td>${feld(`angebot-kosten:${k.id}:ek`, euroFeld(k.ek), { typ: "euro", klasse: "zahl w-ek", leer: "null", titel: fahrt ? "Kosten je km" : "Einkaufspreis", platz: lohn ? euroFeld(s.stundensaetze[k.lohnart ?? "geselle"]) : fahrt ? euroFeld(s.kilometersatz ?? 50) : "0,00", spalte: `ke-${p.id}` })}</td>
<td>${feld(`angebot-kosten:${k.id}:faktor`, zahlText(k.faktor), { typ: "zahl", klasse: "zahl w-faktor", titel: "Faktor" })}</td>
<td class="zahl">${betrag(z.kosten * menge)}</td>
<td class="kz-aus"><input type="checkbox" data-k="angebot-kosten:${k.id}:aktiv" data-typ="bool"${z.aktiv ? " checked" : ""} title="notwendig" aria-label="notwendig"${frei ? "" : " disabled"}>${frei ? `<button class="weg" data-a="kosten-weg" data-id="${k.id}" title="Kostenzeile löschen" aria-label="Kostenzeile löschen">×</button>` : ""}</td></tr>`;
@@ -517,7 +523,7 @@ function kostenTabelle(d: Zeile, p: Zeile, frei: boolean): string {
return `<div class="kosten-rolle"><table class="kosten-tabelle am-t"><thead><tr><th>Art</th><th>Bezeichnung</th><th>Bezug</th><th class="zahl">Ansatz</th><th class="zahl">Pers.</th><th class="zahl">Menge</th><th>Lohnart / Einh.</th><th class="zahl">EK</th><th class="zahl">Faktor</th><th class="zahl">EK gesamt</th><th title="notwendig: abgewählte Zeilen zählen nicht">✓</th></tr></thead>
<tbody>${rumpf}<tr class="summe"><td colspan="5">Kosten gesamt${menge > 0 ? ` (${euro(r.kosten_je_einheit)} je ${esc(p.einheit)})` : ""}</td><td class="zahl">${lohnStd ? `${zahlDeutsch(lohnStd, "h")} h` : ""}</td><td colspan="3"></td><td class="zahl">${betrag(summe)}</td><td></td></tr></tbody></table></div>
${frei ? `<div class="knopfreihe">${KOSTENARTEN.map((x) => `<button class="neben klein" data-a="kosten-neu" data-art="${x}" data-id="${p.id}">+ ${KOSTENART_NAME[x]}</button>`).join("")}</div>` : ""}
<p class="hinweis-k">Menge = Bezug × Ansatz × Personen, wie in deiner Urkalk. Der Bezug ist ein Kürzel aus dem Mengenblatt (z. B. HL); leer heißt je ${esc(p.einheit)} der Position. Abgewählte Zeilen (✓) bleiben stehen und zählen nicht.</p>`;
<p class="hinweis-k">Menge = Bezug × Ansatz × Personen, wie in deiner Urkalk. Der Bezug ist ein Kürzel aus dem Mengenblatt (z. B. HL); leer heißt je ${esc(p.einheit)} der Position. Fahrt: Bezug = Strecke einfach in km, Ansatz = Einsatztage, Pers. = Fahrzeuge; gerechnet wird 2 × Strecke × Tage. Abgewählte Zeilen (✓) bleiben stehen und zählen nicht.</p>`;
}
/** „Verkauf und Zuschläge“ je Kostenart der Position, mit „Preis anpassen“ (A21) */
@@ -673,6 +679,7 @@ function seitenleiste(d: Zeile, z: Zustand, vorlagen: Mengenvorlage[], gross: st
<label>Wagnis<span class="mit-einheit">${feld("angebote:x:wagnis_prozent", zahlText(a.wagnis_prozent), { typ: "zahl", klasse: "zahl w-kurz" })} %</span></label>
<label>Gewinn<span class="mit-einheit">${feld("angebote:x:gewinn_prozent", zahlText(a.gewinn_prozent), { typ: "zahl", klasse: "zahl w-kurz" })} %</span></label>
<label>Ausfall<span class="mit-einheit">${feld("angebote:x:ausfall_prozent", zahlText(a.ausfall_prozent), { typ: "zahl", klasse: "zahl w-kurz" })} %</span></label>
<label title="Vorschlag für die Kostenart Fahrt">Fahrt je km<span class="mit-einheit">${feld("saetze:km:satz", euroFeld(s.kilometersatz ?? 50), { typ: "euro", klasse: "zahl w-euro" })}</span></label>
<span class="t">Mengen</span>
<label title="Im Mengenblatt als VERSCHNITT">Verschnitt<span class="mit-einheit">${feld("saetze:mengen:verschnitt", zahlText(s.mengen?.verschnitt), { typ: "zahl", klasse: "zahl w-kurz" })} %</span></label>
<label title="Im Mengenblatt als ÖFFNUNG_AB">Öffnungen abziehen ab<span class="mit-einheit">${feld("saetze:mengen:oeffnung_ab", zahlText(s.mengen?.oeffnung_ab), { typ: "zahl", klasse: "zahl w-kurz" })} m²</span></label></div>