-
Notifications
You must be signed in to change notification settings - Fork 24
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
Conversation
payee = PayeeOption.createInterestHolder(compReqPayee.interestHolder, compReqPayee); | ||
} | ||
payee.rowVersion = compReqPayee.rowVersion; |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/4621 |
this.payees | ||
?.map<ApiGen_Concepts_CompReqPayee>(formPayee => formPayee.toApi()) | ||
?.filter(exists) ?? []; | ||
|
There was a problem hiding this comment.
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
getAcquisitionFileSolicitors: { | ||
execute: vi.fn(), | ||
loading: false, | ||
}, | ||
getAcquisitionFileRepresentatives: { | ||
execute: vi.fn(), | ||
loading: false, | ||
}, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confirmed locally - approved.
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