Validation for prices and objection

This commit is contained in:
SepehrYahyaee
2026-05-20 11:08:47 +03:30
parent 511d478064
commit e4dfe7c572
18 changed files with 467 additions and 60 deletions

View File

@@ -44,7 +44,7 @@ export class UpsertClaimPriceDropV2Dto {
@ApiProperty({
example: 450000000,
description: "Market price of the car (Rials)",
description: "Market price of the car (Toman)",
})
carPrice: number | string;

View File

@@ -10,11 +10,10 @@ import {
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';
/** Same shape as V1 {@link PartsList} `daghi` (damage expert reply). */
export class DaghiDetailsV2Dto {
@ApiProperty({
enum: DaghiOption,
@@ -25,10 +24,11 @@ export class DaghiDetailsV2Dto {
option: DaghiOption;
@ApiPropertyOptional({
description: `Required when option is '${DaghiOption.RECYCLED_PARTS_VALUE}'`,
description: `Required when option is '${DaghiOption.RECYCLED_PARTS_VALUE}' (Toman)`,
})
@IsOptional()
@IsString()
@IsRepairLineAmountToman()
price?: string;
@ApiPropertyOptional({
@@ -51,16 +51,28 @@ export class PartPricingV2Dto {
@IsString()
typeOfDamage: string;
@ApiProperty({ example: '5000000' })
@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' })
@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' })
@ApiProperty({
example: "7000000",
description: "Line total in Toman (integer string).",
})
@IsString()
@IsRepairLineAmountToman()
totalPayment: string;
@ApiProperty({ type: DaghiDetailsV2Dto })

View File

@@ -8,6 +8,7 @@ import {
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 {
@@ -50,26 +51,29 @@ class FactorDecisionV2Dto {
@ApiPropertyOptional({
description:
"Part price (Persian/ASCII digits). For each factor line, send totalPayment **or** both price and salary. Required for **APPROVED** (accepted amount read from factor / expert) and **REJECTED** (expert’s replacement pricing).",
"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 portion when not using a single totalPayment (must be sent together with price for APPROVED/REJECTED factor lines).",
"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 payment; preferred when the expert enters one number. Required together with APPROVED/REJECTED unless both price and salary are sent.",
"Line total in Toman; or send both price and salary.",
})
@IsOptional()
@IsString()
@IsRepairLineAmountToman()
totalPayment?: string;
}