aboutsummaryrefslogtreecommitdiffstats
path: root/python/umb_monitor.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/umb_monitor.py')
-rw-r--r--python/umb_monitor.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/python/umb_monitor.py b/python/umb_monitor.py
new file mode 100644
index 00000000..9a5a3140
--- /dev/null
+++ b/python/umb_monitor.py
@@ -0,0 +1,73 @@
+import datetime
+from exchangelib import HTMLBody
+
+from serenitas.utils.db import dbconn
+
+from report_ops.utils import Monitor
+
+
+class UmbEurMonitor(
+ Monitor,
+ headers=(
+ "settle_date",
+ "account",
+ "counterparty",
+ "asset_class",
+ "currency",
+ "receive_amount",
+ ),
+ num_format=[("{0:,.2f}", 5)],
+):
+ @classmethod
+ def email(cls):
+ if not cls._staging_queue:
+ return
+ cls._em.send_email(
+ "*Euro Settlements Settling Today* 159260.2",
+ HTMLBody(
+ f"""
+<html>
+ <head>
+ <style>
+ table, th, td {{ border: 1px solid black; border-collapse: collapse;}}
+ th, td {{ padding: 5px; }}
+ </style>
+ </head>
+ <body>
+ Good morning,<br><br>We are expecting the following Euro wires to settle today. Could you revert back once you've received these wires<br><br>{cls.to_tabulate()}
+ </body>
+</html>"""
+ ),
+ to_recipients=("lmcgcustody@umb.com",),
+ cc_recipients=("nyops@lmcg.com",),
+ )
+
+
+def check_eur_settlements(date, fund, conn):
+ with conn.cursor() as c:
+ c.execute(
+ "SELECT settle_date, name as counterparty, asset_class, currency, payment_amount as receive_amount FROM payment_settlements ps WHERE settle_date =%s AND fund=%s AND account IN ('UMB Fund Services', 'OTC') AND payment_amount > 0 AND currency='EUR';",
+ (date, fund),
+ )
+ for row in c:
+ d = row._asdict() | {"account": "159260.2"}
+ UmbEurMonitor.stage(d)
+ UmbEurMonitor.email()
+ UmbEurMonitor.clear()
+
+
+if __name__ == "__main__":
+ import argparse
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ "cob",
+ nargs="?",
+ type=datetime.date.fromisoformat,
+ default=datetime.date.today(),
+ help="working date",
+ )
+ args = parser.parse_args()
+ conn = dbconn("dawndb")
+
+ check_eur_settlements(args.cob, "SERCGMAST", conn)