def process(email_msg: dict) -> dict: """Build the email for mras notification.""" logger.debug('mras_notification: %s', email_msg) # get template and fill in parts template = Path(f'{current_app.config.get("TEMPLATE_PATH")}/BC-MRAS.html').read_text() filled_template = substitute_template_parts(template) # get template info from filing filing, business, leg_tmz_filing_date, leg_tmz_effective_date = get_filing_info(email_msg['filingId']) # render template with vars jnja_template = Template(filled_template, autoescape=True) html_out = jnja_template.render( business=business, incorporationApplication=(filing.json)['filing']['incorporationApplication'], header=(filing.json)['filing']['header'], filing_date_time=leg_tmz_filing_date, effective_date_time=leg_tmz_effective_date ) # get recipients recipients = get_recipients(email_msg['option'], filing.filing_json) return { 'recipients': recipients, 'requestBy': '*****@*****.**', 'content': { 'subject': 'BC Business Registry Partner Information', 'body': f'{html_out}', 'attachments': [] } }
def process(email_msg: dict) -> dict: """Build the email for Business Number notification.""" logger.debug('bn notification: %s', email_msg) # get template and fill in parts template = Path(f'{current_app.config.get("TEMPLATE_PATH")}/BC-BN.html').read_text() filled_template = substitute_template_parts(template) # get filing and business json business = Business.find_by_identifier(email_msg['identifier']) filing = (Filing.get_a_businesses_most_recent_filing_of_a_type(business.id, 'incorporationApplication')) # render template with vars jnja_template = Template(filled_template, autoescape=True) html_out = jnja_template.render( business=business.json() ) # get recipients recipients = get_recipients(email_msg['option'], filing.filing_json) return { 'recipients': recipients, 'requestBy': '*****@*****.**', 'content': { 'subject': f'{business.legal_name} - Business Number Information', 'body': html_out, 'attachments': [] } }
def process(email_msg: dict, token: str) -> dict: # pylint: disable=too-many-locals """Build the email for Business Number notification.""" logger.debug('incorp_notification: %s', email_msg) # get template and fill in parts template = Path(f'{current_app.config.get("TEMPLATE_PATH")}/BC-{email_msg["option"]}-success.html').read_text() filled_template = substitute_template_parts(template) # get template vars from filing filing, business, leg_tmz_filing_date, leg_tmz_effective_date = get_filing_info(email_msg['filingId']) # render template with vars jnja_template = Template(filled_template, autoescape=True) html_out = jnja_template.render( business=business, incorporationApplication=(filing.json)['filing']['incorporationApplication'], header=(filing.json)['filing']['header'], filing_date_time=leg_tmz_filing_date, effective_date_time=leg_tmz_effective_date, entity_dashboard_url=current_app.config.get('DASHBOARD_URL') + (filing.json)['filing']['business'].get('identifier', '') ) # get attachments pdfs = _get_pdfs(email_msg['option'], token, business, filing, leg_tmz_filing_date) # get recipients recipients = get_recipients(email_msg['option'], filing.filing_json) # assign subject if email_msg['option'] == 'filed': subject = 'Confirmation of Filing from the Business Registry' elif email_msg['option'] == 'registered': subject = 'Incorporation Documents from the Business Registry' else: # fallback case - should never happen subject = 'Notification from the BC Business Registry' return { 'recipients': recipients, 'requestBy': '*****@*****.**', 'content': { 'subject': subject, 'body': f'{html_out}', 'attachments': pdfs } }
def process(email_info: dict, token: str) -> dict: # pylint: disable=too-many-locals, , too-many-branches """Build the email for Affiliation notification.""" logger.debug('filing_notification: %s', email_info) # get template vars from filing filing, business, leg_tmz_filing_date, leg_tmz_effective_date = \ get_filing_info(email_info['data']['filing']['header']['filingId']) filing_type = filing.filing_type status = filing.status filing_name = filing.filing_type[0].upper() + ' '.join(re.findall('[a-zA-Z][^A-Z]*', filing.filing_type[1:])) template = Path(f'{current_app.config.get("TEMPLATE_PATH")}/BC-ALT-DRAFT.html').read_text() filled_template = substitute_template_parts(template) # render template with vars jnja_template = Template(filled_template, autoescape=True) filing_data = (filing.json)['filing'][f'{filing_type}'] html_out = jnja_template.render( business=business, filing=filing_data, header=(filing.json)['filing']['header'], filing_date_time=leg_tmz_filing_date, effective_date_time=leg_tmz_effective_date, entity_dashboard_url=current_app.config.get('DASHBOARD_URL') + (filing.json)['filing']['business'].get('identifier', ''), email_header=filing_name.upper(), filing_type=filing_type ) # get recipients recipients = get_recipients(status, filing.filing_json, token) if not recipients: return {} # assign subject legal_name = business.get('legalName', None) subject = f'{legal_name} - How to use BCRegistry.ca' return { 'recipients': recipients, 'requestBy': '*****@*****.**', 'content': { 'subject': subject, 'body': f'{html_out}' } }
def process(email_info: dict, token: str) -> dict: # pylint: disable=too-many-locals, , too-many-branches """Build the email for Business Number notification.""" logger.debug('filing_notification: %s', email_info) # get template and fill in parts filing_type, status = email_info['type'], email_info['option'] # get template vars from filing filing, business, leg_tmz_filing_date, leg_tmz_effective_date = get_filing_info( email_info['filingId']) if filing_type == 'correction': original_filing_type = filing.filing_json['filing']['correction'][ 'correctedFilingType'] if original_filing_type != 'incorporationApplication': return None original_filing_name = original_filing_type[0].upper() + ' '.join( re.findall('[a-zA-Z][^A-Z]*', original_filing_type[1:])) filing_name = f'Correction of {original_filing_name}' else: filing_name = filing.filing_type[0].upper() + ' '.join( re.findall('[a-zA-Z][^A-Z]*', filing.filing_type[1:])) if filing_type == 'correction': template = Path( f'{current_app.config.get("TEMPLATE_PATH")}/BC-{FILING_TYPE_CONVERTER[filing_type]}-' f'{FILING_TYPE_CONVERTER[original_filing_type]}-{status}.html' ).read_text() else: template = Path( f'{current_app.config.get("TEMPLATE_PATH")}/BC-{FILING_TYPE_CONVERTER[filing_type]}-{status}.html' ).read_text() filled_template = substitute_template_parts(template) # render template with vars jnja_template = Template(filled_template, autoescape=True) filing_data = (filing.json)['filing'][f'{original_filing_type}'] if filing_type == 'correction' \ else (filing.json)['filing'][f'{filing_type}'] html_out = jnja_template.render( business=business, filing=filing_data, header=(filing.json)['filing']['header'], filing_date_time=leg_tmz_filing_date, effective_date_time=leg_tmz_effective_date, entity_dashboard_url=current_app.config.get('DASHBOARD_URL') + (filing.json)['filing']['business'].get('identifier', ''), email_header=filing_name.upper(), filing_type=filing_type, additional_info=get_additional_info(filing)) # get attachments pdfs = _get_pdfs(status, token, business, filing, leg_tmz_filing_date, leg_tmz_effective_date) # get recipients recipients = get_recipients(status, filing.filing_json, token) if not recipients: return {} # assign subject if status == Filing.Status.PAID.value: if filing_type == 'incorporationApplication': subject = 'Confirmation of Filing from the Business Registry' elif filing_type == 'correction': subject = f'Confirmation of Correction of {original_filing_name}' elif filing_type in ['changeOfAddress', 'changeOfDirectors']: address_director = [ x for x in ['Address', 'Director'] if x in filing_type ][0] subject = f'Confirmation of {address_director} Change' elif filing_type == 'annualReport': subject = 'Confirmation of Annual Report' elif filing_type == 'alteration': subject = 'Confirmation of Alteration from the Business Registry' elif status == Filing.Status.COMPLETED.value: if filing_type == 'incorporationApplication': subject = 'Incorporation Documents from the Business Registry' if filing_type == 'correction': subject = f'{original_filing_name} Correction Documents from the Business Registry' elif filing_type in [ 'changeOfAddress', 'changeOfDirectors', 'alteration', 'correction' ]: subject = 'Notice of Articles' if not subject: # fallback case - should never happen subject = 'Notification from the BC Business Registry' if filing.filing_type == 'incorporationApplication': legal_name = \ filing.filing_json['filing']['incorporationApplication']['nameRequest'].get('legalName', None) else: legal_name = business.get('legalName', None) subject = f'{legal_name} - {subject}' if legal_name else subject return { 'recipients': recipients, 'requestBy': '*****@*****.**', 'content': { 'subject': subject, 'body': f'{html_out}', 'attachments': pdfs } }