Skip to content

Commit

Permalink
22235 - Legal API - Small tweak on address format for dissolution AR …
Browse files Browse the repository at this point in the history
…letter (bcgov#2856)

* small tweak on address format for dissolution letter

Signed-off-by: Hongjing Chen <[email protected]>

* rename variable

Signed-off-by: Hongjing Chen <[email protected]>

* update

Signed-off-by: Hongjing Chen <[email protected]>

---------

Signed-off-by: Hongjing Chen <[email protected]>
  • Loading branch information
chenhongjing authored Jul 24, 2024
1 parent 11e423d commit 2e6ef23
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div>
{{ furnishing.mailingAddress.addressCity }}
{{ furnishing.mailingAddress.addressRegion }}
&nbsp;{{ furnishing.mailingAddress.postalCode }}
&nbsp;&nbsp;{{ furnishing.mailingAddress.postalCode }}
</div>
</div>
</div>
Expand Down
11 changes: 10 additions & 1 deletion legal-api/src/legal_api/reports/report_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 2e6ef23

Please sign in to comment.