forked from Yara724/api
fix(fanavaran): require vehicle review and recover submitted base claims
Require approved vehicle classification before new base submissions. Allow a first review for existing base claims without damage or expertise, preserve remote IDs, and resume deferred damage submission. Keep approved submitted classifications locked and compare stage IDs and review snapshots when saving.
This commit is contained in:
@@ -4120,9 +4120,13 @@ export class ExpertClaimService {
|
||||
await this.getClaimDetailV2(claimRequestId, actor);
|
||||
const claim = await this.claimCaseDbService.findById(claimRequestId);
|
||||
if (!claim) throw new NotFoundException("Claim request not found");
|
||||
if (claim.claimId != null || claim.claimNo != null) {
|
||||
const baseSent = claim.claimId != null || claim.claimNo != null;
|
||||
// Recover cases created before base submission required vehicle approval.
|
||||
// Never change an approved snapshot or classification already sent downstream.
|
||||
if (baseSent && ((claim as any).fanavaranVehicleReview?.approved === true ||
|
||||
claim.dmgCaseId != null || claim.expertiseId != null)) {
|
||||
throw new ConflictException(
|
||||
"Vehicle classification cannot be changed after the claim was sent to Fanavaran.",
|
||||
"مشخصات تأییدشده خودرو پس از ارسال به فناوران قابل تغییر نیست.",
|
||||
);
|
||||
}
|
||||
const fields =
|
||||
@@ -4209,8 +4213,11 @@ export class ExpertClaimService {
|
||||
const updated = await this.claimCaseDbService.findOneAndUpdate(
|
||||
{
|
||||
_id: claimRequestId,
|
||||
claimId: null,
|
||||
claimNo: null,
|
||||
claimId: claim.claimId ?? null,
|
||||
claimNo: claim.claimNo ?? null,
|
||||
dmgCaseId: claim.dmgCaseId ?? null,
|
||||
expertiseId: claim.expertiseId ?? null,
|
||||
fanavaranVehicleReview: (claim as any).fanavaranVehicleReview ?? null,
|
||||
...(fields?.filter ?? {}),
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user