Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add membership lapse warning email, 7 days before suspension #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions bin/reconcile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ def send_email(address, subject, text)
mail.deliver
end

def send_lapse_warning_email(email, full_name, last_payment)
vars = {'name' => firstname(full_name),
'date' => last_payment.strftime('%Y-%m-%d')}
template = Erubis::Eruby.new(File.read('../emails/lapse_warning.erb'))
send_email(email, "Your London Hackspace membership will lapse in 7 days", template.result(vars))
end

def send_unsubscribe_email(email, full_name, last_payment)
vars = {'name' => firstname(full_name),
'date' => last_payment.strftime('%Y-%m-%d')}
Expand Down Expand Up @@ -97,6 +104,19 @@ def send_subscribe_email(email, full_name)
end
end

db.exec("SELECT users.*, (SELECT max(timestamp) FROM transactions WHERE user_id = users.id) AS lastsubscription
FROM users
WHERE users.subscribed = true
AND (SELECT max(timestamp) FROM transactions WHERE user_id = users.id) < now() - interval '1 month' - interval '7 days'
AND (SELECT max(timestamp) FROM transactions WHERE user_id = users.id) > now() - interval '1 month' - interval '8 days'"
) do |result|

result.each do |user|
puts "Warning #{user['full_name']} of membership soon to lapse"
send_lapse_warning_email(user['email'], user['full_name'], Time.parse(user['lastsubscription']))
end
end

db.exec("SELECT users.*, (SELECT max(timestamp) FROM transactions WHERE user_id = users.id) AS lastsubscription
FROM users
WHERE users.subscribed = true
Expand Down
32 changes: 32 additions & 0 deletions emails/lapse_warning.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Dear <%=name%>,

This is an automated email sent from our payment system.

We haven't noticed a payment from you in over a month, and if we
do not within 7 days your membership will be automatically suspended, and your
door access will be disabled.

We last received a payment from you on <%=date%>.

If you believe we are warning you in error, please reply to this
email with the date, amount, and reference of your most recent payment,
and we'll look into it.

If you've changed bank account or want to confirm our payment details and
your reference you can find them on our web site:

https://london.hackspace.org.uk/members/

Alternatively if you are cancelling your membership we'd be very
interested to hear any feedback you have about why you've cancelled your
membership, or how we can improve London Hackspace - just hit reply and
let us know.

If you're still storing anything in the space, please arrange to remove
it as soon as possible, otherwise we will have to dispose of it to free
up space for other members to use.

Thanks,

The London Hackspace trustees
[email protected]