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


export const paid_time_off_types: string[] = ['SICK', 'VACATION', 'BANKING', 'WITHDRAW_BANKED'];

//used to simplify services
export const paid_time_off_mapping: Record<string, { field: string; invert_logic: boolean; operation: string; }> = {
    SICK: { field: 'sick_hours', invert_logic: false, operation: 'increment' },
    VACATION: { field: 'vacation_hours', invert_logic: false, operation: 'increment' },
    WITHDRAW_BANKED: { field: 'banked_hours', invert_logic: true, operation: 'increment' },
    BANKING: { field: 'banked_hours', invert_logic: false, operation: 'decrement' },
};

export class PaidTimeOffDto {
    @IsInt() id: number;
    @IsInt() @IsNotEmpty() employee_id: number;
    @IsOptional() @Type(() => Number) vacation_hours?: number;
    @IsOptional() @Type(() => Number) sick_hours?: number;
    @IsOptional() @Type(() => Number) banked_hours?: number;
    @IsString() @IsOptional() last_updated?: string | null;

    constructor(employee_id: number) {
        this.employee_id = employee_id;
        this.banked_hours = 0;
        this.sick_hours = 0;
        this.vacation_hours = 0;
        this.last_updated = new Date().toISOString();
    }
}