Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSP-9905 Error thrown when opening compensation requisition with legacy payee/null payee #4621

Merged
merged 5 commits into from
Jan 30, 2025

Conversation

asanchezr
Copy link
Collaborator

Fixed various null-pointer exceptions and faulty logic when showing/editing compensation requisitions due to having all payee keys set as null.
Added unit tests to cover those code paths

@asanchezr asanchezr added bug Something isn't working 5.8 labels Jan 30, 2025
@asanchezr asanchezr self-assigned this Jan 30, 2025
payee = PayeeOption.createInterestHolder(compReqPayee.interestHolder, compReqPayee);
}
payee.rowVersion = compReqPayee.rowVersion;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was one of the sources of NPE - when all payees are null then this variable is null so it cannot take an assignment of "rowVersion"

@@ -264,7 +264,9 @@ const UpdateCompensationRequisitionForm: React.FC<CompensationRequisitionFormPro
selectFunction={(optionPayees, selectedPayees) =>
optionPayees.filter(payee =>
selectedPayees?.find(
selectedPayee => selectedPayee.api_id === payee.api_id,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old logic was selecting some payees when they shouldn't. If you had an owner and an interest holder that had the same id then the multiselect would show both when one of them was selected. This happens because the same Id number (ie 1) can be used in different tables that feed into the payees multi-select.

Fixed by also checking for the type of payee (Owner, InterestHolder, etc) in addition to the entity key

} else if (isValidId(currentPayee?.acquisitionFileTeam?.organizationId)) {
currentPayeeDetail = PayeeDetail.createFromOrganization(
currentPayee.acquisitionFileTeam.organization,
);
}
}
currentPayeeDetail.compReqPayeeId = currentPayee.compReqPayeeId;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another source of NPE if all payees where null

Copy link
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/4621

Comment on lines +61 to +64
this.payees
?.map<ApiGen_Concepts_CompReqPayee>(formPayee => formPayee.toApi())
?.filter(exists) ?? [];

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to save CompReqPayee where all the payees are null - so we filter those records before calling the server

Comment on lines -38 to -45
getAcquisitionFileSolicitors: {
execute: vi.fn(),
loading: false,
},
getAcquisitionFileRepresentatives: {
execute: vi.fn(),
loading: false,
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods no longer exist - needed some cleanup

Copy link
Collaborator

@devinleighsmith devinleighsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirmed locally - approved.

@asanchezr asanchezr merged commit 6037615 into bcgov:dev Jan 30, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.8 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants