1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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 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)
|