1181 Commits

Author SHA1 Message Date
Ethan Mayer
c12b94aea4 models: Refactor corporate/models.py into models package.
Fixes #34318.

Seperated models file into a package with component files.
2025-04-08 10:16:35 -07:00
Prakhar Pratyush
41df472d41 corporate: Replace /try-zulip with /?show_try_zulip_modal.
This commit removes the `/try-zulip` landing page.

The URLs are replaced with `chat.zulip.org/?show_try_zulip_modal`,
which leads to display a modal for spectators.

Fixes #34181.
2025-04-03 13:01:48 -07:00
Lauryn Menard
ec89e5afd2 billing: Improve error handling when invoicing plans as needed.
When we're unable to process an invoice for a customer due to a billing
or assertion error, we log the error and add the customer ID to a set
of failed customer IDs. This allows us to continuing invoicing other
customers, and at the same time not invoice any other pending plans
attached to a customer we failed to invoice.
2025-03-27 12:51:52 -07:00
Lauryn Menard
10fff6a691 billing: Extract helper for invoicing check of remote server audit log.
Extracts the logic for making sure that, for self-hosted plans, the
remote server audit log data is current before invoicing an active
plan.
2025-03-27 12:51:52 -07:00
Lauryn Menard
0f567a1a66 billing: Extract helper for sending invoice overdue email.
Extracts the logic for sending an email to billing support when
a remote server's audit log data is stale and there is an active
CustomerPlan that needs to be invoiced.
2025-03-27 12:51:52 -07:00
Lauryn Menard
10a02142dc billing: Extract helper for sending fixed price plan renewal email.
Extracts the logic for sending a reminder email about the end of a
fixed price plan to billing support into a separate function.
2025-03-27 12:51:52 -07:00
Anders Kaseorg
13bd8771f9 corporate: Parse Accept header instead of X-Requested-With.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-03-26 22:29:09 -07:00
Aman Agrawal
c490b1cbb4 support: Show current billing admins on cloud support page. 2025-03-24 16:00:48 -07:00
Anders Kaseorg
67fb7daa63 ruff: Fix RUF051 Use pop instead of key in dictdel dict[key].
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-03-14 17:31:50 -07:00
Vector73
c049259d07 user: Remove is_billing_admin user property.
Removed `is_billing_admin` user property as it is no longer used since
billing permissions are now determined by `can_manage_billing_group`
realm setting.
2025-03-10 09:36:30 -07:00
Vector73
158fd58cde settings: Add "can_manage_billing_group" realm setting.
Added "can_manage_billing_group" realm group permission setting
to control who can manage billing and plans in the organization.

Fixes #32745.
2025-03-10 09:36:30 -07:00
ImDooMLorD
6dea58623c errors: Standardize "already in use" error messages.
Updates these error messages to have "X is already in use." format,
e.g., "Channel name is already in use." and "Name is already in use."

Fixes #33629.
2025-03-04 16:10:25 -08:00
Lauryn Menard
c4e3ccafa2 stripe: Delete fixed price plan offer if customer on comp access plan.
Updates delete_fixed_price_plan to use the same structure as
configure_fixed_price_plan. If there is a customer plan and it's
billable, then we delete the configured CustomerPlan object. If
there is no customer plan or it's a complimentary access plan, we
delete the configured CustomerPlanOffer object.
2025-02-28 17:42:04 -08:00
Lauryn Menard
add58e3795 billing: Use customer.minimum_licenses for minimum plan check.
Allow for manually setting a minimum_licenses value on a customer
to return that for min_licenses_for_plan in cases where we wanted
to override the general plan minimum for a particular case.
2025-02-20 14:17:25 -08:00
Anders Kaseorg
4e04eed745 typos: Fix typos caught by typos and mwic.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-02-18 19:44:02 -08:00
Anders Kaseorg
dd99ed019a requirements: Upgrade Django from 5.0.10 to 5.1.6.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-02-18 09:50:34 -08:00
Mateusz Mandera
0caf815e36 do_activate_mirror_dummy_user: Assert user_profile is a mirror dummy.
If this is called on a user without is_mirror_dummy=True, that seems
certain to be a bug. Therefore, an assert is preferable in order to
catch this, rather than returning early with noop like some other
function such as do_deactivate_user.
2025-01-28 09:38:56 -08:00
Anders Kaseorg
3b84dd3b8c stripe_event_handler: Fix UP038.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-01-24 22:59:58 -08:00
Aman Agrawal
b549562a4d sponsorship: Ask user how they plan to use Zulip.
This will help avoid some back-and-forth on sponsorship requests.
2025-01-22 09:22:52 -08:00
Aman Agrawal
6e1bb56519 stripe: Check for min_licenses when switching plan tier.
When we are upgrading a customer to a different plan tier, we should
check if switching plans would lead to different licenses due to
different minimum license requirement between plans.
2025-01-21 15:53:53 -08:00
Lauryn Menard
10b2e2a092 support: Update support view PlanData to use "complimentary access".
Prep for implementing a complimentary access plan for Zulip Cloud.
2025-01-21 15:40:27 -08:00
Lauryn Menard
1297541059 stripe-tests: Update uses of "legacy" to "complimentary access". 2025-01-21 15:40:27 -08:00
Lauryn Menard
8d638363da corporate: Update self-hosted complimentary access plan name.
Updates the name for the self-hosted complimentary access plan
to "Zulip Basic (complimentary)" instead of "Free (legacy plan)".

