diff --git a/src/Api/Models/Response/SubscriptionResponseModel.cs b/src/Api/Models/Response/SubscriptionResponseModel.cs index cca4f8ae72..c7aae1dec2 100644 --- a/src/Api/Models/Response/SubscriptionResponseModel.cs +++ b/src/Api/Models/Response/SubscriptionResponseModel.cs @@ -43,20 +43,12 @@ public class SubscriptionResponseModel : ResponseModel public DateTime? Expiration { get; set; } } -public class BillingCustomerDiscount +public class BillingCustomerDiscount(SubscriptionInfo.BillingCustomerDiscount discount) { - public BillingCustomerDiscount(SubscriptionInfo.BillingCustomerDiscount discount) - { - Id = discount.Id; - Active = discount.Active; - PercentOff = discount.PercentOff; - AppliesTo = discount.AppliesTo; - } - - public string Id { get; } - public bool Active { get; } - public decimal? PercentOff { get; } - public List AppliesTo { get; } + public string Id { get; } = discount.Id; + public bool Active { get; } = discount.Active; + public decimal? PercentOff { get; } = discount.PercentOff; + public List AppliesTo { get; } = discount.AppliesTo; } public class BillingSubscription diff --git a/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs b/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs index 61b6a2c943..dca45ceba0 100644 --- a/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs +++ b/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs @@ -1037,7 +1037,6 @@ public class OrganizationService : IOrganizationService { smSubscriptionUpdate = new SecretsManagerSubscriptionUpdate(organization, true) .AdjustSeats(additionalSmSeatsRequired); - await _updateSecretsManagerSubscriptionCommand.ValidateUpdate(smSubscriptionUpdate); } var invitedAreAllOwners = invites.All(i => i.invite.Type == OrganizationUserType.Owner); @@ -1133,12 +1132,14 @@ public class OrganizationService : IOrganizationService throw new BadRequestException("Cannot add seats. Cannot manage organization users."); } + await AutoAddSeatsAsync(organization, newSeatsRequired, prorationDate); + if (additionalSmSeatsRequired > 0) { smSubscriptionUpdate.ProrationDate = prorationDate; await _updateSecretsManagerSubscriptionCommand.UpdateSubscriptionAsync(smSubscriptionUpdate); } - await AutoAddSeatsAsync(organization, newSeatsRequired, prorationDate); + await SendInvitesAsync(orgUsers.Concat(limitedCollectionOrgUsers.Select(u => u.Item1)), organization); await _referenceEventService.RaiseEventAsync( diff --git a/src/Core/Models/Business/SubscriptionInfo.cs b/src/Core/Models/Business/SubscriptionInfo.cs index 7bb5bddbc8..5294097613 100644 --- a/src/Core/Models/Business/SubscriptionInfo.cs +++ b/src/Core/Models/Business/SubscriptionInfo.cs @@ -14,16 +14,16 @@ public class SubscriptionInfo public BillingCustomerDiscount(Discount discount) { - Id = discount.Id; - Active = discount.Start != null && discount.End == null; + Id = discount.Coupon?.Id; + Active = discount.End == null; PercentOff = discount.Coupon?.PercentOff; - AppliesTo = discount.Coupon?.AppliesTo?.Products ?? new List(); + AppliesTo = discount.Coupon?.AppliesTo?.Products ?? []; } - public string Id { get; } - public bool Active { get; } - public decimal? PercentOff { get; } - public List AppliesTo { get; } + public string Id { get; set; } + public bool Active { get; set; } + public decimal? PercentOff { get; set; } + public List AppliesTo { get; set; } } public class BillingSubscription diff --git a/src/Core/OrganizationFeatures/OrganizationSubscriptions/Interface/IUpdateSecretsManagerSubscriptionCommand.cs b/src/Core/OrganizationFeatures/OrganizationSubscriptions/Interface/IUpdateSecretsManagerSubscriptionCommand.cs index 036e4a1795..5c6758fd17 100644 --- a/src/Core/OrganizationFeatures/OrganizationSubscriptions/Interface/IUpdateSecretsManagerSubscriptionCommand.cs +++ b/src/Core/OrganizationFeatures/OrganizationSubscriptions/Interface/IUpdateSecretsManagerSubscriptionCommand.cs @@ -5,5 +5,4 @@ namespace Bit.Core.OrganizationFeatures.OrganizationSubscriptions.Interface; public interface IUpdateSecretsManagerSubscriptionCommand { Task UpdateSubscriptionAsync(SecretsManagerSubscriptionUpdate update); - Task ValidateUpdate(SecretsManagerSubscriptionUpdate update); } diff --git a/src/Core/OrganizationFeatures/OrganizationSubscriptions/UpdateSecretsManagerSubscriptionCommand.cs b/src/Core/OrganizationFeatures/OrganizationSubscriptions/UpdateSecretsManagerSubscriptionCommand.cs index 9eab58ff0a..2871320990 100644 --- a/src/Core/OrganizationFeatures/OrganizationSubscriptions/UpdateSecretsManagerSubscriptionCommand.cs +++ b/src/Core/OrganizationFeatures/OrganizationSubscriptions/UpdateSecretsManagerSubscriptionCommand.cs @@ -47,7 +47,7 @@ public class UpdateSecretsManagerSubscriptionCommand : IUpdateSecretsManagerSubs public async Task UpdateSubscriptionAsync(SecretsManagerSubscriptionUpdate update) { - await ValidateUpdate(update); + await ValidateUpdateAsync(update); await FinalizeSubscriptionAdjustmentAsync(update); @@ -123,7 +123,7 @@ public class UpdateSecretsManagerSubscriptionCommand : IUpdateSecretsManagerSubs } - public async Task ValidateUpdate(SecretsManagerSubscriptionUpdate update) + private async Task ValidateUpdateAsync(SecretsManagerSubscriptionUpdate update) { if (_globalSettings.SelfHosted) {