Commit Graph

23 Commits

Author SHA1 Message Date
Stephon Brown
ee07462d28 [PM-37084] Business Aware Schedule Recovery and Cancellation (#7686)
* feat(billing): introduce unified subscription price increase scheduler API

* feat(billing): implement unified subscription price increase scheduler logic

* refactor(billing): update subscription handlers to use unified scheduler

* feat(billing): extend price migration feature flag checks

* test(billing): add and update tests for unified price increase scheduler

* fix(billing): run dotnet format

* feat(billing): expand customer and customer.discount on subscription fetch

* refactor(ReinstateSubscriptionCommandTests): rename test method for broader scope

* feat(billing): expand customer.discount in update handler

* test(billing): update test name

* feat(billing): add test clock waiting mechanism for upcoming invoices

* feat(billing): introduce cancelling user ID metadata key

* feat(billing): store cancelling user ID on subscription cancellation

* feat(billing): clear cancelling user ID on subscription reinstatement

* test(billing): update subscriber service tests for cancelling user ID

* style(SubscriberService): use 'is not null' pattern matching

* feat(SubscriberService): add PM35215 migration cohort metadata handling

* feat(SubscriberService): extend price migration deferral to PM35215

* test(SubscriberService): add and update tests for PM35215 feature

* feat(billing): Introduce OrganizationPriceIncreaseOptions

* refactor(billing): Centralize price increase eligibility in scheduler

* refactor(billing): Delegate price increase validation from UpcomingInvoiceHandler

* feat(billing): Manage price increase schedules during subscription lifecycle events

* test(billing): Update UpcomingInvoiceHandlerTests for centralized validation

* test(billing): Add PriceIncreaseScheduler tests for SkipIfAlreadyScheduled option

* test(billing): Add SubscriberService tests for price increase schedule management

* fix(billing): run dotnet format

* fix(billing): remove redundant customer expansion

* fix(billing): expand discounts for customer and subscription

* refactor(billing): Rename method to clarify dispatching role for organization scheduling

* fix(billing): Prevent clearing migration cohort metadata on cancellation

* fix(billing): Fallback to standard email when price increase migration fails

* feat(billing): improve observability for missing migration path data

* refactor(billing): simplify business plan type identification
2026-05-26 17:16:18 -04:00
Alex Morask
34d4b6b3f6 [PM-37068] feat: Add business plan cohort branch to UpcomingInvoiceHandler (#7678)
* [PM-37068] feat: Add business plan cohort branch to UpcomingInvoiceHandler

Wires the caller side of the Teams/Enterprise 2020 → current price
migration. AlignOrganizationSubscriptionConcernsAsync becomes a
ProductTier dispatcher; the new business branch loads the cohort
assignment, runs eligibility guards (assignment unscheduled, cohort
active, org PlanType matches cohort source), and invokes PM-37064's
ScheduleBusinessPriceIncrease. The renewal email is a placeholder until
PM-37070 lands.

Also expands subscriptions.data.customer on the customer load so
PM-37064 can preserve customer-level discounts into Phase 2.

Incidentally strips pre-existing #region markers in
UpcomingInvoiceHandlerTests.cs per the no-regions rule.

* Apply review feedback: gate FF in handler, split MigrationPath checks, silence scheduler churn-only warning

* Add cohort metadata to subscription on migration schedule

---------

Co-authored-by: cyprain-okeke <108260115+cyprain-okeke@users.noreply.github.com>
2026-05-20 11:40:50 -05:00
Alex Morask
466bf01148 [PM-37064] feat: Add ScheduleBusinessPriceIncrease scheduler entry point (#7665)
* [PM-37064] feat: Add ScheduleBusinessPriceIncrease scheduler entry point

Extends PriceIncreaseScheduler (PM-32645) with a parallel entry point for
Teams/Enterprise 2020 → current plan migrations under epic PM-35215. The
business path consumes a cohort directly, preserves existing discounts,
optionally appends the cohort's proactive coupon, and stamps ScheduledDate
on the assignment row on success.

Existing Schedule renames to SchedulePersonalPriceIncrease across four
call sites; ResolvePhase2Async becomes private. Shared concerns extract
into ActiveScheduleExistsAsync and CreateAndConfigureScheduleAsync helpers.

ScheduleBusinessPriceIncrease has zero production callers — the
UpcomingInvoiceHandler dispatcher branch lands in a follow-up. The new
PM35215_BusinessPlanPriceMigration feature flag defaults off.

* Address PR review: prevent orphan schedules and fix Release flag gate
2026-05-19 14:14:30 -05:00
Stephon Brown
e5419a7662 [PM-37597] Set Automatic Tax and Prevent Tax Exempt Mutations (#7662)
* feat(billing): add feature flag for automatic tax enforcement

* refactor(billing): remove unused SubscriptionUpdateOptionsExtensions

* refactor(billing): inject IFeatureService into billing services and commands

* feat(billing): conditionalize customer tax exemption logic with feature flag

* feat(billing): conditionally enable Stripe automatic tax in OrganizationBillingService

* test(billing): add unit tests for Stripe automatic tax feature flag

* fix(billing): Run dotnet format

* test(Premium): use class-level IFeatureService mock in UpgradePremiumToOrganizationCommandTests

* refactor(billing): consolidate customer return conditions for automatic tax

* refactor(billing): broaden postal code validation for organization creation

* refactor(billing): remove PM37597 feature flag for automatic tax logic

* Revert "refactor(billing): broaden postal code validation for organization creation"

This reverts commit cddbda838c.

* fix(test): remove outdated test
2026-05-19 13:18:06 -05:00
Conner Turnbull
9e49955045 [PM-31909] Remove m3 flagged logic (#7352)
* Remove pm-26462-milestone-3 flag from PricingClient

Simplify FamiliesAnnually2025 lookup to always return "families-2025".
Remove PreProcessFamiliesPreMigrationPlan deployment safeguard method
and its call sites. Remove unused IFeatureService constructor dependency.

* Remove pm-26462-milestone-3 flag from UpcomingInvoiceHandler.HandleForOrganizationAsync

Remove milestone3 variable and parameter from
AlignOrganizationSubscriptionConcernsAsync. Simplify guard clause
to only check plan type.

* Update PricingClientTests after pm-26462-milestone-3 removal

Remove IFeatureService from test setup. Delete tests for flag-disabled
safeguard behavior. Clean up remaining test names.

* Update UpcomingInvoiceHandlerTests after pm-26462-milestone-3 removal

Remove all feature flag mock setup lines for PM26462_Milestone_3.
Delete test methods that verified flag-disabled behavior.

* Merge GetPlan lookup key test regions into one
2026-04-14 15:31:56 -04:00
Conner Turnbull
aad805a976 [PM-34866][PM-34865] Fix EnableAutomaticTaxAsync to update schedule phases (#7437)
* [PM-34866] Fix EnableAutomaticTaxAsync to update schedule phases

* Use test clock frozen time for phase filtering

* Expand test_clock on customer subscription fetches
2026-04-10 15:50:41 +00:00
Stephon Brown
4883d4995e chore(mail): update 'renewal' to 'subscription' in Families email subject (#7406) 2026-04-09 10:31:13 -04:00
Conner Turnbull
aced3762fa [PM-31902] Remove m2 flagged logic (#7351)
* Remove pm-23341-milestone-2 flag from UpcomingInvoiceHandler.HandleForUserAsync

Always call AlignPremiumUsersSubscriptionConcernsAsync instead of gating
it behind the feature flag.

* Remove pm-23341-milestone-2 flag from AccountsController and SubscriptionResponseModel

Remove includeMilestone2Discount parameter from both SubscriptionResponseModel
constructors. Rename ShouldIncludeMilestone2Discount to ShouldIncludeDiscount
and always evaluate the discount (coupon ID match + active check).

* Update AccountsControllerTests after pm-23341-milestone-2 removal

Remove feature flag mock setup lines and delete test methods that
verified flag-disabled behavior. Rename tests to remove flag references.

* Update SubscriptionResponseModelTests after pm-23341-milestone-2 removal

Remove includeMilestone2Discount parameter from all constructor calls.
Delete tests that verified flag-disabled behavior.

* Update UpcomingInvoiceHandlerTests after pm-23341-milestone-2 removal

Remove all feature flag mock setup lines for PM23341_Milestone_2.

* Remove IFeatureService from AccountsController constructor and tests

The constructor parameter became unused after removing the flag check.

* Add default ListPremiumPlans mock for UpcomingInvoiceHandler tests

After removing the m2 flag guard, AlignPremiumUsersSubscriptionConcernsAsync
is always called and needs ListPremiumPlans to return a non-null value.
Add a default empty list in the test constructor setup.
2026-04-01 18:05:26 +00:00
Conner Turnbull
c604379f04 [PM-33901] Implement schedule-aware tax handling (#7319)
Make tax-related subscription updates schedule-aware during the ~15-day
window between invoice.upcoming and renewal. When a subscription schedule
is present and the feature flag is enabled, update default_settings.automatic_tax
on the schedule instead of the subscription directly.

Modified paths:
- UpcomingInvoiceHandler: AlignOrganizationTaxConcernsAsync,
  AlignPremiumUsersTaxConcernsAsync, new shared EnableAutomaticTaxAsync helper
- UpdateBillingAddressCommand: EnableAutomaticTaxAsync, added IFeatureService
2026-03-27 14:27:36 -04:00
Alex Morask
54c3e4a695 feat(billing): add IPriceIncreaseScheduler for deferred price migration scheduling (#7305) 2026-03-26 15:00:12 -05:00
Alex Morask
15e71aa93d [PM-33894] Schedule price increases (#7293) 2026-03-24 17:22:50 -05:00
Stephon Brown
8302509bf9 [PM-31645] Implement Swiss Tax Logic (#7186)
* feat(tax): introduce direct tax country utilities and Switzerland constant

* refactor(tax): use `TaxHelpers.IsDirectTaxCountry` for country checks

* feat(tax): implement customer tax exempt status alignment

* test(tax): add comprehensive unit tests for tax exempt alignment logic

* tests(billing): clarify tests

* fix(billing): run dotnet format

* fix(billing): run dotnet format

* fix(billing): Prevent NullReferenceException when accessing customer country

* test(billing): Add Stripe adapter mocks for AdjustSubscription scenarios

* refactor(billing): apply null-conditional operator for address country access

* feat(billing): update missing tax exemption determinations

* test(billing): add unit tests for tax exemption updates

* fix(billing) run dotnet format

* fix(billing): add nullability

* style(files): normalize file encoding for billing utilities

* refactor(TaxHelpers): simplify tax exempt status determination

* test(Tax): update tax exempt determination tests

* fix(billing): revert postal code validation

* test(billing): update tax exempt tests

* fix(billing): run dotnet format
2026-03-17 14:09:41 -04:00
Alex Morask
75a857055e [PM-30697] [PM-30698] Renewal email copy updates (#6875)
* feat(families-renewal): Update copy

* feat(premium-renewal): Add new var, update copy
2026-01-21 11:52:36 -06:00
Kyle Denney
89a2eab32a [PM-23717] premium renewal email (#6672)
* [PM-23717] premium renewal email

* pr feedback

* pr feedback
2025-12-02 16:38:28 -06:00
Kyle Denney
02568c8e7c [PM-28100] families 2019 email (#6645)
* [PM-28100] families 2019 email

* pr feedback
2025-12-01 14:01:26 -06:00
Alex Morask
219993cc2e [PM-26461] Send F2020 renewal email (#6638)
* Send F2020 renewal email

* Implement and use simple hero

* Cy's feedback
2025-11-26 08:37:48 -06:00
Alex Morask
f595818ede [PM-24549] Remove feature flag: use-pricing-service (#6567)
* Remove feature flag and move StaticStore plans to MockPlans for tests

* Remove old plan models / move sponsored plans out of StaticStore

* Run dotnet format

* Add pricing URI to Development appsettings for local development and integration tests

* Updated Api Integration tests to get current plan type

* Run dotnet format

* Fix failing tests
2025-11-19 09:53:30 -06:00
Kyle Denney
75d8250f3a [PM-24298] milestone3 families 2025 (#6586)
* [PM-24298] milestone3 families2025

# Conflicts:
#	src/Billing/Services/Implementations/UpcomingInvoiceHandler.cs
#	test/Billing.Test/Services/UpcomingInvoiceHandlerTests.cs

* update test name
2025-11-17 16:03:35 -06:00
Alex Morask
c620ec2aca [PM-28250] Fix seat add on defect (#6580)
* Handle seat add on

* Remove old price instead
2025-11-17 10:50:10 -06:00
Stephon Brown
30ff175f8e Milestone 2 Handler Update (#6564)
* fix(billing): update discount id

* test(billing) update test
2025-11-13 17:47:06 +00:00
Alex Morask
59a64af345 [PM-26435] Milestone 3 / F19R (#6574)
* Re-organize UpcomingInvoiceHandler for readability

* Milestone 3 renewal

* Map premium access data from additonal data in pricing

* Feedback

* Fix test
2025-11-13 09:09:01 -06:00
Stephon Brown
db36c52c62 Milestone 2C Update (#6560)
* fix(billing): milestone update

* tests(billing): update tests
2025-11-10 16:07:14 -05:00
Stephon Brown
5dbce33f74 [PM-24273] Milestone 2C (#6544)
* feat(billing): add mjml template and updated templates

* feat(billing): update maileservices

* feat(billing): add milestone2 discount

* feat(billing): add milestone 2 updates and stripe constants

* tests(billing): add handler tests

* fix(billing): update mailer view and templates

* fix(billing): revert mailservice changes

* fix(billing): swap mailer service in handler

* test(billing): update handler tests
2025-11-06 13:21:29 -05:00