-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreminder.py
executable file
·65 lines (57 loc) · 2.48 KB
/
reminder.py
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
#!/usr/bin/env python3
import sys
import datetime
import json
import pytz
from dateutil.relativedelta import relativedelta
from lib.config import *
from lib import util
from lib import webhook
def lambda_handler():
def prepare_finance_calendar_payload(service):
payload = []
tz = pytz.timezone(config_timezone)
localtime = datetime.datetime.now(tz)
month_and_day = str(localtime.strftime('%m-%d')) # 09-20
year = str(localtime.strftime('%Y')) # 2023
if config_country_code == 'AU':
flag = "🇦🇺"
if month_and_day in {'01-28', '04-28', '07-28', '10-28'}:
payload.append("🤑 Quarterly Superannuation payout deadline" + flag)
if month_and_day == '06-23':
payload.append("💰 Finalise deductable donations, work expenses & investment subscriptions by EOFY June 30" + flag)
payload.append("💸 Realise capital gains/losses by EOFY June 30" + flag)
payload.append("✍️ Submit superannuation 'Notice of Intent to Claim' by EOFY June 30" + flag)
if month_and_day == '10-24':
payload.append("😓 Self-service individual tax returns are due Oct 31" + flag)
if month_and_day == '10-31':
payload.append("😰 Self-service individual tax returns are due today" + flag)
#if config_country_code in {'AU', 'BD', 'EG', 'ET', 'KE', 'NP', 'PK'}:
if month_and_day == '06-30':
payload.append("🥳 Happy EOFY 🇦🇺 🇧🇩 🇪🇬 🇪🇹 🇰🇪 🇳🇵 🇵🇰")
#elif config_country_code in {'GB', 'HK', 'IN', 'KR', 'NZ', 'JP', 'ZA'}:
if month_and_day == '03-31':
payload.append("🥳 Happy EOFY 🇬🇧 🇭🇰 🇮🇳 🇰🇷 🇳🇿 🇯🇵 🇿🇦")
# above ommits countries where EOFY == calendar year
if month_and_day == '08-18':
myBirthday = datetime.datetime(2022,8,18,0,0,0,0, tzinfo=tz)
difference = relativedelta(localtime, myBirthday)
payload.append("It's my " + str(difference.years) + util.ordinal(difference.years) + " birthday! 🥳")
if payload:
heading = webhook.bold("Finance event reminders:", service)
payload.insert(0, heading)
return payload
# MAIN #
# Prep and send payloads
if not webhooks:
print("Error: no services enabled in .env", file=sys.stderr)
sys.exit(1)
for service, url in webhooks.items():
payload = prepare_finance_calendar_payload(service)
if service == "telegram":
url = webhooks['telegram'] + "sendMessage?chat_id=" + config_telegramChatID
webhook.payload_wrapper(service, url, payload)
# make google cloud happy
return True
if __name__ == "__main__":
lambda_handler()