Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
corporate: Invoice self-hosted fixed-price plans with stale data.
Lauryn Menard208f1b30dbbb
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.pyindex 5473fa5b325..0bc8affcca4 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_datelast_audit_log_update = remote_server.last_audit_log_updateif 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_updatediff --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.jsonindex e33cd59f81f..bd0afdb92a5 100644--- 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@@ -41,7 +41,7 @@"default_payment_method": null,"default_source": null,"default_tax_rates": [],- "description": null,+ "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.","discounts": [],"due_date": null,"effective_at": 1000000000,@@ -155,7 +155,7 @@"total_excluding_tax": 10000,"total_pretax_credit_amounts": [],"total_taxes": [],- "webhooks_delivered_at": 1000000000+ "webhooks_delivered_at": null},"previous_attributes": {"amount_paid": 0,@@ -171,7 +171,7 @@"id": "upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json","livemode": false,"object": "event",- "pending_webhooks": 0,+ "pending_webhooks": 2,"request": {"id": "upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json","idempotency_key": "00000000-0000-0000-0000-000000000000"@@ -201,6 +201,7 @@"currency": "usd","customer": "upgrade_server_to_fixed_price_monthly_basic_plan--Customer.create.1.json","description": "Payment for Invoice",+ "excluded_payment_method_types": null,"id": "upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json","last_payment_error": null,"latest_charge": "upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json",@@ -242,7 +243,7 @@"id": "upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json","livemode": false,"object": "event",- "pending_webhooks": 0,+ "pending_webhooks": 1,"request": {"id": "upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json","idempotency_key": "00000000-0000-0000-0000-000000000000"@@ -311,7 +312,7 @@"payment_method_details": {"card": {"amount_authorized": 10000,- "authorization_code": null,+ "authorization_code": "858239","brand": "visa","checks": {"address_line1_check": "pass",@@ -339,7 +340,7 @@"network_token": {"used": false},- "network_transaction_id": "100110997670110",+ "network_transaction_id": "749857738210088","overcapture": {"maximum_amount_capturable": 10000,"status": "unavailable"@@ -369,7 +370,7 @@"id": "upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json","livemode": false,"object": "event",- "pending_webhooks": 0,+ "pending_webhooks": 2,"request": {"id": "upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json","idempotency_key": "00000000-0000-0000-0000-000000000000"@@ -417,7 +418,7 @@"default_payment_method": null,"default_source": null,"default_tax_rates": [],- "description": null,+ "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.","discounts": [],"due_date": null,"effective_at": 1000000000,@@ -531,7 +532,7 @@"total_excluding_tax": 10000,"total_pretax_credit_amounts": [],"total_taxes": [],- "webhooks_delivered_at": 1000000000+ "webhooks_delivered_at": null}},"id": "upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json",@@ -585,7 +586,7 @@"default_payment_method": null,"default_source": null,"default_tax_rates": [],- "description": null,+ "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.","discounts": [],"due_date": null,"effective_at": 1000000000,@@ -699,7 +700,7 @@"total_excluding_tax": 10000,"total_pretax_credit_amounts": [],"total_taxes": [],- "webhooks_delivered_at": 1000000000+ "webhooks_delivered_at": null},"previous_attributes": {"effective_at": null,@@ -751,6 +752,7 @@"currency": "usd","customer": "upgrade_server_to_fixed_price_monthly_basic_plan--Customer.create.1.json","description": "Payment for Invoice",+ "excluded_payment_method_types": null,"id": "upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json","last_payment_error": null,"latest_charge": null,@@ -840,7 +842,7 @@"default_payment_method": null,"default_source": null,"default_tax_rates": [],- "description": null,+ "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.","discounts": [],"due_date": null,"effective_at": null,@@ -954,7 +956,7 @@"total_excluding_tax": 10000,"total_pretax_credit_amounts": [],"total_taxes": [],- "webhooks_delivered_at": 1000000000+ "webhooks_delivered_at": null},"previous_attributes": {"amount_due": 0,@@ -1066,7 +1068,7 @@"default_payment_method": null,"default_source": null,"default_tax_rates": [],- "description": null,+ "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.","discounts": [],"due_date": null,"effective_at": null,@@ -1139,7 +1141,7 @@"total_excluding_tax": 0,"total_pretax_credit_amounts": [],"total_taxes": [],- "webhooks_delivered_at": 1000000000+ "webhooks_delivered_at": null}},"id": "upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json",@@ -1203,7 +1205,7 @@"type": "customer.updated"}],- "has_more": true,+ "has_more": false,"object": "list","url": "/v1/events"}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.jsonindex b00249fa2fa..ca1da9db166 100644--- 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@@ -41,7 +41,7 @@"default_payment_method": null,"default_source": null,"default_tax_rates": [],- "description": null,+ "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.","discounts": [],"due_date": null,"effective_at": 1000000000,@@ -155,13 +155,13 @@"total_excluding_tax": 10000,"total_pretax_credit_amounts": [],"total_taxes": [],- "webhooks_delivered_at": 1000000000+ "webhooks_delivered_at": null}},"id": "upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.3.json","livemode": false,"object": "event",- "pending_webhooks": 0,+ "pending_webhooks": 2,"request": {"id": "upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json","idempotency_key": "00000000-0000-0000-0000-000000000000"@@ -209,7 +209,7 @@"default_payment_method": null,"default_source": null,"default_tax_rates": [],- "description": null,+ "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.","discounts": [],"due_date": null,"effective_at": 1000000000,@@ -323,13 +323,13 @@"total_excluding_tax": 10000,"total_pretax_credit_amounts": [],"total_taxes": [],- "webhooks_delivered_at": 1000000000+ "webhooks_delivered_at": null}},"id": "upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.3.json","livemode": false,"object": "event",- "pending_webhooks": 0,+ "pending_webhooks": 1,"request": {"id": "upgrade_server_to_fixed_price_monthly_basic_plan--Event.list.2.json","idempotency_key": "00000000-0000-0000-0000-000000000000"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.jsonindex a452778e41c..b36ec163cab 100644--- 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@@ -35,7 +35,7 @@"default_payment_method": null,"default_source": null,"default_tax_rates": [],- "description": null,+ "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.","discounts": [],"due_date": null,"effective_at": null,@@ -108,5 +108,5 @@"total_excluding_tax": 0,"total_pretax_credit_amounts": [],"total_taxes": [],- "webhooks_delivered_at": 1000000000+ "webhooks_delivered_at": null}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.jsonnew file mode 100644index 00000000000..b5c581a40ba--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.2.json@@ -0,0 +1,105 @@+{+ "account_country": "US",+ "account_name": "NORMALIZED",+ "account_tax_ids": null,+ "amount_due": 0,+ "amount_overpaid": 0,+ "amount_paid": 0,+ "amount_remaining": 0,+ "amount_shipping": 0,+ "application": null,+ "attempt_count": 0,+ "attempted": false,+ "auto_advance": true,+ "automatic_tax": {+ "disabled_reason": null,+ "enabled": false,+ "liability": null,+ "provider": null,+ "status": null+ },+ "automatically_finalizes_at": 1000000000,+ "billing_reason": "manual",+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",+ "discounts": [],+ "due_date": null,+ "effective_at": null,+ "ending_balance": null,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": null,+ "id": "upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.2.json",+ "invoice_pdf": null,+ "issuer": {+ "type": "self"+ },+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [],+ "has_more": false,+ "object": "list",+ "total_count": 0,+ "url": "/v1/invoices/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.2.json/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": 1000000000,+ "number": null,+ "object": "invoice",+ "on_behalf_of": null,+ "parent": null,+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "auto"+ },+ "template": null,+ "template_version": null+ },+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Basic",+ "status": "draft",+ "status_transitions": {+ "finalized_at": null,+ "marked_uncollectible_at": null,+ "paid_at": null,+ "voided_at": null+ },+ "subtotal": 0,+ "subtotal_excluding_tax": 0,+ "test_clock": null,+ "total": 0,+ "total_discount_amounts": [],+ "total_excluding_tax": 0,+ "total_pretax_credit_amounts": [],+ "total_taxes": [],+ "webhooks_delivered_at": null+}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.jsonnew file mode 100644index 00000000000..7abdad728f2--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.3.json@@ -0,0 +1,105 @@+{+ "account_country": "US",+ "account_name": "NORMALIZED",+ "account_tax_ids": null,+ "amount_due": 0,+ "amount_overpaid": 0,+ "amount_paid": 0,+ "amount_remaining": 0,+ "amount_shipping": 0,+ "application": null,+ "attempt_count": 0,+ "attempted": false,+ "auto_advance": true,+ "automatic_tax": {+ "disabled_reason": null,+ "enabled": false,+ "liability": null,+ "provider": null,+ "status": null+ },+ "automatically_finalizes_at": 1000000000,+ "billing_reason": "manual",+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",+ "discounts": [],+ "due_date": null,+ "effective_at": null,+ "ending_balance": null,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": null,+ "id": "upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.3.json",+ "invoice_pdf": null,+ "issuer": {+ "type": "self"+ },+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [],+ "has_more": false,+ "object": "list",+ "total_count": 0,+ "url": "/v1/invoices/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.3.json/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": 1000000000,+ "number": null,+ "object": "invoice",+ "on_behalf_of": null,+ "parent": null,+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "auto"+ },+ "template": null,+ "template_version": null+ },+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Basic",+ "status": "draft",+ "status_transitions": {+ "finalized_at": null,+ "marked_uncollectible_at": null,+ "paid_at": null,+ "voided_at": null+ },+ "subtotal": 0,+ "subtotal_excluding_tax": 0,+ "test_clock": null,+ "total": 0,+ "total_discount_amounts": [],+ "total_excluding_tax": 0,+ "total_pretax_credit_amounts": [],+ "total_taxes": [],+ "webhooks_delivered_at": null+}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.jsonindex c6c6eef03e4..aba3c72ca04 100644--- 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@@ -35,7 +35,7 @@"default_payment_method": null,"default_source": null,"default_tax_rates": [],- "description": null,+ "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.","discounts": [],"due_date": null,"effective_at": 1000000000,@@ -149,5 +149,5 @@"total_excluding_tax": 10000,"total_pretax_credit_amounts": [],"total_taxes": [],- "webhooks_delivered_at": 1000000000+ "webhooks_delivered_at": null}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.jsonnew file mode 100644index 00000000000..08b13a9a7df--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.finalize_invoice.2.json@@ -0,0 +1,146 @@+{+ "account_country": "US",+ "account_name": "NORMALIZED",+ "account_tax_ids": null,+ "amount_due": 10000,+ "amount_overpaid": 0,+ "amount_paid": 0,+ "amount_remaining": 10000,+ "amount_shipping": 0,+ "application": null,+ "attempt_count": 0,+ "attempted": false,+ "auto_advance": true,+ "automatic_tax": {+ "disabled_reason": null,+ "enabled": false,+ "liability": null,+ "provider": null,+ "status": null+ },+ "automatically_finalizes_at": null,+ "billing_reason": "manual",+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",+ "discounts": [],+ "due_date": null,+ "effective_at": 1000000000,+ "ending_balance": 0,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",+ "id": "upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.2.json",+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",+ "issuer": {+ "type": "self"+ },+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 10000,+ "currency": "usd",+ "description": "Zulip Basic - renewal",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.finalize_invoice.2.json",+ "invoice": "upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.2.json",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "parent": {+ "invoice_item_details": {+ "invoice_item": "ii_NORMALIZED",+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "subscription": null+ },+ "subscription_item_details": null,+ "type": "invoice_item_details"+ },+ "period": {+ "end": 1330657445,+ "start": 1328151845+ },+ "pretax_credit_amounts": [],+ "pricing": {+ "price_details": {+ "price": "price_NORMALIZED",+ "product": "prod_NORMALIZED"+ },+ "type": "price_details",+ "unit_amount_decimal": "10000"+ },+ "quantity": 1,+ "taxes": []+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 1,+ "url": "/v1/invoices/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.2.json/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": 1000000000,+ "number": "NORMALIZED",+ "object": "invoice",+ "on_behalf_of": null,+ "parent": null,+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "letter"+ },+ "template": null,+ "template_version": null+ },+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Basic",+ "status": "open",+ "status_transitions": {+ "finalized_at": 1000000000,+ "marked_uncollectible_at": null,+ "paid_at": null,+ "voided_at": null+ },+ "subtotal": 10000,+ "subtotal_excluding_tax": 10000,+ "test_clock": null,+ "total": 10000,+ "total_discount_amounts": [],+ "total_excluding_tax": 10000,+ "total_pretax_credit_amounts": [],+ "total_taxes": [],+ "webhooks_delivered_at": 1000000000+}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.jsonnew file mode 100644index 00000000000..13b099138d4--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.finalize_invoice.3.json@@ -0,0 +1,146 @@+{+ "account_country": "US",+ "account_name": "NORMALIZED",+ "account_tax_ids": null,+ "amount_due": 10000,+ "amount_overpaid": 0,+ "amount_paid": 0,+ "amount_remaining": 10000,+ "amount_shipping": 0,+ "application": null,+ "attempt_count": 0,+ "attempted": false,+ "auto_advance": true,+ "automatic_tax": {+ "disabled_reason": null,+ "enabled": false,+ "liability": null,+ "provider": null,+ "status": null+ },+ "automatically_finalizes_at": null,+ "billing_reason": "manual",+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",+ "discounts": [],+ "due_date": null,+ "effective_at": 1000000000,+ "ending_balance": 0,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",+ "id": "upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.3.json",+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",+ "issuer": {+ "type": "self"+ },+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 10000,+ "currency": "usd",+ "description": "Zulip Basic - renewal",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.finalize_invoice.3.json",+ "invoice": "upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.3.json",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "parent": {+ "invoice_item_details": {+ "invoice_item": "ii_NORMALIZED",+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "subscription": null+ },+ "subscription_item_details": null,+ "type": "invoice_item_details"+ },+ "period": {+ "end": 1333335845,+ "start": 1330657445+ },+ "pretax_credit_amounts": [],+ "pricing": {+ "price_details": {+ "price": "price_NORMALIZED",+ "product": "prod_NORMALIZED"+ },+ "type": "price_details",+ "unit_amount_decimal": "10000"+ },+ "quantity": 1,+ "taxes": []+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 1,+ "url": "/v1/invoices/upgrade_server_to_fixed_price_monthly_basic_plan--Invoice.create.3.json/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": 1000000000,+ "number": "NORMALIZED",+ "object": "invoice",+ "on_behalf_of": null,+ "parent": null,+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "letter"+ },+ "template": null,+ "template_version": null+ },+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Basic",+ "status": "open",+ "status_transitions": {+ "finalized_at": 1000000000,+ "marked_uncollectible_at": null,+ "paid_at": null,+ "voided_at": null+ },+ "subtotal": 10000,+ "subtotal_excluding_tax": 10000,+ "test_clock": null,+ "total": 10000,+ "total_discount_amounts": [],+ "total_excluding_tax": 10000,+ "total_pretax_credit_amounts": [],+ "total_taxes": [],+ "webhooks_delivered_at": 1000000000+}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.jsonindex 2765e195900..b4d3a5d361f 100644--- 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@@ -35,7 +35,7 @@"default_payment_method": null,"default_source": null,"default_tax_rates": [],- "description": null,+ "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.","discounts": [],"due_date": null,"effective_at": 1000000000,@@ -149,5 +149,5 @@"total_excluding_tax": 10000,"total_pretax_credit_amounts": [],"total_taxes": [],- "webhooks_delivered_at": 1000000000+ "webhooks_delivered_at": null}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.jsonnew file mode 100644index 00000000000..329eff414b7--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--InvoiceItem.create.2.json@@ -0,0 +1,31 @@+{+ "amount": 10000,+ "currency": "usd",+ "customer": "cus_NORMALIZED",+ "date": 1000000000,+ "description": "Zulip Basic - renewal",+ "discountable": false,+ "discounts": [],+ "id": "upgrade_server_to_fixed_price_monthly_basic_plan--InvoiceItem.create.2.json",+ "invoice": "in_NORMALIZED",+ "livemode": false,+ "metadata": {},+ "object": "invoiceitem",+ "parent": null,+ "period": {+ "end": 1330657445,+ "start": 1328151845+ },+ "pricing": {+ "price_details": {+ "price": "price_NORMALIZED",+ "product": "prod_NORMALIZED"+ },+ "type": "price_details",+ "unit_amount_decimal": "10000"+ },+ "proration": false,+ "quantity": 1,+ "tax_rates": [],+ "test_clock": null+}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.jsonnew file mode 100644index 00000000000..165877e0033--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_server_to_fixed_price_monthly_basic_plan--InvoiceItem.create.3.json@@ -0,0 +1,31 @@+{+ "amount": 10000,+ "currency": "usd",+ "customer": "cus_NORMALIZED",+ "date": 1000000000,+ "description": "Zulip Basic - renewal",+ "discountable": false,+ "discounts": [],+ "id": "upgrade_server_to_fixed_price_monthly_basic_plan--InvoiceItem.create.3.json",+ "invoice": "in_NORMALIZED",+ "livemode": false,+ "metadata": {},+ "object": "invoiceitem",+ "parent": null,+ "period": {+ "end": 1333335845,+ "start": 1330657445+ },+ "pricing": {+ "price_details": {+ "price": "price_NORMALIZED",+ "product": "prod_NORMALIZED"+ },+ "type": "price_details",+ "unit_amount_decimal": "10000"+ },+ "proration": false,+ "quantity": 1,+ "tax_rates": [],+ "test_clock": null+}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.jsonindex d652ba776b1..8e74c672f62 100644--- 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@@ -1,5 +1,7 @@{- "adaptive_pricing": null,+ "adaptive_pricing": {+ "enabled": false+ },"after_expiration": null,"allow_promotion_codes": null,"amount_subtotal": null,@@ -48,11 +50,12 @@"livemode": false,"locale": null,"metadata": {- "remote_server_user_id": "15",+ "remote_server_user_id": "1","type": "card_update"},"mode": "setup","object": "checkout.session",+ "origin_context": null,"payment_intent": null,"payment_link": null,"payment_method_collection": "always",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.jsonindex c9932bff908..c385d9e6c8e 100644--- 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@@ -1,7 +1,9 @@{"data": [{- "adaptive_pricing": null,+ "adaptive_pricing": {+ "enabled": false+ },"after_expiration": null,"allow_promotion_codes": null,"amount_subtotal": null,@@ -50,11 +52,12 @@"livemode": false,"locale": null,"metadata": {- "remote_server_user_id": "15",+ "remote_server_user_id": "1","type": "card_update"},"mode": "setup","object": "checkout.session",+ "origin_context": null,"payment_intent": null,"payment_link": null,"payment_method_collection": "always",diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.pyindex 6aca99865af..90548543820 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()