forked from Yara724/api
merge upstream
This commit is contained in:
@@ -26,7 +26,7 @@ describe("SubmitExpertReplyV2Dto", () => {
|
||||
expect(errors).not.toHaveLength(0);
|
||||
});
|
||||
|
||||
it("accepts a replacement part without a price", async () => {
|
||||
it("rejects a replacement part without a price", async () => {
|
||||
const dto = plainToInstance(SubmitExpertReplyV2Dto, {
|
||||
description: "Damage assessment",
|
||||
parts: [
|
||||
@@ -41,7 +41,7 @@ describe("SubmitExpertReplyV2Dto", () => {
|
||||
],
|
||||
});
|
||||
|
||||
expect(await validate(dto)).toHaveLength(0);
|
||||
expect(await validate(dto)).not.toHaveLength(0);
|
||||
});
|
||||
|
||||
it("accepts a repair part without daghi", async () => {
|
||||
@@ -61,4 +61,33 @@ describe("SubmitExpertReplyV2Dto", () => {
|
||||
|
||||
expect(await validate(dto)).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("accepts the expert's repair and replacement pricing rules", async () => {
|
||||
const dto = plainToInstance(SubmitExpertReplyV2Dto, {
|
||||
description: "Damage assessment",
|
||||
parts: [
|
||||
{
|
||||
partId: 11,
|
||||
typeOfDamage: TypeOfDamage.Repair,
|
||||
salary: "۵,۰۰۰",
|
||||
totalPayment: "5000",
|
||||
factorNeeded: false,
|
||||
},
|
||||
{
|
||||
partId: 23,
|
||||
typeOfDamage: TypeOfDamage.Change,
|
||||
price: "۵۰,۰۰۰",
|
||||
salary: "۱۰۰,۰۰۰",
|
||||
totalPayment: "150000",
|
||||
factorNeeded: false,
|
||||
daghi: {
|
||||
option: DaghiOption.RECYCLED_PARTS_VALUE,
|
||||
price: "۱۰۰,۵۰۰,۰۰۰",
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(await validate(dto)).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
IsInt,
|
||||
} from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsRepairLineAmountToman } from 'src/common/validators/repair-line-amount-toman.validator';
|
||||
import { IsMoneyAmountString } from 'src/common/validators/money-amount-string.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';
|
||||
@@ -35,7 +35,7 @@ export class DaghiDetailsV2Dto {
|
||||
)
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsRepairLineAmountToman()
|
||||
@IsMoneyAmountString()
|
||||
price?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
@@ -56,24 +56,24 @@ export class PartPricingV2Dto {
|
||||
|
||||
@ApiProperty({
|
||||
enum: TypeOfDamage,
|
||||
description: "'repair' requires price; 'change' may omit it.",
|
||||
description: "'change' requires price; 'repair' may omit it.",
|
||||
})
|
||||
@IsEnum(TypeOfDamage)
|
||||
typeOfDamage: TypeOfDamage;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "5000000",
|
||||
description: "Required for repair lines; omitted for change lines. Use 0 if the full amount is in salary.",
|
||||
description: "Required for change lines; omitted for repair lines. Use 0 if unused.",
|
||||
})
|
||||
@ValidateIf(
|
||||
(part: PartPricingV2Dto) =>
|
||||
part.typeOfDamage === TypeOfDamage.Repair ||
|
||||
part.typeOfDamage === TypeOfDamage.Change ||
|
||||
(part.price != null &&
|
||||
(typeof part.price !== 'string' || part.price.trim() !== '')),
|
||||
)
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsRepairLineAmountToman({ allowZero: true })
|
||||
@IsMoneyAmountString()
|
||||
price: string;
|
||||
|
||||
@ApiProperty({
|
||||
@@ -82,7 +82,7 @@ export class PartPricingV2Dto {
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsRepairLineAmountToman({ allowZero: true })
|
||||
@IsMoneyAmountString()
|
||||
salary: string;
|
||||
|
||||
@ApiProperty({
|
||||
@@ -91,7 +91,7 @@ export class PartPricingV2Dto {
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsRepairLineAmountToman({ allowZero: true })
|
||||
@IsMoneyAmountString()
|
||||
totalPayment: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
|
||||
Reference in New Issue
Block a user