Skip to content

Commit

Permalink
feat: Improve targethours typings
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnns committed Nov 1, 2021
1 parent 7183c4e commit 3b063ab
Showing 1 changed file with 53 additions and 4 deletions.
57 changes: 53 additions & 4 deletions src/models/targethours.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,74 @@
export type TargethoursRow = {
export enum TargethoursRowType {
Weekly = "weekly",
Monthly = "monthly",
}

type CommonTargethoursRow = {
/** The ID of the target hour settings */
id: number;
usersId: number;
type: string;
/**
* Date from which on the target hours apply
* Format YYYY-MM-DD
*/
dateSince: string;
/**
* Date until which the target hours apply
* Format YYYY-MM-DD
*/
dateUntil: string | null;
/**
* Automatic time compensation per month in hours
*/
compensationMonthly: number;
/** The related employee's ID */
usersId: number;
};

export type TargethoursRowWeekly = CommonTargethoursRow & {
/** Type of the target hours row */
type: TargethoursRowType.Weekly;
/** Target hours for Monday */
monday: number;
/** Target hours for Tuesday */
tuesday: number;
/** Target hours for Wednesday */
wednesday: number;
/** Target hours for Thursday */
thursday: number;
/** Target hours for Friday */
friday: number;
/** Target hours for Saturday */
saturday: number;
/** Target hours for Sunday */
sunday: number;
/**
* true if credited absence hours are applied against the average target hours,
* false if credited absence hours match the target hours of the specific day .
*/
absenceFixedCredit: boolean;
/** Automatic time compensation per day in minutes */
compensationDaily: number;
compensationMonthly: number;
};

export type TargethoursRowMonthly = CommonTargethoursRow & {
/** Type of the target hours row */
type: TargethoursRowType.Monthly;
/** Monthly target hours to attain */
monthlyTarget: number;
/** Is Monday a work day? */
workdayMonday: boolean;
/** Is Tuesday a work day? */
workdayTuesday: boolean;
/** Is Wednesday a work day? */
workdayWednesday: boolean;
/** Is Thursday a work day? */
workdayThursday: boolean;
/** Is Friday a work day? */
workdayFriday: boolean;
/** Is Saturday a work day? */
workdaySaturday: boolean;
/** Is Sunday a work day? */
workdaySunday: boolean;
};

export type TargethoursRow = TargethoursRowWeekly | TargethoursRowMonthly;

0 comments on commit 3b063ab

Please sign in to comment.