refactor(api): extract timeline allocation update support

This commit is contained in:
2026-03-31 17:59:16 +02:00
parent fb09d6487f
commit d0699c90fe
5 changed files with 129 additions and 106 deletions
@@ -35,58 +35,3 @@ export function validateTimelineAllocationDateRanges(
assertTimelineDateRangeValid(range.startDate, range.endDate);
}
}
export function buildTimelineAllocationUpdateAuditChanges(input: {
allocationId: string;
previousHoursPerDay: number;
previousStartDate: Date;
previousEndDate: Date;
nextAllocationId: string;
nextHoursPerDay: number;
nextStartDate: Date;
nextEndDate: Date;
includeSaturday: boolean;
}) {
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 const;
}
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 } : {}),
},
};
}