aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/report_ops/custodians.py39
1 files changed, 26 insertions, 13 deletions
diff --git a/python/report_ops/custodians.py b/python/report_ops/custodians.py
index 7637517b..c03bcaf1 100644
--- a/python/report_ops/custodians.py
+++ b/python/report_ops/custodians.py
@@ -103,6 +103,16 @@ class Custodian:
def __init_subclass__(cls, account):
cls.account = account
+ @staticmethod
+ def em_date_filter(em, date):
+ start = datetime.datetime.combine(date, datetime.time.min).replace(
+ tzinfo=em._account.default_timezone
+ )
+ end = datetime.datetime.combine(date, datetime.time.max).replace(
+ tzinfo=em._account.default_timezone
+ )
+ return {"datetime_received__gte": start, "datetime_received__lte": end}
+
class NT(Custodian, account="NT"):
@classmethod
@@ -133,20 +143,23 @@ class UMB(Custodian, account="UMB"):
@classmethod
def download_reports(cls, date=datetime.date.today()):
em = ExchangeMessage()
- for msg in em.get_msgs(count=20, path=["NYops", "Powerstation"]):
+ for msg in em.get_msgs(
+ count=20, path=["NYops", "Powerstation"], **cls.em_date_filter(em, date)
+ ):
for attach in msg.attachments:
- timestamp = attach.last_modified_time.replace(tzinfo=None)
- if timestamp.date() == date:
- dest = get_dir(timestamp.date(), archived=False)
- dest.mkdir(exist_ok=True, parents=True)
- if attach.name.startswith("cash_balances_umb"):
- p = dest / f"umb_{timestamp:%Y%m%d%H%M}.xlsx"
- elif attach.name.startswith("umb_serenitas_wires"):
- p = dest / f"umbwires_{timestamp:%Y%m%d%H%M}.xlsx"
- else:
- pass
- if not p.exists():
- p.write_bytes(attach.content)
+ ts = attach.last_modified_time.replace(
+ tzinfo=em._account.default_timezone
+ )
+ dest = get_dir(date, archived=False)
+ dest.mkdir(exist_ok=True, parents=True)
+ if attach.name.startswith("cash_balances_umb"):
+ p = dest / f"umb_{ts:%Y%m%d%H%M}.xlsx"
+ elif attach.name.startswith("umb_serenitas_wires"):
+ p = dest / f"umbwires_{ts:%Y%m%d%H%M}.xlsx"
+ else:
+ pass
+ if not p.exists():
+ p.write_bytes(attach.content)
class BNY(Custodian, account="BONY2"):