So this is going to be a very rare case, but consider:
The user manually uploads a milti-ballot SOPN
The ballots in the SOPN contain Foo North ward and Foo ward
This is a upload against Foo ward
Foo North ward is first in the PDF
I think this ballot will get matched to Foo North ward not Foo ward
This is because the parser sorts the possible ballots by the post label length, and then assumes the first match is right.
Suggested actions
Here's another idea that might solve other problems - because the problem I outlined might happen when we import from the spreadsheet too:
When matching pages, we always look at all ballots in the election (sibling ballots).
We then match each page to each ballot, but only store the pages matched against the OfficialDocument that's been uploaded.
This might end up as quite a big refactor, but it would mean that we don't need to worry about matching partial SOPNs at all.
Issue and Steps to Reproduce
Taken from comments to #1375
So this is going to be a very rare case, but consider:
Suggested actions
Here's another idea that might solve other problems - because the problem I outlined might happen when we import from the spreadsheet too:
When matching pages, we always look at all ballots in the election (sibling ballots).
We then match each page to each ballot, but only store the pages matched against the OfficialDocument that's been uploaded.
This might end up as quite a big refactor, but it would mean that we don't need to worry about matching partial SOPNs at all.