Revert "Akte, Reiter Organisation: Stellenverlauf"
This reverts commit a6a360f770.
This commit is contained in:
@@ -19,7 +19,7 @@ export default async function EmployeeDetailPage({ params, searchParams }: PageP
|
||||
const data = await withUser(userId, (tx) => loadEmployeeDetail(tx, id, today));
|
||||
|
||||
if (!data) notFound();
|
||||
const { employee, line, reports, history, dependents, notfallkontakte, notes, orgMaps, placement, kostenstelle, stellenverlauf, onboarding, offboarding, openPositions, byId } = data;
|
||||
const { employee, line, reports, history, dependents, notfallkontakte, notes, orgMaps, placement, kostenstelle, onboarding, offboarding, openPositions, byId } = data;
|
||||
|
||||
return (
|
||||
<EmployeeDetail
|
||||
@@ -34,7 +34,6 @@ export default async function EmployeeDetailPage({ params, searchParams }: PageP
|
||||
}
|
||||
breadcrumb={breadcrumbLabel(orgMaps, placement?.orgUnitId)}
|
||||
kostenstelle={kostenstelle}
|
||||
stellenverlauf={stellenverlauf}
|
||||
onboarding={onboarding}
|
||||
offboarding={offboarding}
|
||||
manager={(line?.acting_manager_id ? byId.get(line.acting_manager_id) : null) ?? null}
|
||||
|
||||
@@ -7,7 +7,6 @@ import { Avatar } from "@/components/ui/Avatar";
|
||||
import { Button } from "@/components/ui/Button";
|
||||
import { StatusChip } from "@/components/ui/StatusChip";
|
||||
import { abwesenheitsplan } from "@/lib/abwesenheitsplan";
|
||||
import type { StellenAbschnitt } from "@/lib/stellenverlauf";
|
||||
import { rueckkehrNachListe, type Checkliste } from "@/lib/checklist";
|
||||
import { fmtFullName, tenure } from "@/lib/format";
|
||||
import { fortschritt as fortschrittOffboarding, gehoertOffboarding } from "@/lib/offboarding";
|
||||
@@ -46,8 +45,6 @@ type EmployeeDetailProps = {
|
||||
breadcrumb: string;
|
||||
/** Die Kostenstelle der laufenden Planstellenbesetzung. */
|
||||
kostenstelle: { code: string; name: string } | null;
|
||||
/** Alle Besetzungen der Person, jüngste zuerst (lib/stellenverlauf.ts). */
|
||||
stellenverlauf: StellenAbschnitt[];
|
||||
/** Die Onboarding-Checklisten, jüngste zuerst; leer heisst: es gibt keine. */
|
||||
onboarding: Checkliste[];
|
||||
/** Die Offboarding-Checklisten, jüngste zuerst; leer heisst: es gibt keine. */
|
||||
@@ -74,7 +71,7 @@ const ALLE_TABS = ["Stammdaten", "Vertrag", "Organisation", "Onboarding", "Offbo
|
||||
type Tab = (typeof ALLE_TABS)[number];
|
||||
|
||||
export function EmployeeDetail(props: EmployeeDetailProps) {
|
||||
const { employee, placement, breadcrumb, kostenstelle, stellenverlauf, onboarding, offboarding, manager, formalManager, directReports, history, dependents, notes, locations, openPositions, today } = props;
|
||||
const { employee, placement, breadcrumb, kostenstelle, onboarding, offboarding, manager, formalManager, directReports, history, dependents, notes, locations, openPositions, today } = props;
|
||||
// Wer aus „Anstehend" kommt, will den Vorgang sehen und nicht die
|
||||
// Stammdaten — die Übersicht verlinkt deshalb mit ?tab=. Unbekanntes führt
|
||||
// auf die Stammdaten.
|
||||
@@ -250,7 +247,6 @@ export function EmployeeDetail(props: EmployeeDetailProps) {
|
||||
directReports={directReports}
|
||||
breadcrumb={breadcrumb}
|
||||
kostenstelle={kostenstelle}
|
||||
stellenverlauf={stellenverlauf}
|
||||
/>
|
||||
)}
|
||||
{tab === "Onboarding" && (
|
||||
|
||||
@@ -2,8 +2,7 @@ import { Network } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { Avatar } from "@/components/ui/Avatar";
|
||||
import { LINK_BUTTON_CLASS } from "@/components/ui/Button";
|
||||
import { fmtDate, fmtName } from "@/lib/format";
|
||||
import type { StellenAbschnitt } from "@/lib/stellenverlauf";
|
||||
import { fmtName } from "@/lib/format";
|
||||
|
||||
type MiniEmployee = { id: string; first_name: string; last_name: string; job_title: string; status?: string };
|
||||
|
||||
@@ -20,8 +19,6 @@ type OrganisationTabProps = {
|
||||
* hat die Person keine laufende Besetzung (geplanter Eintritt, Austritt).
|
||||
*/
|
||||
kostenstelle: { code: string; name: string } | null;
|
||||
/** Alle Besetzungen, jüngste zuerst. */
|
||||
stellenverlauf: StellenAbschnitt[];
|
||||
};
|
||||
|
||||
// Die Niederlassung steht fachlich bewusst nicht hier neben Einheit und
|
||||
@@ -34,7 +31,6 @@ export function OrganisationTab({
|
||||
directReports,
|
||||
breadcrumb,
|
||||
kostenstelle,
|
||||
stellenverlauf,
|
||||
}: OrganisationTabProps) {
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
@@ -108,49 +104,6 @@ export function OrganisationTab({
|
||||
<p className="text-sm text-ink-muted">Keine direkten Berichte.</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 className="mb-2 text-xs font-semibold uppercase tracking-wide text-ink-muted">Stellenverlauf</h3>
|
||||
{stellenverlauf.length > 0 ? (
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="border-b border-border text-left text-[11px] font-bold uppercase tracking-wider text-ink-muted">
|
||||
<th className="py-2 pr-4">Von</th>
|
||||
<th className="py-2 pr-4">Bis</th>
|
||||
<th className="py-2 pr-4">Planstelle</th>
|
||||
<th className="py-2 pr-4">Organisationseinheit</th>
|
||||
<th className="py-2 pr-4">Kostenstelle</th>
|
||||
<th className="py-2">Anlass</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{stellenverlauf.map((s) => (
|
||||
<tr key={`${s.von}-${s.planstelle}`} className={`border-b border-border-subtle align-top ${s.laufend ? "font-semibold text-ink" : "text-ink-body"}`}>
|
||||
<td className="whitespace-nowrap py-2 pr-4 tabular-nums">{fmtDate(s.von)}</td>
|
||||
<td className="whitespace-nowrap py-2 pr-4 tabular-nums">{s.bis ? fmtDate(s.bis) : "–"}</td>
|
||||
<td className="py-2 pr-4">
|
||||
<span className="tabular-nums">{s.planstelle}</span>
|
||||
<span className="font-normal text-ink-muted"> · {s.taetigkeit}</span>
|
||||
{s.leitung && <span className="font-normal text-ink-muted"> (Leitung)</span>}
|
||||
</td>
|
||||
<td className="py-2 pr-4">{s.einheit ?? "–"}</td>
|
||||
<td className="py-2 pr-4 tabular-nums" title={s.kostenstelle?.name}>
|
||||
{s.kostenstelle ? s.kostenstelle.code : "–"}
|
||||
</td>
|
||||
<td className="py-2 font-normal">{s.anlass ?? "–"}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
{/* Bis ist der letzte Tag auf der Stelle; der nächste Abschnitt
|
||||
beginnt am Tag danach. Fett steht die Besetzung zum Stichtag
|
||||
der Akte. */}
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-sm text-ink-muted">Keine Planstellenbesetzung erfasst.</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import { todayIso } from "./format";
|
||||
import { buildOrgMaps, orgMapsAbfragen } from "./org";
|
||||
import { berichtslinienAbfrage, besetzungenAbfrage, orgAsOf, pickPlacements } from "./placement";
|
||||
import { offeneStellenAbfrage, resolveOpenPositions, type OffeneStelle } from "./positions";
|
||||
import { stellenverlauf } from "./stellenverlauf";
|
||||
|
||||
// Was die Mitarbeiterakte liest — gebündelt in vier Rundreisen. Ein
|
||||
// Promise.all brächte keine Gleichzeitigkeit: eine Transaktion hängt an einer
|
||||
@@ -200,13 +199,6 @@ export async function loadEmployeeDetail(tx: Tx, id: string, today: string = tod
|
||||
placement,
|
||||
// Die Kostenstelle des Sitzes, auf dem die Person am Stichtag sitzt.
|
||||
kostenstelle: placement ? (kontierungZum(g.costRows as KontierungsZeile[], asOf).get(placement.positionId) ?? null) : null,
|
||||
stellenverlauf: stellenverlauf(
|
||||
g.placementRows as never,
|
||||
g.history,
|
||||
g.costRows as KontierungsZeile[],
|
||||
(unitId) => orgMaps.units.get(unitId)?.name ?? null,
|
||||
asOf
|
||||
),
|
||||
// Jüngste zuerst; bearbeitet wird nur die jüngste einer Art.
|
||||
onboarding: listenDerArt(g.checklisten as never, g.onboarding as never, "onboarding"),
|
||||
offboarding: listenDerArt(g.checklisten as never, g.offboarding as never, "offboarding"),
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
import { kontierungZum, type KontierungsZeile } from "./cost-centers";
|
||||
import { addDaysIso } from "./format";
|
||||
|
||||
// Auf welcher Planstelle eine Person von wann bis wann sass.
|
||||
//
|
||||
// Gelesen aus den Besetzungen selbst, nicht aus den Texten der Historie: die
|
||||
// Besetzung ist, worauf Organigramm, Berichte und Exporte sich stützen. Stehen
|
||||
// Historie und Besetzung einmal nicht im Einklang, sieht man es hier, statt es
|
||||
// aus einzelnen Einträgen zusammensetzen zu müssen.
|
||||
|
||||
export type StellenAbschnitt = {
|
||||
von: string;
|
||||
/** Der letzte Tag auf der Stelle; leer, solange die Besetzung läuft. */
|
||||
bis: string | null;
|
||||
planstelle: string;
|
||||
taetigkeit: string;
|
||||
leitung: boolean;
|
||||
einheit: string | null;
|
||||
kostenstelle: { code: string; name: string } | null;
|
||||
/** Der Vorgang, mit dem der Abschnitt beginnt — aus der Historie, am selben Tag. */
|
||||
anlass: string | null;
|
||||
/** Läuft am Stichtag der Akte. */
|
||||
laufend: boolean;
|
||||
};
|
||||
|
||||
type Besetzung = {
|
||||
valid_from: string;
|
||||
valid_to: string | null;
|
||||
position_id: string;
|
||||
position_number: string;
|
||||
org_unit_id: string;
|
||||
is_chief: boolean;
|
||||
job_title: string;
|
||||
};
|
||||
|
||||
type Ereignis = { event_type: string; event_date: string; pending_id: string | null };
|
||||
|
||||
/** Vorgänge, mit denen eine Besetzung beginnt — in dieser Reihenfolge bevorzugt. */
|
||||
const BEGINNT_MIT = ["Eintritt", "Wiedereintritt", "Versetzung", "Beförderung"] as const;
|
||||
|
||||
export function stellenverlauf(
|
||||
besetzungen: Besetzung[],
|
||||
historie: Ereignis[],
|
||||
kontierungen: KontierungsZeile[],
|
||||
einheitName: (orgUnitId: string) => string | null,
|
||||
asOf: string
|
||||
): StellenAbschnitt[] {
|
||||
// Nur durchgeführte Vorgänge: ein vorgemerkter hat noch keine Besetzung.
|
||||
const durchgefuehrt = historie.filter((h) => h.pending_id === null || h.event_date <= asOf);
|
||||
return [...besetzungen]
|
||||
.sort((a, b) => b.valid_from.localeCompare(a.valid_from))
|
||||
.map((b) => {
|
||||
const laufend = b.valid_from <= asOf && (b.valid_to === null || b.valid_to > asOf);
|
||||
// Die Kostenstelle zum letzten Tag auf der Stelle, bei einer laufenden
|
||||
// zum Stichtag — so wie die Akte sie heute nennt.
|
||||
const bis = b.valid_to === null ? null : addDaysIso(b.valid_to, -1);
|
||||
const zum = laufend || bis === null ? (asOf < b.valid_from ? b.valid_from : asOf) : bis;
|
||||
const kst = kontierungZum(kontierungen, zum).get(b.position_id);
|
||||
const anlass =
|
||||
BEGINNT_MIT.find((t) => durchgefuehrt.some((h) => h.event_type === t && h.event_date === b.valid_from)) ?? null;
|
||||
return {
|
||||
von: b.valid_from,
|
||||
bis,
|
||||
planstelle: b.position_number,
|
||||
taetigkeit: b.job_title,
|
||||
leitung: b.is_chief,
|
||||
einheit: einheitName(b.org_unit_id),
|
||||
kostenstelle: kst ? { code: kst.code, name: kst.name } : null,
|
||||
anlass,
|
||||
laufend,
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { stellenverlauf } from "@/lib/stellenverlauf";
|
||||
|
||||
const stelle = (nr: string, von: string, bis: string | null) => ({
|
||||
valid_from: von,
|
||||
valid_to: bis,
|
||||
position_id: `p-${nr}`,
|
||||
position_number: nr,
|
||||
org_unit_id: `u-${nr}`,
|
||||
is_chief: false,
|
||||
job_title: `Tätigkeit ${nr}`,
|
||||
});
|
||||
|
||||
describe("stellenverlauf", () => {
|
||||
// Eintritt, Versetzung zum 15., Versetzung zum 19. — wie bei einem Lehrling
|
||||
// mit zwei Wechseln im ersten Monat.
|
||||
const besetzungen = [stelle("A", "2026-10-01", "2026-10-15"), stelle("C", "2026-10-19", null), stelle("B", "2026-10-15", "2026-10-19")];
|
||||
const historie = [
|
||||
{ event_type: "Eintritt", event_date: "2026-10-01", pending_id: null },
|
||||
{ event_type: "Stammdatenänderung", event_date: "2026-10-15", pending_id: null },
|
||||
{ event_type: "Versetzung", event_date: "2026-10-15", pending_id: null },
|
||||
{ event_type: "Versetzung", event_date: "2026-10-19", pending_id: null },
|
||||
// Vorgemerkt und noch nicht wirksam: kein Abschnitt.
|
||||
{ event_type: "Versetzung", event_date: "2027-01-01", pending_id: "q1" },
|
||||
];
|
||||
const kontierungen = [
|
||||
{ position_id: "p-B", cost_center_id: "k1", code: "1000", name: "Alt", valid_from: "2020-01-01", valid_to: "2026-10-17" },
|
||||
{ position_id: "p-B", cost_center_id: "k2", code: "2000", name: "Neu", valid_from: "2026-10-17", valid_to: null },
|
||||
];
|
||||
const verlauf = stellenverlauf(besetzungen, historie, kontierungen, (id) => `Einheit ${id}`, "2026-11-03");
|
||||
|
||||
it("ordnet jüngste zuerst und nennt den letzten Tag auf der Stelle", () => {
|
||||
expect(verlauf.map((s) => [s.planstelle, s.von, s.bis])).toEqual([
|
||||
["C", "2026-10-19", null],
|
||||
["B", "2026-10-15", "2026-10-18"],
|
||||
["A", "2026-10-01", "2026-10-14"],
|
||||
]);
|
||||
});
|
||||
|
||||
it("nimmt den Anlass aus der Historie desselben Tages", () => {
|
||||
expect(verlauf.map((s) => s.anlass)).toEqual(["Versetzung", "Versetzung", "Eintritt"]);
|
||||
});
|
||||
|
||||
it("markiert die laufende Besetzung und nennt die Kostenstelle zum letzten Tag", () => {
|
||||
expect(verlauf.map((s) => s.laufend)).toEqual([true, false, false]);
|
||||
expect(verlauf[1].kostenstelle).toEqual({ code: "2000", name: "Neu" });
|
||||
expect(verlauf[1].einheit).toBe("Einheit u-B");
|
||||
});
|
||||
|
||||
it("lässt den Anlass leer, wenn am Tag kein Vorgang steht", () => {
|
||||
const ohne = stellenverlauf([stelle("A", "2026-10-01", null)], [], [], () => null, "2026-11-03");
|
||||
expect(ohne[0]).toMatchObject({ anlass: null, einheit: null, kostenstelle: null, laufend: true });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user