aboutsummaryrefslogtreecommitdiffstats
path: root/python/report_ops/custodians.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/report_ops/custodians.py')
-rw-r--r--python/report_ops/custodians.py29
1 files changed, 3 insertions, 26 deletions
diff --git a/python/report_ops/custodians.py b/python/report_ops/custodians.py
index 3d64fe68..16940e1a 100644
--- a/python/report_ops/custodians.py
+++ b/python/report_ops/custodians.py
@@ -3,6 +3,7 @@ from typing import ClassVar
from dataclasses import dataclass
import gpg
import re
+import dateutil.parser as dp
from selenium.common.exceptions import (
StaleElementReferenceException,
ElementNotInteractableException,
@@ -177,32 +178,8 @@ class BNY(Custodian, account="BONY2"):
for attach in msg.attachments:
fname = attach.name
if fname.endswith("csv"):
- base_name = fname.removesuffix(".csv")
- file_type, date_part = base_name.split("_")
- match file_type:
- case (
- "Asset Detail"
- | "Net Investment Earned Income by Security"
- | "Settled Cash Statement"
- ):
- date = datetime.datetime.strptime(
- date_part, "%d %b %Y"
- ).date()
- case "BowdstWires":
- try:
- date = datetime.datetime.strptime(
- date_part, "%Y%m%d%H%M%S"
- ).date()
- except ValueError:
- date = datetime.datetime.strptime(
- date_part, "%d %b %Y%H%M%S"
- ).date()
- case "Live-cash":
- date = datetime.datetime.strptime(
- date_part, "%Y%m%d%H%M%S"
- ).date()
- case _:
- continue
+ file_type, date_part = fname.split("_")
+ date = dp.parse(date_part.removesuffix(".csv")).date()
p = DAILY_DIR / str(date) / "Reports" / fname
if not p.parent.exists():
p.parent.mkdir(parents=True, exist_ok=True)