/* eslint-disable @typescript-eslint/no-unnecessary-condition */ import { AbstractDto } from '../../../common/dto/abstract.dto'; import { DateField, NumberField, StringField, StringFieldOptional, } from '../../../decorators'; import { type OtRecordEntity } from '../ot-record.entity'; export class OtRecordDto extends AbstractDto { @DateField() date!: Date; @NumberField() hour!: number; @NumberField() ratePer!: number; @NumberField() dailyRate!: number; @NumberField() amount!: number; @StringField() employeeName!: string; @StringField() activityName!: string; @StringFieldOptional() remark?: string; constructor(otRecord: OtRecordEntity) { super(otRecord); this.date = otRecord.date; this.hour = otRecord.hour; this.ratePer = otRecord.ratePer; this.dailyRate = otRecord.dailyRate; this.amount = otRecord.amount; this.remark = otRecord.remark; this.employeeName = otRecord.employee && otRecord.employee.name; this.activityName = otRecord.activitySetting && otRecord.activitySetting.name; } }