Since these plans are never billed in Stripe, we don't need to
hold to the 22 character limit for the plan name.
2025-01-21 15:40:27 -08:00
Lauryn Menard
261333c37f corporate: Clean up code remaining comments with "legacy plan".
Replaces documentation in billing code and tests to use
"complimentary access plan" instead of "legacy plan".
2025-01-21 15:40:27 -08:00
Lauryn Menard
bc20a0f086 support: Update "temporary courtesy" to "complimentary access".
Updates support actions for "temporary courtesy" plans to instead
use "complimentary access" to refer to these plans and actions.

Prep for implementing a complimentary access plan for Zulip Cloud.
2025-01-21 15:40:27 -08:00
Lauryn Menard
d3bc9bec1d billing: Rename migrate_customer_to_legacy_plan.
Renames migrate_customer_to_legacy_plan to
create_complimentary_access_plan for how this
function is currently used.

Prep for adding a complimentary access plan
for Zulip Cloud.
2025-01-21 15:40:27 -08:00
Lauryn Menard
9fdaa9de0c portico: Fix logic for scheduled upgrade context variables.
Renames context variables used for the pricing model template for
when the customer has a current plan that has an upgrade to a new
plan tier scheduled.

Fixes the "Upgrade scheduled" note that was being shown when an
annual fixed-price plan has a subsequent fixed-price plan scheduled
to start when the current plan ends.

Prep for adding a complimentary access plan for Zulip Cloud.
2025-01-21 15:39:13 -08:00
Aman Agrawal
b870faec5a stripe: Require 10 minimum licenses for cloud plus plan. 2025-01-16 11:32:03 -08:00
Aman Agrawal
e0767b23ed stripe: Validate licenses for the correct plan.
Since licenses are being created for the `new_plan` we need to
check licenses for the new plan here.
2025-01-16 11:32:03 -08:00
Lauryn Menard
e963d5eaa9 billing: Fix deleting next fixed-price plan via support.
If the customer has a current fixed-price plan and a support admin
configures a fixed-price plan for the upcoming billing year, then
a CustomerPlan object is created and not a CustomerPlanOffer.

Fix the support action for deleting a configured fixed-price next
plan.

Updates the success strings for these actions to be specify if the
deleted object was a plan offer or a scheduled plan.
2025-01-15 11:23:24 -08:00
Anders Kaseorg
f223251ffe requirements: Upgrade Python requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-01-14 09:42:16 -08:00
Anders Kaseorg
653b0b0436 ruff: Partially reformat Python with Ruff 0.9 (2025 style).
These are the changes that are backwards compatible with the 2024
style.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-01-14 09:42:16 -08:00
Lauryn Menard
e65f3cf657 corporate: Create license ledger for automanaged plan migrations.
If we move a paid plan from a remote server to a remote realm, and
the plan has automated license management, then we create an updated
license ledger entry when we move the plan for the remote realm
billing data so that we have an accurate user count for licenses
when the plan is next invoiced.
2024-12-31 16:54:40 -08:00
Lauryn Menard
c01787f41a corporate: Clean up vestiges of migrating plans to multiple realms.
In commit ea863bab5b, handle_customer_migration_from_server_to_realm
was updated to only move a remote server's plan in the case that there
is only one remote realm on the server.
2024-12-31 16:54:40 -08:00
Anders Kaseorg
58822372d5 typos: Fix typos caught by typos and mwic.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-12-24 19:15:36 -08:00
Anders Kaseorg
19b8cde27f ruff: Fix PLC0206 Extracting value from dictionary without calling .items().
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-12-21 21:06:53 -08:00
Alya Abbott
e05f66b311 portico: Add Rush Stack case study. 2024-12-17 11:44:32 -08:00
Aman Agrawal
0b063e73fe stripe: Fix error on visiting /customer_portal without parameters.
Now visiting `/customer_portal` will correctly take you to the stripe
customer portal corresponding to the customer for editing.

