Skip to content

Commit

Permalink
fix: corrected get last ar filed date method (#3001)
Browse files Browse the repository at this point in the history
  • Loading branch information
EPortman authored Sep 25, 2024
1 parent 41422f0 commit 82aec4b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions colin-api/src/colin_api/models/filing.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
ShareObject, # noqa: I001
) # noqa: I001
from colin_api.resources.db import DB
from colin_api.utils import convert_to_json_date, convert_to_json_datetime, convert_to_snake
from colin_api.utils import convert_to_json_date, convert_to_json_datetime, convert_to_pacific_time, convert_to_snake


# Code smells:
Expand Down Expand Up @@ -1297,8 +1297,17 @@ def add_filing(cls, con, filing: Filing) -> int:
@classmethod
def _get_last_ar_filed_date(cls, header: dict, business: dict):
filing_year = header.get('filingYear')
recognition_dt = datetime.datetime.fromisoformat(business.get('business').get('foundingDate')).date()
last_ar_filed_dt = f'{filing_year}-{recognition_dt.month}-{recognition_dt.day}'
founding_date_str = business.get('business').get('foundingDate')

# If the founding date has `-00:00`, replace it with `+00:00` before passing to the function
if '-00:00' in founding_date_str:
founding_date_str = founding_date_str.replace('-00:00', '+00:00')

pacific_founding_date = datetime.datetime.fromisoformat(
convert_to_pacific_time(founding_date_str)
).date()

last_ar_filed_dt = f'{filing_year}-{pacific_founding_date.month:02}-{pacific_founding_date.day:02}'
return last_ar_filed_dt

@classmethod
Expand Down

0 comments on commit 82aec4b

Please sign in to comment.