Files
Nexus/packages/api/src/router/timeline-allocation-update-support.ts
T
Hartmut b41c1d2501
CI / Architecture Guardrails (push) Successful in 2m38s
CI / Assistant Split Regression (push) Successful in 3m33s
CI / Typecheck (push) Successful in 3m51s
CI / Lint (push) Successful in 5m2s
CI / E2E Tests (push) Has been cancelled
CI / Fresh-Linux Docker Deploy (push) Has been cancelled
CI / Release Images (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
rename(phase 1): CapaKraken → Nexus across code, UI, docs, CI (#61)
rename(phase 1): CapaKraken → Nexus across code, UI, docs, CI (#61)

Co-authored-by: Hartmut Nörenberg <hn@hartmut-noerenberg.com>
Co-committed-by: Hartmut Nörenberg <hn@hartmut-noerenberg.com>
2026-05-21 16:28:40 +02:00

72 lines
2.1 KiB
TypeScript

import { Prisma } from "@nexus/db";
export function buildTimelineAllocationMetadata(input: {
existingMetadata: Record<string, unknown> | null | undefined;
includeSaturday: boolean | undefined;
}): { metadata: Record<string, unknown>; includeSaturday: boolean } {
const existingMetadata = input.existingMetadata ?? {};
const metadata: Record<string, unknown> = {
...existingMetadata,
...(input.includeSaturday !== undefined ? { includeSaturday: input.includeSaturday } : {}),
};
const includeSaturday =
input.includeSaturday ?? (existingMetadata.includeSaturday as boolean | undefined) ?? false;
return { metadata, includeSaturday };
}
export function buildTimelineAllocationUpdateAuditChanges(input: {
allocationId: string;
previousHoursPerDay: number;
previousStartDate: Date;
previousEndDate: Date;
nextAllocationId: string;
nextHoursPerDay: number;
nextStartDate: Date;
nextEndDate: Date;
includeSaturday: boolean;
}): Prisma.InputJsonValue {
return {
before: {
id: input.allocationId,
hoursPerDay: input.previousHoursPerDay,
startDate: input.previousStartDate,
endDate: input.previousEndDate,
},
after: {
id: input.nextAllocationId,
hoursPerDay: input.nextHoursPerDay,
startDate: input.nextStartDate,
endDate: input.nextEndDate,
includeSaturday: input.includeSaturday,
},
} as unknown as Prisma.InputJsonValue;
}
export function buildTimelineAllocationEntryUpdate(input: {
hoursPerDay: number;
startDate: Date;
endDate: Date;
metadata: Record<string, unknown>;
dailyCostCents: number;
role?: string | undefined;
}) {
return {
demandRequirementUpdate: {
hoursPerDay: input.hoursPerDay,
startDate: input.startDate,
endDate: input.endDate,
metadata: input.metadata,
...(input.role !== undefined ? { role: input.role } : {}),
},
assignmentUpdate: {
hoursPerDay: input.hoursPerDay,
startDate: input.startDate,
endDate: input.endDate,
dailyCostCents: input.dailyCostCents,
metadata: input.metadata,
...(input.role !== undefined ? { role: input.role } : {}),
},
};
}