Closed rsparker-utah closed 3 weeks ago
This may be the culprit code for when I have a better chance to dive into this. I'll need to write some tests to make sure. It may just be sorted backwards 😨 Thank you for the issue submission.
and
Validated that this is working as expected, thank you!
For reference, I tested by re-generating the ABR letters for the following four inventories that were experiencing this issue:
Each of these re-generated ABR letters is now correctly showing the owner as the addressee.
We may have found a bug regarding which contact the ABR letter is being addressed to. For some quick background (this background comes from #223 and the comment in the template referenced in #167), the Contact type order of preference for the ABR letter is:
The generated ABR letter for one of the recent submissions in the prod environment for the "Vineyard 10 & Vineyard Grove Park Stake" site (https://uic-inventory.deq.utah.gov/review/site/52/inventory/54) is being addressed to the "Other" contact instead of the expected "Owner". I did a test submission in the test environment on site "241009_ABR Contact Check" (https://uic-inventory.dev.utah.gov/review/site/169/inventory/326) using an "Owner" and "Other" contact type to see if I could recreate the bug, but the test ABR generated as expected (i.e., it was addressed to the listed owner). The only difference I can see between my test submission in the dev environment and the submission from the prod environment seems to be the order in which the submitter entered each of the contacts. For example, in the prod environment example, it looks like the submitter entered the "Other" contact first, then the "Operator" and the "Owner" last, whereas in my example, I entered the "Owner" first and then the "Other" contact second. I'm not sure if that has any influence on who the ABR letter is addressed to, but I thought I'd mention it in case it is pertinent.