Commit Graph

1123 Commits

Author SHA1 Message Date
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
Lauryn Menard
18686e06bb sponsorship: Remove free_trial from sponsorship page context.
Being on a free trial also means that the billing entity is on a
paid plan.

If they are on a sponsored plan, then they are not on a free trial.
If they have a pending sponsorship request, then they will be
redirected to the billing page. Otherwise, they will be shown the
form to request a sponsored/discounted plan, which does not use
the free_trial boolean.
2024-12-12 11:04:23 -08:00
Lauryn Menard
710f36cade stripe: Refactor function for getting sponsorship page context.
Reorders the logic in get_sponsorship_request_context so that the
early return for billing entities with a pending sponsorship request
that are also on a current paid plan is clearer.
2024-12-12 11:04:23 -08:00
Lauryn Menard
76bd6e2d62 support: Get plan data without making end of billing cycle updates.
Updates get_plan_data_for_support_view to get the latest ledger entry
directly instead of calling make_end_of_cycle_updates_if_needed so
that viewing a support page doesn't trigger any changes to the
current and scheduled plans.
2024-12-03 10:30:35 -08:00
Lauryn Menard
a0562593b3 stripe: Update next_invoice_date for current logic of monthly invoices.
Updates next_invoice_date since, as of commit caba57fe1e, we no
longer consider the plan's billing schedule (annual or monthly)
when invoicing for additional licenses.
2024-12-03 10:17:28 -08:00
Lauryn Menard
7a40462aed support: Use datetime for push notification data in remote support. 2024-12-02 10:09:19 -08:00
Lauryn Menard
a0bbc62f2b support: Add fixed-price plan configuration to Cloud support view.
Adds ability to configure a fixed-price plan and to delete a
configured fixed-price plan in the Cloud support view.

Updates the invoice processing to send reminder emails to the
billing support email for these Cloud fixed-price plans about
renewals since we now are able to configure them via our support
panel.

Updates function to get the billing session for stripe webhook
events to handle an intial upgrade for a custom generated invoice
for a fixed-price plan for a Cloud organization, which won't have
a user_id in the invoice metadata.
2024-11-26 12:42:39 -08:00
Lauryn Menard
89b5e850b2 support: Implement setting a current plan end date for Cloud support.
Prep for implementing fixed-price plan offers in Cloud support view.
2024-11-26 12:42:39 -08:00
Lauryn Menard
6376fb7fec support: Remove count check of keys in Cloud support view.
This check made sense before the support view expanded with the
billing system work over this past year. As we continue to expand
the actions/features of the support views, it's likely we'll have
cases where we're passing more values for particular features.

Prep for implementing fixed-price plan offers in Cloud support view.
2024-11-26 12:42:39 -08:00