1
0
forked from Yara724/api

YARA-883 + Side ID fixes

This commit is contained in:
SepehrYahyaee
2026-05-18 17:14:45 +03:30
parent e1954cdb37
commit cef684e37f
12 changed files with 1234 additions and 119 deletions

View File

@@ -0,0 +1,127 @@
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 (Rials)",
})
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[];
}
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>>;
}