1717from mhr_api .exceptions import DatabaseException
1818from mhr_api .models import db , utils as model_utils , Db2Document
1919from mhr_api .models .db2 import address_utils
20- from mhr_api .models .type_tables import MhrNoteStatusTypes
20+ from mhr_api .models .type_tables import MhrDocumentTypes , MhrNoteStatusTypes
2121from mhr_api .utils .base import BaseEnum
2222
2323
@@ -134,6 +134,14 @@ def find_by_document_id(cls, document_id: str):
134134 note .strip ()
135135 return notes
136136
137+ def include_person_giving_notice (self ) -> bool :
138+ """Check by document type whether to include contact information (person giving notice)."""
139+ if not self .name or not self .document_type :
140+ return False
141+ return bool (self .document_type in (MhrDocumentTypes .CAU , MhrDocumentTypes .CAUC , MhrDocumentTypes .CAUE ,
142+ MhrDocumentTypes .REG_102 , MhrDocumentTypes .NPUB , MhrDocumentTypes .NCON ,
143+ MhrDocumentTypes .TAXN ))
144+
137145 def notice_party (self ):
138146 """Build giving notice party JSON from the unit note information."""
139147 # No way to distinguish individual from business: only used for display anyway.
@@ -161,7 +169,7 @@ def json(self):
161169 note ['destroyed' ] = True
162170 if self .document_type not in (Db2Document .DocumentTypes .RES_EXEMPTION ,
163171 Db2Document .DocumentTypes .NON_RES_EXEMPTION ):
164- if self .name :
172+ if self .include_person_giving_notice () :
165173 note ['givingNoticeParty' ] = self .notice_party ()
166174 return note
167175
@@ -174,7 +182,7 @@ def registration_json(self):
174182 'status' : FROM_LEGACY_STATUS .get (self .status ),
175183 'remarks' : self .remarks
176184 }
177- if self .name :
185+ if self .include_person_giving_notice () :
178186 note ['givingNoticeParty' ] = self .notice_party ()
179187 if self .expiry_date and self .expiry_date .isoformat () != '0001-01-01' :
180188 note ['expiryDateTime' ] = model_utils .format_local_date (self .expiry_date )
0 commit comments