forked from Yara724/api
fix(claims): defer flow 1 fanavaran submission at creation
Skip creation-time submission for Flow 1 while preserving branch validation, later staged submission, and other flows.
This commit is contained in:
@@ -20,6 +20,8 @@ Invalid IDs, inactive branches and branches from another insurer are rejected wi
|
||||
|
||||
`createClaimFromBlameV2` revalidates the active branch and copies `blame.branchId` to `claim.branchId`. Missing/invalid selection prevents creation and automatic Fanavaran submission. Changing browser state or calling the creation endpoint directly cannot omit branch validation. This adds no Fanavaran lookup ID or payload field.
|
||||
|
||||
Flow 1 skips automatic Fanavaran submission during local claim creation. Later staged submission hooks remain enabled and can create the base Fanavaran claim when needed. Flow 6 and expert/registrar/FileMaker-created flows retain their existing submission timing.
|
||||
|
||||
The existing expert claim list filter and detail/assignment/action authorization compare the claim branch with the expert's stored branch, in addition to insurer/tenant isolation. Thus a new routed claim appears in that branch's queue and is rejected for damage experts from another branch, including direct access by case ID. Missing expert branch assignments are already denied. Insurer administrators should assign claim experts to the appropriate branches before rollout.
|
||||
|
||||
Existing claims are not migrated or reassigned. Their current access/ownership rules remain in effect. Already-signed blame cases without a claim select their branch on the final screen before entering claim creation. Direct entry into `/claim` also checks selection and returns to that screen if necessary. Deactivation between signing and creation requires choosing another active branch.
|
||||
|
||||
@@ -90,10 +90,50 @@ describe("claim beneficiary authorization across shared user flows", () => {
|
||||
expect(saved.owner.userClientKey).toBe(payer);
|
||||
expect(
|
||||
service.autoSubmitToFanavaranV2OnClaimCreated,
|
||||
).toHaveBeenCalledTimes(1);
|
||||
).not.toHaveBeenCalled();
|
||||
},
|
||||
);
|
||||
|
||||
it.each(["THIRD_PARTY", "CAR_BODY"])(
|
||||
"defers Flow 1 %s submission at creation while retaining the selected branch",
|
||||
async (type) => {
|
||||
const blame = source();
|
||||
blame.type = type;
|
||||
blame.branchId = "650000000000000000000099";
|
||||
if (type === "CAR_BODY") blame.parties = [blame.parties[0]];
|
||||
const service = serviceFor(blame);
|
||||
|
||||
const result = await service.createClaimFromBlameV2(
|
||||
blameId,
|
||||
type === "CAR_BODY" ? firstId : secondId,
|
||||
);
|
||||
|
||||
expect(result.fanavaran).toMatchObject({
|
||||
attempted: false,
|
||||
submitted: false,
|
||||
skipped: true,
|
||||
});
|
||||
expect(service.autoSubmitToFanavaranV2OnClaimCreated).not.toHaveBeenCalled();
|
||||
expect(service.userClaimBranchService.validate).toHaveBeenCalledWith(blame, blame.branchId);
|
||||
expect(String(service.claimCaseDbService.create.mock.calls[0][0].branchId)).toBe(blame.branchId);
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
{ callCenterInitiated: true },
|
||||
{ expertInitiated: true, creationMethod: "LINK" },
|
||||
{ expertInitiated: true, creationMethod: "IN_PERSON" },
|
||||
{ registrarInitiated: true },
|
||||
{ isMadeByFileMaker: true },
|
||||
])("preserves early submission for other flows: %j", async (flags) => {
|
||||
const service = serviceFor({ ...source(), ...flags });
|
||||
|
||||
await service.createClaimFromBlameV2(blameId, secondId);
|
||||
|
||||
expect(service.autoSubmitToFanavaranV2OnClaimCreated).toHaveBeenCalledTimes(1);
|
||||
expect(service.autoSubmitToFanavaranV2OnClaimCreated).toHaveBeenCalledWith(claimId);
|
||||
});
|
||||
|
||||
it("blocks incomplete, unsigned, rejected, and unresolved cases without creating or submitting a claim", async () => {
|
||||
const invalid = [
|
||||
{ ...source(), status: "WAITING_FOR_SIGNATURES" },
|
||||
|
||||
@@ -8213,9 +8213,18 @@ export class ClaimRequestManagementService {
|
||||
`Claim created: ${newClaim._id} from blame: ${blameRequestId}`,
|
||||
);
|
||||
|
||||
const fanavaran = await this.autoSubmitToFanavaranV2OnClaimCreated(
|
||||
String(newClaim._id),
|
||||
);
|
||||
// Flow 1 defers Fanavaran submission to the later staged hooks.
|
||||
// Flow 6 and expert/registrar-created cases retain early submission.
|
||||
const deferFanavaran =
|
||||
usesUserClaimBranch(blameRequest) && !blameRequest.callCenterInitiated;
|
||||
const fanavaran: FanavaranAutoSubmitResult = deferFanavaran
|
||||
? {
|
||||
attempted: false,
|
||||
submitted: false,
|
||||
skipped: true,
|
||||
skipReason: 'Flow 1 defers Fanavaran submission until a later stage',
|
||||
}
|
||||
: await this.autoSubmitToFanavaranV2OnClaimCreated(String(newClaim._id));
|
||||
const message = this.withFanavaranAutoSubmitMessage(
|
||||
'Claim request created successfully',
|
||||
fanavaran,
|
||||
|
||||
Reference in New Issue
Block a user