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:
@@ -156,8 +156,19 @@ export async function hireEmployee(payload: {
|
||||
// Einzige Mutation, deren Rückgabewert gebraucht wird: die neue
|
||||
// Personen-Kennung, damit die Oberfläche direkt auf die Akte springen kann.
|
||||
try {
|
||||
// Der Notfallkontakt geht in die eigene Tabelle (20261019160000), nicht
|
||||
// in die Spalten an employees — dieselbe Stelle, an der die Akte liest.
|
||||
const { emergency_contact_name, emergency_contact_phone, emergency_contact_relation, ...person } = payload;
|
||||
const employeeId = await withUser(await currentUserId(), async (tx) => {
|
||||
const id = (await callFunction(tx, "hire_employee", payload as Record<string, unknown>)) as string;
|
||||
const id = (await callFunction(tx, "hire_employee", person as Record<string, unknown>)) as string;
|
||||
if (emergency_contact_name?.trim()) {
|
||||
await callFunction(tx, "add_emergency_contact", {
|
||||
employee_id: id,
|
||||
name: emergency_contact_name,
|
||||
phone: emergency_contact_phone,
|
||||
relation: emergency_contact_relation,
|
||||
});
|
||||
}
|
||||
// In derselben Transaktion: eine Einstellung ohne Checkliste wäre eine
|
||||
// halb erfasste Einstellung, und sie später nachzureichen hiesse, dass
|
||||
// jemand daran denken muss.
|
||||
@@ -345,9 +356,30 @@ export async function rehireEmployee(payload: {
|
||||
*/
|
||||
[feld: string]: unknown;
|
||||
}): Promise<ActionResult> {
|
||||
// Notfallkontakte stehen in eigener Tabelle (20261019160000). Was der
|
||||
// Assistent zeigt, kommt hinzu, wenn es dort noch nicht steht — die
|
||||
// Kontakte vom ersten Eintritt bleiben.
|
||||
const { emergency_contact_name, emergency_contact_phone, emergency_contact_relation, ...rest } = payload;
|
||||
const kontaktName = typeof emergency_contact_name === "string" ? emergency_contact_name.trim() : "";
|
||||
const kontaktTelefon = typeof emergency_contact_phone === "string" ? emergency_contact_phone.trim() : "";
|
||||
try {
|
||||
await withUser(await currentUserId(), async (tx) => {
|
||||
await callFunction(tx, "rehire_employee", payload as unknown as Record<string, unknown>);
|
||||
await callFunction(tx, "rehire_employee", rest as unknown as Record<string, unknown>);
|
||||
if (kontaktName && kontaktTelefon) {
|
||||
const vorhanden = await tx
|
||||
.selectFrom("employee_emergency_contacts")
|
||||
.select(["name", "phone"])
|
||||
.where("employee_id", "=", payload.employee_id)
|
||||
.execute();
|
||||
if (!vorhanden.some((k) => k.name === kontaktName && k.phone === kontaktTelefon)) {
|
||||
await callFunction(tx, "add_emergency_contact", {
|
||||
employee_id: payload.employee_id,
|
||||
name: kontaktName,
|
||||
phone: kontaktTelefon,
|
||||
relation: emergency_contact_relation,
|
||||
});
|
||||
}
|
||||
}
|
||||
// Auch bei der Wiedereinstellung: Dienstzettel, Bankverbindung und
|
||||
// E-Card sind wieder zu erledigen. Die Punkte vom ersten Eintritt
|
||||
// bleiben stehen — start_onboarding legt nur an, was fehlt, statt
|
||||
@@ -539,6 +571,31 @@ export async function eintrittPlanstelleBerichtigen(payload: { employee_id: stri
|
||||
return callRpc("eintritt_planstelle_berichtigen", payload, [`/employees/${payload.employee_id}`, "/employees", "/positions"]);
|
||||
}
|
||||
|
||||
// ── Notfallkontakte (20261019160000) ─────────────────────────────────────
|
||||
export async function addEmergencyContact(payload: {
|
||||
employee_id: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
relation?: string;
|
||||
}): Promise<ActionResult> {
|
||||
return callRpc("add_emergency_contact", payload, [`/employees/${payload.employee_id}`]);
|
||||
}
|
||||
|
||||
export async function updateEmergencyContact(payload: {
|
||||
id: string;
|
||||
employee_id: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
relation?: string;
|
||||
}): Promise<ActionResult> {
|
||||
const { employee_id, ...angaben } = payload;
|
||||
return callRpc("update_emergency_contact", angaben, [`/employees/${employee_id}`]);
|
||||
}
|
||||
|
||||
export async function deleteEmergencyContact(payload: { id: string; employee_id: string }): Promise<ActionResult> {
|
||||
return callRpc("delete_emergency_contact", { id: payload.id }, [`/employees/${payload.employee_id}`]);
|
||||
}
|
||||
|
||||
/** Eine irrtümlich erfasste Notiz löschen — nur durch die Verfasserin. */
|
||||
export async function deleteEmployeeNote(payload: { note_id: string; employee_id: string }): Promise<ActionResult> {
|
||||
return callRpc("delete_employee_note", { note_id: payload.note_id }, [`/employees/${payload.employee_id}`, "/"]);
|
||||
|
||||
Reference in New Issue
Block a user