import { Type } from "class-transformer";
import { IsBoolean, IsDate, IsInt, IsOptional, IsString } from "class-validator";

export class TimesheetEntity {
    @IsInt() id: number;
    @IsInt() employee_id: number;
    @IsDate() start_date: Date;
    @IsBoolean() is_approved: boolean;
}

export class Timesheets {
    @IsBoolean() has_preset_schedule: boolean;
    @IsString() employee_fullname: string;
    @Type(() => Timesheet) timesheets: Timesheet[];
}

export class Timesheet {
    @IsInt() timesheet_id: number;
    @IsBoolean() is_approved: boolean;
    @Type(() => TimesheetDay) days: TimesheetDay[];
    @Type(() => TotalHours) weekly_hours: TotalHours;
    @Type(() => TotalExpenses) weekly_expenses: TotalExpenses;
}

export class TimesheetDay {
    @IsString() date: string;
    @Type(() => Shift) shifts: Shift[];
    @Type(() => Expense) expenses: Expense[];
    @Type(() => TotalHours) daily_hours: TotalHours;
    @Type(() => TotalExpenses) daily_expenses: TotalExpenses;
}

export class TotalHours {
    @Type(() => Number) regular: number;
    @Type(() => Number) evening: number;
    @Type(() => Number) emergency: number;
    @Type(() => Number) overtime: number;
    @Type(() => Number) vacation: number;
    @Type(() => Number) holiday: number;
    @Type(() => Number) sick: number;
    @Type(() => Number) banking: number;
    @Type(() => Number) withdraw_banked: number;
}
export class TotalExpenses {
    @Type(() => Number) expenses: number;
    @Type(() => Number) per_diem: number;
    @Type(() => Number) on_call: number;
    @Type(() => Number) mileage: number;
}

export class Shift {
    @IsInt() timesheet_id: number;
    @IsString() date: string;
    @IsString() start_time: string;
    @IsString() end_time: string;
    @IsString() type: string;
    @IsBoolean() is_remote: boolean;
    @IsBoolean() is_approved: boolean;
    @IsInt() @IsOptional() shift_id?: number | null;
    @IsString() @IsOptional() comment?: string | null;
}

export class Expense {
    @IsString() date: string;
    @IsBoolean() is_approved: boolean;
    @IsString() type: string;
    @IsString() comment: string;
    @Type(() => Number) @IsOptional() amount?: number;
    @Type(() => Number) @IsOptional() mileage?: number;
    @IsString() @IsOptional() attachment?: string;
    @IsOptional() @IsInt() id?: number | null;
    @IsString() @IsOptional() supervisor_comment?: string | null;
}

