Versetzung mit Standortwechsel; Standort aenderbar ueber change_employee_data
- 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:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user