import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { IsString, IsNotEmpty, IsArray, IsBoolean, IsOptional, ValidateNested, IsEnum, IsInt, } from 'class-validator'; import { Type } from 'class-transformer'; import { IsRepairLineAmountToman } from 'src/common/validators/repair-line-amount-toman.validator'; import { ClaimRequiredDocumentType } from 'src/Types&Enums/claim-request-management/required-document-type.enum'; import { DamagedPartItem } from 'src/claim-request-management/dto/capture-requirements-v2.dto'; import { DaghiOption } from 'src/Types&Enums/claim-request-management/daghi-option.enum'; export class DaghiDetailsV2Dto { @ApiProperty({ enum: DaghiOption, description: 'Daghi option: ارزش لوازم بازیافتی, تحویل داغی, فاقد ارزش, با احتساب داغی', }) @IsEnum(DaghiOption) option: DaghiOption; @ApiPropertyOptional({ description: `Required when option is '${DaghiOption.RECYCLED_PARTS_VALUE}' (Toman)`, }) @IsOptional() @IsString() @IsRepairLineAmountToman() price?: string; @ApiPropertyOptional({ description: `Required when option is '${DaghiOption.DELIVER_DAMAGED_PART}' (Mongo ObjectId string)`, }) @IsOptional() @IsString() branchId?: string; } export class PartPricingV2Dto { @ApiProperty({ example: 201, description: 'Numeric catalog part id from claim detail `damagedParts[].partId`.', }) @IsInt() partId: number; @ApiProperty({ example: 'Minor' }) @IsString() typeOfDamage: string; @ApiProperty({ example: "5000000", description: "Part price in Toman (integer string). Use 0 if the full amount is in salary.", }) @IsString() @IsRepairLineAmountToman({ allowZero: true }) price: string; @ApiProperty({ example: "2000000", description: "Labor in Toman (integer string). Use 0 if the full amount is in price.", }) @IsString() @IsRepairLineAmountToman({ allowZero: true }) salary: string; @ApiProperty({ example: "7000000", description: "Line total in Toman (integer string).", }) @IsString() @IsRepairLineAmountToman() totalPayment: string; @ApiProperty({ type: DaghiDetailsV2Dto }) @ValidateNested() @Type(() => DaghiDetailsV2Dto) daghi: DaghiDetailsV2Dto; @ApiProperty({ example: false, description: "If true, the owner must upload a repair factor image for this line; expert confirms cost later (validate-factors). Priced lines omit this or set false.", }) @IsBoolean() factorNeeded: boolean; } export class SubmitExpertReplyV2Dto { @ApiProperty({ example: 'Front door and hood have severe paint damage' }) @IsString() @IsNotEmpty() description: string; @ApiProperty({ type: [PartPricingV2Dto], description: "One line per damaged part (`partId` from claim detail `damagedParts[]`), plus pricing, `daghi`, and `factorNeeded`.", }) @IsArray() @ValidateNested({ each: true }) @Type(() => PartPricingV2Dto) parts: PartPricingV2Dto[]; } export class ClaimSubmitResendV2Dto { @ApiPropertyOptional({ description: "Instructions for the owner. At least one of description, resendDocuments, or resendCarParts must be non-empty.", }) @IsOptional() @IsString() resendDescription?: string; @ApiPropertyOptional({ type: [String], enum: ClaimRequiredDocumentType, description: "Document keys to re-upload; each value must be a ClaimRequiredDocumentType string (e.g. national_card).", }) @IsOptional() @IsArray() @IsEnum(ClaimRequiredDocumentType, { each: true }) resendDocuments?: ClaimRequiredDocumentType[]; @ApiPropertyOptional({ type: [DamagedPartItem] }) @IsOptional() @IsArray() @ValidateNested({ each: true }) @Type(() => DamagedPartItem) resendCarParts?: DamagedPartItem[]; }