forked from Yara724/api
87 lines
2.2 KiB
TypeScript
87 lines
2.2 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
|
import { Type } from "class-transformer";
|
|
import {
|
|
IsArray,
|
|
IsEnum,
|
|
IsInt,
|
|
IsOptional,
|
|
IsString,
|
|
ValidateNested,
|
|
} from "class-validator";
|
|
import { IsRepairLineAmountToman } from "src/common/validators/repair-line-amount-toman.validator";
|
|
import { FactorStatus } from "src/Types&Enums/claim-request-management/factor-status.enum";
|
|
|
|
class FactorDecisionDto {
|
|
@ApiProperty()
|
|
@IsString()
|
|
partId: string;
|
|
|
|
@ApiProperty({ enum: [FactorStatus.APPROVED, FactorStatus.REJECTED] })
|
|
@IsEnum([FactorStatus.APPROVED, FactorStatus.REJECTED])
|
|
status: FactorStatus;
|
|
|
|
@ApiProperty({ required: false })
|
|
@IsOptional()
|
|
@IsString()
|
|
rejectionReason?: string;
|
|
}
|
|
|
|
export class FactorValidationDto {
|
|
@ApiProperty({ type: [FactorDecisionDto] })
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => FactorDecisionDto)
|
|
decisions: FactorDecisionDto[];
|
|
}
|
|
|
|
/** V2 ClaimCase: expert confirms or overrides part pricing when validating uploaded factors. */
|
|
class FactorDecisionV2Dto {
|
|
@ApiProperty({ example: 201 })
|
|
@IsInt()
|
|
partId: number;
|
|
|
|
@ApiProperty({ enum: [FactorStatus.APPROVED, FactorStatus.REJECTED] })
|
|
@IsEnum([FactorStatus.APPROVED, FactorStatus.REJECTED])
|
|
status: FactorStatus;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
rejectionReason?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description:
|
|
"Part price (Toman). With totalPayment or price+salary for APPROVED/REJECTED factor lines. Use 0 if unused.",
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
@IsRepairLineAmountToman({ allowZero: true })
|
|
price?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description:
|
|
"Salary in Toman. Send with price when not using only totalPayment. Use 0 if unused.",
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
@IsRepairLineAmountToman({ allowZero: true })
|
|
salary?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description:
|
|
"Line total in Toman; or send both price and salary.",
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
@IsRepairLineAmountToman()
|
|
totalPayment?: string;
|
|
}
|
|
|
|
export class FactorValidationV2Dto {
|
|
@ApiProperty({ type: [FactorDecisionV2Dto] })
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => FactorDecisionV2Dto)
|
|
decisions: FactorDecisionV2Dto[];
|
|
}
|