Mehrere Notfallkontakte, Planstelle nicht vor ihrer Einheit, Anstehend fuehrt in die Historie, Uebernahme, Meine Notizen
- Notfallkontakte: eigene Tabelle employee_emergency_contacts (Migration 20261019160000), beliebig viele je Person, angelegt, geaendert und entfernt wie Angehoerige (add_/update_/delete_emergency_contact, mit Historie und Protokoll). Bestand uebernommen. Verhaeltnis-Liste wie bei den Angehoerigen (Ehepartner, Lebenspartner, Kind, Sonstige mit Freitext). Neueinstellung, Wiedereintritt, Import und Mitarbeiterexport schreiben und lesen die Tabelle. - Planstelle beginnt nicht vor und nicht nach dem Bestehen ihrer Organisationseinheit: Ausloeser an om_positions (Migration 20261019150000), gilt fuer Anlegen, Aendern und Klonen. - Anstehend auf der Uebersicht: Klick oeffnet die Akte im Reiter Historie, bei einer Wiedervorlage im Reiter HR-Notizen (?tab=). - Uebernahme: Vertrag zeigt Besetzungsart und "Uebernahme Ja/Nein" aus der Historie; die Kachel Eintritte (YTD) zaehlt Uebernahmen mit. - Glocke: "Meine Notizen" schaltet bei hinzugewaehlten Kollegen auf nur die eigenen Notizen um. Rauchtest Schritt 18. Geprueft: lint, tsc, types:check, 921 Tests, Waechter
This commit is contained in:
@@ -71,7 +71,9 @@ export async function loadDashboardData(tx: Tx, p: DashboardParams) {
|
||||
// counts too. `entry_date` would also sweep up rehires, whose event is
|
||||
// logged as 'Wiedereintritt' — the tile and its destination would then
|
||||
// show different numbers for the same year.
|
||||
jsonObjectFrom(countIn(eb, ["Eintritt", "Wiedereintritt"])).as("hiresYtd"),
|
||||
// Eine Übernahme von extern zählt wie ein Eintritt, fachlich so
|
||||
// vorgegeben: die Person kommt neu in den eigenen Bestand.
|
||||
jsonObjectFrom(countIn(eb, ["Eintritt", "Wiedereintritt", "Übernahme"])).as("hiresYtd"),
|
||||
jsonObjectFrom(countIn(eb, ["Austritt"])).as("exitsYtd"),
|
||||
|
||||
...orgMapsAbfragen(eb),
|
||||
|
||||
@@ -91,6 +91,15 @@ export async function loadEmployeeDetail(tx: Tx, id: string, today: string = tod
|
||||
.orderBy("created_at")
|
||||
).as("dependents"),
|
||||
|
||||
jsonArrayFrom(
|
||||
eb
|
||||
.selectFrom("employee_emergency_contacts")
|
||||
.select(["id", "employee_id", "name", "phone", "relation"])
|
||||
.select((x) => zeitstempel(x.ref("created_at")).as("created_at"))
|
||||
.where("employee_id", "=", id)
|
||||
.orderBy("created_at")
|
||||
).as("notfallkontakte"),
|
||||
|
||||
jsonArrayFrom(
|
||||
eb
|
||||
.selectFrom("employee_notes")
|
||||
@@ -175,6 +184,7 @@ export async function loadEmployeeDetail(tx: Tx, id: string, today: string = tod
|
||||
reports,
|
||||
history: g.history,
|
||||
dependents: g.dependents,
|
||||
notfallkontakte: g.notfallkontakte,
|
||||
notes: g.notes,
|
||||
orgMaps,
|
||||
placement,
|
||||
|
||||
@@ -63,6 +63,8 @@ export async function ladeExportMitarbeiter(
|
||||
/** Name je HR-Konto — für „Zuständige HR". */
|
||||
hrName: Map<string, string>;
|
||||
dependentsCounts: Map<string, number>;
|
||||
/** Die Notfallkontakte je Person, in der Reihenfolge ihrer Erfassung. */
|
||||
notfallkontakte: Map<string, { name: string; phone: string; relation: string | null }[]>;
|
||||
}> {
|
||||
const statuses = parseStatuses(filters.status);
|
||||
const stichtag = asOf ?? todayIso();
|
||||
@@ -84,7 +86,7 @@ export async function ladeExportMitarbeiter(
|
||||
return applyCriteria(q, criteria);
|
||||
}
|
||||
|
||||
const [employees, lookupResult, allEmployees, dependentsCounts, placements, lines, hrKonten] = await Promise.all([
|
||||
const [employees, lookupResult, allEmployees, dependentsCounts, placements, lines, hrKonten, kontakte] = await Promise.all([
|
||||
employeeQuery().execute(),
|
||||
loadOrgLookups(tx),
|
||||
// Absichtlich schmal: die Liste umfasst **alle** Personen, nicht nur die
|
||||
@@ -95,7 +97,19 @@ export async function ladeExportMitarbeiter(
|
||||
loadReportingLineMap(tx, stichtag),
|
||||
// Für „Zuständige HR": gespeichert ist die Kennung, in die Datei gehört der Name.
|
||||
tx.selectFrom("profiles").select(["id", "full_name", "email"]).where("role", "=", "hr").execute(),
|
||||
tx
|
||||
.selectFrom("employee_emergency_contacts")
|
||||
.select(["employee_id", "name", "phone", "relation"])
|
||||
.orderBy("employee_id")
|
||||
.orderBy("created_at")
|
||||
.execute(),
|
||||
]);
|
||||
const notfallkontakte = new Map<string, { name: string; phone: string; relation: string | null }[]>();
|
||||
for (const k of kontakte) {
|
||||
const liste = notfallkontakte.get(k.employee_id) ?? [];
|
||||
liste.push({ name: k.name, phone: k.phone, relation: k.relation });
|
||||
notfallkontakte.set(k.employee_id, liste);
|
||||
}
|
||||
|
||||
const orgMaps = lookupResult.orgMaps;
|
||||
// Der Einheitenfilter meint den ganzen Teilbaum — sonst enthielte ein
|
||||
@@ -133,5 +147,6 @@ export async function ladeExportMitarbeiter(
|
||||
managerKennung: new Map(allEmployees.map((e) => [e.id, e.cornerstone_id])),
|
||||
hrName: new Map(hrKonten.map((p) => [p.id, p.full_name?.trim() || p.email])),
|
||||
dependentsCounts,
|
||||
notfallkontakte,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@ export async function laden(
|
||||
const personId = new Map(bestand.personalnummern);
|
||||
const personenZeilen = hole("Personen");
|
||||
const besetzungen: { position_id: string; employee_id: string; valid_from: string; valid_to: string | null }[] = [];
|
||||
const notfallkontakte: { employee_id: string; name: string; phone: string; relation: string | null }[] = [];
|
||||
|
||||
for (const z of personenZeilen) {
|
||||
const w = z.werte;
|
||||
@@ -242,9 +243,6 @@ export async function laden(
|
||||
// so verlangt es chk_dienstwagen_art. Fehlt die Angabe in der Datei,
|
||||
// gilt Verbrenner, wie im übernommenen Bestand.
|
||||
dienstwagen_art: bool(w.has_dienstwagen, false) ? (txt(w.dienstwagen_art) ?? "Verbrenner") : null,
|
||||
emergency_contact_name: txt(w.emergency_contact_name),
|
||||
emergency_contact_phone: txt(w.emergency_contact_phone),
|
||||
emergency_contact_relation: txt(w.emergency_contact_relation),
|
||||
is_laterale_fuehrung: bool(w.is_laterale_fuehrung, false),
|
||||
is_c_level: bool(w.is_c_level, false),
|
||||
has_kuendigungsschutz: bool(w.has_kuendigungsschutz, false),
|
||||
@@ -281,6 +279,19 @@ export async function laden(
|
||||
|
||||
personId.set(r.rows[0].personnel_number, r.rows[0].id);
|
||||
|
||||
// Der Notfallkontakt aus der Datei — in die eigene Tabelle, wie in der
|
||||
// Akte (20261019160000). Name und Nummer nur gemeinsam.
|
||||
const kontaktName = txt(w.emergency_contact_name);
|
||||
const kontaktTelefon = txt(w.emergency_contact_phone);
|
||||
if (kontaktName && kontaktTelefon) {
|
||||
notfallkontakte.push({
|
||||
employee_id: r.rows[0].id,
|
||||
name: kontaktName,
|
||||
phone: kontaktTelefon,
|
||||
relation: txt(w.emergency_contact_relation),
|
||||
});
|
||||
}
|
||||
|
||||
const stelle = txt(w.position_number);
|
||||
if (stelle) {
|
||||
besetzungen.push({
|
||||
@@ -300,6 +311,7 @@ export async function laden(
|
||||
// Index — beim Import wie im Assistenten.
|
||||
|
||||
await einfuegen(tx, "position_assignments", besetzungen);
|
||||
await einfuegen(tx, "employee_emergency_contacts", notfallkontakte);
|
||||
|
||||
// ── Historie und Angehörige ───────────────────────────────────
|
||||
const historie = hole("Historie").map((z) => ({
|
||||
|
||||
@@ -30,7 +30,7 @@ export const KPI_ERKLAERUNGEN: Record<string, string> = {
|
||||
"Vollzeitäquivalente der Personen im Headcount Aktiv: Summe ihrer Wochenstunden geteilt durch 38,5. " +
|
||||
"Eine Vollzeitkraft zählt 1,0, eine Teilzeitkraft mit 19,25 Stunden 0,5. Langzeitabwesende zählen nicht.",
|
||||
"Eintritte (YTD)":
|
||||
"Eintritte und Wiedereintritte vom 1. Jänner bis heute (YTD = year to date). " +
|
||||
"Eintritte, Wiedereintritte und Übernahmen von extern vom 1. Jänner bis heute (YTD = year to date). " +
|
||||
"Eintritte, die erst nach heute beginnen, zählen noch nicht.",
|
||||
"Austritte (YTD)":
|
||||
"Austritte mit Austrittsdatum vom 1. Jänner bis heute (YTD = year to date), einschliesslich „Nicht angetreten“. " +
|
||||
|
||||
38
lib/types.ts
38
lib/types.ts
@@ -130,18 +130,9 @@ export type KuendigungsschutzGrund =
|
||||
* „Sonstige" frei eingetragen wird, steht als eigener Text in der Spalte
|
||||
* (VerhaeltnisField).
|
||||
*/
|
||||
export const EMERGENCY_RELATIONS = [
|
||||
"Ehepartner:in",
|
||||
"Lebenspartner:in",
|
||||
"Mutter",
|
||||
"Vater",
|
||||
"Tochter",
|
||||
"Sohn",
|
||||
"Schwester",
|
||||
"Bruder",
|
||||
"Freundin/Freund",
|
||||
"Sonstige",
|
||||
] as const;
|
||||
// Dieselbe Liste wie bei den Angehörigen, fachlich so vorgegeben; alles
|
||||
// Weitere — Eltern, Geschwister, Nachbarn — unter „Sonstige" als freier Text.
|
||||
export const EMERGENCY_RELATIONS = ["Ehepartner:in", "Lebenspartner:in", "Kind", "Sonstige"] as const;
|
||||
|
||||
export type EmergencyRelation = (typeof EMERGENCY_RELATIONS)[number];
|
||||
|
||||
@@ -468,6 +459,26 @@ export type Database = {
|
||||
};
|
||||
Update: Partial<Database["public"]["Tables"]["employee_dependents"]["Insert"]>;
|
||||
};
|
||||
// Notfallkontakte, beliebig viele je Person (20261019160000).
|
||||
employee_emergency_contacts: {
|
||||
Row: {
|
||||
id: string;
|
||||
employee_id: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
relation: string | null;
|
||||
created_at: string;
|
||||
};
|
||||
Insert: {
|
||||
id?: string;
|
||||
employee_id: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
relation?: string | null;
|
||||
created_at?: string;
|
||||
};
|
||||
Update: Partial<Database["public"]["Tables"]["employee_emergency_contacts"]["Insert"]>;
|
||||
};
|
||||
employee_notes: {
|
||||
Row: {
|
||||
id: string;
|
||||
@@ -839,6 +850,9 @@ export type Database = {
|
||||
// werden konnte (20261019140000).
|
||||
austritt_zuruecknehmen: { Args: { payload: Record<string, unknown> }; Returns: string | null };
|
||||
eintritt_planstelle_berichtigen: { Args: { payload: Record<string, unknown> }; Returns: void };
|
||||
add_emergency_contact: { Args: { payload: Record<string, unknown> }; Returns: string };
|
||||
update_emergency_contact: { Args: { payload: Record<string, unknown> }; Returns: void };
|
||||
delete_emergency_contact: { Args: { payload: Record<string, unknown> }; Returns: void };
|
||||
// Eigenes Passwort wechseln. Die einzige mutierende Funktion **ohne**
|
||||
// require_hr_admin() — sonst käme niemand aus dem erzwungenen Wechsel
|
||||
// heraus, denn solange er aussteht, ist is_hr_user() false.
|
||||
|
||||
Reference in New Issue
Block a user