Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscription Alignment #2210

Merged
merged 7 commits into from
Feb 6, 2025
Merged

Subscription Alignment #2210

merged 7 commits into from
Feb 6, 2025

Conversation

GAlexIHU
Copy link
Contributor

@GAlexIHU GAlexIHU commented Feb 4, 2025

Overview

Alignment consists of 2 concepts:

  1. Scheduling: when things, such as issuing an invoice or changing to a different plan happen
  2. Compensation (Prorating): How what someone pays is adjusted based on how their access to it changes, or vice verse, how someone's access to a thing is adjusted based on what they've paid for it

This PR introduces a limited set of features working towards these goals

Contents:

  • new Timing concept: changes can take effect at some special enumerated times (e.g. end of billing cycle, immediately)
  • alignment.BillablesMustAlign for Subscriptions too: inherited from plan setting (or custom input), cannot be changed. If true, any phase with billable items can have at most 1 BillingCycle
  • introduce concept of a shared BillingPeriod for a given SubscriptionPhase: dynamically calculated from subscription contents for alignment enforced subscriptions
  • resetting the Billing Period: currently no user initiated action can trigger this as it needs further product decisions, but the internal capability is there

Changes:

  • change BillingCollector so aligned invoiceAt times are used for the created lines
  • [later, pending OM-1167, followup PR] the generated periods themselves can be aligned with the desired billing times
  • tidy up recurrence package

@GAlexIHU GAlexIHU added the release-note/feature Release note: Exciting New Features label Feb 4, 2025
@GAlexIHU GAlexIHU force-pushed the feat/subs-alignment-2 branch from 92ca733 to 3e04e75 Compare February 4, 2025 18:52
@GAlexIHU GAlexIHU marked this pull request as ready for review February 4, 2025 19:10
@GAlexIHU GAlexIHU force-pushed the feat/subs-alignment-2 branch from f9fb574 to e7b97b4 Compare February 6, 2025 11:57
@@ -78,6 +78,7 @@ func (InvoiceLineManagedBy) Values() []string {

// Period represents a time period, in billing the time period is always interpreted as
// [from, to) (i.e. from is inclusive, to is exclusive).
// TODO: Lets merge this with recurrence.Period
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -18,6 +18,8 @@ type SubscriptionItem struct {
// The defacto cadence of the item is calculated and persisted after each change.
models.CadencedModel `json:",inline"`

BillingBehaviorOverride BillingBehaviorOverride `json:"billingBehaviorOverride"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: as far as I see we only use the Subscription level override, but not this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the reset-anchor logic (that is partially implemented in this PR)

@GAlexIHU GAlexIHU merged commit 0a31349 into main Feb 6, 2025
24 checks passed
@GAlexIHU GAlexIHU deleted the feat/subs-alignment-2 branch February 6, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/feature Release note: Exciting New Features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants