Skip to content

Commit 3f7e26f

Browse files
🐛 fix attachment invoice (#5711)
1 parent c26d3d6 commit 3f7e26f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

services/payments/src/simcore_service_payments/services/notifier_email.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,14 @@ async def _create_user_email(
194194
if product.bcc_email:
195195
msg["Bcc"] = product.bcc_email
196196

197-
# Invoice attachment
197+
# Body
198+
text_template = env.get_template("notify_payments.txt")
199+
msg.set_content(text_template.render(data))
200+
201+
html_template = env.get_template("notify_payments.html")
202+
msg.add_alternative(html_template.render(data), subtype="html")
203+
204+
# Invoice attachment (It is important that attachment is added after body)
198205
if pdf_response := await _get_invoice_pdf(payment.invoice_pdf_url):
199206
match = invoice_file_name_pattern.search(
200207
pdf_response.headers["content-disposition"]
@@ -205,12 +212,6 @@ async def _create_user_email(
205212
attachment["Content-Disposition"] = f"attachment; filename={_file_name}"
206213
msg.attach(attachment)
207214

208-
# Body
209-
text_template = env.get_template("notify_payments.txt")
210-
msg.set_content(text_template.render(data))
211-
212-
html_template = env.get_template("notify_payments.html")
213-
msg.add_alternative(html_template.render(data), subtype="html")
214215
return msg
215216

216217

0 commit comments

Comments
 (0)