Skip to content

Commit eb55b61

Browse files
author
Kimball Johnson
committed
Add membership lapse warning email, 7 days before suspension
1 parent b98b73e commit eb55b61

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

bin/reconcile.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ def send_email(address, subject, text)
2323
mail.deliver
2424
end
2525

26+
def send_lapse_warning_email(email, full_name, last_payment)
27+
vars = {'name' => firstname(full_name),
28+
'date' => last_payment.strftime('%Y-%m-%d')}
29+
template = Erubis::Eruby.new(File.read('../emails/lapse_warning.erb'))
30+
send_email(email, "Your London Hackspace membership wilk lapse in 7 days", template.result(vars))
31+
end
32+
2633
def send_unsubscribe_email(email, full_name, last_payment)
2734
vars = {'name' => firstname(full_name),
2835
'date' => last_payment.strftime('%Y-%m-%d')}
@@ -97,6 +104,19 @@ def send_subscribe_email(email, full_name)
97104
end
98105
end
99106

107+
db.exec("SELECT users.*, (SELECT max(timestamp) FROM transactions WHERE user_id = users.id) AS lastsubscription
108+
FROM users
109+
WHERE users.subscribed = true
110+
AND (SELECT max(timestamp) FROM transactions WHERE user_id = users.id) < now() - interval '1 month' - interval '7 days'
111+
AND (SELECT max(timestamp) FROM transactions WHERE user_id = users.id) > now() - interval '1 month' - interval '8 days'"
112+
) do |result|
113+
114+
result.each do |user|
115+
puts "Warning #{user['full_name']} of membership soon to lapse"
116+
send_lapse_warning_email(user['email'], user['full_name'], Time.parse(user['lastsubscription']))
117+
end
118+
end
119+
100120
db.exec("SELECT users.*, (SELECT max(timestamp) FROM transactions WHERE user_id = users.id) AS lastsubscription
101121
FROM users
102122
WHERE users.subscribed = true

emails/lapse_warning.erb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Dear <%=name%>,
2+
3+
This is an automated email sent from our payment system.
4+
5+
We haven't noticed a payment from you in over a month, and if we
6+
do not within 7 days your membership will be automatically suspended, and your
7+
door access will be disabled.
8+
9+
We last received a payment from you on <%=date%>.
10+
11+
If you believe we are warning you in error, please reply to this
12+
email with the date, amount, and reference of your most recent payment,
13+
and we'll look into it.
14+
15+
If you've changed bank account or want to confirm our payment details and
16+
your reference you can find them on our web site:
17+
18+
https://london.hackspace.org.uk/members/
19+
20+
Alternatively if you are cancelling your membership we'd be very
21+
interested to hear any feedback you have about why you've cancelled your
22+
membership, or how we can improve London Hackspace - just hit reply and
23+
let us know.
24+
25+
If you're still storing anything in the space, please arrange to remove
26+
it as soon as possible, otherwise we will have to dispose of it to free
27+
up space for other members to use.
28+
29+
Thanks,
30+
31+
The London Hackspace trustees
32+

0 commit comments

Comments
 (0)