forked from Yara724/api
status modfied
This commit is contained in:
@@ -85,6 +85,8 @@ import {
|
||||
partKeyAllowedForExpertResend,
|
||||
} from "src/helpers/claim-expert-resend";
|
||||
import {
|
||||
claimCaseStatusAllowsOwnerFactorUploadDuringRevision,
|
||||
claimCaseStatusAllowsOwnerInsurerSignStep,
|
||||
classifyV2ExpertPricingParts,
|
||||
getActiveV2ExpertReply,
|
||||
objectionDisallowedDueToOutstandingFactorWorkflow,
|
||||
@@ -2369,9 +2371,9 @@ export class ClaimRequestManagementService {
|
||||
);
|
||||
}
|
||||
|
||||
if (claim.status !== ClaimCaseStatus.WAITING_FOR_INSURER_APPROVAL) {
|
||||
if (!claimCaseStatusAllowsOwnerFactorUploadDuringRevision(claim.status)) {
|
||||
throw new BadRequestException(
|
||||
"Factors can only be uploaded while the insurer-approval phase is pending.",
|
||||
"Factors can only be uploaded while the claim is in a repair-factor upload phase (see ClaimCaseStatus).",
|
||||
);
|
||||
}
|
||||
if (claim.claimStatus !== ClaimStatus.NEEDS_REVISION) {
|
||||
@@ -2487,6 +2489,7 @@ export class ClaimRequestManagementService {
|
||||
|
||||
await this.claimCaseDbService.findByIdAndUpdate(claimRequestId, {
|
||||
$set: {
|
||||
status: ClaimCaseStatus.EXPERT_VALIDATING_REPAIR_FACTORS,
|
||||
claimStatus: ClaimStatus.UNDER_REVIEW,
|
||||
"workflow.currentStep": ClaimWorkflowStep.EXPERT_COST_EVALUATION,
|
||||
"workflow.nextStep": ClaimWorkflowStep.INSURER_REVIEW,
|
||||
@@ -5064,7 +5067,7 @@ export class ClaimRequestManagementService {
|
||||
/**
|
||||
* V2 API: User objection (ClaimCase + evaluation.objection payload).
|
||||
*
|
||||
* Priced-flow: WAITING_FOR_INSURER_APPROVAL @ INSURER_REVIEW — either NEEDS_REVISION (mixed-priced gate before factor upload)
|
||||
* Priced-flow: insurer-review post-expert statuses (`INSURER_REVIEW_AWAITING_OWNER_SIGN`, `INSURER_REVIEW_MIXED_FACTORS_PENDING`, or legacy `WAITING_FOR_INSURER_APPROVAL`) @ `INSURER_REVIEW` — either NEEDS_REVISION (mixed-priced gate before factor upload)
|
||||
* or APPROVED (final totals after pricing / factor validation); never while uploading factors or while expert validates.
|
||||
* Legacy: objection during unpaid expert resend (`WAITING_FOR_USER_RESEND` @ `USER_EXPERT_RESEND`).
|
||||
* Post: resets owner signatures when applicable and returns claim to WAITING_FOR_DAMAGE_EXPERT.
|
||||
@@ -5121,7 +5124,7 @@ export class ClaimRequestManagementService {
|
||||
|
||||
let pricingObjectionEligible = false;
|
||||
if (
|
||||
claimCase.status === ClaimCaseStatus.WAITING_FOR_INSURER_APPROVAL &&
|
||||
claimCaseStatusAllowsOwnerInsurerSignStep(claimCase.status) &&
|
||||
claimCase.workflow?.currentStep === ClaimWorkflowStep.INSURER_REVIEW &&
|
||||
!claimCase.evaluation?.ownerInsurerApproval?.signedAt
|
||||
) {
|
||||
@@ -5321,11 +5324,11 @@ export class ClaimRequestManagementService {
|
||||
/**
|
||||
* V2: Claim owner signature on expert pricing.
|
||||
*
|
||||
* Phase 1 (mixed priced + factor-needed lines): WAITING_FOR_INSURER_APPROVAL, NEEDS_REVISION, INSURER_REVIEW,
|
||||
* Phase 1 (mixed priced + factor-needed lines): `INSURER_REVIEW_MIXED_FACTORS_PENDING` (or legacy `WAITING_FOR_INSURER_APPROVAL`), NEEDS_REVISION, INSURER_REVIEW,
|
||||
* owner has not yet accepted priced lines — agreeing records `evaluation.ownerPricedPartsApproval` and moves the
|
||||
* workflow to OWNER_UPLOAD_FACTOR_DOCUMENTS. Rejecting rejects the whole case.
|
||||
*
|
||||
* Phase 2 (final): WAITING_FOR_INSURER_APPROVAL, APPROVED, INSURER_REVIEW — full accept/reject completes the case.
|
||||
* Phase 2 (final): INSURER_REVIEW_AWAITING_OWNER_SIGN (or legacy WAITING_FOR_INSURER_APPROVAL), APPROVED, INSURER_REVIEW — full accept/reject completes the case.
|
||||
*/
|
||||
async submitOwnerInsurerApprovalSignV2(
|
||||
claimRequestId: string,
|
||||
@@ -5366,7 +5369,7 @@ export class ClaimRequestManagementService {
|
||||
);
|
||||
}
|
||||
|
||||
if (claimCase.status !== ClaimCaseStatus.WAITING_FOR_INSURER_APPROVAL) {
|
||||
if (!claimCaseStatusAllowsOwnerInsurerSignStep(claimCase.status)) {
|
||||
throw new BadRequestException(
|
||||
`Claim is not waiting for your insurer-approval signature. Current status: ${String(claimCase.status)}`,
|
||||
);
|
||||
@@ -5515,7 +5518,7 @@ export class ClaimRequestManagementService {
|
||||
message:
|
||||
"Priced repair lines accepted. Upload repair factor files for each factor-needed part; the claim will return to the damage expert for cost validation.",
|
||||
claimRequestId,
|
||||
status: ClaimCaseStatus.WAITING_FOR_INSURER_APPROVAL,
|
||||
status: claimCase.status,
|
||||
claimStatus: ClaimStatus.NEEDS_REVISION,
|
||||
currentStep: ClaimWorkflowStep.OWNER_UPLOAD_FACTOR_DOCUMENTS,
|
||||
accepted: true,
|
||||
|
||||
@@ -156,7 +156,7 @@ export class ClaimRequestManagementV2Controller {
|
||||
@ApiOperation({
|
||||
summary: "Submit user objection (V2)",
|
||||
description:
|
||||
"**Windows:** (1) **Insurer-review:** `WAITING_FOR_INSURER_APPROVAL` + `workflow.currentStep=INSURER_REVIEW` without a recorded **final** `evaluation.ownerInsurerApproval` signature — including **mixed** priced+factor gate (`NEEDS_REVISION` before factor upload signature) or **final** totals (`claimStatus=APPROVED`). Not allowed while `OWNER_UPLOAD_FACTOR_DOCUMENTS` or `EXPERT_COST_EVALUATION` (finish factor uploads / validation first).\n" +
|
||||
"**Windows:** (1) **Insurer-review:** `ClaimCaseStatus` in **`INSURER_REVIEW_AWAITING_OWNER_SIGN`**, **`INSURER_REVIEW_MIXED_FACTORS_PENDING`**, or legacy **`WAITING_FOR_INSURER_APPROVAL`**, with `workflow.currentStep=INSURER_REVIEW` and no recorded **final** `evaluation.ownerInsurerApproval` — including **mixed** priced+factor gate (`NEEDS_REVISION` before priced-line signature for factors) or **final** totals (`claimStatus=APPROVED`). Not allowed while uploading factors (`OWNER_UPLOAD_FACTOR_DOCUMENTS`) or expert validation (`EXPERT_COST_EVALUATION`/`EXPERT_VALIDATING_REPAIR_FACTORS`).\n" +
|
||||
"(2) **Legacy resend:** active expert resend (`WAITING_FOR_USER_RESEND` @ `USER_EXPERT_RESEND`).\n\n" +
|
||||
"`objectionParts` may only reference **priced** repair lines (`factorNeeded=false`). Factor-only lines cannot be disputed until they have expert pricing.\n\n" +
|
||||
"After **`damageExpertReplyFinal`** exists (final reply following a prior objection), **no second objection** — owner uses **owner-insurer-approval/sign** to accept/reject and close the case.\n\n" +
|
||||
@@ -247,7 +247,7 @@ export class ClaimRequestManagementV2Controller {
|
||||
@ApiOperation({
|
||||
summary: "Sign priced lines or final claim pricing (owner)",
|
||||
description:
|
||||
"Multipart: `sign`, `agree`, `branchId`. Always requires `status=WAITING_FOR_INSURER_APPROVAL` and `workflow.currentStep=INSURER_REVIEW` (never during `EXPERT_COST_EVALUATION`).\n\n" +
|
||||
"Multipart: `sign`, `agree`, `branchId`. Requires `ClaimCaseStatus` **`INSURER_REVIEW_AWAITING_OWNER_SIGN`**, **`INSURER_REVIEW_MIXED_FACTORS_PENDING`**, or legacy **`WAITING_FOR_INSURER_APPROVAL`**, and `workflow.currentStep=INSURER_REVIEW` (not during owner factor upload or `EXPERT_COST_EVALUATION`).\n\n" +
|
||||
"**Phase A — Mixed reply, priced lines only:** `claimStatus=NEEDS_REVISION`, no `evaluation.ownerPricedPartsApproval` yet. `agree=true` records that signature and moves to `OWNER_UPLOAD_FACTOR_DOCUMENTS` for factor uploads; `agree=false` rejects the whole case (`REJECTED`).\n\n" +
|
||||
"**Phase B — Final:** `claimStatus=APPROVED`, no `evaluation.ownerInsurerApproval` yet. `agree=true` → `COMPLETED`; `agree=false` → `REJECTED`.\n\n" +
|
||||
"Response may include `phase`: `PRICED_PARTS_FOR_FACTORS` or `FINAL_APPROVAL` for UI state.",
|
||||
@@ -895,9 +895,9 @@ Returns status of each item (uploaded/captured or not).
|
||||
summary: "Upload repair factor file for a factor-needed part (V2)",
|
||||
description:
|
||||
"Part must have `factorNeeded: true` on the active reply (`evaluation.damageExpertReply` or `evaluation.damageExpertReplyFinal`). One file per part.\n\n" +
|
||||
"**Requires:** `status=WAITING_FOR_INSURER_APPROVAL`, `claimStatus=NEEDS_REVISION`, `workflow.currentStep=OWNER_UPLOAD_FACTOR_DOCUMENTS`.\n\n" +
|
||||
"**Requires:** `ClaimCaseStatus` **`OWNER_REPAIR_FACTOR_UPLOAD_PENDING`** or **`INSURER_REVIEW_MIXED_FACTORS_PENDING`** (or legacy **`WAITING_FOR_INSURER_APPROVAL`**), `claimStatus=NEEDS_REVISION`, `workflow.currentStep=OWNER_UPLOAD_FACTOR_DOCUMENTS`.\n\n" +
|
||||
"**Mixed priced+factor replies:** owner must complete **owner-insurer-approval/sign** (priced-line phase) first so `evaluation.ownerPricedPartsApproval` exists.\n\n" +
|
||||
"When every `factorNeeded` line has `factorLink`, the case moves to `claimStatus=UNDER_REVIEW`, `workflow.currentStep=EXPERT_COST_EVALUATION` for damage expert validation.",
|
||||
"When every `factorNeeded` line has `factorLink`, the case moves to **`EXPERT_VALIDATING_REPAIR_FACTORS`**, `claimStatus=UNDER_REVIEW`, `workflow.currentStep=EXPERT_COST_EVALUATION` for damage expert validation.",
|
||||
})
|
||||
@ApiParam({ name: "claimRequestId", description: "Claim case ID" })
|
||||
@ApiParam({ name: "partId", description: "Part id from expert reply" })
|
||||
|
||||
@@ -83,7 +83,11 @@ export class ClaimDetailsV2ResponseDto {
|
||||
@ApiProperty({ description: 'Request number' })
|
||||
requestNo: string;
|
||||
|
||||
@ApiProperty({ description: 'Overall case status' })
|
||||
@ApiProperty({
|
||||
description:
|
||||
"ClaimCaseStatus; see also `ownerGuidance` for UX. Post-expert: INSURER_REVIEW_AWAITING_OWNER_SIGN | INSURER_REVIEW_MIXED_FACTORS_PENDING | OWNER_REPAIR_FACTOR_UPLOAD_PENDING | EXPERT_VALIDATING_REPAIR_FACTORS; legacy WAITING_FOR_INSURER_APPROVAL may still appear.",
|
||||
example: "OWNER_REPAIR_FACTOR_UPLOAD_PENDING",
|
||||
})
|
||||
status: string;
|
||||
|
||||
@ApiProperty({ description: 'Claim damage status' })
|
||||
|
||||
@@ -10,7 +10,11 @@ export class ClaimListItemV2Dto {
|
||||
@ApiProperty({ description: 'Claim request number', example: 'CL12345' })
|
||||
requestNo: string;
|
||||
|
||||
@ApiProperty({ description: 'Overall case status', example: 'WAITING_FOR_DAMAGE_EXPERT' })
|
||||
@ApiProperty({
|
||||
description:
|
||||
"ClaimCaseStatus. Post-expert owner phase includes: INSURER_REVIEW_AWAITING_OWNER_SIGN (priced lines only → final owner sign); INSURER_REVIEW_MIXED_FACTORS_PENDING (priced + factor lines); OWNER_REPAIR_FACTOR_UPLOAD_PENDING (all lines factor-needed); EXPERT_VALIDATING_REPAIR_FACTORS (all factors uploaded, expert validating). Legacy DB rows may still use WAITING_FOR_INSURER_APPROVAL for those flows.",
|
||||
example: "INSURER_REVIEW_AWAITING_OWNER_SIGN",
|
||||
})
|
||||
status: string;
|
||||
|
||||
@ApiProperty({ description: 'Claim damage determination status', example: 'PENDING' })
|
||||
|
||||
@@ -76,7 +76,7 @@ export class ClaimUserComment {
|
||||
export const ClaimUserCommentSchema =
|
||||
SchemaFactory.createForClass(ClaimUserComment);
|
||||
|
||||
/** Owner acceptance + signature after expert pricing (WAITING_FOR_INSURER_APPROVAL @ INSURER_REVIEW). */
|
||||
/** Owner acceptance + signature after expert pricing (post-expert insurer `INSURER_REVIEW` — `INSURER_REVIEW_AWAITING_OWNER_SIGN` / `INSURER_REVIEW_MIXED_FACTORS_PENDING` / legacy `WAITING_FOR_INSURER_APPROVAL`). */
|
||||
@Schema({ _id: false })
|
||||
export class ClaimOwnerInsurerApproval {
|
||||
@Prop({ type: Boolean, required: true })
|
||||
|
||||
Reference in New Issue
Block a user