Skip to content

Commit

Permalink
UI - updates for legal name change in legal-api
Browse files Browse the repository at this point in the history
Signed-off-by: Kial Jinnah <kialj876@gmail.com>
  • Loading branch information
kialj876 committed Jun 20, 2024
1 parent 9cce2b2 commit 754cbc8
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 deletions.
5 changes: 0 additions & 5 deletions search-api/src/search_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ class Config(): # pylint: disable=too-few-public-methods
SOLR_REINDEX_START_TIME = os.getenv('SOLR_REINDEX_START_TIME', '')
SOLR_REINDEX_LENGTH = int(os.getenv('SOLR_REINDEX_LENGTH')) if os.getenv('SOLR_REINDEX_LENGTH', None) else 0

# Temporary Legal Name change flags
ALTERNATE_NAMES_ACTIVE = 'true' == os.getenv('ALTERNATE_NAMES_ACTIVE', '').lower()


class DevelopmentConfig(Config): # pylint: disable=too-few-public-methods
"""Config object for development environment."""
Expand All @@ -165,8 +162,6 @@ class UnitTestingConfig(Config): # pylint: disable=too-few-public-methods
DEBUG = True
DEVELOPMENT = False
TESTING = True
# Temporary values
ALTERNATE_NAMES_ACTIVE = True
# SOLR
SOLR_SVC_URL = os.getenv('SOLR_SVC_TEST_URL', 'http://')
# POSTGRESQL
Expand Down
12 changes: 1 addition & 11 deletions search-api/src/search_api/resources/v1/internal/update_solr.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,6 @@ def needs_bc_prefix(identifier: str, legal_type: str) -> bool:
# TODO: get legal types from shared enum
return legal_type in ['BEN', 'BC', 'CC', 'ULC'] and re.search(numbers_only_rgx, identifier)

def get_business_name(business: Dict[str, str]) -> str:
"""Return the parsed name of the business in the given doc info."""
alternate_name_types = ['SP', 'GP'] if current_app.config.get('ALTERNATE_NAMES_ACTIVE') else []
if (legal_name := business.get('legalName')) and business['legalType'] not in alternate_name_types:
return legal_name.strip()
alternate_names = business['alternateNames']
if len(alternate_names) > 1:
current_app.logger.error('Business has more than one operating name: %s', business['identifier'])
return alternate_names[0]['operatingName'].strip()

def get_party_name(officer: Dict[str, str]) -> str:
"""Return the parsed name of the party in the given doc info."""
if officer.get('organizationName'):
Expand All @@ -146,7 +136,7 @@ def get_party_name(officer: Dict[str, str]) -> str:
bn=business_info.get('taxId'),
identifier=f'BC{identifier}' if needs_bc_prefix(identifier, legal_type) else identifier,
legalType=legal_type,
name=get_business_name(business_info),
name=business_info['legalName'].strip(),
status=business_info['state'],
goodStanding=business_info.get('goodStanding'))

Expand Down
5 changes: 3 additions & 2 deletions search-ui/src/components/EntityInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ import { BusinessStatuses, CorpTypeCd } from '@/enums'
// composables
const { pacificDate } = useDatetime()
const { entity, entityNumberLabel, getEntityDescription } = useEntity()
const { entity, entityNumberLabel, isFirm, getEntityDescription } = useEntity()
// computed
const businessDescription = computed(() => getEntityDescription(entity.legalType as CorpTypeCd))
const incorpDate = computed(() => pacificDate(new Date(entity.incorporationDate)))
const incorpDateDesc = computed(() => isFirm.value ? 'Registration Date' : 'Incorporation Date')
const businessInfo = computed(() => [
{ term: 'Incorporation Date', value: incorpDate.value || 'Not Available' },
{ term: incorpDateDesc.value, value: incorpDate.value || 'Not Available' },
{ term: entityNumberLabel.value, value: entity.identifier || 'Not Available' },
{ term: 'Business Number', value: entity.bn || 'Not Available'},
])
Expand Down
11 changes: 10 additions & 1 deletion search-ui/src/composables/entity-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ export const useEntity = () => {
const item = CorpInfoArray.find(obj => (entityType === obj.corpTypeCd))
return (item && item.fullDesc) || ''
}
const getEntityName = (entity: EntityI) => {
// return entity.name
if (!['GP', 'SP'].includes(entity.legalType)) {
return entity.name
}
const primaryName = entity.alternateNames?.find(val => val.identifier === entity.identifier)
return primaryName?.name || entity.name
}
const getEntityInfo = async (identifier: string) => {
// call legal api for entity data
const entityInfo = await getEntity(identifier)
Expand All @@ -52,6 +60,7 @@ export const useEntity = () => {
return null
}
const resp_entity: EntityI = {
alternateNames: entityInfo.business.alternateNames,
bn: entityInfo.business.taxId || '',
identifier: entityInfo.business.identifier,
incorporationDate: entityInfo.business.foundingDate,
Expand All @@ -68,7 +77,7 @@ export const useEntity = () => {
entity.identifier = newEntity.identifier
entity.incorporationDate = newEntity.incorporationDate || ''
entity.legalType = newEntity.legalType
entity.name = newEntity.name
entity.name = getEntityName(newEntity)
entity.status = newEntity.status
entity.goodStanding = newEntity.goodStanding
entity.inDissolution = newEntity.inDissolution
Expand Down
1 change: 1 addition & 0 deletions search-ui/src/interfaces/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BusinessStatuses, BusinessTypes, CorpTypeCd } from '@/enums'
import { ErrorI } from '@/interfaces';

export interface EntityI {
alternateNames?: { name: string, identifier: string }[]
bn?: string,
identifier: string,
incorporationDate?: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ErrorI } from '@/interfaces/error'

export interface LegalApiBusinessI {
adminFreeze: boolean
alternateNames?: { name: string, identifier: string }[]
arMaxDate: string // i.e. "2021-11-29"
arMinDate: string // i.e. "2021-01-01"
complianceWarnings: Array<any>
Expand Down
2 changes: 1 addition & 1 deletion search-ui/src/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const routes: RouteRecordRaw[] = [
component: BusinessInfoView,
props: true,
meta: {
requiresAuth: true,
requiresAuth: false, // app.vue will still verify token after page init
breadcrumb:[SearchHomeBreadCrumb, SearchDashboardBreadcrumb]
},
},
Expand Down

0 comments on commit 754cbc8

Please sign in to comment.