aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/report_ops/__main__.py17
-rw-r--r--python/report_ops/custodians.py2
-rw-r--r--python/report_ops/scotia.py18
3 files changed, 18 insertions, 19 deletions
diff --git a/python/report_ops/__main__.py b/python/report_ops/__main__.py
index 856fe928..01cfef0e 100644
--- a/python/report_ops/__main__.py
+++ b/python/report_ops/__main__.py
@@ -74,18 +74,11 @@ if args.sma_positions:
logger.warning(e)
if args.cash_reports:
- for fund, custodians in _fund_custodians.items():
- for custodian in custodians:
- report = CashReport[
- (
- fund,
- custodian,
- )
- ](args.date)
- try:
- report.to_db()
- except ValueError as e:
- logger.warning(e)
+ for cash_report_cls in CashReport._registry.values():
+ try:
+ cash_report_cls(args.date).to_db()
+ except ValueError as e:
+ logger.warning(e)
if args.isosel_reports:
for fund in ("ISOSEL",):
diff --git a/python/report_ops/custodians.py b/python/report_ops/custodians.py
index 2c985225..33b5f154 100644
--- a/python/report_ops/custodians.py
+++ b/python/report_ops/custodians.py
@@ -200,4 +200,4 @@ class BNY(Custodian, account="BONY2"):
class SCOTIA(Custodian, account="SCOTIA"):
@staticmethod
def download_reports(date=datetime.date.today()):
- download_scotia_report()
+ download_scotia_report(date)
diff --git a/python/report_ops/scotia.py b/python/report_ops/scotia.py
index 3adece1e..fc22366b 100644
--- a/python/report_ops/scotia.py
+++ b/python/report_ops/scotia.py
@@ -6,6 +6,7 @@ from selenium.webdriver.support.ui import WebDriverWait
from .logger import get_logger
from serenitas.utils.env import DAILY_DIR
+from serenitas.analytics.dates import prev_business_day
logger = get_logger(__name__)
@@ -22,10 +23,6 @@ def download_report(account_username, password, report_dir):
navigate_to_inbox(driver)
attachment_element = get_attachment_element(driver)
fname = attachment_element.text.split()[0]
- if not os.path.exists(os.path.join(report_dir, fname)):
- attachment_element.click()
- else:
- logger.info(f"{fname} already exists in {report_dir}")
driver.quit()
@@ -70,8 +67,17 @@ def create_driver(download_dir):
return webdriver.Firefox(firefox_profile=fp, options=options)
-def download_scotia_report():
+def download_scotia_report(date):
scotia_login = {"selene-ops@lmcg.com": "oeujG*UF!53o"}
for username, password in scotia_login.items():
REPORT_DIR = DAILY_DIR / "Selene" / "Scotia_reports"
- download_report(username, password, REPORT_DIR)
+ try:
+ fname = next(
+ REPORT_DIR.glob(
+ f"IsoSelene_{prev_business_day(date):%d-%b-%Y}_*_xlsx.JOAAPKO3.JOAAPKO1"
+ )
+ )
+ logger.info(f"{fname} already exists in {REPORT_DIR}")
+ except StopIteration: # File doesn't exist, let's get it"
+ download_report(username, password, REPORT_DIR)
+ logger.info(f"Downloaded Scotia Report for {date}")