1
0
forked from Yara724/api
Files
yara724-api/src/expert-claim/dto/claim-price-drop-v2.dto.ts
SepehrYahyaee 2c810afcb6 YARA-948
2026-06-03 12:05:19 +03:30

140 lines
3.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import {
IsArray,
IsIn,
IsInt,
IsNotEmpty,
IsNumber,
IsOptional,
IsString,
ValidateNested,
} from "class-validator";
import { Type } from "class-transformer";
import type { PriceDropSeverity } from "src/helpers/claim-price-drop";
export class PriceDropPartSeverityV2Dto {
@ApiProperty({
example: 12,
description: "From claim detail `damagedParts[].partId`",
})
@IsInt()
partId: number;
@ApiProperty({
enum: ["Minor", "Moderate", "Severe"],
description: "Severity: جزئی / متوسط / شدید",
})
@IsIn(["Minor", "Moderate", "Severe"])
severity: PriceDropSeverity;
}
export class UpsertClaimPriceDropV2Dto {
@ApiPropertyOptional({ example: "پژو 206" })
@IsOptional()
@IsString()
carName?: string;
@ApiPropertyOptional({
example: "پژو 206 تیپ 5",
description: "Display model string stored on `claim.vehicle.carModel`",
})
@IsOptional()
@IsString()
carModel?: string;
@ApiProperty({
example: 450000000,
description: "Market price of the car (Toman)",
})
carPrice: number | string;
@ApiPropertyOptional({
example: 1394,
description:
"Jalali production year (coefficient). Defaults from linked blame plate inquiry when omitted.",
})
@IsOptional()
@IsNumber()
carModelYear?: number;
@ApiProperty({
type: [PriceDropPartSeverityV2Dto],
description:
"One row per damaged part on the claim; coefficients come from the price-drop table × severity.",
})
@IsArray()
@ValidateNested({ each: true })
@Type(() => PriceDropPartSeverityV2Dto)
partSeverities: PriceDropPartSeverityV2Dto[];
@ApiPropertyOptional({
description:
"Override: expert manually sets the final price-drop amount (in Rials). " +
"When provided, carPrice and partSeverities are not required and calculation is skipped entirely.",
example: 150000000,
})
@IsOptional()
@IsNumber()
manualPriceDrop?: number;
}
export class ClaimPriceDropContextV2Dto {
@ApiProperty()
claimRequestId: string;
@ApiPropertyOptional()
vehicle?: {
carName?: string;
carModel?: string;
carType?: string;
};
@ApiPropertyOptional({
description: "Jalali year from blame plate inquiry (ModelField / ModelCii)",
})
suggestedCarModelYear?: number | null;
@ApiPropertyOptional()
priceDrop?: Record<string, unknown>;
@ApiProperty({
type: "array",
items: {
type: "object",
properties: {
value: { type: "string" },
label_fa: { type: "string" },
},
},
})
severityOptions: Array<{ value: string; label_fa: string }>;
@ApiProperty({
description: "Full coefficient table for all price-drop parts",
})
priceDropCatalog: Array<Record<string, unknown>>;
@ApiProperty({
description: "Claim damaged parts with optional price-drop key mapping",
})
damagedParts: Array<Record<string, unknown>>;
}
export class ClaimPriceDropResultV2Dto {
@ApiProperty()
claimRequestId: string;
@ApiProperty()
vehicle: {
carName?: string;
carModel?: string;
carType?: string;
};
@ApiProperty()
priceDrop: Record<string, unknown>;
@ApiProperty({ type: "array" })
partLines: Array<Record<string, unknown>>;
}