diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py index 5473fa5b32..0bc8affcca 100644 --- a/corporate/lib/stripe.py +++ b/corporate/lib/stripe.py @@ -5531,6 +5531,15 @@ def check_remote_server_audit_log_data( next_invoice_date = plan.next_invoice_date last_audit_log_update = remote_server.last_audit_log_update if last_audit_log_update is None or next_invoice_date > last_audit_log_update: + # We still process fixed-price plans because the current license count + # won't change the amount due or the fact that we should downgrade the + # plan when it is scheduled to end. + if plan.fixed_price is not None: + # TODO: Possibly send an internal billing notice so that billing admin + # have a record that the customer's license ledger entries do not + # reflect actual audit log data from the remote server. + return True + if not plan.stale_audit_log_data_email_sent: maybe_send_stale_audit_log_data_email( plan, billing_session, next_invoice_date, last_audit_log_update diff --git a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json index e33cd59f81..bd0afdb92a 100644 Binary files a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json and b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json differ diff --git a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.3.json b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.3.json index b00249fa2f..ca1da9db16 100644 Binary files a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.3.json and b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.3.json differ diff --git a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.1.json b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.1.json index a452778e41..b36ec163ca 100644 Binary files a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.1.json and b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.1.json differ diff --git a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.2.json b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.2.json new file mode 100644 index 0000000000..b5c581a40b Binary files /dev/null and b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.2.json differ diff --git a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.3.json b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.3.json new file mode 100644 index 0000000000..7abdad728f Binary files /dev/null and b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.3.json differ diff --git a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.finalize_invoice.1.json b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.finalize_invoice.1.json index c6c6eef03e..aba3c72ca0 100644 Binary files a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.finalize_invoice.1.json and b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.finalize_invoice.1.json differ diff --git a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.finalize_invoice.2.json b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.finalize_invoice.2.json new file mode 100644 index 0000000000..08b13a9a7d Binary files /dev/null and b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.finalize_invoice.2.json differ diff --git a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.finalize_invoice.3.json b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.finalize_invoice.3.json new file mode 100644 index 0000000000..13b099138d Binary files /dev/null and b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.finalize_invoice.3.json differ diff --git a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.pay.1.json b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.pay.1.json index 2765e19590..b4d3a5d361 100644 Binary files a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.pay.1.json and b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.pay.1.json differ diff --git a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--InvoiceItem.create.2.json b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--InvoiceItem.create.2.json new file mode 100644 index 0000000000..329eff414b Binary files /dev/null and b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--InvoiceItem.create.2.json differ diff --git a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--InvoiceItem.create.3.json b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--InvoiceItem.create.3.json new file mode 100644 index 0000000000..165877e003 Binary files /dev/null and b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--InvoiceItem.create.3.json differ diff --git a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--checkout.Session.create.1.json b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--checkout.Session.create.1.json index d652ba776b..8e74c672f6 100644 Binary files a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--checkout.Session.create.1.json and b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--checkout.Session.create.1.json differ diff --git a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--checkout.Session.list.1.json b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--checkout.Session.list.1.json index c9932bff90..c385d9e6c8 100644 Binary files a/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--checkout.Session.list.1.json and b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--checkout.Session.list.1.json differ diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py index 6aca99865a..9054854382 100644 --- a/corporate/tests/test_stripe.py +++ b/corporate/tests/test_stripe.py @@ -10017,16 +10017,26 @@ class TestRemoteServerBillingFlow(StripeTestCase, RemoteServerTestCase): ]: self.assert_in_response(substring, response) - # The last audit log update was 25 days before the plan's next - # invoice date, so invoicing the fixed-price plan fails, and an - # internal billing notice is sent. + # Since fixed-price plans do not depend on license counts for the + # amount due, we invoice them even if the audit log data is stale + # from the server. last_audit_log_update = self.now + timedelta(days=5) with time_machine.travel(last_audit_log_update, tick=False): send_server_data_to_push_bouncer(consider_usage_statistics=False) invoice_plans_as_needed(self.next_month) current_plan.refresh_from_db() - self.assertEqual(current_plan.next_invoice_date, self.next_month) - self.assertTrue(current_plan.stale_audit_log_data_email_sent) + updated_invoice_date = self.next_month + timedelta(days=29) + self.assertEqual(current_plan.next_invoice_date, updated_invoice_date) + self.assertFalse(current_plan.stale_audit_log_data_email_sent) + + # Audit log data is up-to-date when the plan is next invoiced. + with time_machine.travel(updated_invoice_date, tick=False): + send_server_data_to_push_bouncer(consider_usage_statistics=False) + invoice_plans_as_needed(updated_invoice_date) + current_plan.refresh_from_db() + final_invoice_date = updated_invoice_date + timedelta(days=31) + self.assertEqual(current_plan.next_invoice_date, final_invoice_date) + self.assertFalse(current_plan.stale_audit_log_data_email_sent) @responses.activate @mock_stripe()