mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
[PM-15808]Show suspended org modals for orgs in 'unpaid' & 'canceled' status (#5228)
* Recreate changes on the closed pr Signed-off-by: Cy Okeke <cokeke@bitwarden.com> * Remove unused references Signed-off-by: Cy Okeke <cokeke@bitwarden.com> --------- Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
This commit is contained in:
@ -7,6 +7,7 @@ public record OrganizationMetadata(
|
||||
bool IsSubscriptionUnpaid,
|
||||
bool HasSubscription,
|
||||
bool HasOpenInvoice,
|
||||
bool IsSubscriptionCanceled,
|
||||
DateTime? InvoiceDueDate,
|
||||
DateTime? InvoiceCreatedDate,
|
||||
DateTime? SubPeriodEndDate);
|
||||
|
@ -69,7 +69,7 @@ public class OrganizationBillingService(
|
||||
if (string.IsNullOrWhiteSpace(organization.GatewaySubscriptionId))
|
||||
{
|
||||
return new OrganizationMetadata(isEligibleForSelfHost, isManaged, false,
|
||||
false, false, false, null, null, null);
|
||||
false, false, false, false, null, null, null);
|
||||
}
|
||||
|
||||
var customer = await subscriberService.GetCustomer(organization,
|
||||
@ -79,6 +79,7 @@ public class OrganizationBillingService(
|
||||
|
||||
var isOnSecretsManagerStandalone = IsOnSecretsManagerStandalone(organization, customer, subscription);
|
||||
var isSubscriptionUnpaid = IsSubscriptionUnpaid(subscription);
|
||||
var isSubscriptionCanceled = IsSubscriptionCanceled(subscription);
|
||||
var hasSubscription = true;
|
||||
var openInvoice = await HasOpenInvoiceAsync(subscription);
|
||||
var hasOpenInvoice = openInvoice.HasOpenInvoice;
|
||||
@ -87,7 +88,7 @@ public class OrganizationBillingService(
|
||||
var subPeriodEndDate = subscription?.CurrentPeriodEnd;
|
||||
|
||||
return new OrganizationMetadata(isEligibleForSelfHost, isManaged, isOnSecretsManagerStandalone,
|
||||
isSubscriptionUnpaid, hasSubscription, hasOpenInvoice, invoiceDueDate, invoiceCreatedDate, subPeriodEndDate);
|
||||
isSubscriptionUnpaid, hasSubscription, hasOpenInvoice, isSubscriptionCanceled, invoiceDueDate, invoiceCreatedDate, subPeriodEndDate);
|
||||
}
|
||||
|
||||
public async Task UpdatePaymentMethod(
|
||||
@ -437,5 +438,15 @@ public class OrganizationBillingService(
|
||||
? (true, invoice.Created, invoice.DueDate)
|
||||
: (false, null, null);
|
||||
}
|
||||
|
||||
private static bool IsSubscriptionCanceled(Subscription subscription)
|
||||
{
|
||||
if (subscription == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return subscription.Status == "canceled";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
Reference in New Issue
Block a user