diff --git a/legal-api/report-templates/noticeOfDissolutionCommencement.html b/legal-api/report-templates/noticeOfDissolutionCommencement.html index e1dbc0aa49..197cd6cc28 100644 --- a/legal-api/report-templates/noticeOfDissolutionCommencement.html +++ b/legal-api/report-templates/noticeOfDissolutionCommencement.html @@ -25,7 +25,7 @@
{{ furnishing.mailingAddress.addressCity }} {{ furnishing.mailingAddress.addressRegion }} -  {{ furnishing.mailingAddress.postalCode }} +   {{ furnishing.mailingAddress.postalCode }}
diff --git a/legal-api/src/legal_api/reports/report_v2.py b/legal-api/src/legal_api/reports/report_v2.py index 7dfe946c0b..1f13742861 100644 --- a/legal-api/src/legal_api/reports/report_v2.py +++ b/legal-api/src/legal_api/reports/report_v2.py @@ -10,6 +10,7 @@ # specific language governing permissions and limitations under the License. """Produces a PDF output for Furnishing based on templates and JSON messages.""" import copy +import re from enum import auto from http import HTTPStatus from pathlib import Path @@ -28,6 +29,7 @@ from legal_api.utils.legislation_datetime import LegislationDatetime +POSTAL_CODE_REGEX: Final = r'^[A-Z]\d[A-Z]\d[A-Z]\d$' OUTPUT_DATE_FORMAT: Final = '%B %-d, %Y' SINGLE_URI: Final = '/forms/chromium/convert/html' HEADER_PATH: Final = '/template-parts/common/v2/header.html' @@ -156,7 +158,14 @@ def _set_meta_info(self): def _set_address(self): if (furnishing_address := Address.find_by(furnishings_id=self._furnishing.id)): furnishing_address = furnishing_address[0] - self._report_data['furnishing']['mailingAddress'] = furnishing_address.json + self._report_data['furnishing']['mailingAddress'] = self._format_address(furnishing_address.json) + + @staticmethod + def _format_address(address): + postal_code = address['postalCode'] + if re.match(POSTAL_CODE_REGEX, postal_code): + address['postalCode'] = postal_code[:3] + ' ' + postal_code[3:] + return address def _set_registrar_info(self): if self._furnishing.processed_date: