forked from Yara724/api
user owner guidence added + status and steps fixed
This commit is contained in:
67
src/helpers/claim-v2-expert-reply-workflow.ts
Normal file
67
src/helpers/claim-v2-expert-reply-workflow.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { ClaimCaseStatus } from "src/Types&Enums/claim-request-management/claim-case-status.enum";
|
||||
import { ClaimStatus } from "src/Types&Enums/claim-request-management/claimStatus.enum";
|
||||
import { ClaimWorkflowStep } from "src/Types&Enums/claim-request-management/claim-workflow-steps.enum";
|
||||
|
||||
export interface ClaimPricingPartLite {
|
||||
factorNeeded?: boolean;
|
||||
partId?: string;
|
||||
}
|
||||
|
||||
export function getActiveV2ExpertReply(claim: { evaluation?: Record<string, unknown> }): {
|
||||
replyKey: "damageExpertReplyFinal" | "damageExpertReply";
|
||||
reply: Record<string, unknown>;
|
||||
parts: ClaimPricingPartLite[];
|
||||
} | null {
|
||||
const fin = claim.evaluation?.damageExpertReplyFinal as
|
||||
| { parts?: ClaimPricingPartLite[]; submittedAt?: Date }
|
||||
| undefined;
|
||||
const ini = claim.evaluation?.damageExpertReply as
|
||||
| { parts?: ClaimPricingPartLite[]; submittedAt?: Date }
|
||||
| undefined;
|
||||
if (fin?.submittedAt && fin?.parts?.length) {
|
||||
return { replyKey: "damageExpertReplyFinal", reply: fin as Record<string, unknown>, parts: fin.parts };
|
||||
}
|
||||
if (ini?.submittedAt && ini?.parts?.length) {
|
||||
return { replyKey: "damageExpertReply", reply: ini as Record<string, unknown>, parts: ini.parts };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function classifyV2ExpertPricingParts(parts: ClaimPricingPartLite[]) {
|
||||
const factorNeeded = parts.filter((p) => p.factorNeeded === true);
|
||||
const priced = parts.filter((p) => p.factorNeeded !== true);
|
||||
return {
|
||||
pricedPartsCount: priced.length,
|
||||
factorNeededPartsCount: factorNeeded.length,
|
||||
mixedFactorAndPrice:
|
||||
factorNeeded.length > 0 && priced.length > 0,
|
||||
allFactorLines: factorNeeded.length > 0 && priced.length === 0,
|
||||
noFactors: factorNeeded.length === 0,
|
||||
};
|
||||
}
|
||||
|
||||
export function claimIsV2ExpertFactorUploadStep(claim: { workflow?: { currentStep?: string } }) {
|
||||
return claim.workflow?.currentStep === ClaimWorkflowStep.OWNER_UPLOAD_FACTOR_DOCUMENTS;
|
||||
}
|
||||
|
||||
export function claimIsV2PendingFactorExpertValidation(claim: {
|
||||
status?: ClaimCaseStatus;
|
||||
claimStatus?: ClaimStatus;
|
||||
workflow?: { currentStep?: string };
|
||||
}) {
|
||||
return (
|
||||
claim.status === ClaimCaseStatus.WAITING_FOR_INSURER_APPROVAL &&
|
||||
claim.claimStatus === ClaimStatus.UNDER_REVIEW &&
|
||||
claim.workflow?.currentStep === ClaimWorkflowStep.EXPERT_COST_EVALUATION
|
||||
);
|
||||
}
|
||||
|
||||
export function objectionDisallowedDueToOutstandingFactorWorkflow(claim: {
|
||||
workflow?: { currentStep?: string };
|
||||
}) {
|
||||
const step = claim.workflow?.currentStep;
|
||||
return (
|
||||
step === ClaimWorkflowStep.OWNER_UPLOAD_FACTOR_DOCUMENTS ||
|
||||
step === ClaimWorkflowStep.EXPERT_COST_EVALUATION
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user