There is no reason for us to block access to this page.
2024-12-17 10:33:22 -08:00
Aman Agrawal
bb8a0ea1f4 stripe: Create customer if one doesn't exist.
Since this function can only be called by billing admins, it
is okay to allow them to create a customer if one doesn't exist.
2024-12-17 10:33:22 -08:00
Lauryn Menard
a1121b39ad stripe: Rename should_schedule_upgrade_for_legacy_remote_server param.
Renames should_schedule_upgrade_for_legacy_remote_server parameter
to upgrade_when_complimentary_access_plan_ends in both
process_initial_upgrade and compute_plan_parameters, as well as
associated variable names and relevant code comments.
2024-12-15 09:15:07 -08:00
Lauryn Menard
1f2f0af257 stripe: Rename remote_server_legacy_plan param in initial upgrade.
Renames the remote_server_legacy_plan parameter in
process_initial_upgrade to instead be complimentary_access_plan,
as well as some relevant code comments in that function.
2024-12-15 09:15:07 -08:00
Lauryn Menard
7a0626aede stripe: Rename get_remote_server_legacy_plan.
Renames get_remote_server_legacy_plan to
get_complimentary_access_plan, as well as
associated variable names.
2024-12-15 09:15:07 -08:00
Lauryn Menard
20352aff9e stripe: Rename get_legacy_remote_server_next_plan.
Renames get_legacy_remote_server_next_plan to
get_complimentary_access_next_plan, as well as
associated variable names.
2024-12-15 09:15:07 -08:00
Lauryn Menard
b6f8c20772 stripe: Rename get_legacy_remote_server_next_plan_name.
Rename get_legacy_remote_server_next_plan_name to
get_complimentary_access_next_plan_name, as well as all
associated variables.
2024-12-15 09:15:07 -08:00
Lauryn Menard
713bef6ff5 stripe: Rename get_formatted_remote_server_legacy_plan_end_date.
Renames get_formatted_remote_server_legacy_plan_end_date to
get_formatted_complimentary_plan_end_date and associated
variable names.
2024-12-15 09:15:07 -08:00
Lauryn Menard
984fdf3eb9 upgrade: Update context variables to use "complimentary_access". 2024-12-15 09:15:07 -08:00
Lauryn Menard
f63e5c9242 billing: Update context variables to use "complimentary_access". 2024-12-15 09:15:07 -08:00
Lauryn Menard
36210c1ff3 billing: Replace legacy plan languagae with complimentary access.
Replaces the billing context variable for billing entities on a
temporary courtesy plan to use 'complimentary access' instead of
'legacy'.
2024-12-12 11:04:23 -08:00
Lauryn Menard
a6ca968a29 corporate: Add and use CustomerPlan.COMPLIMENTARY_PLAN_TIERS.
Adds COMPLIMENTARY_PLAN_TIERS to the CustomerPlan model so that
we start transitioning from the "legacy plan" language in the
billing system code. Adds a helper function that checks if the
plan tier is in COMPLIMENTARY_PLAN_TIERS.

Updates the sponsorship page context to use that helper function
and updates the relevant template for the updated user-facing
terminology.
2024-12-12 11:04:23 -08:00
Lauryn Menard
e1ae7dba18 stripe: Rename add_sponsorship_info_to_context to clarify function.
Renames add_sponsorship_info_to_context to instead be
add_org_type_data_to_sponsorship_context since this function for
all billing entities is adding information about the organization
type for the sponsorship request form.
2024-12-12 11:04:23 -08:00