Organisationseinheit: Art "Vorstandsbereich" und Art aendern
Neue Art zwischen Gesellschaft und Bereich (CEO, CFO, ...). Damit sie sich auf die bestehenden Einheiten setzen laesst, kann die Art einer Einheit jetzt geaendert werden: change_org_unit_type mit Eintrag im Audit-Log, Stift in der Seitenleiste der Einheit, Spalte "Art" im Import. Die Gesellschaft behaelt ihre Art, keine andere Einheit kann sie werden. Uebersicht, Organigramm-Druck und die Spalte "Bereich" in Berichten zaehlen den Vorstandsbereich wie einen Bereich (istBereich in lib/org-art.ts). Sonst fielen eine als Vorstandsbereich gefuehrte Einheit und alle Personen darunter aus diesen Ansichten heraus. Geprueft: lint, tsc, types:check, 1024 Unit-Tests, Integrationstests Austausch, Waechter; alle Migrationen auf leerer Datenbank (zweiter Lauf nichts anzuwenden), Rauchtest 35/35, vertragsangaben.sql.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { currentUserId } from "@/lib/auth/session";
|
||||
import { runMutation, type ActionResult } from "@/lib/db/rpc";
|
||||
import type { OrgUnitType } from "@/lib/org-art";
|
||||
|
||||
const ORG_PFADE = ["/orgchart", "/positions", "/"];
|
||||
|
||||
@@ -17,7 +18,7 @@ export async function createOrgUnit(payload: {
|
||||
parent_id: string;
|
||||
org_number: string;
|
||||
name: string;
|
||||
unit_type: "Bereich" | "Abteilung" | "Team";
|
||||
unit_type: Exclude<OrgUnitType, "Gesellschaft">;
|
||||
valid_from: string;
|
||||
}): Promise<ActionResult> {
|
||||
// Die Einheit entsteht ohne Leitung. Die Leitungsplanstelle wird über
|
||||
@@ -39,6 +40,14 @@ export async function renameOrgUnit(orgUnitId: string, name: string): Promise<Ac
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Die Art einer Organisationseinheit ändern; gilt sofort, ohne Stichtag. */
|
||||
export async function changeOrgUnitType(orgUnitId: string, unitType: OrgUnitType): Promise<ActionResult> {
|
||||
const result = await runMutation(await currentUserId(), "change_org_unit_type", { org_unit_id: orgUnitId, unit_type: unitType });
|
||||
if (!result.success) return result;
|
||||
for (const path of ORG_PFADE) revalidatePath(path);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Eine Organisationseinheit entfernen.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user