diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/report_ops/cash.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/python/report_ops/cash.py b/python/report_ops/cash.py index 88da9b5a..eabe5805 100644 --- a/python/report_ops/cash.py +++ b/python/report_ops/cash.py @@ -66,12 +66,16 @@ class CashReport: def __class_getitem__(cls, key): return cls._registry[key] - def to_db(self, report_name): + def get_cash_report(self, report_prefix): self.download_reports(self.date) report_dir = get_dir(self.date) report_dir.mkdir(exist_ok=True, parents=True) p = max( - [f for f in get_dir(self.date).iterdir() if f.name.startswith(report_name)], + [ + f + for f in get_dir(self.date).iterdir() + if f.name.startswith(report_prefix) + ], key=partial(dt_from_fname, dt_format=self.dtkey), default=None, ) @@ -105,7 +109,7 @@ class SeleneNTCashReport( CashReport, NT, fund="ISOSEL", custodian="NT", dtkey="%Y%m%d%H%M" ): def to_db(self): - p = super().to_db("cash_") + p = self.get_cash_report("cash_") df = pd.read_csv(p, on_bad_lines="warn") df = df[df["T-NARR-LONG"] == "CLOSING BALANCE"] df = df[["Consolidation", "Currency code", "A-TRAN-AMT"]] @@ -121,7 +125,7 @@ class SerenitasUMBCashReport( CashReport, UMB, fund="SERCGMAST", custodian="UMB", dtkey="%Y%m%d%H%M" ): def to_db(self): - p = super().to_db("umb_") + p = self.get_cash_report("umb_") df = pd.read_excel(p, skiprows=3) for row in ( df.groupby(["Portfolio #", "Currency"]).sum()["Current Balance"].items() @@ -135,7 +139,7 @@ class BowdstBNYCashReport( CashReport, BNY, fund="BOWDST", custodian="BNY", dtkey="%Y%m%d%H%M%S" ): def to_db(self): - p = super().to_db("Live-cash") + p = self.get_cash_report("Live-cash") df = pd.read_csv(p) df["Beginning Balance Local"] = df["Beginning Balance Local"].apply( lambda s: "-" + s[1:-1] if s.startswith("(") else s |
