Übergabestand 2026-11-24
Alpenwerk HR 0.2.2 - C-Level als Auswahl aus der fachlichen Liste (C1 … VD) statt Ja/Nein; überall als Code angezeigt - Standorte mit Unterstandorten: bei „Shop“ folgt die Auswahl des einzelnen Shops - Angehörige und Notfallkontakte im Import: Verhältnis aus der Liste, bei „Sonstige“ mit eigenem Text - Wochenstunden mit zwei Nachkommastellen (z. B. 19,25) - Langzeitabwesenheit: „Endet am“ statt Rückkehr; eine anschliessende Abwesenheit lässt sich nur nach der Wochenhilfe (Mutterschutz) planen - Notizen mit Fälligkeit erscheinen erst ab diesem Tag in der Glocke - Testinstallationen: mit TESTSYSTEM=1 in app.env trägt jede Seite den Schriftzug „Testsystem“ und einen roten Rahmen - Next.js 16.4.6
This commit is contained in:
@@ -5,6 +5,7 @@ import { fmtName } from "../format";
|
||||
import { pruefePlz } from "../plz";
|
||||
import { requiresAustrianSvnr, svnrErrorMessage, svnrHaeltAuf, validateSvnr } from "../svnr";
|
||||
import type { Database } from "../types";
|
||||
import { SONSTIGE, verhaeltnisAusDatei } from "../verhaeltnis";
|
||||
import { pruefsumme } from "./abgleich";
|
||||
import { BLAETTER, WIRKSAM_AB, type Blatt, type Spalte } from "./katalog";
|
||||
import {
|
||||
@@ -158,7 +159,7 @@ async function rufe(tx: Tx, fn: MutationFn, payload: Record<string, unknown>): P
|
||||
|
||||
/** Lookups, die sich mit jedem Blatt ändern können: was die Datei neu anlegt, gilt sofort. */
|
||||
type Bestand = {
|
||||
standorte: Map<string, { id: string; name: string; country: string }>;
|
||||
standorte: Map<string, { id: string; name: string; country: string; parent_id: string | null }>;
|
||||
kostenstellen: Map<string, { id: string; name: string }>;
|
||||
einheiten: Map<string, Record<string, unknown> & { id: string }>;
|
||||
planstellen: Map<string, Record<string, unknown> & { id: string }>;
|
||||
@@ -168,7 +169,7 @@ type Bestand = {
|
||||
|
||||
async function bestandLaden(tx: Tx, heute: string): Promise<Bestand> {
|
||||
const [standorte, kostenstellen, einheiten, planstellen, personen, hr] = await Promise.all([
|
||||
tx.selectFrom("locations").select(["id", "name", "country"]).execute(),
|
||||
tx.selectFrom("locations").select(["id", "name", "country", "parent_id"]).execute(),
|
||||
tx.selectFrom("cost_centers").select(["id", "code", "name"]).execute(),
|
||||
tx
|
||||
.selectFrom("org_units as u")
|
||||
@@ -649,6 +650,15 @@ function mitarbeiterZeile(
|
||||
const planstelle = (n: unknown) => bestand.planstellen.get(String(n));
|
||||
if (zeile.wert("location_id") && !standortId(zeile.wert("location_id"))) {
|
||||
zeile.fehler(`Den Standort „${String(zeile.wert("location_id"))}“ gibt es nicht (auch nicht im Blatt „Standorte“).`, "location_id");
|
||||
} else if (zeile.wert("location_id")) {
|
||||
const id = standortId(zeile.wert("location_id"));
|
||||
const unter = [...bestand.standorte.values()].filter((s) => s.parent_id === id).map((s) => s.name);
|
||||
if (unter.length > 0) {
|
||||
zeile.fehler(
|
||||
`„${String(zeile.wert("location_id"))}“ fasst mehrere Standorte zusammen. Bitte einen davon angeben: ${unter.sort((a, b) => a.localeCompare(b, "de")).join(", ")}.`,
|
||||
"location_id"
|
||||
);
|
||||
}
|
||||
}
|
||||
if (zeile.wert("zustaendige_hr_id") && !hrId(zeile.wert("zustaendige_hr_id"))) {
|
||||
zeile.fehler(`„${String(zeile.wert("zustaendige_hr_id"))}“ ist kein aktives HR-Konto.`, "zustaendige_hr_id");
|
||||
@@ -943,6 +953,34 @@ function eintragZu(zeile: Zeile, aktuell: Datensaetze, person: Person) {
|
||||
return eintrag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Das Verhältnis, wie es gespeichert wird: aus der Auswahl und dem Text zu
|
||||
* „Sonstige" (lib/verhaeltnis.ts). Steht eine der beiden Spalten nicht in
|
||||
* der Zeile, gilt der bisherige Wert — der Text aber nur, solange
|
||||
* „Sonstige" gewählt bleibt. `undefined` bei einem Widerspruch.
|
||||
*/
|
||||
function verhaeltnisDerZeile(zeile: Zeile, feld: string, alt: Record<string, unknown> | null): string | null | undefined {
|
||||
const textFeld = `${feld}_sonstige`;
|
||||
const auswahl = (zeile.gesetzt(feld) ? zeile.wert(feld) : alt?.[feld]) as string | null | undefined;
|
||||
const text = (zeile.gesetzt(textFeld) ? zeile.wert(textFeld) : auswahl === SONSTIGE ? alt?.[textFeld] : null) as
|
||||
| string
|
||||
| null
|
||||
| undefined;
|
||||
const ergebnis = verhaeltnisAusDatei(auswahl, text);
|
||||
if ("fehler" in ergebnis) {
|
||||
zeile.fehler(ergebnis.fehler, textFeld);
|
||||
return undefined;
|
||||
}
|
||||
return ergebnis.wert;
|
||||
}
|
||||
|
||||
/** Die geänderten Felder für die SQL-Funktion: Auswahl und Text als ein Verhältnis. */
|
||||
function mitVerhaeltnis(g: Map<string, unknown>, feld: string, wert: string | null): Record<string, unknown> {
|
||||
const out = Object.fromEntries(g);
|
||||
delete out[`${feld}_sonstige`];
|
||||
return { ...out, [feld]: wert };
|
||||
}
|
||||
|
||||
function angehoerigerZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Datensaetze, { modus, heute }: { modus: Modus; heute: string }) {
|
||||
const person = personZu(zeile, bestand);
|
||||
if (!person) return;
|
||||
@@ -953,9 +991,15 @@ function angehoerigerZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Date
|
||||
if (eintrag === null) {
|
||||
if (zeile.wert("entfernen") === "ja") return zeile.fehler("Ein neuer Eintrag lässt sich nicht entfernen.", "entfernen");
|
||||
if (!pflichtNeu(zeile)) return;
|
||||
const verhaeltnis = verhaeltnisDerZeile(zeile, "relationship", null);
|
||||
if (verhaeltnis === undefined) return;
|
||||
const g = zeile.geaendert(null);
|
||||
zeile.schritt("Angehörige:r angelegt", "last_name", async () => {
|
||||
await rufe(tx, "add_employee_dependent", { employee_id: person.id, effective_date: datum, ...Object.fromEntries(g) });
|
||||
await rufe(tx, "add_employee_dependent", {
|
||||
employee_id: person.id,
|
||||
effective_date: datum,
|
||||
...mitVerhaeltnis(g, "relationship", verhaeltnis),
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -968,6 +1012,8 @@ function angehoerigerZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Date
|
||||
});
|
||||
return;
|
||||
}
|
||||
const verhaeltnis = verhaeltnisDerZeile(zeile, "relationship", eintrag.werte);
|
||||
if (verhaeltnis === undefined) return;
|
||||
const g = zeile.geaendert(eintrag.werte, (f) => f !== "id" && f !== "entfernen");
|
||||
if (g.size === 0) return;
|
||||
const neu = { ...eintrag.werte, ...Object.fromEntries(g) };
|
||||
@@ -976,7 +1022,7 @@ function angehoerigerZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Date
|
||||
dependent_id: id,
|
||||
first_name: neu.first_name,
|
||||
last_name: neu.last_name,
|
||||
relationship: neu.relationship,
|
||||
relationship: verhaeltnis,
|
||||
birth_date: neu.birth_date ?? "",
|
||||
sv_nummer: neu.sv_nummer ?? "",
|
||||
});
|
||||
@@ -993,9 +1039,11 @@ function notfallkontaktZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Da
|
||||
if (eintrag === null) {
|
||||
if (zeile.wert("entfernen") === "ja") return zeile.fehler("Ein neuer Eintrag lässt sich nicht entfernen.", "entfernen");
|
||||
if (!pflichtNeu(zeile)) return;
|
||||
const verhaeltnis = verhaeltnisDerZeile(zeile, "relation", null);
|
||||
if (verhaeltnis === undefined) return;
|
||||
const g = zeile.geaendert(null);
|
||||
zeile.schritt("Notfallkontakt angelegt", "name", async () => {
|
||||
await rufe(tx, "add_emergency_contact", { employee_id: person.id, ...Object.fromEntries(g) });
|
||||
await rufe(tx, "add_emergency_contact", { employee_id: person.id, ...mitVerhaeltnis(g, "relation", verhaeltnis) });
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -1008,10 +1056,12 @@ function notfallkontaktZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Da
|
||||
});
|
||||
return;
|
||||
}
|
||||
const verhaeltnis = verhaeltnisDerZeile(zeile, "relation", eintrag.werte);
|
||||
if (verhaeltnis === undefined) return;
|
||||
const g = zeile.geaendert(eintrag.werte, (f) => f !== "id" && f !== "entfernen");
|
||||
if (g.size === 0) return;
|
||||
const neu = { ...eintrag.werte, ...Object.fromEntries(g) };
|
||||
zeile.schritt("Notfallkontakt geändert", [...g.keys()][0], async () => {
|
||||
await rufe(tx, "update_emergency_contact", { id, name: neu.name, phone: neu.phone, relation: neu.relation ?? "" });
|
||||
await rufe(tx, "update_emergency_contact", { id, name: neu.name, phone: neu.phone, relation: verhaeltnis ?? "" });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ const MITARBEITER_ROH: Spalte[] = [
|
||||
feld("Vertrag und Arbeitszeit", "Beschäftigungsausmaß", "Beschäftigungsausmaß", "employment_type", auswahlAusKarte("Beschäftigungsausmaß"), {
|
||||
hinweis: STUNDEN_HINWEIS,
|
||||
}),
|
||||
feld("Vertrag und Arbeitszeit", "Wochenstunden", "Wochenstunden", "weekly_hours", { art: "zahl", nachkomma: 1 }, {
|
||||
feld("Vertrag und Arbeitszeit", "Wochenstunden", "Wochenstunden", "weekly_hours", { art: "zahl", nachkomma: 2 }, {
|
||||
hinweis: STUNDEN_HINWEIS,
|
||||
}),
|
||||
feld("Vertrag und Arbeitszeit", "Arbeitstage", "Arbeitstage", "work_days", {
|
||||
@@ -273,7 +273,9 @@ const MITARBEITER_ROH: Spalte[] = [
|
||||
hinweis: "Pflicht bei Dienstwagen „Ja“.",
|
||||
}),
|
||||
feld("Vertrag und Arbeitszeit", "Laterale Führung", "Laterale Führung", "is_laterale_fuehrung", JA_NEIN),
|
||||
feld("Vertrag und Arbeitszeit", "C-Level", "C-Level", "is_c_level", JA_NEIN),
|
||||
feld("Vertrag und Arbeitszeit", "C-Level", "C-Level", "c_level", auswahlAusKarte("C-Level"), {
|
||||
hinweis: "Der Code aus der Liste, etwa „C9“.",
|
||||
}),
|
||||
feld("Vertrag und Arbeitszeit", "Besonderer Kündigungsschutz", "Besonderer Kündigungsschutz", "has_kuendigungsschutz", JA_NEIN),
|
||||
feld("Vertrag und Arbeitszeit", "Personenkreis", "Kündigungsschutz Personenkreis", "kuendigungsschutz_grund", auswahlAusKarte("Kündigungsschutz Personenkreis"), {
|
||||
hinweis: KUENDIGUNGSSCHUTZ_HINWEIS,
|
||||
@@ -328,7 +330,7 @@ const MITARBEITER_ROH: Spalte[] = [
|
||||
{
|
||||
titel: "Wochenstunden ab Rückkehr",
|
||||
feld: "rueckkehr_stunden",
|
||||
format: { art: "zahl", nachkomma: 1 },
|
||||
format: { art: "zahl", nachkomma: 2 },
|
||||
thema: "Langzeitabwesenheit",
|
||||
hinweis: "Pflicht bei „Reduziert“; weniger als 38,5.",
|
||||
},
|
||||
@@ -403,7 +405,7 @@ const MITARBEITER_ROH: Spalte[] = [
|
||||
const IMMER_BELEGT = new Set([
|
||||
"last_name", "first_name", "gender", "nationality", "location_id", "position_number", "job_title", "entry_date",
|
||||
"employment_type", "weekly_hours", "contract_type", "source", "worker_type", "mitarbeiterart", "collective_agreement",
|
||||
"work_days", "is_betriebsrat", "has_dienstwagen", "is_laterale_fuehrung", "is_c_level", "has_kuendigungsschutz",
|
||||
"work_days", "is_betriebsrat", "has_dienstwagen", "is_laterale_fuehrung", "has_kuendigungsschutz",
|
||||
"hat_aufenthaltstitel", "ist_beguenstigt_behindert", "has_bonusanspruch", "ist_uebernahme_leiharbeit",
|
||||
]);
|
||||
|
||||
@@ -469,8 +471,22 @@ const PERSONALNUMMER_VERWEIS: Spalte = {
|
||||
pflicht: true,
|
||||
};
|
||||
|
||||
/** Verhältnis bei Angehörigen und Notfallkontakten: Liste oder eigener Text. */
|
||||
const VERHAELTNIS: Format = { art: "auswahl", optionen: anzeigeAuswahl(EMERGENCY_RELATIONS), frei: true };
|
||||
/**
|
||||
* Verhältnis bei Angehörigen und Notfallkontakten: die Liste wie im Formular,
|
||||
* und für „Sonstige" eine Spalte daneben mit dem eigenen Text
|
||||
* (lib/verhaeltnis.ts).
|
||||
*/
|
||||
const VERHAELTNIS: Format = { art: "auswahl", optionen: anzeigeAuswahl(EMERGENCY_RELATIONS) };
|
||||
const VERHAELTNIS_HINWEIS = "Aus der Liste. Ist es keines davon: „Sonstige“ und den Text in der Spalte daneben.";
|
||||
|
||||
function verhaeltnisSonstige(feld: string): Spalte {
|
||||
return {
|
||||
titel: "Verhältnis (Sonstige)",
|
||||
feld,
|
||||
format: TEXT,
|
||||
hinweis: "Nur bei „Sonstige“, etwa Onkel oder Nachbarin. Leer bleibt es bei „Sonstige“.",
|
||||
};
|
||||
}
|
||||
|
||||
const ENTFERNEN: Spalte = {
|
||||
titel: "Entfernen",
|
||||
@@ -485,6 +501,7 @@ export const BLATT_ANGEHOERIGE: Blatt = {
|
||||
zweck: "Angehörige je Person. Leere ID = neu anlegen.",
|
||||
schluessel: PERSONALNUMMER_VERWEIS,
|
||||
wirksamAb: "Leer = heute. Gilt für Neuanlage und Entfernen.",
|
||||
bedingungen: [{ feld: "relationship_sonstige", art: "leer", wenn: { feld: "relationship", nicht: "Sonstige" } }],
|
||||
spalten: [
|
||||
{ titel: "ID", feld: "id", format: TEXT, hinweis: "Vergibt das System. Leer = neuer Eintrag." },
|
||||
{ titel: "Nachname", feld: "last_name", format: TEXT, pflichtNeu: true, pflicht: true },
|
||||
@@ -495,8 +512,9 @@ export const BLATT_ANGEHOERIGE: Blatt = {
|
||||
format: VERHAELTNIS,
|
||||
pflichtNeu: true,
|
||||
pflicht: true,
|
||||
hinweis: "Aus der Liste oder frei eingetragen, wie „Sonstige“ in der Personalakte.",
|
||||
hinweis: VERHAELTNIS_HINWEIS,
|
||||
},
|
||||
verhaeltnisSonstige("relationship_sonstige"),
|
||||
{ titel: "Geburtsdatum", feld: "birth_date", format: DATUM },
|
||||
{ titel: "SV-Nummer", feld: "sv_nummer", format: TEXT },
|
||||
ENTFERNEN,
|
||||
@@ -508,6 +526,7 @@ export const BLATT_NOTFALLKONTAKTE: Blatt = {
|
||||
zweck: "Notfallkontakte je Person. Leere ID = neu anlegen.",
|
||||
schluessel: PERSONALNUMMER_VERWEIS,
|
||||
wirksamAb: "Leer lassen: Notfallkontakte gelten sofort.",
|
||||
bedingungen: [{ feld: "relation_sonstige", art: "leer", wenn: { feld: "relation", nicht: "Sonstige" } }],
|
||||
spalten: [
|
||||
{ titel: "ID", feld: "id", format: TEXT, hinweis: "Vergibt das System. Leer = neuer Eintrag." },
|
||||
{ titel: "Name", feld: "name", format: TEXT, pflichtNeu: true, pflicht: true },
|
||||
@@ -516,8 +535,9 @@ export const BLATT_NOTFALLKONTAKTE: Blatt = {
|
||||
titel: "Verhältnis",
|
||||
feld: "relation",
|
||||
format: VERHAELTNIS,
|
||||
hinweis: "Aus der Liste oder frei eingetragen, wie „Sonstige“ in der Personalakte.",
|
||||
hinweis: VERHAELTNIS_HINWEIS,
|
||||
},
|
||||
verhaeltnisSonstige("relation_sonstige"),
|
||||
ENTFERNEN,
|
||||
],
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@ import { loadOrgMaps, type OrgMaps } from "../org";
|
||||
import { loadPlacements, loadReportingLineMap, type Placement } from "../placement";
|
||||
import { deriveStatusAsOf } from "../reports";
|
||||
import type { Database } from "../types";
|
||||
import { verhaeltnisFuerDatei } from "../verhaeltnis";
|
||||
import type { Listen } from "./herunterladen";
|
||||
import type { Datensatz } from "./herunterladen";
|
||||
|
||||
@@ -132,7 +133,14 @@ export async function ladeAngehoerige(tx: Tx, personen: readonly Person[]): Prom
|
||||
.orderBy("employee_id")
|
||||
.orderBy("created_at")
|
||||
.execute();
|
||||
return zeilen.map((z) => ({ schluessel: nummer.get(z.employee_id)!, kennung: z.id, werte: { ...z } }));
|
||||
return zeilen.map((z) => {
|
||||
const v = verhaeltnisFuerDatei(z.relationship);
|
||||
return {
|
||||
schluessel: nummer.get(z.employee_id)!,
|
||||
kennung: z.id,
|
||||
werte: { ...z, relationship: v.auswahl, relationship_sonstige: v.sonstige },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export async function ladeNotfallkontakte(tx: Tx, personen: readonly Person[]): Promise<Datensatz[]> {
|
||||
@@ -145,7 +153,14 @@ export async function ladeNotfallkontakte(tx: Tx, personen: readonly Person[]):
|
||||
.orderBy("employee_id")
|
||||
.orderBy("created_at")
|
||||
.execute();
|
||||
return zeilen.map((z) => ({ schluessel: nummer.get(z.employee_id)!, kennung: z.id, werte: { ...z } }));
|
||||
return zeilen.map((z) => {
|
||||
const v = verhaeltnisFuerDatei(z.relation);
|
||||
return {
|
||||
schluessel: nummer.get(z.employee_id)!,
|
||||
kennung: z.id,
|
||||
werte: { ...z, relation: v.auswahl, relation_sonstige: v.sonstige },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export async function ladeHistorie(tx: Tx, personen: readonly Person[], b: Bezuege): Promise<Datensatz[]> {
|
||||
@@ -242,7 +257,13 @@ export async function ladeStandorte(tx: Tx): Promise<Datensatz[]> {
|
||||
*/
|
||||
export async function ladeListen(tx: Tx, heute: string): Promise<Listen> {
|
||||
const [standorte, jobs, einheiten, stellen, kostenstellen, hr] = await Promise.all([
|
||||
tx.selectFrom("locations").select("name").orderBy("name").execute(),
|
||||
// Ohne zusammenfassende Standorte wie „Shop": auf ihnen sitzt niemand.
|
||||
tx
|
||||
.selectFrom("locations as l")
|
||||
.select("l.name")
|
||||
.where((eb) => eb.not(eb.exists(eb.selectFrom("locations as u").select("u.id").whereRef("u.parent_id", "=", "l.id"))))
|
||||
.orderBy("l.name")
|
||||
.execute(),
|
||||
tx.selectFrom("jobs").select("title").execute(),
|
||||
tx.selectFrom("org_units").select("org_number").where("valid_to", "is", null).orderBy("org_number").execute(),
|
||||
// Nur freie Planstellen: niemand sitzt heute oder später darauf, keine
|
||||
|
||||
@@ -80,7 +80,9 @@ export const GRUPPE_JE_FELD: Readonly<Record<string, "person" | "contract" | "ro
|
||||
is_betriebsrat: "role",
|
||||
has_dienstwagen: "role",
|
||||
is_laterale_fuehrung: "role",
|
||||
// Abgelöst durch c_level; die Feldkarte führt es weiter für ältere Einträge.
|
||||
is_c_level: "role",
|
||||
c_level: "role",
|
||||
dienstwagen_art: "role",
|
||||
lehrzeit_von: "role",
|
||||
lehrzeit_bis: "role",
|
||||
|
||||
Reference in New Issue
Block a user