Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
vysakh-menon-aot committed Nov 5, 2024
1 parent 2254c4b commit b2d8530
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Dict

import pycountry
from legal_api.models import Address, Business, Office, Party, PartyRole, ShareClass, ShareSeries
from legal_api.models import Address, Office, Party, PartyRole

from entity_filer.filing_processors.filing_components import (
aliases,
Expand Down Expand Up @@ -48,26 +48,27 @@ def create_address(address_info: Dict, address_type: str) -> Address:

db_address_type = address_type.replace('Address', '')

address = Address(street=address_info.get('streetAddress'),
street_additional=address_info.get('streetAddressAdditional') or '',
city=address_info.get('addressCity'),
region=address_info.get('addressRegion'),
country=pycountry.countries.search_fuzzy(address_info.get('addressCountry'))[0].alpha_2,
postal_code=address_info.get('postalCode'),
delivery_instructions=address_info.get('deliveryInstructions') or '',
address_type=db_address_type
)
address = Address(
street=address_info.get('streetAddress') or '',
street_additional=address_info.get('streetAddressAdditional') or '',
city=address_info.get('addressCity') or '',
region=address_info.get('addressRegion') or '',
country=pycountry.countries.search_fuzzy(address_info.get('addressCountry'))[0].alpha_2,
postal_code=address_info.get('postalCode') or '',
delivery_instructions=address_info.get('deliveryInstructions') or '',
address_type=db_address_type
)
return address


def update_address(address: Address, new_info: dict) -> Address:
"""Update address with new info."""
address.street = new_info.get('streetAddress')
address.street = new_info.get('streetAddress') or ''
address.street_additional = new_info.get('streetAddressAdditional') or ''
address.city = new_info.get('addressCity')
address.region = new_info.get('addressRegion')
address.city = new_info.get('addressCity') or ''
address.region = new_info.get('addressRegion') or ''
address.country = pycountry.countries.search_fuzzy(new_info.get('addressCountry'))[0].alpha_2
address.postal_code = new_info.get('postalCode')
address.postal_code = new_info.get('postalCode') or ''
address.delivery_instructions = new_info.get('deliveryInstructions') or ''

return address
Expand Down Expand Up @@ -157,29 +158,3 @@ def update_director(director: PartyRole, new_info: dict) -> PartyRole:
director.cessation_date = new_info.get('cessationDate')

return director


def create_share_class(share_class_info: dict) -> ShareClass:
"""Create a new share class and associated series."""
share_class = ShareClass(
name=share_class_info['name'],
priority=share_class_info['priority'],
max_share_flag=share_class_info['hasMaximumShares'],
max_shares=share_class_info.get('maxNumberOfShares', None),
par_value_flag=share_class_info['hasParValue'],
par_value=share_class_info.get('parValue', None),
currency=share_class_info.get('currency', None),
special_rights_flag=share_class_info['hasRightsOrRestrictions']
)
share_class.series = []
for series in share_class_info['series']:
share_series = ShareSeries(
name=series['name'],
priority=series['priority'],
max_share_flag=series['hasMaximumShares'],
max_shares=series.get('maxNumberOfShares', None),
special_rights_flag=series['hasRightsOrRestrictions']
)
share_class.series.append(share_series)

return share_class
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ def update_business_share_class(share_classes: list, business: Business, exclusi

def update_share_class(share_class: ShareClass, share_class_info: dict):
"""Update share class instance in db."""
share_class.name = share_class_info.get('name')
share_class.priority = share_class_info.get('priority')
share_class.max_share_flag = share_class_info.get('hasMaximumShares')
share_class.name = share_class_info['name']
share_class.priority = share_class_info['priority']
share_class.max_share_flag = share_class_info['hasMaximumShares']
share_class.max_shares = share_class_info.get('maxNumberOfShares', None)
share_class.par_value_flag = share_class_info.get('hasParValue')
share_class.par_value_flag = share_class_info['hasParValue']
share_class.par_value = share_class_info.get('parValue', None)
share_class.currency = share_class_info.get('currency', None)
share_class.special_rights_flag = share_class_info.get('hasRightsOrRestrictions')
share_class.special_rights_flag = share_class_info['hasRightsOrRestrictions']

# array of ids for share series instance from db
share_class_series_ids = []
Expand All @@ -233,8 +233,8 @@ def update_share_class(share_class: ShareClass, share_class_info: dict):

def update_share_series(series_info: dict, series: ShareSeries):
"""Update share series."""
series.name = series_info.get('name')
series.priority = series_info.get('priority')
series.max_share_flag = series_info.get('hasMaximumShares')
series.name = series_info['name']
series.priority = series_info['priority']
series.max_share_flag = series_info['hasMaximumShares']
series.max_shares = series_info.get('maxNumberOfShares', None)
series.special_rights_flag = series_info.get('hasRightsOrRestrictions')
series.special_rights_flag = series_info['hasRightsOrRestrictions']

0 comments on commit b2d8530

Please sign in to comment.