GetBillingAnchorDay returns the day-of-month that anchors this user's billing cycle. For paid users with an active subscription, it uses the renewal date. For free users or when SubscriptionRenewsAt is nil, it falls back to the account creation date.
()
| 132 | // For paid users with an active subscription, it uses the renewal date. |
| 133 | // For free users or when SubscriptionRenewsAt is nil, it falls back to the account creation date. |
| 134 | func (user User) GetBillingAnchorDay() int { |
| 135 | if user.SubscriptionRenewsAt != nil && !user.IsOnFreePlan() { |
| 136 | return user.SubscriptionRenewsAt.Day() |
| 137 | } |
| 138 | return user.CreatedAt.Day() |
| 139 | } |