Cornerstone Report: system values, not display names
Reworked against the load spec and the 27.09. test file. The values I had guessed were the German display names, which is the first entry on the list of errors from earlier loads: Cornerstone answers "ungültiger Wert" and rejects the whole row, followed by "Alle abhängigen Felder müssen gültig sein" as a follow-on. Status Aktiv/Inaktiv -> Active/Inactive Employment Status Arbeitend/... -> Working/On Leave/Terminated User Type Mitarbeiter -> Employee Time Zone CET -> empty The time zone is the second entry on that list: only a portal time zone id is valid, an abbreviation gives "Zeitzonencode nicht eindeutig". Empty means the portal or the OU decides. Division ID is the GUID from the test file, not a name. Termination fields and Leave Reason are filled only when the employment status carries them -- a reason without a termination is an invalid state for the load, not extra information. Four fields now stay empty on purpose, because filling them would mean inventing an identifier that belongs to the target system: Location ID (locations has id/name/country and no Cornerstone id), Position ID (our S-0001 is not a Cornerstone position), Months of Service (Cornerstone derives it) and Rehired Employee (the value for "yes" is unconfirmed, and an unconfirmed value costs the whole row). Retention Rules and Organisationsstufe stay empty because the load ignores them. Header and row now match the test file byte for byte, except User ID (no TEST- prefix outside a test load), Required Training Approvals and Location ID. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,66 +7,58 @@ import {
|
||||
CORNERSTONE_SPALTEN,
|
||||
cornerstoneSpalten,
|
||||
csDatum,
|
||||
dienstmonate,
|
||||
DIVISION_GUID,
|
||||
geschlecht,
|
||||
kontoStatus,
|
||||
type CornerstoneKontext,
|
||||
type CornerstoneQuelle,
|
||||
} from "@/lib/cornerstone";
|
||||
import { toCsv } from "@/lib/export";
|
||||
import { buildOrgMaps, type OrgUnit } from "@/lib/org";
|
||||
|
||||
// Die Datei geht in ein fremdes System, das sie über eine im Portal
|
||||
// eingerichtete Zuordnung einliest. Eine verschobene Spalte oder ein Datum in
|
||||
// der falschen Reihenfolge fällt nicht hier auf, sondern dort — und das
|
||||
// Datum fällt womöglich gar nicht auf, weil 09.03. und 03.09. beide gültig
|
||||
// sind. Deshalb steht die Form hier fest.
|
||||
// eingerichtete Zuordnung einliest. Zwei Sorten Fehler sind hier teuer:
|
||||
//
|
||||
// * Ein deutscher Anzeigename statt des Systemwerts („Aktiv" statt
|
||||
// „Active") weist Cornerstone mit „ungültiger Wert" ab — und zwar die
|
||||
// ganze Zeile, gefolgt von „Alle abhängigen Felder müssen gültig sein".
|
||||
// * Ein Datum in der falschen Reihenfolge fällt gar nicht auf: 09.03. und
|
||||
// 03.09. sind beide gültig.
|
||||
//
|
||||
// Deshalb steht hier beides fest, Wert für Wert.
|
||||
|
||||
// Die Kopfzeile aus der Vorgabe, Zeichen für Zeichen.
|
||||
// Die Kopfzeile aus der Vorlage, Zeichen für Zeichen.
|
||||
const VORGABE =
|
||||
"User ID,Local System ID,Prefix,First Name,Middle Name,Last Name,Suffix,Username,Approver,Manager,Absent,Allow Reconciliation,Email,Required Training Approvals,Gender,Exempt,Ethnicity,Months of Service,Compensation Currency,Address Line 1,Address Line 2,City,State,Zip,Mailstop,Country,Original Hire Date,Last Hire Date,Phone,Mobile,Home Phone,Fax,Status,User activation date,User de-activation date,Personal Email,Language,Time Zone,User Type,Employment Status,Leave Reason,Termination Type,Termination Reason,Termination Date,Eligible For Rehire,Rehired Employee,Division ID,Position ID,Grade ID,Cost Center ID,Location ID,Retention Rules,Organisationsstufe,Customfield ID AD,Customfield ID Doxis,Customfield ID Interflex,Customfield ID LGVplus";
|
||||
|
||||
const units: OrgUnit[] = [
|
||||
{ id: "g", org_number: "1", name: "Manner AG", parent_id: null, unit_type: "Gesellschaft" },
|
||||
{ id: "b", org_number: "2", name: "Produktion", parent_id: "g", unit_type: "Bereich" },
|
||||
{ id: "t", org_number: "3", name: "Linie 1", parent_id: "b", unit_type: "Team" },
|
||||
];
|
||||
|
||||
const kontext: CornerstoneKontext = {
|
||||
orgMaps: buildOrgMaps(units, []),
|
||||
standortName: new Map([["wien", "Wien"]]),
|
||||
managerNummer: new Map([["chef", 1000]]),
|
||||
kostenstelle: new Map([["pos-1", { id: "k", code: "4711", name: "Waffelproduktion" }]]),
|
||||
wiedereingestellt: new Set(["zurueck"]),
|
||||
stichtag: "2026-09-25",
|
||||
kostenstelle: new Map([["pos-1", { id: "k", code: "41130", name: "Waffelproduktion" }]]),
|
||||
};
|
||||
|
||||
function person(teil: Partial<CornerstoneQuelle> = {}): CornerstoneQuelle {
|
||||
return {
|
||||
id: "e1",
|
||||
personnel_number: 9001,
|
||||
first_name: "Testa",
|
||||
last_name: "Musterfrau",
|
||||
personnel_number: 9002,
|
||||
first_name: "Max",
|
||||
last_name: "Alpentest",
|
||||
title_prefix: [],
|
||||
title_suffix: [],
|
||||
gender: "w",
|
||||
company_email: "testa.musterfrau@example.test",
|
||||
address: "Teststrasse 1",
|
||||
gender: "m",
|
||||
company_email: "m.test@alpenwerk.test.com",
|
||||
address: "Teststrasse 2",
|
||||
postal_code: "1010",
|
||||
city: "Wien",
|
||||
address_country: "AT",
|
||||
entry_date: "2026-09-15",
|
||||
entry_date: "2026-10-01",
|
||||
exit_date: null,
|
||||
exit_reason: null,
|
||||
austrittsart: null,
|
||||
absence_type: null,
|
||||
status: "Aktiv",
|
||||
paygrade: "B",
|
||||
paygrade: "HG15",
|
||||
location_id: "wien",
|
||||
org_unit_id: "t",
|
||||
position_id: "pos-1",
|
||||
position_number: "S-0001",
|
||||
manager_id: "chef",
|
||||
manager_id: null,
|
||||
...teil,
|
||||
};
|
||||
}
|
||||
@@ -74,7 +66,7 @@ function person(teil: Partial<CornerstoneQuelle> = {}): CornerstoneQuelle {
|
||||
const zeile = (teil: Partial<CornerstoneQuelle> = {}) => baueCornerstoneZeile(person(teil), kontext);
|
||||
|
||||
describe("Spalten", () => {
|
||||
it("stehen genau so und in genau der Reihenfolge wie vorgegeben", () => {
|
||||
it("stehen genau so und in genau der Reihenfolge wie in der Vorlage", () => {
|
||||
expect(CORNERSTONE_SPALTEN.join(",")).toBe(VORGABE);
|
||||
});
|
||||
|
||||
@@ -82,27 +74,45 @@ describe("Spalten", () => {
|
||||
expect(CORNERSTONE_SPALTEN).toHaveLength(57);
|
||||
});
|
||||
|
||||
it("schreibt die Datei mit Komma und ohne BOM", () => {
|
||||
// Die Route nimmt genau diese Form. Stünden die Vorgaben von toCsv drin
|
||||
// (Semikolon fürs deutsche Excel, BOM gegen Buchstabensalat), käme in
|
||||
// Cornerstone eine einspaltige Datei an, deren Spalte auch noch ein
|
||||
// unsichtbares Zeichen im Namen trägt.
|
||||
expect(CORNERSTONE_CSV).toEqual({ trenner: ",", bom: false });
|
||||
});
|
||||
|
||||
it("decken sich mit den Feldern, die eine Zeile liefert", () => {
|
||||
// Ein Feld, das die Zeile setzt, das aber in keiner Spalte steht, ginge
|
||||
// stillschweigend verloren.
|
||||
expect(Object.keys(zeile()).sort()).toEqual([...CORNERSTONE_SPALTEN].sort());
|
||||
});
|
||||
|
||||
it("schreibt die Datei mit Komma und ohne BOM", () => {
|
||||
// Stünden die Vorgaben von toCsv drin (Semikolon fürs deutsche Excel,
|
||||
// BOM gegen Buchstabensalat), käme in Cornerstone eine einspaltige Datei
|
||||
// an, deren Spalte auch noch ein unsichtbares Zeichen im Namen trägt.
|
||||
expect(CORNERSTONE_CSV).toEqual({ trenner: ",", bom: false });
|
||||
});
|
||||
});
|
||||
|
||||
describe("Einzelne Umsetzungen", () => {
|
||||
it("schreibt das Datum mit dem Tag zuerst", () => {
|
||||
// Die Einleseeinstellung steht auf „Tag zuerst". Ein ISO-Datum würde
|
||||
// stumm falsch gelesen.
|
||||
expect(csDatum("2026-09-15")).toBe("15.09.2026");
|
||||
expect(csDatum(null)).toBe("");
|
||||
describe("Systemwerte statt Anzeigenamen", () => {
|
||||
it("setzt Status auf Active beziehungsweise Inactive", () => {
|
||||
expect(kontoStatus("Aktiv")).toBe("Active");
|
||||
expect(kontoStatus("Karenz")).toBe("Active");
|
||||
expect(kontoStatus("Ausgetreten")).toBe("Inactive");
|
||||
});
|
||||
|
||||
it("setzt Employment Status auf Working, On Leave oder Terminated", () => {
|
||||
expect(beschaeftigungsStatus("Aktiv")).toBe("Working");
|
||||
expect(beschaeftigungsStatus("Karenz")).toBe("On Leave");
|
||||
expect(beschaeftigungsStatus("Ausgetreten")).toBe("Terminated");
|
||||
// „Geplant" kennt Cornerstone nicht — die Person bekommt ein Konto.
|
||||
expect(beschaeftigungsStatus("Geplant")).toBe("Working");
|
||||
});
|
||||
|
||||
it("schreibt nirgends einen deutschen Anzeigenamen in die Statusfelder", () => {
|
||||
// Der häufigste Fehler aus früheren Loads.
|
||||
const z = zeile();
|
||||
expect([z.Status, z["Employment Status"], z["User Type"]]).toEqual(["Active", "Working", "Employee"]);
|
||||
});
|
||||
|
||||
it("lässt die Zeitzone leer, statt ein Kürzel zu schreiben", () => {
|
||||
// Gültig ist allein eine Zeitzonen-ID aus dem Portal; „CET" quittiert
|
||||
// der Load mit „Zeitzonencode nicht eindeutig".
|
||||
expect(zeile()["Time Zone"]).toBe("");
|
||||
});
|
||||
|
||||
it("übersetzt das Geschlecht in Cornerstones Werte", () => {
|
||||
@@ -113,124 +123,151 @@ describe("Einzelne Umsetzungen", () => {
|
||||
expect(geschlecht("x")).toBe("not specified");
|
||||
});
|
||||
|
||||
it("schreibt das Datum mit dem Tag zuerst", () => {
|
||||
expect(csDatum("2026-10-01")).toBe("01.10.2026");
|
||||
expect(csDatum(null)).toBe("");
|
||||
});
|
||||
|
||||
it("baut den Anmeldenamen ohne Umlaute und Sonderzeichen", () => {
|
||||
expect(benutzername("Jörg", "Müller-Groß")).toBe("joerg.muellergross");
|
||||
expect(benutzername("Anna Maria", "Berger")).toBe("annamaria.berger");
|
||||
});
|
||||
|
||||
it("zählt volle Dienstmonate", () => {
|
||||
expect(dienstmonate("2026-09-15", "2026-09-25")).toBe(0);
|
||||
expect(dienstmonate("2025-09-30", "2026-09-25")).toBe(11);
|
||||
expect(dienstmonate("2025-09-15", "2026-09-25")).toBe(12);
|
||||
});
|
||||
|
||||
it("trennt Konto von Beschäftigung", () => {
|
||||
// Wer in Karenz ist, hat ein aktives Konto und arbeitet nicht. Aus einem
|
||||
// Wert gefüllt wäre entweder das eine oder das andere falsch.
|
||||
expect(kontoStatus("Karenz")).toBe("Aktiv");
|
||||
expect(beschaeftigungsStatus("Karenz")).toBe("Abwesend");
|
||||
expect(kontoStatus("Ausgetreten")).toBe("Inaktiv");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Eine Zeile", () => {
|
||||
it("entspricht der Beispielzeile in den tragenden Feldern", () => {
|
||||
const z = zeile();
|
||||
expect(z).toMatchObject({
|
||||
"Local System ID": "9001",
|
||||
"First Name": "Testa",
|
||||
"Last Name": "Musterfrau",
|
||||
Username: "testa.musterfrau",
|
||||
Gender: "female",
|
||||
describe("Eine Zeile gegen das Muster vom 27.09.2026", () => {
|
||||
it("trägt dieselben Werte wie der Testload", () => {
|
||||
expect(zeile()).toMatchObject({
|
||||
"Local System ID": "9002",
|
||||
"First Name": "Max",
|
||||
"Last Name": "Alpentest",
|
||||
Username: "max.alpentest",
|
||||
Email: "m.test@alpenwerk.test.com",
|
||||
Gender: "male",
|
||||
"Compensation Currency": "EUR",
|
||||
"Address Line 1": "Teststrasse 1",
|
||||
"Address Line 1": "Teststrasse 2",
|
||||
City: "Wien",
|
||||
Zip: "1010",
|
||||
Country: "AT",
|
||||
"Original Hire Date": "15.09.2026",
|
||||
"Last Hire Date": "15.09.2026",
|
||||
Status: "Aktiv",
|
||||
"Original Hire Date": "01.10.2026",
|
||||
"Last Hire Date": "01.10.2026",
|
||||
Status: "Active",
|
||||
Language: "de-DE",
|
||||
"Time Zone": "CET",
|
||||
"User Type": "Mitarbeiter",
|
||||
"Employment Status": "Arbeitend",
|
||||
"Customfield ID AD": "testa.musterfrau",
|
||||
"Customfield ID Doxis": "DOX-9001",
|
||||
"Customfield ID Interflex": "9001",
|
||||
"Customfield ID LGVplus": "LGV-9001",
|
||||
"Time Zone": "",
|
||||
"User Type": "Employee",
|
||||
"Employment Status": "Working",
|
||||
"Division ID": DIVISION_GUID,
|
||||
"Grade ID": "HG15",
|
||||
"Cost Center ID": "41130",
|
||||
"Customfield ID AD": "max.alpentest",
|
||||
"Customfield ID Doxis": "DOX-9002",
|
||||
"Customfield ID Interflex": "9002",
|
||||
"Customfield ID LGVplus": "LGV-9002",
|
||||
});
|
||||
});
|
||||
|
||||
it("verweist auf die vorgesetzte Person über deren Personalnummer", () => {
|
||||
// Cornerstone verknüpft über die User ID, nicht über den Namen.
|
||||
expect(zeile().Manager).toBe("1000");
|
||||
expect(zeile({ manager_id: null }).Manager).toBe("");
|
||||
});
|
||||
|
||||
it("nimmt die dienstliche Adresse und lässt die privaten Felder leer", () => {
|
||||
it("lässt die Felder leer, die das Muster leer lässt", () => {
|
||||
const z = zeile();
|
||||
expect(z.Email).toBe("testa.musterfrau@example.test");
|
||||
expect(z["Personal Email"]).toBe("");
|
||||
expect(z["Home Phone"]).toBe("");
|
||||
for (const feld of [
|
||||
"Prefix",
|
||||
"Middle Name",
|
||||
"Suffix",
|
||||
"Approver",
|
||||
"Manager",
|
||||
"Absent",
|
||||
"Allow Reconciliation",
|
||||
"Required Training Approvals",
|
||||
"Exempt",
|
||||
"Ethnicity",
|
||||
"Months of Service",
|
||||
"Address Line 2",
|
||||
"State",
|
||||
"Mailstop",
|
||||
"Phone",
|
||||
"Mobile",
|
||||
"Home Phone",
|
||||
"Fax",
|
||||
"User activation date",
|
||||
"User de-activation date",
|
||||
"Personal Email",
|
||||
"Leave Reason",
|
||||
"Termination Type",
|
||||
"Termination Reason",
|
||||
"Termination Date",
|
||||
"Eligible For Rehire",
|
||||
"Rehired Employee",
|
||||
"Position ID",
|
||||
"Location ID",
|
||||
"Retention Rules",
|
||||
"Organisationsstufe",
|
||||
]) {
|
||||
expect(z[feld], feld).toBe("");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("setzt die Kostenstelle der Planstelle, nicht der Person", () => {
|
||||
expect(zeile()["Cost Center ID"]).toBe("4711");
|
||||
expect(zeile({ position_id: null })["Cost Center ID"]).toBe("");
|
||||
});
|
||||
|
||||
it("nennt als Organisationsstufe die Ebene, nicht den Namen der Einheit", () => {
|
||||
expect(zeile().Organisationsstufe).toBe("Team");
|
||||
expect(zeile({ org_unit_id: "b" }).Organisationsstufe).toBe("Bereich");
|
||||
expect(zeile({ org_unit_id: null }).Organisationsstufe).toBe("");
|
||||
});
|
||||
|
||||
it("füllt den Austritt nur, wenn es einen gibt", () => {
|
||||
const aktiv = zeile();
|
||||
expect(aktiv["Termination Date"]).toBe("");
|
||||
expect(aktiv["Termination Type"]).toBe("");
|
||||
describe("Abhängige Felder", () => {
|
||||
it("füllt die Austrittsfelder nur bei Terminated", () => {
|
||||
// Ein Austrittsgrund ohne Austritt ist für den Load ein ungültiger
|
||||
// Zustand, nicht eine Zusatzangabe.
|
||||
const offen = zeile({ exit_date: "2026-12-31", exit_reason: "Kündigung", austrittsart: "freiwillig" });
|
||||
expect(offen["Termination Date"]).toBe("");
|
||||
expect(offen["Termination Type"]).toBe("");
|
||||
expect(offen["Termination Reason"]).toBe("");
|
||||
|
||||
const weg = zeile({ status: "Ausgetreten", exit_date: "2026-12-31", exit_reason: "Kündigung", austrittsart: "freiwillig" });
|
||||
expect(weg["Termination Date"]).toBe("31.12.2026");
|
||||
expect(weg["Termination Type"]).toBe("freiwillig");
|
||||
expect(weg["Termination Reason"]).toBe("Kündigung");
|
||||
expect(weg.Status).toBe("Inaktiv");
|
||||
expect(weg.Status).toBe("Inactive");
|
||||
expect(weg["Employment Status"]).toBe("Terminated");
|
||||
});
|
||||
|
||||
it("nennt den Abwesenheitsgrund nur bei Karenz", () => {
|
||||
it("nennt den Abwesenheitsgrund nur bei On Leave", () => {
|
||||
expect(zeile({ absence_type: "Elternkarenz" })["Leave Reason"]).toBe("");
|
||||
expect(zeile({ status: "Karenz", absence_type: "Elternkarenz" })["Leave Reason"]).toBe("Elternkarenz");
|
||||
const karenz = zeile({ status: "Karenz", absence_type: "Elternkarenz" });
|
||||
expect(karenz["Leave Reason"]).toBe("Elternkarenz");
|
||||
expect(karenz["Employment Status"]).toBe("On Leave");
|
||||
});
|
||||
|
||||
it("kennzeichnet Wiedereingestellte", () => {
|
||||
expect(zeile()["Rehired Employee"]).toBe("");
|
||||
expect(zeile({ id: "zurueck" })["Rehired Employee"]).toBe("Ja");
|
||||
it("nennt keinen Abwesenheitsgrund an einer ausgetretenen Person", () => {
|
||||
const weg = zeile({ status: "Ausgetreten", absence_type: "Elternkarenz", exit_date: "2026-12-31" });
|
||||
expect(weg["Leave Reason"]).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Kennungen statt Namen", () => {
|
||||
it("verweist auf die vorgesetzte Person über deren Personalnummer", () => {
|
||||
// Cornerstone verknüpft über die User ID, nicht über den Namen.
|
||||
expect(zeile({ manager_id: "chef" }).Manager).toBe("1000");
|
||||
expect(zeile({ manager_id: null }).Manager).toBe("");
|
||||
});
|
||||
|
||||
it("trägt die Platzhalter sichtbar ein", () => {
|
||||
// Sie müssen vor einem echten Lauf ersetzt werden — ein leeres Feld
|
||||
// sähe aus wie „nichts zu tun".
|
||||
expect(zeile()["Division ID"]).toBe("DIVISION-ID-HIER");
|
||||
it("nimmt als Kostenstelle den Code der Planstelle", () => {
|
||||
expect(zeile()["Cost Center ID"]).toBe("41130");
|
||||
expect(zeile({ position_id: null })["Cost Center ID"]).toBe("");
|
||||
});
|
||||
|
||||
it("schreibt die Division als GUID", () => {
|
||||
expect(zeile()["Division ID"]).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("als CSV", () => {
|
||||
it("schreibt die Kopfzeile Zeichen für Zeichen wie vorgegeben", () => {
|
||||
// Komma statt Semikolon und kein BOM — sonst hiesse die erste Spalte für
|
||||
// Cornerstone nicht „User ID", sondern trüge das unsichtbare Zeichen im
|
||||
// Namen und käme in keiner Zuordnung vor.
|
||||
it("schreibt die Kopfzeile Zeichen für Zeichen wie die Vorlage", () => {
|
||||
const csv = toCsv([zeile()], cornerstoneSpalten(), CORNERSTONE_CSV);
|
||||
expect(csv.startsWith("User ID,")).toBe(true);
|
||||
expect(csv.split(/\r?\n/)[0]).toBe(VORGABE);
|
||||
});
|
||||
|
||||
it("trennt die Zeilen mit CRLF", () => {
|
||||
expect(toCsv([zeile()], cornerstoneSpalten(), CORNERSTONE_CSV)).toContain("\r\n");
|
||||
});
|
||||
|
||||
it("maskiert ein Komma im Wert, statt die Zeile zu zerreissen", () => {
|
||||
const csv = toCsv([zeile({ address: "Teststrasse 1, Stiege 2" })], cornerstoneSpalten(), CORNERSTONE_CSV);
|
||||
expect(csv).toContain('"Teststrasse 1, Stiege 2"');
|
||||
const csv = toCsv([zeile({ address: "Teststrasse 2, Stiege 3" })], cornerstoneSpalten(), CORNERSTONE_CSV);
|
||||
expect(csv).toContain('"Teststrasse 2, Stiege 3"');
|
||||
// Felder zählen, nicht Kommas: das maskierte Komma steht ja in der Zeile.
|
||||
// Beide Zeilen müssen gleich viele Felder haben, sonst verrutscht ab der
|
||||
// Adresse jede weitere Spalte um eins.
|
||||
const felder = (zeileText: string) => zeileText.split(/,(?=(?:[^"]*"[^"]*")*[^"]*$)/).length;
|
||||
const felder = (t: string) => t.split(/,(?=(?:[^"]*"[^"]*")*[^"]*$)/).length;
|
||||
const [kopf, daten] = csv.split(/\r?\n/);
|
||||
expect(felder(daten)).toBe(felder(kopf));
|
||||
expect(felder(kopf)).toBe(57);
|
||||
|
||||
Reference in New Issue
Block a user