Skip to content

Commit

Permalink
Update mail for invoice reminder (subject and delay)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsierro committed Apr 21, 2024
1 parent 79cbf46 commit 86e23fb
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions invoicing/invoice_mail_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@


def send_invoice(invoice):

# set payment delay according to invoice status
if invoice.status == 'created':
payment_delay = 30
elif invoice.status == 'rappel1':
payment_delay = 10
elif invoice.status == 'rappel2':
payment_delay = 10
else:
payment_delay = 0

body = \
f"""Cher membre,
Expand All @@ -13,8 +24,8 @@ def send_invoice(invoice):
Numéro de Facture : {invoice.invoice_number}
Montant Total : {invoice.amount_due}
Nous te prions de bien vouloir régler cette facture dans un délai de 30 jours.
Nous te prions de bien vouloir régler cette facture dans un délai de {payment_delay} jours.
Si tu as des questions ou des préoccupations concernant cette facture, n'hésite pas à me contacter en répondant à ce mail.
Meilleures salutations,
Expand All @@ -26,8 +37,16 @@ def send_invoice(invoice):

to = EMAIL_DEBUG_RECEIVER if DEBUG else invoice.member.mail

# add reminder level before subject
if invoice.status == 'rappel1':
pre_subject = 'Rappel - '
elif invoice.status == 'rappel2':
pre_subject = 'Rappel 2 - '
else:
pre_subject = ''

email = EmailMessage(
f"Facture {invoice.invoice_number} - FabLab Sion",
f"{pre_subject}Facture {invoice.invoice_number} - FabLab Sion",
body,
EMAIL_FROM,
[to],
Expand Down

0 comments on commit 86e23fb

Please sign in to comment.