PO-3412 Implementing exact offence code match#2384
Open
ChrisGarratt122 wants to merge 7 commits intomasterfrom
Open
PO-3412 Implementing exact offence code match#2384ChrisGarratt122 wants to merge 7 commits intomasterfrom
ChrisGarratt122 wants to merge 7 commits intomasterfrom
Conversation
iamfrankiemoran
requested changes
Mar 31, 2026
Contributor
iamfrankiemoran
left a comment
There was a problem hiding this comment.
There is also a P1 issue via codex /review:
- [P1] Reject ambiguous exact-code matches — /Users/iamfrankiemoran/Documents/GitHub/opal-frontend/src/app/flows/fines/fines-mac/fines-mac-offence-details/services/fines-mac-offence-details.service.ts:149-152
When the lookup response contains the same CJS code more than once (for example, the existing offence ref-data mock already has GMMET001 against multiple business units), findExactOffenceMatch() will return the first row and initOffenceCodeListener()
will now clear the validation error and persist that row's offence_id. That turns an ambiguous lookup into a seemingly valid selection, and the chosen offence_id is what later gets sent in the MAC account payload, so duplicated codes can be saved
against the wrong offence record. This should only be treated as a match when the exact code is unique, or after disambiguating by business unit/date.
...es/fines-mac/components/fines-mac-offence-code-hint/fines-mac-offence-code-hint.component.ts
Show resolved
Hide resolved
...nce-details-add-an-offence-form/fines-mac-offence-details-add-an-offence-form.component.html
Outdated
Show resolved
Hide resolved
…d to disambiguate duplicate matches.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira link
See PO-3412
Change description
Problem
Entering an offence code that is valid itself but also has related sub-codes could show an incorrect “Offence not found” message in Manual Account Creation.
Example:
CD71039CD71039,CD71039A,CD71039B,CD71039CCD71039is present in the response and the intended code to displayThis created an inconsistent journey because the review screen could still appear to show the correct offence later in the flow.
Cause
The cause of this was the conditional logic on
fines-mac-offence-code-hint.component.htmlset to display the retrieved offence code only whenresponse.count === 1. This means when a code not only pulls itself down from the backend but also all sub-codes the response count is more than 1 and this condition defaults the page to show "No offence found".In general multiple codes being returned in the response hasn't been accounted and these issues affected a few places:
That affected a few places:
offence_idwhenresponse.count === 1count === 1refData[0], which only worked if the exact match happened to be the first returned itemSo for multi-result responses containing a valid exact match, we could:
offence_idunsetSolution
The primary fix here is to change the condition that determines between displaying the offence code or error. Instead of checking for the number of responses, we should be looking for an exact match from all codes in a given response.
Fixes:
offence_idfrom that exact matchThis keeps the behaviour consistent across:
Considerations
Testing done
Manual testing
Unit testing
The testing approach focused on the exact-match behaviour across the full offence-code journey: service tests were used to verify that when the API returns multiple related offences, the lookup only succeeds if one record exactly matches the user-entered code, including both the positive case (CD71039 returned alongside CD71039A/B/C) and the negative case where similar results are returned but no exact match exists; targeted component tests then confirmed that the same rule is reflected in the UI, so the offence hint panel and both review displays now show the correct offence title and “Offence found” state for exact matches, and continue to show “Offence not found” where no exact match is present, removing any dependency on response ordering.
Security Vulnerability Assessment
CVE Suppression: Are there any CVEs present in the codebase (either newly introduced or pre-existing) that are being intentionally suppressed or ignored by this commit?
Checklist