From d05a3f0cb00a2a27d3db55e69298337d8d308891 Mon Sep 17 00:00:00 2001 From: Prakhar Pratyush Date: Fri, 16 Feb 2024 20:01:55 +0530 Subject: [PATCH] corporate: Send invoice overdue mail also when data never uploaded. Earlier, during invoicing we used to send a mail to sales@zulip.com when the last_audit_log_update was at least one day ago. There was an assertion that last_audit_log_update can't be None which is incorrect as such customers exist. This commit extends the behaviour to send an invoice overdue email even if the data was never uploaded. --- corporate/lib/stripe.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py index 1fe20e129a..c667fe6284 100644 --- a/corporate/lib/stripe.py +++ b/corporate/lib/stripe.py @@ -4761,19 +4761,19 @@ def invoice_plans_as_needed(event_time: Optional[datetime] = None) -> None: billing_session = RemoteServerBillingSession(remote_server=remote_server) if remote_server: - assert remote_server.last_audit_log_update is not None assert plan.next_invoice_date is not None - if plan.next_invoice_date > remote_server.last_audit_log_update: + last_audit_log_update = remote_server.last_audit_log_update + if last_audit_log_update is None or plan.next_invoice_date > last_audit_log_update: if ( - plan.next_invoice_date - remote_server.last_audit_log_update - >= timedelta(days=1) - and not plan.invoice_overdue_email_sent - ): + last_audit_log_update is None + or plan.next_invoice_date - last_audit_log_update >= timedelta(days=1) + ) and not plan.invoice_overdue_email_sent: + last_audit_log_update_string = "Never uploaded" + if last_audit_log_update is not None: + last_audit_log_update_string = last_audit_log_update.strftime("%Y-%m-%d") context = { "support_url": billing_session.support_url(), - "last_audit_log_update": remote_server.last_audit_log_update.strftime( - "%Y-%m-%d" - ), + "last_audit_log_update": last_audit_log_update_string, } send_email( "zerver/emails/invoice_overdue",