2018-08-30 15:54:31 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
from utils.email import add_outgoing_email
|
|
|
|
|
2018-11-20 16:12:32 +00:00
|
|
|
# expense emails
|
2018-08-30 15:54:31 +00:00
|
|
|
|
2019-06-16 12:32:24 +00:00
|
|
|
|
2018-11-20 16:12:32 +00:00
|
|
|
def send_accountingsystem_expense_email(expense):
|
2018-08-30 15:54:31 +00:00
|
|
|
"""
|
|
|
|
Sends an email to the accountingsystem with the invoice as an attachment,
|
|
|
|
and with the expense uuid and description in email subject
|
|
|
|
"""
|
|
|
|
add_outgoing_email(
|
2018-11-20 16:12:32 +00:00
|
|
|
"emails/accountingsystem_expense_email.txt",
|
2018-08-30 15:54:31 +00:00
|
|
|
formatdict=dict(expense=expense),
|
|
|
|
subject="Expense %s for %s" % (expense.pk, expense.camp.title),
|
|
|
|
to_recipients=[settings.ACCOUNTINGSYSTEM_EMAIL],
|
|
|
|
attachment=expense.invoice.read(),
|
|
|
|
attachment_filename=os.path.basename(expense.invoice.file.name),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def send_expense_approved_email(expense):
|
|
|
|
"""
|
|
|
|
Sends an expense-approved email to the user who created the expense
|
|
|
|
"""
|
|
|
|
add_outgoing_email(
|
|
|
|
"emails/expense_approved_email.txt",
|
|
|
|
formatdict=dict(expense=expense),
|
|
|
|
subject="Your expense for %s has been approved." % expense.camp.title,
|
|
|
|
to_recipients=[expense.user.emailaddress_set.get(primary=True).email],
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def send_expense_rejected_email(expense):
|
|
|
|
"""
|
|
|
|
Sends an expense-rejected email to the user who created the expense
|
|
|
|
"""
|
|
|
|
add_outgoing_email(
|
|
|
|
"emails/expense_rejected_email.txt",
|
|
|
|
formatdict=dict(expense=expense),
|
|
|
|
subject="Your expense for %s has been rejected." % expense.camp.title,
|
|
|
|
to_recipients=[expense.user.emailaddress_set.get(primary=True).email],
|
|
|
|
)
|
|
|
|
|
2019-06-16 12:32:24 +00:00
|
|
|
|
2018-11-20 16:12:32 +00:00
|
|
|
# revenue emails
|
|
|
|
|
2019-06-16 12:32:24 +00:00
|
|
|
|
2018-11-20 16:12:32 +00:00
|
|
|
def send_accountingsystem_revenue_email(revenue):
|
|
|
|
"""
|
|
|
|
Sends an email to the accountingsystem with the invoice as an attachment,
|
|
|
|
and with the revenue uuid and description in email subject
|
|
|
|
"""
|
|
|
|
add_outgoing_email(
|
|
|
|
"emails/accountingsystem_revenue_email.txt",
|
|
|
|
formatdict=dict(revenue=revenue),
|
|
|
|
subject="Revenue %s for %s" % (revenue.pk, revenue.camp.title),
|
|
|
|
to_recipients=[settings.ACCOUNTINGSYSTEM_EMAIL],
|
|
|
|
attachment=revenue.invoice.read(),
|
|
|
|
attachment_filename=os.path.basename(revenue.invoice.file.name),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def send_revenue_approved_email(revenue):
|
|
|
|
"""
|
|
|
|
Sends a revenue-approved email to the user who created the revenue
|
|
|
|
"""
|
|
|
|
add_outgoing_email(
|
|
|
|
"emails/revenue_approved_email.txt",
|
|
|
|
formatdict=dict(revenue=revenue),
|
|
|
|
subject="Your revenue for %s has been approved." % revenue.camp.title,
|
|
|
|
to_recipients=[revenue.user.emailaddress_set.get(primary=True).email],
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def send_revenue_rejected_email(revenue):
|
|
|
|
"""
|
|
|
|
Sends an revenue-rejected email to the user who created the revenue
|
|
|
|
"""
|
|
|
|
add_outgoing_email(
|
|
|
|
"emails/revenue_rejected_email.txt",
|
|
|
|
formatdict=dict(revenue=revenue),
|
|
|
|
subject="Your revenue for %s has been rejected." % revenue.camp.title,
|
|
|
|
to_recipients=[revenue.user.emailaddress_set.get(primary=True).email],
|
|
|
|
)
|