refactor(api): extract timeline allocation update support
This commit is contained in:
@@ -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 } : {}),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user