From 5d58a39087954c9053570781e67d46410fa3b68c Mon Sep 17 00:00:00 2001 From: Prakhar Pratyush Date: Thu, 29 Feb 2024 14:56:41 +0530 Subject: [PATCH] stripe: Use a common email template for internal billing notices. This is a prep commit which replaces the 'invoice_overdue' and 'reminder_to_review_plan' email templates with 'internal_billing_notice'. This will help us to use the same template as we plan to send an email to sales when a remote realm with paid plan attached is locally deleted. --- corporate/lib/stripe.py | 6 ++++-- ...o_review_plan.html => internal_billing_notice.html} | 5 +++++ .../zerver/emails/internal_billing_notice.subject.txt | 5 +++++ templates/zerver/emails/internal_billing_notice.txt | 7 +++++++ templates/zerver/emails/invoice_overdue.html | 10 ---------- templates/zerver/emails/invoice_overdue.subject.txt | 1 - templates/zerver/emails/invoice_overdue.txt | 3 --- .../zerver/emails/reminder_to_review_plan.subject.txt | 1 - templates/zerver/emails/reminder_to_review_plan.txt | 3 --- 9 files changed, 21 insertions(+), 20 deletions(-) rename templates/zerver/emails/{reminder_to_review_plan.html => internal_billing_notice.html} (61%) create mode 100644 templates/zerver/emails/internal_billing_notice.subject.txt create mode 100644 templates/zerver/emails/internal_billing_notice.txt delete mode 100644 templates/zerver/emails/invoice_overdue.html delete mode 100644 templates/zerver/emails/invoice_overdue.subject.txt delete mode 100644 templates/zerver/emails/invoice_overdue.txt delete mode 100644 templates/zerver/emails/reminder_to_review_plan.subject.txt delete mode 100644 templates/zerver/emails/reminder_to_review_plan.txt diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py index 97e631b0a2..993db9b6e7 100644 --- a/corporate/lib/stripe.py +++ b/corporate/lib/stripe.py @@ -4859,9 +4859,10 @@ def invoice_plans_as_needed(event_time: Optional[datetime] = None) -> None: "billing_entity": billing_session.billing_entity_display_name, "end_date": plan.end_date.strftime("%Y-%m-%d"), "support_url": billing_session.support_url(), + "notice_reason": "fixed_price_plan_ends_soon", } send_email( - "zerver/emails/reminder_to_review_plan", + "zerver/emails/internal_billing_notice", to_emails=[BILLING_SUPPORT_EMAIL], from_address=FromAddress.tokenized_no_reply_address(), context=context, @@ -4881,9 +4882,10 @@ def invoice_plans_as_needed(event_time: Optional[datetime] = None) -> None: context = { "support_url": billing_session.support_url(), "last_audit_log_update": last_audit_log_update_string, + "notice_reason": "invoice_overdue", } send_email( - "zerver/emails/invoice_overdue", + "zerver/emails/internal_billing_notice", to_emails=[BILLING_SUPPORT_EMAIL], from_address=FromAddress.tokenized_no_reply_address(), context=context, diff --git a/templates/zerver/emails/reminder_to_review_plan.html b/templates/zerver/emails/internal_billing_notice.html similarity index 61% rename from templates/zerver/emails/reminder_to_review_plan.html rename to templates/zerver/emails/internal_billing_notice.html index 67902cc453..96562db280 100644 --- a/templates/zerver/emails/reminder_to_review_plan.html +++ b/templates/zerver/emails/internal_billing_notice.html @@ -1,7 +1,12 @@ {% extends "zerver/emails/email_base_default.html" %} {% block content %} + +{% if notice_reason == "fixed_price_plan_ends_soon" %}

Reminder to re-evaluate the pricing and configure a new fixed-price plan accordingly.

+{% elif notice_reason == "invoice_overdue" %} +Last data upload: {{ last_audit_log_update }} +{% endif %}

diff --git a/templates/zerver/emails/internal_billing_notice.subject.txt b/templates/zerver/emails/internal_billing_notice.subject.txt new file mode 100644 index 0000000000..4cb465d50a --- /dev/null +++ b/templates/zerver/emails/internal_billing_notice.subject.txt @@ -0,0 +1,5 @@ +{% if notice_reason == "fixed_price_plan_ends_soon" %} +Fixed-price plan for {{billing_entity}} ends on {{end_date}} +{% elif notice_reason == "invoice_overdue" %} +Invoice overdue due to stale data +{% endif %} diff --git a/templates/zerver/emails/internal_billing_notice.txt b/templates/zerver/emails/internal_billing_notice.txt new file mode 100644 index 0000000000..b38acf9bbd --- /dev/null +++ b/templates/zerver/emails/internal_billing_notice.txt @@ -0,0 +1,7 @@ +{% if notice_reason == "fixed_price_plan_ends_soon" %} +Reminder to re-evaluate the pricing and configure a new fixed-price plan accordingly. +{% elif notice_reason == "invoice_overdue" %} +Last data upload: {{ last_audit_log_update }} +{% endif %} + +Support URL: {{ support_url }} diff --git a/templates/zerver/emails/invoice_overdue.html b/templates/zerver/emails/invoice_overdue.html deleted file mode 100644 index 8e8b20124b..0000000000 --- a/templates/zerver/emails/invoice_overdue.html +++ /dev/null @@ -1,10 +0,0 @@ -{% extends "zerver/emails/email_base_default.html" %} - -{% block content %} -Support URL: {{ support_url }} - -

- -Last data upload: {{ last_audit_log_update }} - -{% endblock %} diff --git a/templates/zerver/emails/invoice_overdue.subject.txt b/templates/zerver/emails/invoice_overdue.subject.txt deleted file mode 100644 index 56ace1e4a2..0000000000 --- a/templates/zerver/emails/invoice_overdue.subject.txt +++ /dev/null @@ -1 +0,0 @@ -Invoice overdue due to stale data diff --git a/templates/zerver/emails/invoice_overdue.txt b/templates/zerver/emails/invoice_overdue.txt deleted file mode 100644 index 7c7633be97..0000000000 --- a/templates/zerver/emails/invoice_overdue.txt +++ /dev/null @@ -1,3 +0,0 @@ -Support URL: {{ support_url }} - -Last data upload: {{ last_audit_log_update }} diff --git a/templates/zerver/emails/reminder_to_review_plan.subject.txt b/templates/zerver/emails/reminder_to_review_plan.subject.txt deleted file mode 100644 index c5ea2f9702..0000000000 --- a/templates/zerver/emails/reminder_to_review_plan.subject.txt +++ /dev/null @@ -1 +0,0 @@ -Fixed-price plan for {{billing_entity}} ends on {{end_date}} diff --git a/templates/zerver/emails/reminder_to_review_plan.txt b/templates/zerver/emails/reminder_to_review_plan.txt deleted file mode 100644 index 2fa99af132..0000000000 --- a/templates/zerver/emails/reminder_to_review_plan.txt +++ /dev/null @@ -1,3 +0,0 @@ -Reminder to re-evaluate the pricing and configure a new fixed-price plan accordingly. - -Support URL: {{ support_url }}