forked from Yara724/api
Fixed daqi being enforced on REPAIR
This commit is contained in:
@@ -102,6 +102,7 @@ import { ClaimFactorsImageDbService } from "src/claim-request-management/entites
|
||||
import { ClaimRequiredDocumentDbService } from "src/claim-request-management/entites/db-service/claim-required-document.db.service";
|
||||
import { FactorStatus } from "src/Types&Enums/claim-request-management/factor-status.enum";
|
||||
import { DaghiOption } from "src/Types&Enums/claim-request-management/daghi-option.enum";
|
||||
import { TypeOfDamage } from "src/Types&Enums/claim-request-management/type-of-damage.enum";
|
||||
import { BranchDbService } from "src/client/entities/db-service/branch.db.service";
|
||||
import { ClaimSubmitResendV2Dto } from "./dto/expert-claim-v2.dto";
|
||||
import { BlameRequestDbService } from "src/request-management/entities/db-service/blame-request.db.service";
|
||||
@@ -947,6 +948,7 @@ export class ExpertClaimService {
|
||||
parts: import("./dto/expert-claim-v2.dto").PartPricingV2Dto[],
|
||||
) {
|
||||
for (const part of parts) {
|
||||
if (part.typeOfDamage === TypeOfDamage.Repair) continue;
|
||||
if (!part.daghi || !part.daghi.option) {
|
||||
throw new BadRequestException(
|
||||
`Daghi option is required for part ${part.partId}`,
|
||||
@@ -972,16 +974,23 @@ export class ExpertClaimService {
|
||||
}
|
||||
}
|
||||
|
||||
return parts.map((part) => ({
|
||||
...part,
|
||||
daghi: {
|
||||
option: part.daghi.option,
|
||||
...(part.daghi.price && { price: part.daghi.price }),
|
||||
...(part.daghi.branchId && Types.ObjectId.isValid(part.daghi.branchId) && {
|
||||
branchId: new Types.ObjectId(part.daghi.branchId),
|
||||
}),
|
||||
},
|
||||
}));
|
||||
return parts.map((part) => {
|
||||
if (part.typeOfDamage === TypeOfDamage.Repair) {
|
||||
const { daghi: _daghi, ...repairPart } = part;
|
||||
return repairPart;
|
||||
}
|
||||
return {
|
||||
...part,
|
||||
daghi: {
|
||||
option: part.daghi!.option,
|
||||
...(part.daghi!.price && { price: part.daghi!.price }),
|
||||
...(part.daghi!.branchId &&
|
||||
Types.ObjectId.isValid(part.daghi!.branchId) && {
|
||||
branchId: new Types.ObjectId(part.daghi!.branchId),
|
||||
}),
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private findClosestCar(input: string, cars: { carName: string }[]) {
|
||||
@@ -1711,6 +1720,7 @@ export class ExpertClaimService {
|
||||
// Validate daghi fields
|
||||
if (reply.parts && reply.parts.length > 0) {
|
||||
for (const part of reply.parts) {
|
||||
if (part.typeOfDamage === TypeOfDamage.Repair) continue;
|
||||
if (!part.daghi || !part.daghi.option) {
|
||||
throw new BadRequestException(
|
||||
`Daghi option is required for part ${part.partId}`,
|
||||
@@ -1758,16 +1768,22 @@ export class ExpertClaimService {
|
||||
: ClaimStepsEnum.WaitingForUserToReact;
|
||||
|
||||
// Process parts: convert branchId string to ObjectId if present
|
||||
const processedParts = reply.parts.map((part) => ({
|
||||
...part,
|
||||
daghi: {
|
||||
option: part.daghi.option,
|
||||
...(part.daghi.price && { price: part.daghi.price }),
|
||||
...(part.daghi.branchId && {
|
||||
branchId: new Types.ObjectId(part.daghi.branchId),
|
||||
}),
|
||||
},
|
||||
}));
|
||||
const processedParts = reply.parts.map((part) => {
|
||||
if (part.typeOfDamage === TypeOfDamage.Repair) {
|
||||
const { daghi: _daghi, ...repairPart } = part;
|
||||
return repairPart;
|
||||
}
|
||||
return {
|
||||
...part,
|
||||
daghi: {
|
||||
option: part.daghi!.option,
|
||||
...(part.daghi!.price && { price: part.daghi!.price }),
|
||||
...(part.daghi!.branchId && {
|
||||
branchId: new Types.ObjectId(part.daghi!.branchId),
|
||||
}),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const expertProfileSnapshot = await this.snapshotDamageExpert(userId.sub);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user