Versetzung mit Standortwechsel; Standort aenderbar ueber change_employee_data
All checks were successful
CI / Lint, Typen, Tests, Build (push) Successful in 12m1s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m40s
CI / Ausrollen (push) Successful in 6s

- Versetzen: Feld "Standort", vorbelegt mit dem bisherigen. Ein anderer
  Standort wechselt zum selben Tag, in derselben Transaktion wie die
  Versetzung (sofort oder vorgemerkt).
- change_employee_data, Nachtlauf und Feldkarte kennen den Standort
  (Gruppe role): Historienzeile "Standort", berichtigbar und
  zuruecknehmbar. In der Historie steht die Kennung, angezeigt wird der
  Name (StandorteContext).

Rauchtest: Schritt 30.

Geprueft: lint, tsc, types:check, 949 Tests, Uebergabe-Waechter
This commit is contained in:
2026-10-22 14:50:19 +02:00
parent 2b419d022a
commit c6f617093f
9 changed files with 219 additions and 34 deletions

View File

@@ -276,8 +276,31 @@ export async function transferEmployee(payload: {
effective_date: string;
/** Die Zielplanstelle; Bereich, Abteilung und Team ergeben sich aus ihrer Einheit. */
target_position_id: string;
/**
* Ein neuer Standort, wenn er mit der Versetzung wechselt — fachlich
* vorgegeben. Leer oder unverändert heisst: der Standort bleibt.
*/
location_id?: string;
}): Promise<ActionResult> {
return callRpc("transfer_employee", payload, [`/employees/${payload.employee_id}`, "/employees"]);
const { location_id, ...versetzung } = payload;
try {
// In einer Transaktion: eine Versetzung ohne den mitbeschlossenen
// Standortwechsel wäre eine halbe.
await withUser(await currentUserId(), async (tx) => {
await callFunction(tx, "transfer_employee", versetzung);
if (location_id) {
await callFunction(tx, "change_employee_data", {
employee_id: payload.employee_id,
effective_date: payload.effective_date,
role: { location_id },
});
}
});
} catch (err) {
return { success: false, error: err instanceof Error ? err.message : "Unbekannter Fehler." };
}
for (const path of [`/employees/${payload.employee_id}`, "/employees"]) revalidatePath(path);
return { success: true };
}
export async function promoteEmployee(payload: {